[论文解读] DeepDebug: Fixing Python Bugs Using Stack Traces, Backtranslation, and Code Skeletons
DeepDebug 提出了一种基于序列到序列的 Transformer 模型,通过使用堆栈跟踪、反向翻译和代码骨架来修复 Python 错误。该方法在可执行测试基准上实现了 75% 的首次修复成功率,并将 QuixBugs 上的误报率从 35% 降低至 5%,在修复数量上优于先前工作超过 50%,同时推理速度显著提升(1 分钟 vs. 6 小时)。
The joint task of bug localization and program repair is an integral part of the software development process. In this work we present DeepDebug, an approach to automated debugging using large, pretrained transformers. We begin by training a bug-creation model on reversed commit data for the purpose of generating synthetic bugs. We apply these synthetic bugs toward two ends. First, we directly train a backtranslation model on all functions from 200K repositories. Next, we focus on 10K repositories for which we can execute tests, and create buggy versions of all functions in those repositories that are covered by passing tests. This provides us with rich debugging information such as stack traces and print statements, which we use to finetune our model which was pretrained on raw source code. Finally, we strengthen all our models by expanding the context window beyond the buggy function itself, and adding a skeleton consisting of that function's parent class, imports, signatures, docstrings, and method bodies, in order of priority. On the QuixBugs benchmark, we increase the total number of fixes found by over 50%, while also decreasing the false positive rate from 35% to 5% and decreasing the timeout from six hours to one minute. On our own benchmark of executable tests, our model fixes 68% of all bugs on its first attempt without using traces, and after adding traces it fixes 75% on first attempt. We will open-source our framework and validation set for evaluating on executable tests.
研究动机与目标
- 解决自动化程序修复中的高误报率问题,即修复补丁通过测试但并非真正修复。
- 通过利用可执行测试反馈(包括堆栈跟踪和打印语句)来提升错误定位和修复能力。
- 通过引入代码骨架(导入语句、函数签名、文档字符串和父类上下文)来增强模型的泛化能力和准确性。
- 将推理时间从数小时缩短至一分钟以内,同时在基准数据集上提高修复率。
- 开发一个可扩展的端到端自动化调试框架,可部署于真实世界开发工作流中。
提出的方法
- 在反转的 Git 提交上训练一个错误生成模型,以生成合成错误用于数据增强。
- 基于 DeepDev-py 的预训练序列到序列 Transformer 模型,在 20 万个项目库上使用反向翻译进行微调,以学习错误到修复的映射关系。
- 将合成错误注入 1 万个具有可执行测试的项目库中的函数中,保持测试覆盖率并收集堆栈跟踪。
- 在该可执行测试数据上对模型进行微调,结合堆栈跟踪和扩展上下文(代码骨架)以提升错误定位和修复效果。
- 使用轴向嵌入扩展模型的上下文窗口,按优先级顺序包含父类、导入语句、函数签名和文档字符串。
- 采用 top-k 和 top-p 解码的采样策略生成多个候选补丁,并在测试套件上进行评估。
实验结果
研究问题
- RQ1在大规模原始 Python 代码上使用反向翻译能否提升自动化程序修复的泛化能力?
- RQ2代码骨架(导入语句、函数签名、文档字符串、父类)在多大程度上改善了错误定位和修复准确性?
- RQ3当与代码骨架和反向翻译结合时,堆栈跟踪在引导模型修复方面有多有效?
- RQ4统一模型能否在将推理时间从数小时缩短至数分钟的同时,实现高修复率和低误报率?
- RQ5与合成基准相比,使用可执行测试反馈(如堆栈跟踪)是否能提升真实世界可执行错误上的性能?
主要发现
- 在 QuixBugs 基准上,DeepDebug 修复了 40 个错误中的 21 个(53%),较之前最先进方法提升 50%,且仅产生 1 个误报(误报率 5%),相比之前 35% 的误报率显著降低。
- 在自定义的 523 个可执行神经错误基准上,当使用堆栈跟踪时,DeepDebug 在首次尝试中修复了 523 个错误中的 393 个(75%),较无堆栈跟踪时的 68% 显著提升。
- 在使用堆栈跟踪时,Top-10 补丁成功率从无堆栈跟踪时的 90% 提升至 97%,证明了感知堆栈修复的价值。
- 引入代码骨架后,神经错误检测的交叉熵损失降低了 25%,表明模型置信度提高且与正确修复的对齐性增强。
- 模型实现了 1 分钟的推理超时,相比之前工具使用的 6 小时超时有显著改进,同时保持了高修复质量。
- 由于困惑度较低,模型生成了大量重复编辑,表明需要改进采样策略以提升修复候选的多样性。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。