QiMeng-PRepair: Precise Code Repair via Edit-Aware Reward Optimization
Changxin Ke Rui Zhang Jiaming Guo Yuanbo Wen Li Ding Shuo Wang, Xuyuan Zhu Xiong Peng Di Huang Zidong Du Xing Hu Qi Guo, Yunji Chen · 2026
Read QiMeng-PRepair: Precise Code Repair via Edit-Aware Reward Optimization by Changxin Ke Rui Zhang Jiaming Guo Yuanbo Wen Li Ding Shuo Wang, Xuyuan Zhu Xiong Peng Di Huang Zidong Du Xing Hu Qi Guo, Yunji Chen (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2604-05963.txt.
Introduction
Ke and twelve colleagues curb over-editing in language-model code repair, where models rewrite good code while fixing bugs. Their PRepair frame pairs Self-Breaking, which plants varied bugs for training, with Self-Repairing, which rewards small, right fixes through edit-aware policy training. Repair precision rises by up to 31.4 percent on a joint correctness-and-size score, and speculative editing lifts decoding speed.
Catalog record
| CREATOR | Changxin Ke Rui Zhang Jiaming Guo Yuanbo Wen Li Ding Shuo Wang, Xuyuan Zhu Xiong Peng Di Huang Zidong Du Xing Hu Qi Guo, Yunji Chen |
|---|---|
| YEAR | 2026 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 52151 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2604.05963
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
QiMeng-PRepair: Precise Code Repair via Edit-Aware Reward Optimization Changxin Ke Rui Zhang Jiaming Guo Yuanbo Wen Li Ding Shuo Wang, Xuyuan Zhu Xiong Peng Di Huang Zidong Du Xing Hu Qi Guo, Yunji Chen Abstract Large Language Models (LLMs) achieve strong program repair performance but often suffer from over-editing , where excessive modifications overwrite correct code and hinder bug localization. We systematically quantify its impact and introduce precise repair task, which maximizes reuse of correct code while fixing only buggy parts. Building on this insight, we propose PRepair, a framework that mitigates over-editing and improves repair accuracy. PRepair has two components: Self-Breaking , which generates diverse buggy programs via controlled bug injection and min–max sampling, and Self-Repairing , which trains models with Edit-Aware Group Relative Policy Optimization (EA-GRPO) using an edit-aware reward to encourage minimal yet correct edits. Experiments show that PRepair improves repair precision by up to 31.4% under fix 1 @ 1 \mathrm{fix}_{1}@1 , a metric that jointly considers repair correctness and extent, and significantly increases decoding throughput when combined with speculative editing, demonstrating its potential for precise and practical code repair. 1 Introduction Program repair aims to automatically correct faulty programs while preserving their intended semantics, and has become an important research area in the era of Large Language Models ( 6 ; 25 ; 4 ) . Prior works generally follow a structured paradigm, decomposing the task into stages such as error localization, correction, and validation ( 19 ; 5 ; 2 ) . With the growing use of coding assistants like Copilot and Cursor, there is an increasing need for fast, end-to-end program repair models. To address this demand, many recent approaches employ supervised fine-tuning (SFT) and reinforcement learning (RL) to train models capable of performing program repair accurately. Figure 1: Existing models suffer from over-editing , which not only reduces repair accuracy but also significantly increases the review burden for developers. In comparison, PRepair improves both repair accuracy and maintainability in practice. Most existing training approaches ( 8 ; 6 ; 23 ; 3 ) optimize repair correctness alone, treating code repair as a correctness-only objective. This formulation ignores how much the model modifies the original program. We observe that these models suffer from an over-editing phenomenon (as illustrated in Figure 1 ), where they tend to regenerate large portions of the code through excessive edits instead of understanding and minimally correcting the original buggy code. Over-editing is harmful for two reasons: (1) it fails to localize the bug, thereby limiting the effectiveness of the repair; and (2) it unnecessarily rewrites the code, breaking the original structure and reducing maintainability in practice. Therefore, for code repair, precise repair is preferred, as it maximizes the reuse of correct logic in the original code while precisely fixing the buggy parts, thereby preserving code logic and reducing developers’ review burden. However, while precise repair is crucial for code repair, it remains largely unsolved in existing approaches. Precise repair faces two key challenges: (1) Data scarcity. Effective repair requires models to understand the semantics of buggy programs, reuse their correct components, and precisely localize and fix errors. However, realistic buggy code that simultaneously contains substantial correct logic and localized faults is extremely scarce. (2) Preservation of correct code. During training, it is challenging to make the model aware of how much of the code has been edited, so that it preserves the correct parts while precisely localizing and fixing only the buggy portions. To address the over-editing issue, we propose the PRepair framework, which explicitly guides models to perform precise repairs. Our central insight is that optimizing for minimal yet sufficient edits preserves repair correctness while encouraging faithful reuse of correct program logic. To address the two challenges of precise repair, the PRepair framework consists of two steps: (1) Self-Breaking , where we design a precise code repair data generation framework that systematically injects bugs into correct programs to construct large-scale training data, combined with a min–max sampling strategy to maximize the diversity of buggy programs while avoiding over-concentration on similar bug patterns; (2) Self-Repairing , where the model is optimized with proposing Edit-Aware Group Relative Policy Optimization (EA-GRPO) to encourage both correct and minimal code repairs. EA-GRPO introduces an edit-aware reward, where edit penalties are applied when the model achieves sufficient repair correctness. This design effectively balances repair correctness and extent, encouraging minimal yet accurate code fixes. Besides, to evaluate both repair correctness and the extent of modifications, we introduce \mathrm{fix}_{p}@k , the first metric specifically designed for assessing precise repair, which jointly considers correctness and the number of edits. Compared with previous methods that optimize code repair solely for correctness, our method offers two key advantages. First, the model learns to focus its attention on the buggy lines, acquiring an implicit error localization ability that guides precise repair, which not only improves repair accuracy but also enhances cross-domain code repair capability. Second, by following the logic of the buggy code, it reuses correct portions of the original program, alleviating the over-editing problem and improving maintainability in practice, as shown in Figure 1 . Experiments on two models of different sizes and two fundamentally different languages, Python and Verilog, show that PRepair effectively reduces unnecessary edits while improving repair correctness. In addition, when combined with speculative editing, PRepair enables faster inference, demonstrating its practical value and generality across diverse programming languages. The main contributions of this paper are as follows: • We identify over-editing as a key issue in LLM-based code repair under GRPO and propose \mathrm{fix}_{p}@k , the first metric for evaluating repair precision. • We propose the PRepair framework to enhance code repair without labeled data, and introduce EA-GRPO to train models for precise code repair using an edit-aware reward. • Empirical evaluations on multiple models and benchmarks demonstrate that PRepair achieves superior repair precision and correctness. • When combined with speculative editing, EA-GRPO significantly increases inference throughput, highlighting the practical value of PRepair as real-world code assistance. 2 Methodology In this section, we first analyze existing models trained with naive GRPO and empirically study the relationship between repair accuracy and extent of modifications. Motivated by these findings, we introduce a novel metric, \mathrm{fix}_{p} , which jointly measures repair accuracy and the number of edited lines. Based on this metric, we then present the proposed PRepair framework. (a) Python Code Repair (b) Verilog Code Repair Figure 2: GRPO training with correctness-only rewards. For both Python and Verilog code repair tasks, although performance improves during training, the edit cost increases substantially, leading to a more severe over-editing phenomenon. We model code as a sequence of lines X=\{x_{1},x_{2},\dots,x_{n}\} . Given a buggy program, the goal of program repair is to perform the necessary line-level insertions, deletions, and substitutions to produce a corrected sequence Y=\{y_{1},y_{2},\dots,y_{m}\} that satisfies the intended functionality. To quantify the distance between the buggy code and the corrected code, we introduce the Edit Cost \mathbf{D}_{\mathrm{EC}} , which is based on the Levenshtein distance \mathbf{D}(X,Y) 7 . This distance measures the minimum number of insertions, deletions, and substitutions required to transform one code into the other. Let |X| denote the number of lines in the source program. We define Edit Cost as: \mathbf{D}_{\mathrm{EC}}(X,Y)=\frac{\mathbf{D}(X,Y)}{|X|} Here,