Litcius/Paper detail

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, Wanchun Dou

2025ACM Transactions on Information Systems15 citationsDOI

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.

Topics & Concepts

Computer scienceCompatibility (geochemistry)Leverage (statistics)Artificial intelligenceMachine learningInformation retrievalDistillationMatching (statistics)JavaBaseline (sea)Source codeTask (project management)Answer set programmingLanguage modelNatural language processingExploitCase-based reasoningProgramming languageAutomated reasoningQuestion answeringFunction (biology)Backward compatibilitySoftware engineeringData miningLibrary functionSemantic Web and OntologiesNatural Language Processing TechniquesBusiness Process Modeling and Analysis