Automatic Layer Selection for Hallucination Detection

Xinpeng Wang, William Cao, Andrew Gordon Wilson, Zhe Zeng

Introduction

Large Language Models (LLMs) are prone to hallucinations—generating confident but factually incorrect statements. Recent research reveals that an LLM's "internal truth" is often more accurately captured within its intermediate hidden layers rather than its final output. However, pinpointing the exact layer that contains the strongest hallucination-related signal has historically been a computationally expensive guessing game.

This paper introduces FEPoID (First Effective Peak of Intrinsic Dimension), a training-free method to automatically select the most informative layer, alongside First-Sentence Truncation (FST), a strategy to mitigate noise in long generations.

The Core Challenges

Detecting these "confident lies" involves two major hurdles:

  1. The Layer Problem: Hallucination signals peak in intermediate layers, but the optimal layer varies drastically depending on the model architecture, scale, and specific task. Manually probing every layer is computationally expensive and impractical for production environments.
  2. The Token Problem: Standard detection methods probe the final generated token. However, as an LLM generates longer responses, it often drifts into "end-of-sequence noise"—meaningless repetitions or semantic drift—which obscures the original factual signal and makes it harder to determine if the core answer was true.

Proposed Methodology

The authors propose a two-pronged approach to clean up and automate hallucination detection:

  • FEPoID (First Effective Peak of Intrinsic Dimension): The authors observed a fascinating phenomenon: as data propagates through LLM layers, its Intrinsic Dimension (ID)—the number of variables required to represent the data—typically exhibits two distinct peaks. They hypothesize that the first peak captures abstract semantic meaning (the "truth"), while the second peak (closer to the output) reflects surface-level vocabulary prediction. FEPoID automatically identifies this first peak to select the optimal layer without requiring labeled training data or expensive gradient calculations.
  • First-Sentence Truncation (FST): To combat the token problem, the authors propose analyzing the representation at the end of the first sentence rather than the final token of the entire sequence. Because LLMs generally state their primary answer early, FST effectively bypasses the semantic degradation that plagues the tail end of long generations.
  • Probing: Using the layer selected by FEPoID and the token isolated by FST, a lightweight Multi-Layer Perceptron (MLP) classifier is trained to distinguish factual from hallucinated content.

Experimental Setup

The methods were rigorously evaluated across diverse benchmarks and models:

  • Question Answering (QA): CoQA, SQuAD, HotpotQA, TriviaQA, and PsiLoQA.
  • Summarization: HaluEval and CNN/Daily Mail.
  • Vision (Generalization): CIFAR-10 using a Vision Transformer (ViT).
  • Models Tested: Llama-3.1-8B, Mistral-7B, and Llama-3.2 (1B and 3B).

Key Findings and Results

  • Superior Detection Accuracy: FEPoID consistently identified layers that outperformed standard heuristics (such as defaulting to the middle layer). In QA tasks, it achieved an average AUROC of 0.8531 on Mistral-7B, surpassing uncertainty-based baselines like Semantic Entropy.
  • Massive FST Boost: Applying First-Sentence Truncation yielded substantial performance improvements across all detection methods. For Llama-3.1-8B, FST improved the AUROC of standard entropy-based detection by nearly 20%.
  • High Efficiency: As a "plug-and-play" criterion, FEPoID is highly efficient. It takes approximately 10 seconds to analyze all 32 layers of a Llama-3.1-8B model, compared to roughly 60 seconds for gradient-based alternatives.
  • Cross-Domain Generalization: The relationship between intrinsic dimension and informative layers extends beyond text; FEPoID successfully identified optimal layers in a Vision Transformer for image classification. This suggests that the "two peaks" phenomenon might be a fundamental property of Transformer architectures.

Limitations and Future Directions

While highly effective, the current framework focuses on binary classification (determining whether a full response is a hallucination or not). Future research could target granular, span-level detection to identify exactly which part of a sentence is false. Additionally, the study primarily examines English-language models; the behavior of ID peaks in multilingual contexts or complex reasoning chains remains an open question. Finally, while empirical evidence for the "two peaks" phenomenon is robust, further theoretical grounding is needed to fully explain why the first peak of intrinsic dimension aligns so precisely with abstract semantic truth.

Summary updated

BibTeX
@inproceedings{wang2026automatic,
  author = {Xinpeng Wang and William Cao and Andrew Gordon Wilson and Zhe Zeng},
  title = {{Automatic Layer Selection for Hallucination Detection}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=srAuLCB3Ca},
}
Figure