Abstract
API recommendation is a crucial task in code intelligence, aiming to suggest suitable APIs for programming queries. Recent efforts have integrated Large Language Models (LLMs) into this task. However, these methods overlook the compatibility between recommended APIs and fail to fully utilize the factual knowledge of APIs. Moreover, these prompting-only methods are limited by the insufficient domain-specific knowledge of LLMs. In this article, we propose a novel fine-tuning method, KDRAR, designed to leverage knowledge-driven reasoning with LLMs for compatible and interpretable API recommendation. To fully utilize the factual knowledge, we introduce a dual matching strategy that leverages both function descriptions and keyword matching to retrieve candidate APIs. To handle compatibility, we translate compatibility information into descriptive knowledge, which is integrated into the recommendation process. Furthermore, we adopt a distilled fine-tuning strategy: a student LLM is trained via distillation from a teacher LLM to perform step-by-step reasoning for enhanced recommendation and explanation. By considering both function matching and compatibility information, the knowledge-driven reasoning not only improves API recommendation accuracy but also provides reasonable explanations for the recommendations. Experimental results show that our method significantly outperforms baseline methods on API recommendation tasks across multiple API domains.
| Original language | English |
|---|---|
| Article number | 27 |
| Pages (from-to) | 27:1-27:30 |
| Number of pages | 30 |
| Journal | ACM Transactions on Information Systems |
| Volume | 44 |
| Issue number | 1 |
| DOIs | |
| Publication status | Published - Jan 2026 |
Bibliographical note
An erratum exists for this article and can be found in ACM Transactions on Information Systems, 44(2), Article C2, doi: 10.1145/3787107Keywords
- API Recommendation
- Recommender Systems
- Large Language Models
Fingerprint
Dive into the research topics of 'Knowledge-driven reasoning for compatible and interpretable API recommendation via teacher LLM distillation'. Together they form a unique fingerprint.Cite this
- APA
- Author
- BIBTEX
- Harvard
- Standard
- RIS
- Vancouver