A classifier can choose the correct class yet attach a probability that is too concentrated or too diffuse for the application using that score. Temperature scaling addresses this mismatch after model training by applying one positive scalar to the logits before softmax.
The mechanism is deliberately narrow. It changes probability sharpness, not the information represented by the classifier. That boundary makes temperature scaling useful when class ranking is acceptable but confidence values need separate calibration.
Temperature rescales every class logit
For logits z_1, ..., z_K and temperature T > 0, the calibrated probability for class k is:
p_k = exp(z_k / T) / sum_j exp(z_j / T)A temperature above one compresses logit differences and produces a flatter probability distribution. A temperature below one expands those differences and produces a sharper distribution. At T = 1, the original softmax is unchanged.
Because division by the same positive scalar preserves logit ordering, the class with the largest logit remains the class with the largest calibrated probability. Top-1 predictions therefore remain unchanged when temperature scaling is applied exactly in this form.
This invariance is useful but restrictive. If a classifier frequently ranks the wrong class first, changing a single temperature cannot repair those decisions.
The temperature comes from held-out predictions
Temperature is normally fitted after the classifier parameters are fixed. The system collects logits and labels from a calibration split, then selects T to minimize a calibration objective such as negative log-likelihood on that split.
Only the scalar temperature is optimized. The base model weights remain fixed.
The calibration split needs to represent the conditions under which the resulting probabilities will be interpreted. Reusing training examples can give the temperature access to observations that already influenced model fitting. Reusing the final test set also contaminates an evaluation intended to estimate behavior on untouched data. A separate held-out partition keeps those roles distinct.
The fitted value is tied to the model checkpoint and data distribution that produced the logits. Replacing the checkpoint, changing preprocessing, or moving to a materially different input distribution can alter the confidence error even when classification accuracy appears similar.
Calibration is not the same as accuracy
Suppose a classifier emits confidence near 0.95 for a group of predictions. Calibration concerns whether outcomes associated with that confidence occur at a compatible empirical frequency under the evaluation setup. Accuracy asks a different question: how often the selected class is correct.
A model can have useful ranking accuracy and poorly scaled confidence. It can also have well-scaled aggregate confidence while making many incorrect predictions. Temperature scaling targets the first property without changing the argmax class.
This distinction matters when probabilities drive downstream decisions. A threshold such as p >= 0.9 is not merely another form of top-1 classification. It assigns operational meaning to the score magnitude, so score calibration becomes part of the interface between the model and the surrounding system.
Aggregate metrics can hide local errors
A single calibration metric compresses behavior across examples. Expected calibration error, for example, groups predictions into confidence bins and compares confidence with observed accuracy inside each bin before aggregating the gaps.
The result depends on bin definitions. Changing the number of bins or their boundaries can change the reported value even when model outputs are identical. A small aggregate value can also coexist with errors concentrated in a particular class, confidence range, or input segment.
For that reason, temperature fitting and calibration assessment are separate concerns. Minimizing negative log-likelihood for T does not make every subgroup calibrated, and a favorable binned metric does not establish that all local probability errors are small.
Examining class-conditional or segment-specific behavior can expose cases that an aggregate score merges together.
One scalar assumes a global confidence distortion
Temperature scaling applies the same correction to every example and every class. Its implicit shape is global: the classifier is treated as broadly too sharp or too flat in a manner that one scalar can adjust.
That assumption can fail. One class may be systematically overconfident while another is underconfident. Confidence may also vary with input length, acquisition source, language, image conditions, or another feature not represented by a global temperature.
More flexible calibration mappings can model richer distortions, but flexibility introduces additional parameters and a greater opportunity to fit noise in a limited calibration set. Temperature scaling occupies a specific point in that design space: low parameter count, preserved class ordering, and limited corrective capacity.
Distribution shift can invalidate the fitted scale
Calibration is evaluated relative to a data distribution. If deployment inputs differ from the calibration split, the relationship between confidence and correctness can move.
Temperature scaling has no mechanism for detecting that shift. It continues to divide logits by the fitted scalar regardless of whether the current inputs resemble the calibration data. The resulting probabilities can therefore lose their prior calibration properties without any change to the temperature parameter itself.
This is especially relevant when confidence controls abstention, escalation, or other thresholded behavior. Monitoring only top-1 accuracy can miss a change in score semantics that alters how often those thresholds fire.
Calibrated probability is still a model output
Temperature scaling can make softmax probabilities better aligned with observed correctness under a chosen calibration procedure. It does not turn those probabilities into guarantees about individual predictions.
The score remains conditional on the model, data, labels, calibration objective, and evaluation population. It also carries no independent evidence that an input belongs to the same distribution as the calibration data.
A practical boundary follows from the mechanism itself: use temperature scaling when the main defect is global confidence sharpness and preserving class ranking is desirable. When errors depend strongly on class or input region, the single scalar is evidence of the method’s limit rather than a parameter that can express the missing structure.