DOI: 10.1145/3840287 ISSN: 1049-331X
Balancing Richness and Reliability: An Explore-Construct-Verify Framework for API Knowledge Graph Construction
Yanbang Sun, Qing Huang, Zhenchang Xing, Xiaoxue Ren, Xiaohong Li, Junjie Wang, Huan Jin, Zhiping Liu
Application Programming Interfaces (APIs) are central to modern software development, yet the growing scale and semantic complexity of APIs present significant challenges for developers in learning and using them effectively. API knowledge graphs (KGs) offer a structured solution by organizing API entities and their relations, but existing construction methods face a trade-off: schema-guided methods ensure precision but suffer from limited richness, while schema-free methods capture richer semantics but often lack reliability. To address this challenge, we propose Explore-Construct-Verify (
ECV
), a three-stage framework for API KG construction using large language models (LLMs). The framework first explores candidate schema in a bottom-up manner, then constructs the KG with schema-guided extraction, and finally applies human-AI collaborative verification based on association rule mining. This design preserves LLMs’ ability to discover domain-specific knowledge while enabling efficient post-hoc validation. We conduct extensive experiments to evaluate the effectiveness of our method. Compared to the state-of-the-art method EDC,
ECV
improves KG construction F1 score by 31.3%. Component analysis shows that the exploration module improves KG richness (recall) by 267.9%, the fully connected schema strategy increases richness by 50.0%, and the verification module improves KG reliability (precision) by 47.1%.
ECV
maintains an average F1 around 0.69 both across six programming languages and across five LLMs, demonstrating strong cross-language and cross-model generalizability. We further validate the practical utility of the constructed KG through an API recommendation task, where KG-enhanced LLMs outperform LLM-only baselines by 26.3% in accuracy.