Boosting Open-Source LLMs for Program Repair via Reasoning Transfer and LLM-Guided Reinforcement Learning

Xunzhu Tang, Jacques Klein, Tegawendé F. BissyandéarXiv 2025

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:

Figure 1: Overview of the Repairity
  1. 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.
  2. 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.
  3. 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:

Table 1: Overview of Benchmark Tasks and Dataset Statistics
  • 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.

Ablation studies on different 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

Abstract

Several closed-source LLMs have consistently outperformed open-source alternatives in program repair tasks, primarily due to their superior reasoning capabilities and extensive pre-training. This paper introduces Repairity, a novel three-stage methodology that significantly narrows this performance gap through reasoning extraction and reinforcement learning. Our approach: (1) systematically filters high-quality reasoning traces from closed-source models using correctness verification, (2) transfers this reasoning knowledge to open-source models via supervised fine-tuning, and (3) develops reinforcement learning with LLM-based feedback to further optimize performance. Empirical evaluation across multiple program repair benchmarks demonstrates that Repairity improves the performance of Qwen2.5-Coder-32B-Instruct, a base open source LLM, by 8.68\% on average, reducing the capability gap with Claude-Sonnet3.7, a state-of-the-art closed-source model, from 10.05% to 1.35%. Ablation studies confirm that both reasoning extraction and LLM-guided reinforcement learning contribute significantly to these improvements. Our methodology generalizes effectively to additional code-related tasks, enabling organizations to leverage high-quality program repair capabilities while maintaining the customizability, transparency, and deployment flexibility inherent to open-source models.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
SWE-bench VerifiedREPAIRITY (full model: base + RT + RL-LF)Resolved62.7%+24.5 vs baselineFull model; benchmark split not specified in the cited results.
Source quote
L466: \toolname (Ours) │ 62.7
BigCodeBenchREPAIRITY (full model: base + RT + RL-LF)Pass@135.6%+4.8 vs baselineFull model; benchmark split not specified in the cited results.
Source quote
L448: \toolname (Ours) │ 35.6
MBPPREPAIRITY (full model: base + RT + RL-LF)Accuracy92.5%+3.7 vs baselineFull model; benchmark split not specified in the cited results.
Source quote
L485: \toolname (Ours) │ 92.5
Reported baseline / comparator measurements (3)
BenchmarkMethodMetricScoreProtocol / Evidence
SWE-bench VerifiedQwen2.5-Coder-32B-Instruct (base) baselineResolved38.2%params=32B
Source quote
L463: Qwen2.5-Coder-32B-Instruct~\cite{hui2024qwen2} │ 38.2
BigCodeBenchQwen2.5-Coder-32B-Instruct (base) baselinePass@130.8%params=32B
Source quote
L447: Qwen2.5-Coder-32B-Instruct~\cite{qwen2023technical} │ 30.8
MBPPQwen2.5-Coder-32B-Instruct (base) baselineAccuracy88.8%params=32B
Source quote
L483: Qwen2.5-Coder-32B-Instruct~\cite{hui2024qwen2} │ 88.8
BibTeX
@misc{tang2025boosting,
  author = {Xunzhu Tang and Jacques Klein and Tegawendé F. Bissyandé},
  title = {{Boosting Open-Source LLMs for Program Repair via Reasoning Transfer and LLM-Guided Reinforcement Learning}},
  year = {2025},
  eprint = {2506.03921},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2506.03921},
}
Figure