Introduction
Schema matching across heterogeneous databases is a critical yet challenging task in data integration. Semantic ambiguities often lead to incorrect mappings, and while Large Language Models (LLMs) offer promise, they frequently suffer from hallucinations when domain-specific structured knowledge is missing. This paper introduces KG-RAG4SM, a novel framework that enhances LLM performance by retrieving and injecting relevant subgraphs from external Knowledge Graphs (KGs) into the reasoning process.
The Challenge of Schema Matching
Schema matching involves identifying semantic correspondences between attributes in disparate data models. For instance, mapping a local hospital's ATTEND_DOCTOR field to a standardized provider_id field requires understanding that both refer to healthcare professionals in a specific context.
Traditional methods relying on string similarity or basic machine learning often fail to capture deep semantic nuances, such as hierarchical taxonomies or domain-specific synonyms. While LLMs have been applied to this problem, they lack explicit grounding in structured facts, leading to errors where unrelated attributes are matched based on superficial similarities.
The KG-RAG4SM Framework
To address these limitations, the authors propose KG-RAG4SM (Knowledge Graph-based Retrieval-Augmented Generation for Schema Matching). The framework grounds LLM reasoning in factual data retrieved from Wikidata.
The methodology involves several key stages:
- Vector-based Retrieval: Instead of relying on LLMs to generate complex graph queries, the system uses RoBERTa to embed schema matching questions and KG triples. A cosine similarity search identifies the most relevant starting points in the KG.
- Graph Traversal and Refinement: Using Breadth-First Search (BFS), the system extracts multi-hop paths between identified entities. To prevent "context poisoning" from irrelevant data, a ranking scheme prunes the results to the top 1 or 2 most relevant paths.
- Prompt Augmentation: These refined subgraphs are converted into semi-structured text and injected into the LLM prompt, providing a logical factual path for the model to follow.
Experimental Setup and Datasets
The framework was evaluated using standard benchmarks and a newly introduced real-world dataset:
- OMOP Benchmarks: MIMIC, Synthea, and CMS datasets, which involve mapping healthcare databases to the OMOP Common Data Model.
- EMED: A new dataset mapping the Hungarian e-MedSolution system to OMOP.
- Knowledge Base: Wikidata and Wikidata5M served as the external knowledge sources.
Results and Key Insights
The experimental results demonstrate significant improvements over existing methods:
- Superior Performance: On the MIMIC dataset, KG-RAG4SM (using GPT-4o-mini) outperformed the fine-tuned Jellyfish-8B model by 35.89% in Precision and 30.50% in F1 score.
- Zero-Shot Advantage: Compared to the pre-trained SMAT model on Synthea, the framework achieved a 69.20% improvement in Precision without requiring task-specific training.
- Mitigating Hallucinations: Case studies showed that baseline LLMs often incorrectly matched temporal events (e.g.,
measurement_timevsintervention_date). With KG augmentation, the model correctly identified these as distinct concepts. - Model Size Paradox: Interestingly,
GPT-4o-minioften outperformedGPT-4o. This suggests that larger models' internal generalized knowledge can sometimes conflict with specific retrieved facts, whereas smaller models adhere more strictly to the provided context.
Conclusion
KG-RAG4SM demonstrates that grounding LLMs with structured knowledge from external graphs significantly enhances schema matching accuracy while reducing hallucinations. Future work will explore the integration of domain-specific KGs, such as SNOMED-CT, to further refine performance in specialized fields like medicine.
Summary updated