Inferensys

Glossary

Temperature Scaling

A post-processing calibration technique that divides the output logits of a neural network by a learned scalar parameter (T) to produce well-calibrated probability estimates.
Enterprise console with connected nodes and monitoring panels for orchestrated systems.
LOGIT CALIBRATION

What is Temperature Scaling?

A post-processing calibration method that uses a single scalar parameter to rescale a model's raw output logits, producing a well-calibrated probability distribution.

Temperature Scaling is a specific, highly effective logit calibration technique that divides a neural network's raw output scores (logits) by a single scalar parameter, T (temperature), before applying the softmax function. This operation directly reshapes the final probability distribution without altering the model's internal weights or the relative ranking of its predictions.

When T > 1, the distribution softens, reducing overconfidence by increasing the entropy of the output probabilities. When T < 1, the distribution sharpens, making the model more decisive. The optimal T value is learned by minimizing the Expected Calibration Error (ECE) on a held-out validation set, making it a computationally cheap and robust guard against calibration drift.

Logit Calibration

Key Characteristics of Temperature Scaling

A post-hoc calibration method that uses a single scalar parameter T to soften or sharpen the output probability distribution, preserving model accuracy while dramatically improving confidence estimates.

01

Single-Parameter Simplicity

Temperature scaling introduces exactly one learnable parameter (T > 0) applied to all logits before the softmax function. Unlike more complex methods such as Platt scaling or isotonic regression, it does not modify the model's internal architecture or require auxiliary models. This makes it computationally trivial to implement and resistant to overfitting on small calibration sets. The parameter T is optimized on a held-out validation set by minimizing the negative log-likelihood (NLL) with respect to the ground-truth labels.

02

Preservation of Rank Order

A critical property of temperature scaling is that it is accuracy-preserving. Multiplying all logits by a scalar does not change their relative ordering, meaning the model's top-1 prediction and overall classification accuracy remain completely unchanged. This is essential for safety-critical applications where you cannot afford to alter the model's decisions, only the confidence associated with them. The method strictly adjusts the sharpness of the distribution, not the decision boundary.

03

Mechanism: Softening vs. Sharpening

The temperature parameter T directly controls the entropy of the output distribution:

  • T > 1 (Softening): Logits are divided by a large number, making the probability distribution more uniform. This corrects overconfident models that output probabilities like 0.99 for incorrect predictions.
  • T < 1 (Sharpening): Logits are divided by a small number, making the distribution peakier. This corrects underconfident models.
  • T = 1: The original probability distribution is recovered.
04

Relationship to Expected Calibration Error (ECE)

Temperature scaling directly minimizes the Expected Calibration Error (ECE), the primary metric for measuring miscalibration. ECE partitions predictions into confidence bins and computes the weighted absolute difference between average confidence and accuracy. By smoothing overconfident peaks, temperature scaling ensures that when a model says it is 80% confident, it is actually correct roughly 80% of the time. Modern neural networks, particularly deep ensembles, often see ECE reduced by an order of magnitude after scaling.

05

Distinction from Distillation Temperature

It is crucial to distinguish calibration temperature from the temperature hyperparameter used in knowledge distillation. In distillation, a high temperature is used during training to extract 'dark knowledge' from a teacher model's soft labels. In calibration, the temperature is a post-hoc correction factor learned after training is complete. While both use the same mathematical operation, their purpose and placement in the workflow are entirely distinct.

06

Limitations and Modern Extensions

Standard temperature scaling assumes miscalibration is uniform across all classes and input regions, which is often not true. Extensions like matrix scaling (class-specific temperatures) and vector scaling (per-class plus a bias) offer more flexibility but risk overfitting. For modern LLMs, context-aware calibration is an active research area, as a single global T is insufficient to correct the complex confidence errors arising from in-context learning and long-form generation.

POST-HOC CALIBRATION COMPARISON

Temperature Scaling vs. Other Calibration Methods

A technical comparison of Temperature Scaling against other prominent post-processing calibration techniques for neural network confidence scores.

FeatureTemperature ScalingPlatt ScalingIsotonic Regression

Parameter Count

1 (scalar T)

2 (A, B for sigmoid)

Non-parametric (many)

Preserves Rank Order

Multiclass Native Support

Risk of Overfitting on Small Sets

Typical Validation ECE

< 0.02

0.02 - 0.05

0.01 - 0.03

Computational Cost

Negligible

Low

Moderate

Optimal For

Modern DNNs with large hold-out sets

Binary classification SVMs

Small, biased validation sets

Requires Separate Hold-out Set

TEMPERATURE SCALING

Frequently Asked Questions

Clear, technical answers to the most common questions about temperature scaling, the post-hoc calibration method that uses a single scalar parameter to soften or sharpen a model's output probability distribution.

Temperature scaling is a post-hoc calibration technique that applies a single scalar parameter, called the temperature (T), to the logit vector of a trained neural network before the softmax activation. The operation divides all logits by T: softmax(z_i / T). When T > 1, the output probability distribution is softened, reducing the confidence of the model's predictions and spreading probability mass more evenly across classes. When T < 1, the distribution is sharpened, making the model more confident in its top prediction. Critically, because T is a single scalar, temperature scaling does not alter the rank order of predictions—the highest-logit class remains the highest-probability class. The optimal T value is learned by minimizing the Negative Log-Likelihood (NLL) on a held-out validation set, keeping the base model's weights frozen. This simplicity makes it one of the most effective and widely adopted calibration methods, consistently outperforming more complex approaches like vector scaling or histogram binning on modern deep networks.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.