Table of Contents
Fetching ...

HalluZig: Hallucination Detection using Zigzag Persistence

Shreyas N. Samaga, Gilberto Gonzalez Arroyo, Tamal K. Dey

TL;DR

HalluZig addresses the reliability issue of LLMs by shifting focus from generated text to the dynamics of internal reasoning. It models layer-wise attention as a sequence of graphs and applies zigzag persistence to extract topological signatures from the evolution, vectorized via PersImg, PersEntropy, and Betti Curves, then classifies with a Random Forest. The approach yields state-of-the-art or near-state-of-the-art performance across generative and QA benchmarks, demonstrates cross-model generalization, and enables effective early detection from partial network depth (about 70%). This work highlights the value of topological, structural interpretability for safety monitoring in LLMs and opens doors to model-internal hallucination diagnostics that are robust across architectures.

Abstract

The factual reliability of Large Language Models (LLMs) remains a critical barrier to their adoption in high-stakes domains due to their propensity to hallucinate. Current detection methods often rely on surface-level signals from the model's output, overlooking the failures that occur within the model's internal reasoning process. In this paper, we introduce a new paradigm for hallucination detection by analyzing the dynamic topology of the evolution of model's layer-wise attention. We model the sequence of attention matrices as a zigzag graph filtration and use zigzag persistence, a tool from Topological Data Analysis, to extract a topological signature. Our core hypothesis is that factual and hallucinated generations exhibit distinct topological signatures. We validate our framework, HalluZig, on multiple benchmarks, demonstrating that it outperforms strong baselines. Furthermore, our analysis reveals that these topological signatures are generalizable across different models and hallucination detection is possible only using structural signatures from partial network depth.

HalluZig: Hallucination Detection using Zigzag Persistence

TL;DR

HalluZig addresses the reliability issue of LLMs by shifting focus from generated text to the dynamics of internal reasoning. It models layer-wise attention as a sequence of graphs and applies zigzag persistence to extract topological signatures from the evolution, vectorized via PersImg, PersEntropy, and Betti Curves, then classifies with a Random Forest. The approach yields state-of-the-art or near-state-of-the-art performance across generative and QA benchmarks, demonstrates cross-model generalization, and enables effective early detection from partial network depth (about 70%). This work highlights the value of topological, structural interpretability for safety monitoring in LLMs and opens doors to model-internal hallucination diagnostics that are robust across architectures.

Abstract

The factual reliability of Large Language Models (LLMs) remains a critical barrier to their adoption in high-stakes domains due to their propensity to hallucinate. Current detection methods often rely on surface-level signals from the model's output, overlooking the failures that occur within the model's internal reasoning process. In this paper, we introduce a new paradigm for hallucination detection by analyzing the dynamic topology of the evolution of model's layer-wise attention. We model the sequence of attention matrices as a zigzag graph filtration and use zigzag persistence, a tool from Topological Data Analysis, to extract a topological signature. Our core hypothesis is that factual and hallucinated generations exhibit distinct topological signatures. We validate our framework, HalluZig, on multiple benchmarks, demonstrating that it outperforms strong baselines. Furthermore, our analysis reveals that these topological signatures are generalizable across different models and hallucination detection is possible only using structural signatures from partial network depth.
Paper Structure (40 sections, 9 equations, 8 figures, 10 tables)

This paper contains 40 sections, 9 equations, 8 figures, 10 tables.

Figures (8)

  • Figure 1: Attention matrices modeled as graphs show distinct topological patterns as they evolve through a model's layers. We leverage zigzag persistence in topological data analysis to quantify these evolving attention structures for hallucination detection.
  • Figure 2: The HalluZig framework: capturing attention evolution for hallucination detection. We model the layer-wise attention matrices from an LLM as a sequence of attention graphs $(G_1, \hdots , G_L)$. Zigzag persistence is applied to this sequence to capture the evolution of topological features resulting in a Persistence Diagram. The Persistence Diagram is vectorized into a topological signature, which is used by a classifier to detect hallucinations.
  • Figure 3: Visualizing the Attention Mechanism. (a) A causally masked attention matrix. (b) The corresponding attention graph where nodes are tokens and thick edges represent high-attention links. This structural representation is the input to our topological pipeline.
  • Figure 4: Zigzag filtration. The figure shows a zigzag filtration where $G_2 = G_1 \cup G_3$ and $G_4 = G_3 \cup G_5$.
  • Figure 5: Two Views of a Topological Summary. (a) The 2D persistence diagram plots each feature's birth vs. death layers. (b) The 1D barcode represents each feature's lifetime as a horizontal bar.
  • ...and 3 more figures