19.1 Training lifecycle and learning signals
This part of Choosing Training and Adaptation Methods develops the mechanisms below. Work the numerical examples or trace the code before checking the answer.
Concepts from other sections (14)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- MinHash: estimating Jaccard similarity by how often the minima of random permutations agree. Read more: 12.5 Discrete math 2 problem set, part b: trees, birthday bounds, MinHash and LSH, Bloom filters, recurrences in Mathematics
- Entropy: , the average surprise of a distribution. Read more: 17.1 Entropy, cross-entropy, KL, JS, and the k3 estimator in Mathematics
- Warmup-stable-decay (WSD): warmup, a long constant phase at the peak, and a short final decay. Read more: 16.4 Learning-rate schedules (cosine, WSD, Noam) and gradient clipping in Mathematics
- Learning-rate schedule: a function from the step number to the learning rate. Read more: 16.4 Learning-rate schedules (cosine, WSD, Noam) and gradient clipping in Mathematics
- RoPE: rotary position embedding, which rotates queries and keys by position to encode relative position. Read more: 5.3 Model landscape and lifecycle
- chat template: the byte-level protocol that renders a list of role-tagged messages into one token sequence. Read more: 18.1 Supervised fine-tuning: chat rendering, assistant-only loss, packing
- PPO: a policy gradient method that clips the new-to-old probability ratio to keep updates small. Read more: 4.4 World models, multiple agents, and RLHF
- DPO: preference optimization that uses the closed-form optimum of KL-constrained RLHF so the reward model and partition function drop out. Read more: 19.7 The training step and validation
- GRPO: a PPO-style RL method that replaces the critic with the group-normalized reward of several samples of the same prompt. Read more: 19.7 The training step and validation
- Model card: the model’s interface documentation: details, intended and out-of-scope use, evaluation with uncertainty, limitations, and data. Read more: 35.1 Datasheet and model card
- MFU: model FLOPs utilization, useful model FLOPs per second divided by the hardware’s peak. Read more: 19.7 The training step and validation
- FlashAttention: attention computed tile by tile with an online softmax, so the score matrix is never stored. Read more: 22.5 FlashAttention forward in C
- Retrieval-augmented generation (RAG): retrieving relevant evidence at query time and placing it in the context window, so a model answers from fresh, private, citable facts instead of only its parametric memory. Read more: Chapter 27: Retrieval and RAG
- LoRA: fine-tuning a frozen matrix through a trainable low-rank update initialized to zero. Read more: 19.7 The training step and validation
Learning objectives
- Identify the data and objective for each training stage.
The pipeline and who does what
Section titled “The pipeline and who does what”A modern model is made in a fixed sequence of stages, as written down in the Llama 3 report and taught in CS336:
data → pretraining → mid-training → SFT → preference / RL → evals → releaseThe table below summarizes what each stage does, how big it is, and what learning signal it uses.
| Stage | What happens | Typical scale | Signal |
|---|---|---|---|
| Data | Crawl (Common Crawl), text extraction, language ID, dedup (exact hash + MinHash LSH near-dup), quality filtering (heuristics + classifier, e.g. FineWeb-Edu), PII and toxicity filters, decontamination against evals, tokenizer training (BPE), mixture weights across web/code/math/books/multilingual | 10s of trillions of raw tokens down to ~15T kept | none (curation) |
| Pretraining | Next-token cross entropy on the mixture, cosine or WSD learning-rate schedule | to FLOPs | self-supervised |
| Mid-training | Anneal on high-quality data, up-weight code/math, long-context extension (raise RoPE base , train on long documents, 8K to 128K+) | 1-10% of pretraining tokens | self-supervised |
| SFT | Instruction→response demonstrations in a chat template | to examples | supervised |
| Preference / RL | Reward model + PPO, or DPO on pairs, or GRPO on verifiable tasks; often several rounds | to prompts | preference / reward |
| Evals | Capability (MMLU-Pro, GPQA, SWE-bench, AIME), safety, regression vs previous checkpoint | every checkpoint | measurement |
| Release | Quantize, convert, write model card, ship weights and serving config |
Two of these rows deserve emphasis. First, data is the source code: most of the quality differences between open models trace to filtering and mixtures, not to architecture (FineWeb, free). Second, decontamination is a correctness requirement, not a nicety. A benchmark that leaked into pretraining makes every later evaluation on it meaningless.
Different people own different stages, and it helps to know what each of them will ask you. The research scientist owns objectives, data recipes, ablations, and the post-training algorithm, and asks questions like “What is your KL coefficient and how did you pick it?” The ML engineer owns training and evaluation pipelines, data tooling, checkpoints, and reproducibility: “How do you version data and resume a failed run?” The member of technical staff on performance owns MFU, kernels (FlashAttention, fused optimizers), the parallelism layout, communication overlap, and FP8: “What MFU do you get on H100 for a 70B with TP=8?” And the forward deployed engineer owns a customer’s adaptation, choosing among prompting, RAG, LoRA, and full fine-tuning, building their dataset and evaluation, running the job, and getting it served. Their question is the one the last section of this chapter answers: “Will fine-tuning fix this, how much data, what will it cost, and how do we know it worked?”
At a fine-tuning cloud, customers almost always start from an open base or instruct model, so the deployed engineer’s pipeline is the last three rows of the table. But you cannot reason about those rows without the arithmetic of the first ones, so that is where we start.
Summary
Section titled “Summary”Identify the data and objective for each training stage. State the assumptions before applying the result to a different workload.
Review questions
Section titled “Review questions”-
Why must the evaluation split be fixed before choosing a fine-tune?
Answer
Choosing data or hyperparameters using the test split makes that split part of training; reserve it for the final comparison.