Knowledge-Driven Reasoning for Compatible and Interpretable API Recommendation via Teacher LLM Distillation
Lianyong Qi, Jinyun Xie, Chunhua Hu, Xiaolong Xu, Hong-Ya Xiang, Haipeng Dai, Rong Gu, Xuyun Zhang,
China University of Petroleum, East China · Beijing Institute of Big Data Research
Key points
From the paper's conclusion- 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.
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.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Don’t Use a Cannon to Kill a Fly: Lightweight Model Editing for LLMs to Correct Deprecated API RecommendationsProceedings of the ACM on software engineering. · 2026
- LLM See, LLM Do: Enhancing Repository-Aware Code Generation in LLMs Through Logical Context and Usage KnowledgeACM Transactions on Software Engineering and Methodology · 2026
- LIMR: Intent-Aware Mashup API Recommendation via LLM-Augmented Multi-Scale FusionIEEE Transactions on Services Computing · 2026
- To See is Not to Master: Teaching LLMs to Use Private Libraries for Code GenerationACM Transactions on Software Engineering and Methodology · 2026
- KDFP: A first-principles approach to knowledge distillation in large language modelsarXiv · 2026
- SelfDR: Self-Distillation from Reasoning for LLM-Based RecommendationarXiv · 2026