Uncertainty Quantification for In-Context Learning of Large Language Models

Chen Ling, Xujiang Zhao, Xuchao Zhang, Wei Cheng, Yanchi Liu, Yiyou Sun, Mika Oishi, Takao Osaki, Katsushi Matsuda, Jie Ji, Guangji Bai, Liang Zhao, Haifeng Chen

Large Language Models (LLMs) have revolutionized natural language processing through In-Context Learning (ICL). This paradigm allows models to perform new tasks by simply prepending a few demonstrations to the input prompt, bypassing the need for traditional gradient-based fine-tuning. However, despite their versatility, LLMs often act as "black boxes" regarding their internal confidence. When a model produces an incorrect answer or a hallucination, it is often unclear whether the error stems from poor prompt quality or inherent limitations in the model's knowledge.

The Challenge of Uncertainty in ICL

Existing methods for uncertainty quantification (UQ) typically provide a single scalar value, such as entropy, to represent a model's confidence. While useful, these aggregate scores fail to distinguish between different sources of "confusion." In the context of ICL, uncertainty is multifaceted. A model might be uncertain because the provided examples are contradictory (data noise) or because the task itself is outside its training distribution (model noise).

Illustration of In-Context Learning (ICL) where different decoding strategies and parameter settings lead to varying predictions and correctness.

As shown in the figure above, even with the same prompt, varying decoding strategies like Beam Search, Greedy decoding, or Top-K sampling can lead to different predictions and levels of correctness. This variability underscores the importance of a robust framework to diagnose the root cause of model uncertainty.

Proposed Framework: Decomposing Uncertainty

A new paper from researchers at Emory University, NEC Labs, and Microsoft, titled "Uncertainty Quantification for In-Context Learning of Large Language Models," provides a novel Bayesian framework to decompose predictive uncertainty into two distinct categories:

  1. Aleatoric Uncertainty (AU): This represents "data" noise. In ICL, AU is primarily driven by the quality, relevance, and ambiguity of the few-shot demonstrations provided in the prompt.
  2. Epistemic Uncertainty (EU): This represents "model" noise. It relates to the model’s internal parameters and its inherent ability (or inability) to handle a specific task.

The authors treat ICL as a process where the model maps a prompt to a "latent concept." By utilizing an unsupervised, entropy-based decomposition, they can quantify these uncertainties without retraining the model.

The mathematical decomposition of Total Uncertainty into Epistemic and Aleatoric components.

The decomposition follows a clear logic: Total Uncertainty is measured by the entropy of the predictive distribution. Epistemic Uncertainty is calculated as the expected entropy across different sets of demonstrations, representing the model's baseline confusion. Aleatoric Uncertainty is then derived as the difference between the two, effectively capturing the mutual information between the prediction and the specific context provided.

Experimental Evaluation and Key Findings

The framework was rigorously tested using open-source models including LLaMA-2 (7B, 13B, 70B) and OPT-13B across several Natural Language Understanding (NLU) tasks such as sentiment analysis, linguistic acceptability, and topic classification.

Key insights from the study include:

  • EU as a Diagnostic Tool: Epistemic Uncertainty proved to be a superior predictor for misclassification detection. It consistently outperformed traditional metrics like total entropy in identifying when a model was likely to make a mistake.
  • AU and Prompt Sensitivity: Aleatoric Uncertainty is highly sensitive to the quality of demonstrations. When irrelevant or "Out-of-Domain" (OOD) examples were used, AU spiked significantly, while EU remained relatively stable.
  • Impact of Model Scale: As model size increases, both types of uncertainty generally decrease. However, the 70B model's EU becomes a much more precise indicator of whether a task is truly beyond the model's capabilities.
  • Optimization via Class Sampling: The study confirmed that "Class Sampling"—ensuring the prompt includes at least one example for every possible label—drastically reduces uncertainty and boosts accuracy compared to random sampling.

Conclusion

By providing a "plug-and-play" method to decompose uncertainty, this research offers a powerful diagnostic tool for LLM practitioners. It allows for a clearer understanding of whether a failure is a "prompting problem" or a "model problem." While currently optimized for classification and short-answer tasks, this framework represents a significant step toward making LLMs more transparent and reliable in real-world applications.

Summary updated

BibTeX
@inproceedings{ling2024uncertainty,
  author = {Chen Ling and Xujiang Zhao and Xuchao Zhang and Wei Cheng and Yanchi Liu and Yiyou Sun and Mika Oishi and Takao Osaki and Katsushi Matsuda and Jie Ji and Guangji Bai and Liang Zhao and Haifeng Chen},
  title = {{Uncertainty Quantification for In-Context Learning of Large Language Models}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.naacl-long.184},
}
Figure