Availit World How AI really works, in your language

Lesson 21 of 4619 minFacts checked October 20, 2026

Reasoning models: teaching AI to think before it answers

In September 2024, OpenAI showed a model that writes a long chain of thought before answering, and became far better at maths and code. Four months later, DeepSeek released R1 with open weights and a paper explaining how it is done: reinforcement learning with rewards a computer can check. With no examples of reasoning to copy, the model taught itself to work step by step, check its work and change course. This lesson explains how, down to the formula.

In this lesson you will

  • Explain why writing out steps makes a model more accurate
  • Describe the parts of reinforcement learning: policy, reward, rollout and advantage
  • Work through GRPO, the algorithm behind DeepSeek-R1, by hand and in a demo
  • Follow the R1 recipe, and the main improvements that came after it
  • Use reasoning models well: effort settings, budgets and costs
On this page
  1. Thinking on paper
  2. What a reasoning model does
  3. Reinforcement learning in five words
  4. GRPO: DeepSeek’s algorithm
  5. R1-Zero: reasoning from rewards alone
  6. The R1 recipe
  7. After R1: the race to fix GRPO
  8. Using reasoning models well
  9. Remember
  10. Check yourself

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.

Answering at once, or on paper
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 = 408

Written 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.

A reasoning model at work
  1. You

    A shop sells pens at 3 for $2. How much do 12 pens cost?

  2. 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.

  3. 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”.

Ways to spend more computation at answer time (test-time compute)
MethodHow it works
Think longerOne long chain of thought, with checking and backtracking
VoteWrite several answers and take the most common one (self-consistency)
Best of NWrite N answers and let a verifier or reward model pick the best
SearchExplore 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.

RL words, for language models
WordMeaning here
PolicyThe model itself: it decides which token to write next
RolloutOne complete attempt: the model’s whole answer to a prompt
RewardA score for the rollout, such as 1 if the final answer is right and 0 if not
AdvantageHow much better this rollout was than expected
Policy updateMake 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.

  1. Take a question with a checkable answer.
  2. Let the model write a group of answers to it: DeepSeek-R1-Zero wrote 16.
  3. Score each one: for R1-Zero, a reward for the right final answer and a reward for the right format (thinking inside the tags).
  4. Give each answer an advantage: its reward minus the group’s average, divided by the group’s spread.
  5. 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.
The advantage, worked out
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.43

2 of 8 answers were right.

right: (1 − 0.25) ÷ 0.43 ≈ +1.73 wrong: (0 − 0.25) ÷ 0.43 ≈ −0.58

Rare successes get a big push up; the common failures a smaller push down.

Try itTrain with GRPO

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

In a group of 8, every answer is correct. What are the advantages?

Show the answer

Answer: All 0, so this group teaches nothing Every reward equals the average, so every advantage is 0. Too-easy and too-hard questions both give no signal, which is why later methods filter them out.

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.

R1-Zero on the AIME 2024 maths competition
  • Start of RL training (single attempt) 15.6 % correct
  • End of RL training (single attempt) 77.9 % correct
  • End of training, majority vote of many attempts 86.7 % correct

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.

From R1-Zero’s thinking, mid-training
  1. 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.

  1. Cold start. SFT on thousands of long, readable chain-of-thought examples.
  2. Reasoning RL. GRPO on maths, code and logic, plus a reward for keeping to one language.
  3. 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.
  4. RL for everything. A final round with checkable rewards for reasoning and reward models for helpfulness.
  5. 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:

GRPO’s descendants
MethodWhoThe idea
DAPO (2025)ByteDance Seed and TsinghuaFour 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 othersRemoves a bias that let wrong answers grow ever longer
GSPO (2025)QwenCompares whole answers instead of single tokens; much more stable for mixture-of-experts models; used for Qwen3
CISPO (2025)MiniMaxClips 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)MoonshotRL 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?

0 of 5 sorted
  • 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.

Check yourself

6 questions. Tap the answer you think is right.

0 of 6 answered

Why does writing out steps help a model?

Show the answer

Answer: Each token gets more computation, and earlier steps stay in the context to build on Every written token is another full pass through the model, and the results stay visible for the next steps.

What does RL need that SFT does not?

Show the answer

Answer: A way to score the model’s own attempts RL learns from rewards on attempts; SFT copies examples.

In GRPO, where does an answer’s advantage come from?

Show the answer

Answer: Comparing its reward with the rest of its group: (r − mean) ÷ std Using the group as the baseline is what lets GRPO drop PPO’s large value model.

What was special about R1-Zero?

Show the answer

Answer: It learned to reason with RL alone, without SFT first It went straight from the base model to RL with rule-based rewards, and long reasoning emerged.

Why did the released R1 add a cold-start SFT stage?

Show the answer

Answer: R1-Zero’s thinking was hard to read and mixed languages A few thousand readable examples gave the RL a better starting point, and a language-consistency reward helped too.

You need to reformat a list of names. Which reasoning effort fits?

Show the answer

Answer: Low, or a non-thinking mode Simple tasks do not need long thinking, and thinking tokens cost time and money.

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
Previous lesson All lessons

Choose your language