Uncertainty Calibration for Tool-Using Language Agents

Hao Liu, Zi-Yi Dou, Yixin Wang, Nanyun Peng, Yisong YueEMNLP 2024

Introduction

Large Language Models (LLMs) are increasingly deployed as autonomous agents capable of invoking external tools—such as calculators, code interpreters, and database search engines—to solve multi-step reasoning problems. However, a significant bottleneck in their reliability is the "confidence gap." Because LLMs are rarely trained in tandem with the specific tools they use, their internal confidence often fails to align with the actual success rate of tool interactions. This paper addresses this fundamental issue of miscalibration in tool-using agents.

The Problem: Miscalibration in Agentic Workflows

In standard text generation, researchers rely on a model's output probabilities (logits) to determine the best path. In agentic workflows, however, these probabilities are often poorly correlated with the actual "reward" or success of a tool call. The authors identify two critical failure points:

  1. Prompt Selection: The inability to choose the optimal system instructions to guide tool usage for a specific query.
  2. Trace Selection: The difficulty in identifying the most promising sequence of tool calls (an "execution trace") from multiple generated candidates.

When an agent is overconfident in a doomed execution path or picks a suboptimal prompt, the entire reasoning chain collapses.

PROBECAL: Probing for Calibration

The authors propose PROBECAL (Probing Calibration), a method that shifts the focus from the LLM's final output tokens to its internal representations.

The PROBECAL framework integrates a probing classifier to estimate the success probability of prompts and tool execution traces, guiding the language agent toward the most reliable path.

The Probing Approach

Instead of relying on potentially overconfident output logits, PROBECAL extracts the hidden embeddings from the LLM. The core idea is that these internal states contain rich, latent information about the model's own uncertainty that the final softmax layer might smooth over.

A lightweight, three-layer Multi-Layer Perceptron (MLP) is trained as a "probe" to predict a binary reward (1 for success, 0 for failure) based on these embeddings. This allows the system to estimate the expected reward for different prompts or execution traces before committing to a final answer.

Calibration Variants

PROBECAL is implemented in three primary configurations:

  • PROBECAL-PROMPT: Calibrates the selection between different system prompts.
  • PROBECAL-TRACE: Calibrates the selection of the best execution path among multiple candidates (e.g., choosing the correct Python script to solve a math problem).
  • PROBECAL-PROMPT&TRACE: A unified approach that optimizes both selection processes simultaneously.

Experimental Results

The framework was evaluated on two rigorous benchmarks: MATH (high-school competition mathematics) and TabMWP (math word problems requiring table reasoning). The MLP probes were trained using only 500 questions, highlighting the method's extreme data efficiency.

Performance comparison of PROBECAL variants against baseline methods in dynamic tool-using scenarios. PROBECAL-Prompt&Trace consistently achieves the highest accuracy and lowest calibration error.

Key Findings

  • Significant Accuracy Gains: On the TabMWP dataset, PROBECAL-Prompt&Trace improved accuracy by over 7% compared to strong baselines like TroVE.
  • Near-Perfect Calibration: The Expected Calibration Error (ECE), which measures the gap between predicted confidence and actual accuracy, dropped from a highly miscalibrated 0.690 to a near-perfect 0.035 on TabMWP.
  • Model Agnostic: The benefits of PROBECAL were consistent across various base models, including Llama-3-8B, Mistral-7B, and CodeLlama, proving it is a robust solution for diverse agentic architectures.

Conclusion and Future Work

PROBECAL demonstrates that the key to more reliable tool-using agents lies in better uncertainty estimation. By probing internal embeddings rather than relying on surface-level logits, agents can "know what they don't know" regarding external tool reliability.

While the current work focuses on known toolsets, future research will explore how this probing approach generalizes to "zero-shot" scenarios where agents encounter entirely new tools. Additionally, integrating these probes into real-time safety frameworks could help mitigate risks by flagging when an agent's internal state suggests a high likelihood of erratic or unintended tool behavior.

Summary updated

BibTeX
@inproceedings{liu2024uncertainty,
  author = {Hao Liu and Zi-Yi Dou and Yixin Wang and Nanyun Peng and Yisong Yue},
  title = {{Uncertainty Calibration for Tool-Using Language Agents}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.978},
}
Figure