Source-linked AI summary
Hallucination Detection in LLMs Using Spectral Features of Attention Maps
Jakub Binkowski, Denis Janiak, Albert Sawczyn, Bogdan Gabrys, Tomasz Kajdanowicz
TL;DR
Hallucinations remain a challenge for LLMs, and detecting them matters in safety-critical applications. LapEigvals uses top-k eigenvalues of attention-map Laplacians as probe features. It achieves the best performance on 6 of 7 datasets, with TruthfulQA the exception.
Problem
LLMs remain prone to hallucinations, making detection important in safety-critical applications where errors are costly.
Source: §1 · p. 1Method
Results
LapEigvals achieved the best performance on 6 of 7 datasets and was second-best on TruthfulQA.
Source: §5 · p. 5Takeaways & Limitations
Ablations indicate stability across varying eigenvalue counts, prompts, and generation temperatures, with reasonable generalization.
Source: §8 · p. 9The method is incompatible with LLMs that have different head and layer configurations.
Source: Limitations · p. 9
Abstract
from arXiv · showhide
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.
1 Introduction
Hallucinations remain a safety concern, motivating methods that detect them and study LLM internal behavior. This work examines spectral features of attention maps and proposes LapEigvals, using top-k Laplacian eigenvalues as probe features.
1 Introduction
- Hallucinations are a particular concern in safety-critical applications, where errors carry high costs, and detection is needed because eliminating hallucinations is impossible.Source: §1 · p. 1
- Prior work has detected hallucinations using model hidden states or attention maps and found that LLMs can internally recognize uncertainty.Source: §1 · p. 1
- Statistical analysis suggests Laplacian features predict hallucinations better than the earlier log-determinant-based method.Source: §1 · p. 1
- The top-k eigenvalues of attention-map Laplacians serve as features for probes, achieving state-of-the-art hallucination detection among attention-based approaches.The paper interprets attention maps as weighted graph adjacency matrices.Source: §1 · p. 1
- Ablation studies demonstrate LapEigvals’ properties, robustness, and generalization, while suggesting directions for further development.Source: §1 · p. 1
2 Motivation
The motivation tests whether graph spectral features of attention maps align with hallucinations more strongly than AttentionScore. The authors connect this hypothesis to possible information-flow bottlenecks and compare the features across datasets and models.
2 Motivation
- The hypothesis is that information-flow disruptions, such as bottlenecks, may arise with hallucinations and be detectable through the graph Laplacian.Source: §2 · p. 2
- The analysis tests whether spectral features coincide more strongly with hallucinations than AttentionScore.Source: §2 · p. 2
- Laplacian eigenvalues often yielded lower p-values than AttentionScore when comparing hallucinated and non-hallucinated examples; similar findings were observed across 7 datasets and 5 LLMs.The analysis used the 10 largest Laplacian eigenvalues from each attention head and layer.Source: §2 · p. 2
3 Method
LapEigvals treats attention maps as graph adjacency matrices and feeds Laplacian eigenvalues from the model’s layers and heads to a hallucination probe. The method derives a directed-graph Laplacian from attention scores, then uses its top-k eigenvalues as features.
3 Method
- Each attention map is a row-stochastic weighted adjacency matrix of a directed graph whose nodes are processed tokens and whose edges carry attention scores.The row-stochastic property means each row sums to 1.Source: §3 · p. 2
- The Laplacian subtracts the attention matrix from an out-degree matrix that measures later-token attention received and is normalized by the number of subsequent tokens.This normalization makes the degree values independent of sequence length.Source: §3 · p. 2
- Because the Laplacian is lower triangular, its eigenvalues are its diagonal entries; the method sorts them and uses the largest values.The passage describes these eigenvalues as summarizing graph information flow.Source: §3 · p. 2
- On TriviaQA with Llama-3.1-8B, 91% of heads had significant differences for Laplacian eigenvalues, versus 80% for AttentionScore.The figure reports the share of heads with p < 0.05 in a two-sided Mann-Whitney U test.Source: Figure 1 · p. 3
- The probe concatenates the top-k Laplacian eigenvalues from every layer and head, then applies PCA to reduce the resulting feature vector’s dimensionality.The vector has dimension L·H·k before projection.Source: §3 · p. 3
4 Experimental setup
The experiments evaluate supervised attention-map probes across QA datasets and LLM configurations, with answer labels constructed from annotated data. The setup compares LapEigvals with attention-based baselines and uses AUROC for test-split evaluation.
4 Experimental setup
- Figure 3 distinguishes solid-line test-time steps from dashed steps used to generate labels for training the logistic-regression hallucination probe.The diagram highlights top-k Laplacian eigenvalues as the probe features.Source: Figure 3 · p. 4
4.1 Dataset construction
- The study uses seven QA datasets and evaluates ten LLM configurations; answers are labeled with an LLM judge except where exact-match evaluation is possible.The judge assigns hallucination, non-hallucination, or rejected labels; a second model’s agreement was checked for Llama-3.1-8B.Source: §4.1 · pp. 3–4
4.2 Hallucination Probe
- A logistic-regression probe tests k values of 5, 10, 20, 50, and 100, projects features with PCA, and is evaluated by test-split AUROC.For examples shorter than 100 tokens, the tested k values stop at 50.Source: §4.2 · p. 4
4.3 Baselines
- Baselines include supervised AttnLogDet, the original unsupervised AttentionScore, and AttnEigvals computed from raw attention maps.The authors also report comparisons with hidden-state methods and per-layer results in appendices.Source: §4.3 · p. 5
5 Results
LapEigvals achieves the best performance among tested methods on six of seven datasets and performs well across five LLM architectures. It is second-best on TruthfulQA, while raw-attention eigenvalues perform worse than Laplacian eigenvalues.
5 Results
- LapEigvals achieved the best performance among tested methods on 6 of 7 datasets and performed consistently across five LLM architectures from 3 to 24 billion parameters.TruthfulQA was the sole dataset where it ranked second-best; the authors suggest small dataset size or severe class imbalance may account for the exception.Source: §5 · p. 5
- AttnEigvals performed worse than LapEigvals, which the authors say suggests that transforming attention maps to a Laplacian is crucial for uncovering hallucination-related features.The reported generalization gap was also consistently smaller for LapEigvals.Source: §5 · p. 5
- LapEigvals performed best in most tested settings against hidden-state probes, while supervised AttnLogDet remained inferior to spectral-feature methods.The authors caution that unsupervised AttentionScore should not be directly compared with supervised methods.Source: §5 · p. 5
6 Ablation studies
The ablations examine eigenvalue count, layer selection, decoding temperature, dataset transfer, and prompt variation. Across these settings, LapEigvals generally performed robustly, though generalization was weaker on TruthfulQA and GSM8K.
6 Ablation studies
- The ablation studies use TriviaQA, selected for its moderate input size and number of examples.The authors state this choice was made to support reliable studies.Source: §6 · p. 5
6.1 How does the number of eigenvalues influence performance?
- LapEigvals at k=5 outperformed AttnEigvals at k=100, while increasing k generally improved performance and LapEigvals varied less across k.The comparison used Mistral-Small-24B on TriviaQA; Figure 4 shows probe performance for k values from 5 to 100.Source: §6.1 · p. 5, Figure 4 · p. 5
6.2 Does using all layers at once improve performance?
- All-layer probes consistently outperformed the best per-layer probes, although per-layer performance generally improved in deeper layers and its peak varied by LLM.Figure 5 compares per-layer and all-layer performance for Mistral-Small-24B on TriviaQA.Source: §6.2 · pp. 5–6, Figure 5 · p. 6
6.3 Does sampling temperature influence results?
- All methods improved at higher decoding temperatures, and LapEigvals consistently achieved the best accuracy across the temperatures considered.The study balanced samples by drawing 1,000 hallucinated and 1,000 non-hallucinated examples ten times per temperature.Source: §6.3 · p. 6, Figure 6 · p. 7
6.4 How does LapEigvals generalizes?
- LapEigvals had a performance drop comparable to baselines under cross-dataset testing and generalized best in several cases, but all methods performed poorly on TruthfulQA and GSM8K.The reported comparison is percent drop in Test AUROC when training and test datasets differ; Appendix I reports LapEigvals had the highest test performance except on TruthfulQA.Source: §6.4 · p. 7
6.5 How does performance vary across prompts?
- LapEigvals consistently outperformed baselines across four prompts, although performance varied across prompts.Table 2 reports Test AUROC for TriviaQA with Llama-3.1-8B, temp=1.0, and k=50.Source: §6.5 · p. 7, Table 2 · p. 7
7 Related Work
Related work spans output-based and internal-state approaches to hallucination detection. This paper situates its supervised, graph-based attention method against prior probes and attention-map methods.
Black-box and white-box approaches
- Black-box approaches assess generated text, including external-knowledge fact checking and response-consistency methods such as SelfCheckGPT (Manakul et al., 2023).External-knowledge checking depends on additional resources, while self-consistency methods require multiple model runs per example (Liang et al., 2024).Source: §7 · pp. 7–8
- White-box methods use hidden states, attention maps, or logits; prior work includes hidden-state probes and Semantic Entropy methods.Related work also reports limited cross-dataset probe generalization, especially between datasets requiring different skills (Orgad et al., 2025).Source: §7 · pp. 7–8
Attention-based methods
- AttentionScore is unsupervised and layer-sensitive, whereas this work uses supervised graph-Laplacian features from all attention scores and layers.The paper states that AttentionScore aggregates the attention diagonal for its log-determinant, while its method derives features from the graph Laplacian; it also reports poor performance for AttentionScore on evaluated datasets.Source: §7 · p. 8
8 Conclusions
The paper concludes that Laplacian spectral features from attention maps carry a hallucination-detection signal and form the basis of LapEigvals. Its evaluations report state-of-the-art performance among tested approaches and robustness across several ablation settings.
8 Conclusions
- LapEigvals uses the top-k eigenvalues of the attention-map Laplacian as input to a hallucination-detection probe.The authors report that these spectral features carry a signal capable of detecting hallucinations.Source: §8 · pp. 8–9
- The method consistently achieved state-of-the-art performance among tested approaches and remained stable across eigenvalue counts, prompts, and generation temperatures, with reasonable generalization.The conclusion characterizes these findings as results of extensive evaluations and multiple ablation studies.Source: §8 · p. 9
- The authors suggest self-supervised learning as a direction for developing more robust and generalizable approaches and uncovering intrinsic attention-map features.They also identify connections between temperature-related results and recent LLM research as a direction for further investigation.Source: §8 · p. 9
Limitations
The paper identifies supervision, architecture compatibility, minimum input length, and access to model internals as method constraints. It also limits its evaluation to selected LLMs and English data, and supplies supporting study, implementation, and dataset details.
Limitations
- The method requires labeled hallucinated and non-hallucinated examples, is incompatible with differing head and layer configurations, and requires at least k tokens for top-k eigenvalues.It also requires access to internal states, so it cannot be applied to closed LLMs; the authors caution that untested domains and tasks need additional validation.Source: Limitations · p. 9
A Details of motivational study
- The motivational study compared hallucinated and non-hallucinated examples across seven datasets and five LLMs; Laplacian eigenvalues distinguished the classes better for almost all considered configurations.The study used ten largest Laplacian eigenvalues per head and a Mann–Whitney U test; significance was assessed at p < 0.05.Source: A Details of motivational study · p. 15, Table 3 · p. 15
B Bounds of the Laplacian
- The appendix states that Laplacian eigenvalues are bounded between -1 and 1 and that the Laplacian has at least one zero eigenvalue.The zero eigenvalue corresponds to the last token, according to the stated lemma.Source: B Bounds of the Laplacian · pp. 15–16
C Implementation details
- Experiments used a single Nvidia A40 for inference except Mistral-Small-24B, which used an Nvidia H100; probe training ran on CPU.The implementation details also report using gpt-4o-mini through the OpenAI API to compute labels with the llm-as-judge approach.Source: C Implementation details · p. 16
D Details of QA datasets
- The study used seven publicly available question-answering datasets, including NQ-Open, SQuADv2, TruthfulQA, HaluEvalQA, CoQA, TriviaQA, and GSM8K.The appendix notes dataset-specific licensing and research-purpose use.Source: D Details of QA datasets · p. 16
E Hallucination dataset sizes
Datasets were split by hallucination label after rejected examples were removed, and most were imbalanced. The authors also assessed agreement between LLM judges as a check on label quality.
E Hallucination dataset sizes
- Rejected examples were excluded, and each dataset was split 80%/20% into stratified training and test sets; most datasets underrepresented truthful examples.TriviaQA and GSM8K were exceptions to the imbalance pattern.Source: E Hallucination dataset sizes · p. 16
F LLM-as-Judge agreement
- The authors treated higher agreement between two LLM judges as evidence of better label quality and suggest lower agreement may contribute to weaker TriviaQA performance.They also cite dataset size and class imbalance as possible contributors.Source: F LLM-as-Judge agreement · p. 16, Table 4 · p. 16
E Hallucination dataset sizes
- Figure 8 summarizes question and gold-answer token counts, flattening multiple gold answers into one.Counts use the Llama-3.1-8B-Instruct tokenizer.Source: Figure 8 · p. 17
G.1 Precision and Recall analysis
The extended comparisons report advantages for all-layer probes and higher-temperature data, while performance trade-offs and best per-layer settings vary. Hidden-state probes using all layers performed worse than LapEigvals.
G.1 Precision and Recall analysis
- Higher recall occurs on CoQA, GSM8K, and TriviaQA, while HaluEvalQA, NQ-Open, SQuADv2, and TruthfulQA show higher precision.The analysis uses the default 0.5 threshold and is not a full production evaluation.Source: §G.1 · p. 18
G.2 Extended method comparison
- Across the extended configurations, all-layer probes usually beat per-layer variants, LapEigvals has a smaller generalization gap, and temp=1.0 probes outperform temp=0.1 probes.The authors interpret the smaller gap as evidence of more robust Laplacian-eigenvalue features.Source: §G.2 · p. 18
G.3 Best found hyperparameters
- The best results generally use k=100, though smaller k suffices in some cases.Table 8 reports the selected k values for the best results.Source: §G.3 · p. 18
- Per-layer performance often peaks above layer 10, especially for Llama-3.1-8B, but no consistent optimal layer emerges and selection often requires a search.The first layer is also strong in a few cases.Source: §G.3 · p. 18
G.4 Comparison with hidden-states-based baselines
- The all-layer hidden-state baseline performs worse than LapEigvals.The comparison uses PCA-projected hidden states from the last generated token.Source: §G.4 · p. 18
H Extended results of ablations
- The extended ablation figures compare performance across top-k choices and across layers for five LLMs.The layer-wise comparison is reported separately for each model.Source: H Extended results of ablations · p. 18
I Extended results of generalization study
The extended study reports strong cross-dataset results for LapEigvals, while also identifying limits involving TruthfulQA, labeled-data dependence, perturbations, and implementation costs. Its appendices document evaluation settings and supporting analyses.
J Influence of dataset size
- LapEigvals is supervised and requires labeled hallucination data, but retained reasonable performance when trained on only a few hundred examples.The study used Llama-3.1-8B outputs and evaluated on the full test split; the authors note that LLM-as-judge labeling can be automated and scaled.Source: J Influence of dataset size · p. 19, Table 12 · p. 27
K Reliability of spectral features
- Ordered spectral features may be perturbation-sensitive, but small Gaussian perturbations had negligible performance impact in the tested setup.The authors report bfloat16 storage as rounding minor fluctuations and acting as regularization.Source: K Reliability of spectral features · p. 19, Table 13 · p. 27
L Cost and time analysis
- Precise cost and time estimates vary with external services and hardware; labeling estimates use $0.60 per 1M output tokens and exclude caching effects.The authors note that Batch API use could reduce labeling costs.Source: L Cost and time analysis · p. 19
- Inference requires materializing the full attention matrix, which may limit optimizations such as FlashAttention; feature computation is O(n^2) in token count, followed by O(n log n) sorting.The overall complexity also scales with the model’s number of layers and heads.Source: L Cost and time analysis · pp. 19–20
M QA prompts
- The QA appendix lists one-shot, zero-shot, few-shot, and GSM8K-specific prompts; the few-shot prompt is the main prompt used in the study.The GSM8K prompt includes an output-format instruction.Source: M QA prompts · p. 20
N LLM-as-Judge prompt
- Dataset labels were produced with an LLM-as-judge approach using gpt-4o-mini and a prompt adapted from Orgad et al. (2025).The appendix provides the judge prompt used to determine hallucination labels.Source: N LLM-as-Judge prompt · pp. 20, 32
I Extended results of generalization study
- Except on TruthfulQA, LapEigvals has the highest test AUROC across configurations; it has the lowest relative performance drop in nearly half of cross-dataset scenarios.The authors call for further evaluation across datasets, particularly deeper analysis of TruthfulQA.Source: I Extended results of generalization… · p. 19, Table 11 · p. 27, Figure 12 · p. 30
Related papers
This paper cites
- Attention Is All You Need2017
- GPT-4 Technical Report2023
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness2022
- TruthfulQA: Measuring How Models Mimic Human Falsehoods2021
- A Survey on Hallucination in Large Language Models: Principles, Taxonomy, Challenges, and Open Questions2023
- Know What You Don't Know: Unanswerable Questions for SQuAD2018
Cited by
- CHORD: Cross-Model Hallucination Detection via Relational Graph Discrimination2026
- Spectral Geometry of Attention: From Information Routing to Uncertainty2026
- READY or Not: Reliable Enterprise Agent Deployment2026
- Investigating Linear Probe Robustness to Linguistic Register, Medical Specialty, and Corpus Shifts in Medical QA2026
- The Safeguard Worked. Is the LLM System Safer?2026