Table of Contents
Fetching ...

Kernel Language Entropy: Fine-grained Uncertainty Quantification for LLMs from Semantic Similarities

Alexander Nikitin, Jannik Kossen, Yarin Gal, Pekka Marttinen

TL;DR

Kernel Language Entropy (KLE) introduces a kernel-based framework for fine-grained semantic uncertainty quantification in LLM outputs by encoding semantic similarity with unit-trace PSD kernels and measuring uncertainty via the von Neumann entropy. By leveraging semantic graphs and graph kernels, KLE captures distance-aware relationships between generated texts or semantic clusters, generalizing the prior semantic entropy (SE) approach and enabling robust uncertainty estimates in both white-box and black-box settings. The method is validated across 60 model–dataset scenarios and multiple LLM families, achieving state-of-the-art performance in uncertainty quantification and offering practical hyperparameter strategies via entropy convergence plots. The work advances safe deployment of LLMs by providing a principled, scalable mechanism to detect and manage hallucinations through semantic uncertainty.

Abstract

Uncertainty quantification in Large Language Models (LLMs) is crucial for applications where safety and reliability are important. In particular, uncertainty can be used to improve the trustworthiness of LLMs by detecting factually incorrect model responses, commonly called hallucinations. Critically, one should seek to capture the model's semantic uncertainty, i.e., the uncertainty over the meanings of LLM outputs, rather than uncertainty over lexical or syntactic variations that do not affect answer correctness. To address this problem, we propose Kernel Language Entropy (KLE), a novel method for uncertainty estimation in white- and black-box LLMs. KLE defines positive semidefinite unit trace kernels to encode the semantic similarities of LLM outputs and quantifies uncertainty using the von Neumann entropy. It considers pairwise semantic dependencies between answers (or semantic clusters), providing more fine-grained uncertainty estimates than previous methods based on hard clustering of answers. We theoretically prove that KLE generalizes the previous state-of-the-art method called semantic entropy and empirically demonstrate that it improves uncertainty quantification performance across multiple natural language generation datasets and LLM architectures.

Kernel Language Entropy: Fine-grained Uncertainty Quantification for LLMs from Semantic Similarities

TL;DR

Kernel Language Entropy (KLE) introduces a kernel-based framework for fine-grained semantic uncertainty quantification in LLM outputs by encoding semantic similarity with unit-trace PSD kernels and measuring uncertainty via the von Neumann entropy. By leveraging semantic graphs and graph kernels, KLE captures distance-aware relationships between generated texts or semantic clusters, generalizing the prior semantic entropy (SE) approach and enabling robust uncertainty estimates in both white-box and black-box settings. The method is validated across 60 model–dataset scenarios and multiple LLM families, achieving state-of-the-art performance in uncertainty quantification and offering practical hyperparameter strategies via entropy convergence plots. The work advances safe deployment of LLMs by providing a principled, scalable mechanism to detect and manage hallucinations through semantic uncertainty.

Abstract

Uncertainty quantification in Large Language Models (LLMs) is crucial for applications where safety and reliability are important. In particular, uncertainty can be used to improve the trustworthiness of LLMs by detecting factually incorrect model responses, commonly called hallucinations. Critically, one should seek to capture the model's semantic uncertainty, i.e., the uncertainty over the meanings of LLM outputs, rather than uncertainty over lexical or syntactic variations that do not affect answer correctness. To address this problem, we propose Kernel Language Entropy (KLE), a novel method for uncertainty estimation in white- and black-box LLMs. KLE defines positive semidefinite unit trace kernels to encode the semantic similarities of LLM outputs and quantifies uncertainty using the von Neumann entropy. It considers pairwise semantic dependencies between answers (or semantic clusters), providing more fine-grained uncertainty estimates than previous methods based on hard clustering of answers. We theoretically prove that KLE generalizes the previous state-of-the-art method called semantic entropy and empirically demonstrate that it improves uncertainty quantification performance across multiple natural language generation datasets and LLM architectures.
Paper Structure (29 sections, 6 theorems, 14 equations, 14 figures, 2 tables, 1 algorithm)

This paper contains 29 sections, 6 theorems, 14 equations, 14 figures, 2 tables, 1 algorithm.

Key Result

Proposition 3.4

The VNE of a unit trace positive semidefinite kernel has the following properties:

Figures (14)

  • Figure 1: Illustration of Kernel Language Entropy (KLE). We here show a version of KLE called $\operatorname{KLE-c}$, which operates on semantic clusters. Given an input query and two different LLMs, we sample 10 answers from each model $a_1, \ldots, a_{10}$ and $a^{\prime}_1, \ldots, a^{\prime}_{10}$ and cluster them by semantic equivalence into clusters $C_1, \ldots, C_3$ and $C^{\prime}_1, \ldots, C^{\prime}_3$. For the sake of the example, we assume that the numbers and sizes of clusters, as well as individual cluster probabilities, are all equal $p(C_i|\text{inp}) = p(C_i^{\prime} | \text{inp})$ for all $i$. Then, semantic entropy would yield identical uncertainties for both LLMs. However, uncertainty should be lower for $\operatorname{LLM_2}$ because semantic "similarity" between the generations is much higher; i.e., the model is fairly confident that "Kolmogorov" and "Laplace" are good answers. KLE, explicitly accounts for the semantic similarity between texts using a kernel-based approach and correctly identifies that $\operatorname{LLM_2}$'s generations should be assigned lower uncertainty (see right).
  • Figure 2: Entropy Convergence Plots for heat kernels. For graphs of various sizes $|V|$, we grow the number of edges and examine the VNE. For large lengthscales $t$, corresponding to darker colored curves, the VNE quickly converges to zero. We can use these plots to determine kernel hyperparameters without validation sets. The VNE is scaled to start at 1 for visualization purposes.
  • Figure 3: Summary of 60 experimental scenarios. Each cell contains the fraction of experiments where a method from a row outperforms a method from a column. Our methods are labeled $\operatorname{KLE}(\cdot)$. Values larger than or equal to $0.62$ correspond to the significance level $p<0.05$ according to the binomial statistical significance test.
  • Figure 4: Comparison of various design choices for semantic graph kernels. represents the best hyperparameters and -- defaults. Error bars are twice the standard error. Summary of 48 experiments.
  • Figure : Kernel Language Entropy
  • ...and 9 more figures

Theorems & Definitions (17)

  • Definition 2.1
  • Definition 2.2
  • Definition 3.1
  • Definition 3.2: Von Neumann Entropy
  • Definition 3.3: Kernel Language Entropy
  • Proposition 3.4: Properties of the von Neumann Entropy bengtsson2017geometry
  • Theorem 3.5: KLE and KLE-c generalize SE
  • proof : Proof Sketch
  • Definition A.1
  • Lemma A.2
  • ...and 7 more