Skip to main content
QUICK REVIEW

[论文解读] Evaluating Representation Learning of Code Changes for Predicting Patch Correctness in Program Repair

Haoye Tian, Kui Liu|arXiv (Cornell University)|Aug 7, 2020
Software Engineering Research参考文献 65被引用 6
一句话总结

本文评估了分布式表示学习技术——特别是 BERT、Doc2Vec、code2vec 和 CC2Vec——在自动化程序修复中预测补丁正确性方面的表现。通过在基于 BERT 的代码变更嵌入上训练逻辑回归分类器,该方法在 1,000 个去重标记补丁数据集上实现了 AUC 0.8 的性能,表明学习到的嵌入能够有效识别错误补丁,并优于基于动态分析的方法(如 PATCH-SIM)。

ABSTRACT

A large body of the literature of automated program repair develops approaches where patches are generated to be validated against an oracle (e.g., a test suite). Because such an oracle can be imperfect, the generated patches, although validated by the oracle, may actually be incorrect. While the state of the art explore research directions that require dynamic information or rely on manually-crafted heuristics, we study the benefit of learning code representations to learn deep features that may encode the properties of patch correctness. Our work mainly investigates different representation learning approaches for code changes to derive embeddings that are amenable to similarity computations. We report on findings based on embeddings produced by pre-trained and re-trained neural networks. Experimental results demonstrate the potential of embeddings to empower learning algorithms in reasoning about patch correctness: a machine learning predictor with BERT transformer-based embeddings associated with logistic regression yielded an AUC value of about 0.8 in predicting patch correctness on a deduplicated dataset of 1000 labeled patches. Our study shows that learned representations can lead to reasonable performance when comparing against the state-of-the-art, PATCH-SIM, which relies on dynamic information. These representations may further be complementary to features that were carefully (manually) engineered in the literature.

研究动机与目标

  • 探究学习到的代码表示是否能够提升自动化程序修复中补丁正确性的预测能力。
  • 评估预训练和微调神经网络在生成捕捉错误代码与修复后代码之间语义和语法差异的嵌入表示方面的有效性。
  • 将基于表示学习的方法与依赖于动态执行轨迹的最先进方法进行性能比较。
  • 评估学习到的嵌入与手动构建的静态特征(如 ODS 中的特征)之间的互补性。
  • 为将表示学习整合到 APR 流程中以过滤错误补丁提供实证指导。

提出的方法

  • 在代码变更片段(错误代码与修复后代码)上应用多种表示学习模型——BERT、Doc2Vec、code2vec 和 CC2Vec——以生成稠密向量嵌入。
  • 使用错误代码与修复后代码嵌入之间的余弦相似度计算相似度得分,用于过滤错误补丁。
  • 在学习到的嵌入上训练监督式机器学习分类器(逻辑回归、决策树、朴素贝叶斯)以预测补丁正确性。
  • 在 APR 数据集上对 BERT 及其他模型进行微调,以提升领域特定表示的质量。
  • 对 1,000 个标记补丁的数据集应用去重处理,以确保评估的稳健性。
  • 将学习到的嵌入与手工构建的静态特征(如 ODS 特征)结合,以评估其在预测性能上的互补性。

实验结果

研究问题

  • RQ1预训练并微调的神经网络模型是否能够生成有效区分正确与错误补丁的代码变更嵌入?
  • RQ2不同表示学习模型(如 BERT、Doc2Vec、code2vec、CC2Vec)在捕捉补丁正确性信号方面的能力如何比较?
  • RQ3基于余弦相似度的相似度阈值,学习到的嵌入在多大程度上能够过滤出错误补丁?
  • RQ4使用学习到的嵌入的机器学习预测器的性能,与依赖于动态执行轨迹的最先进方法(如 PATCH-SIM)相比如何?
  • RQ5学习到的嵌入是否能与手工构建的静态特征有效结合,以提升补丁正确性预测性能?

主要发现

  • 基于 BERT 的嵌入模型在与逻辑回归结合使用时,在 1,000 个去重标记补丁数据集上实现了 AUC 0.8 的性能,表明其在预测补丁正确性方面具有强大的预测能力。
  • 基于学习到的嵌入计算出的余弦相似度得分,根据所用的相似度阈值,可过滤掉 31.5% 至 94.9% 的错误补丁。
  • 使用 BERT 嵌入的逻辑回归模型(F-measure: 0.72,AUC: 0.8)在相同评估设置下,性能优于最先进方法 PATCH-SIM(基于动态分析)。
  • 学习到的嵌入在与 ODS 等手工构建的静态特征结合时表现出互补价值,表明混合预测方法具有潜力。
  • 在 APR 特定数据上对 BERT 等预训练模型进行微调,相比使用冻结的预训练状态,能显著提升学习嵌入的判别能力。
  • 在所评估的模型中,BERT 和 CC2Vec 生成的嵌入在正确性预测方面最为有效,而 Doc2Vec 和 code2vec 在此特定任务上的表现较低。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。