arXiv:2502.13412cs.SEcs.AI2025-02

用大模型自动构建丰富可靠的API知识图谱,减少人工干预。

Explore-Construct-Filter: An Automated Framework for Rich and Reliable API Knowledge Graph Construction

  • 分三步:探索设计模式、构建初始图谱、过滤噪声,全自动化。
  • 相比最新方法,F1得分提升25.2%,图谱丰富度提高133.6%。
  • 适合做API推荐、代码生成和漏洞检测的开发者与研究者。

API知识图谱(API KG)是一种结构化网络,用于建模API实体及其关系,为API推荐、代码生成和API误用检测等任务提供语义支持。然而,构建丰富且可靠的API KG面临挑战:基于模式的方法依赖大量人工标注,成本高;无模式方法缺乏引导,易引入噪声,影响可靠性。为此,我们提出Explore-Construct-Filter框架,基于大语言模型(LLM)实现自动化构建。该框架包含三个模块:1)KG探索:LLM模拟标注流程,自动设计涵盖全面类型三元组的模式,减少人工介入;2)KG构建:在模式指导下,LLM提取实例三元组,生成丰富但不可靠的API KG;3)KG过滤:剔除无效类型三元组和可疑实例三元组,最终构建出丰富且可靠的图谱。实验表明,该方法优于当前最优方法,F1得分提升25.2%。其中,探索模块使图谱丰富度提升133.6%,过滤模块使可靠性提升26.6%。跨模型实验验证了框架的通用性。

原文摘要 · Abstract (English)

The API Knowledge Graph (API KG) is a structured network that models API entities and their relations, providing essential semantic insights for tasks such as API recommendation, code generation, and API misuse detection. However, constructing a knowledge-rich and reliable API KG presents several challenges. Existing schema-based methods rely heavily on manual annotations to design KG schemas, leading to excessive manual overhead. On the other hand, schema-free methods, due to the lack of schema guidance, are prone to introducing noise, reducing the KG's reliability. To address these issues, we propose the Explore-Construct-Filter framework, an automated approach for API KG construction based on large language models (LLMs). This framework consists of three key modules: 1) KG exploration: LLMs simulate the workflow of annotators to automatically design a schema with comprehensive type triples, minimizing human intervention; 2) KG construction: Guided by the schema, LLMs extract instance triples to construct a rich yet unreliable API KG; 3) KG filtering: Removing invalid type triples and suspicious instance triples to construct a rich and reliable API KG. Experimental results demonstrate that our method surpasses the state-of-the-art method, achieving a 25.2% improvement in F1 score. Moreover, the Explore-Construct-Filter framework proves effective, with the KG exploration module increasing KG richness by 133.6% and the KG filtering module improving reliability by 26.6%. Finally, cross-model experiments confirm the generalizability of our framework.

知识图谱API分析大模型应用

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。