[论文解读] Neural Program Repair by Jointly Learning to Localize and Repair
本文提出一种联合神经模型,使用多头指针网络定位并修复 VarMisuse(变量误用)错误,预测结果优于枚举修复方法和基于图的基线。
Due to its potential to improve programmer productivity and software quality, automated program repair has been an active topic of research. Newer techniques harness neural networks to learn directly from examples of buggy programs and their fixes. In this work, we consider a recently identified class of bugs called variable-misuse bugs. The state-of-the-art solution for variable misuse enumerates potential fixes for all possible bug locations in a program, before selecting the best prediction. We show that it is beneficial to train a model that jointly and directly localizes and repairs variable-misuse bugs. We present multi-headed pointer networks for this purpose, with one head each for localization and repair. The experimental results show that the joint model significantly outperforms an enumerative solution that uses a pointer based model for repair alone.
研究动机与目标
- 推动对变量误用(VarMisuse)错误的自动修复,以提升程序员工作效率和软件质量。
- 用一个联合对错误进行分类、定位和修复的模型取代枚举修复。
- 利用指针网络在输入程序中指向错误位置并修复变量。
- 在大型 Python 和 C# 数据集上,将所提联合模型与先前的枚举方法和基于图的基线进行比较评估。
提出的方法
- 在 LSTM 编码器之上使用多头指针网络联合预测漏洞位置和修复变量。
- 将程序表示为令牌序列,并对令牌和变量进行嵌入。
- 使用从正确程序派生的合成带错和无错示例进行训练,使用 Loc 和 Rep 指针作为监督。
- 将 VarMisuseRepair 定义为输出一个定位符令牌(或无错)以及一个来自程序作用域的修复令牌。
- 将联合模型与逐槽预测修复并汇总结果的枚举修复方法进行比较。
- 使用 ETH-Py150(Python)和 MSR-VarMisuse(C#)数据集进行评估,指标包括真正例、定位和定位+修复准确率。
实验结果
研究问题
- RQ1联合 VarMisuseRepair 模型是否能比枚举修复方法更有效地同时定位和修复错误?
- RQ2未知错误的存在如何影响非枚举设定下的修复准确性?
- RQ3当仅限于句法信息时,基于指针网络的方法与基于图的 VarMisuse 修复模型相比如何?
- RQ4槽位放置不正确对枚举模型与联合模型的修复性能有何影响?
主要发现
| 模型 | 真正阳性 | 分类准确率 | 定位准确率 | 定位+修复准确率 |
|---|---|---|---|---|
| Enumerative (tau=0.99) | 99.9% | 53.5% | 7.0% | 7.0% |
| Enumerative (tau=0.5) | 95.3% | 63.8% | 28.7% | 27.1% |
| Enumerative (tau=0.3) | 81.? | 68.6% | 44.2% | 39.7% |
| Enumerative (tau=0.2) | 66.3% | 70.6% | 54.3% | 47.4% |
| Enumerative (tau=0.0) | 42.2% | 71.1% | 64.6% | 55.8% |
| Enumerative (Top-k=1) | 91.7% | 63.6% | 27.2% | 24.8% |
| Enumerative (Top-k=3) | 64.9% | 70.1% | 49.6% | 43.2% |
| Enumerative (Top-k=5) | 50.9% | 70.9% | 58.4% | 50.4% |
| Enumerative (Top-k=10) | 43.5% | 71.1% | 63.6% | 54.8% |
| Enumerative (Top-k=∞) | 42.2% | 71.1% | 64.6% | 55.8% |
| Joint (proposed) | 84.5% | 82.4% | 71% | 65.7% |
- 联合模型在多种设置下的定位准确率为 71%,定位+修复准确率为 65.7%,优于枚举基线;真正阳性率为 84.5%,分类准确率为 82.4%。
- 当预测槽位不正确或阈值调整时,枚举方法在定位和修复准确率上有显著下降,例如在某些阈值下定位从 64.6% 降至 7.0%。
- 在 ETH-Py150 上,联合模型在定位方面比枚举方法的最低阈值/最高 Top-k 配置提高约 6.4 个百分点,定位+修复约提高 9.9 点。
- 当仅限于句法输入时,基于指针网络的联合建模在 MSR-VarMisuse 的消融测试中(62.3% vs 55.3%)优于基于图的修复模型。
- 该模型学习在无显式枚举的情况下对错误进行分类、定位和修复,在训练和推理阶段具有效率优势。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。