Token-Level Density-Based Uncertainty Quantification Methods for Eliciting Truthfulness of Large Language Models

Artem Vazhentsev, Lyudmila Rvanova, Ivan Lazichny, Alexander Panchenko, Maxim Panov, Timothy Baldwin, Artem Shelmanov · 2025

Read Token-Level Density-Based Uncertainty Quantification Methods for Eliciting Truthfulness of Large Language Models by Artem Vazhentsev, Lyudmila Rvanova, Ivan Lazichny, Alexander Panchenko, Maxim Panov, Timothy Baldwin, Artem Shelmanov (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2502-14427.txt.

Introduction

Artem Vazhentsev and co-authors gauge the truthfulness of language model answers from token level density scores in a 2025 paper. Flagging unsure answers helps users trust model output. Information and agreement based checks dominate, while density methods that ruled older classifiers had lagged for text generation.

Their method takes token vectors from several model layers and scores each token by its distance from the typical cloud of training points. A small regression then blends those scores into one uncertainty number. Across eleven data sets it beat prior methods for both choosing safe answers and checking single claims, and it held up on new domains.

Catalog record

CREATORArtem Vazhentsev, Lyudmila Rvanova, Ivan Lazichny, Alexander Panchenko, Maxim Panov, Timothy Baldwin, Artem Shelmanov
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE49 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2502-14427

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Token-Level Density-Based Uncertainty Quantification Methods for Eliciting Truthfulness of Large Language Models Artem Vazhentsev, Lyudmila Rvanova, Ivan Lazichny, Alexander Panchenko, Maxim Panov, Timothy Baldwin, Artem Shelmanov Abstract Uncertainty quantification (UQ) is a prominent approach for eliciting truthful answers from large language models (LLMs). To date, information-based and consistency-based UQ have been the dominant UQ methods for text generation via LLMs. Density-based methods, despite being very effective for UQ in text classification with encoder-based models, have not been very successful with generative LLMs. In this work, we adapt Mahalanobis Distance (MD) -- a well-established UQ technique in classification tasks -- for text generation and introduce a new supervised UQ method. Our method extracts token embeddings from multiple layers of LLMs, computes MD scores for each token, and uses linear regression trained on these features to provide robust uncertainty scores. Through extensive experiments on eleven datasets, we demonstrate that our approach substantially improves over existing UQ methods, providing accurate and computationally efficient uncertainty scores for both sequence-level selective generation and claim-level fact-checking tasks. Our method also exhibits strong generalization to out-of-domain data, making it suitable for a wide range of LLM-based applications. 1 1 1 The code is available online at https://github.com/ArtemVazh/token_mahalanobis_distance 1 Introduction Figure 1: An illustration of the proposed method. After each decoder layer, the embeddings of each generated token are extracted. Subsequently, we compute the Mahalanobis distance for each token and layer and then average over all tokens in the generated sequence. Finally, we train a linear regression on the PCA decomposition of the calculated features with the addition of sequence probability to predict the uncertainty of the generation. Large language models (LLMs) have achieved impressive results over various tasks and applications OpenAI et al. (2024) ; Dubey et al. (2024) ; Rivière et al. (2024) . Nevertheless, even the most advanced LLMs are inevitably prone to making mistakes during text generation. Their responses often contain hallucinations or non-factual claims Xiao and Wang (2021) ; Dziri et al. (2022) , posing significant challenges for LLM deployment in safety-critical domains. Many studies have investigated methods for assessing the truthfulness of LLM responses Manakul et al. (2023) ; Min et al. (2023) ; Chen et al. (2023) ; Feng et al. (2024) . However, many of the proposed techniques have limited practical applicability, as they often rely on external knowledge sources or require ensembling multiple large LLMs, leading to high computational costs that make them economically unfeasible for many use cases. One of the most promising approaches to addressing this challenge is uncertainty quantification (UQ) Gal and Ghahramani (2016) ; Shelmanov et al. (2021) ; Baan et al. (2023) ; Geng et al. (2024) ; Fadeeva et al. (2023) . This research direction recognizes that we will never have complete information about model predictions due to the limited amount of training data and ambiguity of the tasks, and suggests general ways to estimate the reliability of predictions under different conditions. Recently, a suite of UQ methods specifically designed for text generation with LLMs has been developed Fomicheva et al. (2020) ; Lin et al. (2023) ; Kuhn et al. (2023) ; Farquhar et al. (2024) ; Duan et al. (2024) . However, many of these methods are either ineffective or come with a substantial computational overhead, limiting their practicality for large-scale or real-time applications. For text classification and regression tasks, researchers have identified several groups of techniques that maintain a balance between effectiveness and computational efficiency Zhang et al. (2019) ; He et al. (2020) ; Xin et al. (2021) ; Wang et al. (2022) ; Vazhentsev et al. (2023a) ; He et al. (2024a) . One such class of approach is so-called density-based uncertainty scores Lee et al. (2018) ; van Amersfoort et al. (2020) ; Kotelevskii et al. (2022) ; Yoo et al. (2022) . These methods use embeddings of instances obtained from the top layers of a classification model to fit the density of the training distribution in the latent space. The likelihood of the input data under this estimated distribution is then used for confidence estimation. This has been demonstrated to achieve excellent results in out-of-distribution detection tasks Podolskiy et al. (2021) , and proven to be useful for selective text classification Vazhentsev et al. (2022) ; Vazhentsev et al. (2023a) . Despite being computationally lightweight, these techniques often outperform more resource-intensive methods, such as deep ensembles Lakshminarayanan et al. (2017) and Monte Carlo dropout Gal and Ghahramani (2016) ; Tsymbalov et al. (2018) . Unfortunately, the reported performance of density-based scores for text generation so far has been notably low Vashurin et al. (2024) . Recent work has demonstrated that the internal states of LLMs carry a lot of information about their uncertainty Azaria and Mitchell (2023) ; Chen et al. (2024) ; He et al. (2024b) ; CH-Wang et al. (2024) ; Vazhentsev et al. (2024) . These techniques train a supplementary model on top of the activations of LLM internal layers. However, they often rely on simplistic features and fail to incorporate more advanced, well-established density-based UQ methods, limiting their ability to capture uncertainty. In this work, we address this gap by adapting density-based techniques for the UQ of LLMs and propose a new supervised method based on density-based features. Specifically, we adapt one of the most robust methods for UQ in the classification tasks, namely Mahalanobis Distance (MD; Lee et al. (2018) ), and train a linear regression on top of the MD scores from various layers of the LLM. These features are supplemented with a probability of the generated sequence. Figure 1 illustrates the scheme of the proposed supervised UQ method. Our extensive experimental evaluation demonstrates that the proposed method provides substantial improvement over the state of the art. Our key contributions are as follows. • We conduct a comprehensive investigation of density-based UQ methods for LLMs. While previous research Vashurin et al. (2024) has indicated that sequence-level density-based methods are ineffective, we propose a token-level adaptation of MD that is on par with or better than state-of-the-art UQ techniques. • We propose a new computationally efficient supervised method for UQ in LLMs using layer-wise density-based scores as features to improve uncertainty estimation without sacrificing the performance. • We conduct a vast empirical investigation that demonstrates the effectiveness of the proposed methods for sequence-level selective classification across eleven datasets and claim-level fact-checking. 2 Related Work Many effective UQ methods, such as deep ensembles ( Lakshminarayanan et al., 2017 ) and Monte Carlo (MC) dropout ( Gal and Ghahramani, 2016 ) , require sampling multiple predictions from a model, which leads to substantial computational and memory overheads. A key challenge in UQ is developing techniques that balance effectiveness with computational efficiency. Among the most promising approaches in this regard are density-based methods Lee et al. (2018) ; Liu et al. (2020) ; van Amersfoort et al. (2020) ; Kotelevskii et al. (2022) ; Yoo et al. (2022) . These methods leverage latent representations of instances to model the training data distribution, then estimate how likely a new instance belongs to that distribution. Lee et al. (2018) propose to use Mahalanobis Distance (MD) as a measure of uncertainty for out-of-distribution detection in computer vision

Read the complete text