A language model already produces fluent text. A reasoning model is asked to do something more specific: spend tokens on intermediate steps before it commits to an answer. Those steps are ordinary generated text. They are not a separate symbolic engine. The gain, when there is one, is that the extra tokens change the distribution over the final answer.
These notes build that behavior on top of a pretrained base model. They do not train a transformer from random initialization. The base model is Qwen3 with 0.6 billion parameters, small enough to run the later training chapters on a single GPU and still large enough that the same algorithms are the ones used at a much bigger scale.
What counts as reasoning
Definition 1.1 (Reasoning model).In these notes, a reasoning model is a language model that generates intermediate steps and then a final answer, where the procedure that produces those steps was chosen because it raises accuracy on tasks with a checkable result.
Definition 1.1 is an operational definition. It does not claim that the network has a proof system, a world model, or human-like deliberation. It claims that we can name the procedure (a prompt, a vote, a training objective) and measure whether answers get better.
The usual place this shows up is a math problem, a logic puzzle, or a coding task, because those have a verifier. Open-ended writing can look stepwise too, but there is no automatic check that the steps were the ones that mattered.
Remark 1.1 (Pattern matching).A model can emit a chain of steps that is only a memorized pattern. The steps then read as an explanation even when they did not constrain the answer.
Remark 1.1 is why a verifier sits at the center of the later modules. If the only signal is “the text looks like a solution,” a model will learn the look. If the signal is “the final answer matches the reference under a symbolic check,” the look is not enough.
The ordinary training pipeline
Before any reasoning method, a base model has already been trained in stages.
- Pretraining. Next-token prediction on a large text corpus. This is where the model learns language, code, and a great deal of factual and procedural pattern.
- Supervised fine-tuning. Often called instruction tuning. The model is trained to answer prompts in a dialogue format, on curated prompt-response pairs.
- Preference tuning. A second stage that pushes the model toward responses humans, or a reward model, prefer. Reinforcement learning from human feedback (RLHF) is the familiar version.
Reasoning methods are usually added after these stages. They can also be applied directly to the pretrained base model, which is what the later chapters do. Starting from the base model makes the effect of each method easier to see: there is no instruction-tuned habit already hiding inside the weights.
Three ways to add reasoning
Figure 1.1 is the map for the rest of the course. The three methods spend compute in different places.
Sample more, at inference time. The weights stay frozen. The model is prompted to write steps, or it is sampled several times and the answers are voted on, or it is asked to revise one draft. Accuracy can rise because the final answer is conditioned on extra tokens, or because several draws are combined. The cost is paid on every question. Module 4 and Module 5 implement this.
Train against a verifiable reward. For each question, sample a group of answers, score them with the same verifier used at evaluation, and update the policy so that better-than-average answers become more likely. The algorithm in these notes is Group Relative Policy Optimization (GRPO), a policy-gradient method that uses the group as its own baseline. Module 6 derives the simple form. Module 7 adds clipping, a KL tether, and a format reward.
Distill a teacher. A stronger reasoning model writes traces and answers. A smaller student is trained with ordinary cross-entropy to imitate that text. No reward model and no rollouts are required at student training time. Module 8 is this supervised setup, which is the practical form of hard distillation used for the smaller DeepSeek-R1 models.
Inference-time methods and training-time methods compose. A model trained with GRPO or distillation can still be sampled several times at test time. The notes treat them separately so each mechanism stays visible.
Why build it small
The production systems that made this vocabulary familiar (DeepSeek-R1, the various “thinking” modes) run the same three ideas at a scale where a single training step is not something you can read. A 0.6B model with a few dozen rollouts will not match those systems. It will show the same objects: a prompt, a group of sampled answers, a scalar reward, an advantage, a policy-gradient step, a distillation loss.
That is the reason to implement the methods rather than only read about them. The failure modes in Module 7 — a reward that the model games, a KL term that blows up, an advantage that is identically zero — are visible in a log file from a laptop run.
What comes next
Module 2 loads the base model and writes the generation loop that every later method calls. The architecture of that model is collected in Module 9, for when the loop stops being a black box.
The exercises for this chapter are in Homework 1.
Code
Chapter 1 of the book has no training code. The repository’s orientation page is the README, which maps each chapter to a notebook.