Why subtracting two conditions can produce an exponential tilt
A worked Gaussian likelihood-ratio derivation, with its assumptions made explicit.
Worked visual example and derivation
Exact three-action probabilities for intuition; not learned-sampler or benchmark evidence.
Read the derivation PDF Download the animation
Read the animation transcript
Three actions have utility 0, 1 and 2, with equal reference probabilities. Conditioning on a noisy label y = 1 with Gaussian standard deviation 1 gives probabilities 0.274069, 0.451863, 0.274069. This favors matching the target. Contrasting labels 1 and 0 with guidance weight 1 cancels the quadratic term: normalized weights proportional to exp(A) give 0.090031, 0.244728, 0.665241. Expected utility rises from 1 to about 1.575. These are exact pedagogical probabilities, not neural sampler measurements or benchmark results; finite-step sampling need not realize this target exactly.
Scope and notation
This is a derivation notebook about conditioning, exponential tilting and generative policy extraction. Its main paper is Advantage Guidance v2, Sections 3–6 and Appendix A.1 (opens in a new tab). The mathematical steps below are worked explanations; the finite discrete example and tests are notebook constructions, not benchmark results. It begins with one paper and can grow into a multi-paper concept note as further sources are actually read.
Fix a state and suppress it when convenient. Write for a reference density, for a fixed estimated advantage, and for a regularization temperature. Probability statements concern this fixed state; they do not solve the entire sequential control problem. Assume the densities and derivatives used below exist, and that the relevant normalizing integrals are finite.
1. Derive the KL-regularized optimum
Consider policies absolutely continuous with respect to and maximize
subject to . With a multiplier , the stationary condition is
Rearrangement gives , with determined by normalization. Therefore
A stronger check substitutes this density back into the objective:
Nonnegativity of KL proves the optimum, rather than relying only on a stationary point. This requires ; an unrestricted unbounded utility need not satisfy that condition. Where is zero, this objective cannot create new support at finite KL. In practical neural policies, support may be formally broad while reliable offline-data coverage is narrow; those are not the same assurance.
At fixed state, adding a constant to changes by the same multiplicative factor and leaves unchanged. Multiplying advantage by a positive constant changes the effective temperature. These are useful invariance checks for both derivations and implementations.
The result is optimal for the specified fixed-state surrogate objective. It does not show that the critic is accurate, that the state visitation distribution is unchanged after deployment, or that the resulting policy globally optimizes an MDP.
2. Bayes conditioning creates a matching preference
Let a noisy scalar label satisfy
Bayes’ rule yields
The label is a value to match. Its likelihood is largest when and decreases on either side. For an action with advantage already greater than , improving the advantage further makes this likelihood worse. That is the mismatch between conditioning and optimization.
This is a model of the clean action-label joint distribution. In AG’s implementation, labels are based on estimated, state-normalized advantages, not an oracle utility. Every use of the ideal identity should specify which function occupies the symbol .
3. What ordinary CFG changes
Let and . Because is constant with respect to ,
Then the CFG combination is
For , the direction due to the label changes sign when crosses . Larger strengthens the same matching tendency. At , the clean-density expression is simply the conditional model. This does not imply that every flow implementation with this numerical setting yields exact conditional samples: the statement here is about the assumed density and its score.
A request above all achievable advantages can favor the best available actions in a toy bounded setting. But choosing such a request requires knowing the range, and a learned conditional model may be unreliable there. That workaround does not establish equality with exponential tilting at an arbitrary temperature.
4. Why the contrastive ratio cancels the quadratic term
For two labels, subtract their log likelihoods:
Expanding both squares cancels :
where does not depend on action. The same action-dependent term appears in the ratio of conditional action densities because their reference density cancels and their normalizers are action-independent. Thus
Adding the difference to the reference score gives
For , this is the target score with . Reversing the labels reverses the preference; identical labels remove the guidance. Those are simple checks that catch sign errors.
The exponential-family generalization
Suppose instead
The difference of log likelihoods cancels , leaving plus a constant. Consequently . This is the structure used in Section 6.1 and Appendix A.1. It requires to occupy the specified natural-parameter position; merely saying that a distribution “is exponential-family” is insufficient.
For Gaussian labels with constant variance, . If variance itself depends on action, new action-dependent terms appear and the simple cancellation no longer applies. Likewise, zero label noise is a singular limit of this density derivation, even if a zero-noise empirical variant happens to work.
5. A worked discrete example
Take three equally likely actions with utilities . Let , , and compare ordinary conditioning at with the contrastive pair .
| Utility | Reference | Gaussian conditioning / CFG at w=1 | Contrastive target, β=1 |
|---|---|---|---|
| 0 | 0.333333 | 0.274069 | 0.090031 |
| 1 | 0.333333 | 0.451863 | 0.244728 |
| 2 | 0.333333 | 0.274069 | 0.665241 |
Conditioning gives utilities zero and two equal probability because both are one unit from the query. Contrastive weighting prefers two, then one, then zero. Expected utility is 1 for the matching distribution and approximately 1.575210 for the tilted distribution.
The computation is just normalized weights: versus . It requires no trained model and no random sampling. The repository tests reconstruct the contrastive likelihood ratio and compare it with the direct tilt. They also verify the KL objective decomposition on several candidate distributions. Passing these tests verifies arithmetic and algebra in this example; it does not validate the paper’s benchmark or a neural sampler.
6. From score space to straight-path flow velocity
It is tempting to replace every score in the derivation with a velocity and call the result exact. Here is the extra structure that needs to be stated.
Let a clean action be , independent standard Gaussian noise be , and . For , write . Gaussian denoising gives
The population flow-matching velocity is
Eliminating the posterior mean gives
The same relation holds conditionally on a label when the interpolation and noise law are shared. Hence conditional velocity differences are proportional to conditional score differences at that intermediate time; the term cancels. These relations are derived here for this particular path, not asserted for arbitrary noise schedules. Endpoint expressions require limits; evaluating at is invalid, even though a learned velocity can be evaluated there.
Now the critical limitation: the Gaussian label model was specified given the clean action. Given an intermediate , the label likelihood averages over possible clean actions. That mixture generally is not a Gaussian with mean and the same variance. The clean-action cancellation therefore does not automatically prove the same tilted marginal identity at every intermediate time.
Even a score assembled from an instantaneous product of marginals need not describe a consistent forward-noising path of the desired final density. The practical guided ODE must still be evaluated. In addition, learned velocity errors and Euler discretization introduce further error. These are separate from a sign mistake in the clean-density algebra.
7. Residual parameterization in that sampler
With , the practical rule is
The shared reference cancels inside the difference. Algorithm 1 integrates this velocity from Gaussian noise toward an action. The residual networks must be queried at identical state, time and current noisy action. Querying the two labels from independently sampled intermediate actions would no longer be a pointwise difference of fields.
Residual training and action imagination help the model learn label-dependent fields. They do not remove the need to learn a critic. A useful implementation review separately checks reference-actor updates, critic targets, advantage normalization, residual loss gradients and sampler field evaluations rather than judging correctness from one end-to-end reward curve.
8. Normalization changes the units of guidance
Suppose , where . At fixed state and treating these statistics as fixed,
The subtraction of cancels from normalization; the division does not. The effective raw-advantage temperature is . States with different scales receive different raw-unit preferences even when , label spacing and label noise are held fixed.
For example, let , , , and . Standardized utilities are . Their tilted probabilities equal those obtained from raw utility at : approximately . They do not equal the raw tilt at .
AG estimates its normalization statistics from the dataset action and sampled alternatives. Finite-sample variability, tiny within-state variance and the stabilizer all matter. The fixed-statistics derivation is an interpretation of a particular estimated normalization, not a claim that these statistics are globally exact or independent of the proposal policy.
9. What is established, and what remains to test
There are four levels of evidence to keep separate:
- Variational identity: the exponential tilt solves the stated fixed-state KL objective.
- Clean-score identity: the contrastive ratio produces that score under the assumed likelihood model.
- Learned sampler: neural approximation, intermediate-time guidance and numerical integration determine actual generated actions.
- Control performance: the critic and environment determine whether those actions improve real return and satisfy constraints.
The first two do not certify the last two. A good next experiment holds a known utility fixed, varies integration steps and learned-field accuracy, and compares the generated distribution against an exactly normalized small reference problem. A second experiment perturbs the utility estimator while evaluating with the unperturbed utility. This separates sampler error from critic exploitation.
For future literature connections, add a separately read source on flow matching or classifier-free guidance and state precisely which path, marginal or endpoint theorem it provides. Until then, this is a worked technical companion to one paper, not a claim to cover the whole literature.
Note provenance
Authoring tool: Codex. Model: not exposed by this run. Reasoning setting: not exposed by this run. Generated/updated: 2026-10-30.
Review: same-session source checks and deterministic mathematical tests. Review model: not exposed by this run. Review date: 2026-10-30. Independent review: no.
Human review: The owner reviewed the notes and companion outputs. This is not an independent scientific audit. Review date: 2026-10-30.