Papers
Topics
Authors
Recent
Search
2000 character limit reached

Automatic Layer Selection for Hallucination Detection

Published 25 May 2026 in cs.AI and cs.LG | (2605.26366v1)

Abstract: Recent studies on hallucination detection have shown that hallucination-related signals are more strongly encoded in intermediate layers than in the final layer of LLMs. Although a growing body of work has sought to exploit this property for hallucination detection, how to automate the selection of high-performing layers remains underexplored, and principled methods for this purpose are still lacking. To address this gap, we first propose several hypotheses for why such signals emerge in intermediate layers and evaluate corresponding criteria for automatic layer selection across diverse LLM architectures, scales, and tasks, covering both question answering and summarization hallucination detection benchmarks. However, we find that none of these criteria consistently delivers satisfactory performance. We therefore propose a new selection criterion, First Effective Peak of Intrinsic Dimension (FEPoID), which consistently identify optimal or near-optimal layers and outperforms both the aforementioned criteria and existing hallucination detection baselines. FEPoID is training-free and incurs negligible computational overhead. In addition, we study the generation behaviors of LLMs and introduce a simple yet effective truncation strategy, which further amplifies hallucination-related signals and substantially improves overall detection performance. Code is publicly available at https://github.com/DesoloYw/Automatic-Layer-Selection-for-Hallucination-Detection.git

Summary

  • The paper introduces FEPoID, a novel criterion that automatically identifies optimal intermediate layers by leveraging intrinsic dimension curves for enhanced hallucination detection.
  • The paper rigorously benchmarks various selection methods, demonstrating that FEPoID outperforms traditional criteria by achieving near-oracle AUROC performance across diverse LLMs and tasks.
  • The paper presents First-Sentence Truncation (FST) as a simple, effective heuristic that mitigates end-of-sequence noise, thereby further boosting detection performance.

Automatic Layer Selection for Hallucination Detection: A Comprehensive Analysis

Introduction

The issue of hallucinationโ€”outputting fluent yet factually incorrect or inconsistent generationsโ€”remains a significant bottleneck in the deployment and reliability of LLMs. Hidden-state probing methods, which extract fixed representations from an LLM (keeping model weights frozen) and train a lightweight classifier (e.g., an MLP) for hallucination detection, have gained traction due to their flexibility and efficiency. Empirical evidence indicates that hallucination-related signals are not most salient in the final output layer but are instead strongly encoded in intermediate layers. However, principled, efficient, and generalizable criteria for automatically selecting such layers are lacking. This work offers a systematic evaluation of existing and novel criteria for automatic layer selection, introduces the First Effective Peak of Intrinsic Dimension (FEPoID) criterion, and proposes a practical token position heuristicโ€”First-Sentence Truncation (FST)โ€”that amplifies detection performance. Figure 1

Figure 1

Figure 1

Figure 1

Figure 1

Figure 1: Hallucination detection performance under a unified experimental setting. FEPoID consistently outperforms the last-layer heuristic, and its combination with truncation yields further gains across models.

Layer Selection in Hallucination Detection

Problem Motivation

Layer selection is nontrivial since the optimal probing layer (in terms of AUROC for hallucination detection) demonstrably varies across models, datasets, and tasks, and is rarely the output layer. Exhaustively evaluating every candidate layer is computationally impractical, while using simplistic middle or preset heuristics leads to suboptimal results. The core research question: Can an automatic, training-free criterion reliably identify layers encoding maximal hallucination-related information under the hidden-state probing paradigm?

Criteria and Hypotheses

The paper systematically benchmarks several criteria inspired by different representational hypotheses:

  • Information-theoretic: RankMe score quantifies rank/linearity of embeddings.
  • Gradient-based: Probe validation loss, relative gradient norm (RGN), and signal-to-noise ratio (SNR) capture trainability and robustness.
  • Geometric/structural: Curvature measures trajectory complexity, and Intrinsic Dimension (ID) quantifies information capacity.

However, none of these approaches consistently yield layers that match oracle performance (the highest possible AUROC achievable with post hoc selection).

FEPoID: A New Criterion

FEPoID (First Effective Peak of Intrinsic Dimension) leverages the observation that ID curves across a network often show a multimodal structure: an early (intermediate) peak associated with semantic abstraction, and a late peak proximate to output layers dominated by surface information. FEPoID formalizes the selection of the first robust (within a forward window) local maximum of the ID curve as the optimal probing layer. This method is training-free, data-agnostic, architecture-agnostic, and introduces minimal computational overhead, outperforming all prior baselines across diverse LLMs and tasks. Figure 2

Figure 2

Figure 2

Figure 2

Figure 2

Figure 2

Figure 2

Figure 2

Figure 2: Layer-wise AUROC and intrinsic dimension across QA datasetsโ€”FEPoID consistently selects layers near the oracle optima, highlighting robustness for practical use.

Token Position Heuristics: Weakness of the Last-Token and FST

Problem with the Last-Token Representation

Standard practice for hidden-state probing is to extract a representation at the last generated token, justified by maximal receptive field in autoregressive models. However, this approach is vulnerable to end-of-sequence noise, including semantic drift, inconsistent continuations, and degenerate repetition, especially in models that do not emit precise <eos> tokens. Figure 3

Figure 3: Generation behaviors in LLaMA-Instruct and Mistral-Instruct models without FST: LLaMA-Instruct more frequently produces noisy or inconsistent continuations post-answer.

First-Sentence Truncation (FST)

The authors propose FST: truncating generated responses at the end of the first sentence and extracting hidden states from the corresponding token. This rule-based, supervision-free heuristic consistently produces more discriminative class structure and improves performance for all hallucination detection methods, reducing contamination from noise introduced in late-stage generation. Figure 4

Figure 4: AUROC improvements achieved by applying FST relative to the standard last generated token heuristic across all methods.

Empirical Results and Analysis

Numerical Results

  • QA and Summarization Benchmarks: FEPoID achieves highest or near-highest AUROC on all tested datasets and LLMs, outperforming baselines rooted in validation loss, RGN, SNR, RankMe, Curvature, ID, LID, EigenScore, and surface/likelihood-based heuristics.
  • Computational Efficiency: FEPoID's computation time is significantly lower than that of gradient-based or validation-loss methods, making it practical for large-scale or production deployments.
  • Robustness: FEPoID is invariant to the forward horizon hyperparameter ww within a reasonable range, and generalizes to models of various scales, instruction-tuned and base, as well as to tasks beyond text (e.g., ViT-based image modeling). Figure 5

    Figure 5: The AUROC gap between the layer selected by each criterion and the oracle best layerโ€”for FEPoID, the gap is consistently minimal, while other methods yield larger, more variable disparities.

Practical and Theoretical Implications

The work substantiates the claim that automatic layer selection is essential for unlocking the full potential of latent representations for factuality/semantic tasks, and that representation quality does not monotonically increase with depth. The ID curve structure provides a theoretically grounded signal for extracting maximal abstract semantic content. FST, as a simple truncation heuristic, highlights the need to reconsider assumptions on context completeness and noise when extracting representations for any downstream classification or calibration task in LLMs. Figure 6

Figure 6

Figure 6

Figure 6

Figure 6

Figure 6

Figure 6

Figure 6

Figure 6: Layer-wise AUROC and intrinsic dimension (with FST) across QA datasetsโ€”FEPoID (diamonds) consistently tracks the actual best-performing layer (stars).

Generalization and Extension

The FEPoID framework is validated on vision tasks: in ViT image classification, it reliably picks high-performing layers corresponding to the last (penultimate) transformer block, paralleling the findings from language modeling. This supports FEPoID's generality for layer selection across modalities and tasks that favor semantic abstraction.

Conclusion

This work provides the first systematic, cross-model, and cross-task evaluation of automatic layer-selection criteria for hidden-state probing in hallucination detection. Prior layer-selection rules, including validation loss, gradient-based, information-theoretic, and geometric criteria, fail to reliably identify optimal layers. FEPoIDโ€”a training-free and computationally lightweight criterion based on intrinsic dimension curvesโ€”consistently selects near-optimal intermediate layers. First-Sentence Truncation further enhances representation quality by precluding end-of-sequence noise without requiring external supervision. Together, these contributions offer a principled, practical blueprint for robust, modular hallucination detectionโ€”and more generally, for extracting task-relevant representations from LLMsโ€”without model modification or costly validation.

Future directions include extending the approach to more abstract tasks and modalities and formalizing the theoretical connections between intrinsic dimension dynamics, semantic abstraction, and downstream discriminability.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

Tweets

Sign up for free to view the 2 tweets with 23 likes about this paper.