Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Explainers/Research Papers

DeepSeek-R1 explained: how it learned to think step by step

DeepSeek-AI shows a model can learn to reason from correct-answer rewards alone (GRPO), then turns it into R1 and distils it into small models.

Derpx0627 Jan · 7 min read
Contents
The idea in one sentenceHow it worksStep 1: Reinforcement learning with rule-based rewardsStep 2: GRPO, the update ruleStep 3: What R1-Zero learnedStep 4: Why R1-Zero was not enough, and the R1 pipelineStep 5: DistillationWhat the paper foundWhat to be careful aboutSources
0% read · 7 min leftBack to top ↑
On this page0%
Contents
The idea in one sentenceHow it worksStep 1: Reinforcement learning with rule-based rewardsStep 2: GRPO, the update ruleStep 3: What R1-Zero learnedStep 4: Why R1-Zero was not enough, and the R1 pipelineStep 5: DistillationWhat the paper foundWhat to be careful aboutSources

Language models answer hard maths and coding questions better when they write out their thinking step by step. Until this paper, the usual way to teach that was to show the model many human-written solutions. DeepSeek-AI asked a different question: can a model learn to reason from rewards alone, with no human-written reasoning to copy? The answer was yes for questions with checkable answers, and the paper then shows how to turn that raw result into a usable assistant and how to pass the skill to small models.

Paper

DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning, by DeepSeek-AI, arXiv:2501.12948, first posted January 2025 (the text read here is version 2, January 2026). Read it at arxiv.org/abs/2501.12948.

The idea in one sentence

Reward a model only when its final answer is correct, and it learns to think longer, check its work and try other approaches on its own.

The paper builds on DeepSeek-V3-Base, a large pre-trained model. The first version trained only with rewards (R1-Zero). The second added a few extra stages to make the output readable and generally helpful (R1).

How it works

Step 1: Reinforcement learning with rule-based rewards

Reinforcement learning (RL) means the model tries something, gets a score, and changes itself to earn higher scores. For R1-Zero the score comes from two simple rules, not from a learned judge:

  • Accuracy reward. For maths, the model must put its final answer in a set format, such as a box, so a program can compare it with the known answer. For code, a compiler runs the answer against test cases.
  • Format reward. The model must put its thinking between <think> and </think> tags.

The paper adds the two rewards with equal weight. It chose not to use a neural reward model for reasoning, because such models can be exploited during long training. This exploiting is called reward hacking: the model finds a shortcut that earns a high score without doing the real task.

Toy example (my own numbers; the paper does not list its point values). Say each rule gives 1 point. Right answer with tags: 2. Right answer without tags: 1. Wrong answer with tags: 1.

Step 2: GRPO, the update rule

The RL method is Group Relative Policy Optimization (GRPO). The policy is the model itself. For each question, GRPO does this:

Question
Group of answers
Rewards
Advantages
Update

Ask one question

Step 1 of 5
One GRPO round for one question.

The older method, PPO, uses a second network, a value model, to estimate how good a state is. The paper's Figure 3 shows that GRPO has no value model and takes its comparison from the group's own scores. This saves memory and computing.

The comparison is called the advantage. For answer iii with reward rir_iri​:

Ai=ri−mean(r1,…,rG)std(r1,…,rG)A_i = \frac{r_i - \text{mean}(r_1,\dots,r_G)}{\text{std}(r_1,\dots,r_G)}Ai​=std(r1​,…,rG​)ri​−mean(r1​,…,rG​)​

Here GGG is the group size, and std is the standard deviation, a measure of how spread out the rewards are.

Toy example. A group of 4 answers has rewards 1, 0, 0, 0. The mean is 0.25 and the standard deviation is about 0.433. The correct answer gets A=0.75/0.433≈+1.73A = 0.75/0.433 \approx +1.73A=0.75/0.433≈+1.73. Each wrong answer gets A≈−0.58A \approx -0.58A≈−0.58. If the rewards were 1, 1, 0, 0, the advantages would be +1, +1, -1, -1.

The full objective adds two safety parts:

  • A clip: the new-to-old probability ratio of an answer is limited to the range [1−ε,1+ε][1-\varepsilon, 1+\varepsilon][1−ε,1+ε], so one update cannot change the model too much. With a toy ε=0.2\varepsilon = 0.2ε=0.2, a ratio of 1.5 and A=1.73A = 1.73A=1.73, the value used is 1.2×1.73≈2.081.2 \times 1.73 \approx 2.081.2×1.73≈2.08, not 1.5×1.73≈2.61.5 \times 1.73 \approx 2.61.5×1.73≈2.6. The paper sets ε=10\varepsilon = 10ε=10 in its first RL stage, and says a low value cuts the learning signal for many tokens.
  • A KL penalty, weighted by β=0.001\beta = 0.001β=0.001. KL divergence measures how far the new model's behaviour has drifted from a reference model. The penalty keeps it from drifting too far.

For R1-Zero the paper samples 16 answers per question and trains for 10,400 steps.

Step 3: What R1-Zero learned

With only these rewards, the model's average score on AIME 2024 (a hard maths competition) rose from 15.6% to 77.9% (pass@1, meaning one try per question). With majority voting over 16 answers it reached 86.7%. The average answer also grew steadily longer as training went on.

The paper reports an "aha moment": the model began using the word "wait" much more often while re-checking its own work (Table 2 shows an example).

Step 4: Why R1-Zero was not enough, and the R1 pipeline

R1-Zero was hard to read, sometimes mixed English and Chinese in one answer, and was weaker at writing and open questions. R1 uses these stages:

The multi-stage pipeline of DeepSeek-R1 from the paper, Figure 2: V3 Base to R1-Zero, then Dev-1, Dev-2, Dev-3 and finally R1.
The multi-stage pipeline of DeepSeek-R1 from the paper, Figure 2: V3 Base to R1-Zero, then Dev-1, Dev-2, Dev-3 and finally R1.
  1. Cold-start SFT. Supervised fine-tuning (SFT) trains the model to copy example answers. Here the examples are thousands of long, readable, first-person reasoning traces. They come from correct R1-Zero outputs, rewritten by DeepSeek-V3 and checked by people. The result is called Dev-1.
  2. First RL stage. Same rule-based rewards, plus a language-consistency reward: the share of words in the reasoning that are in the target language. The paper notes this slightly lowers benchmark scores but makes the output easier to read. The result is Dev-2.
  3. Rejection sampling and a second SFT. Rejection sampling means generating many answers and keeping only the good ones. From the Dev-2 checkpoint the team kept about 600,000 correct reasoning samples, and added about 200,000 non-reasoning samples such as writing and factual questions. Fine-tuning DeepSeek-V3-Base on these roughly 800,000 samples gives Dev-3.
  4. Second RL stage. Reasoning questions still use rules. General questions use reward models for helpfulness (trained on 66,000 preference pairs) and for safety (trained on 106,000 labelled prompts). The stage lasts 1,700 steps, and general data and preference rewards are used only in the last 400, because longer use led to reward hacking. The result is R1.

Step 5: Distillation

Distillation means training a small "student" model to imitate a large "teacher". The team fine-tuned Qwen and Llama models of 1.5B to 70B parameters on the same 800,000 samples from R1. They used SFT only and no RL for these models.

GPT-4o9.3%
Claude-3.5-Sonnet16%
Distill-Qwen-1.5B28.9%
Distill-Qwen-7B55.5%
Distill-Qwen-14B69.7%
Distill-Qwen-32B72.6%
AIME 2024 pass@1 (paper Table 15).

What the paper found

R1 stage by stage (paper Table 3):

BenchmarkR1-ZeroDev-1Dev-2Dev-3R1
AIME 2024 (pass@1)77.959.074.078.179.8
Codeforces (percentile)80.484.590.592.196.3

R1 against OpenAI o1-1217 (paper Table 8):

BenchmarkR1o1-1217
AIME 2024 (pass@1)79.879.2
MATH-50097.396.4
Codeforces (percentile)96.396.6
GPQA Diamond71.575.7
MMLU90.891.8

The distilled 32B model scored 72.6 on AIME 2024. A 32B model trained with large-scale RL only (Qwen2.5-32B-Zero) scored 47.0, and QwQ-32B-Preview scored 50.0 (Table 16). The paper concludes that for small models, distillation beats running the same RL.

The paper's Table 7 puts the R1 work at 147,000 H800 GPU hours, about 294,000atanassumed294,000 at an assumed 294,000atanassumed2 per hour (202,000forR1−Zero,202,000 for R1-Zero, 202,000forR1−Zero,10,000 for SFT data, $82,000 for R1). This covers the stages built on DeepSeek-V3-Base. The paper does not give a figure for building the base model.

What these numbers show. Rule-based RL can raise reasoning scores a lot on maths, code and STEM, and the result is close to the o1-1217 model on several tests. What they do not show. They do not show that RL works for every task, and the o1 comparison is on selected benchmarks, with o1 ahead on four of the six above.

What to be careful about

  • It needs a checkable answer. The method works best where a program can verify the result. For writing, no reliable rule exists, and model-based rewards were hacked. The paper's own Figure 6 shows reward rising while a code score fell.
  • The base model must be large. Early tries with a 7B dense model and a 16B mixture-of-experts model did not improve on AIME.
  • The "aha" is not proof of understanding. The paper describes it as a rise in the word "wait", and the paper cautions that the human-like reasoning style partly reflects choices made by its team, not human-like intelligence.
  • Known weaknesses. The paper lists weak structured output, no tool use, "overthinking" on easy questions, language mixing outside Chinese and English, worse results with few-shot prompts, and little gain over V3 on software-engineering tasks. Its SFT data is mostly single-turn.
  • Several widely repeated claims are not in this paper. It does not report a total company cost, headcount, market effects, or a percentage cost saving from GRPO.
Key takeaways
  • R1-Zero learned long, self-checking reasoning from only accuracy and format rewards on V3-Base.
  • GRPO scores each answer against its own group and needs no separate value model.
  • R1 adds cold-start SFT, language consistency, rejection sampling and a second RL stage to make this usable.
  • Distilling R1's outputs into small models beat running the same RL on a small model.

Sources

  • DeepSeek-AI, DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning, arXiv, 2025 (v2, 2026). All numbers above come from this paper unless marked as my own toy examples.
ShareXLinkedInEmail
Written by Derpx06A developer who builds AI search tools and the code around them. I explain what I got wrong first, so you can skip it. Spotted a mistake? Tell me — corrections get credited.
Research Papers · 6 minAttention Is All You Need, explained simplyResearch Papers · 5 minMamba explained: an alternative to TransformersResearch Papers · 6 minLoRA explained: fine-tune a big AI model cheaplyResearch Papers · 7 minChinchilla explained: how big should an AI model be?
Start here
01Why do AI chatbots make things up?02How does Raft work? Getting computers to agree03Mamba explained: an alternative to Transformers