Dive into Deep Learning · §18.4
Scoring Language Models
likelihood scores · bits per byte · parsers · pass@k · reasoning · conventions
The problem
Qwen3-1.7B on ARC-Challenge: science questions with four options, where guessing gives 25%.
| how the answer is read | accuracy |
|---|---|
| probability of each answer’s text, summed over its tokens | 0.39 |
the same, minus the answer’s log-probability after Answer: |
0.46 |
| probability of the option’s letter | 0.72 |
| the letter, after five solved examples | 0.76 |
| the model writes, and a parser reads the letter | 0.79 |
| the model reasons first, then writes (100 of the 500 items) | 0.83 |
Nothing about the model changed between the rows. Which number is its score?
Goals
The idea: a score is a convention, a rule fixed in advance that turns the outputs of a model into a number.
Running example: 500 ARC-Challenge science questions and five checkpoints. A base model was trained only to predict the next token, a post-trained one further on conversations. Qwen3-0.6B and Qwen3.5-0.8B are the pair to compare, fixed before any score.
Where this fits
| movement | section |
|---|---|
| open a checkpoint | Pretrained Models with Hugging Face |
| A Released Checkpoint in the Book’s Own Code | |
| measure it | Prompting and In-Context Learning |
| Scoring Language Models | |
| Evaluation Suites, Judges and Error Bars | |
| inside and outside | Interpretability |
| Models behind an API |
Conventions
All three are reasonable, and nothing guarantees that they agree. Here (a) and (b) do: Qwen3-0.6B-Base prefers the text of carbon dioxide and gives the letter B a probability of 0.86.
A farmer wants to water her vegetables with water from the nearby ocean. Is this a good idea?
| option | Qwen3-0.6B picks it when we read | |
|---|---|---|
| A | Yes, because there is plenty of ocean water. | |
| B | Yes, because ocean water has many natural fertilizers. | the letters |
| C | No, because ocean water is too salty for plants grown on land. | its written reply |
| D | No, because ocean water is much more polluted than rainwater. | the answer texts |
Its written reply names a letter on 451 of 500 items. On 352 of them the three readings give at least two different answers.
Likelihood scores
\ell(c \mid x) = \sum_{t=1}^{m} \log p(c_t \mid x, c_{<t})
' oxygen' adds 1 token, ' carbon dioxide' 2, the letter ' B' 1.The scored tokens must spell the choice. Count boundary merges for every new tokenizer and format. Here: 0 of 2,000.
| cloze | letter | |
|---|---|---|
| prompt | Question: … Answer: |
question, A. … to D. …, Answer: |
| choices | the texts of the options | ' A' to ' D' |
| tokens per choice | one or more | one |
| the model sees the options | no | yes |
| asks | how probable is this answer? | read, choose, name the letter |
Whether current small models can name the letter is measured below.
Length normalization
Choice a: l_a tokens, mean log-probability m_a per token. Choice b: l_b < l_a tokens, mean m_b. Both means are negative.
1 < \frac{|m_b|}{|m_a|} < \frac{l_a}{l_b}: \quad \text{the mean picks } a, \text{ the sum picks } b
| \log p per token | carbon dioxide, 2 tokens | oxygen, 1 token | ratio | the sum picks |
|---|---|---|---|---|
| invented | -1.0 each | -1.5 | 1.5, inside (1, 2) | oxygen |
| Qwen3-0.6B-Base | -3.9 each | -8.9 | 2.3, outside | carbon dioxide |
One token per choice: the wedge is empty. Letters need no normalization.
Length spread of an item: characters of its longest option over those of its shortest. 500 items in thirds, five checkpoints pooled.
| third | length spread | sum and per-character rule disagree | 95% interval |
|---|---|---|---|
| most even | 1.00 to 1.29 | 0.17 | 0.14 to 0.21 |
| middle | 1.29 to 1.60 | 0.37 | 0.32 to 0.42 |
| most uneven | 1.60 to 6.00 | 0.57 | 0.52 to 0.63 |
On more than half of the uneven items, dividing by the length decides the answer.
Check
PMI rule: \log P(c \mid \text{question}) - \log P(c \mid \texttt{Answer:}), by how much the question raises the probability of the answer.
| option | tokens | \log P after the question | \log P after Answer: |
|---|---|---|---|
| a | 1 | -2.0 | -3.0 |
| b | 2 | -3.0 | -7.0 |
Which option wins under the sum, per token, and under PMI?
Answer. Sum: a, since -2.0 > -3.0. Per token: b, since -1.5 > -2.0. PMI: b, since -3.0 + 7.0 = 4.0 beats -2.0 + 3.0 = 1.0. Three defensible rules, two answers.
Measured on ARC, paired with the sum: PMI gains 7 to 10 points for every checkpoint. Per token and per character gain 0 to 5, not resolved.
Running text
\textrm{bpb} = \frac{1}{B} \sum_{t=1}^{T} -\log_2 P(x_t \mid x_{<t}) = \frac{T}{B} \log_2 \textrm{PPL}
B: bytes of the text. T: its tokens. PPL: perplexity per token. A PPL of 16 at T/B = 0.25 is 1 bit per byte.
| held-out code | tokens per byte | PPL | bits per byte |
|---|---|---|---|
| Qwen3-0.6B-Base | 0.362 | 3.41 | 0.64 |
| Qwen3.5-0.8B-Base | 0.379 | 3.63 | 0.71 |
Compare per byte, also across texts: one model has PPL 10.5 on prose and 3.4 on code, but 0.88 and 0.64 bits per byte.
A long text is scored in windows of ctx tokens that advance by stride, each token once. An unscored boundary token <|endoftext|> is the context of the first.
ctx 4, stride 2: the windows score 4, 2, 2 and 2 tokens.| Qwen3-0.6B-Base, wikitext-2 | stride = ctx | stride = ctx/2 |
|---|---|---|
| ctx 512 | 0.93 | 0.87 |
| ctx 2,048 | 0.83 | 0.81 |
More context per scored token lowers the score. Report ctx, stride and the boundary token with every bits-per-byte figure.
Bits per byte, windows of 2,048 tokens with stride 1,024:
| text | bytes | Qwen3-0.6B-Base | Qwen3.5-0.8B-Base |
|---|---|---|---|
| wikitext-2 test, Wikipedia as of 2016 | 1,290,000 | 0.81 | 0.82 |
| prose written after both releases | 68,000 | 0.88 | 0.87 |
| code written after both releases | 56,000 | 0.64 | 0.71 |
One comparison cannot separate memorization from a change of domain.
Generated answers
100 arithmetic word problems, 8 sampled solutions each, after four solved examples that end in a line #### 72. An extractor finds the number.
| extractor reads the number | Qwen3-0.6B | Qwen3.5-0.8B |
|---|---|---|
on a line #### N only |
0.00 | 0.09 |
after #### or “the answer is” (strict) |
0.06 | 0.09 |
| else the last number in the text | 0.42 | 0.45 |
A strict parser measures knowledge and format together. A lenient one can credit an answer never given.
pass@k: the probability 1 - (1-p)^k that at least one of k samples is correct, if each is with probability p. From n samples with c correct (Chen et al., 2021):
\hat U = 1 - \binom{n-c}{k} \Big/ \binom{n}{k}
pass@2 from n=4, c=1: 0.5000; plug-in: 0.4375
n=20, p=0.3, k=5: mean 0.83193, variance 0.018063 (sd 0.1344), plug-in mean 0.79583 (bias -0.0361)
The plug-in 1 - (1 - c/n)^k draws with replacement and is biased low, by 0.036 in the second line.
maj@8: accuracy of the most frequent answer among 8 samples.
| Qwen3-0.6B | Qwen3.5-0.8B | |
|---|---|---|
| pass@1 | 0.41 | 0.43 |
| maj@8 | 0.48 | 0.55 |
| pass@8 | 0.70 | 0.71 |
| plug-in at 8 | 0.64 | 0.66 |
On 16 to 22% of the problems a correct sample was in the pool and the vote missed it.
Check
Mean pass@1 over M = 100 problems with n = 8 samples has a band of \pm 8 points. Its variance is
\frac{1}{M}\Bigl(\underbrace{\mathbb{E}\bigl[p_i(1-p_i)\bigr]/n}_{\text{within problems}} + \underbrace{\textrm{Var}[p_i]}_{\text{between problems}}\Bigr),
with p_i the probability that a sample solves problem i. Measured share of the within term: 0.07 and 0.09.
Answer. Hardly. Ten times the samples remove at most the within term, under a tenth of the variance: the band narrows by less than 5%. Twice the problems narrow it by 29%.
Execution checks
For code the verdict comes from running tests, in a fresh Python process with limits on time and memory. Four versions of one function:
correct passed=True
wrong passed=False
infinite loop passed=False stopped after 5 s
syntax error passed=False
Run code that a model wrote only in a container. HumanEval’s own harness was released with its execution line commented out.
Reasoning before answering
Direct: thinking off, greedy, at most 1,024 tokens. Reasoning: thinking on, sampled, at most 4,096. The reply ends in a boxed letter.
| the same 100 items | Qwen3-0.6B | Qwen3-1.7B |
|---|---|---|
| accuracy, reasoning / direct | 0.67 / 0.49 | 0.83 / 0.76 |
| difference, with paired 95% interval | 0.18 (0.07 to 0.29) | 0.07 (0.00 to 0.15) |
| items right only with reasoning / only directly | 25 / 7 | 11 / 4 |
| tokens per reply, reasoning / direct | 1,019 / 91 | 1,321 / 242 |
| different letters where both name one | 30 of 88 | 16 of 95 |
A scored letter is one token and shows what a model says at once. What it concludes after a thousand tokens of deliberation is another measurement.
Batch drift
bf16: 16-bit floats, in which the models are stored and run. fp32: 32-bit.
| batch 8 against batch 1 | model | convention | predictions changed of 500 | largest score change |
|---|---|---|---|---|
| bf16 | Qwen3-0.6B | cloze, sum | 6 | 1.1 nats |
| bf16 | Qwen3-0.6B | letter | 12 | 0.78 nats |
| bf16 | Qwen3.5-0.8B | cloze, sum | 1 | 0.35 nats |
| bf16 | Qwen3.5-0.8B | letter | 7 | 0.27 nats |
| fp32 | Qwen3-0.6B | both | 0 | 0.0001 nats |
State precision and batch size. A difference between models below this batch drift (0.2 to 1.0 points here) is not a difference.
Right: Qwen3.5-0.8B minus Qwen3-0.6B, paired over 500 items. Cloze: -1 to +3 points, intervals contain 0. Letter: 11 (6 to 16). Written: 20 (15 to 25), and 18 where both replies name a letter. Fixed before looking: the gap is 12 points (5 to 18) larger under letters than under the cloze sum.
Bits per byte of the correct option: -\log_2 P(\text{correct option} \mid \text{question}) over the bytes of the option. A real number per item, where accuracy is one bit.
| Qwen3.5-0.8B minus Qwen3-0.6B | difference | difference over half-width of its interval |
|---|---|---|
| accuracy, cloze per character | 0.01 | 0.4 |
| bits per byte of the correct option | -0.16 | 3.9 |
| bits per byte of the wrong options | -0.14 | 3.3 |
| wrong minus correct | 0.02 | 0.5 |
Qwen3.5-0.8B predicts the text of ARC options better, right or wrong. The part that tracks the answer separates the pair no better than accuracy.
Check
A model card says “ARC-Challenge: 72%”. What do you need to know before you compare it with a number of your own?
Answer. The format (cloze, letter or written) and the demonstrations; the normalization; for written answers the prompt, the sampler, thinking on or off, the token budget and the parser; precision and batch size; the items; and an interval. For Qwen3-1.7B, 72% is the letter format without demonstrations.
Next: when a difference is real, and how many items that takes.