liveBook · Manning

Advantage function

An advantage function in reinforcement learning estimates how much better or worse an action’s expected return is than a baseline value for the corresponding state or policy.

How 3 Manning books explain it

Reinforcement Learning from Human Feedback

An advantage function estimates how much better an action is than the policy's expected value at a state.

How it is used
Weights policy-gradient updates so completions outperforming their expected baseline become more likely.
How deep it goes
Derives Q-minus-V and TD-residual forms, then details critic, leave-one-out, and group-normalized estimators.
Examples
Uses positive, negative, and zero updates; leave-one-out completion rewards; group-normalized rewards; and token-versus-sequence tensors.
What you can do after
Apply it via PPO, RLOO, or GRPO losses by computing relative rewards and weighting token log-probability updates.

Read how Reinforcement Learning from Human Feedback explains advantage function →

Optimization Algorithms: AI techniques for design, planning, and control problems

An advantage is the estimated improvement in expected future reward from taking an action in a state compared with the average action in that state.

How it is used
Guides policy updates by comparing a selected action’s expected return with its state’s value baseline.
How deep it goes
Defines Q(s, a) − V(s), explains its effect on action probabilities, and works through a one-step CartPole estimate.
Examples
Uses CartPole’s left-or-right actions, a one-step advantage calculation, actor and critic losses, and episode-reward tracking.
What you can do after
Build it from scratch in the shown A2C CartPole setup to compute advantages and update an actor and critic.

Read how Optimization Algorithms: AI techniques for design, planning, and control problems explains advantage function →

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.

How it is used
Supplies the learning signal used to weight rollout responses before the GRPO policy update.
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 you can do after
Apply it to compute a centered, scaled rollout signal and diagnose whether training updates are strong, weak, or collapsed.

Read how Build a Reasoning Model (From Scratch) explains advantage function →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.