Introduction
Automated Program Repair (APR) has traditionally been approached as a "one-shot" translation task: given a buggy input, a model is expected to produce a corrected output in a single pass. While this works for trivial syntax errors, it often fails for complex logical bugs where the "edit distance" between the broken code and the fix is substantial. This "outcome-based" paradigm creates a complexity gap that even large language models (LLMs) struggle to bridge.
To address this, the RePair framework shifts the focus from single-step outcomes to an iterative, process-based approach. By mimicking the human debugging cycle—where developers use compiler feedback and test cases to refine their code—RePair enables smaller models to solve complex problems that previously required massive parameter counts.
Methodology: The RePair Framework
RePair treats program repair as a multi-step reinforcement learning (RL) problem. The architecture is built on three pillars: Supervised Fine-Tuning, Reward Modeling, and Reinforcement Learning.
1. Supervised Fine-Tuning (SFT)
The process begins with a 15.5B-parameter StarCoderBase model. It is fine-tuned on a specialized dataset to establish a baseline understanding of code repair tasks and the structure of programming competition problems.
2. Reward Modeling (The Virtual Critic)
A critical innovation in RePair is the use of a Reward Model (RM) that acts as a "virtual compiler." Running a real compiler millions of times during RL training is computationally prohibitive. Instead, the RM is trained to rank code submissions based on a human-defined hierarchy of correctness:
- Accepted (AC) > Presentation Error (PE) > Wrong Answer (WA) = Time/Memory Limit Exceed > Compile Error (CE) > Runtime Error (RE).
3. Reinforcement Learning with PPO
Using Proximal Policy Optimization (PPO), the repair model (the "actor") learns to generate code that maximizes the reward from the virtual critic. This training phase encourages the model to prioritize fixing fundamental execution errors (like Runtime Errors) before fine-tuning for logical correctness.
The CodeNet4Repair Dataset
To support this process-based learning, the researchers introduced CodeNet4Repair. Unlike standard datasets that only provide "before" and "after" snapshots, CodeNet4Repair contains over 10,000 multi-step repair records. It tracks the evolution of programs through intermediate states (e.g., from a Compile Error to a Wrong Answer, and finally to Accepted), providing the necessary data to train models on the process of debugging.
Key Results and Insights
The performance of the 15B-parameter RePair model is significant. On the CodeNet4Repair benchmark, it achieved a pass@1 of 44.34%, outperforming much larger models:
- LLaMA2-70B: 7.59%
- PaLM-540B: 17.13%
- GPT-3.5: 46.39% (comparable performance)
The success of RePair highlights that decomposition is king. By breaking a complex repair into smaller, incremental steps, the cognitive load on the model is reduced. A 15B model can effectively solve a "hard" problem if it only needs to fix one logical flaw at a time. Furthermore, the feedback hierarchy ensures the model focuses on deeper logical flaws before syntax, mirroring effective human debugging strategies.
Conclusion and Future Work
RePair demonstrates that architectural scale is not the only path to high-performance APR. A well-designed iterative process, supported by reinforcement learning and process-based feedback, allows relatively small models to rival industry giants. Future work will focus on expanding the framework to other programming languages beyond Python and exploring more universal feedback mechanisms that do not rely on manually defined reward hierarchies.
Summary updated