Abstract: Tool-using agents that act in the world need to be both useful and safe. Well-calibrated model confidences can be used to weigh the risk versus reward of potential actions, but prior work shows that many models are poorly calibrated. Inspired by interpretability literature exploring the internals of models, we propose a novel class of model-internal confidence estimators (MICE) to better assess confidence when calling tools. MICE first decodes from each intermediate layer of the language model using logit lens and then computes similarity scores between each layer’s generation and the final output. These features are fed into a learned probabilistic classifier to assess confidence in the decoded output. On the simulated trial and error (STE) tool-calling dataset using Llama3 models, we find that MICE beats or matches the baselines on smoothed expected calibration error. Using MICE confidences to determine whether to call a tool significantly improves over strong baselines on a new metric, expected tool-calling utility. Further experiments show that MICE is sample-efficient, can generalize zero-shot to unseen APIs, and results in higher tool-calling utility in scenarios with varying risk levels.
Introduction
Large Language Models (LLMs) are increasingly being used as "agents" that can execute code or call APIs. While a hallucination in a chat window is annoying, a hallucination in a tool call can be catastrophic—imagine an agent accidentally running a destructive command instead of a simple file operation. To prevent these disasters, agents need to be well-calibrated: if an agent reports 90% confidence in a tool call, it should be correct 90% of the time. Unfortunately, most LLMs are notoriously overconfident, and their raw token probabilities are often unreliable indicators of truth. This paper explores whether internal model signals can provide a more robust measure of certainty.
Methodology: The MICE Framework
We introduce MICE (Model-Internal Confidence Estimation), which treats confidence estimation as a supervised learning problem by analyzing the model's internal state during computation.
The MICE pipeline consists of three primary stages:
- Layer-wise Decoding: For every intermediate layer in the transformer, MICE uses the logit lens technique to "decode" what the model would have predicted if computation stopped at that layer.
- Feature Extraction: It calculates the BERTScore (a semantic similarity metric) between the output of each intermediate layer and the final output. This captures the trajectory of the model's internal computation.
- Probabilistic Classification: These similarity scores, along with raw token confidence, are fed into a simple classifier (e.g., Random Forest). This classifier is trained to predict the likelihood that a tool call is correct.
To evaluate these agents, we propose a new metric: Expected Tool-Calling Utility (ETCU). Unlike standard error metrics, ETCU accounts for the risk-reward trade-off of an action, penalizing dangerous mistakes more heavily than abstention.
Experimental Setup
Evaluation was performed using the Simulated Trial-and-Error (STE) dataset, which includes English-language queries requiring calls to 50 distinct APIs. We tested MICE on the Llama 3 family (8B, 8B-Instruct, and 3.2-3B-Instruct). The MICE classifier was trained on 1,500 examples and evaluated on a test set of 750 examples.
Results and Key Insights
MICE consistently outperformed baselines like raw confidence and standard recalibration techniques (HRE, NWKR) across all models.
- The Evolution of a Thought: A key insight is that correct predictions tend to stabilize early in the model's layers. If a model's internal prediction shifts drastically in the final layers, it is a strong signal of uncertainty. MICE captures this stability as a proxy for confidence.
- Risk Sensitivity: In high-risk scenarios (where a wrong move is significantly worse than doing nothing), MICE achieved significantly higher utility. While raw confidence often led to negative utility—meaning the agent caused more harm than good—MICE allowed for safe operation.
- Generalization: MICE generalizes to unseen APIs. When trained on 49 APIs and tested on a 50th, performance remained stable, suggesting it learns a general signal of uncertainty rather than specific API patterns.
- Sample Efficiency: MICE requires as few as 300 examples to outperform traditional baselines, making it practical for rapid deployment.
Limitations and Future Work
MICE requires access to a model's internal activations, which limits its use with closed-source "black box" APIs. Furthermore, decoding from every layer adds computational overhead, though this can be mitigated through parallelization. Future research will explore "tuned lenses" to improve intermediate decoding accuracy and test MICE on broader tasks like long-form generation.
Summary updated