An Empirical Study on Strong-Weak Model Collaboration for Repo-level Code Generation

S.m. Gandhi, Atharva Naik, Yiqing Xie, Carolyn Penstein Rosé2025

Introduction

Large Language Models (LLMs) have demonstrated remarkable proficiency in software engineering tasks, particularly in resolving repository-level bugs. However, the deployment of frontier models for these tasks faces a significant "performance-cost wall." High-end agents can cost upwards of $4.00 per run, making large-scale deployment prohibitively expensive. Conversely, smaller, cheaper models often lack the reasoning depth required for complex multi-file logic.

This study, conducted by researchers at Carnegie Mellon University, investigates the "Pareto frontier" of code generation—seeking the optimal balance between performance and cost. By developing a systematic taxonomy of "Strong-Weak" model collaboration, the researchers demonstrate that strategic task delegation can match top-tier performance while reducing costs by 40%.

A Taxonomy of Collaboration Strategies

The researchers categorized 14 collaboration techniques (12 of which were newly proposed or adapted) into three primary architectural patterns:

1. Static Context Augmentation

In this paradigm, the "Strong" model serves as a high-level consultant. Before the "Weak" model attempts any code generation, the Strong model analyzes the repository or the specific GitHub issue to produce auxiliary artifacts such as:

  • Instance-level Plans: Step-by-step instructions for the fix.
  • Instance-level QA: Answers to potential technical hurdles.
  • Repository Summaries: High-level overviews of the codebase.

2. Pipeline Division

This approach uses models sequentially to handle different stages of the debugging process:

  • Weak LM First (Cascading): The cheaper model attempts the fix first. If it fails (determined by test passes or internal heuristics), the expensive model is invoked.
  • Strong LM First (Refinement): The expensive model generates an initial draft or patch, which the cheaper model then iteratively refines or formats.
  • Prompt Reduction: A weak model acts as a "distiller," pruning irrelevant code from the context window to allow the strong model to focus on the most salient logic.

3. Dynamic Collaboration (Routing)

A "router" model evaluates the incoming GitHub issue to determine its complexity. "Simple" tasks are routed to the Weak LM, while "Complex" tasks are escalated to the Strong LM.

Experimental Setup

The framework was evaluated using SWE-Bench Lite, a benchmark comprising 300 real-world GitHub issues from 11 Python repositories. The researchers utilized the Agentless-Lite framework as a baseline. Model pairings included frontier models (O3-mini, O4-mini) as "Strong" candidates and the Qwen2.5-Coder series (7B to 32B) and GPT-4o-mini as "Weak" candidates.

Key Insights

The "Overthinking" Router

A surprising finding was that Weak Routers often outperformed Strong Routers. The researchers observed that stronger models tend to "overthink" simple tasks, classifying them as complex and unnecessarily escalating them to expensive models. This behavior effectively kills cost-efficiency without providing a proportional boost in accuracy.

Instance-Level vs. Repo-Level Guidance

The study found that providing a weak model with a high-level summary of an entire repository actually degraded performance by introducing "noise." However, providing specific, instance-level guidance—such as a targeted plan for a specific bug—significantly boosted the weak model's success rate. This suggests that weak models benefit more from narrow, actionable instructions than broad context.

The Prompt Reduction Trade-off

Using a weak model to prune context for a strong model created a unique trade-off. While it slightly increased the rate of syntax errors (lowering the "valid patch rate"), it significantly increased the overall resolution rate. By forcing the strong model to focus only on the most relevant code blocks, the model was more likely to identify the correct logic for the fix.

Efficiency of Pipeline Methods

Pipeline-based methods proved to be the most robust. Weak LM First strategies were the most effective for extremely tight budgets. However, Strong LM First (initial generation by a strong model followed by weak model refinement) emerged as the superior strategy for high-performance requirements, maintaining high accuracy while still slashing costs by 40% compared to strong-only baselines.

Results and Conclusion

The empirical results highlight three major takeaways:

  1. Cost Efficiency: Collaborative strategies can match the performance of frontier-only setups with a 40% reduction in cost.
  2. Performance Gains: Strategic collaboration improved the standalone performance of weak models by approximately 62%.
  3. Smart Scaling: The study compared collaboration against "Self-Consistency" (giving a weak model multiple attempts until the cost equaled a strong model). In all cases, smart collaboration significantly outperformed brute-force sampling.

While the study was limited to the Agentless-Lite framework and inference-based costs, it provides a clear roadmap for developers looking to deploy LLM-based engineering agents at scale. Future work may explore fine-tuning weak models specifically for routing or refining roles to further push the Pareto frontier.

Summary updated

Abstract

We study cost-efficient collaboration between strong and weak language models for repository-level code generation, where the weak model handles simpler tasks at lower cost, and the most challenging tasks are delegated to the strong model.While many works propose architectures for this task, few analyze performance relative to cost.We evaluate a broad spectrum of collaboration strategies: context-based, pipeline-based, and dynamic, on GitHub issue resolution.Our most effective collaborative strategy achieves equivalent performance to the strong model while reducing the cost by 40%.Based on our findings, we offer actionable guidelines for choosing collaboration strategies under varying budget and performance constraints.Our results show that strong-weak collaboration substantially boosts the weak model's performance at a fraction of the cost, pipeline and context-based methods being most efficient.We have also opensourced the code 1 for our work.
BibTeX
@misc{gandhi2025empirical,
  author = {S.M. Gandhi and Atharva Naik and Yiqing Xie and Carolyn Penstein Rosé},
  title = {{An Empirical Study on Strong-Weak Model Collaboration for Repo-level Code Generation}},
  year = {2025},
  doi = {10.18653/v1/2025.emnlp-main.1043},
}
Figure