What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
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
- 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model11 Jun
- 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completion2 Apr
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
- 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar
- 2021Retrieval Augmented Code Generation and Summarization26 Aug
Other references · 37
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2024Qwen2.5 Technical Reportcited by 4,942
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,839
- 2022Competition-Level Code Generation with AlphaCodecited by 1,462
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 800
- 2023Making Retrieval-Augmented Language Models Robust to Irrelevant Contextcited by 369
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
- 2024CodeAgent: Enhancing Code Generation with Tool-Integrated Agent Systems for Real-World Repo-level Coding Challengescited by 282
25 more
- 2020IntelliCode Compose: Code Generation Using Transformercited by 227
- 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 183
- 2022DocPrompting: Generating Code by Retrieving the Docscited by 153
- 2023CodePlan: Repository-level Coding using LLMs and Planningcited by 140
- 2023CodeBERTScore: Evaluating Code Generation with Pretrained Models of Codecited by 102
- 2024RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graphcited by 91
- 2022CERT: Continual Pre-Training on Sketches for Library-Oriented Code Generationcited by 87
- 2024ToolGen: Unified Tool Retrieval and Calling via Generationcited by 74
- 2022CoCoMIC: Code Completion By Jointly Modeling In-file and Cross-file Contextcited by 65
- 2022CodeFill: Multi-token Code Completion by Jointly Learning from Structure and Naming Sequencescited by 50
- 2024Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedbackcited by 46
- 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completioncited by 40
- 2023Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language Modelscited by 38
- 2024REPOFUSE: Repository-Level Code Completion with Fused Dual Contextcited by 32
- 2021Code Completion by Modeling Flattened Abstract Syntax Trees as Graphscited by 30
- 2024Probing-RAG: Self-Probing to Guide Language Models in Selective Document Retrievalcited by 29
- 2020Opportunities and Challenges in Code Search Toolscited by 22
- 2024On the Impacts of Contexts on Repository-Level Code Generationcited by 22
- 2024When to Stop? Towards Efficient Code Generation in LLMs with Excess Token Preventioncited by 21
- 2023Domain Adaptive Code Completion via Language Models and Decoupled Domain Databasescited by 19
- 2024De-Hallucinator: Mitigating LLM Hallucinations in Code Generation Tasks via Iterative Groundingcited by 15
- 2024IRCoCo: Immediate Rewards-Guided Deep Reinforcement Learning for Code Completioncited by 13
- 2024Advanced RAG Models with Graph Structures: Optimizing Complex Knowledge Reasoning and Text Generationcited by 13
- 2016Learning Python Code Suggestion with a Sparse Pointer Networkcited by 12
- 2024RAMBO: Enhancing RAG-based Repository-Level Method Body Completioncited by 10
Built on by
Citing papers per year: 2025: 6; 2026: 16.
22 papers.
Sort:
By area:
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 23
- 2025An Empirical Study of Agent Developer Practices in AI Agent Frameworkscited by 14
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completioncited by 7
- 2025Context Engineering for Multi-Agent LLM Code Assistants Using Elicit, NotebookLM, ChatGPT, and Claude Codecited by 5
- 2025EffiReasonTrans: RL-Optimized Reasoning for Code Translationcited by 5
- 2026VeriCache: Turning Lossy KV Cache into Lossless LLM Inferencecited by 5
- 2026RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Modelscited by 5
- 2026DRAINCODE: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoningcited by 3
- 2026PhoenixRepair: Rethinking Repair Strategy Exploration in Software Agentscited by 2
- 2025LLMs as Packagers of HPC Softwarecited by 1
- 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Codecited by 1
10 more
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Taskscited by 1
- 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generationcited by 1
- 2026Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generationcited by 1
- 2026SWE-Gate: Passing Functional Tests Is Not Enough for Software Engineering Agentscited by 1
- 2026Context-Augmented Code Generation Using Programming Knowledge Graphscited by 0
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generationcited by 0
- 2026ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generationcited by 0
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generationcited by 0
- 2026Efficient SWE Agent Benchmarking via Trajectory-Aware Evaluationcited by 0
- 2026MAP4CS: A Multi-dimensional Data Pruning Framework for Efficient Code Retriever Fine-tuningcited by 0
- 2026MAP4CS: A Multi-dimensional Data Pruning Framework for Efficient Code Retriever Fine-tuning8 Oct 2026
- 2026SWE-Gate: Passing Functional Tests Is Not Enough for Software Engineering Agents3 Sep 2026
- 2026Efficient SWE Agent Benchmarking via Trajectory-Aware Evaluation1 Sep 2026
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation1 Sep 2026
- 2026Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation3 Aug 2026
- 2026RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Models28 Jul 2026
- 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generation27 Jul 2026
- 2026PhoenixRepair: Rethinking Repair Strategy Exploration in Software Agents21 Jul 2026
- 2026ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generation9 Jul 2026
- 2026VeriCache: Turning Lossy KV Cache into Lossless LLM Inference17 May 2026
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Tasks14 May 2026
- 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Code6 May 2026
10 more
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generation2 May 2026
- 2026Context-Augmented Code Generation Using Programming Knowledge Graphs28 Jan 2026
- 2026DRAINCODE: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoning28 Jan 2026
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completion27 Jan 2026
- 2025An Empirical Study of Agent Developer Practices in AI Agent Frameworks1 Dec 2025
- 2025LLMs as Packagers of HPC Software7 Nov 2025
- 2025EffiReasonTrans: RL-Optimized Reasoning for Code Translation21 Oct 2025
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025Context Engineering for Multi-Agent LLM Code Assistants Using Elicit, NotebookLM, ChatGPT, and Claude Code9 Aug 2025
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 23
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2026DRAINCODE: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoningcited by 3
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Taskscited by 1
- 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generationcited by 1
- 2026Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generationcited by 1
- 2026MAP4CS: A Multi-dimensional Data Pruning Framework for Efficient Code Retriever Fine-tuningcited by 0
- 2026MAP4CS: A Multi-dimensional Data Pruning Framework for Efficient Code Retriever Fine-tuning8 Oct 2026
- 2026Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation3 Aug 2026
- 2026Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generation27 Jul 2026
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Tasks14 May 2026
- 2026DRAINCODE: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoning28 Jan 2026
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025An Empirical Study of Agent Developer Practices in AI Agent Frameworkscited by 14
- 2025Context Engineering for Multi-Agent LLM Code Assistants Using Elicit, NotebookLM, ChatGPT, and Claude Codecited by 5
- 2026SWE-Gate: Passing Functional Tests Is Not Enough for Software Engineering Agentscited by 1
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generationcited by 0
- 2026Efficient SWE Agent Benchmarking via Trajectory-Aware Evaluationcited by 0
- 2026SWE-Gate: Passing Functional Tests Is Not Enough for Software Engineering Agents3 Sep 2026
- 2026Efficient SWE Agent Benchmarking via Trajectory-Aware Evaluation1 Sep 2026
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generation2 May 2026
- 2025An Empirical Study of Agent Developer Practices in AI Agent Frameworks1 Dec 2025
- 2025Context Engineering for Multi-Agent LLM Code Assistants Using Elicit, NotebookLM, ChatGPT, and Claude Code9 Aug 2025
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completioncited by 7
- 2025LLMs as Packagers of HPC Softwarecited by 1
- 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Codecited by 1
- 2026Context-Augmented Code Generation Using Programming Knowledge Graphscited by 0
- 2026ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generationcited by 0
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generationcited by 0
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation1 Sep 2026
- 2026ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generation9 Jul 2026
- 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Code6 May 2026
- 2026Context-Augmented Code Generation Using Programming Knowledge Graphs28 Jan 2026
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completion27 Jan 2026
- 2025LLMs as Packagers of HPC Software7 Nov 2025
Similar, not cited
Close in wording, no citation either way
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities
- 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat
- 2024Context-Augmented Code Generation Using Programming Knowledge Graphs
- 2025When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?
- 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
- 2024Evaluating the Effectiveness and Efficiency of Demonstration Retrievers in RAG for Coding Tasks
- 2024Retrieval-augmented code completion for local projects using large language models