arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2404.08877cs.SEcs.CLcs.LG
收藏

对齐基于大语言模型的程序修复目标

Aligning the Objective of LLM-based Program Repair

The Chinese University of Hong Kong, Shenzhen(香港中文大学(深圳));Chongqing University(重庆大学);Concordia University(康考迪亚大学)

Junjielong Xu, Ying Fu, Shin Hwei Tan, Pinjia He

AI总结:

针对LLM训练目标与现有填充式程序修复方法目标错位、受限于预设缺陷位置的问题,提出对齐训练目标、直接调试全程序的D4C提示框架,在Defects4J上性能超完美定位的SOTA方法10%,采样量降90%。

摘要:

大语言模型(LLM)已在自动化程序修复(APR)领域取得了不错的成果。然而,仅解码器架构的LLM(如GPT-4)的下一词元预测训练目标,与当前填充式方法的掩码跨度预测目标存在错位,这阻碍了LLM充分利用预训练知识开展程序修复。此外,尽管部分LLM能够借助相关工件(如测试用例)定位并修复特定函数中的缺陷,但现有方法仍依赖语句级缺陷定位方法提供待修复的缺陷代码块列表。这一限制使得LLM无法探索给定位置之外的潜在补丁。\n本文研究了一种使LLM适配程序修复的新方法。我们的核心洞见是,只需让输出对齐LLM的训练目标,并允许其在不预先识别缺陷语句的情况下对整个程序进行优化,就能大幅提升LLM的APR能力。基于这一洞见,我们设计了D4C——一种简洁的APR提示框架。D4C在Defects4J数据集上可正确修复180个缺陷,每个补丁仅采样10次。这一表现超过了具备完美缺陷定位能力的当前最优(SOTA)APR方法10%,且补丁采样数量减少了90%。我们的研究结果表明:(1)目标对齐对于充分发挥LLM的预训练能力至关重要;(2)对于基于LLM的APR方法,用直接调试替代传统的“定位缺陷代码块再修复”工作流更有效。因此,我们认为本文为利用LLM开展APR研究引入了新思路。

英文摘要:

Large language models (LLMs) have achieved decent results on automated program repair (APR). However, the next token prediction training objective of decoder-only LLMs (e.g., GPT-4) is misaligned with the masked span prediction objective of current infilling-style methods, which impedes LLMs from fully leveraging pre-trained knowledge for program repair. In addition, while some LLMs can locate and repair bugs in certain functions using the related artifacts (e.g., test cases), existing methods still depend on statement-level fault localization methods to provide a list of buggy hunks for repair. This restriction hinders LLMs from exploring potential patches beyond the given locations. In this paper, we investigate a new approach to adapt LLMs to program repair. Our core insight is that LLM's APR capability can be greatly improved by simply aligning the output to their training objective and allowing them to refine the whole program without first identifying faulty statements. Based on this insight, we designed D4C, a straightforward prompting framework for APR. D4C can repair 180 bugs correctly in Defects4J, with each patch being sampled only 10 times. This surpasses the SOTA APR methods with perfect fault localization by 10% and reduces the patch sampling number by 90%. Our findings reveal that (1) objective alignment is crucial for fully exploiting LLM's pre-trained capability, and (2) replacing the traditional localize-buggy-hunks-then-repair workflow with direct debugging is more effective for LLM-based APR methods. Thus, we believe this paper introduces a new mindset for harnessing LLMs in APR.

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

↑