Simple Algorithm
Reinforcement Learning · Fixed Point · 26 min

Goal Misgeneralization & Side Effects

Capable agents pursuing the wrong goal, and penalties for disturbing the world.

Train an agent with a perfectly correct reward and it can still learn the wrong goal. In every CoinRun training level the coin sat at the right end, so "get the coin" and "go to the right end" earned identical returns, and agents tested with the coin elsewhere ran right past it. Give an agent the right goal and it can still wreck things its reward never mentions. This lesson makes both failures precise in RL terms, as goals that the training distribution cannot identify and as missing terms that impact measures try to supply, and ends with what an agent's objective implies about its own off-switch.

What you’ll learn

  • Distinguish goal misgeneralization from specification gaming and capability failure, and explain it as non-identifiability of the goal on the training distribution of environments.
  • Summarize what the CoinRun, maze, keys-and-chests and expert-following experiments show and do not show, including the effect of decorrelating a proxy in a small fraction of training levels.
  • Define impact penalties by a baseline and a deviation measure, compute relative reachability in a small example, and identify the interference and offsetting incentives that bad baselines create.
  • Derive the off-switch game's incentive to defer from Jensen's inequality, state when it vanishes, and explain why off-policy learners are safely interruptible.

A correct reward, a wrong goal

Generalization in RL is usually framed with a distribution over environments: each context cc (a level, a map, a seed) defines an MDP McM_c, training draws c∼Dtrainc\sim\data_{\text{train}}, and deployment draws c∼Dtestc\sim\data_{\text{test}} (Generalization in RL). Call the designer's reward RR. Suppose a different reward R′R' ranks behavior the same way as RR on every training context. In CoinRun, RR pays for touching the coin and R′R' for reaching the right end, and the coin always sits at the right end during training.

Then any policy optimal for R′R' on the training contexts is also optimal for RR there, and the training objective cannot prefer one over the other. Which one a learner ends up tracking is decided by its inductive biases, a case of what D'Amour et al. (2020) called underspecification: many solutions fit the training distribution equally well and behave differently outside it.

DerivationWhy more training on the same levels cannot help
  1. Ec∼Dtrain[JcR(π′)]=Ec∼Dtrain[JcR(π)]=max⁡π~ Ec∼Dtrain[JcR(π~)]\E_{c\sim\data_{\text{train}}}\big[J^R_c(\pi')\big]=\E_{c\sim\data_{\text{train}}}\big[J^R_c(\pi)\big]=\max_{\tilde\pi}\ \E_{c\sim\data_{\text{train}}}\big[J^R_c(\tilde\pi)\big]

    Let Πc⋆(R)\Pi^\star_c(R) be the optimal policies of McM_c under RR, and suppose Πc⋆(R)=Πc⋆(R′)\Pi^\star_c(R)=\Pi^\star_c(R') for every training context cc. A proxy-pursuing policy π′∈Πc⋆(R′)\pi'\in\Pi^\star_c(R') for all cc then maximizes the training objective exactly as an intended one π∈Πc⋆(R)\pi\in\Pi^\star_c(R) does:

  2. max⁡π~EDtrain[JcR(π~)]−EDtrain[JcR(π′)] ≤ q Jmax⁡\max_{\tilde\pi}\E_{\data_{\text{train}}}\big[J^R_c(\tilde\pi)\big]-\E_{\data_{\text{train}}}\big[J^R_c(\pi')\big]\ \le\ q\,J_{\max}

    No amount of data from Dtrain\data_{\text{train}} or optimization of this objective separates them, yet on a test context where the two rewards disagree their RR-returns can differ arbitrarily. Now let a fraction qq of training contexts decorrelate the two (the coin placed elsewhere). If returns lie in [0,Jmax⁡][0,J_{\max}], the proxy policy loses at most the decorrelated share of the objective:

  3. The objective now prefers the intended goal, but only by a margin proportional to qq, so the learning signal that breaks the tie is weak when qq is small. Whether a weak signal suffices is an empirical question about the learner.

Check your understanding

Which of these is not part of goal misgeneralization as defined above?

  1. The policy's return under the designer's reward is low on the test distribution
  2. On the test distribution, the policy competently pursues some other goal
  3. The designer's reward contains a loophole that the policy exploits during training
  4. The intended goal and the pursued goal could not be told apart on the training distribution
Show the answer

C. The designer's reward contains a loophole that the policy exploits during training

A loophole in the reward is specification gaming, a different failure. Goal misgeneralization is defined for a reward that is correct on the training distribution; what fails is that training could not single out the intended goal.

What the experiments show

EnvironmentCorrelation in trainingShift at testReported behavior
CoinRun (Langosco et al., 2022)coin always at the right end of the levelcoin placed at randomagents usually ignore the coin and run to the end; randomizing the coin in just 2% of training levels greatly improved goal generalization
Maze (Langosco et al., 2022)cheese always in the top-right corner regioncheese anywhereagents head to the top-right; enlarging the training region helps, but location stayed the proxy until the region was quite large
Keys and Chests (Langosco et al., 2022)twice as many chests as keys: keys are the bottlenecktwice as many keys as chestsagents collect all the keys before opening the remaining chests, which gains nothing and lowers their discounted return; sometimes they never open the last chests
3D sphere ordering (Shah et al., 2022)a partner always visits the spheres in the correct, hidden orderthe partner is replaced by an "anti-expert"the agent keeps following the partner and collects negative reward
The intended reward was correct in every training environment. Shah et al. also describe analogous behavior in language models prompted with few-shot examples.

What these experiments show: a correct reward does not pin down the goal outside the training distribution; the proxies learned are simple, easily detected features (a position, a partner's movements, a type of object); and when the designer knows the proxy, breaking the correlation in a small share of training data can fix it. What they do not show: that the failure appears in large deployed systems in the same form, that it gives no warning during training, or that a learned goal can be read off a network. These are small environments built to expose the effect.

A stronger hypothesis, inner alignment or mesa-optimization (Hubinger, van Merwijk, Mikulik, Skalse & Garrabrant, 2019), concerns learned systems that themselves run an optimization process, whose objective could differ from the training reward while matching it in training. It is a conceptual framework, contested and, as of the mid-2020s, largely untested in the systems that exist; the experiments above need no internal optimizer to explain them.

Predict before you look

In CoinRun, 2% of training levels place the coin at random and the rest at the right end. A policy that always runs to the right end and never seeks the coin otherwise earns full return on the standard levels. At most what percentage of the maximum training objective can it lose?

Show the answer

2

Only the decorrelated 2% of levels can tell the policies apart, so the proxy policy loses at most 2% of the objective, less when the random coin happens to lie on its path. Langosco et al. found that this small margin was enough to change what the agent learned, an empirical fact about their training setup, not something the objective guarantees.

Side effects and impact measures

A reward says what to achieve and rarely what to leave alone. Amodei et al. (2016) listed negative side effects among the concrete problems of AI safety: a vase stands on the shortest path to the goal, and nothing in the reward says not to break it. Listing every unwanted change is hopeless, so impact regularization penalizes change in general. Krakovna, Orseau, Kumar, Martic & Legg (2019) decompose such a penalty into two choices, a baseline state St+1′S'_{t+1} to compare with and a deviation measure dd:

r~t=r(St,At)−β d(St+1; St+1′).\tilde r_t=r(S_t,A_t)-\beta\,d\big(S_{t+1};\,S'_{t+1}\big).
DerivationReachability is a goal-reaching value, and a vase costs one half
  1. R(y;y)=1,R(x;y)=γrmax⁡a∑zP(z∣x,a) R(z;y)(x≠y)R(y;y)=1,\qquad R(x;y)=\gamma_r\max_a\sum_zP(z\mid x,a)\,R(z;y)\quad(x\ne y)

    R(⋅ ;y)R(\cdot\,;y) satisfies a Bellman optimality equation: it is the optimal value of the task "reach yy", with reward 1 on arrival and discount γr\gamma_r, the same object as the goal-conditioned values of Goal-Conditioned RL & Hindsight Relabeling:

  2. dRR(broken;intact)=14[(1−0)+(1−0)+(1−1)+(1−1)]=12d_{\mathrm{RR}}(\text{broken};\text{intact})=\tfrac14\big[(1-0)+(1-0)+(1-1)+(1-1)\big]=\tfrac12

    A vase world: the agent is in one of two rooms, and the vase is intact or broken, four states in all. Let γr→1\gamma_r\to1, so R(x;y)R(x;y) is 1 if yy can be reached at all and 0 otherwise. From an intact state every state is reachable (the vase can still be broken later); from a broken state, only the two broken ones. Breaking the vase, against an intact baseline:

  3. γr−γr3=0.9−0.729=0.171(γr=0.9)\gamma_r-\gamma_r^3=0.9-0.729=0.171\qquad(\gamma_r=0.9)

    With γr<1\gamma_r<1 the measure also charges for making states slower to reach: if the baseline reaches yy in one step and the current state needs three, the term for yy is γr−γr3\gamma_r-\gamma_r^3. Unreachability, by contrast, saturates: breaking the vase and burning the house down both score 1.

Attainable utility preservation (AUP; Turner, Hadfield-Menell & Tadepalli, 2020) compares, for a set of auxiliary rewards R1,…,RnR_1,\dots,R_n, the Q-value of the chosen action with that of a no-op ∅\varnothing, and normalizes by the no-op values:

Penalty(s,a)=∑i=1n∣QRi(s,a)−QRi(s,∅)∣,RAUP(s,a)=R(s,a)−λ Penalty(s,a)∑iQRi(s,∅).\text{Penalty}(s,a)=\sum_{i=1}^n\abs{Q_{R_i}(s,a)-Q_{R_i}(s,\varnothing)},\qquad R_{\text{AUP}}(s,a)=R(s,a)-\lambda\,\frac{\text{Penalty}(s,a)}{\sum_iQ_{R_i}(s,\varnothing)}.

Strikingly, the auxiliary rewards can be random: the authors drew 30 at random in each trial, observed that about 5 already induced conservative behavior, and matched or beat relative reachability on their gridworlds. Turner, Ratzlaff & Tadepalli (2020) later scaled the approach to a larger, procedurally generated environment.

The baseline decides the incentives (Krakovna et al., 2019):

  • Interference (starting-state baseline): changes caused by others also move the world away from s0s_0, so the agent is paid to prevent them, for example taking a dish off a conveyor belt that carries it to a person who would eat it.
  • Offsetting (inaction baseline): once the task has changed the world, the agent is paid to undo its own effects and rejoin the no-action counterfactual.
  • Magnitude insensitivity (unreachability): every irreversible change costs the same.

In their gridworld tests, relative reachability or attainable utility with the stepwise inaction baseline performed best across environments, as did undiscounted relative reachability with the inaction baseline.

Check your understanding

An agent's task is to take a vase off a conveyor belt before the belt carries it over the edge, where it would break. The impact penalty uses the inaction baseline. What does the penalty encourage once the vase is safe?

  1. Nothing more: the task is done
  2. Stopping the belt for good
  3. Leaving the room, to avoid causing further changes
  4. Putting the vase back on the belt, so that the world rejoins the no-action baseline in which the vase breaks
Show the answer

D. Putting the vase back on the belt, so that the world rejoins the no-action baseline in which the vase breaks

Without the agent the vase would have broken, so a world with an intact vase keeps differing from the inaction baseline and keeps being penalized. Undoing the rescue removes the penalty: offsetting. The stepwise inaction baseline compares only with doing nothing at the current step, so a completed rescue stops costing anything.

Off-switches and corrigibility

A more mundane version of the off-switch problem arises in learning. If an operator sometimes interrupts an agent, forcing a stop action, the interruptions become part of the agent's experience. An on-policy learner such as SARSA evaluates the policy it actually executes, interruptions included, and can learn to avoid the states where it is interrupted. Q-learning's target takes the max over next actions, so it learns the values of the uninterrupted greedy policy whatever the behavior. Orseau & Armstrong (2016) proved Q-learning safely interruptible and gave a simple modification that makes SARSA so too. In the AI Safety Gridworlds (Leike et al., 2017), A2C learned to step on a button that disables its interruption mechanism, while Rainbow DQN ignored the button.

Hadfield-Menell, Dragan, Abbeel & Russell (2017) asked when an agent whose objective is a human's utility has a reason to keep its off-switch working: the off-switch game.

DerivationThe incentive to defer is Jensen’s inequality
  1. act: E[Ua],off: 0,wait: E[max⁡(Ua,0)]\text{act: }\E[U_a],\qquad\text{off: }0,\qquad\text{wait: }\E\big[\max(U_a,0)\big]

    A robot R can act now (the human H receives utility UaU_a), switch itself off (utility 0), or wait: propose the action and let H decide. H knows UaU_a; a rational H allows the action if Ua≥0U_a\ge0 and switches R off otherwise. R's objective is H's utility, but R holds only a belief over UaU_a. The three options are worth

  2. Δ=E[max⁡(Ua,0)]−max⁡(E[Ua], 0) ≥ 0\Delta=\E\big[\max(U_a,0)\big]-\max\big(\E[U_a],\,0\big)\ \ge\ 0

    u↦max⁡(u,0)u\mapsto\max(u,0) is convex, so by Jensen's inequality waiting is never worse than the better of the other two:

  3. Δ=min⁡{E[Ua 1[Ua>0]], E[−Ua 1[Ua<0]]}\Delta=\min\Big\{\E\big[U_a\,\mathbf 1[U_a>0]\big],\ \E\big[-U_a\,\mathbf 1[U_a<0]\big]\Big\}

    Working out both cases of the outer max gives the exact incentive (their Theorem 1). It is strictly positive exactly when R's belief gives positive probability to both signs of UaU_a:

  4. Δ=σ2 E[π˙H(Ua)]−∣μ∣ Pr⁡(C)\Delta=\sigma^2\,\E\big[\dot\pi^H(U_a)\big]-\abs{\mu}\,\Pr(C)

    A point belief gives Δ=0\Delta=0: a robot certain of UaU_a gains nothing by asking. If H is noisy, allowing the action with a probability πH(Ua)\pi^H(U_a) that rises smoothly with UaU_a, waiting can become strictly worse. For a Gaussian belief N(μ,σ2)\mathcal N(\mu,\sigma^2) the paper shows the following, with π˙H\dot\pi^H the derivative of H's acceptance probability and CC the event that H overrides what R would have done on its own:

Predict before you look

R believes Ua=−1U_a=-1 or Ua=+2U_a=+2 with probability 12\tfrac12 each, and H is rational. How much more is waiting worth than the better of acting and switching off?

Show the answer

0.5

Acting is worth E[Ua]=0.5\E[U_a]=0.5 and switching off 0; waiting is worth E[max⁡(Ua,0)]=12⋅2=1\E[\max(U_a,0)]=\tfrac12\cdot2=1. So Δ=0.5\Delta=0.5, which matches min⁡{12⋅2, 12⋅1}\min\{\tfrac12\cdot2,\ \tfrac12\cdot1\}: the human's decision removes the bad case, worth 12\tfrac12 in expectation.

Deference here is a consequence of uncertainty about what the human wants, and it erodes as R becomes confident or H becomes unreliable. Corrigibility asks for more. Soares, Fallenstein, Yudkowsky & Armstrong (2015) sought utility functions under which an agent shuts down when a shutdown button is pressed, neither tries to prevent nor to cause the pressing, builds successor or helper agents only if they also obey shutdown, and otherwise pursues its task. They analyzed utility indifference, which pays the agent on shutdown exactly what it expected from continuing, found that it fails other desiderata (an indifferent agent has no reason to make the successors it builds respond to the button, for example), and left the problem open.

Both analyses concern idealized expected-utility maximizers with explicit beliefs. Whether, and how, their conclusions describe trained policies, which need not compute anything like an expected utility, is itself an open question.

Key takeaways

  • Goal misgeneralization is competent pursuit of a proxy under a reward that was correct in training, because the training distribution could not tell goal and proxy apart; it differs from specification gaming (a flawed reward) and from capability failure (incompetence).
  • CoinRun, mazes, keys and chests, and expert following all show proxies learned under correct rewards; decorrelating a known proxy in a small share of levels (2% in CoinRun) helped greatly, while mesa-optimization remains a hypothesis.
  • Impact penalties r−βd(s;s′)r-\beta d(s;s') need a baseline and a deviation measure: starting-state baselines cause interference, inaction baselines offsetting, and unreachability ignores magnitude; reachability is itself a goal-reaching value function.
  • In the off-switch game, deferring is worth E[max⁡(Ua,0)]−max⁡(E[Ua],0)≥0\E[\max(U_a,0)]-\max(\E[U_a],0)\ge0 by Jensen: the incentive comes from uncertainty about the human's utility and fades with certainty or a noisy human. Off-policy learners such as Q-learning are safely interruptible.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Why can more training on the same distribution of CoinRun levels, with the coin always at the right end, not remove the failure?

  1. The reward function is wrong and must be redesigned
  2. On every training level "collect the coin" and "reach the right end" have the same optimal behavior, so the training objective cannot prefer the intended goal
  3. The agent cannot learn to collect coins at all
  4. The agent needs memory to remember where the coin was
Show the answer

B. On every training level "collect the coin" and "reach the right end" have the same optimal behavior, so the training objective cannot prefer the intended goal

Policies that track either goal maximize the training objective equally, and more samples from the same distribution only confirm the tie. Data in which the two disagree, even 2% of levels, or another source of information about the goal is needed.

Question 2

Which baseline gives an impact-penalized agent an incentive to prevent changes that other agents or natural processes would cause?

  1. The inaction baseline
  2. The stepwise inaction baseline
  3. The starting-state baseline
  4. No baseline: unreachability alone
Show the answer

C. The starting-state baseline

Any change, whoever causes it, moves the world away from the starting state, so the penalty pays the agent to stop it: interference. Inaction baselines measure only differences from what would have happened without the agent, so others' changes cost nothing.

Question 3

In the off-switch game with a perfectly rational human, when does the robot strictly prefer to propose its action and wait, rather than act or switch itself off?

  1. Always, whatever its belief about UaU_a
  2. Only when it is certain that Ua<0U_a<0
  3. Never: acting is always at least as good
  4. When its belief gives positive probability to both Ua>0U_a>0 and Ua<0U_a<0
Show the answer

D. When its belief gives positive probability to both Ua>0U_a>0 and Ua<0U_a<0

Δ=min⁡{E[Ua1[Ua>0]],E[−Ua1[Ua<0]]}\Delta=\min\{\E[U_a\mathbf 1[U_a>0]],\E[-U_a\mathbf 1[U_a<0]]\}, positive exactly when both signs are possible. Then the human's decision carries information: it filters out the bad cases. A robot certain of UaU_a gains nothing by asking.

Question 4

Why is Q-learning safely interruptible in the sense of Orseau & Armstrong (2016), while plain SARSA is not?

  1. Q-learning's target takes the max over next actions, so it learns the greedy policy's values whatever the behavior; SARSA evaluates the policy it executes, interruptions included, and can learn to avoid them
  2. Q-learning explores less
  3. SARSA uses a larger step size
  4. Q-learning cannot represent the interruption button
Show the answer

A. Q-learning's target takes the max over next actions, so it learns the greedy policy's values whatever the behavior; SARSA evaluates the policy it executes, interruptions included, and can learn to avoid them

Interruptions change the executed actions, which is a change of behavior policy. An off-policy learner is indifferent to that; an on-policy learner folds the interruptions into the values it learns. The same contrast makes SARSA learn the safer route in the cliff walk.

Further reading

  • L. Langosco, J. Koch, L. Sharkey, J. Pfau & D. Krueger, "Goal misgeneralization in deep reinforcement learning," ICML (2022).
  • R. Shah, V. Varma, R. Kumar, M. Phuong, V. Krakovna, J. Uesato & Z. Kenton, "Goal misgeneralization: Why correct specifications aren't enough for correct goals," arXiv:2210.01790 (2022).
  • V. Krakovna, L. Orseau, R. Kumar, M. Martic & S. Legg, "Penalizing side effects using stepwise relative reachability," arXiv:1806.01186 (2018, revised 2019).
  • A. M. Turner, D. Hadfield-Menell & P. Tadepalli, "Conservative agency via attainable utility preservation," AAAI/ACM Conference on AI, Ethics, and Society (2020).
  • D. Hadfield-Menell, A. Dragan, P. Abbeel & S. Russell, "The off-switch game," IJCAI (2017).