[论文解读] Less Training, More Repairing Please: Revisiting Automated Program Repair via Zero-shot Learning
本文提出 AlphaRepair,一种零样本、填空式(cloze-style)的自动化程序修复技术,利用 CodeBERT 等大规模预训练代码模型,无需在错误修复数据集上进行微调。通过直接从上下文代码片段中预测正确的代码行,AlphaRepair 在 Defects4J 和 QuixBugs 上实现了最先进(SOTA)的修复效果,在 Defects4J 2.0 上比最佳基线多修复了 3.3 倍的错误,并展现出对 Java 和 Python 的强大多语言修复能力。
Due to the promising future of Automated Program Repair (APR), researchers have proposed various APR techniques, including heuristic-based, template-based, and constraint-based techniques. Among such classic APR techniques, template-based techniques have been widely recognized as state of the art. However, such template-based techniques require predefined templates to perform repair, and their effectiveness is thus limited. To this end, researchers leveraged the recent advances in Deep Learning to further improve APR. Such learning-based techniques view APR as a Neural Machine Translation problem, using the buggy/fixed code snippets as the source/target languages for translation. In this way, such techniques heavily rely on large numbers of high-quality bug-fixing commits, which can be extremely costly and challenging to construct. Furthermore, the edit variety of these learning-based techniques are limited to the available bug-fixes within their training datasets. Therefore, in this paper, we aim to revisit the learning-based APR problem, and propose AlphaRepair, to leverage zero-shot learning directly using large pre-trained code models for APR. Our main insight is instead of modeling what a repair edit should look like, we can directly predict what the correct code is based on the context information. We have implemented AlphaRepair as a practical multilingual APR tool based on the recent CodeBERT model. Our results on the widely used Defects4J benchmark show that AlphaRepair can substantially outperform state-of-the-art APR tools. We also studied the impact of different design choices and show that AlphaRepair performs even better on a newer version of Defects4J (2.0) with 3.3X more fixes than best performing baseline, indicating that AlphaRepair can potentially avoid the dataset-overfitting issue of existing learning-based techniques.
研究动机与目标
- 解决现有基于学习的程序修复(APR)技术依赖大规模高质量错误修复数据集进行微调所带来的局限性。
- 探索预训练代码模型是否可直接用于零样本设置下的程序修复,而无需任何任务特定的训练。
- 评估该方法在 Defects4J 和 QuixBugs 等标准基准上的有效性与泛化能力。
- 探究该方法是否可在不重新训练或为每种语言单独构建模型的前提下,支持多语言程序修复。
提出的方法
- AlphaRepair 将程序修复建模为填空任务,即根据周围上下文预测正确的代码行,而非将修复视为序列到序列的翻译任务。
- 通过将 CodeBERT 的预训练目标(掩码语言建模)应用于修复任务,即对错误代码行进行掩码,并提示模型预测正确的修复内容。
- 输入通过将错误代码行替换为 [MASK] 标记而构建,同时保留周围代码上下文,从而实现使用预训练模型直接进行推理。
- 该模型未在任何历史错误修复对上进行微调;相反,它直接使用 CodeBERT 的冻结权重进行修复任务的推理。
- 该方法被实现为一个多语言 APR 工具,利用 CodeBERT 在六种编程语言(Java、Python、Go、PHP、JavaScript、Ruby)上联合预训练的特性。
- 通过编译和测试套件执行验证生成补丁的正确性,辅以人工检查以确认语义正确性。
实验结果
研究问题
- RQ1预训练代码模型是否可直接用于自动化程序修复,而无需在错误修复数据集上进行任何微调?
- RQ2填空式修复方法是否优于传统的基于神经机器翻译(NMT)的基于学习的 APR 技术?
- RQ3零样本方法是否可在不同编程语言间泛化,实现在不重新训练情况下的多语言修复?
- RQ4该方法是否避免了数据集过拟合,特别是在更新、更大的基准(如 Defects4J 2.0)上评估时?
主要发现
- AlphaRepair 在 Defects4J 1.2 上生成了最多正确补丁(28 个),在 Defects4J 2.0 上也以 27 个补丁的数量领先所有基线。
- 在 Defects4J 2.0 上,AlphaRepair 比表现最佳的基线多修复了 3.3 倍的错误,展现出强大的泛化能力与更低的过拟合风险。
- AlphaRepair 在 QuixBugs 的 Java 和 Python 版本上均取得了最先进结果,证实了其多语言修复能力。
- 即使排除了 CodeBERT 训练数据中包含的 15 个重叠错误,AlphaRepair 仍优于所有基线,表明其鲁棒性超越了数据泄露的影响。
- 对重叠错误代码片段的人工扰动实验表明,AlphaRepair 的泛化能力超越了记忆化修复,不依赖于数据集中的精确匹配。
- 通过掩码代码建模实现的零样本填空式预测方法,显著优于需要在历史修复数据上进行大量微调的 NMT 基于学习的 APR 方法。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。