When Retrieval Augmentation Meets API Documentation: Can LLMs Code with Less-Common Libraries?
Open Access
- 25 June 2026
- journal article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Software Engineering and Methodology
Abstract
Retrieval-augmented generation (RAG) has increasingly shown its power in extending large language models’ (LLMs’) capability beyond their pre-trained knowledge. Existing works showed that RAG can help with software development tasks such as code generation and test generation. Yet, the effectiveness of adapting LLMs to their unfamiliar, less-common or fast-evolving library APIs using RAG remains unknown. To bridge this gap, we take an initial step to study this unexplored yet practical setting – when developers code with an unfamiliar library, they often refer to its API documentation; likewise,
when LLMs are allowed to look up API documentation of their unfamiliar libraries 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 libraries as additional knowledge for retrieval and generation. Our study yields interesting findings: (1) RAG helps improve LLMs’ performance by 83% \(\sim\) 220%. (2) Example code contributes the most to advancing LLMs, compared to 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. Based on the findings, we advocate that developers pay more attention to the quality and diversity of code examples in the API documentation. The study sheds light on the future low-code software development workflows with LLMs.
Keywords
This publication has 39 references indexed in Scilit:
- Efficient Text-to-Code Retrieval with Cascaded Fast and Slow Transformer Models2023
- Programming by Example Made EasyACM Transactions on Software Engineering and Methodology, 2023
- The state-of-practice in requirements specification: an extended interview study at 12 companiesRequirements Engineering, 2023
- Software documentation2020
- Automatic Detection and Update Suggestion for Outdated API Names in DocumentationIEEE Transactions on Software Engineering, 2019
- Detecting API documentation errors2013
- A field study of API learning obstaclesEmpirical Software Engineering, 2010
- What Makes APIs Hard to Learn? Answers from DevelopersIEEE Software, 2009
- Automated identification of parameter mismatches in web applications2008
- Building more usable APIsIEEE Software, 1998