NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Uncovering Uncertainty in Transformer Inference

Greyson Brothers, Willa M. Mannering, John Winder, Amber Tien · DOI

Introduction

Large Language Models (LLMs) frequently exhibit "hallucinations," where they generate false information with high confidence. Distinguishing between instances where a model is certain of its output versus when it is merely selecting a statistically probable but incorrect token remains a critical challenge for AI safety and interpretability. This research investigates the internal dynamics of Transformers to identify signals of uncertainty during the inference process.

The Iterative Inference Hypothesis

The core of this study is the Iterative Inference Hypothesis (IIH). Rather than generating a token in a single computational step, the hypothesis suggests that a Transformer progressively refines a token's representation as it passes through successive layers of the residual stream. This process can be viewed as an optimization trajectory where each layer contributes to narrowing down the final prediction.

Iterative refinement of token predictions across layers.

Methodology: Peeking into the Residual Stream

To test the IIH, researchers analyzed GPT-2 XL (a 48-layer model) using two primary techniques:

  1. The Logit Lens: This method involves applying the model's final output head to intermediate representations at every layer. This allows researchers to observe the "proto-predictions" the model would make if inference were halted prematurely.
  2. Residual Cross-Entropy: This metric measures the "surprise" or distance between intermediate predictions and the final output token. A rapid, stable decline in cross-entropy indicates early convergence and high certainty. Conversely, persistent or fluctuating high cross-entropy suggests the model is struggling to stabilize its representation.

The researchers primarily utilized the EPIE Dataset, which contains 330 English idioms (e.g., "Great minds think [alike]"). Idioms provide a controlled environment with clear ground-truth completions. They also evaluated open-ended factual generation regarding Alan Turing to observe real-world hallucination patterns.

Empirical Findings

The findings provide strong empirical support for the IIH. Correct token predictions typically show a steady decrease in loss across layers, particularly in the middle-to-late stages (layers 20–38).

Final cross-entropy distribution and ROC curve for predicting token correctness.

The "Output Cross-Entropy" metric proved to be a highly effective predictor of token correctness. On the idiom dataset, it achieved an Area Under the Curve (AUC) of 0.92, demonstrating a clear separation between correct and incorrect internal states. In open-ended generation tasks, factual errors were consistently preceded by significant spikes in cross-entropy, whereas predictable, factual tokens maintained near-zero levels.

Discussion and Limitations

While promising, the metric faces the "confidently incorrect" problem: if a model stabilizes early on a false fact, the cross-entropy may remain low, failing to flag the error. Additionally, while GPT-2 XL serves as a foundational architecture, future work must determine if these patterns hold in modern, larger-scale models like Llama 3. Extending this single-token analysis to measure cumulative uncertainty across entire paragraphs is essential for developing robust hallucination filters.

Summary updated

BibTeX
@misc{brothers2024uncovering,
  author = {Greyson Brothers and Willa M. Mannering and John Winder and Amber Tien},
  title = {{Uncovering Uncertainty in Transformer Inference}},
  year = {2024},
  eprint = {2412.05768},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.05768},
}
Figure