From Out-of-Distribution Detection to Hallucination Detection: A Geometric View Litian Liu, Reza Pourreza, Yubing Jian, Yao Qin, Roland Memisevic Abstract Detecting hallucinations in large language models is a critical open problem with significant implications for safety and reliability. While existing hallucination detection methods achieve strong performance in question‑answering tasks, they remain less effective on tasks requiring reasoning. In this work, we revisit hallucination detection through the lens of out‑of‑distribution (OOD) detection, a well‑studied problem in areas like computer vision. Treating next‑token prediction in language models as a classification task allows us to apply OOD techniques, if we bring to bear appropriate modifications to account for the structural differences in large language models. We show that approaches based on OOD detection yield training-free, single-sample based detectors, achieving strong accuracy in hallucination detection in reasoning tasks. Overall, our work suggests that reframing hallucination detection as OOD detection provides a promising and scalable pathway toward language model safety. 1 Introduction Hallucination remains a fundamental obstacle to the reliable deployment of Large Language Models (LLMs), and their detection has therefore been an important research area in recent years. One prominent line of work ( 1 ; 12 ; 16 ; 21 ; 29 ; 30 ; 34 ; 40 ) trains a separate classifier to detect hallucinations. These methods can be sensitive to distribution shifts and incur high training costs. Training-free methods ( 1 ; 12 ; 16 ; 21 ; 29 ; 30 ; 34 ; 40 ) , by contrast, measure discrepancies across multiple samples to detect hallucinations. While they avoid training overhead, they impose significant computational costs during inference—particularly in multi-step reasoning. Furthermore, although such methods perform well on concise question-answering tasks, they face challenges in reasoning, where the inherent diversity of valid reasoning paths makes comparing multiple outputs conceptually difficult. This motivates the need for training-free , single-sample based hallucination detection algorithms within the increasingly critical domain of reasoning. Conceptually, hallucination detection is reminiscent of out-of-distribution (OOD) detection ( 6 ; 17 ; 26 ; 35 ; 36 ; 43 ; 15 ; 37 ; 24 ; 25 ) , a dominant research area for classification tasks. In OOD detection, the goal is to identify test samples whose class labels were not seen during training. For such samples, the model will still produce a prediction from the set of training classes, despite having no knowledge of the true label—effectively generating a “hallucination” of the classifier. At their core, both OOD detection and hallucination detection in LLMs boil down to measuring the model’s uncertainty ( 14 ; 24 ) . (a) NCI: Proximity to Weight Vectors (b) fDBD: Distance to Decision Boundary Figure 1 : OOD-inspired geometric uncertainty measures can detect hallucinations. (a) Embeddings from hallucinated responses exhibit less proximity to weight vectors, extending OOD detector NCI ( 25 ) . (b) Embeddings from hallucinated responses exhibit smaller distance to decision boundaries than correct embeddings, extending OOD detector fDBD ( 24 ) . (a) Left and (b) Left illustrate the proximity score and distance to the decision boundaries defined in Definition 3.1 and Definition 3.2 , respectively. (a) Right and (b) Right show histograms for the corresponding uncertainty measures based on the CSQA dataset on Llama-3.2-3B-Instruct . A natural question therefore is: can we leverage the rich literature on OOD detection to address the challenge of hallucination detection? Unfortunately, despite the conceptual similarities, several practical challenges arise when applying OOD detection methods to hallucination detection in LLMs. First, many OOD detectors rely on the empirical estimation of training statistics ( 39 ; 25 ; 7 ; 15 ; 27 ) such as the mean of penultimate-layer features. While these statistics effectively characterize the training distribution and enable OOD detection, directly estimating them from LLM training data is impractical. Modern training corpora are often proprietary, and even when accessible, their scale renders computation prohibitively expensive. Second, the label space expands dramatically when moving from conventional classifiers to LLMs. OOD scores designed for small label spaces can become noisy and less reliable, and the expanded space furthermore amplifies computational costs, particularly in multi-step reasoning tasks where expenses accumulate across decoding steps. Third, unlike classifiers, which typically make deterministic decisions, LLMs are generative and may employ stochastic decoding. The inherent variance from token sampling therefore makes it unclear to what degree OOD scores are applicable in hallucination detection. In this work, we take a step towards bridging the gap between OOD detection and hallucination detection. Since the cumulative computational cost in applying the score at each decoding step is high, we explore the adaptation of two light-weight OOD detectors, NCI ( 25 ) and fDBD ( 24 ) . Both methods take a geometric view of measuring uncertainty: NCI measures penultimate layer feature proximity to weight vectors of the last layer (see Figure 1(a) ) (the lower the proximity the higher the uncertainty); fDBD measures the penultimate layer distance to the decision boundaries of the last layer (Figure 1(b) ). To adapt these methods to solve the task of hallucination detection, we derive an analytical proxy for the required training statistics in their score function - the mean of training features in this case. In addition, for fDBD to be efficient and effective in the large label space, we explore the reduction of the distance computation to a selected subset of high-likely alternative tokens in hallucination detection. We furthermore show that a simple but effective way to extend these methods to sequences, is the averaging of the step-wise uncertainty score as the hallucination detection score. We demonstrate that the adapted geometry based methods can perform well under both greedy and stochastic decoding. We perform extensive experiments to validate the effectiveness of OOD-inspired hallucination detection across different types of reasoning tasks (commonsense v.s. mathematical), model architectures and model scales (Llama-3.2-3B-Instruct, Qwen-2.5-7B-Instruct, Qwen-3-32B), showing consistent superior performance compared to a range of baselines. This shows that framing hallucination detection as OOD detection provides a promising and scalable path toward improved language model safety. 2 Problem Statement Let f denote a large language model (LLM). Given an input prompt \bm{x} , let \bm{y}=(y_{1},\dots,y_{T}) be the sequence of tokens generated by the model. We denote the set of all factually correct responses to \bm{x} as \mathcal{Y}^{*}(\bm{x}) . We say that the model f is hallucinating if the generated response \bm{y} is incorrect, i.e., \bm{y}\notin\mathcal{Y}^{*}(\bm{x}) . During inference, the ground-truth set of correct responses \mathcal{Y}^{*}(\bm{x}) for a given prompt \bm{x} is unknown. The task of hallucination detection is to construct a binary detector \mathcal{I} that predicts whether \bm{y}\in\mathcal{Y}^{*}(\bm{x}) based on the prompt \bm{x} , the response \bm{y} , and the model f ’s internal representations: \mathcal{I}(\bm{x},\bm{y};f)=\begin{cases}1\,(\text{Hallucination}),&\text{if }S(\bm{x},\bm{y};f)\leq\tau,\\ 0\,(\text{Not Hallucination}),&\text{otherwise}.\end{cases} (1) where S(\bm{x},\bm{y};f) is a scoring function and \tau is a threshold. Under this formulation, a lower score S typically reflects lower model certainty and therefore a higher likelihood of hallucination. 3 Geometry of Token Generation under a Classification View In this section, we adapt two geometric measures—feature proximity to weight vectors and feature distance to decision boundaries—from the out-of-distribution detection literature for token generation. Both measures characterize the interplay between features and language head but were shown to exhibit different empirical strength across different OOD settings. We then discuss and empirically validate their connection to hallucination detection. 3.1 Classification View Consider a large language model (LLM) f with model dimension d_{\text{model}} and vocabulary \mathcal{V} . At decoding step t , given an input prompt \bm{x} and previously generated tokens \bm{y}_{