confidence has a temperature

seedling 10 min read

tl;dr A model's confidence can rank things correctly and still be wrong as a percentage. Preference tuning tends to make models sound surer without making them know more. It's the same math as cooling a gas, and accuracy metrics can't see it.

This is a physicist’s companion to what Jev is selling, for anyone who wants the why. That post turns an honest probability into a threshold on a refund queue and shows what a cooled model costs there. This one is why a model’s confidence usually isn’t a probability in the first place, why the knob that bends it is called temperature, and why preference tuning can turn it down.

The short version: two models can rank every item in exactly the same order and still need different thresholds to make the same decisions, because a model’s confidence is a number of a particular kind, and most of the time it isn’t the kind it looks like.


what kind of number

In 1946 the psychologist S. S. Stevens sorted measurements by what you can do to the numbers without changing what they mean. An ordinal scale (finishing places in a race, star ratings) survives anything that keeps the order, so you can sort the numbers but not meaningfully average them. Interval and ratio scales (Celsius, weight) survive less and so support more arithmetic. A probability sits past the end of his list. It survives no transformation at all, because 0.8 has to mean four times in five, and anything that moves it to 0.9 has changed what it claims. That’s what lets you compare it to a threshold worked out from prices, as the refund queue does, and it’s what makes it fragile, because most of what models report as confidence can only be trusted as an ordinal score, a number that ranks things correctly and means nothing else, written with a percent sign.

None of this is new. Weather forecasters have been calibrated for decades, since a forecast gets checked every day, and their tools came from their own journals: Glenn Brier’s score in 1950, Allan Murphy’s decomposition of it in 1973. Machine learning came to it late and sideways. Niculescu-Mizil and Caruana’s 2005 benchmark found boosted trees and SVMs squashing their outputs toward the middle, naive Bayes flinging them toward the corners, and logistic regression calibrated almost by accident, because log loss is a proper scoring rule. Then Guo and colleagues (ICML 2017) found that bigger, more accurate deep networks had quietly become less honest, and proposed a single number called temperature as the fix.

temperature

Every classifier that hands you a probability over options, from a 2005 neural net to whatever you called this morning, ends in the same operation. It gives each option a score, called a logit, which can be any real number, and then turns the scores into probabilities by exponentiating each one and dividing by the total, so that bigger scores become bigger probabilities, everything comes out positive, and the whole thing sums to one. Machine learning calls this softmax. Physics has called it the Boltzmann distribution since the 1870s, when Ludwig Boltzmann showed that a molecule in a gas at temperature TT sits in a state of energy EE with probability proportional to e−E/kBTe^{-E/k_B T}, so that low-energy states are likelier and temperature sets how much likelier. Read the logit as a negative energy and softmax is Boltzmann at T=1T = 1, and the temperature slider in every LLM API is the same TT, dividing the logits before the exponential:

pi=ezi/T∑jezj/Tp_i = \frac{e^{z_i/T}}{\sum_j e^{z_j/T}}

What physics gives you for free is an intuition for what temperature does. Heat a system and the differences between energies stop mattering, so it wanders through every state almost evenly; cool it and it settles into its lowest state and stays there. Here are the same three logits, 2, 1 and 0, at three temperatures:

T = 0.5, cooledT = 0.5, cooled: option A (logit 2) = 0.8670.87AT = 0.5, cooled: option B (logit 1) = 0.1170.12BT = 0.5, cooled: option C (logit 0) = 0.0160.02C T = 1T = 1: option A (logit 2) = 0.6650.67AT = 1: option B (logit 1) = 0.2450.24BT = 1: option C (logit 0) = 0.0900.09C T = 2.5, heatedT = 2.5, heated: option A (logit 2) = 0.4720.47AT = 2.5, heated: option B (logit 1) = 0.3160.32BT = 2.5, heated: option C (logit 0) = 0.2120.21C three options with logits 2, 1 and 0
The same three scores through softmax at three temperatures. The favorite is the favorite every time; what changes is how loudly the distribution says so.

Nothing about the options changed, and neither did their order, since the favorite is the favorite at every temperature. What changed is how loudly the distribution announces its favorite, and if that distribution is also what the model reports as its confidence, temperature is a dial on how sure the model sounds that has no connection to how much it knows. For a yes/no question, here is what cooling and heating do to a model’s stated probability as a function of what it actually believes:

00.250.50.75100.250.50.751 what the model actually believes what it reports temperature 0.5, overconfident temperature 2.5, underconfident believes 0.80, reports 0.94 believes 0.80, reports 0.80 believes 0.80, reports 0.64 T = 0.5says 0.94T = 1says 0.80T = 2.5says 0.64
A yes/no model's stated probability against what it believes, at three temperatures. Cooling bends the curve toward the corners and heating flattens it toward the middle, so the same belief of 0.8 comes out as 0.94, 0.80 or 0.64, and because no curve ever turns back on itself, all three rank every item in the same order.

Read up from 0.8 on the horizontal axis and three models that believe the same thing report 0.94, 0.80 and 0.64. The curves bend, but none of them ever turns back on itself, so any item ranked above another stays above it, and cooling changes every number while changing no ordering. That’s the thread back to Stevens: cooling is a transformation an ordinal scale shrugs off and a probability can’t survive.

Now put it back in the refund queue, where approving an abusive request costs five dollars, turning away a customer costs twenty, and the threshold works out to 0.2. Cool a probability of 0.3 to T=0.5T = 0.5 and it becomes about 0.155, which lands on the other side of 0.2. Run a cooled copy of the fake model described further down through that queue at 0.2 and it costs $1.59 a ticket against the honest model’s $1.44, and a heated one (T=2.5T = 2.5) costs $1.88. Neither knows any less than the honest model. The cooled one’s own cheapest threshold is down near 0.04, where it costs $1.43, but nothing in the arithmetic would send you there, and only labelled examples could.

Anything that depends only on the ordering survives cooling: which answer ranks first, a human preferring one answer to another, and for a yes/no question the AUC and accuracy at 0.5, since cooling never moves a probability across one half. So the metrics most people check first can’t see the thing that just cost about eleven percent.


why models run cool

This matters because of what happens to most models after pretraining. The step is called preference tuning, usually some variant of RLHF, and the vocabulary it borrows from reinforcement learning makes it sound more exotic than it is. The model’s distribution over possible answers gets called a policy. Human raters look at pairs of answers and pick the better one, and a second model, the reward model, learns to predict their picks, so that it can give any answer a score. Then the original model is nudged toward answers that score well, with one restraint: it pays a penalty for drifting too far from the model it started as, measured by KL divergence (Kullback–Leibler), which is a standard yardstick for how different two probability distributions are, and a single number, β\beta, sets how heavy that penalty is.

That optimization has an exact solution,

new(y)  ∝  old(y) e reward(y)/β,\text{new}(y) \;\propto\; \text{old}(y)\, e^{\,\text{reward}(y)/\beta},

and to a physicist it’s another Boltzmann factor, with reward playing the part of negative energy and β\beta playing temperature, multiplied onto the distribution the model already had. Now suppose raters tend to reward answers that sound confident, and push that to its limit, where the reward simply is the model’s own log-probability. Substitute and the solution becomes

new(y)  ∝  old(y)1+1/β,\text{new}(y) \;\propto\; \text{old}(y)^{1 + 1/\beta},

and raising a Boltzmann distribution to a power is the same as dividing its temperature, so the tuned model is the old model cooled to T=β/(1+β)T = \beta/(1+\beta), which is below one for any positive β\beta. It’s a caricature, and the takeaway is narrow: this toy reward shows one way preference optimization can sharpen probabilities without making the predictions any better. Real preference tuning also changes which answers a model prefers, so it isn’t just a temperature. Whether tuned models end up overconfident in practice is an empirical question, and the measurements say they often do: Tian and colleagues found the token probabilities of preference-tuned models poorly calibrated where the pretrained ones had been well calibrated.

The same closed form is the starting point of Rafailov and colleagues’ DPO paper (NeurIPS 2023), where it appears without the thermodynamics.

measuring it

To watch this happen at scale I needed a model whose honesty I could set exactly, which no real model offers, so I built a fake one that generates things in the reverse of the natural order. A real model meets an item whose answer is already fixed and forms a belief about it. The mock draws the belief first, then flips a coin weighted by that belief to decide what’s true:

const belief = beta(rand, 0.45, 0.45);
const actual = rand() < belief;

That makes it calibrated by construction, since among the items where it believed 0.8 the event happens 80% of the time, because that’s how the event was drawn. It has exactly two knobs. The beta(0.45, 0.45) decides where its beliefs come from, which amounts to deciding how smart it is: both parameters below one bend the distribution into a U, a model that is usually confident one way or the other with a thin band of genuine toss-ups, which is roughly what a competent classifier looks like from the inside. The temperature decides how honestly it says what it believes.

00.250.50.751 the belief the mock draws for an item density 0123 sure sure a toss-up about 1 in 8 shaded edges: about 2 in 5 items
Beta(0.45, 0.45), the prior the mock draws its beliefs from. Both parameters below one bend the density into a U, so most items are easy calls one way or the other and a thin middle band is genuinely uncertain.

Those two knobs map one-to-one onto the two measures that carry through the rest of this series, both from Allan Murphy’s split of the Brier score. ReliabilityHow far a model's stated probabilities sit from how often things actually happen. Zero is perfectly honest. is how honest the forecasts are, and the temperature sets it. ResolutionHow much the outcomes differ between the items a model scores differently. A model that gives everything the same score has none. is how informative they are, and the beta sets it.

For a calibrated forecaster, resolution works out to the variance of its beliefs, and a symmetric beta with both parameters equal to aa has variance 1/(4(2a+1))1/\big(4(2a+1)\big), which for a=0.45a = 0.45 is 0.1316. The simulation below measured 0.1317.

Turn only the temperature, leaving every hidden truth where it was, and run twenty thousand items on the same seed:

ECE, expected calibration error, is the plainest of these: sort the predictions into ten buckets by what they claimed, check how often the thing actually happened in each bucket, and average the gaps, weighting each bucket by how many predictions landed in it.
temperatureECEreliabilityresolution
1.0, honest0.00650.000070.1317
0.5, cooled0.07390.006380.1290
2.5, heated0.12800.019240.1308

Reliability gets about ninety times worse cooled and nearly three hundred times worse heated, and resolution stays within two percent of the value the beta promised, because the temperature never touched what the model believed, only what it claimed.

00.250.50.75100.250.50.751 probability the model claimed how often it happened the dashed line is perfect honesty honest: claimed 0.03, happened 0.04 (n=4506)honest: claimed 0.15, happened 0.14 (n=1732)honest: claimed 0.25, happened 0.25 (n=1380)honest: claimed 0.35, happened 0.35 (n=1229)honest: claimed 0.45, happened 0.46 (n=1144)honest: claimed 0.55, happened 0.56 (n=1238)honest: claimed 0.65, happened 0.66 (n=1253)honest: claimed 0.75, happened 0.77 (n=1386)honest: claimed 0.85, happened 0.85 (n=1685)honest: claimed 0.97, happened 0.97 (n=4447) T = 0.5: claimed 0.02, happened 0.08 (n=6970)T = 0.5: claimed 0.15, happened 0.31 (n=1069)T = 0.5: claimed 0.25, happened 0.36 (n=752)T = 0.5: claimed 0.35, happened 0.44 (n=647)T = 0.5: claimed 0.45, happened 0.50 (n=553)T = 0.5: claimed 0.55, happened 0.56 (n=640)T = 0.5: claimed 0.65, happened 0.57 (n=649)T = 0.5: claimed 0.75, happened 0.64 (n=786)T = 0.5: claimed 0.85, happened 0.73 (n=1097)T = 0.5: claimed 0.98, happened 0.92 (n=6837) honeston the linecooledT = 0.5
The same twenty thousand yes/no calls, bucketed by what the model reported, with how often the thing actually happened in each bucket and a 95% interval around it. The honest model sits on the dashed diagonal. The cooled one crosses it, so that in the bucket where it said about 0.15 things happened 31% of the time, and where it said about 0.85 they happened 73% of the time, which is what sounding sure looks like from the outside: wrong in both directions at once.

where this goes

A word on the metaphor running through these posts. When I say a model is honest, I mean calibrated: its stated probabilities match how often things happen, over a population of items. That’s an empirical relationship between numbers and outcomes, not a claim about what the model believes or whether it means what it says.

A model whose confidence runs cool or hot still ranks your items as well as it ever did, so nothing that measures ranking will flag it, and every threshold you set on its numbers is quietly in the wrong place. What Jev is selling runs three bent models through a refund queue and repairs them with a few hundred labels or with none, and a probability you can count on is the loop that keeps a model honest in production.