mlsanityData to 14 Oct 2026

An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities

arXiv 2501.13742 ↗First posted 23 Jan 2025cs.SEcited by 18

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

  1. 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
  2. 2021Retrieval Augmented Code Generation and Summarization26 Aug

Other references · 57

  1. 2017Attention Is All You Needcited by 60,361
  2. 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
  3. 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,372
  4. 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
  5. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  6. 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,513
  7. 2021Program Synthesis with Large Language Modelscited by 3,637
  8. 2020The Pile: An 800GB Dataset of Diverse Text for Language Modelingcited by 2,411
  9. 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,141
  10. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  11. 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,839
  12. 2022Competition-Level Code Generation with AlphaCodecited by 1,462
38 more
  1. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
  2. 2021BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Modelscited by 1,252
  3. 2020Leveraging Passage Retrieval with Generative Models for Open Domain Question Answeringcited by 1,210
  4. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  5. 2021GLM: General Language Model Pretraining with Autoregressive Blank Infillingcited by 1,031
  6. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
  7. 2021Measuring Coding Challenge Competence With APPScited by 902
  8. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 885
  9. 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 800
  10. 2017Reading Wikipedia to Answer Open-Domain Questionscited by 777
  11. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
  12. 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
  13. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 609
  14. 2023Active Retrieval Augmented Generationcited by 516
  15. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
  16. 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
  17. 2022CodeT: Code Generation with Generated Testscited by 384
  18. 2021Unified Pre-training for Program Understanding and Generationcited by 366
  19. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
  20. 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 333
  21. 2020IntelliCode Compose: Code Generation Using Transformercited by 227
  22. 2018Learning to Mine Aligned Code and Natural Language Pairs from Stack Overflowcited by 165
  23. 2022DocPrompting: Generating Code by Retrieving the Docscited by 153
  24. 2023CodePlan: Repository-level Coding using LLMs and Planningcited by 140
  25. 2022Dense Text Retrieval based on Pretrained Language Models: A Surveycited by 136
  26. 2022RetroMAE: Pre-Training Retrieval-oriented Language Models Via Masked Auto-Encodercited by 118
  27. 2018Mapping Language to Code in Programmatic Contextcited by 104
  28. 2017Abstract Syntax Networks for Code Generation and Semantic Parsingcited by 92
  29. 2018TRANX: A Transition-based Neural Abstract Syntax Parser for Semantic Parsing and Code Generationcited by 88
  30. 2016Latent Predictor Networks for Code Generationcited by 73
  31. 2018A Retrieve-and-Edit Framework for Predicting Structured Outputscited by 73
  32. 2019TreeGen: A Tree-Based Transformer Architecture for Code Generationcited by 58
  33. 2022XLCoST: A Benchmark Dataset for Cross-lingual Code Intelligencecited by 56
  34. 2022PanGu-Coder: Program Synthesis with Function-Level Language Modelingcited by 48
  35. 2022Compilable Neural Code Generation with Compiler Feedbackcited by 47
  36. 2023What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?cited by 47
  37. 2018Retrieval-Based Neural Code Generationcited by 41
  38. 2022MCoNaLa: A Benchmark for Code Generation from Multiple Natural Languagescited by 41

50 most cited of 57 All 57 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 8; 2026: 10.

18 papers.

Sort:

By area:

  1. 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 23
  2. 2025When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?cited by 13
  3. 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generationcited by 9
  4. 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generationcited by 8
  5. 2025ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinementcited by 7
  6. 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
  7. 2026Reliable Graph-RAG for Codebases: AST-Derived Graphs vs LLM-Extracted Knowledge Graphscited by 4
  8. 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generationcited by 3
  9. 2025CODE-DITING: A Reasoning-Based Metric for Functional Alignment in Code Evaluationcited by 2
  10. 2026Can AI Agents Generate Microservices? How Far are We?cited by 1
  11. 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Taskscited by 1
  12. 2026DeepDiscovery: A Location-Inference Framework for Task-Level Repository Understandingcited by 1
6 more
  1. 2026WaterMoE: Expert-Routing-based Watermarking for High Fidelity and Efficiencycited by 1
  2. 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generationcited by 1
  3. 2026CangjieBench: Benchmarking LLMs on a Low-Resource General-Purpose Programming Languagecited by 0
  4. 2026RCL: A Retrieval-Confidence Layer for Detecting Insufficient Context in Enterprise Retrieval-Augmented Code Generationcited by 0
  5. 2026AdaRepair-Mem: Adaptive Experience Orchestration for Repository-Level Program Repaircited by 0
  6. 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generationcited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
  2. 2024Context-Augmented Code Generation Using Programming Knowledge Graphs
  3. 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
  4. 2026Context-Augmented Code Generation Using Programming Knowledge Graphs
  5. 2025SACL: Understanding and Combating Textual Bias in Code Retrieval with Semantic-Augmented Reranking and Localization
  6. 2024Building A Coding Assistant via the Retrieval-Augmented Language Model
  7. 2024Retrieval-augmented code completion for local projects using large language models
  8. 2024CodeGRAG: Bridging the Gap between Natural Language and Programming Language via Graphical Retrieval Augmented Generation