[论文解读] APPT: Boosting Automated Patch Correctness Prediction via Fine-tuning Pre-trained Models
APPT 提出了一种微调预训练模型的方法,用于程序修复中的自动补丁正确性预测,结合 BERT 作为编码器与 LSTM 及分类器,以提升泛化能力。在 Defects4J 补丁上,其准确率达到 79.7%,召回率达到 83.2%,分别优于最先进方法(SOTA)4.3% 和 6.7%。在真实世界补丁上,五项指标超过 99%。
Automated program repair (APR) aims to fix software bugs automatically without human debugging efforts and plays a crucial role in software development and maintenance. Despite promising, APR is still challenged by a long-standing overfitting problem (i.e., the generated patch is plausible but overfitting). Various techniques have thus been proposed to address the overfitting problem. Recently, researchers have employed BERT to extract code features, which are then used to train a classifier for patch correctness prediction. However, BERT is restricted to feature extraction for classifier training without benefiting from the training process, potentially generating sub-optimal vector representations for patched code snippets. In this paper, we propose APPT, a pre-trained model-based automated patch correctness assessment technique by both pre-training and fine-tuning. APPT adopts a pre-trained model as the encoder stack, followed by an LSTM stack and a deep learning classifier. More importantly, the pre-trained model is fine-tuned in conjunction with other components as a whole pipeline to fully adapt it specifically for reasoning about patch correctness. We conduct an extensive experiment on 1,183 Defects4J patches and the experimental results show that APPT achieves prediction accuracy of 79.7% and recall of 83.2%, outperforming CACHE by 4.3% and 6.7%. Our additional investigation on 49,694 real-world patches shows that APPT achieves the optimum performance compared with existing representation learning techniques. We further investigate the impact of each component and find that they all positively contribute to APPT, e.g., the fine-tuning process and the LSTM stack increase F1-score by 10.22% and 4.11%, respectively. We also prove that adopting advanced pre-trained models can further provide substantial advancement, highlighting the generalizability of APPT.
研究动机与目标
- 解决自动化程序修复(APR)中的过拟合问题,即补丁通过测试用例但在未见数据上失败。
- 克服静态与动态补丁正确性评估技术的局限性,后者存在精度低或计算成本高的问题。
- 利用预训练模型学习更优的代码表征以用于补丁正确性预测,提升超越手工特征的泛化能力。
- 探索端到端微调预训练模型在补丁正确性预测中的有效性,而非仅将其用于特征提取。
- 验证该方法在不同预训练模型(包括 BERT、CodeBERT 和 GraphCodeBERT)上的泛化能力。
提出的方法
- 使用预训练的 BERT 模型作为编码器堆栈,从有错误和已修复的代码片段中提取上下文表征。
- 在编码器后集成一个 LSTM 层,以建模代码变更及其上下文之间的序列依赖关系。
- 将 LSTM 输出送入一个包含两个全连接层和 softmax 激活函数的深度学习分类器,实现补丁正确性的二分类。
- 端到端地微调整个流程——包括编码器、LSTM 和分类器——以使模型专门适应补丁正确性推理任务。
- 在合成数据集(Defects4J)和真实世界数据集(49,694 个补丁)上评估模型,以检验其鲁棒性与可扩展性。
- 使用标准指标(如精确率、召回率、F1 和 AUC)与现有技术(包括 CACHE 和手工特征方法)进行比较。

实验结果
研究问题
- RQ1与仅使用特征提取的方法相比,端到端微调预训练模型是否能提升补丁正确性预测的准确率?
- RQ2集成 LSTM 层如何影响模型捕捉代码变更依赖关系的能力?
- RQ3APPT 是否能在不同预训练模型(如 CodeBERT 和 GraphCodeBERT)上泛化?它们是否优于基于 BERT 的 APPT?
- RQ4与现有最先进方法相比,APPT 在真实世界补丁上的表现如何?
- RQ5每个组件(如微调、LSTM)对整体性能提升的贡献是什么?
主要发现
- 在 1,183 个 Defects4J 补丁上,APPT 达到 79.7% 的准确率和 83.2% 的召回率,分别优于最先进方法 CACHE 4.3 个百分点和 6.7 个百分点。
- 在 49,694 个真实世界补丁上,APPT 在五项标准评估指标中均超过 99%,展现出强大的泛化能力和鲁棒性。
- 仅微调过程本身便使 F1 分数提升 10.22%,表明其在适应补丁正确性任务中的关键作用。
- LSTM 组件对 F1 分数提升贡献了 4.11%,凸显其在建模代码变更序列依赖关系方面的价值。
- 在 APPT 中使用 GraphCodeBERT 替代 BERT,使精确率提升 2.8%,AUC 提升 3.3%,证实了先进预训练模型的优势。
- 消融实验表明,所有组件——编码器、LSTM 和分类器——均对性能有正向贡献,验证了设计选择的有效性。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。