arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.00608cs.SEcs.LGcs.PL
收藏

为副驾驶提供副驾驶支持:融合大语言模型与补全引擎的自动化程序修复方法

Copiloting the Copilots: Fusing Large Language Models with Completion Engines for Automated Program Repair

University of Illinois(伊利诺伊大学);University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校)

Yuxiang Wei, Chunqiu Steven Xia, Lingming Zhang

AI总结:

针对大语言模型用于自动化程序修复时因忽略编程语言语义约束而生成大量无效补丁的问题,提出融合LLM与补全引擎的Repilot框架,通过交互协同剪枝不可行token、主动补全token,在Defects4j数据集上显著提升bug修复数量与补丁有效性。

摘要:

在自动化程序修复(Automated Program Repair, APR)过程中,为通用编程语言编写的真实系统生成正确补丁通常颇具挑战。近期的大语言模型(Large Language Models, LLMs)已被证明是辅助开发者完成各类编码任务的得力“副驾驶”,也已被直接应用于补丁合成。然而,大多数LLM将程序视为token序列,意味着它们不了解目标编程语言的底层语义约束,这会导致生成大量静态无效的补丁,阻碍了该技术的实用性。\n为此,我们提出Repilot——一个通用代码生成框架,通过在修复过程中合成更多有效补丁,进一步为AI“副驾驶”(即LLM)提供副驾驶支持。我们的核心洞见是:许多LLM以自回归方式(即逐token)生成输出,这一过程类似人类编写程序,可通过补全引擎(Completion Engine)得到显著增强与引导。\nRepilot通过LLM与补全引擎的交互协同合成候选补丁,具体机制包括:1)剪枝LLM建议的不可行token;2)基于补全引擎提供的建议主动补全token。我们在广泛使用的Defects4j 1.2和2.0数据集的子集上开展评估,结果显示Repilot的表现优于现有最优技术,修复的bug数量分别多出27%和47%。此外,在相同计算预算下,Repilot生成的有效补丁与正确补丁数量均多于基础LLM。尽管本工作聚焦于将Repilot应用于APR任务,该整体方法同样可推广至其他代码生成任务。

英文摘要:

During Automated Program Repair (APR), it can be challenging to synthesize correct patches for real-world systems in general-purpose programming languages. Recent Large Language Models (LLMs) have been shown to be helpful "copilots" in assisting developers with various coding tasks, and have also been directly applied for patch synthesis. However, most LLMs treat programs as sequences of tokens, meaning that they are ignorant of the underlying semantics constraints of the target programming language. This results in plenty of statically invalid generated patches, impeding the practicality of the technique. Therefore, we propose Repilot, a general code generation framework to further copilot the AI "copilots" (i.e., LLMs) by synthesizing more valid patches during the repair process. Our key insight is that many LLMs produce outputs autoregressively (i.e., token by token), resembling human writing programs, which can be significantly boosted and guided through a Completion Engine. Repilot synergistically synthesizes a candidate patch through the interaction between an LLM and a Completion Engine, which 1) prunes away infeasible tokens suggested by the LLM and 2) proactively completes the token based on the suggestions provided by the Completion Engine. Our evaluation on a subset of the widely-used Defects4j 1.2 and 2.0 datasets shows that Repilot outperforms state-of-the-art techniques by fixing 27% and 47% more bugs, respectively. Moreover, Repilot produces more valid and correct patches than the base LLM with the same budget. While we focus on leveraging Repilot for APR in this work, the overall approach is also generalizable to other code generation tasks.

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

↑