mlsanityData to 7 Oct 2026

Repoformer: Selective Retrieval for Repository-Level Code Completion

arXiv 2403.10059 ↗First posted 15 Mar 2024cs.SE cs.CLcited by 55

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

  1. 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar

Other references · 31

  1. 2023GPT-4 Technical Reportcited by 18,132
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  3. 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
  4. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  5. 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,800
  6. 2022Language Models (Mostly) Know What They Knowcited by 1,783
  7. 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memoriescited by 1,103
  8. 2023Accelerating Large Language Model Decoding with Speculative Samplingcited by 975
  9. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
  10. 2023REPLUG: Retrieval-Augmented Black-Box Language Modelscited by 786
  11. 2023In-Context Retrieval-Augmented Language Modelscited by 694
  12. 2023Active Retrieval Augmented Generationcited by 506
19 more
  1. 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
  2. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
  3. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
  4. 2022The Stack: 3 TB of permissively licensed source codecited by 354
  5. 2022Efficient Training of Language Models to Fill in the Middlecited by 248
  6. 2020IntelliCode Compose: Code Generation Using Transformercited by 225
  7. 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 181
  8. 2022DocPrompting: Generating Code by Retrieving the Docscited by 151
  9. 2023CodeGen2: Lessons for Training LLMs on Programming and Natural Languagescited by 124
  10. 2022Repository-Level Prompt Generation for Large Language Models of Codecited by 106
  11. 2021Efficient Nearest Neighbor Language Modelscited by 93
  12. 2023Self-Knowledge Guided Retrieval Augmentation for Large Language Modelscited by 69
  13. 2022CoCoMIC: Code Completion By Jointly Modeling In-file and Cross-file Contextcited by 64
  14. 2022When Language Model Meets Private Librarycited by 54
  15. 2023RepoFusion: Training Code Models to Understand Your Repositorycited by 40
  16. 2021CoCoSum: Contextual Code Summarization with Multi-Relational Graph Neural Networkcited by 22
  17. 2022ContraCLM: Contrastive Learning For Causal Language Modelcited by 18
  18. 2022You can't pick your neighbors, or can you? When and how to rely on retrieval in the kNN-LMcited by 18
  19. 2023Better Context Makes Better Code Language Models: A Case Study on Function Call Argument Completioncited by 14

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 11; 2025: 24; 2026: 20.

55 papers.

Sort:

By area:

  1. 2024Qwen2.5-Coder Technical Reportcited by 1,151
  2. 2024RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graphcited by 88
  3. 2025OpenCodeInstruct: A Large-scale Instruction Tuning Dataset for Code LLMscited by 57
  4. 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyondcited by 22
  5. 2024Perception of Knowledge Boundary for Large Language Models through Semi-open-ended Question Answeringcited by 20
  6. 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 20
  7. 2025Improving Code Localization with Repository Memorycited by 19
  8. 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representationscited by 17
  9. 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunitiescited by 17
  10. 2025LLM/Agent-as-Data-Analyst: A Surveycited by 15
  11. 2024Debate as Optimization: Adaptive Conformal Prediction and Diverse Retrieval for Event Extractioncited by 10
  12. 2024RAMBO: Enhancing RAG-based Repository-Level Method Body Completioncited by 10
38 more
  1. 2025Towards an Understanding of Context Utilization in Code Intelligencecited by 10
  2. 2025Self-Routing RAG: Binding Selective Retrieval with Knowledge Verbalizationcited by 9
  3. 2024CATCODER: Repository-Level Code Generation with Relevant Code and Type Contextcited by 8
  4. 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
  5. 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completioncited by 7
  6. 2024RepoGenReflex: Enhancing Repository-Level Code Completion with Verbal Reinforcement and Retrieval-Augmented Generationcited by 6
  7. 2025Towards Realistic Project-Level Code Generation via Multi-Agent Collaboration and Semantic Architecture Modelingcited by 6
  8. 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChatcited by 5
  9. 2025Enhancing Project-Specific Code Completion by Inferring Internal API Informationcited by 5
  10. 2025Impact-driven Context Filtering For Cross-file Code Completioncited by 5
  11. 2025SecureReviewer: Enhancing Large Language Models for Secure Code Review through Secure-aware Fine-tuningcited by 5
  12. 2026RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Modelscited by 5
  13. 2026When Parallelism Pays Off: Cohesion-Aware Task Partitioning for Multi-Agent Codingcited by 4
  14. 2024Renaissance of Literate Programming in the Era of LLMs: Enhancing LLM-Based Code Generation in Large-Scale Projectscited by 3
  15. 2025Practical Code RAG at Scale: Task-Aware Retrieval Design Choices under Compute Budgetscited by 3
  16. 2024On The Importance of Reasoning for Context Retrieval in Repository-Level Code Editingcited by 2
  17. 2025TENET: One Step Toward Test-Driven Development for Repository-Level Code Generationcited by 2
  18. 2024Retrieval-augmented code completion for local projects using large language modelscited by 1
  19. 2026ContiguousKV: Accelerating LLM Prefill with Granularity-Aligned KV Cache Managementcited by 1
  20. 2026Evaluating and Achieving Controllable Code Completion in Code LLMcited by 1
  21. 2026Knowdit: Agentic Smart Contract Vulnerability Detection with Auditing Knowledge Summarizationcited by 1
  22. 2026RAT: RunAnyThing via Fully Automated Environment Configurationcited by 1
  23. 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generationcited by 1
  24. 2024A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Modelcited by 0
  25. 2025Judge a Book by its Cover: Investigating Multi-Modal LLMs for Multi-Page Handwritten Document Transcriptioncited by 0
  26. 2025Maximally-Informative Retrieval for State Space Model Generationcited by 0
  27. 2025Which Programming Language and Model Work Best With LLM-as-a-Judge For Code Retrieval?cited by 0
  28. 2025Challenge on Optimization of Context Collection for Code Completioncited by 0
  29. 2025Relative Positioning Based Code Chunking Method For Rich Context Retrieval In Repository Level Code Completion Task With Code Language Modelcited by 0
  30. 2025A Matter of Representation: Towards Graph-Based Abstract Code Generationcited by 0
  31. 2025CoRoVA: Compressed Representations for Vector-Augmented Code Completioncited by 0
  32. 2026Hierarchical Embedding Fusion for Retrieval-Augmented Code Generationcited by 0
  33. 2026How Does Chunking Affect Retrieval-Augmented Code Completion? A Controlled Empirical Studycited by 0
  34. 2026Predictive Prefetching for Retrieval-Augmented Generationcited by 0
  35. 2026KACE: Knowledge-Adaptive Context Engineering for Mathematical Reasoningcited by 0
  36. 2026FlowArk: Boosting Agentic Data-flow Analysis for Android Apps via Context-Aware Knowledge Reusecited by 0
  37. 2026CodeNib: A Multi-View Data System for Serving Repository Context to Coding Agentscited by 0
  38. 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)

Similar, not cited

Close in wording, no citation either way

  1. 2025CodeRAG: Finding Relevant and Necessary Knowledge for Retrieval-Augmented Repository-Level Code Completion
  2. 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
  3. 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model
  4. 2025SaraCoder: Orchestrating Semantic and Structural Cues for Resource-Optimized Repository-Level Code Completion
  5. 2026RepoShapley: Shapley-Enhanced Context Filtering for Repository-Level Code Completion
  6. 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generation
  7. 2025ReCode: Improving LLM-based Code Repair with Fine-Grained Retrieval-Augmented Generation
  8. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?