mlsanityData to 14 Oct 2026

What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond

arXiv 2503.20589 ↗First posted 26 Mar 2025cs.SEcited by 22

On the map: Retrieval-augmented generation → RAG for code

Abstract (arXiv)

Repository-level code generation remains challenging due to complex code dependencies and the limitations of large language models (LLMs) in processing long contexts. While retrieval-augmented generation (RAG) frameworks are widely adopted, the effectiveness of different retrieved information sources-contextual code, APIs, and similar snippets-has not been rigorously analyzed. Through an empirical study on two benchmarks, we demonstrate that in-context code and potential API information significantly enhance LLM performance, whereas retrieved similar code often introduces noise, degrading results by up to 15%. Based on the preliminary results, we propose AllianceCoder, a novel context-integrated method that employs chain-of-thought prompting to decompose user queries into implementation steps and retrieves APIs via semantic description matching. Through extensive experiments on CoderEval and RepoExec, AllianceCoder achieves state-of-the-art performance, improving Pass@1 by up to 20% over existing approaches.

Key facts. Cited by 22 papers in the map (data through 14 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 42 of its 61 references that are in the map. First posted on arXiv 26 Mar 2025.

Builds on

42 of 61 references.

Closest ancestors · 5

Same direction, newest first

  1. 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model11 Jun
  2. 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completion2 Apr
  3. 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
  4. 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar
  5. 2021Retrieval Augmented Code Generation and Summarization26 Aug

Other references · 37

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  2. 2024Qwen2.5 Technical Reportcited by 4,942
  3. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  4. 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,839
  5. 2022Competition-Level Code Generation with AlphaCodecited by 1,462
  6. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  7. 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 800
  8. 2023Making Retrieval-Augmented Language Models Robust to Irrelevant Contextcited by 369
  9. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
  10. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
  11. 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
  12. 2024CodeAgent: Enhancing Code Generation with Tool-Integrated Agent Systems for Real-World Repo-level Coding Challengescited by 282
25 more
  1. 2020IntelliCode Compose: Code Generation Using Transformercited by 227
  2. 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 183
  3. 2022DocPrompting: Generating Code by Retrieving the Docscited by 153
  4. 2023CodePlan: Repository-level Coding using LLMs and Planningcited by 140
  5. 2023CodeBERTScore: Evaluating Code Generation with Pretrained Models of Codecited by 102
  6. 2024RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graphcited by 91
  7. 2022CERT: Continual Pre-Training on Sketches for Library-Oriented Code Generationcited by 87
  8. 2024ToolGen: Unified Tool Retrieval and Calling via Generationcited by 74
  9. 2022CoCoMIC: Code Completion By Jointly Modeling In-file and Cross-file Contextcited by 65
  10. 2022CodeFill: Multi-token Code Completion by Jointly Learning from Structure and Naming Sequencescited by 50
  11. 2024Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedbackcited by 46
  12. 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completioncited by 40
  13. 2023Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language Modelscited by 38
  14. 2024REPOFUSE: Repository-Level Code Completion with Fused Dual Contextcited by 32
  15. 2021Code Completion by Modeling Flattened Abstract Syntax Trees as Graphscited by 30
  16. 2024Probing-RAG: Self-Probing to Guide Language Models in Selective Document Retrievalcited by 29
  17. 2020Opportunities and Challenges in Code Search Toolscited by 22
  18. 2024On the Impacts of Contexts on Repository-Level Code Generationcited by 22
  19. 2024When to Stop? Towards Efficient Code Generation in LLMs with Excess Token Preventioncited by 21
  20. 2023Domain Adaptive Code Completion via Language Models and Decoupled Domain Databasescited by 19
  21. 2024De-Hallucinator: Mitigating LLM Hallucinations in Code Generation Tasks via Iterative Groundingcited by 15
  22. 2024IRCoCo: Immediate Rewards-Guided Deep Reinforcement Learning for Code Completioncited by 13
  23. 2024Advanced RAG Models with Graph Structures: Optimizing Complex Knowledge Reasoning and Text Generationcited by 13
  24. 2016Learning Python Code Suggestion with a Sparse Pointer Networkcited by 12
  25. 2024RAMBO: Enhancing RAG-based Repository-Level Method Body Completioncited by 10

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 6; 2026: 16.

22 papers.

Sort:

By area:

  1. 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 23
  2. 2025An Empirical Study of Agent Developer Practices in AI Agent Frameworkscited by 14
  3. 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
  4. 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completioncited by 7
  5. 2025Context Engineering for Multi-Agent LLM Code Assistants Using Elicit, NotebookLM, ChatGPT, and Claude Codecited by 5
  6. 2025EffiReasonTrans: RL-Optimized Reasoning for Code Translationcited by 5
  7. 2026VeriCache: Turning Lossy KV Cache into Lossless LLM Inferencecited by 5
  8. 2026RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Modelscited by 5
  9. 2026DRAINCODE: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoningcited by 3
  10. 2026PhoenixRepair: Rethinking Repair Strategy Exploration in Software Agentscited by 2
  11. 2025LLMs as Packagers of HPC Softwarecited by 1
  12. 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Codecited by 1
10 more
  1. 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Taskscited by 1
  2. 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generationcited by 1
  3. 2026Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generationcited by 1
  4. 2026SWE-Gate: Passing Functional Tests Is Not Enough for Software Engineering Agentscited by 1
  5. 2026Context-Augmented Code Generation Using Programming Knowledge Graphscited by 0
  6. 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generationcited by 0
  7. 2026ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generationcited by 0
  8. 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generationcited by 0
  9. 2026Efficient SWE Agent Benchmarking via Trajectory-Aware Evaluationcited by 0
  10. 2026MAP4CS: A Multi-dimensional Data Pruning Framework for Efficient Code Retriever Fine-tuningcited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
  2. 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities
  3. 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat
  4. 2024Context-Augmented Code Generation Using Programming Knowledge Graphs
  5. 2025When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?
  6. 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
  7. 2024Evaluating the Effectiveness and Efficiency of Demonstration Retrievers in RAG for Coding Tasks
  8. 2024Retrieval-augmented code completion for local projects using large language models