Repoformer: Selective Retrieval for Repository-Level Code Completion
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
Recent advances in retrieval-augmented generation (RAG) have initiated a new era in repository-level code completion. However, the invariable use of retrieval in existing methods exposes issues in both efficiency and robustness, with a large proportion of the retrieved contexts proving unhelpful or harmful to code language models (code LMs). In this paper, we propose a selective RAG framework to avoid retrieval when unnecessary. To power this framework, we design a self-supervised learning approach to enable a code LM to accurately self-evaluate whether retrieval can improve its output quality and robustly leverage the potentially noisy retrieved contexts. Using this LM as both the selective RAG policy and the generation model, our framework achieves state-of-the-art repository-level code completion performance on diverse benchmarks including RepoEval, CrossCodeEval, and CrossCodeLongEval, a new long-form code completion benchmark. Meanwhile, our analyses show that selectively retrieving brings as much as 70% inference speedup in the online serving setting without harming the performance. We further demonstrate that our framework is able to accommodate different generation models, retrievers, and programming languages. These advancements position our framework as an important step towards more accurate and efficient repository-level code completion.
Key facts. Cited by 55 papers in the map (data through 7 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 32 of its 43 references that are in the map. First posted on arXiv 15 Mar 2024.
Builds on
32 of 43 references.
Closest ancestors · 1
Same direction, newest first
Other references · 31
- 2023GPT-4 Technical Reportcited by 18,132
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,800
- 2022Language Models (Mostly) Know What They Knowcited by 1,783
- 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memoriescited by 1,103
- 2023Accelerating Large Language Model Decoding with Speculative Samplingcited by 975
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023REPLUG: Retrieval-Augmented Black-Box Language Modelscited by 786
- 2023In-Context Retrieval-Augmented Language Modelscited by 694
- 2023Active Retrieval Augmented Generationcited by 506
19 more
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
- 2022The Stack: 3 TB of permissively licensed source codecited by 354
- 2022Efficient Training of Language Models to Fill in the Middlecited by 248
- 2020IntelliCode Compose: Code Generation Using Transformercited by 225
- 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 181
- 2022DocPrompting: Generating Code by Retrieving the Docscited by 151
- 2023CodeGen2: Lessons for Training LLMs on Programming and Natural Languagescited by 124
- 2022Repository-Level Prompt Generation for Large Language Models of Codecited by 106
- 2021Efficient Nearest Neighbor Language Modelscited by 93
- 2023Self-Knowledge Guided Retrieval Augmentation for Large Language Modelscited by 69
- 2022CoCoMIC: Code Completion By Jointly Modeling In-file and Cross-file Contextcited by 64
- 2022When Language Model Meets Private Librarycited by 54
- 2023RepoFusion: Training Code Models to Understand Your Repositorycited by 40
- 2021CoCoSum: Contextual Code Summarization with Multi-Relational Graph Neural Networkcited by 22
- 2022ContraCLM: Contrastive Learning For Causal Language Modelcited by 18
- 2022You can't pick your neighbors, or can you? When and how to rely on retrieval in the kNN-LMcited by 18
- 2023Better Context Makes Better Code Language Models: A Case Study on Function Call Argument Completioncited by 14
Built on by
Citing papers per year: 2024: 11; 2025: 24; 2026: 20.
55 papers.
Sort:
By area:
- 2024Qwen2.5-Coder Technical Reportcited by 1,151
- 2024RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graphcited by 88
- 2025OpenCodeInstruct: A Large-scale Instruction Tuning Dataset for Code LLMscited by 57
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyondcited by 22
- 2024Perception of Knowledge Boundary for Large Language Models through Semi-open-ended Question Answeringcited by 20
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 20
- 2025Improving Code Localization with Repository Memorycited by 19
- 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representationscited by 17
- 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunitiescited by 17
- 2025LLM/Agent-as-Data-Analyst: A Surveycited by 15
- 2024Debate as Optimization: Adaptive Conformal Prediction and Diverse Retrieval for Event Extractioncited by 10
- 2024RAMBO: Enhancing RAG-based Repository-Level Method Body Completioncited by 10
38 more
- 2025Towards an Understanding of Context Utilization in Code Intelligencecited by 10
- 2025Self-Routing RAG: Binding Selective Retrieval with Knowledge Verbalizationcited by 9
- 2024CATCODER: Repository-Level Code Generation with Relevant Code and Type Contextcited by 8
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completioncited by 7
- 2024RepoGenReflex: Enhancing Repository-Level Code Completion with Verbal Reinforcement and Retrieval-Augmented Generationcited by 6
- 2025Towards Realistic Project-Level Code Generation via Multi-Agent Collaboration and Semantic Architecture Modelingcited by 6
- 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChatcited by 5
- 2025Enhancing Project-Specific Code Completion by Inferring Internal API Informationcited by 5
- 2025Impact-driven Context Filtering For Cross-file Code Completioncited by 5
- 2025SecureReviewer: Enhancing Large Language Models for Secure Code Review through Secure-aware Fine-tuningcited by 5
- 2026RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Modelscited by 5
- 2026When Parallelism Pays Off: Cohesion-Aware Task Partitioning for Multi-Agent Codingcited by 4
- 2024Renaissance of Literate Programming in the Era of LLMs: Enhancing LLM-Based Code Generation in Large-Scale Projectscited by 3
- 2025Practical Code RAG at Scale: Task-Aware Retrieval Design Choices under Compute Budgetscited by 3
- 2024On The Importance of Reasoning for Context Retrieval in Repository-Level Code Editingcited by 2
- 2025TENET: One Step Toward Test-Driven Development for Repository-Level Code Generationcited by 2
- 2024Retrieval-augmented code completion for local projects using large language modelscited by 1
- 2026ContiguousKV: Accelerating LLM Prefill with Granularity-Aligned KV Cache Managementcited by 1
- 2026Evaluating and Achieving Controllable Code Completion in Code LLMcited by 1
- 2026Knowdit: Agentic Smart Contract Vulnerability Detection with Auditing Knowledge Summarizationcited by 1
- 2026RAT: RunAnyThing via Fully Automated Environment Configurationcited by 1
- 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generationcited by 1
- 2024A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Modelcited by 0
- 2025Judge a Book by its Cover: Investigating Multi-Modal LLMs for Multi-Page Handwritten Document Transcriptioncited by 0
- 2025Maximally-Informative Retrieval for State Space Model Generationcited by 0
- 2025Which Programming Language and Model Work Best With LLM-as-a-Judge For Code Retrieval?cited by 0
- 2025Challenge on Optimization of Context Collection for Code Completioncited by 0
- 2025Relative Positioning Based Code Chunking Method For Rich Context Retrieval In Repository Level Code Completion Task With Code Language Modelcited by 0
- 2025A Matter of Representation: Towards Graph-Based Abstract Code Generationcited by 0
- 2025CoRoVA: Compressed Representations for Vector-Augmented Code Completioncited by 0
- 2026Hierarchical Embedding Fusion for Retrieval-Augmented Code Generationcited by 0
- 2026How Does Chunking Affect Retrieval-Augmented Code Completion? A Controlled Empirical Studycited by 0
- 2026Predictive Prefetching for Retrieval-Augmented Generationcited by 0
- 2026KACE: Knowledge-Adaptive Context Engineering for Mathematical Reasoningcited by 0
- 2026FlowArk: Boosting Agentic Data-flow Analysis for Android Apps via Context-Aware Knowledge Reusecited by 0
- 2026CodeNib: A Multi-View Data System for Serving Repository Context to Coding Agentscited by 0
- 2026The Recall Trap: A Recall-Maximizing Retriever Configuration Reduces Issue Resolution in Fixed-Budget Code Contextcited by 0
50 most cited of 55 All 55 (JSON)
- 2026Assurance Envelopes for Autonomous Coding Agents: Minimum-Cost Evidence for Software Change14 Sep 2026
- 2026RCL: A Retrieval-Confidence Layer for Detecting Insufficient Context in Enterprise Retrieval-Augmented Code Generation10 Sep 2026
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation1 Sep 2026
- 2026The Thousand-Graph Hypothesis: A Testable Hypothesis of Task-Conditioned Relation Materialization in Repository-Level Code Reasoning27 Aug 2026
- 2026Specification Portability Across LLM Development Agents: Cross-Agent Compatibility in Specification-Driven Software Migration21 Aug 2026
- 2026The Recall Trap: A Recall-Maximizing Retriever Configuration Reduces Issue Resolution in Fixed-Budget Code Context14 Aug 2026
- 2026RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Models28 Jul 2026
- 2026CodeNib: A Multi-View Data System for Serving Repository Context to Coding Agents28 Jul 2026
- 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generation27 Jul 2026
- 2026FlowArk: Boosting Agentic Data-flow Analysis for Android Apps via Context-Aware Knowledge Reuse13 Jul 2026
- 2026When Parallelism Pays Off: Cohesion-Aware Task Partitioning for Multi-Agent Coding31 May 2026
- 2026KACE: Knowledge-Adaptive Context Engineering for Mathematical Reasoning30 May 2026
38 more
- 2026Predictive Prefetching for Retrieval-Augmented Generation18 May 2026
- 2026How Does Chunking Affect Retrieval-Augmented Code Completion? A Controlled Empirical Study6 May 2026
- 2026RAT: RunAnyThing via Fully Automated Environment Configuration25 Apr 2026
- 2026Knowdit: Agentic Smart Contract Vulnerability Detection with Auditing Knowledge Summarization27 Mar 2026
- 2026Hierarchical Embedding Fusion for Retrieval-Augmented Code Generation4 Feb 2026
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completion27 Jan 2026
- 2026Evaluating and Achieving Controllable Code Completion in Code LLM22 Jan 2026
- 2026ContiguousKV: Accelerating LLM Prefill with Granularity-Aligned KV Cache Management20 Jan 2026
- 2025Towards Realistic Project-Level Code Generation via Multi-Agent Collaboration and Semantic Architecture Modeling5 Nov 2025
- 2025SecureReviewer: Enhancing Large Language Models for Secure Code Review through Secure-aware Fine-tuning30 Oct 2025
- 2025Practical Code RAG at Scale: Task-Aware Retrieval Design Choices under Compute Budgets23 Oct 2025
- 2025CoRoVA: Compressed Representations for Vector-Augmented Code Completion22 Oct 2025
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025A Matter of Representation: Towards Graph-Based Abstract Code Generation15 Oct 2025
- 2025Relative Positioning Based Code Chunking Method For Rich Context Retrieval In Repository Level Code Completion Task With Code Language Model7 Oct 2025
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025Challenge on Optimization of Context Collection for Code Completion5 Oct 2025
- 2025Improving Code Localization with Repository Memory1 Oct 2025
- 2025Which Programming Language and Model Work Best With LLM-as-a-Judge For Code Retrieval?30 Sep 2025
- 2025TENET: One Step Toward Test-Driven Development for Repository-Level Code Generation29 Sep 2025
- 2025LLM/Agent-as-Data-Analyst: A Survey28 Sep 2025
- 2025Impact-driven Context Filtering For Cross-file Code Completion8 Aug 2025
- 2025Enhancing Project-Specific Code Completion by Inferring Internal API Information28 Jul 2025
- 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat24 Jul 2025
- 2025Maximally-Informative Retrieval for State Space Model Generation13 Jun 2025
- 2025Towards an Understanding of Context Utilization in Code Intelligence11 Apr 2025
- 2025OpenCodeInstruct: A Large-scale Instruction Tuning Dataset for Code LLMs5 Apr 2025
- 2025Self-Routing RAG: Binding Selective Retrieval with Knowledge Verbalization1 Apr 2025
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond26 Mar 2025
- 2025Judge a Book by its Cover: Investigating Multi-Modal LLMs for Multi-Page Handwritten Document Transcription27 Feb 2025
- 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities23 Jan 2025
- 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representations22 Jan 2025
- 2024Renaissance of Literate Programming in the Era of LLMs: Enhancing LLM-Based Code Generation in Large-Scale Projects25 Dec 2024
- 2024RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graph3 Oct 2024
- 2024RAMBO: Enhancing RAG-based Repository-Level Method Body Completion23 Sep 2024
- 2024RepoGenReflex: Enhancing Repository-Level Code Completion with Verbal Reinforcement and Retrieval-Augmented Generation19 Sep 2024
- 2024Qwen2.5-Coder Technical Report18 Sep 2024
- 2024Retrieval-augmented code completion for local projects using large language models9 Aug 2024
50 newest of 55 All 55 (JSON)
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyondcited by 22
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 20
- 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunitiescited by 17
- 2025Self-Routing RAG: Binding Selective Retrieval with Knowledge Verbalizationcited by 9
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2024RepoGenReflex: Enhancing Repository-Level Code Completion with Verbal Reinforcement and Retrieval-Augmented Generationcited by 6
- 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChatcited by 5
- 2025Impact-driven Context Filtering For Cross-file Code Completioncited by 5
- 2024Retrieval-augmented code completion for local projects using large language modelscited by 1
- 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generationcited by 1
- 2024A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Modelcited by 0
- 2025CoRoVA: Compressed Representations for Vector-Augmented Code Completioncited by 0
12 most cited of 16 All 16 (JSON)
- 2026RCL: A Retrieval-Confidence Layer for Detecting Insufficient Context in Enterprise Retrieval-Augmented Code Generation10 Sep 2026
- 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generation27 Jul 2026
- 2026Predictive Prefetching for Retrieval-Augmented Generation18 May 2026
- 2026How Does Chunking Affect Retrieval-Augmented Code Completion? A Controlled Empirical Study6 May 2026
- 2026Hierarchical Embedding Fusion for Retrieval-Augmented Code Generation4 Feb 2026
- 2025CoRoVA: Compressed Representations for Vector-Augmented Code Completion22 Oct 2025
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025Impact-driven Context Filtering For Cross-file Code Completion8 Aug 2025
- 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat24 Jul 2025
- 2025Self-Routing RAG: Binding Selective Retrieval with Knowledge Verbalization1 Apr 2025
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond26 Mar 2025
12 newest of 16 All 16 (JSON)
- 2025LLM/Agent-as-Data-Analyst: A Surveycited by 15
- 2024Debate as Optimization: Adaptive Conformal Prediction and Diverse Retrieval for Event Extractioncited by 10
- 2025Towards Realistic Project-Level Code Generation via Multi-Agent Collaboration and Semantic Architecture Modelingcited by 6
- 2026When Parallelism Pays Off: Cohesion-Aware Task Partitioning for Multi-Agent Codingcited by 4
- 2026Knowdit: Agentic Smart Contract Vulnerability Detection with Auditing Knowledge Summarizationcited by 1
- 2026FlowArk: Boosting Agentic Data-flow Analysis for Android Apps via Context-Aware Knowledge Reusecited by 0
- 2026CodeNib: A Multi-View Data System for Serving Repository Context to Coding Agentscited by 0
- 2026Assurance Envelopes for Autonomous Coding Agents: Minimum-Cost Evidence for Software Changecited by 0
- 2026Assurance Envelopes for Autonomous Coding Agents: Minimum-Cost Evidence for Software Change14 Sep 2026
- 2026CodeNib: A Multi-View Data System for Serving Repository Context to Coding Agents28 Jul 2026
- 2026FlowArk: Boosting Agentic Data-flow Analysis for Android Apps via Context-Aware Knowledge Reuse13 Jul 2026
- 2026When Parallelism Pays Off: Cohesion-Aware Task Partitioning for Multi-Agent Coding31 May 2026
- 2026Knowdit: Agentic Smart Contract Vulnerability Detection with Auditing Knowledge Summarization27 Mar 2026
- 2025Towards Realistic Project-Level Code Generation via Multi-Agent Collaboration and Semantic Architecture Modeling5 Nov 2025
- 2025LLM/Agent-as-Data-Analyst: A Survey28 Sep 2025
- 2024Debate as Optimization: Adaptive Conformal Prediction and Diverse Retrieval for Event Extraction18 Jun 2024
- 2024Qwen2.5-Coder Technical Reportcited by 1,151
- 2026RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Modelscited by 5
- 2024On The Importance of Reasoning for Context Retrieval in Repository-Level Code Editingcited by 2
- 2026KACE: Knowledge-Adaptive Context Engineering for Mathematical Reasoningcited by 0
- 2026RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Models28 Jul 2026
- 2026KACE: Knowledge-Adaptive Context Engineering for Mathematical Reasoning30 May 2026
- 2024Qwen2.5-Coder Technical Report18 Sep 2024
- 2024On The Importance of Reasoning for Context Retrieval in Repository-Level Code Editing6 Jun 2024
- 2024RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graphcited by 88
- 2025OpenCodeInstruct: A Large-scale Instruction Tuning Dataset for Code LLMscited by 57
- 2024Perception of Knowledge Boundary for Large Language Models through Semi-open-ended Question Answeringcited by 20
- 2025Improving Code Localization with Repository Memorycited by 19
- 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representationscited by 17
- 2024RAMBO: Enhancing RAG-based Repository-Level Method Body Completioncited by 10
- 2025Towards an Understanding of Context Utilization in Code Intelligencecited by 10
- 2024CATCODER: Repository-Level Code Generation with Relevant Code and Type Contextcited by 8
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completioncited by 7
- 2025Enhancing Project-Specific Code Completion by Inferring Internal API Informationcited by 5
- 2025SecureReviewer: Enhancing Large Language Models for Secure Code Review through Secure-aware Fine-tuningcited by 5
- 2024Renaissance of Literate Programming in the Era of LLMs: Enhancing LLM-Based Code Generation in Large-Scale Projectscited by 3
12 most cited of 25 All 25 (JSON)
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation1 Sep 2026
- 2026The Thousand-Graph Hypothesis: A Testable Hypothesis of Task-Conditioned Relation Materialization in Repository-Level Code Reasoning27 Aug 2026
- 2026Specification Portability Across LLM Development Agents: Cross-Agent Compatibility in Specification-Driven Software Migration21 Aug 2026
- 2026The Recall Trap: A Recall-Maximizing Retriever Configuration Reduces Issue Resolution in Fixed-Budget Code Context14 Aug 2026
- 2026RAT: RunAnyThing via Fully Automated Environment Configuration25 Apr 2026
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completion27 Jan 2026
- 2026Evaluating and Achieving Controllable Code Completion in Code LLM22 Jan 2026
- 2025SecureReviewer: Enhancing Large Language Models for Secure Code Review through Secure-aware Fine-tuning30 Oct 2025
- 2025Practical Code RAG at Scale: Task-Aware Retrieval Design Choices under Compute Budgets23 Oct 2025
- 2025A Matter of Representation: Towards Graph-Based Abstract Code Generation15 Oct 2025
- 2025Relative Positioning Based Code Chunking Method For Rich Context Retrieval In Repository Level Code Completion Task With Code Language Model7 Oct 2025
- 2025Challenge on Optimization of Context Collection for Code Completion5 Oct 2025
12 newest of 25 All 25 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2025CodeRAG: Finding Relevant and Necessary Knowledge for Retrieval-Augmented Repository-Level Code Completion
- 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
- 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model
- 2025SaraCoder: Orchestrating Semantic and Structural Cues for Resource-Optimized Repository-Level Code Completion
- 2026RepoShapley: Shapley-Enhanced Context Filtering for Repository-Level Code Completion
- 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generation
- 2025ReCode: Improving LLM-based Code Repair with Fine-Grained Retrieval-Augmented Generation
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?