Calibration of model probabilities
Define calibration (events assigned 70% happen 70% of the time) and explain why minimizing cross-entropy rewards calibrated next-token probabilities. Contrast this with the confidence expressed in generated text, and note that post-training often degrades calibration.
Builds on: The next-token cross-entropy objective, From base model to assistant
What the animation says
Two kinds of confidence
A language model shows confidence in two different ways. First, the probability it puts on each possible next token. Second, words in its reply, like “I’m ninety percent sure.” A confidence is calibrated if, across all the times it says seventy percent, the thing happens about seventy percent of the time. Training only teaches the model to predict text. So which of these two ends up honest?
What the loss charges
The token probabilities. Here’s how the loss makes them honest. Say one context appears ten times in the corpus: seven times followed by yes, three times by no. Each time, cross-entropy charges minus the log of the probability given to the token that actually came. Small probability, big charge. Predict yes at seventy percent: each yes costs zero point three six nats, each no costs one point two. Now an overconfident ninety percent against a hedging fifty-fifty. Which costs more on average?
Minimum at the truth
Ninety percent costs more. Each rare no now costs two point three nats. Fifty-fifty overpays on every yes instead. Seventy percent is cheapest: zero point six one. In general, the average loss equals the data’s own uncertainty, which is fixed, plus a gap that is zero only at the true frequencies. For ninety percent, that gap is zero point one five. Matching every context gives calibrated probabilities. Saying “I’m ninety percent sure” gets none of this pressure. Those words are just tokens imitating people.
Post-training sharpens
Post-training changes the goal. It scores whole replies by reward, not by how often continuations occur. Confident, single-answer replies tend to win, so probability piles onto one answer. This toy simulation draws a true chance for each event, then lets each event happen with that chance. Two predictors: one reports the true chance; the other is a changed copy. Tap the line that makes the second predictor overconfident.
Said 90%, happened 75%
That line stretches every chance away from one half. A true seventy-five percent becomes a claimed ninety. Gather every case where a predictor says about ninety percent. For the calibrated one, they happen about ninety percent of the time. For the sharpened one, only about seventy-five percent. Its average loss also rises above the calibrated zero point five nats. So: base-model token probabilities tend to be calibrated, because cross-entropy is lowest at the real frequencies. Stated confidence is imitated text. And reward-driven post-training often makes even the token probabilities overconfident.
The loss pays for honest frequencies
Cross-entropy is minimized at the truth
A 70/30 continuation, three guesses
Post-training sharpens, calibration breaks
import numpy as np
rng = np.random.default_rng(0)
truth = rng.uniform(0, 1, 200_000) # real chance of each event
happened = rng.uniform(0, 1, truth.size) < truth
sharp = np.clip(0.5 + 1.6 * (truth - 0.5), 0.01, 0.99) # pushed toward 0/1
for name, q in [("calibrated", truth), ("sharpened", sharp)]:
near90 = (q > 0.85) & (q < 0.95)
hit = happened[near90].mean()
ce = -np.mean(np.where(happened, np.log(q), np.log(1 - q)))
print(name, round(hit, 2), round(ce, 3))
What to remember
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses