Evaluation lab · San Francisco · London · Zürich
Reinforced Labs Request a briefing
Reinforcement learning

Actor-critic methods and generalized advantage estimation (GAE), with the λ trade-off measured

Actor-critic methods pair a policy with a learned value function that turns noisy returns into low-variance advantages. GAE controls how much to trust that critic with one number, lambda. We measured the trade-off: the best lambda rose from 0.1 with a perfect critic to 0.85 with a poor one, and low lambda with an untrained critic locked every seed into a myopic policy.

Part of Reinforcement learning. New to the topic? Start with What is reinforcement learning? A guide from gridworlds to language models.

An actor-critic method trains two things at once: an actor, the policy that chooses actions, and a critic, a learned value function that judges them. The critic turns noisy Monte Carlo returns into lower-variance advantage estimates, most simply the temporal-difference error . Generalized advantage estimation (GAE) blends multi-step TD errors with a parameter : trusts the critic completely, ignores it except as a baseline, and values in between trade bias for variance.

This page builds actor-critic up from the policy gradient, derives GAE, and then measures the trade-off it controls. On a simulated chain we computed the squared bias and the variance of the policy gradient estimate for every and several levels of critic error. With a perfect critic the best was 0.1; as the critic got worse, the best rose to 0.5, 0.7, 0.8 and 0.85. In a learning run with a critic that starts out ignorant, every seed with locked onto a myopic policy. All numbers come from seeded numpy runs we did for this article.

What is an actor-critic method?#

The policy gradient theorem [2] says the gradient of expected return is , where the advantage measures how much better an action is than the policy's average. REINFORCE [3] estimates the advantage with the sampled return , minus a baseline if it has one. That estimate is unbiased, but adds up every random reward until the end of the episode, so its variance grows with the horizon.

The idea of actor-critic is old: Barto, Sutton and Anderson's 1983 pole-balancing system already had an "adaptive critic element" that learned to predict reinforcement and an "associative search element" that learned to act on the critic's signal [5]. The critic was trained with what Sutton later formalized as temporal-difference learning [6], and Konda and Tsitsiklis gave convergence results for actor-critic algorithms with function approximation [7]. Modern deep RL algorithms such as A2C, its asynchronous predecessor A3C [8], and PPO with a value head are all actor-critic methods.

The loop has two updates per batch of experience:

  1. Critic: move toward a target built from observed rewards and its own predictions, for example .
  2. Actor: move along , where is computed from the critic.

The TD error as an advantage estimate#

The temporal-difference error is

where is the reward at step , the discount factor and the critic's value estimate (with at terminal states). If the critic is exact, , then conditioning on the state and action gives

So the one-step TD error is an unbiased advantage estimate when the critic is right, and it involves only one random reward and one random transition, far less noise than a full return. When the critic is wrong, the error leaks straight into the advantage, and because it depends on , which depends on the action, it does bias the policy gradient. That is the trade: the TD error gets its low variance by trusting a model that may be wrong. The Bellman equation page explains why satisfies the consistency condition that makes average to zero under the policy.

n-step advantages#

Between one step and the whole episode there is a family of -step estimates. Summing discounted TD errors telescopes the intermediate value estimates away:

The -step estimate uses real rewards and then bootstraps from the critic. The critic's error enters only through , shrunk by , plus the term, which acts as a baseline and does not bias the gradient. As grows, bias falls and variance rises. At the estimate is : REINFORCE with a value baseline.

Generalized advantage estimation#

Rather than picking one , GAE averages all of them with exponentially decaying weights , which simplifies to a discounted sum of TD errors [4]:

Here controls how far into the future the estimate looks before relying on the critic. The two ends are the cases we already know:

  • : , the one-step TD error. Lowest variance, and biased whenever is wrong.
  • : . Unbiased for any , because the critic only appears as a baseline, with the high variance of Monte Carlo returns.

The construction is the same as the -return in TD(), applied to advantages; Sutton and Barto treat the -return and eligibility traces at length [1]. In practice GAE is computed backwards through a trajectory in one pass, , and the critic is usually trained toward , the -return.

Two parameters, two roles. Schulman and colleagues point out that also acts as a bias-variance knob, since discounting down-weights distant, noisy rewards at the cost of changing the objective, while introduces bias only through critic error. In their experiments the best results came from intermediate values, roughly and on their cart-pole task [4]; has since become a common default in PPO code.

Measuring the λ trade-off on a chain#

Setup (simulation). A chain of 10 states. The agent starts at the left end; moving right costs 0.1, and stepping right from the last state reaches a goal worth +10 and ends the episode. Moving left pays +0.2 (a small temptation) and moves back one state. Every reward carries Gaussian noise with standard deviation 1, and . We fix the policy at in every state and parameterize it with one logit per state, so the exact policy gradient (squared length 0.306) and the true values (3.9 at the start, rising to 9.5 next to the goal) can be computed by solving linear systems. To control critic quality we used , where is a fixed pattern of standard normal errors and the error scale. From 6,000 episodes we computed, for each , the squared bias of the GAE policy gradient estimate (its mean over all episodes minus the exact gradient, squared and summed) and the variance of a 10-episode batch estimate.

Critic error : bias², variance: bias², variance: bias², varianceBest (lowest MSE)
0 (exact critic)0.000, 0.2180.001, 0.9670.002, 1.5430.1 (MSE 0.218)
0.50.346, 0.2940.003, 0.9850.002, 1.5500.5 (MSE 0.374)
11.387, 0.5160.007, 1.0730.003, 1.6310.7 (MSE 0.591)
25.554, 1.3990.021, 1.4560.003, 2.0180.8 (MSE 1.172)
312.50, 2.8670.043, 2.1170.004, 2.7020.85 (MSE 1.972)

The bias at (about 0.002 to 0.004) is the Monte Carlo noise floor of the experiment, not real bias: with an exact or inexact critic, is unbiased, as the algebra says. Everything else in the table is the trade-off made visible.

  • With a perfect critic, bootstrap. At the TD error is unbiased and its variance (0.218) is seven times lower than the Monte Carlo estimate's (1.543).
  • Critic error turns into bias fast at low . An error of one unit in a value scale of 4 to 10 gives a squared bias of 1.39, more than four times the squared length of the true gradient. That estimate does not just wobble around the right direction; it points somewhere else.
  • A bad critic also raises variance. At the critic is only a baseline, yet its variance grows from 1.54 to 2.70 as goes from 0 to 3, because a baseline far from removes less variance, as the baselines article shows.
  • The best tracks critic quality. It moves from 0.1 to 0.85 as the critic degrades, and when the critic is poor the MSE curve is flat between about 0.8 and 0.9, so a value in that region is a reasonable default when you do not know how good your critic is.
0.10.3131000.20.40.60.81GAE λMSE of the gradient estimate (log scale)critic error 3critic error 2critic error 1critic error 0.5critic error 0
Figure 1. Mean squared error (squared bias plus variance of a 10-episode estimate) of the GAE policy gradient on the chain, against , for five critic error scales; log scale. Each curve has an interior minimum except the perfect critic, whose best value is near . All curves meet at , where critic error affects only variance.

Explore the trade-off#

The figure below reruns the same simulation in your browser (2,400 episodes, a different random critic-error pattern, so the numbers differ slightly from the table). Move the critic error to see the bias curve rise and the best shift right; the dashed line marks the you select.

Error of a 10-episode policy gradient estimate against λ00.250.50.7511.251.500.20.40.60.81GAE λMSEvariancebias²▲ lowest MSE at λ = 0.7; dashed line: selected λ = 0.95
1.00 0.95

Figure 2 (interactive). Squared bias, variance and their sum for the GAE policy gradient estimate on the chain, computed live. The static version shows critic error 1, where the lowest error is at and gives nearly unbiased but noisier estimates.

An actor-critic that learns: when bias locks in#

A fixed critic error is a simplification. In a real actor-critic the critic is learned alongside the policy, starts out wrong, and its errors are systematic, not random. We trained a tabular actor-critic on the same chain, now with the policy free to learn.

Setup (simulation). Actor: one logit per state, starting at . Critic: a table initialized to zero. Each iteration collects 4 episodes (capped at 300 steps), computes GAE advantages, takes an actor step of size 0.1 along per state, and moves each visited state's value 10% of the way toward its average -return. We ran 500 iterations for 20 seeds per . The optimal policy (always right) is worth 5.5 from the start; camping in the first state and collecting +0.2 forever is worth exactly 4.0; the initial policy is worth 1.65.

Return after 100 iterationsAfter 250After 500Seeds within 5% of optimal at 500
03.994.004.000 of 20
0.53.994.004.000 of 20
0.84.104.124.192 of 20
0.94.684.945.1216 of 20
0.954.875.125.2218 of 20
1.04.855.185.2919 of 20

Every seed with converged to the camping policy, worth exactly 4.0. The reason is the zero-initialized critic. Early on, the critic believes every state is worth nothing, so a bootstrapped advantage for "right" sees a cost of 0.1 and a next state worth zero, while "left" sees a reward of +0.2. The goal's value has to propagate back through ten states of TD updates before the critic knows about it, and by then the actor has made "left" near-deterministic, so the states near the goal are rarely visited and the critic never learns their value. Higher lets the real +10 reach the advantage estimates directly. In this task, with a poor critic and a distant reward, ended marginally ahead of 0.95; with a pretrained or quickly learned critic, the earlier experiment says a lower would win. The general point: bias in actor-critic is not only an error in one gradient, it can steer which data you collect next, and that can make it permanent.

Actor-critic vs REINFORCE, and A2C vs A3C#

REINFORCE with a learned value baseline is GAE at ; one-step actor-critic is GAE at . Sutton and Barto reserve the name actor-critic for methods that bootstrap, where the critic's estimate actually replaces part of the return [1]. In practice the boundary is a slider, and most modern implementations sit near the REINFORCE end with .

REINFORCE with baseline ()One-step actor-critic ()GAE, intermediate
Advantage estimate
Bias from critic errorNoneLargestTunable
VarianceHighestLowestTunable
Can update mid-episodeNoYesYes, over a truncated window

A3C, introduced by Mnih and colleagues [8], runs many actors in parallel threads, each computing -step advantage actor-critic gradients and applying them asynchronously to shared parameters; an entropy bonus keeps the policy from collapsing early. A2C is the synchronous variant: all workers step in lockstep and their gradients are averaged into one batched update, which uses accelerators better and is easier to reproduce. The algorithmic core, an advantage actor-critic with -step or GAE advantages, is the same. PPO adds a clipped objective on top of that core so one batch can support several update epochs; see TRPO and PPO explained.

GAE in numpy#

This is the backward recursion used throughout this page, with the two details implementations most often get wrong: no bootstrapping across true episode ends, and bootstrapping from the critic when an episode is cut off by a time limit.

import numpy as np

def gae(rewards, values, next_values, terminated, gamma=0.99, lam=0.95):
    """rewards, values, next_values, terminated: arrays of length T for one rollout.
    values[t] = V(s_t); next_values[t] = V(s_{t+1}) (use V of the last observed state
    when the rollout was truncated by a time limit); terminated[t] = 1 if s_{t+1} is terminal.
    Returns advantages and lambda-return targets for the critic."""
    T = len(rewards)
    adv = np.zeros(T)
    running = 0.0
    for t in range(T - 1, -1, -1):
        nonterminal = 1.0 - terminated[t]
        delta = rewards[t] + gamma * next_values[t] * nonterminal - values[t]
        running = delta + gamma * lam * nonterminal * running
        adv[t] = running
    return adv, adv + values

Treating a time-limit cutoff as a true terminal state teaches the critic that the world ends at step 1,000, which biases both the critic and the advantages; Pardo and colleagues analyse this failure and the fix [9].

Practical guidance#

  1. Start at between 0.9 and 0.95, . These are safe when the critic is poor: at critic errors of 2 and 3, was within 7% of the lowest MSE in our chain. With a good critic they are too conservative; at error 1 the best value was 0.7.
  2. Lower only when you trust the critic. A pretrained or well-converged value function, dense rewards, and long noisy episodes favour more bootstrapping.
  3. Raise when rewards are sparse or delayed. A critic cannot bootstrap information it has never seen, as the learning experiment showed.
  4. Give the critic enough capacity and updates. More value-function steps per batch, a separate network or a larger learning rate for the critic are common fixes. Andrychowicz and colleagues' large study of on-policy design choices recommends GAE with and found separate policy and value networks performed better [10].
  5. Normalize advantages per batch. It stabilizes step sizes across tasks; remember it rescales, so it interacts with the learning rate.
  6. Handle episode ends correctly. Do not bootstrap through terminal states; do bootstrap through time-limit truncations.
  7. Compare settings across seeds. Differences between and 1 in our runs were within run-to-run spread; see how to evaluate RL agents.

Failure modes#

  • Myopic lock-in. A pessimistic or untrained critic plus low can drive the actor to a short-sighted policy before the critic learns, as in our chain.
  • Critic lag. The critic estimates the value of an older policy. Large actor steps make it stale; trust regions limit how far the actor moves per batch.
  • Shared-network interference. A shared torso for actor and critic is cheaper but lets value-loss gradients overwhelm policy gradients; weight the losses or separate the networks.
  • Reward scale. Value targets that span orders of magnitude make the critic hard to fit. Normalizing rewards or returns helps the critic more than the actor.

Actor-critic methods are the practical form of policy gradients for most problems, and the same structure appears in RL for language models, where the critic is a value head on the policy model and controls how per-token rewards and a sequence-level score are blended into advantages. The broader map is in what is reinforcement learning.

Frequently asked questions#

What is an actor-critic method?

It is a reinforcement learning method with two learned parts: an actor, the policy, updated by policy gradient, and a critic, a value function updated by temporal-difference learning. The critic supplies advantage estimates such as the TD error, which are far less noisy than Monte Carlo returns, at the cost of bias when the critic is wrong.

What is generalized advantage estimation (GAE)?

GAE estimates the advantage as a discounted sum of TD errors with weights (gamma times lambda) to the power l. It is an exponentially weighted average of all n-step advantage estimates. Lambda equal to 0 gives the one-step TD error; lambda equal to 1 gives the Monte Carlo return minus the value baseline.

How does lambda trade bias for variance in GAE?

Low lambda relies on the critic after few real rewards, which lowers variance but passes critic error into the advantage. High lambda uses more real rewards, which removes that bias but adds the noise of many random rewards. In our chain the best lambda rose from 0.1 with an exact critic to 0.85 with a poor one.

What lambda should I use for GAE?

A value between 0.9 and 0.97 is a common, safe default, and 0.95 is the default in many PPO implementations. The original GAE paper found the best results at intermediate values, roughly 0.92 to 0.99. Use lower values only when the critic is accurate, and higher values when rewards are sparse or the critic is untrained.

Why is the TD error an estimate of the advantage?

If the critic equals the true value function, the expected TD error after taking action a in state s is the expected reward plus discounted next-state value, which is Q(s, a), minus V(s). That difference is exactly the advantage. With an inexact critic the TD error is biased by the critic's error at the next state.

What is the difference between A2C and A3C?

Both are advantage actor-critic methods. A3C runs parallel workers that compute gradients and apply them asynchronously to shared parameters. A2C is synchronous: workers step together and their experience is combined into one batched update, which is easier to reproduce and uses accelerators better. The learning rule is essentially the same.

Is REINFORCE with a baseline an actor-critic method?

By Sutton and Barto's definition, no: its value function is used only as a baseline subtracted from a full Monte Carlo return, not to bootstrap. It corresponds to GAE with lambda equal to 1, which is unbiased whatever the value estimate. In practice the distinction is a point on the lambda slider.

Sources#

  1. R. S. Sutton, A. G. Barto. Reinforcement Learning: An Introduction (2nd ed.), 2018. incompleteideas.net
  2. R. S. Sutton, D. McAllester, S. Singh, Y. Mansour. Policy Gradient Methods for Reinforcement Learning with Function Approximation, 1999. proceedings.neurips.cc
  3. R. J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning, 1992. doi.org
  4. J. Schulman, P. Moritz, S. Levine, M. Jordan, P. Abbeel. High-Dimensional Continuous Control Using Generalized Advantage Estimation, 2015. arxiv.org
  5. A. G. Barto, R. S. Sutton, C. W. Anderson. Neuronlike adaptive elements that can solve difficult learning control problems, 1983. doi.org
  6. R. S. Sutton. Learning to predict by the methods of temporal differences, 1988. doi.org
  7. V. R. Konda, J. N. Tsitsiklis. Actor-Critic Algorithms, 1999. proceedings.neurips.cc
  8. V. Mnih, A. P. Badia, M. Mirza, A. Graves, T. P. Lillicrap, T. Harley, D. Silver, K. Kavukcuoglu. Asynchronous Methods for Deep Reinforcement Learning, 2016. arxiv.org
  9. F. Pardo, A. Tavakoli, V. Levdik, P. Kormushev. Time Limits in Reinforcement Learning, 2017. arxiv.org
  10. M. Andrychowicz, A. Raichuk, P. Stańczyk, M. Orsini, S. Girgin, R. Marinier, L. Hussenot, M. Geist, O. Pietquin, M. Michalski, S. Gelly, O. Bachem. What Matters In On-Policy Reinforcement Learning? A Large-Scale Empirical Study, 2020. arxiv.org

Know the number before you ship.

A 45-minute working session with an evaluation engineer. Bring one use case; leave with a threat model, a draft eval plan with sample sizes, and an honest read on where you stand.