UNCERTAINTY-LINE: Length-Invariant Estimation of Uncertainty for Large Language Models

Roman Vashurin, Maiya Goloburda, Preslav Nakov, Maxim Panov

Abstract

Uncertainty Quantification (UQ) is a critical component in deploying trustworthy Large Language Models (LLMs), allowing systems to abstain from answering when confidence is low. However, standard UQ metrics often suffer from "length bias," where the length of a generated sequence spuriously correlates with its uncertainty score. This paper introduces UNCERTAINTY-LINE (Length-INvariant Estimation), a post-hoc regression-based method designed to detrend uncertainty scores from output length. By treating the relationship between length and uncertainty as a regression problem, UNCERTAINTY-LINE significantly improves the reliability of selective prediction across various tasks, including translation, mathematical reasoning, and summarization.

Introduction

As LLMs are integrated into decision-making pipelines, the ability to quantify a model's confidence becomes paramount. Most existing UQ methods rely on the internal token probabilities of the model. However, in autoregressive generation, the total sequence probability is the product of individual token probabilities. Mathematically, as a sequence grows longer, its total probability naturally trends toward zero, and its log-probability becomes increasingly negative.

This creates a fundamental challenge: long, high-quality outputs may be flagged as high-uncertainty simply due to their length. While researchers have attempted to mitigate this using normalization techniques like Perplexity (PPL) or Mean Token Entropy (MTE), this study demonstrates that length bias persists even in these nominally normalized metrics. This spurious correlation hinders "selective prediction"—the practice of having a model abstain from answering when its confidence is low—by conflating verbosity with error.

The Problem: Persistent Length Bias

The core issue stems from the fact that standard normalization does not fully decouple uncertainty from sequence length. In many cases, metrics like Maximum Sequence Probability (MSP) show an increase in value as length increases, while PPL tends to decrease. This bias makes it difficult to set universal thresholds for model abstention. If a model is penalized for being thorough, the utility of the UQ metric is compromised, leading to higher false-positive rates in hallucination detection.

Methodology: UNCERTAINTY-LINE

The authors propose UNCERTAINTY-LINE, a simple yet effective post-hoc debiasing procedure. The method treats the relationship between a raw uncertainty score ($u$) and sequence length ($|y|$) as a regression problem. It offers two primary modes of operation:

1. Unsupervised Detrending

In tasks where the quality of the output is largely independent of its length (such as Machine Translation), the method fits a linear regression between the raw uncertainty scores and the sequence length. The "debiased" uncertainty score is defined as the residual—the portion of the uncertainty that cannot be explained by the length of the sequence. This effectively "flattens" the bias curve, ensuring that the uncertainty score reflects the model's actual confidence rather than the sequence's token count.

2. Supervised Detrending

In some domains, length is a legitimate proxy for quality. For example, in Mathematical Reasoning (GSM8K), longer proofs often contain more steps and thus more opportunities for error. Conversely, in Abstractive Summarization (XSum), longer summaries might capture more essential detail and thus be of higher quality. In these scenarios, the authors fit a second regression to model the meaningful quality-length trend. They then remove the spurious length bias while re-incorporating the task-relevant quality trend.

Because UNCERTAINTY-LINE is post-hoc, it requires no architectural changes or model retraining and can be applied to any existing UQ metric.

Experimental Setup

The researchers evaluated UNCERTAINTY-LINE across three distinct task types using state-of-the-art open models: Llama 3.1 8B, Gemma 2 9B, and EuroLLM 9B.

  • Machine Translation: Evaluated on WMT14 and WMT19 datasets across multiple language pairs.
  • Mathematical Reasoning: Evaluated on the GSM8K dataset.
  • Abstractive Summarization: Evaluated on the XSum dataset.

The primary evaluation metric was the Prediction-Rejection Ratio (PRR). PRR measures the effectiveness of an uncertainty score in ranking outputs by their actual quality, essentially testing how well the metric identifies which samples should be rejected to improve overall system accuracy.

Key Insights and Results

Normalization is Insufficient

The study found that standard length-normalized metrics like PPL and MTE still exhibit significant linear correlations with length. This suggests that the common practice of dividing by sequence length does not truly eliminate the underlying statistical bias inherent in autoregressive models.

Substantial Performance Gains

UNCERTAINTY-LINE consistently improved the reliability of uncertainty estimates. The most dramatic improvements were observed in metrics highly sensitive to length, such as MSP. On WMT datasets, detrending improved the PRR of MSP by an average of 0.09 to 0.18 points. The method successfully reduced the slope between corrected uncertainty scores and sequence length to near zero.

Efficiency and Generality

The supervised version of the method proved to be highly data-efficient. The quality-length trend could be accurately estimated with as few as 500 labeled examples. Furthermore, the benefits were consistent across all tested models (Llama, Gemma, and EuroLLM), indicating that length bias is a fundamental property of current UQ calculation methods rather than a specific model flaw.

Conclusion and Future Work

UNCERTAINTY-LINE provides a lightweight, effective solution to the persistent problem of length bias in LLM uncertainty quantification. By detrending scores through simple linear regression, practitioners can achieve more reliable selective prediction without the need for expensive retraining.

While the linear assumption proved robust for the tasks tested, the authors note that more complex, multi-step reasoning tasks might exhibit non-linear uncertainty patterns. Future research could explore addressing these biases during the training phase or investigating non-linear "phase-specific" uncertainty detrending for long-form generation.

Summary updated

BibTeX
@misc{vashurin2025uncertainty,
  author = {Roman Vashurin and Maiya Goloburda and Preslav Nakov and Maxim Panov},
  title = {{UNCERTAINTY-LINE: Length-Invariant Estimation of Uncertainty for Large Language Models}},
  year = {2025},
  eprint = {2505.19060},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.19060},
}
Figure