一句话:提出 Repilot,用补全引擎引导 LLM 生成补丁,在 APR 中提升补丁有效性与修复数。
自动程序修复(APR)难以为通用语言真实系统合成正确补丁。近期大语言模型(LLM)可作为编程“副驾驶”直接生成补丁,但它们通常将程序视为 token 序列,忽略目标语言的语义约束,导致大量静态无效补丁,影响实用性。为此,作者提出 Repilot 框架,用补全引擎进一步“副驾驶”LLM。其核心洞见是 LLM 自回归逐 token 生成类似人类写程序,可由补全引擎显著增强和引导。Repilot 让 LLM 与补全引擎交互合成候选补丁:剪除 LLM 建议的不可行 token,并根据补全引擎建议主动补全 token。在 Defects4j 1.2 与 2.0 子集上,Repilot 分别修复 66 和 50 个缺陷,比最佳基线多修 14 和 16 个;相同生成预算下能产生更多有效且正确的补丁。
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 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 fixes 66 and 50 bugs, respectively, surpassing the best-performing baseline by 14 and 16 bugs fixed. More importantly, Repilot is capable of producing more valid and correct patches than the base LLM when given the same generation budget.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-2309-00608,
title = {Copiloting the Copilots: Fusing Large Language Models with Completion Engines for Automated Program Repair},
author = {Yuxiang Wei and Chunqiu Steven Xia and Lingming Zhang},
booktitle = {FSE},
year = {2023},
doi = {10.1145/3611643.3616271}
}