LearnQuestion bank

Derive the REINFORCE policy-gradient estimator, explain why it has high variance, and show why subtracting a baseline reduces variance without adding bias.

ResearchTechnicalMedium

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • Log-derivative trick: ∇J = E[∇log π(a|s)·G]
  • Variance comes from noisy, trajectory-dependent returns
  • State-only baseline has zero expected score-weighted effect, so unbiasedness is preserved; an action-dependent baseline would add bias
  • Best baseline approximates V(s); advantage A = Q − V; actor-critic; reward-to-go
  • LLM RL: terminal sequence-level reward over long completions makes raw REINFORCE noisy; use a value baseline (PPO) or a group-mean baseline (GRPO)

In full

Start from J(θ)=E_{τ~πθ}[G(τ)]. Using ∇∫pθ(τ)G(τ)dτ = ∫G(τ)∇pθ(τ)dτ = E[G(τ)∇log pθ(τ)] and ∇log pθ(τ)=Σ_t ∇logπθ(a_t|s_t), the policy gradient is ∇J=E[Σ_t ∇logπθ(a_t|s_t) G(τ)] (the environment dynamics do not depend on θ, so their log-terms vanish), and because an action cannot affect earlier rewards, G(τ) can be replaced by the reward-to-go G_t; this is often written E[∇logπ(a|s)G]. It is unbiased but high variance because G is a noisy, trajectory-dependent return that can vary widely for the same state-action. Subtracting a state-only baseline b(s) does not change the expectation: E[∇logπ(a|s)b(s)] = b(s)∇Σ_aπ(a|s)=0, so E[∇logπ(a|s)(G−b(s))]=∇J (a baseline that depends on the action generally breaks this identity and adds bias), while choosing b(s)≈V(s)=E[G|s] removes the predictable part of the return and lowers variance. This is the advantage A=Q−V; actor-critic methods learn V or Q to estimate A, and reward-to-go drops past rewards that cannot be affected by the current action. In LLM RL the same idea is used with a terminal sequence-level reward over a long completion, which makes the raw estimator especially noisy, so baselines are standard: a learned value function as in PPO, or the mean reward of several samples for the same prompt as in group-relative methods such as GRPO, usually combined with clipped or KL-regularised updates.

Corrected by an independent AI reviewer.

What a strong answer covers

  • ∇J = E[∇log π(a|s)·G], via the log-derivative trick.
  • Variance comes from the noisy returns.
  • A state-only baseline has zero expected effect, so the estimator stays unbiased.
  • The advantage A = Q − V; actor-critic methods; reward-to-go.
  • Link to sequence-level rewards in LLM RL.

Common mistakes

  • Using a baseline that depends on the action.
  • Being unable to show the log-derivative step.