Reinforcement Learning

Dive into Deep Learning · §14

Foundations of Reinforcement Learning
Markov decision processes · dynamic programming · temporal differences · exploration · imitation · optimal control · policy gradients · variance reduction

Acting Changes Which Data the Learner Sees Next

The Sequential Decision Loop

In supervised learning the dataset sits still, whereas a sequential agent’s decisions alter future states and determine which data arrive next:

  • Policy \pi(a_t \mid s_t): Maps the current state s_t to an action a_t (such as a motor torque, grid move, or generated token).
  • Environment dynamics P(s_{t+1} \mid s_t, a_t): Evolves the state stochastically and emits a scalar reward r_t.
  • Closed-loop feedback: Repeating the interaction generates a trajectory \tau = (s_0, a_0, r_0, s_1, a_1, r_1, \ldots) whose distribution depends on \pi.

Benchmark 1: Slippery Ice Reverses Shortest-Path Logic

Tabular MDP Benchmark

Our first running benchmark is 4 \times 4 FrozenLake-v1, small enough to solve to machine precision yet stochastic enough to defeat naive greedy heuristics:

  • Slippery transition kernel: Each command moves in the intended direction with probability 1/3 and slips perpendicularly to each side with probability 1/3.
  • Shortest path vs. slip-aware optimum: Following the 6-move calm-ice shortest path succeeds in only 4.5\% of episodes because slips drop it into adjacent holes.
  • Risk-minimizing control: The optimal policy \pi^* reaches the goal in 73.0\% of episodes—pointing away from the goal in four cells to eliminate hole risk.

Benchmark 2: Language Generation as a Verifier MDP

Language Model Post-Training Benchmark

  • Collapsed one-step view: With deterministic token appending and terminal reward r(x, y) \in \{0, 1\}, an entire response y acts as one action at prompt x.
  • Reference vs. ceiling: The uniform softmax reference policy passes 6.2\% of the time (\approx 1/8 on 2+2 and 3*4, 0 on unsolvable 8*8 and 9*9), against a 50\% ceiling.
  • Reward hacking hazard: A ninth candidate hedges (“4, 12, 64 or 81”); an exact checker scores it 0, whereas a lenient substring checker pays 1.0 on every prompt.

Chapter 14 Roadmap: From Exact Tables to Neural Critics

Architectural & Algorithmic Progression

  • Known to unknown physics (§§14.1–14.4): Formulate MDPs, solve Bellman contraction sweeps, learn Q^* from single samples, and bound exploration regret via UCB and Thompson sampling.
  • Demonstrations & continuous physics (§§14.5–14.6): Diagnose O(\varepsilon T^2) cloning shift (DAgger), and solve continuous linear/nonlinear control via Riccati LQR, iLQR, and receding-horizon MPC.
  • Policy gradients & neural critics (§§14.7–14.9): Differentiate stochastic policies via REINFORCE, baselines, RLOO, GRPO, and tanh MLP critics.

Concept Check: Framing Sequential Decision Problems

Check Your Understanding

Work through these three foundational questions before diving into §14.1:

  1. Credit assignment & discounting: Which discount factor \gamma gives an effective planning horizon 1/(1-\gamma) of 50 steps, and how much weight does a reward 50 steps away receive?
  2. Stochastic control: At cell 9 of slippery FrozenLake (hole 5 directly above), why does the optimal policy command down even though down slides sideways two times in three?
  3. Reward specification: Why does a lenient verifier that checks whether the true answer appears as a substring fail on the 4-prompt arithmetic task?

Answers:

  1. Setting 1/(1-\gamma) = 50 yields \gamma = 0.98, and a reward one horizon away carries weight 0.98^{50} \approx e^{-1} \approx 0.368.
  2. Commanding left, right, or up from cell 9 slips into hole 5 with probability 1/3, whereas down has 0 one-step hole risk and lands on safe cells 8, 13, or 10.
  3. The optimizer exploits the specification by outputting the hedge “one of 4, 12, 64 or 81” on every prompt, earning 1.0 without solving the arithmetic.