Skip to content

MRCoder: An Efficient Context Selecting Approach for Repository-Level Code Generation

Jul 2026 · arXiv.org · Vol abs/2607.26805 · 0 citations · 34 references
Computer Science

TL;DR

Experimental results show that MRCoder improves code generation accuracy over strong baselines while reducing token consumption by 30 to 50% and inference time by up to 52%.

Abstract

Large language models (LLMs) have demonstrated strong capabilities in code generation. However, repository-level code generation remains challenging, as it requires effectively identifying and utilizing repository-specific context. While retrieval-augmented generation (RAG) incorporates relevant code snippets, it often introduces redundant context that interferes with the LLM's ability to utilize relevant information, leading to degraded generation quality and increased computational cost. Moreover, existing context selection and compression methods struggle to balance efficiency and quality, either introducing additional computational overhead or failing to effectively select valid context. In this paper, we propose MRCoder, an efficient context selection framework that improves both the effectiveness and efficiency of repository-level code generation. MRCoder adopts a Map-Reduce paradigm: in the Map Phase, a lightweight draft model generates drafts over partitioned contexts, and Structure-Aware Draft-Guided Selection (SADGS) selects informative contexts based on drafts through API consistency and logical similarity; in the Reduce Phase, the refined contexts are aggregated for final generation, with a parallel verification strategy further accelerating decoding. We evaluate MRCoder on two widely used repository-level code generation benchmarks, CoderEval and DevEval, using Qwen2.5-Coder and DeepSeek-Coder as backbone LLMs. Experimental results show that MRCoder improves code generation accuracy over strong baselines while reducing token consumption by 30 to 50% and inference time by up to 52%. These results demonstrate that our proposed structured and draft-guided context selection strategy is crucial for improving both the quality and efficiency of repository-level code generation

View source

Similar papers

#artificial intelligence Preprint Sep 2026

Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation

ACToR identifies critical tokens during generation and triggers targeted retrieval on demand to provide repository context at these decisive positions, and designs a position-aware weighting method for dense retrievers to prioritize context that is more informative for generation.

Kefeng Duan, De-Wu Zheng, Yan-Lin Wang et al. · 0 citations
Conference Aug 2026

CoLSM: Collaborative Large and Small Models for Automatic Software Generation

Large language models (LLMs) support human-in-the-loop code development by rapidly generating high-quality code snippets. However, they still face prominent challenges in fast and efficient deployment on edge environments. Such challenges mainly involve heavy computation costs, poor domain accuracy, unbalanced collaboration efficiency and inconsistent cross-model knowledge. This study proposes CoLSM, a new collaboration mechanism guided by mixture experts for automatic software generation. It establishes a hierarchical and iterative working pipeline. A mixture-expert router assigns tasks dynamically. Large models take charge of system architecture and complex logic design. Domain-adapted small models refine code details, optimize resource usage and ensure security compliance. This mechanism integrates an abstract syntax tree based synchronization module to resolve cross-model conflicts and embeds a quality feedback loop to support adaptive iterative optimization. We evaluate the proposed CoLSM on a self-built multi-scenario software generation dataset. Experimental results demonstrate that CoLSM improves software generation accuracy and functional consistency by 4.3% and 5.7%, respectively. It also reduces inference latency by 20.3% and energy consumption by 14.8%. CoLSM effectively combines the respective advantages of large and small models. It realizes accurate and low-cost automatic software generation and provides reliable technical support for agile automated software development.

Quan Wen, Liu-Shun Zhao, Xiongtao Zhang et al. · 0 citations
Open access Aug 2026

Optimizing Context and Cost in LLM‐Based Unit Test Generation: A Study on External Dependency Retrieval Strategies

A systematic empirical study of multiple strategies for context enrichment and optimization in LLM‐based unit test generation, conducted on seven diverse projects (three open‐source and four proprietary industrial systems), encompassing 261 distinct methods establish this optimized context strategy as a cost‐effective solution for scalable, industrial‐grade automated test generation.

Javier Ferrer, Francisco Chicano · 0 citations
Preprint Aug 2026

Route-Align-Verify for Functional Correctness in Code Generation

The results indicate that functional correctness in code generation can be meaningfully improved without modifying the backbone architecture, by jointly optimizing how tasks are prompted, how the model is adapted, and how final outputs are selected.

Erxue Zhou, Jing Meng, Ao-Fan Liu · 0 citations
#artificial intelligence Preprint Sep 2026

Retrieval-Augmented Generation for Scientific Code Understanding

Large language models have become central to modern coding assistants, but state-of-the-art systems such as Claude Code or Codex rely on very large, cloud-hosted models with significant computational cost and data-privacy implications. This work investigates whether a useful, fully local coding agent can be built around small open-source models by shifting the computational burden away from inference. We develop a Retrieval-Augmented Generation (RAG) system for scientific code understanding that strictly separates an expensive offline ingestion stage parsing, structural graph construction, LLM-generated entity explanations, and embedding from a lightweight online answering stage. The system is evaluated on a 100-question benchmark spanning eleven categories over the IPPL scientific codebase written in C++, with answers scored by an independent frontier model as the judge. Across seven answering models, we find that model family and retrieval quality matter more than parameter count, i.e. a 9B model achieves the highest average score (0.795), outperforming both larger models within our pipeline and the same models embedded in the Claude Code retrieval architecture. The results indicate that front-loading code understanding into a reusable, codebase-specialised vector store enables small local models to deliver grounded and repository-specific answers, making the agent well suited as a privacy-preserving development tool for in-house scientific codebases.

Aaron Nobile, Andreas Adelmann, Mohsen Sadr · 0 citations
#software testing Preprint Aug 2026

XREPOTEST: Benchmarking Multilingual Repository-Level Unit Test Generation for Large Language Models

XREPOTEST is introduced, a multilingual repository-level benchmark for unit test generation spanning five underexplored languages: Rust, Go, Julia, PHP, and Ruby, and Invocation Rate is proposed to assess whether generated tests meaningfully exercise the intended functionality.

L. Dung, Dong Cao Van, Nam Le Hai et al. · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.