Chapter 16
Frontiers
Throughout this companion, from the bandits of Part I to the case studies of the previous chapter (Chapter 15), three assumptions have been held fixed: the agent predicts one thing, the sum of future rewards; it acts at one time scale, the time step of the MDP; and it is handed a state with the Markov property. Each was a simplification, and each fails for any agent living in a world as rich as ours. Sutton and Barto’s last chapter relaxes them in turn: value functions become predictions of arbitrary signals, actions become temporally extended options, and states become something the agent must construct from observations.Richard S. Sutton and Andrew G. Barto. Reinforcement Learning: An Introduction. Adaptive Computation and Machine Learning. MIT Press, Cambridge, MA, second edition, 2018. ISBN 978-0-262-03924-6. URL http://incompleteideas.net/book/the-book-2nd.html It then turns to the one input that was never questioned, the reward signal, and asks how it should be designed. We follow the same path, with proofs where the book only describes (the Bellman equations of option models, the invariance of potential-based shaping) and symbolic checks on small examples, and close with what happened next: distributional and offline reinforcement learning, learned world models, the reward hypothesis debate and the problem of learning continually, before a last look back over the whole companion.
16.1General Value Functions and Auxiliary Tasks#
The value functions of this companion have grown steadily more general. Off-policy learning let them refer to any target policy; Chapter 12 let the discount depend on the state, so that the horizon of a prediction can end at a particular event. The last step is to replace the reward by an arbitrary signal. Call the signal being accumulated the cumulant ; it may be a sensor reading, a feature, a sound, or another prediction.
Definition 16.1 (General Value Function). Given a policy , a termination (continuation) function and a cumulant , the general value function is
(16.1)With and we recover . Splitting off the first term of the sum gives , a Bellman equation of exactly the usual form. Everything we know about learning (TD, eligibility traces, gradient-TD for the off-policy case) therefore applies unchanged; only the “reward” and the “discount” in the update have new meanings. If the cumulant is received on arrival in a state, , and is the state-transition matrix under and , the equation reads , so
(16.2)16.1.1In Wolfram Language#
We solve (16.2) on a two-state chain that stays in state 1 with probability and in state 2 with probability .
A GVF is a value function with a different cumulant and state-dependent continuation ; the same linear solve applies. Shown is the value of state 1; that of state 2 follows by exchanging the labels of the two states (, ).const Pg = await wl`{{p, 1 - p}, {1 - q, q}}`
const gvf = await wl`Function[{c, g}, Simplify[Inverse[IdentityMatrix[2] - ${Pg} . DiagonalMatrix[g]] . ${Pg} . c]]`
await show`First[${gvf}[{Subscript[c, 1], Subscript[c, 2]}, {Subscript[\[Gamma], 1], Subscript[\[Gamma], 2]}]]`await show`${gvf}[{1, 1}, {1, 0}]`await show`Simplify[${gvf}[{Subscript[r, 1], Subscript[r, 2]}, {\[Gamma], \[Gamma]}] - Inverse[IdentityMatrix[2] - \[Gamma] ${Pg}] . ${Pg} . {Subscript[r, 1], Subscript[r, 2]}]`The answer of the second check, the geometric mean waiting time , is a piece of knowledge about the world that has nothing to do with reward, yet it was obtained as a value function.
16.1.2Why Predict Many Things?#
An agent could learn thousands of GVFs in parallel from one stream of experience, all off-policy. Sutton and colleagues built such an architecture, Horde, on a mobile robot, with each “demon” a GVF learned by gradient-TD in real time.Richard S. Sutton, Joseph Modayil, Michael Delp, Thomas Degris, Patrick M. Pilarski, Adam White, and Doina Precup. Horde: A Scalable Real-Time Architecture for Learning Knowledge from Unsupervised Sensorimotor Interaction. In Proceedings of the 10th International Conference on Autonomous Agents and Multiagent Systems (AAMAS), pages 761–768, 2011. doi: 10.65109/qdhn7183 Why would one want this? The book gives three reasons.
First, auxiliary tasks shape representations. If a network has a shared body and several heads, one estimating the main value function and others predicting pixel changes, the next reward or other GVFs, the gradients of all heads train the shared features. Predictions with short horizons and clear causes are easier to learn and may yield features (objects, positions, velocities) that the main task needs; the UNREAL agent sped up learning on 3D mazes and Atari considerably in this way.Max Jaderberg, Volodymyr Mnih, Wojciech Marian Czarnecki, Tom Schaul, Joel Z. Leibo, David Silver, and Koray Kavukcuoglu. Reinforcement Learning with Unsupervised Auxiliary Tasks. In International Conference on Learning Representations (ICLR), 2017
Second, learned predictions can trigger built-in reactions, as in classical conditioning (Chapter 14): the blink is innate, the prediction of the air puff is learned. A vacuum robot could head for its charger whenever a learned GVF predicting “battery empty before reaching the charger” exceeds a threshold. Modayil and Sutton called this Pavlovian control.
Third, and most important, a large collection of GVFs can serve as a model of the world and as the basis of the agent state. The next two sections make each of these precise.
16.2Temporal Abstraction via Options#
People plan a journey in terms of flights and taxis, not muscle twitches, yet they also catch balls at the level of twitches. Can a single MDP framework accommodate both? The idea is to keep the MDP at its finest time scale and add temporally extended courses of action that can be selected like actions.
Definition 16.2 (Option). An option is a policy together with a termination function . Executing from means choosing , and then, at each subsequent state , stopping with probability or otherwise continuing with . The duration is the number of steps until it stops. A primitive action is the option with and .
The book writes the termination function as and treats it like the continuation function of a GVF, with for a one-step action;Read literally, Sutton and Barto (2018, p. 461) say that an option “terminates at with probability ”, but then give primitive actions and use as a GVF discount, both of which require to be the probability of continuing. We use the standard of Sutton, Precup and Singh (1999), the probability of stopping. we follow the original paper on optionsRichard S. Sutton, Doina Precup, and Satinder Singh. Between MDPs and Semi-MDPs: A Framework for Temporal Abstraction in Reinforcement Learning. Artificial Intelligence, 112(1–2):181–211, 1999. doi: 10.1016/S0004-3702(99)00052-1 and write for the probability of stopping, so that the continuation probability is . A policy over options , choosing among the options available in and running each to termination, is a hierarchical policy; its option-value function is the expected return from starting in and following afterwards.
16.2.1Option Models and Their Bellman Equations#
The model of a primitive action is its expected reward and its next-state distribution. The model of an option must account for the random duration , and does so by folding the discount into the transition part:
(16.3)Because of the factor , : the transition part is a discounted distribution, and the discount no longer appears separately.
Theorem 16.3 (Bellman Equations with Options). For a hierarchical policy ,
(16.4)and the optimal values over the options in satisfy . Moreover the two parts of the option model satisfy their own Bellman equations under :
(16.5)where is the expected one-step reward and the one-step transition matrix under .
Proof. Start in and let be its duration. The return from splits at : . The first sum has expectation by definition. For the second, condition on ; by the Markov property, after termination the process restarts from under , so , and
Averaging over gives (16.4). The optimality equation follows in the same way, since an optimal hierarchical policy may be taken greedy with respect to its own option values, exactly as in Chapter 4. For (16.5), condition on the first step: the option collects and moves to ; with probability it stops there, contributing to the transition part and nothing more to the reward part; otherwise it continues as a fresh execution of from , discounted by one more factor . □
The theorem has two readings. The first equation is the Bellman equation of a semi-Markov decision process: decisions are made at the (random) termination times, and planning methods such as value iteration, , run unchanged with options in place of actions. If contains all primitive actions this converges to ; if it contains only a few well-chosen options it converges to the best hierarchical policy restricted to them, usually much faster, because each backup jumps over many time steps. The second reading is that the model equations (16.5) are GVF Bellman equations: is the GVF with policy , cumulant and continuation ; and is the GVF with the same policy and continuation and cumulant , which pays out only at termination in . Option models are collections of GVFs, and can be learned with the methods of Parts I and II.
In matrix form, with , (16.5) gives and .
A corridor whose option “walk right until state 3” advances with probability per step (otherwise slips in place), with reward per step and . Shown: and the row .const Pw = await wl`{{1 - q, q, 0}, {0, 1 - q, q}, {0, 0, 1}}`
const Bw = await wl`DiagonalMatrix[{0, 0, 1}]`
const Mw = await wl`Inverse[IdentityMatrix[3] - \[Gamma] ${Pw} . (IdentityMatrix[3] - ${Bw})]`
await show`Simplify[{(${Mw} . {-1, -1, -1})[[1]], (${Mw} . (\[Gamma] ${Pw} . ${Bw}))[[1]]}]`The result is what a direct argument gives: each of the two corridor steps takes a geometric number of tries, and , so is its square. The model compresses an unbounded number of primitive steps into two numbers per state, and value iteration over options needs one backup where primitive actions need many.
16.2.2Learning with Options#
The simplest learning rule treats an option as one big action. SMDP Q-learning waits until an option started in terminates in after steps with discounted reward , and updates . It learns only about the option being executed, and only once per execution. Intra-option learning does better by noting that each step of experience is relevant to every option that would have taken the same action: for each deterministic with ,
(16.6)The value on arrival continues the option if it does not terminate and otherwise lets the agent choose afresh. Since the options being updated are not the one being followed, intra-option learning is off-policy learning, with all the difficulties of Chapter 11 when combined with function approximation.
16.3Observations and State#
Tabular methods assumed that the agent observes the state of the environment. Function approximation already weakens this: a parameterization that ignores some state variable behaves exactly as if that variable were unobservable, so every result of Part II covers some partial observability. But to build states we need an explicit treatment. Sutton and Barto outline it in four steps.
1. Observations. The environment emits observations , not states; the reward is a known function of the observation. The data stream is
2. Histories and Markov states. The history contains everything the agent can know. A state is a summary .
Definition 16.4 (Markov State). A function of histories has the Markov property if, for all histories ,
(16.7)for all observations and actions .
One-step predictability is enough for everything else. A test is a future sequence , with probability of observing the ’s if the ’s are taken. By the chain rule, , and each factor depends on the extended history only through its -value if can be updated incrementally (step 3); hence a Markov state determines the probability of every test, every GVF, and an optimal policy of the form .
3. State-update functions. For computation we need the state to be compact and to be updated recursively,
(16.8)The function is the state-update function. The identity is Markov and is updated by appending, but it never recurs, so nothing could be learned in tabular form. The classical compact Markov state is the belief state of a POMDP.Leslie Pack Kaelbling, Michael L. Littman, and Anthony R. Cassandra. Planning and Acting in Partially Observable Stochastic Domains. Artificial Intelligence, 101(1–2):99–134, 1998. doi: 10.1016/S0004-3702(98)00023-X Assume a latent state with known dynamics and observation probabilities . The belief is updated by Bayes’ rule:
(16.9)The belief has a fixed size and is Markov, but computing it requires a correct model of hidden quantities that the agent never sees, and planning over beliefs is intractable in general; Sutton and Barto do not recommend it as a route to AI. Predictive state representations instead use as state the vector of probabilities of a set of core tests, quantities defined entirely by observable data and therefore learnable in principle.Michael L. Littman, Richard S. Sutton, and Satinder Singh. Predictive Representations of State. In T. G. Dietterich, S. Becker, and Z. Ghahramani, editors, Advances in Neural Information Processing Systems 14, pages 1555–1561. MIT Press, 2002. URL https://proceedings.neurips.cc/paper/2001/hash/1e4d36177d71bbb3558e43af9577d70e-Abstract.html
4. Approximate state. Finally, states must be approximate. The simplest is the last observation; better is the last observations and actions, updated by shifting, which is DQN’s frame stack (Section 15.5); more powerful is a learned recurrent update . When the Markov property holds only approximately, long-term predictions can degrade badly and there is no theory to say how much. The working hypothesis, the same as for auxiliary tasks, is that a state that is good for many predictions will be good for others, and learning to support many GVFs is, in reinforcement learning, what representation learning means.
16.3.1In Wolfram Language#
We run (16.9) on a two-state hidden process that switches with probability per step, observed through a sensor that reports the true state with probability ; the belief vector is and the observation is “state 1”.
One Bayes-filter step: predict with the transition matrix, multiply by the likelihood of the observation, normalize. Shown is the new probability of state 1; that of state 2 is its complement.const bel = await wl`Function[{s, T, O}, (s . T) O/Total[(s . T) O]]`
await show`Simplify[First[${bel}[{b, 1 - b}, {{1 - e, e}, {e, 1 - e}}, {q, 1 - q}]]]`await show`Simplify[{${bel}[{b, 1 - b}, IdentityMatrix[2], {q, 1 - q}][[1]], #[[1]]/#[[2]] &[Nest[${bel}[#, IdentityMatrix[2], {q, 1 - q}] &, {b, 1 - b}, 3]]}]`With a static hidden state each report multiplies the odds by , so the belief is a sufficient statistic that a counter of reports could replace; when the state moves () old reports must be forgotten at the right rate, and that rate is what the belief update encodes (Exercise 16.9).
16.4Designing Reward Signals#
The reward signal is the one part of the problem that reinforcement learning takes as given, and the one on which success most depends. It is easy to design when the goal is a score or a win, and hard when it is “be a useful household robot”. Three difficulties recur. The goal may be hard to translate into a scalar signal. An optimizer finds unintended ways of collecting reward. And even a correct reward may be so sparse that the agent never encounters it, wandering on what Minsky called a plateau.
The tempting fix, rewarding subgoals, can change what is optimal: an agent paid for approaching the goal may learn to circle near it (Exercise 16.7). A safer way to inject knowledge is to leave the reward alone and initialize the value function, for example with initially, so that a guess of guides early behavior while the asymptotic solution is unchanged. A precise form of reward modification with the same guarantee was found by Ng, Harada and Russell.Andrew Y. Ng, Daishi Harada, and Stuart Russell. Policy Invariance under Reward Transformations: Theory and Application to Reward Shaping. In Proceedings of the Sixteenth International Conference on Machine Learning (ICML), pages 278–287. Morgan Kaufmann, 1999
Theorem 16.5 (Potential-Based Shaping Preserves Optimal Policies). Let be any function with , and replace every reward by the shaped reward
(16.10)Then for every policy , and . Consequently , and the two problems have the same optimal policies.
Proof. Fix and consider an episode (or, for , an infinite trajectory with bounded ) from , . The shaping terms telescope:
because at termination (in the continuing case as ). So on every trajectory, and taking expectations under gives ; averaging over gives the statement for . Since the shift is the same for all actions in and for all policies, , and in every state. □
The proof also explains why only potential differences are safe: any bonus whose discounted sum around a cycle of states is positive can be harvested by circling. Ng and colleagues showed the converse too: without knowledge of the dynamics, potential-based bonuses are the only ones that preserve optimal policies in every MDP. Wiewiora later proved that Q-learning with shaped rewards behaves exactly like Q-learning on the original rewards started from :E. Wiewiora. Potential-Based Shaping and Q-Value Initialization are Equivalent. Journal of Artificial Intelligence Research, 19:205–208, 2003. doi: 10.1613/jair.1190 shaping is value initialization, which is why Sutton and Barto present the latter (Exercise 16.8).
16.4.1In Wolfram Language#
We check the policy-level identity of Theorem 16.5 on a general two-state, two-action MDP: transition probabilities of moving to state 1, expected rewards , an arbitrary stochastic policy choosing action 1 with probability in state , and arbitrary potentials . The expected shaped reward is .
Solve the four Bellman equations (3.10) for with the shaped and with the original rewards, and subtract; the order is .const P1 = await wl`{{Subscript[p, 11], 1 - Subscript[p, 11]}, {Subscript[p, 21], 1 - Subscript[p, 21]}}`
const P2 = await wl`{{Subscript[p, 12], 1 - Subscript[p, 12]}, {Subscript[p, 22], 1 - Subscript[p, 22]}}`
const qpi = await wl`Function[{r1, r2}, Module[{q11, q12, q21, q22, v}, v = {Subscript[\[Pi], 1] q11 + (1 - Subscript[\[Pi], 1]) q12, Subscript[\[Pi], 2] q21 + (1 - Subscript[\[Pi], 2]) q22}; {q11, q12, q21, q22} /. First[Solve[{q11 == r1[[1]] + \[Gamma] ${P1}[[1]] . v, q21 == r1[[2]] + \[Gamma] ${P1}[[2]] . v, q12 == r2[[1]] + \[Gamma] ${P2}[[1]] . v, q22 == r2[[2]] + \[Gamma] ${P2}[[2]] . v}, {q11, q12, q21, q22}]]]]`
const Phi = await wl`{Subscript[\[CapitalPhi], 1], Subscript[\[CapitalPhi], 2]}`
const ra1 = await wl`{Subscript[r, 11], Subscript[r, 21]}`
const ra2 = await wl`{Subscript[r, 12], Subscript[r, 22]}`
await show`Simplify[${qpi}[${ra1} + \[Gamma] ${P1} . ${Phi} - ${Phi}, ${ra2} + \[Gamma] ${P2} . ${Phi} - ${Phi}] - ${qpi}[${ra1}, ${ra2}]]`The difference is for both actions of each state, for every policy, every dynamics and every ; this is the whole content of the theorem, since the optimal policy is found by comparing actions within a state.
16.4.2Beyond Hand-Made Rewards#
Other routes to a good reward avoid hand design altogether. Skinner’s shaping in the psychological sense changes the task gradually, rewarding successive approximations to the target behavior, so that the agent is always in a regime where reward is frequent; in machine learning this is a curriculum. When an expert is available, imitation learning copies its behavior by supervised learning, and inverse reinforcement learning seeks a reward under which the expert is optimal, then optimizes it.Andrew Y. Ng and Stuart Russell. Algorithms for Inverse Reinforcement Learning. In Proceedings of the Seventeenth International Conference on Machine Learning (ICML), pages 663–670. Morgan Kaufmann, 2000 The problem is ill-posed (a constant reward makes every policy optimal), so assumptions such as linearity in known features are needed.
The trial-and-error search for a reward can also be automated: treat the reward function as a parameter and optimize it for a designer’s objective, evaluating each candidate by the performance of an agent trained with it. Experiments with this bilevel optimal reward problem found, surprisingly, that the best reward for a bounded agent is often not the designer’s objective itself.Satinder Singh, Richard L. Lewis, and Andrew G. Barto. Where Do Rewards Come From? In Proceedings of the 31st Annual Conference of the Cognitive Science Society, pages 2601–2606, 2009. URL https://escholarship.org/uc/item/2v29r0b6 An agent with limited time, memory or perception may do better on the designer’s goal by pursuing a different one, just as evolution gave us a taste for sweetness and fat as observable proxies for a fitness we cannot observe. Rewards can finally depend on internal quantities, such as novelty, surprise or learning progress: intrinsic motivation, the computational analogue of curiosity.Jürgen Schmidhuber. A Possibility for Implementing Curiosity and Boredom in Model-Building Neural Controllers. In From Animals to Animats: Proceedings of the First International Conference on Simulation of Adaptive Behavior, pages 222–228. MIT Press, 1991. doi: 10.7551/mitpress/3115.003.0030; and Satinder Singh, Andrew G. Barto, and Nuttapong Chentanez. Intrinsically Motivated Reinforcement Learning. In L. Saul, Y. Weiss, and L. Bottou, editors, Advances in Neural Information Processing Systems 17, pages 1281–1288. MIT Press, 2004. URL https://proceedings.neurips.cc/paper/2004/hash/4be5a36cbaca8ab9d2066debfe4e65c1-Abstract.html
16.5Remaining Issues#
Suppose everything above works. Sutton and Barto list six problems that would still stand between the methods of the book and a general learning agent.
- Deep learning that works incrementally and online. Neural networks learn well from large shuffled batches, replayed data or many parallel actors, all of which are workarounds for catastrophic interference: new learning overwrites old. An honest assessment, in the authors’ words, is that current methods are not well suited to online learning.
- Representation learning. How can experience produce features that make future learning generalize better? In reinforcement learning this is the problem of learning the state-update function , possibly guided by auxiliary GVFs.
- Planning with learned models. Planning has been spectacular when the model is given (Go, chess), but rarely succeeds with models learned from data. Models must be learned selectively: those parts that matter for planning, with options at several time scales.
- Automatic task selection. Which GVFs, options and auxiliary tasks should the agent pose to itself? Today a designer chooses; the cumulants, policies and termination functions should themselves become objects the agent searches over, a hierarchy of questions to match the hierarchy of answers.
- Curiosity: the interaction between behavior and learning. When many tasks are learned off-policy from one stream of experience, the choice of actions decides what is learned. Measures of learning progress can serve as intrinsic rewards and give a computational analogue of play.
- Safety. Agents embedded in the physical world must explore without causing harm, and their rewards must express what we want.
16.6The Future of Artificial Intelligence#
Sutton and Barto end with the observation that superhuman performance in Go is not general intelligence, and that reinforcement learning, being about learning from interaction, will be a component of any agent that has general adaptability. The working assumption behind the whole book is the reward hypothesis, in the words of Sutton and Barto’s Section 3.2: “that all of what we mean by goals and purposes can be well thought of as the maximization of the expected value of the cumulative sum of a received scalar signal (called reward).“Richard S. Sutton and Andrew G. Barto. Reinforcement Learning: An Introduction. Adaptive Computation and Machine Learning. MIT Press, Cambridge, MA, second edition, 2018. ISBN 978-0-262-03924-6. URL http://incompleteideas.net/book/the-book-2nd.html
Because reinforcement learning is optimization, it inherits optimization’s dangers. An agent maximizes what it is rewarded for, not what its designer meant: the theme of Goethe’s sorcerer’s apprentice and of Wiener’s “monkey’s paw”, which grants “what you ask for, not what you should have asked for”. There are two separate problems: ensuring that the learned behavior serves our goals, and ensuring that behavior during learning is acceptably safe. Neither is new: engineers have long optimized designs under constraints and controlled aircraft and chemical plants with adaptive controllers, guided by risk-management practice and stability theory. Simulators help, but the full promise of reinforcement learning requires agents that learn in the real world, and the book closes with Herbert Simon’s reminder that we are designers of that future, not spectators.
16.7Beyond the Book: What Happened Next#
The frontiers of 2018 have moved. This section reports, briefly and with the primary sources, the developments that most directly continue the themes of this chapter.Beyond Sutton and Barto (2018). The results in this section were published between 2017 and 2025: distributional RL (2017–2018), offline RL and the Decision Transformer (2020–2022), Dreamer (2023, in Nature 2025), the reward-hypothesis analyses (2021–2023) and loss of plasticity (2024). The book mentions only the first of these, in its bibliographical remarks.
16.7.1Distributional Reinforcement Learning#
Instead of the expected return, learn its whole distribution. Let be the random return from under ; then the distributional Bellman equation holds in law,
(16.11)and taking expectations returns the ordinary Bellman equation (3.10). Bellemare, Dabney and Munos proved that the evaluation operator defined by the right side is a -contraction in the maximal Wasserstein metric , so that by Theorem A.3 it has a unique fixed point ; the optimality version, by contrast, is not a contraction, although the means of its iterates still converge to .Marc G. Bellemare, Will Dabney, and Rémi Munos. A Distributional Perspective on Reinforcement Learning. In Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 449–458. PMLR, 2017. URL https://proceedings.mlr.press/v70/bellemare17a.html The proof idea for is a coupling: shifting by does not change distances, scaling by multiplies them by , and a mixture over is no farther apart than the worst pair of components. Their agent C51 represents each on 51 fixed atoms, projects the sampled target back onto the atoms and minimizes a cross-entropy; QR-DQN instead fixes the probabilities and learns the atom locations as quantiles by quantile regression, which minimizes a Wasserstein distance directly and closes the gap between theory and algorithm.Will Dabney, Mark Rowland, Marc G. Bellemare, and Rémi Munos. Distributional Reinforcement Learning with Quantile Regression. In Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence, volume 32. AAAI Press, 2018. doi: 10.1609/aaai.v32i1.11791 Distributional agents were much better than DQN on Atari, partly because predicting a distribution is a rich auxiliary task in the sense of Section 16.1.2.Mark Rowland, Marc G. Bellemare, Will Dabney, Rémi Munos, and Yee Whye Teh. An Analysis of Categorical Distributional Reinforcement Learning. In Proceedings of the Twenty-First International Conference on Artificial Intelligence and Statistics, volume 84 of Proceedings of Machine Learning Research, pages 29–37. PMLR, 2018. URL https://proceedings.mlr.press/v84/rowland18a.html The simplest distributional rule, TD with different step sizes for positive and negative errors, learns expectiles of the return (Proposition 14.11), and it is this form that has been found in dopamine neurons (Section 14.11.1).
Two states, each moving to state 1 or 2 with probabilities , return distributions given as lists of (probability, atom); the mean of the distributional backup minus the ordinary Bellman backup of the means.const zBackup = await wl`Function[{z1, z2}, Join[{#[[1]] Subscript[p, 1], r + \[Gamma] #[[2]]} & /@ z1, {#[[1]] (1 - Subscript[p, 1]), r + \[Gamma] #[[2]]} & /@ z2]]`
await show`Simplify[Total[Times @@@ ${zBackup}[{{a, Subscript[z, 1]}, {1 - a, Subscript[z, 2]}}, {{b, Subscript[z, 3]}, {1 - b, Subscript[z, 4]}}]] - (r + \[Gamma] (Subscript[p, 1] (a Subscript[z, 1] + (1 - a) Subscript[z, 2]) + (1 - Subscript[p, 1]) (b Subscript[z, 3] + (1 - b) Subscript[z, 4])))]`const wass1 = await wl`Function[{d1, d2}, Integrate[Abs[CDF[EmpiricalDistribution[d1[[All, 1]] -> d1[[All, 2]]], x] - CDF[EmpiricalDistribution[d2[[All, 1]] -> d2[[All, 2]]], x]], {x, -10, 10}, Assumptions -> 0 < \[Gamma] < 1]]`
const zHalf = await wl`${zBackup} /. {Subscript[p, 1] -> 1/2, r -> 0}`
await show`{Max[${wass1}[{{1, 0}}, {{1/2, 1}, {1/2, -1}}], ${wass1}[{{1/2, 0}, {1/2, 2}}, {{1, 3}}]], ${wass1}[${zHalf}[{{1, 0}}, {{1/2, 0}, {1/2, 2}}], ${zHalf}[{{1/2, 1}, {1/2, -1}}, {{1, 3}}]]}`The backup shrinks the distance from to , as the contraction property requires. (Both states have the same transitions here, so is the same at both and one distance suffices.)
16.7.2Offline Reinforcement Learning and Sequence Models#
Offline (or batch) RL learns a policy from a fixed dataset with no further interaction, as in the web-services case of Section 15.7. The survey of Levine, Kumar, Tucker and Fu identifies the central obstacle: the Q-learning target queries actions the data never contain, their estimates are unconstrained, the maximization selects exactly the overestimated ones, and without new data the errors are never corrected.Sergey Levine, Aviral Kumar, George Tucker, and Justin Fu. Offline Reinforcement Learning: Tutorial, Review, and Perspectives on Open Problems, 2020 Two answers became standard. Conservative Q-learning, whose loss is written out in Section 11.10 as the deadly triad without exploration, adds to the TD loss a penalty that pushes down the values of all actions (softly, the largest) and up those of actions in the data, and yields a lower bound on the value of the learned policy.Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative Q-Learning for Offline Reinforcement Learning. In Advances in Neural Information Processing Systems, volume 33, pages 1179–1191. Curran Associates, Inc., 2020 Implicit Q-learning never evaluates an unseen action: it fits to an upper expectile of over the dataset’s actions (the statistic of Proposition 14.11), using the asymmetric loss , fits to , and extracts a policy by advantage-weighted regression.Ilya Kostrikov, Ashvin Nair, and Sergey Levine. Offline Reinforcement Learning with Implicit Q-Learning. In International Conference on Learning Representations (ICLR), 2022. URL https://openreview.net/forum?id=68n2s9ZJWF8 As the expectile approaches the maximum over the actions that actually occur, an in-sample version of the Bellman optimality backup:
The -expectile of a two-point distribution on (mass at ) solves ; shown at and as .const expectile = await wl`m /. First[Solve[\[Tau] p (1 - m) == (1 - \[Tau]) (1 - p) m, m]]`
await show`{${expectile} /. \[Tau] -> 1/2, Limit[${expectile}, \[Tau] -> 1]}`The -expectile is the mean (SARSA-like evaluation of the data’s policy); the limit is the largest value in the support (Q-learning restricted to the data). The Decision Transformer went further and dropped value functions: a transformer is trained by supervised learning on trajectories written as sequences , where is the return-to-go, and at test time it is prompted with the return one wishes to achieve.Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Michael Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision Transformer: Reinforcement Learning via Sequence Modeling. In Advances in Neural Information Processing Systems, volume 34, pages 15084–15097. Curran Associates, Inc., 2021 It matched TD-based offline methods on standard benchmarks with no bootstrapping at all; but conditioning on an observed return confuses skill with luck in stochastic environments, which is exactly what the expectations of the Bellman equation average out.
16.7.3World Models and Planning with Learned Models#
The third remaining issue, planning with learned models, saw the most progress. Ha and Schmidhuber trained a variational autoencoder to compress frames, a recurrent network to predict the next code, and a tiny controller on top, and showed that the controller could be trained entirely inside the model’s “dream”.David Ha and Jürgen Schmidhuber. Recurrent World Models Facilitate Policy Evolution. In Advances in Neural Information Processing Systems, volume 31, pages 2450–2462. Curran Associates, Inc., 2018. Extended preprint: “World Models”, arXiv:1803.10122 DreamerV3 learns a recurrent latent-state model from replayed experience and trains an actor-critic on imagined latent trajectories, which is Dyna (Algorithm 8.2) with a learned deep model and, in the terms of Section 16.3, a learned state-update function; it was the first algorithm to collect diamonds in Minecraft from scratch.Danijar Hafner, Jurgis Pasukonis, Jimmy Ba, and Timothy Lillicrap. Mastering Diverse Control Tasks through World Models. Nature, 640(8059):647–653, 2025. doi: 10.1038/s41586-025-08744-2 MuZero took the complementary route of a model that predicts only rewards, values and policies. Both are described in Section 8.11.
16.7.4Options, Successor Features and GVFs Revisited#
Where do options come from? The option-critic architecture learns intra-option policies and terminations by gradient ascent, using an intra-option policy-gradient theorem (the analogue of Theorem 13.2) and a termination gradient that raises in proportion to the disadvantage of continuing: stop an option when another would be better.Pierre-Luc Bacon, Jean Harb, and Doina Precup. The Option-Critic Architecture. In Proceedings of the Thirty-First AAAI Conference on Artificial Intelligence, volume 31. AAAI Press, 2017. doi: 10.1609/aaai.v31i1.10916 Without a cost of deliberation, the learned options tend to shrink to single steps, a reminder that the purpose of temporal abstraction must be specified somewhere. Successor features generalize the successor representation of Section 14.11.2 and are vector-valued GVFs: if rewards are linear in features, , then with the GVF whose cumulant is , so a new task (a new ) is evaluated without learning. Given policies , generalized policy improvement acts by and is guaranteed to be at least as good as each , a multi-policy version of Theorem 4.6.André Barreto, Will Dabney, Rémi Munos, Jonathan J. Hunt, Tom Schaul, Hado van Hasselt, and David Silver. Successor Features for Transfer in Reinforcement Learning. In Advances in Neural Information Processing Systems, volume 30, pages 4055–4065. Curran Associates, Inc., 2017
16.7.5Exploration Bonuses#
Intrinsic rewards became the standard answer to hard exploration in Atari. The intrinsic curiosity module rewards the error of a forward model in a learned feature space.Deepak Pathak, Pulkit Agrawal, Alexei A. Efros, and Trevor Darrell. Curiosity-Driven Exploration by Self-Supervised Prediction. In Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 2778–2787. PMLR, 2017. URL https://proceedings.mlr.press/v70/pathak17a.html Random network distillation is simpler: a fixed, randomly initialized network maps observations to vectors, a predictor is trained to imitate it on the states visited, and the bonus is large exactly where the agent has rarely been. Because the target is a deterministic function of the observation, the bonus cannot be inflated by unpredictable noise (the “noisy TV” that traps prediction-error curiosity), and RND was the first method to exceed average human performance on Montezuma’s Revenge without demonstrations.Yuri Burda, Harrison Edwards, Amos Storkey, and Oleg Klimov. Exploration by Random Network Distillation. In International Conference on Learning Representations (ICLR), 2019 These bonuses are Schmidhuber’s curiosity made scalable, and Agent57 (Section 15.10) combines them with a schedule over exploration weights.
16.7.6Continual Learning and Loss of Plasticity#
The first remaining issue turned out to be deeper than catastrophic forgetting. Dohare and colleagues showed that standard deep networks trained on a long sequence of tasks progressively lose the ability to learn at all: on a sequence of binary ImageNet tasks, accuracy on new tasks fell to the level of a linear network, across architectures, optimizers and activation functions, and the same happened in reinforcement learning.Shibhansh Dohare, J. Fernando Hernandez-Garcia, Qingfeng Lan, Parash Rahman, A. Rupam Mahmood, and Richard S. Sutton. Loss of Plasticity in Deep Continual Learning. Nature, 632(8026):768–774, 2024. doi: 10.1038/s41586-024-07711-7 The cure they proposed, continual backpropagation, keeps reinitializing a small fraction of the least-used hidden units, maintaining the diversity that random initialization provides at the start. Sutton, Bowling and Pilarski’s Alberta Plan makes this setting central to a research program: an agent that learns continually from a single stream of ordinary experience, with GVFs, options and learned models as its building blocks, much as this chapter outlines.Richard S. Sutton, Michael Bowling, and Patrick M. Pilarski. The Alberta Plan for AI Research, 2022
16.7.7Is Reward Enough?#
Silver, Singh, Precup and Sutton argued that “intelligence, and its associated abilities, can be understood as subserving the maximisation of reward”, so that perception, language, social intelligence and generalization would all emerge in an agent maximizing reward in a rich enough environment.David Silver, Satinder Singh, Doina Precup, and Richard S. Sutton. Reward is Enough. Artificial Intelligence, 299:103535, 2021. doi: 10.1016/j.artint.2021.103535 Two formal analyses sharpened the claim. Abel and colleagues showed that some natural tasks, specified as a set of acceptable policies or as orderings over behaviors or trajectories, cannot be expressed by any Markov reward function, and gave algorithms that decide when one exists.David Abel, Will Dabney, Anna Harutyunyan, Mark K. Ho, Michael L. Littman, Doina Precup, and Satinder Singh. On the Expressivity of Markov Reward. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P. S. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems, volume 34, pages 7799–7812. Curran Associates, Inc., 2021 Bowling, Martin, Abel and Dabney characterized exactly when the reward hypothesis holds: preferences over outcomes are representable as expected cumulative Markov reward if and only if they satisfy the four von Neumann–Morgenstern axioms of expected utility and one further axiom, temporal -indifference, which ties the preferences across time to a discount.Michael Bowling, John D. Martin, David Abel, and Will Dabney. Settling the Reward Hypothesis. In Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 3003–3020. PMLR, 2023. URL https://proceedings.mlr.press/v202/bowling23a.html Risk-sensitive objectives, like the downside limits of Watson’s wagering in Section 15.3, violate it unless the state is augmented. On the practical side, reward hacking, the gap between a proxy reward and the intended one that an optimizer exploits, received a formal definition.Joar Skalse, Nikolaus H. R. Howe, Dmitrii Krasheninnikov, and David Krueger. Defining and Characterizing Reward Gaming. In Advances in Neural Information Processing Systems, volume 35, pages 9460–9471. Curran Associates, Inc., 2022. doi: 10.52202/068431-0687. arXiv title: “Defining and Characterizing Reward Hacking”
16.7.8Reinforcement Learning for Language Models#
The largest deployment of reinforcement learning since the book is the fine-tuning of language models: RLHF with a reward model learned from human comparisons, direct preference optimization which removes the explicit reward model, and GRPO with verifiable rewards for reasoning.Paul F. Christiano, Jan Leike, Tom B. Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep Reinforcement Learning from Human Preferences. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett, editors, Advances in Neural Information Processing Systems 30 (NIPS 2017), volume 30, pages 4299–4307. Curran Associates, Inc., 2017; Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul F. Christiano, Jan Leike, and Ryan Lowe. Training Language Models to Follow Instructions with Human Feedback. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in Neural Information Processing Systems 35 (NeurIPS 2022), volume 35, pages 27730–27744. Curran Associates, Inc., 2022. doi: 10.52202/068431-2011; Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, and Chelsea Finn. Direct Preference Optimization: Your Language Model is Secretly a Reward Model. In A. Oh, T. Naumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine, editors, Advances in Neural Information Processing Systems 36 (NeurIPS 2023), volume 36, pages 53728–53741. Curran Associates, Inc., 2023. doi: 10.52202/075280-2338; Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Xiao Bi, Haowei Zhang, Mingchuan Zhang, Y. K. Li, Y. Wu, and Daya Guo. DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models. arXiv preprint arXiv:2402.03300, 2024. doi: 10.48550/arXiv.2402.03300; and Daya Guo, Dejian Yang, Haowei Zhang, Junxiao Song, Peiyi Wang, Qihao Zhu, Runxin Xu, Ruoyu Zhang, Shirong Ma, Xiao Bi, et al. DeepSeek-R1 Incentivizes Reasoning in LLMs through Reinforcement Learning. Nature, 645(8081):633–638, Springer Nature, 2025. doi: 10.1038/s41586-025-09422-z. Preprint: DeepSeek-AI, “DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning”, arXiv:2501.12948 (2025) The algorithms are policy-gradient methods and are derived in Section 13.8.7; the case studies are in Section 15.10. In the vocabulary of this chapter, they are experiments in reward design at an unprecedented scale: learned rewards, KL penalties as protection against reward hacking, and verifiable rewards as a way of making the reward signal trustworthy.
16.8Looking Back#
From the tic-tac-toe player of Chapter 1 to a glider riding thermals and a language model learning to reason, much less has changed underneath than on the surface. Every method in this companion estimates values or a policy from experience and improves each against the other, in the loop of generalized policy iteration (Section 4.7). Every method takes a position along the same few axes: sample or expected updates, bootstrapping or complete returns, learning about the policy it follows or about another one. Each had to cross from tables, where the theory is complete, to function approximation, where the deadly triad (Section 11.3) marks the limit of what can be guaranteed. And one quantity, the TD error (6.2), the difference between successive predictions, drove the backgammon network, the Atari player and, it seems, the dopamine neurons of a monkey waiting for juice.
The frontiers of this chapter are what that loop does not yet provide: agents that predict many things, act at many time scales, build their own state, keep learning without losing the ability to learn, and pursue rewards that say what we mean. They are open problems, not loose ends, and they are being attacked with the ideas of these pages: value functions, Bellman equations, and learning from the gap between what was expected and what happened. That last idea is the one to keep. An agent that compares each prediction with the next, and changes a little every time, needs neither a teacher nor the final outcome to keep getting better.
16.9Exercises#
Exercise 16.6. (Sutton and Barto, Exercise 17.1.) Write the Bellman equation for a hierarchical policy in the average-reward setting of Section 10.3, analogous to (16.4). What are the parts of the option model now? Compute the new part for the corridor option of Section 16.2.1.
Solution
Without discounting, the transition part becomes a true probability distribution of the termination state, , and the reward part the undiscounted sum . Differential returns subtract per time step, so an option that lasts longer must be charged more, and a third part is needed, the expected duration . Repeating the proof of Theorem 16.3 with gives
the Bellman equation of an average-reward semi-Markov decision process. The duration is a GVF with cumulant and continuation , so .
Expected duration of the corridor option from state 1: two geometric waiting times with success probability .await show`Simplify[(Inverse[IdentityMatrix[3] - ${Pw} . (IdentityMatrix[3] - ${Bw})] . {1, 1, 1})[[1]]]`Exercise 16.7. In a two-state episodic task the agent starts in , whose only action moves it to . In it can finish (reward , episode ends) or go back to (reward ). The designer adds a subgoal bonus for entering . For which is it optimal never to finish? Show that the potential-based bonus on and on cannot create this behavior.
Solution
Without the bonus, finishing is optimal: , . With the bonus, the looping policy has and , so and . Looping beats finishing in when :
Condition for the loop to be worth more than the goal.await show`Reduce[\[Gamma] b/(1 - \[Gamma]^2) > 1 && 0 < \[Gamma] < 1 && b > 0, b]`For a bonus of , less than a quarter of the true reward, already makes the agent circle forever. With potential-based shaping the discounted bonus collected around the loop, starting in , is , the same as the telescoping sum of Theorem 16.5. Summed over the infinitely many laps of the looping policy, the discounted bonus is ; finishing from collects as well. Both options are shifted by the same amount, so the comparison between looping and finishing is unchanged, as the theorem guarantees.
Exercise 16.8. Let tabular Q-learning (Algorithm 6.7) run on the shaped rewards (16.10) from , and a second copy run on the original rewards from , both with the same step sizes and the same experience. Show by induction that for all , and conclude that the two agents make identical greedy (or -greedy, or soft-max) choices.
Solution
The claim holds at . Suppose it holds at and the transition is observed. The shaped TD error is
because the terms cancel in pairs (the max of a shifted function is the shifted max). The two updates add the same to the same entry, so the relation holds at . In every state the two tables differ by a constant across actions, so , -greedy and soft-max choices coincide; with the same random numbers the two agents generate the same experience forever. Shaping with is therefore equivalent to optimistic or pessimistic initialization by . The same induction works for tabular Sarsa; with function approximation the equivalence requires to be exactly representable by the approximator.
Exercise 16.9. In the example of Section 16.3.1 with switching probability , suppose the sensor reports “state 1” forever. Show that the belief converges to a fixed point , find it, and evaluate it for , . What does this say about approximating the belief by the last observations?
Solution
The update is a monotone Möbius map of ; its fixed point in is the limit.
The fixed point of the belief update under a constant report, for .const bStar = await wl`b /. First[Solve[(${bel}[{b, 1 - b}, {{1 - e, e}, {e, 1 - e}}, {q, 1 - q}])[[1]] == b && 0 < b < 1, b, Assumptions -> 0 < e < 1/2 && 1/2 < q < 1]]`
await show`N[${bStar} /. {e -> 1/10, q -> 4/5}]`The belief never reaches certainty, because the hidden state may have switched since the last report; it saturates at . The map contracts towards geometrically, so after a handful of identical reports the belief is within any tolerance of : the influence of old observations decays exponentially. Hence a window of the last observations, with of the order of the contraction’s time constant, is an approximately Markov state for this process, while for (where reports accumulate forever) no finite window suffices and a counter is needed.