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.
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.
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
- Group Relative Policy Optimizationpart of · Group Relative Policy Optimization is a reinforcement-learning algorithm that updates a policy using relative rewards or advantages estimated from groups of sampled outputs or actions.
- policy gradient methodused by · A policy gradient method is a reinforcement-learning technique that uses gradients of expected return to optimize the parameters of a policy.
- generalized advantage estimationproduced by · Generalized advantage estimation estimates policy advantages by exponentially weighting temporal-difference errors across multiple time scales, trading bias against variance.
- reward signaluses · A reward signal is an evaluative feedback value representing the desirability or payoff of an action, outcome, or state.
- varianceaddresses · Variance is the expected squared deviation of a random variable from its mean, measuring the spread of its distribution.
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.


