Topic 45 of 62 · Post-training
Actor-critic and the advantage
HardWhat does a critic add to the policy gradient, and what does it cost when training an LLM?
1 · Start with the intuition
Instead of crediting every token with the final reward, ask how much better each token was than expected at that point. A learned value function V(s) predicts the expected final reward from every prefix; the change it sees after each token is that token’s credit.
2 · How the mechanism works
Mechanism step 1 of 3 · no question to answer
Predict value
The critic estimates V(sₜ) for each generated prefix.
Next, we will look at: Estimate advantage. Move on when this operation makes sense.
Visualizing the behavior
Where this sits: the RL-for-LLMs progression
PPO-based RLHF keeps four models in play
Critic value along a 3-token completion (terminal reward 1)
Derived- V(sₜ), with the realised reward at t = 3
3 · The governing equation
Aₜ = Q(sₜ, aₜ) − V(sₜ) δₜ = rₜ + γ·V(sₜ₊₁) − V(sₜ) GAE: Âₜ = Σₗ (γλ)ˡ · δₜ₊ₗ Critic loss: (V(sₜ) − R̂ₜ)²
Notation: In LLM RLHF, γ is usually 1 and the reward arrives at the final token, often with a per-token KL penalty added. λ = 1 gives the return minus V(sₜ); λ = 0 trusts the one-step TD error.
A critic lowers variance and assigns token-level credit, but introduces bias when V is wrong. λ trades these off. For LLMs the critic is typically a second network of similar size, often initialised from the reward model, so PPO-based RLHF keeps four models in play: policy, reference, reward model, and value model. Learning a good value for partial reasoning chains from a sparse terminal reward is itself hard. That memory and estimation cost is the pressure that motivates GRPO.
4 · Put concrete numbers on it
Worked numbers (from stated assumptions)5 · Common misconception to avoid
“The critic is the reward model.” The reward model scores finished completions and is frozen during RL. The critic predicts expected future reward from partial prefixes and is trained alongside the policy.
In practice · implementation & engineering rule of thumb
Detach value targets when training the critic, and warm up the critic head for a few steps before updating the policy so noisy initial value estimates do not corrupt early actor updates.
# Generalized Advantage Estimation (GAE) reverse recursion across tokens:
gae = 0.0
advantages = torch.zeros_like(rewards)
for t in reversed(range(seq_len)):
delta = rewards[:, t] + gamma * values[:, t + 1] - values[:, t]
gae = delta + gamma * lam * gae
advantages[:, t] = gae6 · Self-check & interview synthesis
Explain it in your own words first
Before revealing the reference answer, try answering the opening question aloud in four beats: what it is → how the math works → what trade-off it makes → a concrete number or failure mode.
Follow-up question interviewers often ask next
MediumWith λ = 0 and a perfect critic, what does a token’s advantage measure?
Show follow-up reasoning
δₜ = rₜ + V(sₜ₊₁) − V(sₜ): exactly how much choosing that token changed the expected final reward. Any error then comes from the critic, so the concern shifts from variance to the critic’s bias.