Automatic Layer Selection for Hallucination Detection
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 large language models (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
Lay Summary
Large language models (LLMs) can sometimes produce confident-sounding but factually wrong answers, a problem known as hallucination. Detecting these errors automatically is important for safely deploying AI. Recent research shows that the hidden states of an LLM contain signals about whether the model is hallucinating, and these signals are strongest at intermediate layers rather than the final layer. However, no principled method exists to automatically find the best layer. 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. Through a systematic investigation of the various criteria, we find that none of them reliably identifies high-performing layers. We therefore propose a new selection criterion, First Effective Peak of Intrinsic Dimension (FEPoID), a simple and training-free criterion that selects layers by tracking how the geometric complexity of representations evolves across layers. Experiments show that it consistently identifies near-optimal layers and achieves superior detection performance than other criterions and existing detection baselines. 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.