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.
翻译:自动程序修复(APR)可帮助开发者自动为缺陷生成补丁。由于大型预训练语言模型(LLM)在许多代码相关任务中展现出卓越性能,研究者已开始直接采用LLM进行APR。然而,现有方法仅基于原始缺陷代码构建输入/提示,并反复对LLM进行重复采样,这不仅导致反复生成相同的错误补丁,还忽略了测试用例中的关键信息。为解决这些问题,我们提出对话式APR——一种以对话方式交替进行补丁生成与验证的程序修复新范式。在对话式APR中,我们通过将先前生成的补丁与验证反馈相结合,迭代构建模型输入。由此,我们利用LLM的长程上下文窗口,不仅避免生成先前错误的补丁,还能融入验证反馈以帮助模型理解被测程序的语义含义。我们评估了包括新开发的ChatGPT模型在内的10种不同LLM,以证明对话式APR相较于先前基于LLM的APR方法所带来的改进。