Compositional API Recommendation for Library-Oriented Code Generation
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) have achieved exceptional performance in code generation. However, the performance remains unsatisfactory in generating library-oriented code, especially for the libraries not present in the training data of LLMs. Previous work utilizes API recommendation technology to help LLMs use libraries: it retrieves APIs related to the user requirements, then leverages them as context to prompt LLMs. However, developmental requirements can be coarse-grained, requiring a combination of multiple fine-grained APIs. This granularity inconsistency makes API recommendation a challenging task. To address this, we propose CAPIR (Compositional API Recommendation), which adopts a "divide-and-conquer" strategy to recommend APIs for coarse-grained requirements. Specifically, CAPIR employs an LLM-based Decomposer to break down a coarse-grained task description into several detailed subtasks. Then, CAPIR applies an embedding-based Retriever to identify relevant APIs corresponding to each subtask. Moreover, CAPIR leverages an LLM-based Reranker to filter out redundant APIs and provides the final recommendation. To facilitate the evaluation of API recommendation methods on coarse-grained requirements, we present two challenging benchmarks, RAPID (Recommend APIs based on Documentation) and LOCG (Library-Oriented Code Generation). Experimental results on these benchmarks, demonstrate the effectiveness of CAPIR in comparison to existing baselines. Specifically, on RAPID's Torchdata-AR dataset, compared to the state-of-the-art API recommendation approach, CAPIR improves recall@5 from 18.7% to 43.2% and precision@5 from 15.5% to 37.1%. On LOCG's Torchdata-Code dataset, compared to code generation without API recommendation, CAPIR improves pass@100 from 16.0% to 28.0%.
Key facts. Cited by 10 papers in the map (data through 14 Oct 2026). Builds on 19 of its 47 references that are in the map. First posted on arXiv 29 Feb 2024.
Builds on
19 of 47 references.
References · 19
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,374
- 2018UMAP: Uniform Manifold Approximation and Projection for Dimension Reductioncited by 2,898
- 2022Making Large Language Models Better Reasoners with Step-Aware Verifiercited by 233
- 2022Grounded Copilot: How Programmers Interact with Code-Generating Modelscited by 218
- 2018Learning to Mine Aligned Code and Natural Language Pairs from Stack Overflowcited by 165
- 2022DocPrompting: Generating Code by Retrieving the Docscited by 153
- 2022Execution-Based Evaluation for Open-Domain Code Generationcited by 91
- 2022Coder Reviewer Reranking for Code Generationcited by 84
- 2023How Do In-Context Examples Affect Compositional Generalization?cited by 51
- 2016Deep API Learningcited by 41
7 more
- 2022Code Generation Tools (Almost) for Free? A Study of Few-Shot, Pre-Trained Language Models on Codecited by 39
- 2023Automatic Code Summarization via ChatGPT: How Far Are We?cited by 34
- 2021Revisiting, Benchmarking and Exploring API Recommendation: How Far Are We?cited by 21
- 2018RACK: Automatic API Recommendation using Crowdsourced Knowledgecited by 12
- 2015SWIM: Synthesizing What I Meancited by 10
- 2021PyART: Python API Recommendation in Real-Timecited by 6
- 2023Source Code Recommender Systems: The Practitioners' Perspectivecited by 2
Built on by
Citing papers per year: 2024: 3; 2025: 5; 2026: 2.
10 papers.
- 2025SoRFT: Issue Resolving with Subtask-oriented Reinforced Fine-Tuningcited by 28
- 2025A Study of LLMs' Preferences for Libraries and Programming Languagescited by 20
- 2024Model Editing for LLMs4Code: How Far are We?cited by 10
- 2025Towards an Understanding of Context Utilization in Code Intelligencecited by 10
- 2024Repository Structure-Aware Training Makes SLMs Better Issue Resolvercited by 4
- 2026To See is Not to Master: Teaching LLMs to Use Private Libraries for Code Generationcited by 3
- 2025CCCI: Code Completion with Contextual Information for Complex Data Transfer Tasks Using Large Language Modelscited by 2
- 2026Learning from Execution: Self-Evolving Memory for Private-Library Code Generationcited by 2
- 2024Dehallucinating Parallel Context Extension for Retrieval-Augmented Generationcited by 0
- 2025Automated Network Protocol Testing with LLM Agentscited by 0
- 2026Learning from Execution: Self-Evolving Memory for Private-Library Code Generation27 Apr 2026
- 2026To See is Not to Master: Teaching LLMs to Use Private Libraries for Code Generation16 Mar 2026
- 2025Automated Network Protocol Testing with LLM Agents15 Oct 2025
- 2025Towards an Understanding of Context Utilization in Code Intelligence11 Apr 2025
- 2025CCCI: Code Completion with Contextual Information for Complex Data Transfer Tasks Using Large Language Models29 Mar 2025
- 2025A Study of LLMs' Preferences for Libraries and Programming Languages21 Mar 2025
- 2025SoRFT: Issue Resolving with Subtask-oriented Reinforced Fine-Tuning27 Feb 2025
- 2024Repository Structure-Aware Training Makes SLMs Better Issue Resolver26 Dec 2024
- 2024Dehallucinating Parallel Context Extension for Retrieval-Augmented Generation19 Dec 2024
- 2024Model Editing for LLMs4Code: How Far are We?11 Nov 2024