Thinking on paper
Each token a model writes gets the same, fixed amount of computation: one pass through all its layers. A hard question answered in one token gets one pass. The same question answered after 2,000 tokens of working gets 2,000 passes, and every step can build on the results written before it.
17 × 24 = ?Asked for the answer straight away, a model has to produce it in one go.
17 × 24 = 17 × 20 + 17 × 4 = 340 + 68 = 408Written out, each small step is easy, and the earlier results are right there in the context.
In 2022, Google researchers showed that giving a large model a few examples with worked steps, chain-of-thought prompting, made it much better at maths word problems. The same year, a team from Tokyo found that adding just “Let’s think step by step” raised one model’s score on the GSM8K maths test from 10.4 % to 40.7 %.
What a reasoning model does
A reasoning model is trained to think before it answers. Open models write their thinking between special tags such as <think> and </think>, and the app shows or hides it. Some closed models keep their thinking hidden and show only a summary.
-
You
A shop sells pens at 3 for $2. How much do 12 pens cost?
-
Model, thinking
12 pens is 12 ÷ 3 = 4 groups of 3. Each group costs $2, so 4 × 2 = $8. Check: $8 for 12 pens is about 67 cents each, and 2 ÷ 3 is about 0.67. Correct.
-
Model
12 pens cost $8.
Thinking is a dial, not a switch. More thinking tokens usually mean better answers on hard problems, at a higher cost. Qwen3 introduced a thinking budget: a cap on thinking tokens, and its scores rose smoothly as the budget grew. Most APIs now offer a reasoning effort setting. DeepSeek-V4’s levels are low, high and max: “low for simple tasks, high for everyday agent tasks, max for complex ones”.
| Method | How it works |
|---|---|
| Think longer | One long chain of thought, with checking and backtracking |
| Vote | Write several answers and take the most common one (self-consistency) |
| Best of N | Write N answers and let a verifier or reward model pick the best |
| Search | Explore a tree of partial solutions, guided by a step-by-step verifier |
Researchers at Google DeepMind and Berkeley found in 2024 that spending test-time compute wisely can beat a 14 times larger model, on problems the small model can already sometimes solve.
Reinforcement learning in five words
SFT needs examples to copy. For long reasoning, nobody has millions of perfect examples. Reinforcement learning (RL) needs only a way to score attempts: the model tries, gets a reward, and shifts towards whatever earned more.
| Word | Meaning here |
|---|---|
| Policy | The model itself: it decides which token to write next |
| Rollout | One complete attempt: the model’s whole answer to a prompt |
| Reward | A score for the rollout, such as 1 if the final answer is right and 0 if not |
| Advantage | How much better this rollout was than expected |
| Policy update | Make high-advantage rollouts more likely, low ones less likely |
GRPO: DeepSeek’s algorithm
The classic RL method for language models, PPO, needs a second network as large as the model, called a value model, to estimate how good each situation is. DeepSeek’s group relative policy optimisation (GRPO), introduced in its 2024 DeepSeekMath paper, removes it. Instead of estimating what to expect, it simply samples a group of answers and compares them with each other.
- Take a question with a checkable answer.
- Let the model write a group of answers to it: DeepSeek-R1-Zero wrote 16.
- Score each one: for R1-Zero, a reward for the right final answer and a reward for the right format (thinking inside the tags).
- Give each answer an advantage: its reward minus the group’s average, divided by the group’s spread.
- Raise the probability of every token in the answers with positive advantage, and lower it in those with negative advantage. A small penalty keeps the model close to a reference copy.
A_i = (r_i − mean(r)) ÷ std(r)r_i is answer i’s reward; mean and std (standard deviation) are taken over the group.
rewards [1, 0, 0, 1, 0, 0, 0, 0]: mean = 0.25, std ≈ 0.432 of 8 answers were right.
right: (1 − 0.25) ÷ 0.43 ≈ +1.73 wrong: (0 − 0.25) ÷ 0.43 ≈ −0.58Rare successes get a big push up; the common failures a smaller push down.
Sample, learn, and repeat a few times. Notice what happens when the whole group is right, or the whole group is wrong.
This interactive part needs JavaScript.
Quick check
R1-Zero: reasoning from rewards alone
DeepSeek’s boldest experiment was R1-Zero: take the base model DeepSeek-V3-Base, skip SFT entirely, and run GRPO on maths, coding and logic problems with simple rule-based rewards. No human ever showed it how to reason.
From the DeepSeek-R1 paper, as published in Nature in 2025. 16 answers per question, 10,400 training steps.
Nobody told it to write long answers, but its answers grew longer and longer as training went on, because thinking longer earned more reward. Behaviours appeared on their own: checking its work, trying another method, going back to a mistake. The paper shows one moment in training where the model interrupts itself in the middle of a solution.
-
Model, thinking
…squaring both sides again gives x⁴ − 2ax² − x + (a² − a) = 0 … “Wait, wait. Wait. That’s an aha moment I can flag here.” Let’s re-evaluate this step by step…
The R1 recipe
R1-Zero reasoned well but was hard to read, and sometimes mixed English and Chinese in one chain of thought. The released DeepSeek-R1 added stages around the RL.
- Cold start. SFT on thousands of long, readable chain-of-thought examples.
- Reasoning RL. GRPO on maths, code and logic, plus a reward for keeping to one language.
- Rejection sampling and SFT. Generate many answers, keep the good ones, and train on about 800,000 examples covering both reasoning and general tasks such as writing.
- RL for everything. A final round with checkable rewards for reasoning and reward models for helpfulness.
- Distillation. The same 800,000 examples fine-tuned small Qwen and Llama models from 1.5B to 70B, which then reasoned far better than before.
After R1: the race to fix GRPO
R1 started a wave of open RL research, most of it from Chinese labs. A few names you will meet in papers:
| Method | Who | The idea |
|---|---|---|
| DAPO (2025) | ByteDance Seed and Tsinghua | Four fixes, including skipping groups where every answer scores the same. Reached 50 on AIME 2024 from the Qwen2.5-32B base model |
| Dr. GRPO (2025) | Sea AI Lab and others | Removes a bias that let wrong answers grow ever longer |
| GSPO (2025) | Qwen | Compares whole answers instead of single tokens; much more stable for mixture-of-experts models; used for Qwen3 |
| CISPO (2025) | MiniMax | Clips the importance weights rather than the updates. MiniMax-M1’s full RL run took 3 weeks on 512 H800s, about $534,700 |
| Kimi k1.5 (2025) | Moonshot | RL with very long contexts, and “long2short” methods that teach short answers from long reasoning |
Does each one judge only the final answer, or each step?
-
R1-Zero’s accuracy reward
Answer: Final answer only
-
A process reward model
Answer: Each step
-
Unit tests run on finished code
Answer: Final answer only
-
A verifier that marks the first wrong line of a proof
Answer: Each step
-
Checking a boxed final number against the answer key
Answer: Final answer only
Using reasoning models well
- Match the effort to the task. Use low effort or a non-thinking mode for look-ups, formatting and short chats; save high effort for maths, debugging, planning and agent work.
- Thinking costs money. Thinking tokens are output tokens: billed, and slow to generate. A hard question can use tens of thousands of them.
- Do not micro-manage. Reasoning models already think step by step; long instructions on how to think can make them worse. Say clearly what you want and how to check it.
- Read the thinking when it goes wrong. Where it is visible, it shows where the model misunderstood you.
Remember
- Each token gets a fixed amount of computation, so writing out steps gives a model more computation and a place to keep results.
- Reasoning models are trained to think before answering; effort settings and thinking budgets trade cost for accuracy.
- RL learns from scores, not examples: rollouts, rewards, advantages and policy updates.
- GRPO samples a group, scores it, and uses (reward − mean) ÷ std as each answer’s advantage. No value model needed.
- R1-Zero learned to reason from checkable rewards alone (AIME 15.6 % → 77.9 %); R1 added cold-start SFT, more RL and distillation.
- RL mostly sharpens what pretraining built. Later methods (DAPO, Dr. GRPO, GSPO, CISPO) fix GRPO’s weak spots.
Words to know
- Chain of thought
- The written steps a model produces before its final answer.
- Reasoning model
- A model trained, usually with RL, to think at length before answering.
- Test-time compute
- Computation spent while answering: longer thinking, voting, or searching.
- Thinking budget
- A limit on how many tokens a model may spend thinking.
- Reinforcement learning (RL)
- Learning by trying, being scored, and shifting towards what scored well.
- Policy
- In RL for language models, the model being trained.
- Rollout
- One full attempt by the model, which is then scored.
- Advantage
- How much better an attempt did than expected, here than its group’s average.
- GRPO
- Group relative policy optimisation: RL that compares a group of answers instead of using a value model.
- Value model
- In PPO, a second network that predicts how much reward to expect.
- Process reward model
- A model that scores each step of a solution, not just the final answer.
- pass@k
- The chance that at least one of k attempts is correct. pass@1 is a single attempt.
Go to the source
This lesson is built on these papers and documents. Paper links open arxiv.org, a separate site.
-
Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
Where it started. Figure 1 shows one prompt with and without worked steps.
-
DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
Introduces GRPO. Figure 4 puts PPO and GRPO side by side.
-
DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning
The paper to read in this part. Appendix A compares GRPO with PPO in detail.
-
DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning (Nature)
The peer-reviewed version of the same work.
-
Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters
When thinking longer beats being bigger.
-
DAPO: An Open-Source LLM Reinforcement Learning System at Scale
Four practical fixes to GRPO, each tested on its own.
-
Does Reinforcement Learning Really Incentivize Reasoning Capacity in LLMs Beyond the Base Model?
The pass@k study: read it to understand what RL does and does not add.
-
Let’s Verify Step by Step
Process against outcome rewards, with a public dataset of 800,000 step labels.
Check yourself
6 questions. Tap the answer you think is right.
0 of 6 answered
Lesson complete
Answer every question above to complete this lesson.
Your progress is saved on this device only.
Next lessonFine-tuning: making a model your own