SAFE: Schema-Driven Approximate Distance Join for Efficient Knowledge Graph Querying

S.h. Lee, Sungho Park, Wook-Shin Han2025

Abstract

To reduce hallucinations in large language models (LLMs), researchers are increasingly investigating reasoning methods that integrate LLMs with external knowledge graphs (KGs). Existing approaches either map an LLM-generated query graph onto the KG or let the LLM traverse the entire graph; the former is fragile because noisy query graphs derail retrieval, whereas the latter is inefficient due to entity-level reasoning over large graphs. In order to tackle these problems, we propose SAFE (Schema-Driven Approximate Distance Join For Efficient Knowledge Graph Querying), a framework that leverages schema graphs for robust query graph generation and efficient KG retrieval. SAFE introduces two key ideas: (1) an Approximate Distance Join (ADJ) algorithm that refines LLM-generated pseudo query graphs by flexibly aligning them with the KG's structure; and (2) exploiting a compact schema graph to perform ADJ efficiently, reducing overhead and improving retrieval accuracy. Extensive experiments on WebQSP, CWQ and GrailQA demonstrate that SAFE outperforms state-of-the-art methods in both accuracy and efficiency, providing a robust and scalable solution to overcome the inherent limitations of LLM-based knowledge retrieval.

Introduction

While Large Language Models (LLMs) demonstrate remarkable reasoning capabilities, they are prone to hallucinations and lack access to real-time or specialized factual knowledge. Integrating LLMs with Knowledge Graphs (KGs)—structured repositories of facts—offers a promising path toward grounded reasoning. However, current integration strategies face significant challenges.

As illustrated in Figure 1, existing methods generally fall into three categories, each with distinct drawbacks:

  1. Semantic Parsing: Methods that translate natural language into formal queries (e.g., SPARQL) are highly sensitive to minor errors. A single hallucinated relation or syntax mistake can lead to complete retrieval failure.
  2. LLM Agents: Iterative agents that explore the KG step-by-step are computationally expensive and slow, often requiring dozens of LLM calls to answer a single multi-hop question.
  3. Retrieval-Augmented Generation (RAG): Standard RAG approaches often demand a perfect structural match between the LLM's predicted query and the KG. They frequently fail when the KG contains intermediate "mediator" nodes that the LLM omits.
Limitations of existing LLM-KG integration methods

The SAFE Framework

To address these limitations, we propose SAFE (Schema-Driven Approximate Distance Join). SAFE prioritizes robustness and efficiency by decoupling the high-level query intent from the rigid physical structure of the KG.

Methodology Overview

The SAFE pipeline consists of four primary stages, as shown in Figure 4:

  1. Pseudo Query Graph Generation: The LLM generates a high-level "pseudo-query" graph representing the entities and relations mentioned in the question.
  2. Approximate Distance Join (ADJ): Instead of requiring direct edges, ADJ allows for "approximate" matches. An edge in the pseudo-query is considered satisfied if a path exists between the corresponding nodes within a distance threshold ($\delta$).
  3. Ranked Semantic Subgraph Matching: The system identifies the top-$k$ subgraphs in the KG that best align with the pseudo-query, using semantic similarity to rank candidates.
  4. Answer Generation: The retrieved subgraphs are provided to the LLM as context to generate the final answer.
The SAFE pipeline: Pseudo Query Graph Generation, Approximate Distance Join (ADJ), Ranked Semantic Subgraph Matching, and Answer Generation.

Schema-Driven Efficiency

A core innovation of SAFE is the use of the Schema Graph. Calculating shortest paths between billions of entities in a KG is computationally prohibitive. However, the schema graph—which represents types (e.g., "Singer") and relations rather than individual entities—is compact. SAFE precomputes All-Pairs Shortest Paths (APSP) on this schema graph, creating a "distance oracle" that enables constant-time lookups during the ADJ process. This allows the system to bridge structural gaps (e.g., missing mediator nodes) without the overhead of real-time graph traversal.

Experimental Evaluation

We evaluated SAFE on three major multi-hop KGQA benchmarks: WebQSP, ComplexWebQuestions (CWQ), and GrailQA.

Performance and Accuracy

SAFE consistently achieved state-of-the-art results. On the WebQSP benchmark using GPT-4, SAFE reached 90.6% Hits@1, outperforming the previous leading RAG method, SimGRAG, by 3.9%. Notably, on the GrailQA zero-shot subset, which tests generalization to unseen relations, SAFE outperformed the agent-based PoG by 7.8%.

Efficiency Gains

Beyond accuracy, SAFE offers significant improvements in speed and cost. Compared to the iterative PoG agent on the CWQ dataset, SAFE was 60.3% faster (13.6s vs 34.3s) and reduced token consumption by 56.9%. While agents typically require over 13 LLM calls per query, SAFE operates with just two calls: one for query generation and one for final answering. Analysis of inference time shows that the pseudo-query generation is the primary bottleneck, while the schema-driven ADJ and retrieval steps are highly optimized.

Conclusion

SAFE provides a robust and efficient framework for integrating LLMs with large-scale Knowledge Graphs. By leveraging schema-driven approximate distance joins, it overcomes the fragility of semantic parsing and the inefficiency of iterative agents. Future work will focus on expanding SAFE's support for complex SPARQL operators like filters and aggregations to further enhance its reasoning capabilities.

Summary updated

Abstract

To reduce hallucinations in large language models (LLMs), researchers are increasingly investigating reasoning methods that integrate LLMs with external knowledge graphs (KGs).Existing approaches either map an LLM-generated query graph onto the KG or let the LLM traverse the entire graph; the former is fragile because noisy query graphs derail retrieval, whereas the latter is inefficient due to entitylevel reasoning over large graphs.In order to tackle these problems, we propose SAFE (Schema-Driven Approximate Distance Join For Efficient Knowledge Graph Querying), a framework that leverages schema graphs for robust query graph generation and efficient KG retrieval.SAFE introduces two key ideas:(1) an Approximate Distance Join (ADJ) algorithm that refines LLM-generated pseudo query graphs by flexibly aligning them with the KG's structure; and (2) exploiting a compact schema graph to perform ADJ efficiently, reducing overhead and improving retrieval accuracy.Extensive experiments on WebQSP, CWQ and GrailQA demonstrate that SAFE outperforms state-of-the-art methods in both accuracy and efficiency, providing a robust and scalable solution to overcome the inherent limitations of LLM-based knowledge retrieval.
BibTeX
@misc{lee2025safe,
  author = {S.H. Lee and Sungho Park and Wook-Shin Han},
  title = {{SAFE: Schema-Driven Approximate Distance Join for Efficient Knowledge Graph Querying}},
  year = {2025},
  doi = {10.18653/v1/2025.emnlp-main.883},
}
Figure