An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
Code generation aims to automatically generate code snippets of specific programming language according to natural language descriptions. The continuous advancements in deep learning, particularly pre-trained models, have empowered the code generation task to achieve remarkable performance. One main challenge of pre-trained models for code generation is the semantic gap between natural language requirements and source code. To address the issue, prior studies typically adopt a retrieval-augmented framework for the task, where the similar code snippets collected by a retrieval process can be leveraged to help understand the requirements and provide guidance for the generation process. However, there is a lack of systematic study on the application of this framework for code generation, including the impact of the final generated results and the specific usage of the framework. In this paper, we choose three popular pre-trained code models, namely CodeGen, UniXcoder, and CodeT5, to assess the impact of the quality and utilization of retrieved code on the retrieval-augmented framework. Our analysis shows that the retrieval-augmented framework is beneficial for improving the performance of the existing pre-trained models. We also provide suggestions on the utilization of the retrieval-augmented code generation framework: BM25 and Sequential Integration Fusion are recommended due to their convenience and superior performance. Sketch Filling Fusion, which extracts a sketch of relevant code, could help the model improve its performance further. Additionally, we conduct experiments to investigate the influence of the retrieval-augmented framework on large language models for code generation, showing the effectiveness of the framework, and we discuss the trade-off between performance improvement and computational costs in each phase within the framework.
Key facts. Cited by 18 papers in the map (data through 14 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 59 of its 81 references that are in the map. First posted on arXiv 23 Jan 2025.
Builds on
59 of 81 references.
Closest ancestors · 2
Same direction, newest first
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
- 2021Retrieval Augmented Code Generation and Summarization26 Aug
Other references · 57
- 2017Attention Is All You Needcited by 60,361
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,372
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,513
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2020The Pile: An 800GB Dataset of Diverse Text for Language Modelingcited by 2,411
- 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,141
- 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
38 more
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2021BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Modelscited by 1,252
- 2020Leveraging Passage Retrieval with Generative Models for Open Domain Question Answeringcited by 1,210
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2021GLM: General Language Model Pretraining with Autoregressive Blank Infillingcited by 1,031
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2021Measuring Coding Challenge Competence With APPScited by 902
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 885
- 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 800
- 2017Reading Wikipedia to Answer Open-Domain Questionscited by 777
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 609
- 2023Active Retrieval Augmented Generationcited by 516
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
- 2022CodeT: Code Generation with Generated Testscited by 384
- 2021Unified Pre-training for Program Understanding and Generationcited by 366
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 333
- 2020IntelliCode Compose: Code Generation Using Transformercited by 227
- 2018Learning to Mine Aligned Code and Natural Language Pairs from Stack Overflowcited by 165
- 2022DocPrompting: Generating Code by Retrieving the Docscited by 153
- 2023CodePlan: Repository-level Coding using LLMs and Planningcited by 140
- 2022Dense Text Retrieval based on Pretrained Language Models: A Surveycited by 136
- 2022RetroMAE: Pre-Training Retrieval-oriented Language Models Via Masked Auto-Encodercited by 118
- 2018Mapping Language to Code in Programmatic Contextcited by 104
- 2017Abstract Syntax Networks for Code Generation and Semantic Parsingcited by 92
- 2018TRANX: A Transition-based Neural Abstract Syntax Parser for Semantic Parsing and Code Generationcited by 88
- 2016Latent Predictor Networks for Code Generationcited by 73
- 2018A Retrieve-and-Edit Framework for Predicting Structured Outputscited by 73
- 2019TreeGen: A Tree-Based Transformer Architecture for Code Generationcited by 58
- 2022XLCoST: A Benchmark Dataset for Cross-lingual Code Intelligencecited by 56
- 2022PanGu-Coder: Program Synthesis with Function-Level Language Modelingcited by 48
- 2022Compilable Neural Code Generation with Compiler Feedbackcited by 47
- 2023What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?cited by 47
- 2018Retrieval-Based Neural Code Generationcited by 41
- 2022MCoNaLa: A Benchmark for Code Generation from Multiple Natural Languagescited by 41
50 most cited of 57 All 57 (JSON)
Built on by
Citing papers per year: 2025: 8; 2026: 10.
18 papers.
Sort:
By area:
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 23
- 2025When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?cited by 13
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generationcited by 9
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generationcited by 8
- 2025ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinementcited by 7
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2026Reliable Graph-RAG for Codebases: AST-Derived Graphs vs LLM-Extracted Knowledge Graphscited by 4
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generationcited by 3
- 2025CODE-DITING: A Reasoning-Based Metric for Functional Alignment in Code Evaluationcited by 2
- 2026Can AI Agents Generate Microservices? How Far are We?cited by 1
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Taskscited by 1
- 2026DeepDiscovery: A Location-Inference Framework for Task-Level Repository Understandingcited by 1
6 more
- 2026WaterMoE: Expert-Routing-based Watermarking for High Fidelity and Efficiencycited by 1
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generationcited by 1
- 2026CangjieBench: Benchmarking LLMs on a Low-Resource General-Purpose Programming Languagecited by 0
- 2026RCL: A Retrieval-Confidence Layer for Detecting Insufficient Context in Enterprise Retrieval-Augmented Code Generationcited by 0
- 2026AdaRepair-Mem: Adaptive Experience Orchestration for Repository-Level Program Repaircited by 0
- 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generationcited by 0
- 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generation10 Oct 2026
- 2026AdaRepair-Mem: Adaptive Experience Orchestration for Repository-Level Program Repair17 Sep 2026
- 2026RCL: A Retrieval-Confidence Layer for Detecting Insufficient Context in Enterprise Retrieval-Augmented Code Generation10 Sep 2026
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generation2 Sep 2026
- 2026WaterMoE: Expert-Routing-based Watermarking for High Fidelity and Efficiency14 Jul 2026
- 2026DeepDiscovery: A Location-Inference Framework for Task-Level Repository Understanding22 Jun 2026
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Tasks14 May 2026
- 2026CangjieBench: Benchmarking LLMs on a Low-Resource General-Purpose Programming Language15 Mar 2026
- 2026Can AI Agents Generate Microservices? How Far are We?9 Mar 2026
- 2026Reliable Graph-RAG for Codebases: AST-Derived Graphs vs LLM-Extracted Knowledge Graphs13 Jan 2026
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generation30 Oct 2025
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
6 more
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generation4 Jun 2025
- 2025CODE-DITING: A Reasoning-Based Metric for Functional Alignment in Code Evaluation26 May 2025
- 2025ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinement29 Apr 2025
- 2025When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?19 Mar 2025
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generation5 Feb 2025
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 23
- 2025When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?cited by 13
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generationcited by 9
- 2025ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinementcited by 7
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2026Reliable Graph-RAG for Codebases: AST-Derived Graphs vs LLM-Extracted Knowledge Graphscited by 4
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generationcited by 3
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Taskscited by 1
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generationcited by 1
- 2026RCL: A Retrieval-Confidence Layer for Detecting Insufficient Context in Enterprise Retrieval-Augmented Code Generationcited by 0
- 2026RCL: A Retrieval-Confidence Layer for Detecting Insufficient Context in Enterprise Retrieval-Augmented Code Generation10 Sep 2026
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generation2 Sep 2026
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Tasks14 May 2026
- 2026Reliable Graph-RAG for Codebases: AST-Derived Graphs vs LLM-Extracted Knowledge Graphs13 Jan 2026
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generation4 Jun 2025
- 2025ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinement29 Apr 2025
- 2025When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?19 Mar 2025
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generation5 Feb 2025
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generationcited by 8
- 2026DeepDiscovery: A Location-Inference Framework for Task-Level Repository Understandingcited by 1
- 2026CangjieBench: Benchmarking LLMs on a Low-Resource General-Purpose Programming Languagecited by 0
- 2026AdaRepair-Mem: Adaptive Experience Orchestration for Repository-Level Program Repaircited by 0
- 2026AdaRepair-Mem: Adaptive Experience Orchestration for Repository-Level Program Repair17 Sep 2026
- 2026DeepDiscovery: A Location-Inference Framework for Task-Level Repository Understanding22 Jun 2026
- 2026CangjieBench: Benchmarking LLMs on a Low-Resource General-Purpose Programming Language15 Mar 2026
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generation30 Oct 2025
Similar, not cited
Close in wording, no citation either way
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2024Context-Augmented Code Generation Using Programming Knowledge Graphs
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
- 2026Context-Augmented Code Generation Using Programming Knowledge Graphs
- 2025SACL: Understanding and Combating Textual Bias in Code Retrieval with Semantic-Augmented Reranking and Localization
- 2024Building A Coding Assistant via the Retrieval-Augmented Language Model
- 2024Retrieval-augmented code completion for local projects using large language models
- 2024CodeGRAG: Bridging the Gap between Natural Language and Programming Language via Graphical Retrieval Augmented Generation