[论文解读] Conversational Automated Program Repair
简述:本文提出对话式 APR,一种基于 LLM 的方法,交替进行 patch 生成和带反馈的验证,在多种模型和基准上相对于传统采样方法提升了修复效果。
Automated Program Repair (APR) can help developers automatically generate patches for bugs. Due to the impressive performance obtained using Large Pre-Trained Language Models (LLMs) on many code related tasks, researchers have started to directly use LLMs for APR. However, prior approaches simply repeatedly sample the LLM given the same constructed input/prompt created from the original buggy code, which not only leads to generating the same incorrect patches repeatedly but also miss the critical information in testcases. To address these limitations, we propose conversational APR, a new paradigm for program repair that alternates between patch generation and validation in a conversational manner. In conversational APR, we iteratively build the input to the model by combining previously generated patches with validation feedback. As such, we leverage the long-term context window of LLMs to not only avoid generating previously incorrect patches but also incorporate validation feedback to help the model understand the semantic meaning of the program under test. We evaluate 10 different LLM including the newly developed ChatGPT model to demonstrate the improvement of conversational APR over the prior LLM for APR approach.
研究动机与目标
- 通过利用来自测试结果的反馈的 LLM 在 APR 中减少手动工作量。
- 提出对话式 APR,交替进行 patch 生成和验证,以利用 LLM 的长上下文能力。
- 表明结合验证反馈和先前生成的 patch 能提高 patch 的多样性和在多模型上的成功率。
- 在一个标准的 bug fix 基准上,对 10 LLMs(包括 ChatGPT)评估对话式 APR,以评估有效性和效率。
提出的方法
- 将对话轮转定义为生成 patch、对其进行验证,并提取反馈。
- 构造输入提示,将先前的 patch 及其验证反馈串联起来,以指导后续生成。
- 使用最大链长来管理 LLM 上下文,并在需要时自动用新链重启。
- 在相同提示下,将对话式 APR 与基线采样方法进行对比。
- 使用多个 LLMs(CodeGen 变体、Codex、ChatGPT)对 QuixBugs 的 Python 和 Java 进行评估。

实验结果
研究问题
- RQ1RQ1:相比基线采样的 LLM APR,对话式 APR 的效果如何?
- RQ2RQ2:不同组件(chain length、验证提示)如何影响性能?
- RQ3RQ3:在同一基准上,ChatGPT 相对于其他 LLMs 的对话式 APR 表现如何?
- RQ4RQ4:提示风格和验证反馈对修复结果的影响是什么?
主要发现
- 对话式 APR 在不同规模的无监督 LLMs 上,相较于基线采样,提升了正确且合理 patch 的数量。
- 更长的链长在一个模型依赖的点上有帮助(CodeGen 大约 3–4 次转;更大模型能更好地处理更长的链)。
- 功能性验证提示(用测试输入调用函数)在提示风格中带来最佳结果。
- 在此设置中,ChatGPT 通常优于 Codex,得益于其面向对话的训练和 RLHF。
- 使用验证反馈减少重复 patch,降低达到可行/正确 patch 所需的样本数(尝试次数)。

更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。