KG-Guard: Graph-Based Hallucination Detection for Knowledge Base Question Answering

Albert Sawczyn, Piotr Bielak, Tomasz Jan KajdanowiczNeurIPS 2026

TL;DR

Even when you hand a Large Language Model (LLM) a clean, structured knowledge graph as a cheat sheet, it will still occasionally ignore the facts and hallucinate wrong answers. KG-Guard solves this by treating hallucination detection as a graph-learning problem rather than a text problem, using a tiny neural network ($\sim305\times$ smaller than LLM judges) to verify individual answer nodes. Better yet, telling the LLM exact which graph nodes it got wrong allows it to self-correct, boosting overall accuracy by up to 17.6 percentage points.

What Problem Does This Paper Address?

Imagine asking an AI a factual question, like "What is the capital of Australia?" Instead of letting the LLM guess from memory, Knowledge Base Question Answering (KBQA) systems hand the model a relevant slice of a Knowledge Graph (KG)—a structured network of entities (like Australia and Canberra) connected by relationships (capital_of).

You would think having the ground-truth map right in front of it would stop an LLM from making things up. Unfortunately, it doesn't. LLMs still fall back on faulty internal memories or misread the connections on the map, selecting the wrong entities as answers.

Existing hallucination detectors struggle here: they either treat everything as flat text (ignoring the rich structure of the graph), require "white-box" access to the LLM's internal brainwaves (impossible with closed APIs), or rely on expensive "LLM-as-a-judge" setups that require firing off multiple massive model calls just to check one answer. Prior to this work, nobody had built a dedicated, lightweight detector specifically designed to verify the graph nodes returned by KBQA systems.

Methods

The authors reframe hallucination detection from a text-checking task into a node classification problem. The core intuition is geometric: on a knowledge graph, a factual answer node and a hallucinated node live in very different structural neighborhoods relative to the entities mentioned in the user's question.

Enter KG-Guard, which treats the answering LLM completely as a black box. Here is how it works:

  1. Semantic Initialization: Standard graph nodes don't come with numbers attached, so a text encoder converts the names of nodes, edge relations, and the user's question into numerical vectors.
  2. Augmented Graph Construction: This is the clever bit. KG-Guard "marks" the subgraph using learnable vector tags—highlighting which nodes were mentioned in the question (topic entities) and which nodes the LLM proposed as answers. It also injects a virtual question node directly into the graph, wiring it bidirectionally to the topic entities so the question's context flows through the network.
  3. Graph Encoding & Classification: A lightweight Graph Neural Network (specifically, a GraphTransformer) passes messages across this marked-up graph. Finally, a tiny Multi-Layer Perceptron (MLP) looks at each proposed answer node's updated graph representation alongside the question vector and outputs a simple binary verdict: factual ($0$) or hallucinated ($1$).
Figure 2: KG-Guard architecture for classifying answer nodes. Node features combine semantic node representations with topic-entity marks MT and answer-node marks MA. A virtual question node vq is connected to the topic entities with edges in both directions. The graph encoder gθ computes answer-node representations hˆa, which are concatenated with the question embedding zq and passed to an MLP to predict whether the returned node is hallucinated (y = 1) or factual (y = 0).

Beyond just catching errors, KG-Guard acts as an editor in an iterative refinement loop. If it flags any proposed nodes as hallucinations, those specific node names are sent back to the answering LLM in a chat prompt, asking it to revise its answer until KG-Guard gives the all-clear (or a 5-step cap is hit).

Role of KG-Guard in the iterative KBQA refinement loop. (Note: Corrected ID below)

Datasets

Because standard KBQA benchmarks only provide questions and gold answers, the authors constructed and released a new KBQA hallucination detection dataset by running LLM pipelines (like KAPING) over retrieved subgraphs and logging both factual and hallucinated node predictions. They built this atop three established benchmarks:

  • WebQuestionsSP (WebQSP): Natural, real-world English queries from Google Suggest, grounded in Freebase.
  • ComplexWebQuestions (CWQ): A much harder English dataset grounded in Freebase, built by adding complex logical constraints to WebQSP queries.
  • PUGG: A Polish-language KBQA dataset grounded in Wikidata, testing whether the approach generalizes beyond English and Freebase.

Key Insights and Ideas

  • Flattening graphs loses the plot: Fine-tuning a strong text model (RoBERTa) on a text-serialized list of graph triples worked great on template-heavy questions (CWQ) but collapsed on natural human queries (WebQSP), trailing KG-Guard by 18.3 F1 points. Preserving explicit graph topology matters.
  • LLM Judges are surprisingly gullible on natural queries: Prompting massive models like Llama-4-Scout (109B parameters) to verify answers against the graph actually performed worse than flipping a coin on WebQSP. LLM judges were overly conservative—high precision, terrible recall—meaning they missed most hallucinations.
  • One nudge is usually enough: When feeding KG-Guard's node-level flags back to the LLM for self-correction, almost all accuracy gains happen on the very first refinement step. Practitioners can cap refinement at 1 iteration to get big accuracy boosts on a tight compute budget.

Key Results

Across all three benchmarks, KG-Guard (using a GraphTransformer) achieved the best overall average rank (1.7) while using $\sim305\times$ fewer parameters than LLM baselines and requiring zero extra LLM calls at detection time.

Table 2: Hallucination detection F1 comparing KG-Guard against baselines, with Llama-4-Scout as the KAPING answering LLM. Bold and underlined values indicate the best and second-best result per column, respectively. Avg. Rank is the average rank of each method across the three datasets (lower is better). Values with ± denote mean ± std over 3 runs. G, RS, and RT denote the retrieved subgraph, reasoning summary, and reasoning triples provided to the LLM judge, respectively.
  • Detection Performance: KG-Guard hit F1 scores of 82.0 on WebQSP (1st place by over 16 points), 87.4 on CWQ (0.3 points behind fine-tuned RoBERTa), and 84.3 on PUGG (1.2 points behind SelfCheckGPT, which required 10 separate, expensive LLM generations per question).
  • Actionable Correction: Using KG-Guard to guide iterative refinement improved downstream KBQA F1 scores by 13.0–14.5 points and Exact Match (getting the entire answer set 100% right with zero missing or extra nodes) by 16.9–17.6 points across all three datasets.

Limitations and Future Work

  • Blind to "I don't know": Because KG-Guard classifies nodes inside a graph, it cannot evaluate cases where the LLM abstains with an unknown response.
  • Trapped in the subgraph: If the initial retrieval step fails to pull the true answer into the subgraph in the first place, KG-Guard's refinement loop can't magically find it—it only re-queries the existing subgraph. Expanding or re-retrieving the graph during refinement is a promising next step.
  • Supervised training required: Unlike zero-shot LLM judges, KG-Guard isn't plug-and-play out of the box; it requires labeled training data tailored to the specific KBQA pipeline and retriever being used.

Summary updated

Abstract

Large language models (LLMs) are increasingly used for knowledge base question answering (KBQA), also referred to as knowledge graph question answering (KGQA), where answering requires selecting entities from a question-specific knowledge graph subgraph. Yet LLMs are known to hallucinate across tasks, and KBQA is no exception: even when we provide a graph as the knowledge source, the model may rely on parametric knowledge instead of graph evidence or perform invalid reasoning over the given relations. Such hallucinated answer nodes can limit the practical deployment of KBQA systems, especially in high-stakes domains such as healthcare. We formulate hallucination detection in KBQA as an answer-node classification problem and propose a lightweight graph-based framework that treats the answering LLM as a black box. KG-Guard represents each KBQA instance as an augmented graph. It initializes node features with semantic representations of KG entities, marks topic entities and LLM-proposed answer nodes with learned vectors, and connects a virtual question node to the topic entities. A graph encoder then produces verification-oriented node representations, and a small MLP classifies each proposed answer node using its graph representation together with the question embedding. Experiments on WebQSP, ComplexWebQuestions, and PUGG show that our detector achieves the best average rank across all three benchmarks (F1 $82.0$, $87.4$, and $84.3$), while using ${\sim}305\times$ fewer parameters than LLM-based baselines. It also retains the best average rank when jointly evaluated across an extended set of pipelines and settings. Beyond detection, the node-level feedback is actionable: when flagged answers are fed back to the KBQA system for iterative refinement, downstream KBQA F1 improves by $13.0$-$14.5$ points and Exact Match by $16.9$-$17.6$ points.
BibTeX
@inproceedings{sawczyn2026kg,
  author = {Albert Sawczyn and Piotr Bielak and Tomasz Jan Kajdanowicz},
  title = {{KG-Guard: Graph-Based Hallucination Detection for Knowledge Base Question Answering}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=STsaMODjS9},
}
Figure