當模型過度編輯時:論最小程式碼編輯的忠實度
When Models Edit Too Much: On the Fidelity of Minimal Code Edits
September 3, 2026
作者: Tongyao Zhu, Wei Hern Lim, Min-Yen Kan
cs.AI
摘要
大型語言模型(LLM)日益被用於編輯既有程式碼,但僅有正確性並不夠:有用的修復也應具備最小化、可審查性,並忠於原始實作。我們研究「過度編輯」現象,即模型傾向於重寫超出修復缺陷所需範圍的程式碼。我們透過將受控的AST層級損壞注入參考解答,從400個BigCodeBench問題建構了一套評估框架,使每個修復任務都具有已知的最小修補。在前沿LLM中,過度編輯現象相當普遍,即使如GPT-5.5等強大模型也不例外:高Pass@1可能與不必要的大幅編輯及增加的認知複雜度並存。加入保留指令能顯著降低此行為,將平均超額Levenshtein距離從0.195降至0.131,使新增認知複雜度減少26.6%,並將Pass@1提升2.3個百分點。然而,這些成效並非單純來自更大的推理預算或更大的模型。我們接著探討最小化編輯是否能在後訓練階段直接學習。我們觀察到,監督式微調會過度擬合所見的損壞模式,而強化學習則在跨域編輯保真度與效能保留之間提供了最佳取捨。這些結果將編輯保真度定位為程式碼修復品質的一個獨立軸向,並顯示其可以量測與學習。
English
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.