D2HScore: Reasoning-Aware Hallucination Detection via Semantic Breadth and Depth Analysis in LLMs

Yue Ding, Xiaofang Zhu, Tianze Xia, Junfei Wu, Xinlong Chen, Qiang Liu, Liang WangarXiv 2025 · DOI

Abstract

Large Language Models (LLMs) frequently generate content that is fluent but factually incorrect, a phenomenon known as hallucination. This paper introduces $D^2HScore$ (Dispersion and Drift-based Hallucination Score), a training-free, "white-box" framework designed to detect these errors by analyzing the model's internal hidden states. By evaluating Semantic Breadth (intra-layer dispersion) and Semantic Depth (inter-layer drift), $D^2HScore$ captures the underlying reasoning dynamics of the model. Experimental results across multiple benchmarks and models demonstrate that $D^2HScore$ significantly outperforms existing detection methods, offering a robust and interpretable approach to ensuring LLM faithfulness.

Introduction

The deployment of Large Language Models in high-stakes fields like medicine or law is currently hindered by their tendency to hallucinate. Existing detection strategies generally fall into two categories: black-box methods, which analyze final text outputs for consistency but are computationally expensive, and white-box methods, which inspect internal activations. While faster, many white-box methods require labeled training data or fail to account for the "reasoning trace"—the progressive refinement of information as it passes through the model's layers.

We propose that hallucinations occur when internal representations either lack diversity (semantic collapse) or fail to evolve meaningfully. $D^2HScore$ addresses this by monitoring how a model "thinks" internally, rather than just what it says.

Methodology: The $D^2HScore$ Framework

The $D^2HScore$ framework utilizes two primary metrics derived from a single forward pass of the model:

  1. Intra-Layer Dispersion (Semantic Breadth): This metric quantifies the spread of token embeddings within a single layer. A faithful, information-rich response typically exhibits high dispersion, indicating diverse representations. Conversely, hallucinations often show "semantic collapse," where embeddings clump into tight, low-information clusters.
  2. Inter-Layer Drift (Semantic Depth): This tracks the trajectory of representations across successive layers. Rather than averaging all tokens, $D^2HScore$ uses attention signals to isolate "key tokens." A significant "drift" in these tokens suggests active reasoning and refinement, whereas a stagnant drift indicates the model is merely repeating learned patterns without coherent logic.
The $D^2HScore$ framework architecture, illustrating the calculation of Dispersion and Drift scores from internal activations and attention weights.

The final hallucination score is a balanced fusion of these two metrics, providing a lightweight, training-free detection mechanism.

Experimental Evaluation

The researchers evaluated $D^2HScore$ across five diverse benchmarks: GSM8K (math), TheoremQA (STEM theorems), MMLU (general knowledge), Belebele (reading comprehension), and MGSM (multilingual math). Testing spanned several models, including Llama-2, Llama-3.1, Qwen-1.5, and specialized "Long Reasoning Models" like DeepSeek-distilled variants.

Key Insights

  • Hallucinations are "Thin": Visual analysis using Principal Component Analysis (PCA) reveals a stark difference in the internal state space of faithful versus hallucinated responses. Faithful outputs occupy a broad, dispersed space, while hallucinated ones form dense, restricted clusters.
  • Reasoning as a Journey: The metric treats reasoning as a progressive evolution. If the internal representation of a key concept remains static between early and late layers, the model is likely failing to perform genuine logical inference.
  • Attention-Guided Filtering: By focusing on tokens with high attention weights, $D^2HScore$ filters out "noise" (e.g., punctuation), leading to a clearer signal of the model's reasoning process compared to methods that average all embeddings.
PCA visualizations comparing token-level hidden states. Faithful samples (left) show high dispersion, while hallucinated samples (right) exhibit semantic collapse.

Results

$D^2HScore$ consistently outperformed standard baselines such as Maximum Softmax Probability (Maxprob), Perplexity, and the Chain-of-Embedding (CoE) method. On the TheoremQA dataset with Llama2-7B, $D^2HScore$ achieved an AUPR of 19.73, a significant improvement over the 12.58 achieved by Maxprob. The method also showed strong performance in multilingual contexts (Japanese and French) and scaled effectively with advanced reasoning architectures.

Conclusion and Future Work

$D^2HScore$ provides a powerful, interpretable tool for detecting hallucinations by looking "under the hood" of LLMs. While its requirement for internal state access limits its use to open-source models, its efficiency makes it an ideal candidate for real-time monitoring. Future research could explore using $D^2HScore$ as a feedback signal during the generation process to steer models away from hallucination paths in real-time.

Summary updated

BibTeX
@misc{ding2025d,
  author = {Yue Ding and Xiaofang Zhu and Tianze Xia and Junfei Wu and Xinlong Chen and Qiang Liu and Liang Wang},
  title = {{D2HScore: Reasoning-Aware Hallucination Detection via Semantic Breadth and Depth Analysis in LLMs}},
  year = {2025},
  eprint = {2509.11569},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.11569},
}
Figure