Generalized Advantage Estimation (GAE)
The Bias-Variance Tradeoff
Section titled “The Bias-Variance Tradeoff”How do we estimate the advantage ? There are many options:
Monte Carlo (high variance, no bias):
TD(0) (low variance, high bias):
where is the TD residual.
Monte Carlo uses the actual return (accurate but noisy). TD uses the value estimate (smooth but biased by errors).
GAE: The Best of Both Worlds
Section titled “GAE: The Best of Both Worlds”Generalized Advantage Estimation (Schulman et al., 2016) interpolates between these extremes with a parameter :
This can be written recursively:
The Role of
Section titled “The Role of λ\lambdaλ”| Equivalent to | Bias | Variance | |
|---|---|---|---|
| TD(0): | High | Low | |
| Monte Carlo: | None | High | |
| Weighted mix of n-step returns | Medium | Medium |
Worked Example: Computing GAE Across a 4-Step Episode
Section titled “Worked Example: Computing GAE Across a 4-Step Episode”Concrete numbers. Rewards , value estimates (the last is for terminal), .
TD residuals :
GAE recursion , with three different values:
| t | , λ=0 (TD(0)) | , λ=0.5 | , λ=1 (MC) | |
|---|---|---|---|---|
| 3 | 1.00 | 1.000 | 1.000 | 1.000 |
| 2 | 0.40 | 0.400 | 0.400 + 0.45·1.000 = 0.850 | 0.400 + 0.9·1.000 = 1.300 |
| 1 | 0.05 | 0.050 | 0.050 + 0.45·0.850 = 0.433 | 0.050 + 0.9·1.300 = 1.220 |
| 0 | 0.56 | 0.560 | 0.560 + 0.45·0.433 = 0.755 | 0.560 + 0.9·1.220 = 1.658 |
At the GAE value matches the Monte Carlo return-minus-baseline exactly (you can verify: , and ✓). At each depends only on the one-step bootstrap — if is mis-calibrated even a little, that bias appears everywhere. Intermediate mixes them: a longer-horizon estimate where you still trust enough to short-circuit far-future noise.
GAE in the PPO Pipeline
Section titled “GAE in the PPO Pipeline”The full PPO training loop:
- Collect rollout data with current policy
- Compute TD residuals:
- Compute GAE advantages:
- Compute targets for the value function:
- Run multiple epochs of mini-batch updates on and the value loss
Interactive: GAE-(γ,λ) Calculator
Section titled “Interactive: GAE-(γ,λ) Calculator”Edit the rewards or value estimates and slide to watch morph between pure TD(0) (red) and pure Monte Carlo (green). With a perfectly-calibrated , all three curves coincide; introduce bias into and watch them diverge.
Why Not Just Monte Carlo?
Section titled “Why Not Just Monte Carlo?”In LLM training (RLHF), episodes can be long (hundreds of tokens). Monte Carlo returns have very high variance because each token’s reward signal is buried under the noise of all future tokens.
GAE with exponentially downweights distant TD residuals, giving a much cleaner signal for credit assignment — which token actually contributed to the reward?
References
Section titled “References”- Schulman, Moritz, Levine, Jordan, Abbeel. High-Dimensional Continuous Control Using Generalized Advantage Estimation. ICLR 2016. arXiv:1506.02438