Hallucination Detection in LLMs Using Spectral Features of Attention Maps
Jakub Binkowski, Denis Janiak, Albert Sawczyn, Bogdan Gabrys, Tomasz Kajdanowicz
TL;DR
The paper tackles hallucinations in LLMs by introducing LapEigvals, a supervised detector that leverages the top-$k$ eigenvalues of the graph Laplacian derived from attention maps. By treating each attention map as a graph, it computes $L^{(l,h)} = D^{(l,h)} - A^{(l,h)}$ and uses the diagonal eigenvalues across all layers and heads as features, reduced via PCA and input to a logistic regression probe. Across 7 QA datasets and 5 LLMs, LapEigvals achieves state-of-the-art performance among attention-based methods and demonstrates robust ablations with respect to hyperparameters, prompts, and temperatures. The work demonstrates that spectral properties of internal attention dynamics provide meaningful signals for safety-critical hallucination detection, with practical implications for improving reliability in real-world AI systems. It also discusses limitations and avenues for future research, including generalization to unseen architectures and potential self-supervised approaches to enhance robustness.
Abstract
Large Language Models (LLMs) have demonstrated remarkable performance across various tasks but remain prone to hallucinations. Detecting hallucinations is essential for safety-critical applications, and recent methods leverage attention map properties to this end, though their effectiveness remains limited. In this work, we investigate the spectral features of attention maps by interpreting them as adjacency matrices of graph structures. We propose the $\text{LapEigvals}$ method, which utilises the top-$k$ eigenvalues of the Laplacian matrix derived from the attention maps as an input to hallucination detection probes. Empirical evaluations demonstrate that our approach achieves state-of-the-art hallucination detection performance among attention-based methods. Extensive ablation studies further highlight the robustness and generalisation of $\text{LapEigvals}$, paving the way for future advancements in the hallucination detection domain.
