By Sagar Shankaran, Founder of CallSphere
Understand what LLM calibration means, how to measure it with calibration curves, and practical techniques like temperature scaling and verbalized confidence to build agents that know when they do not know.
Key takeaways
An LLM is well-calibrated when its expressed confidence matches its actual accuracy. If a model says it is 90% confident in an answer, that answer should be correct roughly 90% of the time. Poorly calibrated models are dangerous in agentic systems because they either overstate confidence — leading agents to take incorrect actions — or understate it — causing unnecessary escalations and human-in-the-loop bottlenecks.
For agent developers, calibration directly impacts two critical decisions: when to act autonomously and when to ask for help.
A calibration curve plots predicted confidence against observed accuracy. A perfectly calibrated model produces a diagonal line where predicted probability equals actual correctness. Most LLMs deviate significantly from this ideal.
flowchart LR
USERS(["Traffic"])
LB["Geo LB plus<br/>Anycast"]
EDGE["Edge cache plus<br/>rate limit"]
APP["Stateless app pods<br/>HPA on QPS"]
QUEUE[(Async work queue)]
WORKER["Worker pool<br/>GPU or CPU"]
CACHE[("Redis cache<br/>LLM responses")]
DB[("Read replicas<br/>and primary")]
OBS[(Observability)]
USERS --> LB --> EDGE --> APP
APP --> CACHE
APP --> QUEUE --> WORKER
APP --> DB
APP --> OBS
style LB fill:#4f46e5,stroke:#4338ca,color:#fff
style WORKER fill:#ede9fe,stroke:#7c3aed,color:#1e1b4b
style CACHE fill:#f59e0b,stroke:#d97706,color:#1f2937
style OBS fill:#0ea5e9,stroke:#0369a1,color:#fff
import numpy as np
from sklearn.calibration import calibration_curve
import matplotlib.pyplot as plt
def evaluate_calibration(
predictions: list[dict], # [{"confidence": 0.9, "correct": True}, ...]
) -> dict:
"""Compute calibration metrics from model predictions."""
confidences = np.array([p["confidence"] for p in predictions])
accuracies = np.array([p["correct"] for p in predictions])
# Compute calibration curve
prob_true, prob_pred = calibration_curve(
accuracies, confidences, n_bins=10, strategy="uniform"
)
# Expected Calibration Error (ECE)
bin_sizes = np.histogram(confidences, bins=10, range=(0, 1))[0]
bin_weights = bin_sizes / len(confidences)
ece = np.sum(bin_weights * np.abs(prob_true - prob_pred))
return {
"ece": float(ece),
"prob_true": prob_true.tolist(),
"prob_pred": prob_pred.tolist(),
"mean_confidence": float(confidences.mean()),
"mean_accuracy": float(accuracies.mean()),
}
The Expected Calibration Error (ECE) summarizes miscalibration as a single number. An ECE of 0 means perfect calibration. Most production LLMs have ECE values between 0.05 and 0.20, meaning their confidence is off by 5-20 percentage points on average.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
Temperature scaling is the simplest and most effective post-hoc calibration technique. It applies a single learned parameter (temperature T) to the model's output logits to bring confidence estimates in line with actual accuracy:
from scipy.optimize import minimize_scalar
from scipy.special import softmax
def find_optimal_temperature(
logits: np.ndarray, labels: np.ndarray
) -> float:
"""Find the temperature that minimizes negative log-likelihood."""
def nll_with_temperature(T):
scaled = logits / T
probs = softmax(scaled, axis=1)
correct_probs = probs[np.arange(len(labels)), labels]
return -np.mean(np.log(correct_probs + 1e-10))
result = minimize_scalar(nll_with_temperature, bounds=(0.1, 10.0), method="bounded")
return result.x
# Usage: after finding optimal T on a calibration set
optimal_T = find_optimal_temperature(validation_logits, validation_labels)
calibrated_probs = softmax(test_logits / optimal_T, axis=1)
Temperature scaling requires access to model logits, which is available with local models but not through most API providers. For API-based agents, verbalized confidence is the practical alternative.
When you cannot access logits, you can ask the model to express its confidence as a number. Research shows that with careful prompting, verbalized confidence provides useful — though imperfect — calibration signals:
from openai import OpenAI
import json
def get_calibrated_answer(question: str, client: OpenAI) -> dict:
"""Get an answer with a verbalized confidence score."""
response = client.chat.completions.create(
model="gpt-4",
messages=[{
"role": "user",
"content": f"""Answer this question and rate your confidence.
Question: {question}
Respond in JSON with:
- "answer": your answer
- "confidence": a number from 0.0 to 1.0 representing your true confidence
- "reasoning": why you assigned this confidence level
Be honest about uncertainty. A 0.7 means you expect to be right about 70% of the time on similar questions."""
}],
response_format={"type": "json_object"},
)
return json.loads(response.choices[0].message.content)
def should_agent_act(confidence: float, threshold: float = 0.85) -> str:
"""Decide whether the agent should act autonomously."""
if confidence >= threshold:
return "act"
elif confidence >= 0.5:
return "act_with_caveat"
else:
return "escalate_to_human"
In production agent systems, calibration informs routing decisions. High-confidence answers proceed through automated workflows, while low-confidence answers get routed to human reviewers or trigger additional verification steps.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Build a calibration dataset specific to your domain by collecting model predictions with confidence scores and comparing them against ground truth. Track calibration metrics over time — model updates, prompt changes, and distribution shifts all affect calibration.
Most LLMs are overconfident — they express high confidence even when their answers are wrong. This is especially pronounced for factual knowledge questions outside the model's strong training domains. Instruction-tuned models tend to be slightly better calibrated than base models.
Yes, through verbalized confidence. Ask the model to output a confidence score with each answer, then build a calibration curve from these scores against ground truth. You can then apply a simple mapping function (learned from your calibration set) to adjust raw verbalized confidence into calibrated estimates.
Recalibrate whenever the underlying model changes (new version, different provider) or when your input distribution shifts significantly. A monthly calibration check on a held-out evaluation set is good practice for production agents.
#LLMCalibration #ConfidenceEstimation #TemperatureScaling #Reliability #AgenticAI #LearnAI #AIEngineering

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
Self-correction is now a property of the model, not the framework. What that means for production agent reliability, voice/chat fallbacks, and CallSphere.
The 2026 desktop AI agent landscape — ServiceNow Project Arc, Anthropic Claude offerings, OpenAI agents, and Google Mariner. A buyer's map.
An agentic-AI perspective on Anthropic Skills system, covering orchestration patterns, tool use, and how agent tooling fits production agent stacks.
Enterprise CIO Guide perspective on Comet's general-availability launch put an agentic browser in front of millions of consumers, and it works better than the demos suggested.
Enterprise CIO Guide perspective on Harvey AI's enterprise rollout numbers show legal agents have moved past the pilot stage at AmLaw 100 firms.
Enterprise CIO Guide perspective on Hippocratic AI's deployment numbers show healthcare voice agents are moving from pilot to production across major US health systems.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco