When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?
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
- 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities23 Jan
- 2024EVOR: Evolving Retrieval for Code Generation19 Feb
Other references · 19
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,383
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 1,906
- 2024Qwen2.5-Coder Technical Reportcited by 1,151
- 2023Enhancing Chat Language Models by Scaling High-quality Instructional Conversationscited by 825
- 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 527
- 2023How Far Can Camels Go? Exploring the State of Instruction Tuning on Open Resourcescited by 405
- 2022Text and Code Embeddings by Contrastive Pre-Trainingcited by 358
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2024The Power of Noise: Redefining Retrieval for RAG Systemscited by 275
- 2023Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMscited by 175
- 2023Dense X Retrieval: What Retrieval Granularity Should We Use?cited by 88
7 more
- 2023Large Language Model-Aware In-Context Learning for Code Generationcited by 42
- 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applicationscited by 26
- 2024On Mitigating Code LLM Hallucinations with API Documentationcited by 21
- 2024DOMAINEVAL: An Auto-Constructed Benchmark for Multi-Domain Code Generationcited by 21
- 2025From Informal to Formal -- Incorporating and Evaluating LLMs on Natural Language Requirements to Verifiable Formal Proofscited by 17
- 2024Retrieval-Augmented Test Generation: How Far Are We?cited by 7
- 2021Ivy: Templated Deep Learning for Inter-Framework Portabilitycited by 6
Built on by
Citing papers per year: 2025: 4; 2026: 8.
12 papers.
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 20
- 2025FreshStack: Building Realistic Benchmarks for Evaluating Retrieval on Technical Documentscited by 15
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generationcited by 3
- 2026kRAIG: A Natural Language-Driven Agent for Automated DataOps Pipeline Generationcited by 3
- 2026BIM Information Extraction Through LLM-based Adaptive Explorationcited by 1
- 2026Understanding Agent-Reactive Bugs at the Model-Harness Boundary: An Empirical Study of LLM Agent Issue Reportscited by 1
- 2025LibRec: Benchmarking Retrieval-Augmented LLMs for Library Migration Recommendationscited by 0
- 2026RAG Strategies for Natural Language-Based SQL Query and REST API Call Generationcited by 0
- 2026BODHI: Precise OS Kernel Specification Inferencecited by 0
- 2026Diagnosing Knowledge Gaps in LLM Tool Use: An Agentic Benchmark for Novel API Acquisitioncited by 0
- 2026Detecting Architectural Drift in Safety-Critical Firmware through Runtime Trace Analysiscited by 0
- 2026Can Agents Design Libraries for Agents?cited by 0
- 2026Can Agents Design Libraries for Agents?29 Sep 2026
- 2026Understanding Agent-Reactive Bugs at the Model-Harness Boundary: An Empirical Study of LLM Agent Issue Reports17 Jul 2026
- 2026Detecting Architectural Drift in Safety-Critical Firmware through Runtime Trace Analysis3 Jul 2026
- 2026Diagnosing Knowledge Gaps in LLM Tool Use: An Agentic Benchmark for Novel API Acquisition2 Jun 2026
- 2026BIM Information Extraction Through LLM-based Adaptive Exploration3 May 2026
- 2026BODHI: Precise OS Kernel Specification Inference22 Apr 2026
- 2026kRAIG: A Natural Language-Driven Agent for Automated DataOps Pipeline Generation19 Mar 2026
- 2026RAG Strategies for Natural Language-Based SQL Query and REST API Call Generation6 Feb 2026
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025LibRec: Benchmarking Retrieval-Augmented LLMs for Library Migration Recommendations13 Aug 2025
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generation4 Jun 2025
- 2025FreshStack: Building Realistic Benchmarks for Evaluating Retrieval on Technical Documents17 Apr 2025
Similar, not cited
Close in wording, no citation either way
- 2026When LLMs Lag Behind: Knowledge Conflicts from Evolving APIs in Code Generation
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat
- 2026Mitigating Errors in LLM-Generated Web API Invocations via Retrieval-Augmented Generation and Constrained Decoding
- 2025Never Come Up Empty: Adaptive HyDE Retrieval for Improving LLM Developer Support
- 2024Are LLMs Correctly Integrated into Software Systems?
- 2024A Comparative Study of DSL Code Generation: Fine-Tuning vs. Optimized Retrieval Augmentation