Explain reasoning models and test-time compute
Explain why longer chains of thought and more samples improve accuracy on hard problems. Explain how RL with verifiable rewards trains models to produce long reasoning, and how distillation spreads this ability to smaller models.
Builds on: Scaling test-time compute: parallel vs sequential, RL with verifiable rewards (GRPO), Distillation from a stronger model
What the animation says
Fixed depth per token
A reasoning model writes thousands of tokens of scratch work before it answers. Yet its weights are the same size as the version that doesn't think. Here's the catch: every token gets exactly one forward pass, through the same fixed stack of layers. So the work per token is capped. Only the number of tokens can grow. Suppose a problem needs forty steps in a row, but one pass manages about ten. What can the model do?
Two ways to spend compute
Writing steps out works: each new token reads every earlier one, so serial work spreads across the chain. That's the sequential way. One answer of n tokens costs about two times the parameter count, times n, operations. In practice, each doubling of thinking tokens adds a similar gain, until it levels off. The parallel way: sample several independent tries and let a checker pick one. If one try is right twenty percent of the time, eight tries with a perfect checker succeed about eighty-three percent.
Scoring one group
How did training teach such long chains? With reinforcement learning from verifiable rewards. Sample a group of four attempts, and a checker marks each answer: one right, three wrong. The mean reward is a quarter, the spread about point four three. So the right chain gets plus one point seven three. Each wrong one gets minus point five eight. The right chain's tokens, including its 'wait, let me check,' become likelier. Length isn't rewarded; checking just wins more. Now suppose all four attempts are wrong. What are the advantages?
No contrast, no signal
All zero. Every reward equals the mean, so every advantage is zero. The spread is zero too; the tiny epsilon in this line makes the result zero, not zero over zero. With no contrast, no chain is pushed up or down. Nothing is learned. Same if all four are right: still no contrast. Here are four groups. Tap the ones that teach the model something.
Handing down the skill
So reinforcement learning only learns where the model sometimes succeeds. Smaller models have another route: distillation. A strong teacher solves problems; a checker keeps only the correct traces. The small student is fine-tuned to predict those traces token by token, with ordinary cross-entropy. It copies the strategy, checks and backtracks included, without having to discover it by trial and error. Recap: longer chains or more checked tries buy accuracy, and training rewards only correct answers.
Compute per token is fixed; tokens are not
What you pay and what gets reinforced
One GRPO group, and one with no signal
Both effects in a few lines
import numpy as np
def pass_at_k(p, k):
return 1 - (1 - p) ** k
def grpo_adv(r, eps=1e-6):
r = np.asarray(r, float)
return (r - r.mean()) / (r.std() + eps) # np.std divides by G
print(pass_at_k(0.2, 1), pass_at_k(0.2, 8)) # 0.2, ~0.83
print(grpo_adv([1, 0, 0, 0])) # ~[1.73 -0.58 -0.58 -0.58]
print(grpo_adv([0, 0, 0, 0])) # all zeros: no signal
Remember this
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