liveBook · Manning

Advantage function

As explained in Build a Reasoning Model (From Scratch)

A normalized per-rollout signal computed from rewards that indicates how much better or worse a rollout was than the group average.

Advantages turn per-rollout rewards into a normalized signal that says how each rollout performed relative to the group for the same prompt. They are computed by subtracting the group mean reward and dividing by the group standard deviation plus a small stability constant. section 6.7 section 7.3.1

In the GRPO pipeline, advantages are the third stage: they bridge raw rewards and the policy gradient loss. Positive values favor the actions that produced a rollout, negative values suppress them, and near-zero values contribute little. section 6.7 section 6.9

Core properties in this treatment:

  • Mean-centered, so the average advantage is always zero. section 7.3.1
  • Standard deviation near 1 suggests a well-scaled learning signal. section 7.3.1
  • Identical rewards collapse the signal and produce no policy update. section 7.3.1

Worked rollout example

For rewards [1., 1., 0., 0.], the computed advantages are [0.8659, 0.8659, -0.8659, -0.8659]. The positive pair is treated as better than average, and the negative pair as worse than average. section 6.7 section 7.3.1

How Build a Reasoning Model (From Scratch) covers it

How deep it goes
Defines the normalization formula, explains the stability term, and shows how the values affect gradients and training diagnostics.
Examples
Uses a four-rollout reward example, PyTorch listings, and zero-reward or all-one reward edge cases.
What it assumes
Assumes rewards are already available and introduces advantages as the next step from them.
What you can do after
Apply it to compute a centered, scaled rollout signal and diagnose whether training updates are strong, weak, or collapsed.
How it connects
Links rewards, rollouts, GRPO, policy gradient loss, and entropy-based training metrics.

Also explained in

Compare how 3 books explain advantage function →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Reasoning Model (From Scratch). The section links point to the parts of the book it draws on.