What you will learn in Build a Reasoning Model (From Scratch)
Chapter by chapter
Chapter 1: Understanding reasoning models
The chapter introduction motivates reasoning methods for complex LLM tasks and agents, and explains why the book uses checkable math examples while considering the costs of added reasoning machinery.
What you learn in chapter 1 →Chapter 2: Generating text with a pretrained LLM
The chapter establishes why it starts with a pretrained base LLM before adding reasoning techniques in later chapters.
What you learn in chapter 2 →Chapter 3: Evaluating reasoning models
The chapter introduction defines evaluation as quantitative testing against reference answers and identifies math-answer verification as the chapter’s approach.
What you learn in chapter 3 →Chapter 4: Improving reasoning with inference-time scaling
The chapter introduction establishes that reasoning accuracy can improve during text generation without retraining or modifying the model.
What you learn in chapter 4 →Chapter 5: Inference-time scaling via self-refinement
Introduces self-refinement as an inference-time scaling technique and contrasts it with self-consistency.
What you learn in chapter 5 →Chapter 6: Training reasoning models with reinforcement learning
The introduction places reinforcement learning among the ways to improve reasoning models, contrasting training methods with increased inference compute.
What you learn in chapter 6 →Chapter 7: Improving GRPO for reinforcement learning
The chapter picks up from an implemented GRPO baseline and identifies training instability as a concern during longer runs.
What you learn in chapter 7 →Chapter 8: Distilling reasoning models for efficient reasoning
The chapter introduces distillation as a training-time way to improve a smaller reasoning model using outputs from a larger model.
What you learn in chapter 8 →Concepts explained in this book
- Group Relative Policy OptimizationA reinforcement-learning method that uses groups of rollouts for the same prompt and derives learning signals from their relative performance.
- log probabilityThe logarithm of a model-assigned probability, used here to score how likely a generated token or whole sequence is under the current parameters.
- generationThe process of producing new textual output from a language model given prior context or instructions.
- temperatureA token sampling method that draws from a probability distribution after temperature rescaling to control randomness.
- distillationA model adaptation approach that trains a smaller student model to imitate a larger teacher model’s outputs or behavior.
- inference-time compute scalingImproving a trained model's output quality by spending more computation at inference time without changing its weights.
- self-consistencyAn inference technique that generates multiple candidate responses and selects or combines them to improve answer quality.
- token probabilityThe probability assigned by the model to a candidate token at a particular position in the output sequence.
- softmaxA normalization function that converts logits into a probability distribution over possible next tokens.
- language modelA neural language model trained on large text corpora to predict and generate text.
- multi-step reasoningThe process of deriving conclusions from premises through explicit inference rather than surface pattern recognition.
- Kullback–Leibler divergenceA measure of how different two probability distributions are, used here for soft distillation.
- continuous improvementAn inference-time procedure that iteratively revises a model answer and keeps a revision only if it scores better than the current answer.
- top-p filteringA decoding method that restricts sampling to the smallest set of tokens whose cumulative probability reaches a chosen threshold p.
- reasoning modelA language model optimized to deliberate over complex problems, often producing intermediate steps or using tools to improve answer quality.
- tokenizerA component that splits text into token IDs for model input, with this section focusing on the Qwen3 reasoning variant that supports reasoning tags.
- reinforcement learning with human feedbackA training approach that uses human preference labels to optimize a language model toward responses humans prefer.
- confidenceThe model-assigned probability used here as a scorer for how strongly an LLM prefers a candidate answer.
- joint probability distributionThe probability of an entire token sequence under a model, computed by multiplying conditional token probabilities across positions.
- torch.prodPyTorch's product operation used here to multiply per-token probabilities into a sequence score.
- reinforcement learning with verifiable rewardsA reinforcement learning approach that uses automatically checkable correctness rewards instead of human preference signals.
- reinforcement learningA training approach where a model learns from rewards or feedback to improve its behavior.
- clipped policy ratioA policy-optimization constraint that limits how far a new policy’s probability ratio can move from an old policy’s ratio for the same sampled response.
- pretrainingThe initial training stage in which a language model learns general statistical structure from large amounts of data before task-specific adaptation.
- templateA fixed prompt structure used to shape how an LLM formats and reasons in its response.
- answer checking pipelineA deterministic workflow that extracts a model's answer and compares it to the reference for correctness.
- logprob scorerA scoring method that ranks answers by their average log probability under the model, favoring fluent and likely text.
- trainingA method that improves model behavior by further updating the model through training.
- post-trainingMethods applied after initial pretraining to improve model behavior or capabilities.
- sequence_logprobA sequence-scoring function that sums token log probabilities to obtain a whole-response log probability.
- evaluationThe process of assessing model performance on held-out data or benchmarks.
- probability distributionA normalized set of values over tokens that sum to 1 and can be sampled from to choose the next token.
- response-formatting rewardA reward component that gives the model credit for producing outputs in the required tag format, regardless of whether the answer is correct.
- trajectoryA generated response trajectory sampled from the model, treated as one complete candidate output in policy optimization.
- torch.log_softmaxA PyTorch function that computes log-softmax over logits to produce log probabilities in a numerically stable way.
- <think> tagA special markup tag used to enclose hidden reasoning steps in model output.
- inference modeA runtime setting that disables gradient tracking and other training-time behavior for efficient model execution.
- preference tuningA post-training method that adjusts a model to produce responses aligned with preferred outputs or styles.
- student modelA smaller model trained to imitate a teacher model's reasoning traces and answers during distillation.
- pattern recognitionThe process of completing text or answers by relying on learned correlations and recurring examples instead of formal reasoning.
- reasoning methodologyA method applied to a language model to improve explicit step-by-step reasoning behavior.
- torch.compile()An optimization process that transforms a model's computation graph into more efficient executable code for faster inference.
- teacher modelA larger model whose outputs or signals are used as training targets for a smaller student model during distillation.
- advantage functionA normalized per-rollout signal computed from rewards that indicates how much better or worse a rollout was than the group average.
- verifierA component that checks whether a candidate answer is correct or acceptable, often by comparing it against a reference.
- computation graphA recorded graph of differentiable operations in PyTorch that enables gradient computation during backpropagation.
- verifiable rewardA reward signal that can be automatically checked against a correct answer or objective criterion.
- cross entropy lossA loss function that measures the average negative log probability assigned to the correct target tokens.
- numerical stabilityThe property of a computation remaining accurate and avoiding underflow or rounding errors when values are very small or very large.
- rule-based scoring functionA manually specified scoring method that assigns numeric values to model outputs using explicit rules rather than learned parameters.
- answer boxA final answer presented inside boxed notation so it can be extracted more reliably from the response text.
- regular expressionA pattern-matching technique for searching and extracting text using formal expression syntax.
- end of text tokenA special token used to mark the end of a document or generated sequence and stop generation.
- stopping criterionA criterion that terminates generation when met, such as encountering an end-of-sequence token.
- policy gradient methodThe reinforcement-learning objective used to adjust a policy so actions with better outcomes become more likely and worse ones less likely.
- symbolic AIReasoning based on explicit symbolic rules rather than statistical associations learned from data.
- MATH-500A curated benchmark dataset of 500 math problems sampled from the original MATH dataset for evaluating reasoning models.
- answer-only lossA training loss computed only on answer tokens and not on prompt tokens.
- equality_checkA function that decides whether two mathematical expressions are equivalent after normalization.
- verification pipelineThe ordered process used to evaluate model answers, from loading the model through scoring on a dataset.
- SymPyAn open-source Python library for symbolic mathematics used here to parse and compare expressions for equivalence.
- tokenizationThe process of rendering text into a model-ready format and splitting it into tokens/IDs for training.
- entropyA measure of uncertainty in the model's output distribution during generation, where low entropy indicates collapse and high entropy indicates randomness.
- tokenA discrete text unit used as the basic element of language-model generation.
- cumulative sumThe running total of sorted token probabilities used here to determine which tokens remain under a top-p threshold.
- pipPython’s package installer used to install packages from a terminal.
- PyTorchA deep learning library used here to represent tensors and define optimizers that minimize losses.
- requirements.txtA file listing Python package dependencies to install for a project.
- uvA Python package and project manager that can create environments and resolve dependencies automatically.
- mathematical equivalenceThe property that two expressions represent the same mathematical value despite differing surface forms.
- greedy algorithmA decoding strategy that always selects the highest-probability next token instead of sampling randomly.
- equalityThe process of determining whether two mathematical expressions represent the same value or form symbolically.
- evaluation pipelineAn ordered process that loads a model, generates outputs, and scores them against a dataset or reference answers.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
