[论文解读] Practical Program Repair in the Era of Large Pre-trained Language Models
本文首次在多个数据集和语言上对最先进的大型 PLMs 在自动化程序修复中的进行广泛评估,结果表明 PLMs 能优于传统 APR 工具,且模型规模越大通常表现越好,且 infilling(填充)/后缀上下文 可提升补丁质量。
Automated Program Repair (APR) aims to help developers automatically patch software bugs. However, current state-of-the-art traditional and learning-based APR techniques face the problem of limited patch variety, failing to fix complicated bugs. This is mainly due to the reliance on bug-fixing datasets to craft fix templates or directly predict potential patches. Large Pre-Trained Language Models (PLMs), trained using billions of text/code tokens, can potentially help avoid this issue. Very recently, researchers have directly leveraged PLMs for APR without relying on any bug-fixing datasets. Meanwhile, such existing work either failed to include state-of-the-art PLMs or was not evaluated on realistic datasets. In this work, we perform the first extensive study on directly applying PLMs for APR. We select 9 recent state-of-the-art PLMs, including both generative and infilling models, ranging from 125M to 20B in size. We designed 3 different repair settings to evaluate the different ways we can use PLMs to generate patches. We apply the PLMs under these repair settings on 5 datasets across 3 different languages and compare different PLMs in the number of bugs fixed, generation speed and compilation rate. Our study demonstrates that directly applying state-of-the-art PLMs can already substantially outperform all existing APR techniques on all our datasets. Among the studied PLMs, the scaling effect exists for APR where larger models tend to achieve better performance. Also, we show for the first time that suffix code after the buggy line (adopted in infilling-style APR) is important in not only generating more fixes but more patches with higher compilation rate. Besides patch generation, the PLMs consider correct patches to be more natural than other ones, and can even be leveraged for effective patch ranking or patch correctness checking.
研究动机与目标
- 评估各种大型 PLMs 在跨多个数据集和语言的自动化程序修复中的表现。
- 将基于 PLM 的 APR 与最先进的传统和基于学习的 APR 工具进行比较。
- 研究修复设置(完整函数生成、infilling、单行生成)如何影响补丁质量和速度。
- 使用如熵等 PLM 派生指标探索补丁排序和正确性检查。
- 确定提升基于 PLM 的 APR 性能的实际指南(样本量、修复模板)。
提出的方法
- 评估 9 个大型 PLMs(125M–20B 参数),包括生成型和 infilling 模型,在 Java、Python 和 C 的 5 个真实世界修复数据集上。
- 三种修复设置:完整函数生成、正确代码 infilling、单行生成。
- 使用提示和少量示例使 PLMs 在没有 bug-fix 训练数据的情况下生成补丁。
- 对每个漏洞使用核采样(top-p、temperature)生成多份补丁,并按补丁熵进行排序。
- 通过运行测试套件来验证补丁,以区分看似合理的补丁和正确的补丁。
- 将基于 PLM 的 APR 与 20 个基线 APR 工具(学习型和传统型)进行比较。
实验结果
研究问题
- RQ1在每种 APR 设置下,不同类型和规模的 PLMs 在各数据集和语言上的表现如何?
- RQ2在真实世界的缺陷上,PLMs 是否优于最先进的 APR 工具?
- RQ3PLMs 是否可以通过熵有效用于补丁排序和正确性检查?
- RQ4哪些策略(更多样本、引入修复模板)可以进一步提升基于 PLM 的 APR 性能?
主要发现
- 更大型的 PLMs 通常在跨数据集上产生更多正确且看似合理的补丁(存在缩放效应)。
- Codex 常常在若干设置中优于其他模型,这归因于面向代码的预训练和微调。
- 带后缀上下文(前缀+后缀)的 infilling 同时提高了修复数量和补丁的编译通过率。
- 在可用后缀上下文时,infilling 模型在单行和 infilling 任务上优于生成型对手。
- 使用正确的代码 infilling 或单行生成获得的正确对看似合理的补丁比完整函数生成更高。
- 随着模型变大,补丁生成速度下降,但 Codex 在某些数据集上推理较慢的同时仍显示出强大的修复能力。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。