mlsanityData to 7 Oct 2026

When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?

arXiv 2503.15231 ↗First posted 19 Mar 2025cs.SEcited by 12

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

Abstract (arXiv)

Retrieval-augmented generation (RAG) has increasingly shown its power in extending large language models' (LLMs') capability beyond their pre-trained knowledge. Existing works have shown that RAG can help with software development tasks such as code generation, code update, and test generation. Yet, the effectiveness of adapting LLMs to fast-evolving or less common API libraries using RAG remains unknown. To bridge this gap, we take an initial step to study this unexplored yet practical setting - when developers code with a less common library, they often refer to its API documentation; likewise, when LLMs are allowed to look up API documentation via RAG, to what extent can LLMs be advanced? To mimic such a setting, we select four less common open-source Python libraries with a total of 1017 eligible APIs. We study the factors that affect the effectiveness of using the documentation of less common API libraries as additional knowledge for retrieval and generation. Our intensive study yields interesting findings: (1) RAG helps improve LLMs' performance by 83%-220%. (2) Example code contributes the most to advance LLMs, instead of the descriptive texts and parameter lists in the API documentation. (3) LLMs could sometimes tolerate mild noises (typos in description or incorrect parameters) by referencing their pre-trained knowledge or document context. Finally, we suggest that developers pay more attention to the quality and diversity of the code examples in the API documentation. The study sheds light on future low-code software development workflows.

Key facts. Cited by 12 papers in the map (data through 7 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 21 of its 49 references that are in the map. First posted on arXiv 19 Mar 2025.

Builds on

21 of 49 references.

Closest ancestors · 2

Same direction, newest first

  1. 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities23 Jan
  2. 2024EVOR: Evolving Retrieval for Code Generation19 Feb

Other references · 19

  1. 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
  2. 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,383
  3. 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 1,906
  4. 2024Qwen2.5-Coder Technical Reportcited by 1,151
  5. 2023Enhancing Chat Language Models by Scaling High-quality Instructional Conversationscited by 825
  6. 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 527
  7. 2023How Far Can Camels Go? Exploring the State of Instruction Tuning on Open Resourcescited by 405
  8. 2022Text and Code Embeddings by Contrastive Pre-Trainingcited by 358
  9. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
  10. 2024The Power of Noise: Redefining Retrieval for RAG Systemscited by 275
  11. 2023Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMscited by 175
  12. 2023Dense X Retrieval: What Retrieval Granularity Should We Use?cited by 88
7 more
  1. 2023Large Language Model-Aware In-Context Learning for Code Generationcited by 42
  2. 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applicationscited by 26
  3. 2024On Mitigating Code LLM Hallucinations with API Documentationcited by 21
  4. 2024DOMAINEVAL: An Auto-Constructed Benchmark for Multi-Domain Code Generationcited by 21
  5. 2025From Informal to Formal -- Incorporating and Evaluating LLMs on Natural Language Requirements to Verifiable Formal Proofscited by 17
  6. 2024Retrieval-Augmented Test Generation: How Far Are We?cited by 7
  7. 2021Ivy: Templated Deep Learning for Inter-Framework Portabilitycited by 6

Built on by

Cited by year (2026 to 7 Oct)

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

12 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026When LLMs Lag Behind: Knowledge Conflicts from Evolving APIs in Code Generation
  2. 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
  3. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
  4. 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat
  5. 2026Mitigating Errors in LLM-Generated Web API Invocations via Retrieval-Augmented Generation and Constrained Decoding
  6. 2025Never Come Up Empty: Adaptive HyDE Retrieval for Improving LLM Developer Support
  7. 2024Are LLMs Correctly Integrated into Software Systems?
  8. 2024A Comparative Study of DSL Code Generation: Fine-Tuning vs. Optimized Retrieval Augmentation