Table of Contents
Fetching ...

Semantic Volume: Quantifying and Detecting both External and Internal Uncertainty in LLMs

Xiaomin Li, Zhou Yu, Ziji Zhang, Yingying Zhuang, Swair Shah, Narayanan Sadagopan, Anurag Beniwal

TL;DR

Semantic Volume introduces a unified, training-free measure to detect both external and internal uncertainty in LLMs by perturbing queries or responses, embedding them, and computing the dispersion via $\log \det(\tilde{\bm{V}}^\top \tilde{\bm{V}} + \epsilon\mathbf{I})$. The approach does not require access to model weights, works with external APIs, and naturally generalizes the prior semantic-entropy idea through a continuous dispersion metric linked to differential entropy under Gaussian assumptions. Empirically, Semantic Volume outperforms prompt-based, probability-based, and sampling-based baselines on external query ambiguity (CLAMBER, AmbigQA) and internal hallucination detection (TriviaQA, SQuAD), across multiple models and perturbation sizes (notably $n=20$). Theoretical results connect the measure to differential entropy and establish invariance under linear transformations, while ablation studies validate the roles of PCA dimensionality and perturbation count. Overall, Semantic Volume offers a robust, interpretable framework for improving LLM reliability in scenarios with both user-driven ambiguity and model-driven uncertainty, applicable to closed and open models alike.

Abstract

Large language models (LLMs) have demonstrated remarkable performance across diverse tasks by encoding vast amounts of factual knowledge. However, they are still prone to hallucinations, generating incorrect or misleading information, often accompanied by high uncertainty. Existing methods for hallucination detection primarily focus on quantifying internal uncertainty, which arises from missing or conflicting knowledge within the model. However, hallucinations can also stem from external uncertainty, where ambiguous user queries lead to multiple possible interpretations. In this work, we introduce Semantic Volume, a novel mathematical measure for quantifying both external and internal uncertainty in LLMs. Our approach perturbs queries and responses, embeds them in a semantic space, and computes the Gram matrix determinant of the embedding vectors, capturing their dispersion as a measure of uncertainty. Our framework provides a generalizable and unsupervised uncertainty detection method without requiring internal access to LLMs. We conduct extensive experiments on both external and internal uncertainty detections, demonstrating that our Semantic Volume method consistently outperforms existing baselines in both tasks. Additionally, we provide theoretical insights linking our measure to differential entropy, unifying and extending previous sampling-based uncertainty measures such as the semantic entropy. Semantic Volume is shown to be a robust and interpretable approach to improving the reliability of LLMs by systematically detecting uncertainty in both user queries and model responses.

Semantic Volume: Quantifying and Detecting both External and Internal Uncertainty in LLMs

TL;DR

Semantic Volume introduces a unified, training-free measure to detect both external and internal uncertainty in LLMs by perturbing queries or responses, embedding them, and computing the dispersion via . The approach does not require access to model weights, works with external APIs, and naturally generalizes the prior semantic-entropy idea through a continuous dispersion metric linked to differential entropy under Gaussian assumptions. Empirically, Semantic Volume outperforms prompt-based, probability-based, and sampling-based baselines on external query ambiguity (CLAMBER, AmbigQA) and internal hallucination detection (TriviaQA, SQuAD), across multiple models and perturbation sizes (notably ). Theoretical results connect the measure to differential entropy and establish invariance under linear transformations, while ablation studies validate the roles of PCA dimensionality and perturbation count. Overall, Semantic Volume offers a robust, interpretable framework for improving LLM reliability in scenarios with both user-driven ambiguity and model-driven uncertainty, applicable to closed and open models alike.

Abstract

Large language models (LLMs) have demonstrated remarkable performance across diverse tasks by encoding vast amounts of factual knowledge. However, they are still prone to hallucinations, generating incorrect or misleading information, often accompanied by high uncertainty. Existing methods for hallucination detection primarily focus on quantifying internal uncertainty, which arises from missing or conflicting knowledge within the model. However, hallucinations can also stem from external uncertainty, where ambiguous user queries lead to multiple possible interpretations. In this work, we introduce Semantic Volume, a novel mathematical measure for quantifying both external and internal uncertainty in LLMs. Our approach perturbs queries and responses, embeds them in a semantic space, and computes the Gram matrix determinant of the embedding vectors, capturing their dispersion as a measure of uncertainty. Our framework provides a generalizable and unsupervised uncertainty detection method without requiring internal access to LLMs. We conduct extensive experiments on both external and internal uncertainty detections, demonstrating that our Semantic Volume method consistently outperforms existing baselines in both tasks. Additionally, we provide theoretical insights linking our measure to differential entropy, unifying and extending previous sampling-based uncertainty measures such as the semantic entropy. Semantic Volume is shown to be a robust and interpretable approach to improving the reliability of LLMs by systematically detecting uncertainty in both user queries and model responses.

Paper Structure

This paper contains 43 sections, 6 theorems, 32 equations, 9 figures, 11 tables, 1 algorithm.

Key Result

Proposition 1

Denote $\mathcal{L} \in \mathcal{D}$ as a labeled subset with inputs $\{s_i\}$ and labels $\{y_i\}$: For each $s_i$, denotes its semantic volume as $m(s_i)$. Define a classification rule Then the optimal threshold $\tau$ that maximizes the $F_1$ score on $\mathcal{L}$ is given by Note that the $F_1$ score can be replaced by other metrics, such as the accuracy.

Figures (9)

  • Figure 1: Pipeline for external and internal uncertainty detection using semantic volume. Step 1. Generate perturbations. For external uncertainty, we augment each query using an LLM, treating the augmentations as perturbations. For internal uncertainty, perturbations refer to multiple sampled candidate responses. Step 2. Compute semantic volume (essentially $\log \det ({\bm{V}}^\top {\bm{V}})$ where columns of ${\bm{V}}$ are normalized embedding vectors). Step 3. Cases with high semantic volume are predicted as ambiguous queries (external uncertainty) or hallucinated responses (internal uncertainty).
  • Figure 2: Distribution of subsets for both labels across different uncertainty measures. Two-sample Kolmogorov–Smirnov statistics are computed to quantify the separation of two bulks.
  • Figure 3: Parallelogram for $n=2$ (left) and parallelepiped for $n=3$ (right)
  • Figure 4: Mahalanobis–chi-square Q–Q plots for four examples each of queries (top row) and responses (bottom row).
  • Figure 5: Distribution of $R^2$.
  • ...and 4 more figures

Theorems & Definitions (11)

  • Proposition 1: Formula for optimal threshold $\tau^*$
  • Theorem 1
  • Theorem 2
  • proof
  • Lemma 1: Invariance of semantic volume method under linear transformation
  • proof
  • Lemma 2: Differential entropy of Gaussian vectors
  • proof
  • Lemma 3: Eigenvalue distribution of rank-one perturbed matrix
  • proof
  • ...and 1 more