Skip to content

Reinforcement Learning: An Introduction (2nd edition)

optionalcorefundamentalbookrubric 9/122018 · MIT Press (2nd edition) · ~900 min

Richard S. Sutton, Andrew G. Barto

Status

TL;DR. The standard RL textbook, free online as a PDF. Do not read it cover to cover for the LLM path. Chapters 3–6 and 13 (about 114 pages) give you MDPs, Bellman equations, dynamic programming, Monte Carlo, TD learning and policy gradients with the cleanest notation anywhere. Section 11.3 (the deadly triad), 12.1 (the λ-return) and 17.4 (designing reward signals) are short, high-value detours.

Why it matters now. When an LLM-RL paper writes vπv_\pi, qπq_\pi, GtG_t or “semi-gradient”, it uses this book’s notation. Section 16.7 (personalized web services) is an IR-adjacent case study of contextual bandits. And Section 17.4 on reward design reads like a prologue to the reward hacking literature.

  • Official page: incompleteideas.net/book/the-book-2nd.html, with the full PDF, code, errata and solutions links. Second edition, MIT Press, 2018.
  • Structure: Ch 1 introduction; Part I tabular methods (Ch 2–8); Part II approximate methods (Ch 9–13); Part III looking deeper (Ch 14–17: psychology, neuroscience, applications, frontiers). The preface marks sections that are more difficult and not essential to the rest of the book with an asterisk.
  • Page numbers below are the printed page numbers in that PDF.
Sutton and Barto chapters to read for the LLM RL path Three columns for the book parts. Part I tabular methods: chapter 2 bandits, chapters 3 to 6 highlighted as core, chapter 7 n-step with detour 7.1, chapter 8 planning. Part II approximate methods: chapters 9 and 10, chapter 11 with detour 11.3 deadly triad, chapter 12 with detour 12.1 lambda-return, chapter 13 policy gradient highlighted as core. Part III: chapters 14 and 15 dashed as skip, chapter 16 applications, chapter 17 with detour 17.4 reward design. Part I · Tabular (Ch 2–8) Ch 2 Bandits Ch 3 Finite MDPs Ch 4 Dynamic programming Ch 5 Monte Carlo Ch 6 TD, Sarsa, Q-learning Ch 7 n-step → read 7.1 Ch 8 Planning Part II · Approximate (Ch 9–13) Ch 9–10 Approximation Ch 11 → 11.3 deadly triad Ch 12 → 12.1 λ-return Ch 13 Policy gradient Part III · Looking deeper Ch 14 Psychology Ch 15 Neuroscience Ch 16 Applications Ch 17 → 17.4 rewards core: read fully short detour later / optional dashed: skip
Original sketch. The book's three parts, with the chapters to read for the LLM path highlighted, the short detours marked, and the rest left for later.
Ch (page)Title and sections to readPrepares you forPriority
1 (p. 1)IntroductionVocabularySkim
2 (p. 25)Multi-armed Bandits; 2.8 Gradient Bandit Algorithms (p. 37) is the first baselineEntropy mechanism (exploration), REINFORCE (baseline idea)Optional
3 (p. 47)Finite MDPs: 3.1 agent–environment interface, 3.3 returns and episodes, 3.5 policies and value functions (p. 58; Bellman equation 3.14), 3.6 optimal policiesMDPs and returns, Value functions and BellmanCore
4 (p. 73)Dynamic Programming: 4.1 policy evaluation, 4.2 improvement, 4.3 policy iteration, 4.4 value iteration, 4.6 generalized policy iterationValue functions and BellmanCore
5 (p. 91)Monte Carlo Methods; 5.5 off-policy prediction via importance sampling (p. 103)MC, TD, Q-learning; the ratio in PPOCore
6 (p. 119)Temporal-Difference Learning: 6.1 TD prediction (update 6.2), 6.4 Sarsa, 6.5 Q-learning (p. 131; update 6.8), 6.7 maximization bias and double learningMC, TD, Q-learning, DQNCore
7 (p. 141)n-step BootstrappingGAE (n-step advantages)Skim 7.1
8 (p. 159)Planning and Learning with Tabular Methods: 8.2 Dyna, 8.10 rollout, 8.11 MCTSPlanning in agents, stage 8Later
9–10 (p. 197, 243)On-policy prediction and control with approximation (semi-gradient methods, 9.7 neural networks)Value heads in Actor-criticSkim 9.3
11 (p. 257)Off-policy Methods with Approximation; 11.3 The Deadly Triad (p. 264)DQN, why critic-free methods are attractiveRead 11.3
12 (p. 287)Eligibility Traces; 12.1 The λ-return (p. 288)GAERead 12.1
13 (p. 321)Policy Gradient Methods: 13.1 advantages of policy approximation (Example 13.1), 13.2 policy gradient theorem (p. 324), 13.3 REINFORCE (p. 326), 13.4 with baseline (p. 329), 13.5 actor–critic (p. 331)REINFORCE, Actor-critic, RLOO, GRPOCore: most important
14–15 (p. 341, 377)Psychology; NeuroscienceNot on the LLM pathSkip
16 (p. 421)Applications: 16.5 Atari, 16.6 Go, 16.7 personalized web servicesContext; 16.7 for IR readersOptional
17 (p. 459)Frontiers: 17.3 observations and state, 17.4 designing reward signals (p. 469)Rewards map, Specification gamingRead 17.4

Suggested order: Ch 3 → 4 → 5 (through 5.5) → 6 (through 6.5) → 13 → 12.1 → 11.3 → 17.4. Pair each with the matching Silver lecture if you prefer to watch first.

The equations you will see quoted everywhere

Section titled “The equations you will see quoted everywhere”
  • Bellman equation for vπv_\pi (3.14): vπ(s)=∑aπ(a∣s)∑s′,rp(s′,r∣s,a) [r+γvπ(s′)]v_\pi(s) = \sum_a \pi(a\mid s)\sum_{s',r} p(s',r\mid s,a)\,[r + \gamma v_\pi(s')].
  • TD(0) update (6.2): V(St)←V(St)+α [Rt+1+γV(St+1)−V(St)]V(S_t) \leftarrow V(S_t) + \alpha\,[R_{t+1} + \gamma V(S_{t+1}) - V(S_t)]. The bracket is the TD error.
  • Q-learning (6.8): the same, with target Rt+1+γmax⁡aQ(St+1,a)R_{t+1} + \gamma \max_a Q(S_{t+1}, a). It learns q∗q_* whatever policy generated the data.
  • REINFORCE (13.8): θt+1=θt+α Gt ∇π(At∣St,θt)/π(At∣St,θt)\theta_{t+1} = \theta_t + \alpha\, G_t \, \nabla\pi(A_t\mid S_t,\theta_t)/\pi(A_t\mid S_t,\theta_t). The ratio is ∇ln⁡π\nabla \ln \pi, which the book calls the eligibility vector. Dividing by π\pi stops frequently chosen actions from winning just because they are updated more often. The text works with γ=1\gamma = 1; the boxed pseudocode is the discounted version and therefore carries an extra γt\gamma^t.
  • REINFORCE with baseline (13.11): replace GtG_t with Gt−b(St)G_t - b(S_t). Because ∑ab(s)∇π(a∣s)=b(s)∇1=0\sum_a b(s)\nabla\pi(a\mid s) = b(s)\nabla 1 = 0, the expected update is unchanged for any baseline that does not depend on the action, but the variance can drop a lot (Figure 13.2, short corridor).
  • The deadly triad (11.3): function approximation + bootstrapping + off-policy training. With all three, instability and divergence can occur, even in planning with a known model. With any two, it can be avoided.

Why stochastic policies matter (Example 13.1). In the “short corridor with switched actions”, every state looks the same to the features. An ε-greedy action-value method can only choose between “mostly right” and “mostly left”, worth less than −44 and −82 with ε = 0.1. The best stochastic policy picks right with probability about 0.59 and gets about −11.6. A policy-gradient method can learn that probability directly.

Worked example: the search toy in the book’s notation

Section titled “Worked example: the search toy in the book’s notation”

Toy (shared with the course map): in s₀ the agent can search (reward −0.1, go to s₁) or answer (+1 with probability 0.2). In s₁, answer pays +1 with probability 0.9 and search costs −0.1 and stays in s₁. Take γ = 0.9.

  1. Evaluate a policy with (3.14). Let π search from s₀ with probability 0.5 and always answer from s₁. Then vπ(s1)=0.9v_\pi(s_1) = 0.9 and vπ(s0)=0.5⋅0.2+0.5⋅(−0.1+0.9⋅0.9)=0.455v_\pi(s_0) = 0.5\cdot 0.2 + 0.5\cdot(-0.1 + 0.9\cdot 0.9) = 0.455.
  2. Improve (4.2). qπ(s0,search)=0.71>qπ(s0,answer)=0.2q_\pi(s_0,\text{search}) = 0.71 > q_\pi(s_0,\text{answer}) = 0.2, so the greedy policy always searches first. Its value 0.71 satisfies the optimality equation: policy iteration is done.
  3. Learn from samples (6.2). Suppose V(s0)=0.5V(s_0) = 0.5 and V(s1)=0.9V(s_1) = 0.9, and the agent searches. The TD error is −0.1+0.9⋅0.9−0.5=0.21-0.1 + 0.9\cdot 0.9 - 0.5 = 0.21, so V(s₀) moves up by 0.21α0.21\alpha without waiting for the episode to finish.
  4. Policy gradient (13.11). With π(search∣s0)=σ(θ)\pi(\text{search}\mid s_0) = \sigma(\theta) at θ=0\theta = 0, one episode “search, then correct answer” has G0=−0.1+0.9⋅1=0.8G_0 = -0.1 + 0.9\cdot 1 = 0.8. With baseline b(s0)=0.455b(s_0) = 0.455, the update is α⋅(0.8−0.455)⋅(1−0.5)≈0.17α\alpha\cdot(0.8 - 0.455)\cdot(1 - 0.5) \approx 0.17\alpha.
  5. Translate. For an LLM, s₀ is a prompt, the actions are tokens, and G0G_0 is the end-of-sequence reward. Step 4 with a per-prompt group mean as bb is the core of RLOO and GRPO.
  • Mostly tabular and linear function approximation. Deep RL appears in case studies (Ch 16), not as algorithms such as TRPO or PPO.
  • Nothing on reward models from human preferences, KL-regularized RLHF, DPO or verifiable rewards.
  • Dense and long: the full book is over 500 pages. Reading it in order delays the LLM material by months.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    Use the Bellman equation for v_π (equation 3.14) on the search toy with γ = 0.9 and the policy that searches from s0 with probability 0.5 and always answers from s1. Compute v_π(s1) and v_π(s0). Then do one policy-improvement step (Section 4.2): what is the new policy, and is it optimal?

    What a strong answer covers
    • v_π(s1) = 0.9, because the policy always answers from s1.
    • v_π(s0) = 0.5·0.2 + 0.5·(−0.1 + 0.9·0.9) = 0.1 + 0.355 = 0.455.
    • Greedy improvement compares q_π(s0, search) = 0.71 with q_π(s0, answer) = 0.2, so the new policy always searches from s0 (and still answers from s1).
    • Its value is 0.71, which satisfies the Bellman optimality equation, so policy iteration has converged after one improvement step.
  2. Mechanism

    The REINFORCE update (13.8) multiplies the return by ∇π(A|S)/π(A|S), not by ∇π(A|S). Explain, in the book's own terms, why the division by π is needed, and what the boxed pseudocode's extra γ^t factor is doing.

    What a strong answer covers
    • ∇π/π = ∇ ln π, the eligibility vector. The policy gradient theorem sums over actions; sampling actions from π introduces a factor π that the division cancels.
    • Book's intuition: without the division, frequently selected actions would win out because updates move in their direction more often, even if they do not have the highest return.
    • The text derives the update for the undiscounted case (γ = 1); the boxed algorithm is the general discounted version, which carries γ^t.
    • REINFORCE uses the complete return G_t, so it is a Monte Carlo method defined for episodic tasks with updates after the episode ends.
  3. What if…

    Section 13.4 adds a baseline b(S) to REINFORCE (13.10–13.11), and Figure 13.2 shows it learning much faster on the short corridor. Prove that the baseline adds no bias, then design the matching ablation for an LLM policy trained with an outcome reward.

    What a strong answer covers
    • Σ_a b(s)∇π(a|s) = b(s)∇Σ_a π(a|s) = b(s)∇1 = 0, so the expected update is unchanged for any baseline that does not depend on the action.
    • It changes the variance: a state-dependent baseline separates better and worse actions in states where all actions have high or all have low value.
    • LLM ablation arms: no baseline, a running batch mean, a per-prompt group mean (as in GRPO and RLOO), and a learned value head (as in PPO), at matched samples.
    • Measure gradient-estimate variance, reward against samples, and stability across seeds; keep the prompt set, reward and KL setting fixed.
  4. Critique

    A colleague claims a value-based method with ε-greedy action selection can always match a policy-gradient method if you tune ε. Use Example 13.1 (short corridor with switched actions) to critique this, and say why the same issue can appear for a search agent with a truncated context window.

    What a strong answer covers
    • In the corridor, all states look identical to the features, so an action-value method can only choose between "mostly right" and "mostly left": values below −44 and −82 with ε = 0.1.
    • The best stochastic policy picks right with probability about 0.59 and reaches about −11.6. Only a method that learns action probabilities directly can represent it.
    • The underlying issue is state aliasing (partial observability), not tuning; Section 17.3 treats observations versus state.
    • A search agent whose context drops earlier results can see identical observations in different true states, so a stochastic policy, or a better state representation, may be required.
  5. Connect

    Section 11.3 names the deadly triad: function approximation, bootstrapping and off-policy training. Classify DQN, PPO with a learned critic as used in RLHF, and critic-free GRPO by which elements they contain, and say what each does about the risk.

    What a strong answer covers
    • DQN has all three: a neural Q-network, a bootstrapped max target, and replay of old transitions. Fixed target networks and replay are its stabilisers.
    • PPO for RLHF: the critic is a neural network and its targets bootstrap when λ is below 1; reusing a batch for several epochs makes the data slightly off-policy, which the ratio and clipping partly correct.
    • GRPO drops the critic, so there is no bootstrapping in the advantage; the triad's instability cannot arise through a value function.
    • The book notes that with any two of the three, instability can be avoided, which is one way to read the move away from learned critics in RLVR.
  6. Design

    Section 17.4 says reward design is critical, warns of sparse rewards (the "plateau problem") and of agents finding unexpected ways to get reward. Design a reward for a multi-step search agent answering factoid questions that addresses sparsity without opening an obvious hack. Say how you would detect a hack.

    What a strong answer covers
    • Base reward: +1 for a correct final answer judged against a held-out reference, 0 otherwise; this is sparse but hard to game.
    • Dense help: a small per-step cost to discourage endless searching, and possibly a capped bonus for retrieving a gold-relevant document, checked against relevance labels the agent never sees.
    • Hack risks: shaping terms that pay for retrieval actions or citation strings can be farmed without answering correctly.
    • Detection: track the shaped reward and an independent end-task metric separately; a rising proxy with flat accuracy, or growing search counts, indicates gaming.

Done with this page?

Status