Introduction
Virtual Knowledge Graphs (VKGs) provide a powerful paradigm for data integration, allowing users to query relational databases through a "virtual" semantic layer using high-level ontologies and graph query languages like SPARQL. This approach avoids the overhead of physical data migration. However, the manual creation of mappings between database schemas and ontologies remains a significant bottleneck. Traditional rule-based systems often fail due to naming ambiguities and the "fuzzy" semantic nature of database metadata.
The LLM4VKG Framework
To address these challenges, we present LLM4VKG, an automated framework that synergizes structural database analysis with the semantic reasoning capabilities of Large Language Models (LLMs). The construction process is divided into two primary phases:
1. Mapping Pattern Recognition
The framework first abstracts the database schema into a graph representation. It then executes predefined SPARQL queries to identify common structural "Mapping Patterns," such as Schema Entities, Relationships, and Hierarchies. This step provides a formal structural skeleton, ensuring that the final mappings are architecturally sound.
2. Ontology Completion & Mapping Bootstrapping
The core of the semantic matching is handled by a three-stage LLM pipeline:
- Retriever: Employs a sentence-similarity model (bge-m3) to identify the top-$n$ candidate matches within the ontology for specific database elements.
- Matcher: A generative LLM (e.g., GPT-4o) evaluates these candidates, assigning a match quality score (High, Medium, or Low).
- Namer: In cases where no suitable match is found (Low quality), the Namer leverages the LLM's contextual understanding to generate new class or property names, effectively "completing" an incomplete ontology.
Experimental Evaluation
The framework was evaluated using the RODI (Relational-to-Ontology Data Integration) benchmark, which spans diverse domains including Geodata and Oil & Gas. To test robustness, we introduced RODI-T (x%), a variant where varying percentages of the target ontology vocabulary were removed to simulate real-world scenarios of incomplete domain models.
Key Results and Insights
LLM4VKG demonstrates a significant leap over previous state-of-the-art tools like BootOX:
- Accuracy Gains: LLM4VKG achieved an average F1-score improvement of 17% across all RODI scenarios.
- Robustness to Naming: In scenarios with obscured or non-standard database naming, the framework showed a 39% absolute improvement in F1-score, highlighting the LLM's superior semantic understanding over lexical rules.
- Handling Incompleteness: The system proved remarkably resilient to incomplete ontologies. As shown in the performance metrics, LLM4VKG with 25% missing ontology data still performed comparably to prior tools using a complete ontology.
- Complex Mappings: Unlike traditional tools that struggle with n:1 relationships, LLM4VKG successfully managed complex mapping patterns.
Conclusion
LLM4VKG establishes a new state-of-the-art for automated VKG construction by grounding LLM reasoning within formal structural patterns. Future work will focus on expanding the library of mapping patterns and incorporating data-level statistics to further refine matching accuracy in highly complex database environments.
Summary updated