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

Yanbang Sun, Qing Huang, Xiaoxue Ren, Zhenchang Xing, Xiaohong Li, Junjie WangarXiv 2025 · DOI

Introduction

Application Programming Interfaces (APIs) are fundamental to modern software development. However, the sheer scale of modern libraries—such as the Java standard library with over 30,000 APIs—presents a significant navigation challenge for developers. API Knowledge Graphs (KGs) offer a solution by providing structured networks of relationships, such as identifying that a HashMap is non-thread-safe compared to a Hashtable.

Historically, constructing these graphs has faced a binary trade-off. Schema-based methods rely on human experts to manually define relationship types, a process that is slow, expensive, and often misses niche insights. Conversely, schema-free methods leverage Large Language Models (LLMs) to extract relationships directly from text. While fast, these methods are prone to "hallucinations" and semantically nonsensical triples, such as mischaracterizing the logical relationship between a SortedSet and a Set.

A comparison of API KG construction methods, illustrating the evolution from manual schema-based approaches to the proposed ECF framework.

The Explore-Construct-Filter (ECF) framework introduces a "third way": an automated system that achieves the richness of schema-free approaches while maintaining the reliability of human-designed schemas.

The ECF Framework

The ECF framework automates the API KG construction process by simulating the workflow of human experts through three distinct modules: Exploration, Construction, and Filtering.

The architecture of the Explore-Construct-Filter (ECF) framework, showing the pipeline from seed texts to a rich and reliable Knowledge Graph.

1. KG Exploration (The Architect)

Instead of requiring a predefined human schema, the LLM analyzes a small set of "seed texts" to identify entities and label their types (e.g., utility class, instance method). These are then fused into high-level categories. To ensure comprehensive coverage, the module employs a fully connected strategy, generating every possible combination of entity types and relations. This allows the system to discover potential insights that human annotators might overlook.

2. KG Construction (The Builder)

Guided by the generated schema, the framework processes a large corpus of text to extract instance triples. To balance reasoning capabilities with precision, ECF uses a hybrid execution strategy. AI units handle complex semantic reasoning, while non-AI, code-based units manage data processing tasks that require absolute precision.

3. KG Filtering (The Editor)

To address the noise introduced by the "fully connected" exploration strategy, the filtering module acts as a statistical safety net. It applies association rules from data mining—specifically Support, Confidence, and Lift—to every relation type. If a relationship type does not appear with sufficient frequency or logical consistency across the graph, it is pruned as a likely hallucination.

Experimental Evaluation

The researchers evaluated ECF using a corpus of 5,047 texts from GitHub and Java documentation, with 206 Stack Overflow entries serving as seed texts. A ground-truth benchmark was established by four PhD students who manually annotated 384 texts. While primarily tested using GPT-4o, the framework demonstrated generalizability across other models, including Llama-3.1-70b and Claude-3.5-Sonnet.

Key Results

  • Superior Accuracy: ECF achieved a 25.2% improvement in F1 score over the previous state-of-the-art method (EDC).
  • Increased Richness: The exploration module identified 13 unique relation types (such as Limitation and Execution), representing a 133.6% increase in richness compared to traditional schema-based methods which typically identified only 9.
  • Enhanced Reliability: The statistical filtering module improved triple reliability by 26.6%, effectively removing illogical connections generated during the exploration phase.

Conclusion and Future Work

The ECF framework demonstrates that LLMs, when guided by structured exploration and statistical pruning, can automate the creation of high-quality knowledge graphs. While the current implementation is optimized for Java APIs, future work will focus on recalibrating filtering thresholds for other programming domains. Additionally, the authors plan to integrate ECF with GraphRAG (Graph Retrieval-Augmented Generation) to enable real-time, complex query resolution for developers.

Summary updated

BibTeX
@misc{sun2025explore,
  author = {Yanbang Sun and Qing Huang and Xiaoxue Ren and Zhenchang Xing and Xiaohong Li and Junjie Wang},
  title = {{Explore-Construct-Filter: An Automated Framework for Rich and Reliable API Knowledge Graph Construction}},
  year = {2025},
  eprint = {2502.13412},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.13412},
}
Figure