Post-training: From autocomplete to assistant
GPT-3 existed for two and a half years before ChatGPT. The model that took over the world was not much more capable than the base model that preceded it; it was more usable, and the difference was post-training. If pre-training pours in the knowledge, post-training shapes the thing you actually talk to: the assistant persona, the instruction-following, the refusals, and (since 2024) the reasoning. (The field’s umbrella word for the first three, making the model’s behavior match what its operators intend, is alignment, and you’ll see it attached to half the techniques in this chapter.)
The base model is a simulator of documents, and the assistant is a character the model has been trained to play. Post-training is character design, and it runs on a startlingly small budget — for InstructGPT, the pipeline that created the ChatGPT recipe, all of post-training cost about 65 petaflop/s-days against pre-training’s 3,640, by the paper’s own accounting (a petaflop/s-day: FLOPs per second, sustained for a day): under 2% of the compute, steering 100% of the behavior. The chapter builds the pipeline:
- Supervised fine-tuning — show the model transcripts of the assistant you want. Teaches the format.
- RLHF (reinforcement learning from human feedback) — grade its answers instead of writing them. Teaches judgment, and introduces post-training’s central demon.
- RLVR (reinforcement learning from verifiable rewards) — replace the fallible grader with a verifier, and watch reasoning emerge. The 2024 turn.
- The practical tier — the fine-tuning you might actually do, and what it can and can’t fix.
Supervised fine-tuning: show it the format
The first step is embarrassingly direct. Hire people (increasingly: use stronger models, with humans editing) to write ideal transcripts — conversations between a user and the assistant you wish existed. Then train on them with the exact same next-token loss from Chapter 1. This is supervised fine-tuning (SFT), and mechanically there is nothing new in it: it’s more pre-training, on a tiny, curated corpus of “documents” that all happen to depict a helpful assistant. InstructGPT needed only ~13,000 such demonstrations to transform the model’s behavior:
(If you learned some ML years ago, you may know this whole pattern — train a general network once, expensively, then adapt it to tasks cheaply — as transfer learning. In the LLM era nobody says the term anymore, because it stopped being a technique and became the field’s entire structure: the “P” in GPT stands for pre-trained precisely because the model is built to be adapted.)
Conversations are serialized with special tokens marking who’s speaking — the chat template:
<|system|>You are a helpful assistant.<|end|>
<|user|>What's the capital of France?<|end|>
<|assistant|>Paris.<|end|>(When you call a chat API, this is what your list of messages compiles to. The model is still just completing a document — the document is a screenplay, and the API stops generation when the model emits the end-of-turn token.)
What SFT can’t teach well is judgment (the difference between a good answer and a great one), because writing perfect demonstrations of judgment is exactly as hard as having it.
RLHF: grading is easier than writing
The insight that unlocked ChatGPT-level behavior, from the InstructGPT paper: people are much better at comparing answers than producing them. Ask the model “my script crashes with KeyError: 'user_id' — why?” and sample two answers: one dumps a corrected snippet with no explanation. The other explains that the dictionary is missing the key, shows the fix, and mentions .get() for safety. Few users could write the ideal answer — but nearly everyone picks the second, instantly. Reinforcement learning from human feedback (RLHF) converts that cheap signal into training pressure.
Reinforcement learning (RL) is the third training paradigm, alongside the supervised learning of Chapter 1 (imitate labeled outputs) and the self-supervised next-token training of Chapter 7 (the data labels itself). Supervised learning says “here is the correct output; imitate it.” RL says “act, receive a score, and be adjusted so that high-scoring actions become more likely.” No one shows the model what to do — it explores, and the score shapes it. The pipeline:
- Train a reward model. Sample pairs of model outputs, have humans pick the better one (InstructGPT used ~33,000 such comparisons), and train a separate model, typically a clone of the LLM with its final output layer (the token-prediction “head”) swapped for a single score output, to predict human preference. You’ve now compressed human judgment into a function you can call millions of times an hour.
- Optimize against it with RL. The LLM generates responses, the reward model scores them, and an algorithm, classically PPO (proximal policy optimization), adjusts the LLM to make high-scoring responses more probable. The update is scaled by how much a response beats the expected score (the “baseline”), so an average response teaches nothing. Unlike SFT’s “reproduce this exact text,” RL says “produce whatever scores well”: the model can discover behaviors no human demonstrated. (This is reinforcement learning’s original lineage: the same family of ideas from learning Atari and robot control from human preferences , repurposed.)
What PPO actually does.
Strip the RL jargon and PPO is Chapter 1’s loop with a different target. The model samples a response; the reward model hands back one score. And the question is which of the response’s hundreds of token-choices to credit. PPO’s answer is blunt: credit all of them, in proportion to how much better than expected the response scored (the advantage: a learned baseline predicts the expected score, so an average response produces no update at all). Then gradient-ascend: raise the log-probabilities of every token in above-expectation responses, lower them in below-expectation ones. Backpropagation is unchanged, just pointed at “more reward” instead of “match this text.”
The proximal part is the production-grade detail. Each update is clipped so the new policy can’t move far from the one that generated the samples — one weird batch can’t yank the model somewhere strange, and the samples you paid to generate stay approximately on-policy for a few more updates. That stability knob, more than any theoretical property, is why PPO became the default: it made RL boring enough to run unattended at scale. (This per-step clipping is a different leash from the KL penalty below — one keeps each update small, the other keeps the total drift from the original model small.)
One guardrail runs through all of it. KL divergence (Kullback–Leibler) is the standard measure of how different two probability distributions are: for each token the tuned model generates, compare the probability it assigned against the probability its frozen, pre-RL self would have assigned, and average the log-ratios:
It’s zero when the two models would behave identically and grows as they disagree — in Chapter 2’s compression language, it’s the extra bits per token you’d pay encoding the new model’s output with a compression scheme tuned to the old model’s probabilities. RLHF subtracts this from the reward: every step of drift away from the original model now has a price, so the optimizer only moves where the reward gain is worth it. That’s the KL penalty: a leash tethering the updated model to its pre-RL self. Without the leash, the model finds the reward model’s bugs, because the reward model is a lossy proxy for what humans want and a sufficiently strong optimizer will exploit the gap. This failure mode, reward hacking, is post-training’s central demon. Optimize “answers humans rate highly” hard enough and you get confident, flattering answers — the well-documented sycophancy of chat models is widely attributed to exactly this, and “Great question!” is its artifact. Goodhart’s law (when a measure becomes a target, it ceases to be a good measure), running at a million samples an hour.
Reward optimization exacts a quieter tax too: mode collapse. Concentrating probability mass on what the reward model likes means whole regions of the base model’s distribution effectively vanish — ask an aligned model for a joke at any temperature (Chapter 3’s knob) and you’ll keep meeting the same few. Sampling settings can only redistribute what survived training; they can’t resurrect modes the RL already pruned. This is the diversity-loss failure Chapter 3 promised a name for, and it’s why base models remain popular for brainstorming and synthetic-data work.
Two variations:
- Direct Preference Optimization (DPO) collapses the pipeline: a clever loss lets you train on preference pairs directly, no reward model, no RL loop. Far simpler and cheaper; the workhorse of open-source post-training. Frontier labs still mostly run the full RL pipeline — sampling fresh responses from the current model as it trains (“online”), with continually retrained reward models — because it can iterate past the fixed dataset that DPO is anchored to.
- Constitutional AI (Anthropic) substitutes AI feedback for most human feedback: a written constitution of principles, a model that critiques and revises outputs against it, and preference labels generated by the model itself (RLAIF — reinforcement learning from AI feedback). The scalable-oversight bet: use models to supervise models, keeping humans at the top writing principles instead of grading millions of transcripts.
The DPO loss, in one line.
Read it as: push the winner’s probability up and the loser’s down — but measure both relative to the frozen reference model, which is the KL leash smuggled directly into the loss. The derivation’s trick is showing that the optimal RLHF policy and reward model are two views of one object, so you can skip training the reward model entirely. One loss, preference pairs in, aligned model out.
RLVR and reasoning: the 2024 turn
Everything above optimizes for human approval — a fuzzy, hackable signal. The breakthrough behind reasoning models was to find domains where the reward can be verified: the math answer is right or wrong, the code passes the tests or doesn’t. Reinforcement learning from verifiable rewards (RLVR) is RLHF with the squishy reward model replaced by a checker that cannot be flattered.
Given an unhackable reward and room to explore, the model discovers extended reasoning on its own — documented most openly in DeepSeek’s R1 paper . Trained only on “was the final answer right,” R1-Zero (the pure-RL model built before R1 itself) spontaneously learned to produce long chains of thought, to double-check itself, to backtrack — the paper’s researchers watched it learn to say “wait, let me reevaluate this step” with no one having demonstrated it:
(An algorithm note, since R1 made it famous: instead of PPO, R1 runs GRPO, group relative policy optimization, which exploits something verifiable rewards make cheap. PPO trains a whole separate value model just to predict the expected score, the baseline that defines “better than expected.” GRPO skips it: sample a group of answers to the same problem, score them all, and use the group’s average as the baseline — above your siblings, reinforced; below, suppressed. One fewer model to train, a natural fit when scoring is as cheap as running a checker — and now, with its descendants, the default across open reasoning work. It also explains a practical rule: if every answer in a group scores the same (all right, or all wrong), the baseline equals the reward and the gradient is zero, so a run learns only from problems the model sometimes solves. Difficulty curation is where the training signal comes from.)
This is the third scaling axis promised in Chapter 4, test-time compute, made concrete: reasoning models convert inference tokens into accuracy, and the exchange rate is good enough that “think for 10,000 tokens” competes with “be 10× bigger.” It also reframes the economics of Chapters 10 and 11: a reasoning model’s cost lives largely in its inference bill. (OpenAI’s o1 announced the regime; R1 showed everyone how it works.)
Two caveats to keep your model of reasoning models honest. Verifiability is a spectrum — math and code sit at the easy end, and extending RLVR to essay quality or medical advice requires reward models again (with all their hackability; there’s active work on making the graders themselves reason). And recall Chapter 6: the chain of thought is evidence of the computation, not a faithful log of it.
The practical tier: fine-tuning for the rest of us
You will probably never run RLHF, but you may well fine-tune — and the method you’d use is LoRA (low-rank adaptation). The problem it solves is training’s memory arithmetic, landing on your desk: full fine-tuning needs weights, gradients, and optimizer state for every parameter (~16 bytes each, Chapter 10’s tally, so ~130 GB of working state for even an 8B model), which prices out single GPUs. LoRA’s move: freeze every original weight , and next to each big matrix install a bypass of two skinny matrices ( projects the layer’s input down to a tiny width , then projects it back up) so the layer computes . Only and train:
The bet behind it is that a fine-tune’s change to the weights (, whose rank, the number of independent directions it can act in, is at most ) doesn’t need the full matrix’s expressiveness: a fine-tune nudges a mostly-right model. Empirically, rank 8–64 captures most of what full fine-tuning gets. The economics follow: under 1% of the parameters trainable (and only their optimizer state in memory), a single GPU instead of a cluster, and — since the original weights never moved — the adapters (the trained , pairs) can be merged into for zero-latency serving, or kept separate and hot-swapped per customer or task. (The budget variant you’ll see everywhere, QLoRA, squeezes further: hold the frozen base weights in 4-bit (Chapter 11’s quantization) and train the adapters in full precision on top, putting a 70B fine-tune within reach of one card.)
The advice half of this section: fine-tuning teaches form extremely well (your tone, your domain’s jargon) and facts poorly — new knowledge injected via fine-tuning tends to be brittle and to collide with what the model already believes. For facts, retrieval (Chapter 12) usually beats weights. And for strict output syntax (valid JSON matching a schema), you may not need training at all: constrained generation masks away every token that would break the grammar at decode time, making invalid output impossible rather than unlikely (Chapter 12 covers how). Fine-tune for behavior; retrieve for knowledge. Constrain for syntax. And know the tax you’re paying either way: any narrow training erodes some general capability (catastrophic forgetting), which is why labs mix general data into every specialization run — and why a model that’s been aggressively aligned can feel slightly dumber than its base (the “alignment tax,” real but much reduced in modern pipelines).
Hallucination: the failure users meet first
Hallucination — the model confidently asserting things that aren’t true — is not a bug bolted onto an otherwise truthful system; it’s the default behavior of the machine this book has described. A language model never retrieves facts: it continues documents (Chapter 2), and nothing in the pre-training loss distinguishes true from plausible. A confident, well-formatted wrong answer is often literally the most likely next text, and when the fact isn’t in the weights, the distribution still has to put its mass somewhere — it lands on things that sound like answers. Post-training then makes a bad situation worse in a specific, measurable way. Graders, human raters and benchmarks alike, score a blank “I don’t know” as zero and a guess as sometimes-right, so optimization teaches the model to be a confident test-taker (OpenAI’s analysis frames hallucination as exactly this: an artifact of evaluations that reward guessing over calibrated uncertainty). Calibration (training the model to say “I don’t know” when its internal confidence is genuinely low) treats the symptom. For facts that must be right, ground the model in retrieved sources (Chapter 12) and verify what comes out (Chapter 9).
What post-training can’t fix
Hallucination is one instance of a general rule, and a clean mental model to close on: pre-training sets the ceiling — the knowledge and raw capability. Post-training determines how much of the ceiling you can reach through the chat interface, and RLVR genuinely raises it for verifiable domains. But no amount of preference tuning installs knowledge that isn’t there. When a model fails you, ask which layer failed: the ceiling, or the character?
Every section of this chapter also quietly assumed that someone can tell when an answer is better — every technique optimized a measurement, whether a reward model, a verifier, or a human preference. So everything hangs on a question the techniques themselves can’t answer: are the measurements any good? The next chapter is about how this field grades its models, and why you should trust almost none of the numbers in a launch post.
Further reading
- Training language models to follow instructions with human feedback — InstructGPT: the paper that turned GPT-3 into a product; the RLHF pipeline in full.
- Direct Preference Optimization — the simplification that democratized preference tuning.
- Constitutional AI — RLAIF and the scalable-oversight bet.
- DeepSeek-R1 — the most open account of RLVR and emergent reasoning; read the “aha moment” section.
- Why Language Models Hallucinate — the statistical case that hallucination is what training and evaluation reward, not a mysterious defect.
- RLHF: Reinforcement Learning from Human Feedback — Chip Huyen’s explainer; the best single narrative of the classical pipeline.
- The RLHF Book — Lambert’s book-length treatment of everything this chapter compressed: reward-model math, policy gradients, preference data, rejection sampling, and the practitioner details. Where to go if this chapter becomes your job.
- LoRA — the fine-tuning method you’d actually use.