Glossary term · · 3 min read
Temperature Scaling
A model routes messages to billing or delivery. Ten times it chooses billing with 90% confidence, but a human confirms only eight decisions. You want to improve those percentages. Simply reducing them by eye does not tell you how strong the correction should be or whether it will help on new tickets.
Temperature Scaling fits one positive number after training, shared across all categories and examples, to adjust probabilities. The model’s weights, the numbers learned during training, remain fixed. The goal is Calibration: closer agreement between stated confidence and the frequency of correct decisions. Guo and colleagues describe the rule in §4.2, Equation 9 of On Calibration of Modern Neural Networks.

Same decisions, different percentages
In our simplified example, every ticket has the same two scores before conversion to probabilities: approximately 2.197 and 0. These scores are called logits; the larger one indicates the preferred category. The Softmax function turns them into positive shares adding up to 100%: here 90% for billing and 10% for delivery.
Divide both scores by temperature T ≈ 1.585. We obtain approximately 1.386 and 0, and after Softmax: 80% and 20%. Billing still wins. Division by a positive number preserves the order of scores, so when selecting the largest probability, none of the ten tickets changes department. Eight remain correct.
Where does T come from? On held-out examples with known correct answers, choose the value minimizing the average penalty for assigning a low probability to the actual answer. This is Cross-entropy, here also mean NLL. In this invented sample, the minimum occurs at 80%/20%: the penalty drops from approximately 0.545 to 0.500. These ten tickets are used for fitting, so they are not an independent test of improvement. Evaluate the final result on other data, a Test Set, following the protocol in §4 of the paper.
Does a stronger correction always help?
Try T=4. Billing confidence falls to approximately 63.4%, and the penalty rises again. Less confidence does not automatically mean better calibration. The demonstration recalculates the same ten examples; it samples nothing.
The exact scores in the demonstration are ln(9) and 0. “ln” means the natural logarithm. For these two scores, the probability of billing is p = 9^(1/T) / (9^(1/T) + 1). The average penalty is −[0.8 × ln(p) + 0.2 × ln(1−p)]: eight correct categories are billing, two are delivery.
Limitation: one shared number may not fix different errors in different groups; fitting on a small sample does not guarantee improvement on new data. The method adds no knowledge and removes no incorrect decisions. Temperature uses the same rescaling when sampling text, but choosing a chat setting alone does not calibrate the truthfulness of the entire answer.
The text and illustration were prepared with AI assistance. The data are our own educational example, not measurements of a particular LLM.