Chapter 4 · Book pages 139–141
RL Foundations for Language Models
The big picture
Supervised fine-tuning teaches a model to imitate demonstrations — but imitation has a ceiling: the model can never exceed the quality of its training data. Reinforcement learning breaks that barrier. By generating novel text, receiving reward feedback, and updating toward higher-reward behaviors, an RL-trained model can discover strategies no human demonstrator ever wrote — outputs that are more helpful, more accurate, and better aligned with human preferences.
Stop 1 — Two paradigms for RL in LLMs
Paradigm 1: alignment via human preferences. The original motivation for RL on LLMs was alignment — making models helpful, harmless, and honest. RLHF (Reinforcement Learning from Human Feedback) trains a reward model from pairwise human judgments ("which response is better?"), then optimizes the policy to maximize that learned reward. DPO simplifies this by eliminating the reward model entirely, converting preferences directly into a supervised loss.
Paradigm 2: capability enhancement via verifiable rewards. More recently RL has been used to teach new capabilities — reasoning, mathematics, code generation. Here the reward comes from verifiable outcomes: did the model produce the correct answer? Did the code pass all tests? DeepSeek-R1 demonstrated that GRPO with rule-based rewards (format correctness + answer accuracy) can train sophisticated chain-of-thought reasoning without any human preference data. This paradigm — RLVR, RL from Verifiable Rewards — is now the dominant approach for building reasoning models and agentic systems.
Interactive · Paradigm comparator
Pick a dimension and see how RLHF/DPO and RLVR answer it side by side.
Go deeper: the book's framing of both paradigms
Both RLHF and DPO produce aligned assistants that follow instructions and respect safety constraints; DPO trades flexibility for simplicity by skipping RL entirely (chapter 6 details the conversion). RLVR's rule-based rewards need no preference data at all — which is why it scales to domains like math and code where correctness is cheap to check but human taste is not the point. Book §4.1, p. 139; §4.4, p. 141.
Stop 2 — The shared foundation
Despite their different goals, both paradigms run on the same four pieces of machinery:
Go deeper: why a KL constraint at all?
Without an anchor, a policy chasing a learned reward can drift into degenerate solutions — text that games the reward model while no longer resembling language. The KL constraint keeps the trained policy close to the reference (the SFT model), buying safety at the cost of reduced exploration — a trade-off stop 5 revisits. Book §4.1, p. 139; §4.3, p. 140–141.
Stop 3 — Text generation as an MDP
The key insight that makes RL applicable to language models is recasting autoregressive generation as a Markov Decision Process. Think of the LLM as an agent writing a response one token at a time: it looks at everything written so far (the state), chooses the next word (the action), and the page grows by one token (the transition). When the response is complete, a judge scores it (the reward).
Watch one tiny canned generation step through this loop:
Interactive · Generation as an MDP, token by token
Step a toy response through state → action → deterministic append, with reward arriving only at the end. (Illustrative example, not from the book.)
Go deeper: reading each MDP element in LLM terms
Compare with chapter 3's generic 5-tuple: S = all token sequences (infinite in practice), A = the vocabulary, P = append (deterministic — the one trivial part of language RL), R = a judge's score delivered once per episode, γ = 1.0. This is why stop 5 can say LLM RL is model-free almost by accident: the dynamics never needed modeling in the first place. Book §4.2, p. 140.
Stop 4 — The RLHF pipeline
The classic RLHF pipeline has four stages: (1) SFT — train a base model on high-quality demonstrations to produce a policy πSFT that can follow instructions; (2) reward model training — collect human preference comparisons (yw ≻ yl for the same prompt) and train a reward model Rφ(x, y) using the Bradley-Terry objective; (3) RL optimization — optimize the policy via PPO or GRPO against the reward model's signal, subject to a KL constraint against πSFT; (4) evaluation and iteration — evaluate the aligned model, collect new failure cases, and iterate.
For RLVR, stages 1–2 are replaced — the SFT model trains on reasoning traces, and a verifier (e.g. checking mathematical correctness) replaces the reward model — while stage 3 stays exactly the same. Explore both versions:
Interactive · RLHF pipeline explorer
Click through the four stages, then flip the RLVR toggle to see stages 1–2 swapped out.
Go deeper: where each pipeline stage gets its own chapter
Stage 1 → chapter 10 (SFT best practices: packing, templates, data mixing — and how SFT quality determines the RL ceiling). Stage 2 → chapter 9 (Bradley-Terry models, process vs outcome rewards, rule-based rewards for RLVR). Stage 3 → chapters 5 and 7 (PPO, GRPO). The iteration loop of stage 4 is where evaluation plugs in (site cross-link, not from this chapter: evaluation gets its own treatment in chapter 14). Book §4.3–4.4, p. 140–141.
Stop 5 — How LLM RL differs from classical RL
Five differences separate this setting from the game-playing RL of chapter 3:
Together these explain why PPO and GRPO dominate over DQN-style approaches for LLMs — the same conclusion chapter 3 reached from the action-space side.
Go deeper: connecting the differences back to chapter 3
Deterministic transitions kill the need for a world model (model-free by default). The 32K–128K action space kills value-based methods (no tractable max over Q). The KL anchor is the practical answer to reward hacking from chapter 3, stop 10. And GRPO's group normalization is a baseline computed from group statistics — the critic's job done without a critic. Book §4.3, p. 140; ch. 7 preview p. 141.
Stop 6 — Roadmap of Part II
Seven chapters build the complete RL-for-LLMs toolkit:
Go deeper: the book's own chapter summaries
PPO is described as the workhorse behind GPT-4 and Claude; DPO as bypassing RL entirely via a contrastive supervised loss; GRPO as the dominant choice for reasoning model training. Chapter 8 adds guidance on method selection across Online DPO, KTO, and Best-of-N; chapter 11 covers distributed training at scale. Book §4.4, p. 141.