LUQ: Long-text Uncertainty Quantification for LLMs

Caiqi Zhang, Fangyu Liu, Marco Basaldella, Nigel Collier

Introduction

Large Language Models (LLMs) frequently generate "hallucinations"—outputs that are linguistically fluent but factually incorrect. Detecting these errors through Uncertainty Quantification (UQ) is critical for building trustworthy AI systems. However, traditional UQ methods are often optimized for short, single-token responses and struggle with the complexity of long-form content. This paper introduces LUQ (Long-text Uncertainty Quantification), a framework designed to estimate model certainty in long-form generations by shifting the focus from passage-level similarity to sentence-level consistency.

The Challenge of Long-Form Uncertainty

Existing UQ research faces two primary hurdles when applied to real-world long-form tasks like biography generation or medical explanations:

  1. Logit Access: Many state-of-the-art models (e.g., GPT-4, Gemini) are closed-source. Traditional UQ methods that rely on internal probability distributions (logits) are inapplicable to these models.
  2. Length Dilution: Standard metrics often rely on lexical similarity (word overlap) between multiple model outputs. In long texts, two responses might share 90% of their vocabulary but disagree on a single critical fact, such as a date or a location. Traditional metrics often fail to capture these high-stakes factual discrepancies.

The LUQ Framework

LUQ is a sampling-based approach that operates without requiring internal model access. The framework follows a multi-step workflow to determine how "sure" a model is about its claims:

  • Stochastic Sampling: The model generates $n$ independent responses for the same prompt.
  • Sentence-Level Granularity: Rather than comparing entire passages, LUQ decomposes responses into individual sentences. The core insight is that uncertainty in long-form text is not a monolithic property of the document, but a sum of uncertainties across specific claims.
  • NLI-based Scoring: LUQ employs a Natural Language Inference (NLI) classifier—specifically a fine-tuned DeBERTa-v3-large—to check for consistency. It determines if a sentence in one response is supported (entailed) or contradicted by the other sampled responses.
  • Uncertainty Calculation: High consistency across samples indicates low uncertainty, while conflicting facts across samples signal high uncertainty.

Specialized Variations

The researchers developed two advanced versions of the framework:

  • LUQ-ATOMIC: Uses an LLM to break sentences into "atomic facts" before consistency checking, allowing for granular error detection.
  • LUQ-PAIR: Computes entailment scores for every sentence pair between two responses to maximize the sensitivity of the metric.

Experimental Setup

The framework was evaluated using two primary benchmarks:

  • FACTSCORE-BIO: A dataset of 500 biographies from Wikidata used to measure factual precision.
  • FACTSCORE-DIS: A new dataset introduced in this study focusing on 180 disease entities to test how UQ generalizes to specialized medical knowledge.

Key Insights and Results

Superior Factuality Correlation

LUQ demonstrated a significantly stronger negative correlation with factuality scores compared to baselines like LexSim or SelfCheckNLI. For Gemini Pro, LUQ achieved a Pearson coefficient of -0.851, indicating that the metric is a highly reliable proxy for actual factual accuracy.

The Popularity Effect and Model Behavior

The study found a clear correlation between "entity frequency" and model certainty. LLMs are notably more certain—and more accurate—regarding common topics (e.g., George Washington) than obscure historical figures. Additionally, the researchers observed that GPT-4 exhibits a form of "self-awareness," often choosing to abstain from answering when it is uncertain, which results in more tightly clustered uncertainty scores compared to models that confidently hallucinate.

Practical Applications: Ensembling and Selective Answering

LUQ enables two powerful strategies for improving LLM reliability:

  • LUQ-ENSEMBLE: By generating responses from multiple models (e.g., Tulu-2-70B, Gemini 1.0 Pro, and Vicuna-33B) and selecting the output with the lowest LUQ uncertainty score, the researchers improved overall factuality by 5% over the best standalone model.
  • Selective Answering: By setting an uncertainty threshold and allowing the model to "refuse" to answer the most uncertain 15% of queries, the factuality of the remaining responses improved by over 5%.

Limitations and Future Work

While LUQ represents a significant step forward, it focuses primarily on factuality rather than stylistic quality or coherence. Furthermore, the computational cost of generating multiple samples and running NLI checks for every sentence remains high. Future research will focus on increasing the efficiency of these computations and investigating why models internalize non-factual data during the pre-training phase.

Summary updated

BibTeX
@inproceedings{zhang2024luq,
  author = {Caiqi Zhang and Fangyu Liu and Marco Basaldella and Nigel Collier},
  title = {{LUQ: Long-text Uncertainty Quantification for LLMs}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.299},
}
Figure