When Models Edit Too Much: On the Fidelity of Minimal Code Edits
作者: Tongyao Zhu, Wei Hern Lim, Min-Yen Kan
分类: cs.SE, cs.AI, cs.CL
发布日期: 2026-09-03
备注: EMNLP 2026 (Main)
💡 一句话要点
提出最小化代码编辑方法以提高代码修复的准确性
🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture) 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 代码修复 大型语言模型 过度编辑 编辑保真度 强化学习 软件开发 自动化测试
📋 核心要点
- 现有的代码编辑模型在修复错误时常常进行过度编辑,导致不必要的复杂性和可读性下降。
- 论文提出了一种保留指令的方法,旨在减少过度编辑现象,提高代码修复的最小化和准确性。
- 实验结果显示,保留指令显著降低了编辑的复杂性,并提高了模型的修复准确率,展示了编辑保真度的重要性。
📝 摘要(中文)
大型语言模型(LLMs)在代码编辑中越来越常用,但仅有正确性不足以满足需求,实用的修复还应是最小化、可审查且忠实于原始实现。本文研究了过度编辑现象,即模型在修复错误时倾向于重写代码超出必要范围。通过构建一个评估框架,利用400个BigCodeBench问题,注入受控的AST级别损坏,给每个修复任务提供已知的最小补丁。研究发现,即使是强大的模型如GPT-5.5,过度编辑现象普遍存在。引入保留指令显著减少了这种行为,降低了平均额外Levenshtein距离,并提高了修复的准确性。通过监督微调和强化学习的比较,发现强化学习在保持编辑保真度和性能方面表现最佳。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在代码修复中存在的过度编辑问题,现有方法往往导致不必要的复杂性和可读性下降。
核心思路:通过引入保留指令,限制模型的编辑范围,使其在修复错误时尽量保持原始代码的结构和意图,从而实现最小化编辑。
技术框架:研究构建了一个评估框架,利用400个BigCodeBench问题,通过注入AST级别的损坏,生成每个修复任务的已知最小补丁。模型在此框架下进行训练和评估。
关键创新:最重要的创新在于将编辑保真度作为代码修复质量的一个独立维度进行测量和学习,强调了最小化编辑的重要性。
关键设计:在模型训练中,采用保留指令来减少额外的Levenshtein距离,并通过强化学习优化模型的编辑保真度和性能,确保模型在未见过的损坏模式下也能保持良好的修复效果。
🖼️ 关键图片
📊 实验亮点
实验结果表明,引入保留指令后,平均额外Levenshtein距离从0.195降低至0.131,认知复杂性减少26.6%,同时Pass@1提高了2.3分。这些结果表明,编辑保真度的提升与模型的推理预算和规模无关,强调了学习编辑保真度的重要性。
🎯 应用场景
该研究的潜在应用领域包括软件开发、代码审查和自动化测试等。通过提高代码修复的准确性和可读性,可以显著提升开发效率,减少维护成本,并为开发者提供更可靠的工具支持。未来,该方法可能在智能编程助手和代码生成系统中发挥重要作用。
📄 摘要(原文)
Large language models (LLMs) are increasingly used to edit existing code, but correctness alone is not enough: useful repairs should also be minimal, reviewable, and faithful to the original implementation. We study over-editing, the tendency of a model to rewrite code beyond what is required to fix a bug. We construct an evaluation framework from 400 BigCodeBench problems by injecting controlled AST-level corruptions into reference solutions, giving each repair task a known minimal patch. Across frontier LLMs, over-editing is widespread even among strong models like GPT-5.5: high Pass@1 can coexist with unnecessarily large edits and added cognitive complexity. A preservation instruction substantially reduces this behavior, lowering average excess Levenshtein distance from 0.195 to 0.131, reducing added cognitive complexity by 26.6%, and increasing Pass@1 by 2.3 points. However, these gains do not simply follow from a larger reasoning budget or larger models. We next ask whether minimal editing can be learned directly during post-training. We observe that supervised fine-tuning overfits to seen corruption patterns, whereas reinforcement learning gives the best out-of-domain edit-fidelity and performance-retention trade-off. These results position edit fidelity as a distinct axis of code-repair quality and show that it can be measured and learned.