Abstract
Automated software patching represents a significant challenge in software engineering, requiring precise localization, code generation, and rigorous validation. While current state-of-the-art approaches often rely on monolithic, large-scale models, this paper introduces Co-PatcheR, a collaborative system that utilizes a suite of specialized 14B parameter reasoning models. By decomposing the patching process into distinct, expert-driven stages, Co-PatcheR achieves a 46% resolved rate on the SWE-bench-Verified benchmark. Notably, this performance surpasses models five times its size while requiring 88% less training data, demonstrating that architectural modularity and task specialization can outperform raw parameter scaling in complex engineering domains.
1. Introduction
The "grand challenge" of automated software patching involves navigating massive codebases to identify faults, authoring syntactically and logically correct fixes, and verifying those fixes against existing and new test cases. Traditional approaches have favored monolithic models (70B+ parameters) to handle this end-to-end complexity. However, these models often hit performance ceilings and are computationally expensive to train and deploy.
Co-PatcheR shifts this paradigm by employing a "divide and conquer" strategy. It utilizes three specialized 14B models based on the Qwen-2.5-Coder architecture, each fine-tuned for specific sub-tasks: localization, generation, and validation. This modular approach allows for more efficient training and higher precision in each phase of the software development lifecycle.
2. Methodology
Co-PatcheR is structured around three primary functional components that collaborate to resolve GitHub issues.
2.1 Localization and Generation (Loc-Gen)
The Loc-Gen Model manages the initial phases of the pipeline. To manage the context window effectively, localization is split into two steps: first identifying relevant files within the repository, and then pinpointing specific faulty lines. Once the fault is localized, the model generates a patch. A critical feature of this stage is the "self-critique" loop, where the model reviews its own proposed code and refines it to eliminate common errors before finalizing the output.
2.2 Specialized Validation Models
Validation is handled by two distinct models designed to generate Proof-of-Concept (PoC) test cases:
- Val-assert: Focuses on creating rigid, assertion-based tests (e.g.,
assert x == y) to catch specific logic failures. - Val-no-assert: Generates general scripts to observe behavioral changes and side effects that might not be captured by simple assertions.
2.3 Training via Reasoning Distillation
The models were trained using a distillation process. High-end models (such as Claude-3.7-Sonnet) were used to generate complex "reasoning chains" for 2,000 training issues. These chains represent the step-by-step thinking process required to solve a bug. The 14B models were then fine-tuned to mimic these reasoning paths. The training set was expanded to 6,000 samples through task decomposition, focusing exclusively on correct reasoning paths to prevent the models from learning "hallucinated" or incorrect code patterns.
2.4 Hybrid Inference and Voting
During the inference phase, the system runs generated patches against both the generated PoCs and the repository's existing functional tests. A majority-vote system is employed to select the most robust fix from the candidate pool.
3. Evaluation
Co-PatcheR was evaluated on SWE-bench-Verified, a curated subset of 500 real-world GitHub issues that have been human-verified for test reliability.
3.1 Key Results
- State-of-the-Art Accuracy: Co-PatcheR achieved a 46% resolved rate, placing it among the top 10 open-source patching systems globally.
- Efficiency Gains: The system reached this performance level using 40% fewer parameters and 88% fewer training samples (6K vs. 11M) compared to previous leaders like SWE-RL.
- Hardware Accessibility: By utilizing 14B models, Co-PatcheR can be deployed on mid-range enterprise GPUs (e.g., NVIDIA L40S), making high-tier automated patching more accessible to smaller organizations.
4. Discussion and Insights
The success of Co-PatcheR yields several insights into the future of AI-driven engineering:
- Specialization > Scale: Modular architectures with specialized experts can outperform larger, general-purpose models on technical tasks.
- The Correctness Requirement: Unlike mathematical reasoning where "negative" examples can be useful, software patching benefits most from training on strictly correct reasoning paths to avoid the propagation of syntax and logic errors.
- Diversity in Testing: Using multiple validation models with different testing philosophies (assertion-based vs. behavioral) provides superior path coverage and more reliable patch verification.
5. Conclusion and Future Work
Co-PatcheR demonstrates that a collaborative team of small reasoning models is a highly effective and efficient solution for automated software patching. Future iterations will focus on integrating more complex tool-calling capabilities (e.g., documentation search) and incorporating Reinforcement Learning (RL) to reward models specifically for passing test cases, potentially further closing the gap between AI and human-level software maintenance.
Summary updated