Efficient semantic uncertainty quantification in language models via diversity-steered sampling

Ji Won Park, Kyunghyun Cho

Introduction

Estimating how uncertain a Large Language Model (LLM) is about a free-form answer usually requires generating dozens of expensive, often repetitive, samples. When we ask an LLM a question, we want to know if it is confident in its answer or just guessing. In free-form Question Answering (QA), measuring this is notoriously difficult because two completely different strings of text can mean the exact same thing (e.g., "The distance ladder method" vs. "Using Cepheid variable stars").

To quantify uncertainty, researchers often generate many answers, cluster them by meaning, and calculate "Semantic Entropy." If the model generates answers across many conflicting semantic clusters, it is highly uncertain. However, standard sampling methods tend to generate semantically redundant answers, wasting valuable compute. Existing workarounds either ignore semantics entirely (like simply cranking up the sampling temperature, which degrades text quality) or are restricted to specific model architectures.

This paper introduces a diversity-steered sampler that actively pushes the model to generate semantically unique answers during decoding, working for both standard autoregressive and newer masked diffusion models. By combining this on-the-fly steering with statistical bias correction, the method drastically improves the sample efficiency and accuracy of uncertainty estimates.

Methods: Diversity-Steered Sampling

The authors propose a plug-and-play sampling framework that actively discourages semantic redundancy without needing access to the LLM's internal gradients.

Overview of the diversity-steered sampling framework for both autoregressive and masked diffusion models.
  1. Diversity-Steered Sampling: During generation, the sampler modifies the model's token probabilities. It calculates a penalty based on how semantically similar the currently generating sequence is to previously generated sequences. If a new token pushes the sentence toward a meaning already seen, its probability is reduced.
  2. NLI for Partial Text: To penalize similarity during generation, the system needs to evaluate half-finished sentences. The authors lightly fine-tuned an off-the-shelf Natural Language Inference (NLI) model (DeBERTa) using special [TRUNC] (truncated) and [MASK] tokens. This allows the NLI model to accurately predict if a partial sentence will eventually entail a previous answer.
  3. Importance Reweighting & Control Variates: Because the sampler artificially forces the model away from its natural distribution, the raw outputs are biased. The authors use importance reweighting to mathematically correct this bias when calculating final uncertainty scores. They also apply control variates (using the base model's log probabilities) to keep the statistical variance of these estimates low.
  4. Cross-Paradigm Support: The method is designed to work for both standard Autoregressive Models (ARMs, which generate left-to-right) and Masked Diffusion Models (MDMs, which iteratively denoise text).

Key Insights and Results

The authors evaluated their method on four diverse QA benchmarks: CoQA (abstractive), TriviaQA (extractive), TruthfulQA (hallucination testing), and AmbigQA (ambiguous open-domain).

Partial text contains massive semantic signal: One of the most surprising findings is that an NLI model can accurately predict entailment long before a sentence is finished. Even when a hypothesis is heavily truncated or masked, the NLI model quickly converges on the correct semantic trajectory, making on-the-fly steering highly effective.

Entailment probability as a function of the percentage of tokens masked, demonstrating that partial text contains strong semantic signals even in diffusion models.

Superior Uncertainty Detection and Efficiency: Across the four datasets, the diversity-steered sampler matched or surpassed baselines (Vanilla sampling, Temperature scaling, Diverse Beam Search, and SDLG) in AUROC for Semantic Entropy. The uncertainty scores generated by this method correlate much better with whether the model's answer is actually correct. Furthermore, the method discovered significantly more unique semantic clusters using the exact same number of samples ($N=16$) compared to baselines, proving it wastes far less compute on redundant answers.

Broad Compatibility: The framework successfully improved uncertainty estimation across a range of models, including OPT (6.7B, 13B), LLaMA 3 8B-Instruct (autoregressive), and LLaDA 8B-Instruct (masked diffusion). This provides one of the first unified frameworks that brings semantic uncertainty quantification to the diffusion paradigm.

Limitations and Future Work

While highly effective, the method has some trade-offs. Because it relies on checking current generations against previous ones, it forces sequential sampling. This limits the ability to generate all $N$ samples perfectly in parallel, trading parallel throughput for better exploration. Additionally, the accuracy of the semantic clustering and steering is entirely dependent on the NLI model; if the NLI model makes a mistake or is noisy, the downstream uncertainty estimates will suffer.

Future directions include marginalizing over paraphrased prompts to make uncertainty estimates robust to how a question is worded, and integrating this logit-repulsion technique directly into Reinforcement Learning (RL) fine-tuning pipelines like PPO.

Summary updated

BibTeX
@inproceedings{park2025efficient,
  author = {Ji Won Park and Kyunghyun Cho},
  title = {{Efficient semantic uncertainty quantification in language models via diversity-steered sampling}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=IiEtQPGVyV},
}
Figure