Variational Uncertainty Decomposition for In-Context Learning

I. Shavindra Jayasekera, Jacob Si, Filippo Valdettaro, Wenlong Chen, Aldo A. Faisal, Yingzhen Li

Introduction

As Large Language Models (LLMs) increasingly perform complex prediction tasks via In-Context Learning (ICL), understanding why a model is uncertain becomes critical for reliability. Typically, an LLM provides a "total uncertainty" score. However, this single metric fails to distinguish between a prompt that is inherently ambiguous (aleatoric uncertainty) and a prompt the model simply hasn't seen enough examples to understand (epistemic uncertainty).

In traditional Bayesian machine learning, these uncertainties are decomposed by sampling from a posterior distribution of model parameters. For LLMs, the task "parameters" are implicit and hidden within billions of weights, making standard Bayesian methods computationally intractable. To bridge this gap, researchers have introduced the Variational Uncertainty Decomposition (VUD) framework. This method provides a mathematically grounded way to peek under the hood of ICL uncertainty without needing to retrain or heavily sample the model's parameters.

The Variational Uncertainty Decomposition (VUD) Framework

The core innovation of VUD is the use of auxiliary queries ($Z$) and their "fantasized" answers ($U$) as probes to estimate uncertainty bounds.

  1. The "Fantasy" Mechanism: The model is asked to imagine potential answers to auxiliary questions related to the main task. If knowing the answer to these "fantasies" significantly reduces the model's uncertainty on the original test point, that original uncertainty was likely epistemic (reducible with more data).
  2. Variational Bound: The authors mathematically prove that the average entropy of the model's prediction, after conditioning on these auxiliary probes, provides an upper bound on the true aleatoric uncertainty.
  3. Promoting Exchangeability: Because LLMs are sensitive to the order of examples in a prompt—violating the "exchangeability" assumption required for Bayesian logic—the authors mitigate this by shuffling the context examples and ensembling the results.
  4. KL Filtering: To ensure the auxiliary queries are helpful and adhere to Bayesian principles, the framework filters out queries that cause the model's predictive distribution to drift too far from its original state.
The VUD Framework: From choosing auxiliary queries to computing the final decomposed uncertainty.

Experimental Setup and Datasets

The authors validated VUD across a spectrum of complexity using models like Qwen2.5 (7B/14B) and Llama-3.1 (8B):

  • Synthetic Tasks: 1D Linear and Logistic regressions, the "Two-Moons" classification dataset, and a complex "Spirals" dataset. These environments allow for clear visualization of where uncertainty "should" be.
  • Real-World QA: Binary and multiclass classification using datasets such as BoolQA (reading comprehension), HotpotQA (complex reasoning), PubMedQA (biomedical), and MMLU (massive multi-task language understanding).

Key Insights and Results

Spatial Awareness of Uncertainty

VUD demonstrates that epistemic uncertainty behaves exactly as a Bayesian model would expect: it is lowest near the provided in-context examples and grows as the test input moves into "uncharted territory." Aleatoric uncertainty, meanwhile, correctly spikes at the decision boundaries where classes overlap.

Uncertainty decomposition on the Two-Moons dataset. Aleatoric uncertainty (center) pinpoints the boundary, while epistemic (right) highlights areas far from data points.

The Power of Perturbation and Information Gain

When choosing auxiliary queries ($Z$), simply "perturbing" the original test input (e.g., adding slight noise or rephrasing the question) proved to be a highly effective and scalable way to probe the model's internal logic. Furthermore, the gap between total uncertainty and the aleatoric bound represents the "expected information gain." This metric quantifies exactly how much the model's performance would improve if provided with more data for that specific type of query.

Improved Performance in High-Stakes Tasks

  • Better "Abstention": In high-stakes QA (like PubMedQA), models should abstain from answering if they are confused. Using the decomposed aleatoric uncertainty as a threshold for abstention led to higher accuracy on the remaining questions compared to using total uncertainty. For example, on PubMedQA, filtering by aleatoric uncertainty reached 90.00% accuracy, versus 88.89% for total uncertainty.
  • Smarter Bandits: In reinforcement learning "bandit" tasks, using epistemic variance to guide exploration resulted in much lower "regret" (better performance) than using total variance. The model successfully focuses on exploring what it doesn't know, rather than getting distracted by inherent noise.

Limitations and Future Work

While VUD offers a robust step forward, it comes with computational overhead, requiring multiple LLM calls per prediction to handle shuffling and auxiliary probes. Additionally, the method currently excels on tasks with discrete labels or numbers. For open-ended natural language generation, integrating "semantic uncertainty" methods—which recognize when two differently phrased sentences share the same meaning—will be a crucial next step. Finally, while the results strongly align with Bayesian properties, LLMs are only "approximately" Bayesian, making the KL filtering step a necessary patch for this approximation.

Summary updated

BibTeX
@inproceedings{jayasekera2025variational,
  author = {I. Shavindra Jayasekera and Jacob Si and Filippo Valdettaro and Wenlong Chen and Aldo A. Faisal and Yingzhen Li},
  title = {{Variational Uncertainty Decomposition for In-Context Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=MqGZIJxZ1z},
}
Figure