On the Importance of Uncertainty in Decision-Making with Large Language Models

Nicolò Felicioni, Lucas Maystre, Sina Ghiassian, Kamil Ciosek

Abstract

We investigate the role of uncertainty in decision-making problems with natural language as input. For such tasks, using Large Language Models as agents has become the norm. However, none of the recent approaches employ any additional phase for estimating the uncertainty the agent has about the world during the decision-making task. We focus on a fundamental decision-making framework with natural language as input, which is the one of contextual bandits, where the context information consists of text. As a representative of the approaches with no uncertainty estimation, we consider an LLM agent with a greedy policy, which picks the action corresponding to the largest predicted reward. We compare this baseline to LLM agents that make active use of uncertainty estimation by integrating the uncertainty in a Thompson Sampling policy. We employ different techniques for uncertainty estimation, such as Laplace Approximation, Dropout, and Epinets. We empirically show on real-world data that the greedy policy performs worse than the Thompson Sampling policies. These findings suggest that, while overlooked in the LLM literature, uncertainty improves performance on bandit tasks with LLM agents.

Introduction

In recent years, Large Language Models (LLMs) have been increasingly deployed as agents in decision-making frameworks, such as automated content moderation or recommendation systems. Usually, these models are fine-tuned to predict a "reward" (e.g., the likelihood a comment is toxic) and then used greedily: the agent simply picks the action with the highest predicted reward.

However, this "greedy" status quo ignores the model's own ignorance. If a model is uncertain about a specific type of input because it hasn't seen enough similar data, a greedy policy might prematurely dismiss a potentially high-reward action or repeatedly take a "safe" but sub-optimal one. This is a classic problem in contextual bandits—a framework where an agent must choose actions based on a context (in this case, text) to maximize rewards over time. This research bridges the gap by introducing principled uncertainty estimation to the LLM-as-agent literature.

Methods

The researchers treat the LLM as a feature extractor with a linear regression head to predict rewards. To move beyond greedy selection, they implement Thompson Sampling (TS), a Bayesian algorithm that selects actions based on samples from a posterior distribution of the model's parameters.

Since calculating an exact posterior for a massive neural network is computationally impossible, four scalable uncertainty estimation techniques were adapted:

  • Dropout: Using dropout during the decision-making phase to simulate sampling from different model versions.
  • Diagonal Laplace Approximation (Diag. LA): A Bayesian method that approximates the parameter distribution as a Gaussian using the diagonal of the Hessian matrix.
  • Last-Layer Laplace Approximation (Last LA): Computing a full, high-quality uncertainty estimate specifically for the final linear layer of the model.
  • Epinets: A small, auxiliary "epistemic neural network" trained alongside the LLM to estimate the uncertainty of the base model's predictions.

Experimental Setup

The agents were evaluated on four real-world text classification tasks adapted into bandit problems: Measuring Hate Speech, IMDb sentiment, Offensive Language Identification, and HatEval. In these tasks, the "reward" was asymmetric; for example, publishing a non-toxic comment gave a high reward, while publishing a toxic one resulted in a heavy penalty.

Key Results

Across all datasets, Thompson Sampling policies significantly outperformed the greedy baseline in terms of "average regret" (the difference between the agent's performance and the theoretical optimal).

Average regret over time for different uncertainty estimation methods compared to a greedy baseline.

Last-Layer LA and Epinets emerged as the strongest methods. While Last-Layer LA provided the best results, Epinets offered a more computationally efficient alternative with only a slight dip in performance. These findings held true even when scaling from a 124M parameter model (GPT-2) to a 1.5B parameter model (GPT-2 XL), proving that uncertainty-aware decision-making remains vital as models grow.

Key Insights

  • The "Greedy Trap": Greedy policies often suffer from "under-exploration." If the model initially underestimates a "risky" action, it may never try it again, incurring constant regret. Thompson Sampling forces the model to explore actions it is uncertain about.
  • Pre-training is Essential: Models trained from scratch failed to learn the bandit tasks effectively. The knowledge baked into the LLM during pre-training is essential for the model to understand the context well enough to begin exploring rewards.
  • Last-Layer vs. Full Model: Focusing uncertainty estimation on just the last layer (Last LA) was often the most effective strategy. This suggests that the primary uncertainty lies in how extracted features map to rewards, rather than the feature extraction itself.

Conclusion

While uncertainty estimation adds computational overhead compared to a simple greedy pass, the reduction in regret is substantial. Future research should investigate these uncertainty methods in full Reinforcement Learning (RL) environments where actions affect future contexts, and explore how these techniques scale to frontier models with 70B+ parameters.

Summary updated

BibTeX
@article{felicioni2024importance,
  author = {Nicolò Felicioni and Lucas Maystre and Sina Ghiassian and Kamil Ciosek},
  title = {{On the Importance of Uncertainty in Decision-Making with Large Language Models}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=YfPzUX6DdO},
}
Figure