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

基于大语言模型的程序自动修复

Automated Repair of Programs from Large Language Models

Zhiyu Fan, Xiang Gao, Martin Mirchev, Abhik Roychoudhury, Shin Hwei Tan

摘要:

像Codex这样的大语言模型已经显示出为许多编程任务生成代码的能力。然而,现有模型的成功率很低,特别是对于复杂的编程任务。原因之一是语言模型缺乏对程序语义的认识,导致程序不正确,甚至不能编译。在本文中,我们系统地研究了自动程序修复(APR)技术是否可以修复LeetCode竞赛中由语言模型产生的错误解决方案。我们的目标是研究APR技术是否可以提高可靠性的代码产生的大语言模型。我们的研究显示:(1)自动生成的代码与人工制作的解决方案共享常见的编程错误,这表明APR技术可能具有修复自动生成的代码的潜力;(2)给定由统计错误定位方法提供的错误位置信息,新发布的Codex编辑模式(支持编辑代码)在修复错误解决方案方面类似于或优于现有的Java修复工具TBar和Codder。通过分析这些工具产生的实验结果,我们提供了几个建议:(1)增强APR工具,以超越补丁空间的限制(例如,引入更灵活的错误定位)是期望的;(2)由于大语言模型可以通过在更多数据上训练来导出更多修复模式,未来的APR工具可以将焦点从添加更多修复模式转移到基于合成/语义的方法,(3)语言模型与APR的组合以策展补丁成分是值得研究的。

英文摘要:

Large language models such as Codex, have shown the capability to produce code for many programming tasks. However, the success rate of existing models is low, especially for complex programming tasks. One of the reasons is that language models lack awareness of program semantics, resulting in incorrect programs, or even programs which do not compile. In this paper, we systematically study whether automated program repair (APR) techniques can fix the incorrect solutions produced by language models in LeetCode contests. The goal is to study whether APR techniques can enhance reliability in the code produced by large language models. Our study revealed that: (1) automatically generated code shares common programming mistakes with human-crafted solutions, indicating APR techniques may have potential to fix auto-generated code; (2) given bug location information provided by a statistical fault localization approach, the newly released Codex edit mode, which supports editing code, is similar to or better than existing Java repair tools TBar and Recoder in fixing incorrect solutions. By analyzing the experimental results generated by these tools, we provide several suggestions: (1) enhancing APR tools to surpass limitations in patch space (e.g., introducing more flexible fault localization) is desirable; (2) as large language models can derive more fix patterns by training on more data, future APR tools could shift focus from adding more fix patterns to synthesis/semantics based approaches, (3) combination of language models with APR to curate patch ingredients, is worth studying.

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

↑