Improving Factuality in LLMs via Inference-Time Knowledge Graph Construction

Shanglin Wu, Lihui Liu, Jinho D. Choi, Kai Shu · OpenReview

Abstract

Large Language Models (LLMs) often struggle with producing factually consistent answers due to limitations in their parametric memory. Retrieval-Augmented Generation (RAG) paradigms mitigate this issue by incorporating external knowledge at inference time. However, such methods typically handle knowledge as unstructured text, which reduces retrieval accuracy, hinders compositional reasoning, and amplifies the influence of irrelevant information. We propose a novel framework that dynamically constructs and expands knowledge graphs (KGs) during inference, integrating both internal knowledge extracted from LLMs and external knowledge retrieved from sources like Wikipedia. Our method begins by extracting a seed KG from the question, followed by iterative expansion and selective refinement through external retrieval. We evaluate our approach on three diverse Factual QA benchmarks, demonstrating consistent gains in factual accuracy over baselines.

Introduction

Large Language Models (LLMs) are prone to "hallucinations"—generating plausible but factually incorrect information—because their internal parametric memory may be incomplete or outdated. While Retrieval-Augmented Generation (RAG) addresses this by providing external text, it often introduces noise and struggles with multi-hop reasoning where disparate facts must be connected.

Comparison of reasoning approaches: (a) Chain-of-Thought (CoT) only, (b) KG from internal knowledge, and (c) KG with external knowledge grounding.

As shown in Figure 1, standard Chain-of-Thought (CoT) and internal-only knowledge graphs can fail on complex queries. For instance, identifying the original play behind Bernstein's Symphonic Dances requires connecting the dances to West Side Story and then to Romeo and Juliet. Our framework, AutoKG, bridges these gaps by constructing a structured reasoning path grounded in external evidence.

Methodology: The AutoKG Pipeline

The proposed framework operates entirely at inference time through a four-stage pipeline:

  1. Graph Initialization: The LLM extracts "seed" entities and relations from the input question.
  2. Graph Expansion: The model performs a breadth-first search of its internal knowledge to build a skeleton graph of related triplets (Subject-Relation-Object).
  3. External Retrieval & Grounding: The system queries external sources (e.g., Wikipedia) to verify and refine the graph. This involves Correction of internal inaccuracies and Expansion with new, verified facts.
  4. Answering on Graph: The LLM generates a final answer constrained strictly by the paths identified in the refined KG. This constraint significantly reduces "off-graph" hallucinations.
The four-stage pipeline for inference-time Knowledge Graph construction and grounding.

Experimental Evaluation

We evaluated AutoKG on three benchmarks designed to test different aspects of factuality:

  • Complex WebQuestions (CWQ): Focused on multi-hop knowledge base interactions.
  • HotpotQA: A popular benchmark for multi-step reasoning across multiple documents.
  • SimpleQA: A high-difficulty dataset curated to target the factual "blind spots" of frontier models.

Key Results

AutoKG consistently outperformed standard RAG and other graph-based baselines. On the challenging SimpleQA dataset, the method boosted the accuracy of the Llama-4-Scout model from 14.1% (internal knowledge only) to 37.1% when using external KG grounding.

Furthermore, the structured approach significantly improved "Graph Recall"—the percentage of ground-truth facts actually present in the reasoning context. By forcing the model to follow a structured path, we effectively "corral" the LLM's creativity and reduce the likelihood of fabricated answers.

Discussion and Conclusion

The primary advantage of inference-time KG construction is the "Hybrid Advantage": using the LLM to propose a logical structure while using external search to ground that structure in reality. This method provides inherent interpretability; unlike the "black box" of standard RAG, AutoKG produces an auditable reasoning path (e.g., Dag Achatz → transcribed → Symphonic Dances → is from → West Side Story → inspired by → Romeo and Juliet).

While challenges remain regarding retrieval latency and potential noise propagation, our findings suggest that structured, grounded reasoning is a critical path forward for enhancing the factuality and reliability of LLMs in a scalable manner.

Summary updated

Abstract

Large Language Models (LLMs) often struggle with producing factually consistent answers due to limitations in their parametric memory. Retrieval-Augmented Generation (RAG) paradigms mitigate this issue by incorporating external knowledge at inference time. However, such methods typically handle knowledge as unstructured text, which reduces retrieval accuracy, hinders compositional reasoning, and amplifies the influence of irrelevant information on the factual consistency of LLM outputs. To overcome these limitations, we propose a novel framework that dynamically constructs and expands knowledge graphs (KGs) during inference, integrating both internal knowledge extracted from LLMs and external knowledge retrieved from external sources. Our method begins by extracting a seed KG from the question via prompting, followed by iterative expansion using the LLM's internal knowledge. The KG is then selectively refined through external retrieval, enhancing factual coverage and correcting inaccuracies. We evaluate our approach on three diverse Factual QA benchmarks, demonstrating consistent gains in factual accuracy over baselines. Our findings reveal that inference-time KG construction is a promising direction for enhancing LLM factuality in a structured, interpretable, and scalable manner.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
CWQInference-time KG construction (Internal KG)Performance score64.6backbone=GPT-4o · knowledge-setting=internal
Source quote
L156: \quad Internal KG │ 64.6 │ 51.8 │ 25.8
HotpotQAInference-time KG construction (Internal KG)Performance score51.8backbone=GPT-4o · knowledge-setting=internal
Source quote
L156: \quad Internal KG │ 64.6 │ 51.8 │ 25.8
SimpleQAInference-time KG construction (Internal KG)Performance score25.8backbone=GPT-4o · knowledge-setting=internal
Source quote
L156: \quad Internal KG │ 64.6 │ 51.8 │ 25.8
CWQInference-time KG construction (+ External)Performance score66.0backbone=GPT-4o · knowledge-setting=external
Source quote
L157: \quad + External │ 66.0 │ 53.9 │ 48.1
HotpotQAInference-time KG construction (+ External)Performance score53.9backbone=GPT-4o · knowledge-setting=external
Source quote
L157: \quad + External │ 66.0 │ 53.9 │ 48.1
SimpleQAInference-time KG construction (+ External)Performance score48.1backbone=GPT-4o · knowledge-setting=external
Source quote
L157: \quad + External │ 66.0 │ 53.9 │ 48.1
BibTeX
@misc{wu2025improving,
  author = {Shanglin Wu and Lihui Liu and Jinho D. Choi and Kai Shu},
  title = {{Improving Factuality in LLMs via Inference-Time Knowledge Graph Construction}},
  year = {2025},
  eprint = {2509.03540},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.03540},
}
Figure