Push up the log-probability of each action in proportion to how good it turned out. Every method on this page uses that one gradient, ∇θ log πθ(a | s) × weight, and differs in only two places: what number the weight is (the return, the return minus a baseline, a critic's estimate) and how far one batch of data may move the policy (a step size, a KL limit, a clip, an entropy bonus).
Fig. 1 · one update of a softmax policy, step by step
You need: TD errors, TD(λ) and importance sampling from Model-free prediction and control (the critics here learn those targets); replay buffers and target networks from Value-based deep RL (DDPG, TD3 and SAC borrow them). The one-state version of the policy gradient is the gradient bandit on Bandits and exploration.
First dial: from the first box to the last, the weight relies less on sampled rewards and more on a learned critic, so variance falls and the critic's bias enters. Second dial: on-policy methods limit the step on fresh data (step size, KL, clip); off-policy ones reuse a replay buffer and need target networks, and SAC adds entropy to the objective. Tap a box to jump to its section.
| Method | What weights ∇ log π(a | s) | How far a step may go | Data | Actions |
|---|---|---|---|---|
| REINFORCE (1992) | The sampled return Gt | Step size only | On-policy, whole episodes | Any |
| REINFORCE with baseline; RLOO, GRPO | Gt − b(st): a learned V, or the other samples' mean reward | Step size (GRPO borrows PPO's clip) | On-policy | Any |
| Actor-critic (1983) | The critic's TD error δt = r + γV(s′) − V(s) | Step size | On-policy, every step | Any |
| GAE (2015) | Σ (γλ)l δt+l: λ slides from TD error to return minus V | (an estimator, used by the rows below) | On-policy | Any |
| A3C (2016), A2C (2017) | n-step return minus V | Step size; parallel actors decorrelate the data | On-policy | Any |
| Natural gradient (2001), TRPO (2015) | The advantage, through an importance ratio | A hard KL limit δ, solved with the Fisher matrix | On-policy | Any |
| PPO (2017) | GAE advantage times a clipped ratio | The clip removes the incentive beyond 1 ± ε | Approximately on-policy: a few epochs per batch | Any |
| DPG (2014), DDPG (2015) | No log-probability: the critic's slope ∇aQ(s, a) through a deterministic actor | Soft target networks | Off-policy, replay | Continuous |
| TD3 (2018) | As DDPG, with the smaller of two critics | Delayed actor updates | Off-policy, replay | Continuous |
| SAC (2018) | The soft Q, minus α log π, through a reparameterised stochastic actor | The entropy bonus keeps the policy wide | Off-policy, replay | Continuous |
Rows jump to their section. Dates and first papers match the parent's Method atlas tab, which places these among the other 47 methods. Widgets are computed exactly in the page and checked against Python; numbers are published (source linked) unless marked derived or illustrative. PPO for RLHF with its four models, GRPO, RLOO and their corrections on language models are on RL for LLMs.
A value-based agent acts by arg maxa Q(s, a): a maximisation over actions at every step, awkward when the action is a vector of joint torques and expensive when it is one of 100,000 tokens, and it only yields a deterministic policy plus bolted-on exploration noise. A parameterised policy has four advantages (Sutton and Barto §13.1): continuous and huge action spaces are natural (a Gaussian over torques, a softmax over tokens); the optimal policy may be stochastic (card games with hidden information, or states the agent cannot tell apart: an ε-greedy action-value method cannot represent specific probabilities; a softmax policy can); smooth change, since probabilities move continuously with θ while an arbitrarily small change in estimated values can flip an ε-greedy choice ("Largely because of this, stronger convergence guarantees are available for policy-gradient methods than for action-value methods", §13.2); and prior knowledge goes into the form of the policy, "often the most important reason for using a policy-based learning method".
The short corridor (Example 13.1) is the smallest problem on which a policy-gradient method beats every action-value method that uses the same features, and it runs through sections 3 to 5. Three states, reward −1 per step, actions right and left, switched in the second state; every state has the same features, so a policy is one number, p = probability of right.
In the first and third states right moves right and left moves left (left in the first state bumps the wall). Write v1, v2, v3 for the three states under "right with probability p". The Bellman equations are v1 = −1 + p v2 + (1 − p) v1; v2 = −1 + p v1 + (1 − p) v3 (switched); v3 = −1 + (1 − p) v2. Solving gives J(p) = v1 = 2(2 − p) / (p(p − 1)). Setting dJ/dp = 0 gives p* = 2 − √2 ≈ 0.5858 and J* ≈ −11.657 derived. The ε-greedy policies with ε = 0.1 choose their greedy action with probability 1 − ε/2 = 0.95: J(0.95) = −44.21 and J(0.05) = −82.11, the book's "less than −44 and −82" derived.
The value of the start state is J(p) = 2(2 − p) / (p(p − 1)), maximised at p* = 2 − √2 ≈ 0.586 with J* = −(6 + 4√2) ≈ −11.66 derived. The two policies an ε-greedy method can reach (ε = 0.1) choose right with probability 0.95 or 0.05 and score −44.2 and −82.1. The book: "The best probability is about 0.59, which achieves a value of about −11.6."
Everything below needs only the score ∇θ log π(a | s, θ). Nearly every implementation uses one of two:
The Gaussian score needs no environment: with σ fixed, reward times noise over σ, averaged over samples, estimates the gradient of the expected reward with respect to μ. Dust uses exactly this to train a transformer with no backward pass: it adds noise to each token's activations at a layer, scores each token by its own loss change against the mean over draws (the baseline), and the reward-weighted noise estimates the error at that layer's output (Dust).
The objective is the expected return of trajectories τ = (s0, a0, r1, s1, ...) sampled by running the policy, J(θ) = 𝔼τ~πθ[G(τ)]. The difficulty: θ changes which trajectories happen, through a state distribution that depends on unknown dynamics. Four steps remove it.
Fig. 2 · causality deletes the lower triangle
The second form is the statement in Sutton et al. (1999) and in the book, which proves it by unrolling ∇vπ(s) = Σa [∇π(a | s) qπ(s, a) + π(a | s) ∇qπ(s, a)] through the Bellman equation (the box on p. 325). Its point: the gradient does not involve the derivative of the state distribution, which depends on the unknown environment.
The same paper's Theorem 2 says when a learned fw(s, a) can replace Qπ without biasing the gradient: if fw is a local optimum of the squared error to Qπ under π, and its gradient in w equals the policy's score, ∂fw/∂w = ∇θ π(s, a) / π(s, a). Its Theorem 3 then shows that "a form of policy iteration with function approximation is convergent to a locally optimal policy" under standard step-size conditions. Practical critics are not compatible in this sense; the theorem is why "a critic that is exactly right gives the exact gradient" holds and an arbitrary one does not.
REINFORCE (Williams 1992) samples the theorem directly: run an episode, then use each step's return as the estimate of Qπ.
It is unbiased: the expected update is the gradient, which assures improvement for a small enough α and convergence to a local optimum with decreasing step sizes (§13.3). It has high variance: one episode's return carries the randomness of every later action and transition. It needs episodes that end and updates only afterwards. And when every reward is positive, every sampled action is pushed up, the good ones merely more than the bad; when every reward is negative (the short corridor), every sampled action is pushed down. The policy still improves on average, slowly. With θ started at p(right) = 0.05 and 100 runs averaged, REINFORCE with α = 2−13 climbs from −82 to within about one unit of J* over 1,000 episodes, and α = 2−14 more slowly (Figure 13.1, rerun in section 4).
REINFORCE is an acronym, "REward Increment = Nonnegative Factor times Offset Reinforcement times Characteristic Eligibility", which describes the update's form, Δw = α(r − b)e: a step size, a reward minus a baseline, and the score.
Learning rate 0.1, 60 updates of one sampled action each. Bars are the policy's probabilities; thin marks are this sample's update (purple) against the exact expected gradient (grey); variance is the exact total variance of the one-sample estimate at the current policy. With offset 10, 86 of 200 seeded runs without a baseline lock onto a worse action within 60 updates, against none with it derived.
Subtract from the return any baseline b(s) that may depend on the state but not on the action. The gradient is unchanged in expectation, because the subtracted term averages to zero:
The natural choice is b(s) = Vπ(s), which turns the weight into the advantage Aπ(s, a) = Qπ(s, a) − Vπ(s): better-than-average actions are pushed up, worse-than-average ones down. "In some states all actions have high values and we need a high baseline to differentiate the higher valued actions from the less highly valued ones; in other states all actions will have low values and a low baseline is appropriate" (§13.4).
The identity needs on-policy samples. 𝔼a~π[∇ log π] = 0 holds only when the action is drawn from π itself. When it is drawn from another policy q but scored through π (an LLM's rollout engine against its trainer), 𝔼a~q[∇ log π] is not zero, and every update gains a term, the mean reward times that vector, that pulls π toward q whatever the rewards say. Subtracting 𝔼a~q[∇ log π] from each sample's score (score centering) restores the zero mean; unlike a baseline it moves the mean of the estimate rather than its variance, a bias correction, not a variance reduction (RL for LLMs, section 8; Score Centering).
Worked example illustrative: one state, three actions with rewards 1, 2 and 6, a softmax with all logits 0, so each action has probability 1/3 and V = 3. The score with respect to the logits is ea − π, so the exact gradient is πk(Rk − V) = (−0.667, −0.333, 1).
Predict, then move the offset to 10: adding 10 to every reward changes nothing about which action is best. Does REINFORCE without a baseline still find action 3 within 60 updates?
The animation, in five stretches
Which baseline minimises the variance? For a constant b, the variance of (Ra − b)∇ log π(a) is a parabola in b with its minimum at the score-weighted mean b* = 𝔼[‖∇ log π‖2 R] / 𝔼[‖∇ log π‖2], not at V = 𝔼[R] (Greensmith, Bartlett and Baxter 2004, who "show that the popular approach of using the average reward to define the baseline can be suboptimal"). When every action's score has the same length, as at the uniform policy above, the two coincide; otherwise V is close, and it is what practice uses because it can be learned.
Exact, not sampled: mean and variance are sums over the three actions weighted by their probabilities. Try: raise the logit of action 3 to 2 and watch b* leave V.
A learned baseline. V is unknown, so it is learned alongside the policy: Sutton and Barto's "REINFORCE with baseline" fits v̂(s, w) to the returns by Monte Carlo and updates θ with Gt − v̂(St, w) (box on p. 330). On the short corridor a one-number baseline, v̂ = w, with αθ = 2−9 and αw = 2−6, reaches the optimum within about 100 episodes, where REINFORCE at its best step size needs most of 1,000 (Figure 13.2, rerun below). The baseline also allows a 16 times larger policy step without diverging.
Total reward per episode, averaged over seeded runs computed in your browser when the card comes into view; dashed: v*(s0) = −11.66. With 100 runs the baseline curve is within about 0.5 of J* by episodes 100 to 200, while REINFORCE at 2−13 is still near −25 there and approaches −12.6 by the end.
The curve is J(p) from section 1; each dot is one learning run, one frame every 10 episodes: REINFORCE with α = 2−13, REINFORCE with a learned baseline (αθ = 2−9, αw = 2−6, the book's settings for Figure 13.2), and one-step actor-critic with the same step sizes (not in the book). The average over 100 runs is the actor-critic curve in the figure above (turn it on there).
An actor-critic learns an actor π(a | s, θ), updated by the policy gradient, and a critic v̂(s, w), trained by TD learning, whose estimate of the next state turns one real reward into an assessment of the action just taken. Barto, Sutton and Anderson (1983) balanced a pole with an "adaptive critic element" and an "associative search element"; the root's Method atlas dates the family there.
The trade is Model-free prediction and control's Monte Carlo against TD trade, moved to policies: one real reward and the critic's estimate give low variance and an update every step, but when the critic is wrong the weight is biased. The book adds: "the bias in the gradient estimate is not due to bootstrapping as such; the actor would be biased even if the critic was learned by a Monte Carlo method." Between the two ends sit n-step and λ-returns, which section 6 turns into an advantage estimator.
When the critic is too poor. Give the one-step actor-critic the same one-number critic as the baseline, v̂(s, w) = w. Every state looks the same to it, so δ = −1 + w − w = −1 on every step except the last, where δ = −1 − w > 0 derived. The last action of every episode is right from the third state, so the critic keeps crediting right, and the policy drifts past the optimum to the 0.95 floor (−44 per episode) within a few hundred episodes, while REINFORCE with the same baseline settles at the optimum. With a critic this poor, the actor-critic's bias wins over its lower variance; a smaller actor step (2−12) delays the drift but does not stop it. A baseline only has to be a number; a critic has to tell states apart.
The animation, in eight stretches (seed 1; p(right) for REINFORCE, with baseline, actor-critic)
The second episode is a chain whose only reward, 1, arrives at the end, with exact values V(st) = γ7−t plus the critic error illustrative. The chain is deterministic, so every true advantage is 0 and anything else is the critic's bias: at λ = 0 the first advantage is −0.3(1 − γ) = −0.003, at λ = 1 it is −0.3 exactly (a wrong baseline shifts every advantage by the same amount without biasing the expected gradient; the λ = 0 estimate is biased through the wrong V(st+1) inside each TD error). Try: error 0 (every advantage is 0 at every λ), then 0.3, and slide λ.
Worked example (γ = 1): a three-step episode with rewards 0, 0, 1 and critic values V(s0) = 0.5, V(s1) = 0.6, V(s2) = 0.8. The TD errors are δ0 = 0.1, δ1 = 0.2, δ2 = 1 − 0.8 = 0.2. The first action's advantage is 0.1 if we trust the critic after one step (λ = 0); 0.5 if we use the whole return, 1 minus V(s0) = 0.5 (λ = 1); and 0.1 + 0.95 × 0.2 + 0.952 × 0.2 = 0.4705 at λ = 0.95 derived. Every implementation computes it backwards, one TD error at a time:
The animation, in four steps (numbers for the worked example at λ = 0.95)
Between the one-step TD error and the full return sits a family of k-step estimators, Â(k)t = Σl<k γl δt+l = rt + γrt+1 + ... + γk−1rt+k−1 + γkV(st+k) − V(st) (the sum telescopes). GAE (Schulman et al. 2015) averages them with weights (1 − λ)λk−1, exactly as TD(λ) averages n-step returns, and the average collapses to a discounted sum of TD errors:
The two parameters bias different things: "Taking γ < 1 introduces bias into the policy gradient estimate, regardless of the value function's accuracy. On the other hand, λ < 1 introduces bias only when the value function is inaccurate." The paper concludes that "choosing an appropriate intermediate value of λ in the range [0.9, 0.99] usually results in the best performance"; PPO's reference settings use λ = 0.95 with γ = 0.99 (PPO, Tables 3 and 5). The bias-variance dial itself (bias squared, variance and mean squared error against λ) is drawn on Model-free prediction and control, which owns TD(λ); this section owns its use as an advantage estimator.
Best results at intermediate values: γ ∈ [0.96, 0.99] and λ ∈ [0.92, 0.99] on cart-pole, γ ∈ [0.99, 0.995] and λ ∈ [0.96, 0.99] on the 3D biped. With it, TRPO learned 3D biped and quadruped locomotion from raw joint states, with simulated experience equal to "1-2 weeks of real time" for the bipeds (Schulman et al. 2015).
On-policy methods cannot use a replay buffer (old data comes from old policies), yet consecutive transitions of one trajectory are highly correlated, which is what made naive deep RL unstable. A3C, asynchronous advantage actor-critic (Mnih et al. 2016), decorrelates the data with many actor-learners, each with its own copy of the environment, exploring different states at the same moment and applying their gradients to shared weights asynchronously. Each uses an n-step return minus V as its advantage, plus an entropy bonus: "adding the entropy of the policy π to the objective function improved exploration by discouraging premature convergence to suboptimal deterministic policies" (weight β = 0.01 on Atari). It "surpasses the current state-of-the-art on the Atari domain while training for half the time on a single multi-core CPU instead of a GPU", with 16 actor-learner threads.
A2C is the synchronous version. OpenAI's Baselines release found "Our synchronous A2C implementation performs better than our asynchronous implementations; we have not seen any evidence that the noise introduced by asynchrony provides any performance benefit", and that it "is more cost-effective than A3C when using single-GPU machines, and is faster than a CPU-only A3C implementation when using larger policies" (OpenAI Baselines: ACKTR and A2C, 2017, Wayback copy). The parallel actors helped; the asynchrony did not (one of the root Method atlas's corrections). A batch of rollouts from parallel environments, then one update, is the shape of PPO and of every LLM RL loop since.
Four workers, time to the right illustrative timings. Bars are n-step rollouts labelled with the version of the shared weights θ they were computed on; a tick is a gradient applied, making the version written beside it. In A3C, worker 3's second gradient was computed on θ version 4 but is applied as version 9: four other updates landed while it rolled out (stale). In A2C the faster workers idle (hatched) at the barrier, then one update averages all four.
Why the step size is dangerous. The policy gradient is only valid near the policy that collected the data. In supervised learning a too-large step costs one bad update; in RL the next batch is sampled from the broken policy, so the data itself degrades and training may never recover. Two goals follow: the largest step that is still safe, and several gradient steps on one expensive batch of rollouts.
The step is measured in the wrong units. Take two actions with logit difference z, so p = σ(z). From p = 0.5, a step Δz = 1 moves p to 0.731, a KL divergence of 0.120; from p = 0.99 the same step moves it to 0.996, a KL of 0.0037, 33 times less derived. Gradient ascent is not covariant: reparameterise the policy and its steps change. The fix is to measure distance by how much the action distribution changes. To second order, KL(πθ ‖ πθ+Δ) ≈ ½ Δ⊤FΔ, where F = 𝔼[∇ log π ∇ log π⊤] is the Fisher information matrix (for two actions, F = p(1 − p): 0.25 at p = 0.5, 0.0099 at p = 0.99).
Kakade (2001) introduced this natural policy gradient (his words and caveat are below). In the example, a KL budget of 0.01 allows Δz = 0.283 at p = 0.5 (exact KL 0.00997) and Δz = 1.42 at p = 0.99 (exact KL 0.0066: the quadratic approximation is loose far from the centre, which is why TRPO checks the true KL with a line search) derived.
Exact KL(πold ‖ πnew) of two-action policies. Defaults reproduce the text's numbers at p = 0.5; drag to 0.99 for the other pair.
TRPO, trust region policy optimisation (Schulman et al. 2015), turns this into an algorithm. With the importance ratio rt(θ) = πθ(at | st) / πθold(at | st), maximising the surrogate 𝔼t[rt(θ) Ât] has the same gradient as the policy gradient at θ = θold, and the ratio corrects for the drift as θ moves (the importance-sampling correction of Model-free prediction and control, applied to a slightly stale policy). Theory bounds how far the surrogate can mislead, but its penalty is far too conservative, so TRPO uses a hard constraint:
It works, but the second-order machinery is heavy, and TRPO is "not compatible with architectures that include noise (such as dropout) or parameter sharing (between the policy and value function, or with auxiliary tasks)" (PPO, §1). PPO keeps the idea and drops the machinery.
"the standard gradient descent rule is non-covariant ... we present a covariant gradient by defining a metric based on the underlying structure of the policy"; and "the natural gradient is moving toward choosing a greedy optimal action rather than just a better action." He also notes that the averaged F is not fully invariant, because of the weighting by the state distribution.
From its Theorem 1 (stated with total variation) the paper derives η(π̃) ≥ Lπ(π̃) − C · maxs KL(π ‖ π̃), with C = 4εγ / (1 − γ)2 and ε = max |Aπ(s, a)| (Eq. 9), so maximising the penalised surrogate improves the true return monotonically. The penalty coefficient that theory gives is far too conservative in practice, hence the constraint.
It tried two ways of collecting data, "single path" (ordinary rollouts) and "vine" (branching rollouts from states along a trunk, which needs a resettable simulator), and learned "simulated robotic swimming, hopping, and walking gaits; and playing Atari games using images of the screen as input".
PPO, proximal policy optimisation (Schulman et al. 2017), replaces TRPO's constraint with a pessimistic objective that plain stochastic gradient ascent can optimise. Four cases with ε = 0.2 show what it does:
| Case (ε = 0.2) | r  | clip(r)  | Objective (the min) | Gradient |
|---|---|---|---|---|
| Â = +2, r = 1.5 | 3.0 | 1.2 × 2 = 2.4 | 2.4 | zero: already raised past 1 + ε |
| Â = +2, r = 0.7 | 1.4 | 0.8 × 2 = 1.6 | 1.4 | active: a good action became less likely, so push it back up |
| Â = −1, r = 0.7 | −0.7 | 0.8 × (−1) = −0.8 | −0.8 | zero: already lowered past 1 − ε |
| Â = −1, r = 1.5 | −1.5 | 1.2 × (−1) = −1.2 | −1.5 | active: a bad action became more likely, so push it back down |
A ratio that moved the wrong way (down for a good action, up for a bad one) is never clipped: the unclipped term is the smaller one there, so the full gradient pulls it back. The clip removes the incentive to exploit further; it never stops the correction of a mistake.
The dot is grey where the gradient is zero. Try r = 0.7 (the good action's objective still slopes, the bad action's is flat), then 1.5 (the reverse).
A softmax policy over three actions with starting logits (0, 0.5, −0.5), one sampled action (probability 0.307 under the old policy), its advantage, and plain gradient ascent on the surrogate for ten epochs illustrative. Raise η and the clipped run overshoots 1 + ε on its first step and then stops: the clip removes the incentive, it does not bound the ratio, which is why practitioners also watch the KL and the fraction of clipped samples.
What makes the min useful is reuse: several epochs of minibatch SGD on each batch of rollouts (10 epochs in the paper's MuJoCo runs, 3 on Atari). Before and after, on one sample:
Predict: raise the step size η to 0.6 with the clip on. Does the ratio stay inside 1 ± ε?
The animation, in four steps (numbers at ε = 0.2, η = 0.2)
The full loss. With a network shared between policy and value, PPO maximises LCLIP+VF+S = 𝔼t[LCLIP − c1(Vθ(st) − Vtargt)2 + c2 S[πθ](st)]: a value regression term and an entropy bonus S. The algorithm: N parallel actors each run the policy for T steps, compute truncated GAE advantages, optimise the loss for K epochs with minibatches, repeat. In the paper's ablation (7 MuJoCo tasks), no clipping or penalty scored −0.39 against 0.82 for the clip at ε = 0.2, with KL penalties in between (details below). Its practical success made it the default on-policy algorithm (in Stable-Baselines3, CleanRL and verl; OpenAI Five was trained with it) and the template that RLHF and GRPO adapt (RL for LLMs).
The paper also tried a soft version of TRPO's constraint, maximising 𝔼[rt Ât − β KL(πold ‖ πθ)] with β either fixed or adapted after each update toward a target KL dtarg: "If d < dtarg/1.5, β ← β/2; If d > dtarg × 1.5, β ← β × 2" ("chosen heuristically, but the algorithm is not very sensitive to them"). Table 1: 7 MuJoCo tasks, 3 seeds each, one million timesteps, scores normalised so a random policy is 0 and the best result 1.
| Variant | Normalised score |
|---|---|
| No clipping or penalty | −0.39 |
| Clipping, ε = 0.1 / 0.2 / 0.3 | 0.76 / 0.82 / 0.70 |
| Adaptive KL, dtarg = 0.003 / 0.01 / 0.03 | 0.68 / 0.74 / 0.71 |
| Fixed KL, β = 0.3 / 1 / 3 / 10 | 0.62 / 0.71 / 0.72 / 0.69 |
The unclipped score is negative "because for one environment (half cheetah) it leads to a very negative score" (PPO, §6.1, Table 1).
| PPO paper settings | MuJoCo (Table 3) | Atari (Table 5) |
|---|---|---|
| Horizon T | 2048 | 128 |
| Adam step size | 3 × 10−4 | 2.5 × 10−4 × α |
| Epochs K | 10 | 3 |
| Minibatch | 64 | 32 × 8 |
| γ, λ | 0.99, 0.95 | 0.99, 0.95 |
| Parallel actors | not listed | 8 |
| Clip ε | 0.2 | 0.1 × α |
| c1, c2 | separate networks, no entropy bonus | 1, 0.01 |
On 49 Atari games, PPO had the best average reward over all of training in 30 games (ACER 18, A2C 1), but the best over the last 100 episodes in only 19 (ACER 28, A2C 1, one tie) (Table 2): PPO learns fast and simply rather than reaching the highest final scores.
PPO's paper describes an objective; its results come from an implementation. Engstrom et al. (2020) isolated nine "code-level optimisations" in the reference code and found they "are responsible for most of PPO's gain in cumulative reward over TRPO": with them, TRPO ("TRPO+") matched or beat PPO. And the clip does not do what its name suggests: "all three algorithms fail to maintain a ratio-based trust region, despite PPO and PPO-M being trained directly with a ratio-clipping objective", although all keep a KL-based one. Their summary: "code-level optimizations contribute to algorithms' increased performance often significantly more than the choice of algorithm."
Seeds. Deep RL results vary so much across random seeds that one run misleads: Henderson et al. (2018) split ten TRPO runs on HalfCheetah into two groups of five seeds and got significantly different curves (t = −9.09, p = 0.0016): "the variance between runs is enough to create statistically different distributions just from varying random seeds." Report interquartile means with bootstrap intervals (below).
Value function clipping, reward scaling, orthogonal initialisation and layer scaling, Adam learning-rate annealing, reward clipping, observation normalisation, observation clipping, tanh activations, global gradient clipping. On Hopper, PPO 2513, PPO without them ("PPO-M") 2142, TRPO 2043, TRPO+ 2466; on Humanoid TRPO+ 1030 against PPO's 806 (Engstrom et al. 2020).
Huang et al., "The 37 Implementation Details of Proximal Policy Optimization" (ICLR blog track, 2022) reproduced the official code detail by detail: 13 core details, 9 for Atari, 9 for continuous actions, 5 for LSTMs and 1 for multi-discrete actions. The 13 core ones:
The largest study, Andrychowicz et al. (2021), trained "over 250'000 agents in five continuous control environments" across more than 50 choices. Its recommendations: "Use the PPO policy loss. Start with the clipping threshold set to 0.25"; "Initialize the last policy layer with 100× smaller weights" and use softplus for the standard deviation; "Always use observation normalization"; "Use GAE with λ = 0.9 but neither Huber loss nor PPO-style value loss clipping"; the discount γ "is one of the most important hyperparameters and should be tuned per environment (start with γ = 0.99)"; and Adam with 0.0003 as "a safe default".
Agarwal et al. (2021) recommend "interval estimates via stratified bootstrap confidence intervals, as opposed to point estimates", and the interquartile mean, which "discards the bottom and top 25% of the runs".
For a robot arm the action is a vector of torques, and Q-learning's max over actions becomes an optimisation problem at every step. The off-policy actor-critics train an actor that performs the max. Their theory is the deterministic policy gradient (Silver et al. 2014): for a deterministic policy a = μθ(s),
There is no log-probability and no integral over actions, only over states, so "the deterministic policy gradient can be estimated much more efficiently than the usual stochastic policy gradient", and it is "the limiting case, as policy variance tends to zero, of the stochastic policy gradient" (Theorem 2). Because the expectation is only over states, it can be learned from data gathered by any exploratory behaviour policy, without importance ratios on actions.
Fig. 11 · one loop serves DDPG, TD3 and SAC: replay feeds a critic, the critic's slope trains the actor, slow target copies make the critic's target
DDPG: the critic regresses onto y = r + γQ′(s′, μ′(s′)); the actor climbs the critic's slope ∇ₐQ through the chain rule; exploration is noise added to the action; the targets follow the learned networks slowly (τ = 0.001).
DDPG, deep deterministic policy gradient (Lillicrap et al. 2015), put this on networks with DQN's two stabilisers: a replay buffer (106 transitions) and target networks, here updated softly, θ′ ← τθ + (1 − τ)θ′ with τ = 0.001. The critic regresses onto r + γQ′(s′, μ′(s′)); the actor climbs ∇aQ; exploration is noise added to the actor's output. It "robustly solves more than 20 simulated physics tasks", nearly all "within 2.5 million steps of experience (and usually far fewer), a factor of 20 fewer steps than DQN requires" for Atari. In practice it proved brittle and sensitive to its settings, which is what TD3 set out to fix. (Replay and target networks are explained on Value-based deep RL.)
Exploration by an Ornstein-Uhlenbeck process with θ = 0.15, σ = 0.2; Adam with learning rates 10−4 (actor) and 10−3 (critic); L2 weight decay 10−2 on the critic; γ = 0.99; minibatch 64; batch normalisation.
The maximisation bias of Q-learning (the max of noisy estimates is biased upwards) does not need an explicit max: an actor trained to climb a noisy critic finds and exploits the critic's overestimates just as well. Fujimoto, van Hoof and Meger (2018) showed "this problem persists in an actor-critic setting" and fixed DDPG with three changes (switch Fig. 11 to TD3):
Paper: exploration noise 𝒩(0, 0.1), τ = 0.005, Adam 10−3, minibatch 100, and purely random actions for the first 10,000 steps (HalfCheetah, Ant) or 1,000 (the others). The authors' current code uses batch 256, learning rate 3 × 10−4 and 25,000 random steps, and its README warns it is "no longer exactly representative of the code used in the paper" (sfujim/TD3).
SAC, soft actor-critic (Haarnoja et al. 2018a; 2018b), changes the objective: maximise reward and the policy's entropy. A policy split evenly between two actions has entropy ln 2 ≈ 0.693, worth 0.2 × 0.693 ≈ 0.139 reward per step at α = 0.2; a deterministic policy earns nothing derived.
The entropy enters the Bellman equation too: the soft value is V(s) = 𝔼a~π[Q(s, a) − α log π(a | s)] and the critic's target is r + γ𝔼[V(s′)], with the minimum of two Q networks as in TD3. Policy improvement moves π toward the Boltzmann distribution of the critic, πnew = arg minπ′ KL(π′(· | s) ‖ exp(Q(s, ·)/α) / Z(s)); in practice the actor minimises 𝔼[α log π(a | s) − Q(s, a)] with actions drawn by the reparameterisation trick, a = tanh(μ(s) + σ(s) ⊙ ξ), ξ ~ 𝒩(0, I), so the gradient flows through the sampled action into the critic ("a lower variance estimator" than the score function). The tanh keeps actions bounded and changes the density: log π(a | s) = log μ(u | s) − Σi log(1 − tanh2(ui)) (Appendix C), a correction that implementations forget at their peril.
The temperature is learned. The 2018b version adjusts α so that the policy's entropy stays near a target ℋ̄, minimising J(α) = 𝔼[−α log π(a | s) − αℋ̄]; its gradient is ℋ(π) − ℋ̄, so α falls while the policy is more random than the target and rises when it is less. The default target is "−dim(A) (e.g., −6 for HalfCheetah-v1)". The widget shows what α does on a one-dimensional action illustrative reward, exact computation: a tall narrow reward peak at +0.6, a lower wide one at −0.5, and an effort cost 0.5a2. For each α it computes the soft-optimal policy exp(r/α)/Z and the best Gaussian actor (the maximiser of 𝔼[r] + αℋ over all Gaussians, SAC's projection onto its policy class).
Predict: as α rises from 0.005, does the best Gaussian widen smoothly on the tall peak, or jump?
The paper's claim is stability as much as sample efficiency: "in contrast to other off-policy algorithms, our approach is very stable, achieving very similar performance across different random seeds" (2018a). Entropy bonuses and KL penalties toward a reference policy play the role of α ℋ in LLM training, keeping the policy from collapsing onto one mode; a KL to a fixed reference pulls toward a particular distribution, not toward uniform, so it is not the same thing (RL for LLMs covers each there).
A Minitaur quadruped "learns to walk from 160k environment steps, or approximately 400 episodes ... approximately 2 hours of real-world training time", and a 3-finger dexterous hand learned to turn a valve from camera images in about 300,000 steps, "the equivalent of 20 hours of training" (from the valve's position alone, 3 hours, against 7.4 hours for PPO) (2018b, §7). Its settings are the defaults most libraries copied: Adam 3 × 10−4, γ = 0.99, replay 106, minibatch 256, τ = 0.005, two hidden layers of 256 units.
Below about 0.16 the best Gaussian sits narrowly on the tall peak; just above, it jumps to the wide peak, where it can be much wider for little lost reward; by α ≈ 0.3 it covers both. The soft-optimal policy (purple) changes smoothly and is bimodal in between: a single Gaussian cannot represent it, which is the price of SAC's policy class. Expected rewards and entropies are exact (closed form for the Gaussian, an 801-point grid for the soft-optimal policy); the Gaussian is found on a 481 × 241 grid of means and widths.
| Situation | Start with | Why, and what it costs |
|---|---|---|
| Any action space, cheap parallel simulation, stability first | PPO | Simple, robust to settings, first-order; on-policy, so it spends many environment steps |
| Continuous control, samples expensive (a real robot) | SAC, or TD3 | Off-policy replay buys sample efficiency; more moving parts (twin critics, target networks, a temperature) |
| A stochastic policy is required, or states are aliased | Any stochastic policy-gradient method | Greedy value methods cannot represent a specific probability (the short corridor) |
| Need a guaranteed small step, compute is not the constraint | TRPO or a natural-gradient method | The KL constraint is explicit; second-order machinery and no parameter sharing |
| A teaching or debugging baseline | REINFORCE with a learned baseline, or A2C | Few parts, unbiased (REINFORCE) or low-variance (A2C); slow |
| Discrete actions and replay matters most | The DQN family | See Value-based deep RL |
| Post-training a language model | PPO with a value model, or GRPO, RLOO and their corrections | See RL for LLMs |
On language models, PPO with a learned reward and a value model is the RLHF recipe; GRPO and RLOO delete the critic and use a group baseline, and the clip, the KL and the ratio all return in token form (RL for LLMs owns that, including the 2025 to 2026 corrections to GRPO). Beyond this page: AlphaZero's network is an actor-critic (a policy head and a value head) trained by search rather than by a policy gradient (Model-based RL and planning); offline actor-critics (CQL, IQL) and behaviour cloning learn with no interaction (Offline RL and imitation).
Why can DQN or SAC use a replay buffer but A2C cannot without corrections? Their targets do not depend on which policy chose the stored action (Q-learning's max, SAC's soft value under the current policy). A policy gradient is an expectation under the current policy, so stale data needs importance ratios, which PPO uses for slightly stale data only.
Links open in a new tab, with reading times. Times for papers are estimates for a careful first read of the main text.
Sutton and Barto's Example 13.1 solved exactly (section 1) and Figures 13.1 and 13.2 rerun in the browser (section 4), with a one-step actor-critic whose critic is too poor (section 5). (about 5 min)
The overview this page belongs to, with the Taxonomy, Method atlas (first paper and year of every method here, with corrections) and Milestones and benchmarks tabs (OpenAI Five was trained with PPO). (17 min, plus 2 in closed details)
The page before this one in reading order: DQN, replay and target networks (which DDPG, TD3 and SAC borrow), Double DQN's fix for the max bias that TD3 carries over. (29 min, plus 16 in closed details)
Monte Carlo, TD and TD(λ), the targets the critics on this page learn, and importance sampling, which the PPO and TRPO ratio applies. (34 min, plus 9 in closed details)
The gradient bandit: the policy gradient with one state, and the baseline that makes it work. (27 min, plus 9 in closed details)
The next page: Dyna, AlphaZero (an actor-critic network trained by search) and MuZero. (41 min, plus 9 in closed details)
Learning from a fixed dataset: behaviour cloning, CQL, IQL. (34 min, plus 9 in closed details)
PPO for RLHF with its four models, GRPO and RLOO, the clip on rare tokens, and the off-policy corrections of real training systems. (53 min, plus 13 in closed details)
The post-training pipeline around RL, and DPO, which reaches the KL-regularised optimum without a policy gradient. (33 min, plus 4 in closed details)
What an optimiser this good does with a proxy reward. (33 min, plus 12 in closed details)
PPO with a learned reward model at scale, verified, with the three steps trained live. (26 min read)
The paper that introduced GRPO, baselined REINFORCE with PPO's clip. (25 min read)
A concrete policy-gradient local optimum: PPO, trained for a billion steps on a Kinetix level where the car must back up before jumping, learned to drive straight at the ramp and stall (0 of 256 episodes); a language model reading the weights explained the trap and repaired it by editing 3.5% of them (1,024 of 1,024). (23 min, plus 3 in closed details)
The policy gradient theorem with its proof, REINFORCE, baselines, actor-critic, continuing tasks and Gaussian policies; the short corridor comes from here. (about 1h 30m)
"Intro to Policy Optimization" derives the gradient in code-ready notation; the algorithm pages (VPG, TRPO, PPO, DDPG, TD3, SAC) have reference implementations. (about 3h for the core pages)
The best single derivation chain from REINFORCE through TRPO and PPO to SAC and TD3. (about 45 min)
Mandatory before implementing PPO or GRPO, with line-by-line video tutorials. (about 50 min)
Lectures 5 to 9 cover policy gradients, actor-critic, value methods and advanced policy gradients (natural gradient, TRPO, PPO) at lecture depth. (course, about 25h in all)
Policy gradient methods: finite differences, Monte Carlo and actor-critic policy gradients, compatible function approximation, natural actor-critic. (about 1h 30m)
The reproduction of Figures 13.1 and 13.2 this page's short corridor reruns follow (with the differences listed in section 4). (about 10 min)
"Simple statistical gradient-following algorithms for connectionist reinforcement learning". (about 1h 30m)
The policy gradient theorem with function approximation, compatible features and convergence. (about 40 min)
Variance reduction for policy gradients: the optimal baseline, and why the true value function is not always the best critic. (about 2h)
The first actor-critic, balancing a pole. (about 45 min)
Generalised advantage estimation, with TRPO on 3D locomotion. (about 1h)
Asynchronous methods for deep RL. (about 1h)
The covariant gradient and the Fisher metric. (about 40 min)
The monotonic improvement bound and the trust region algorithm. (about 1h 30m)
The clipped and KL-penalty objectives, the ablation and the hyperparameters. (about 45 min)
Code-level optimisations, PPO against TRPO, and the trust region that the clip does not keep. (about 1h)
250,000 agents, more than 50 design choices, and recommendations. (about 1h 30m)
The deterministic policy gradient theorem. (about 1h)
Continuous control with deep RL. (about 45 min)
Addressing function approximation error in actor-critic methods. (about 1h)
Maximum-entropy actor-critic, then automatic temperature and real robots. (about 2h for both)
"Deep RL that matters" and "Deep RL at the edge of the statistical precipice": seeds, variance and how to report. (about 2h for both)