arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.07138cs.SE
收藏

前所未有的代码变更自动化:LLM 与示例驱动转换的融合

Unprecedented Code Change Automation: The Fusion of LLMs and Transformation by Example

Malinda Dilhara, Abhiram Bellur, Timofey Bryksin, Danny Dig

AI总结:

本文提出结合 LLM、静态与动态分析的 PyCraft,通过生成语义等价的代码变更变体增强 TBE,并在实验与开源项目补丁提交中验证其高准确率和实用性。

摘要:

软件开发人员经常在项目内部和跨项目之间重复进行代码变更,这些变更被称为“代码变更模式”(CPAT)。自动化这些 CPAT 可加速开发,但当前的示例驱动转换(TBE)技术受限于输入示例的质量和数量,会遗漏语法或控制流不同但语义相似的变体。在海量代码数据集上训练的大型语言模型(LLM)能够通过生成语义等价且此前未见的 CPAT 变体来克服这些限制,从而提升 TBE 的有效性。我们确定了使用 LLM 生成满足正确性、有用性和适用性标准的代码变体的最佳实践。将这些实践实现于 PyCraft 中,并结合静态与动态分析以及 LLM,我们在识别正确变体方面取得了 96.6% 的 F-measure,将输入平均扩展 58 倍,并通过自动化变更使目标代码最多增加 39 倍。来自 PyCraft 的补丁已提交到 microsoft/DeepSpeed 和 IBM/inFairness 等项目,接受率达到 83%,验证了我们方法的有用性。

英文摘要:

Software developers often repeat code changes, known as "code change patterns" (CPATs), within and across projects. Automating these CPATs accelerates development, but current Transformation by Example (TBE) techniques are limited by the input examples' quality and quantity, missing variations with different syntax or flow yet semantically similar. Large Language Models (LLMs), trained on vast code datasets, can overcome these limitations by generating semantically equivalent, unseen CPAT variants, enhancing TBE effectiveness. We identified best practices for using LLMs to generate code variants meeting criteria of correctness, usefulness, and applicability. Implementing these in PyCraft, combining static and dynamic analysis with LLMs, we achieved an F-measure of 96.6% in identifying correct variants, expanding inputs by 58x on average, and automating changes to increase target codes by up to 39x. Patches from PyCraft were submitted to projects like microsoft/DeepSpeed and IBM/inFairness, with an 83% acceptance rate, validating our approach's usefulness.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑