TL;DR
The paper introduces Repairity, a three-stage framework that closes the performance gap between open-source and closed-source LLMs on automated program repair tasks. By distilling step-by-step reasoning traces from Claude-3.7-Sonnet and optimizing the model using LLM-guided reinforcement learning, Repairity boosts the open-source Qwen2.5-Coder-32B model to near-parity with top-tier proprietary models, achieving a massive 24.5% absolute performance gain on complex software engineering benchmarks.
What Problem Does This Paper Address?
Automated Program Repair (APR) is a holy grail in software engineering: fixing software bugs automatically without human intervention. While Large Language Models (LLMs) have revolutionized this space, a stark divide remains. Top-tier closed-source models (like GPT-4 and Claude) consistently outperform open-source alternatives because of their superior multi-step reasoning capabilities.
However, relying on closed-source APIs introduces significant hurdles for enterprises, including high costs, lack of customizability, and severe data privacy risks when handling proprietary codebases. Existing methods to upgrade open-source models—like standard instruction tuning or Reinforcement Learning from Human Feedback (RLHF)—either require prohibitive amounts of human annotation or fail to teach the model how to reason through a bug. This paper tackles the challenge of transferring complex debugging logic from proprietary "teacher" models to open-source "student" models efficiently.
Methods
Repairity achieves this through a novel three-stage pipeline that combines imitation learning with automated preference alignment:
- Data Collection & Filtering: The authors prompt a powerful closed-source teacher model (Claude-3.7-Sonnet) to solve programming bugs while explicitly outputting its step-by-step reasoning process (problem analysis, bug identification, repair planning, and implementation). Crucially, they filter this data using functional correctness verification, keeping only the reasoning traces that successfully pass all unit tests.
- Reasoning Trace Learning (SFT): The base open-source model (Qwen2.5-Coder-32B-Instruct) undergoes Supervised Fine-Tuning on these high-quality reasoning traces. Instead of just learning the final code fix, the model learns to internalize the procedural logic required to get there.
- Reinforcement Learning with LLM Feedback (RL-LF): To refine the model beyond mere functional correctness, the authors introduce an AI-driven reinforcement learning step. The student model generates multiple candidate repairs, which are paired and evaluated by the closed-source model based on criteria like code efficiency, readability, and minimality of changes. These preferences train a CodeLlama-7b reward model, which guides Proximal Policy Optimization (PPO) to fine-tune the open-source model.
Datasets
The framework was evaluated across four diverse benchmarks spanning code generation, completion, and real-world program repair:
- SWE-bench Verified: 500 software engineering tasks featuring real-world production bugs and unit tests.
- Defects4J: 835 real-world bugs drawn from open-source Java projects.
- BigCodeBench: 1,140 complex programming problems testing general code completion and repair.
- MBPP (Mostly Basic Programming Problems): 964 shorter, basic Python programming tasks.
Key Insights and Ideas
- Reasoning Scales with Complexity: Explicit reasoning traces provide massive benefits for complex, multi-step software engineering tasks (like SWE-bench), but offer negligible improvements for simpler programming tasks (like MBPP).
- The SFT and RL-LF Synergy: Supervised fine-tuning on reasoning traces builds a vital foundation of structured problem-solving. Reinforcement learning (RL-LF) then acts as a polisher, aligning the model with implicit quality preferences—such as writing clean, readable code and making minimal, non-disruptive edits—that are hard to capture via SFT alone.
- Cross-Task Generalization: Reasoning skills are highly transferable. When Repairity was trained purely on SWE-bench data and evaluated on BigCodeBench, it still significantly outperformed the base model, proving it learns generalized debugging strategies rather than just memorizing benchmark-specific fixes.
Key Results
Repairity successfully closed up to 93% of the performance gap between the base open-source model and Claude-3.7-Sonnet, improving the base model's performance by an average of 8.68% across all benchmarks.
- SWE-bench Verified: Repairity achieved a 62.7% resolution rate, up from the base model's 38.2% (a +24.5% absolute gain), actually outperforming Claude-3.7-Sonnet's default mode (62.3%).
- BigCodeBench: Pass@1 increased from 30.8% to 35.6%, landing within 0.2% of Claude-3.7.
- MBPP: Accuracy improved from 88.8% to 92.5%, surpassing standard Claude-3.7 (89.5%).
Limitations and Future Work
Despite its strong results, the authors note a few limitations:
- The Bootstrapping Dependency: The framework still relies on initial access to a state-of-the-art closed-source model to generate the training data and feedback. Future work will explore iterative self-improvement loops to minimize this dependency.
- Computational Overhead: Reasoning traces are highly verbose. Generating and training on thousands of tokens per problem increases computational costs and training times.
- Ethical and IP Boundaries: Distilling knowledge from proprietary models raises complex questions regarding intellectual property and appropriate attribution, an area that requires clearer ethical frameworks moving forward.
Summary updated