[论文解读] A Syntax-Guided Edit Decoder for Neural Program Repair
本文提出一种语法引导的编辑解码器,名为\techname,用于神经程序修复,其生成的是代码编辑而非完整代码序列,通过提供者/决策者架构确保语法正确性,并通过占位符生成支持项目特定标识符。该方法在性能上达到最先进水平,在Defects4J v1.2上修复了51个错误——比之前最先进方法多修复21.4%——是首个在该基准上超越传统方法的基于深度学习的程序修复方法。
Automated Program Repair (APR) helps improve the efficiency of software development and maintenance. Recent APR techniques use deep learning, particularly the encoder-decoder architecture, to generate patches. Though existing DL-based APR approaches have proposed different encoder architectures, the decoder remains to be the standard one, which generates a sequence of tokens one by one to replace the faulty statement. This decoder has multiple limitations: 1) allowing to generate syntactically incorrect programs, 2) inefficiently representing small edits, and 3) not being able to generate project-specific identifiers. In this paper, we propose Recoder, a syntax-guided edit decoder with placeholder generation. Recoder is novel in multiple aspects: 1) Recoder generates edits rather than modified code, allowing efficient representation of small edits; 2) Recoder is syntax-guided, with the novel provider/decider architecture to ensure the syntactic correctness of the patched program and accurate generation; 3) Recoder generates placeholders that could be instantiated as project-specific identifiers later. We conduct experiments to evaluate Recoder on 395 bugs from Defects4J v1.2 and 420 additional bugs from Defects4J v2.0. Our results show that Recoder repairs 53 bugs on Defects4J v1.2, which achieves 21.4% improvement over the previous state-of-the-art approach for single-hunk bugs (TBar). Importantly, to our knowledge, Recoder is the first DL-based APR approach that has outperformed the traditional APR approaches on this dataset. Furthermore, Recoder also repairs 19 bugs on the additional bugs from Defects4J v2.0, which is 137.5% more than TBar (8 bugs) and 850% more than SimFix (2 bugs). This result suggests that Recoder has better generalizability than existing APR approaches.
研究动机与目标
- 为解决基于深度学习的程序修复中标准序列到序列解码器的局限性,即生成语法无效的程序且对小规模编辑的表示效率低下。
- 通过将补丁建模为编辑而非完整代码序列,提升神经程序修复的效率与正确性。
- 通过占位符实例化实现项目特定标识符的生成,增强上下文相关性。
- 在现有基于深度学习和传统程序修复方法之上,实现更优的泛化能力和性能。
- 证明重新设计的解码器架构能够弥合基于深度学习与传统程序修复技术之间的性能差距。
提出的方法
- 所提出的\\techname解码器生成编辑(如标记替换、插入或删除),而非完整代码序列,从而高效表示小规模修改。
- 采用提供者/决策者架构:提供者生成候选编辑,决策者利用上下文无关文法对目标语言的语法进行验证。
- 模型引入占位符标记,随后在后处理阶段实例化为项目特定的标识符,提升上下文准确性。
- 解码器采用端到端训练,基于序列到序列框架并使用语法感知损失函数,优先生成语法正确的输出。
- 编码器处理错误语句及其上下文,生成潜在表示,以指导编辑解码器。
- 该方法集成复制机制,以保留未修改的代码片段,降低生成复杂度。

实验结果
研究问题
- RQ1与标准序列到序列解码器相比,语法引导的编辑解码器是否能提升神经程序修复的语法正确性和效率?
- RQ2与完整代码序列生成相比,基于编辑的表示方法在修复有效性与泛化能力方面是否更具优势?
- RQ3占位符生成是否能实现更优的项目特定标识符集成?
- RQ4\\techname是否在标准基准上优于基于深度学习和传统程序修复方法?
- RQ5重新设计的解码器架构是否能弥合基于深度学习与传统程序修复系统之间的性能差距?
主要发现
- \\techname在Defects4J v1.2上修复了51个错误,相比先前最先进方法TBar在单hunk错误上提升了21.4%(多修复9个错误)。
- 在Defects4J v2.0的额外错误上,\\techname修复了19个错误——比TBar多137.5%,比SimFix多850%,展现出强大的泛化能力。
- 在IntroClassJava上相比基线方法提升775%,在QuixBugs上提升30.8%,表明其在多样化基准上的广泛有效性。
- 据作者所知,\\techname是首个在Defects4J v1.2基准上超越传统程序修复技术的基于深度学习的程序修复方法。
- 语法引导的提供者/决策者架构显著减少了语法无效补丁的生成,提升了可靠性与训练效率。
- 基于占位符的标识符生成支持上下文感知的补丁生成,增强了真实项目中修复代码的相关性与正确性。

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