arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.09135cs.SE
收藏

HAFix: 历史增强型大语言模型用于缺陷修复

HAFix: History-Augmented Large Language Models for Bug Fixing

Queen’s University(女王大学);Lahore University of Management Sciences(拉合尔管理科学大学)

Yu Shi, Abdul Ali Bangash, Emad Fallahzadeh, Bram Adams, Ahmed E. Hassan

AI总结:

HAFix通过整合历史启发式方法提升LLM在缺陷修复中的性能,实验表明其在缺陷修复率上显著优于基线方法。

摘要:

近期的研究探讨了大型语言模型(LLMs)在各种软件工程(SE)任务上的性能,如代码生成和缺陷修复。然而,这些方法通常依赖于当前项目快照的上下文数据,忽略了现实世界软件仓库中丰富的历史数据的潜力。此外,提示风格对LLM在历史背景下进行软件工程任务的性能影响仍缺乏研究。为解决这些差距,我们提出了HAFix,即用于缺陷修复的历史增强型LLM,是一种新的方法,利用与缺陷相关的七个单独的历史启发式方法,并汇总这些启发式方法的结果(HAFix-Agg)以增强LLM的缺陷修复能力。为了实证评估HAFix,我们使用三种代码LLMs(即Code Llama、DeepSeek-Coder和DeepSeek-Coder-V2-Lite模型)在BugsInPy中的51个单行Python缺陷和Defects4J中的116个单行Java缺陷上进行测试。我们的评估表明,多个HAFix启发式方法在非历史基线(灵感来自GitHub Copilot)上实现了统计学上显著的改进。此外,汇总的HAFix变体HAFix-Agg通过结合各个启发式方法的互补优势,实现了显著的改进,使BugsInPy中的缺陷修复率平均提高了45.05%,使Defects4J中的缺陷修复率平均提高了49.92%。此外,在历史启发式方法的背景下,我们发现指令提示风格是比指令标签和指令掩码更有效的模板,对于LLM在缺陷修复中的表现。最后,我们评估了HAFix在推理时间和令牌使用方面的成本,并提供了成本和缺陷修复性能之间的务实权衡分析,为我们在现实世界场景中的实际部署提供了有价值的见解。

英文摘要:

Recent studies have explored the performance of Large Language Models (LLMs) on various Software Engineering (SE) tasks, such as code generation and bug fixing. However, these approaches typically rely on the context data from the current snapshot of the project, overlooking the potential of rich historical data residing in real-world software repositories. Additionally, the impact of prompt styles on LLM performance for SE tasks within a historical context remains underexplored. To address these gaps, we propose HAFix, which stands for History-Augmented LLMs on Bug Fixing, a novel approach that leverages seven individual historical heuristics associated with bugs and aggregates the results of these heuristics (HAFix-Agg) to enhance LLMs' bug-fixing capabilities. To empirically evaluate HAFix, we employ three Code LLMs (i.e., Code Llama, DeepSeek-Coder and DeepSeek-Coder-V2-Lite models) on 51 single-line Python bugs from BugsInPy and 116 single-line Java bugs from Defects4J. Our evaluation demonstrates that multiple HAFix heuristics achieve statistically significant improvements compared to a non-historical baseline inspired by GitHub Copilot. Furthermore, the aggregated HAFix variant HAFix-Agg achieves substantial improvements by combining the complementary strengths of individual heuristics, increasing bug-fixing rates by an average of 45.05% on BugsInPy and 49.92% on Defects4J relative to the corresponding baseline. Moreover, within the context of historical heuristics, we identify the Instruction prompt style as the most effective template compared to the InstructionLabel and InstructionMask for LLMs in bug fixing. Finally, we evaluate the cost of HAFix in terms of inference time and token usage, and provide a pragmatic trade-off analysis of the cost and bug-fixing performance, offering valuable insights for the practical deployment of our approach in real-world scenarios.

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

↑