Large language models (LLMs) have shown impressive effectiveness in various software engineering tasks, including automated program repair (APR). In this study, we take a deep dive into automated bug fixing utilizing LLMs. In contrast to many deep learning-based APR methods that assume known bug locations, rely on line-level localization tools, or address bug prediction and fixing in one step, our approach uniquely employs LLMs to predict bug location at the token level and subsequently utilizes them for bug fixing. This methodological separation of bug localization and fixing using different LLMs enables effective integration of diverse contextual information and improved incorporation of inductive biases. We introduce Toggle: Token-Granulated Bug Localization and Repair, a comprehensive program repair framework that integrates a bug localization model, an adjustment unit, and a bug-fixing model. Toggle takes a buggy function as input and generates a complete corrected function. We investigate various styles of prompting to the bug fixing model to identify the most effective prompts that better utilize the inductive bias and significantly outperform others. Toggle achieves the new state-of-the-art (SOTA) performance on the CodeXGLUE code refinement benchmark, and exhibits better and comparable performance on several other widely-used APR datasets, including Defects4J.
翻译:大型语言模型(LLM)已在各类软件工程任务中展现出显著效果,包括自动化程序修复(APR)。本研究深入探讨了利用LLM实现自动化缺陷修复的技术路径。与众多基于深度学习的APR方法不同——这些方法或假定已知缺陷位置、或依赖行级定位工具、或采用缺陷预测与修复一体化的处理方式——我们的方法创新性地采用LLM进行令牌级缺陷位置预测,并进一步利用其完成修复。通过将缺陷定位与修复这两个环节交由不同LLM完成,该方法不仅实现了多样化上下文信息的有效整合,还增强了归纳偏置的融入效果。我们提出Toggle:令牌粒度缺陷定位与修复框架——一种集成缺陷定位模型、调节单元与缺陷修复模型的综合性程序修复框架。Toggle以包含缺陷的函数作为输入,直接输出完整的修正后函数。我们系统探讨了面向缺陷修复模型的多种提示策略,旨在甄别最能有效利用归纳偏置且显著优于其他方案的提示方法。Toggle在CodeXGLUE代码精炼基准测试中达到了最新最优(SOTA)性能,并在包括Defects4J在内的多个广泛使用的APR数据集上表现出与现有方法相当乃至更优的性能。