research24 min studyLesson 635 in Engineering

Derive a reference-constrained policy on an explicit support

Analyze a finite-support KL-regularized objective, its normalization, and its limits without mistaking an average penalty for a hard behavioral guarantee.

On this page

What you’ll understand

  • State the support and reward assumptions of the finite policy optimum.
  • Derive the reference-weighted exponential optimum and partition function.
  • Distinguish a KL penalty from a checked constraint and from desirable behavior.

A policy can raise a learned reward by moving toward answers on which the reward model extrapolates poorly. A KL term penalizes departure from a specified reference distribution, making that tradeoff explicit. It does not prove the reward is correct or keep every generated answer acceptable. The clean closed-form solution requires stated domains and support. Work through a finite set of responses first, where every probability and normalization can be checked, before interpreting a large language model's approximate training procedure.

Define the distributional optimization problem

Fix one prompt and a finite response set Y. Let the reference q assign strictly positive probability to every response in that set, let rewards r(y) be finite real values, and choose β>0. Optimize over normalized policies p on Y. The reward expectation is under the candidate policy, and D_KL(p||q) averages its log density ratio to the reference under that same candidate policy. These choices matter: reversing the KL or changing the sampling distribution defines another objective. Use natural logs and state the reward scale so the coefficient's numerical meaning is reproducible.

A constrained formulation can require an average KL no greater than a budget κ; its Lagrangian introduces a multiplier. Merely setting a positive penalty coefficient in an approximate optimizer does not certify that a chosen hard budget was met. Measure the resulting divergence under the declared distribution and estimator, including uncertainty. Average KL over prompts is also different from a per-prompt bound and from a per-response probability-ratio bound. Keep those scopes distinct when a training report says a model stayed close to its reference.

Jβ(p)=∑y∈Yp(y)r(y)−β∑y∈Yp(y)log⁡p(y)q(y)J_\beta(p)=\sum_{y\in Y}p(y)r(y)-\beta\sum_{y\in Y}p(y)\log\frac{p(y)}{q(y)}
Y is finite, q(y)>0 and sums to 1, rewards are finite, p lies on the probability simplex, and β>0. Use the convention 0 log(0/q)=0. KL is in nats; β converts that penalty to the declared reward scale.↔ Scroll wide equations horizontally.

Normalize the reference-weighted exponential

The optimum weights each reference probability by exp(r/β) and divides by the resulting positive finite partition function. One way to establish this is to rewrite the objective as β log Z minus β times KL to that normalized distribution. Nonnegativity of KL makes the maximizing policy explicit. The result is unique on the stated simplex because the reference is positive and rewards finite. Adding a prompt-only reward constant changes Z and the objective value but cancels from the optimal policy; this matches the score-origin ambiguity of within-prompt preference data.

Support cannot be ignored. If the reference assigns zero probability to a response, assigning it positive candidate mass makes D_KL(p||q) infinite under the usual convention. One can instead define the finite problem only on the reference support, but then unsupported responses are outside the allowed optimization domain. Infinite sequence spaces require further conditions ensuring a finite normalizer and well-defined expectations; the finite derivation alone does not supply them. A neural policy trained with finite data may also fail to represent or find the ideal optimum, so the formula is a conditional mathematical result rather than a training-success guarantee.

p∗(y)=q(y)er(y)/βZ,Z=∑u∈Yq(u)er(u)/βp^*(y)=\frac{q(y)e^{r(y)/\beta}}{Z},\qquad Z=\sum_{u\in Y}q(u)e^{r(u)/\beta}
Under the finite positive-reference assumptions, Z is finite and positive and p* is normalized with positive entries. β uses the penalty-multiplier convention in J_β; a reciprocal-temperature convention elsewhere must be converted before comparing numerical settings.↔ Scroll wide equations horizontally.

Interpret the coefficient and verify actual behavior

For a fixed reward function, increasing this β weakens the exponential reward tilt and moves the ideal distribution toward the reference. Rescaling rewards while holding β fixed changes the problem; matching the reward scale therefore matters as much as reporting β. In preference-derived objectives, β can also appear inside a classification margin, so a local loss response should not be confused with the entire fitted-policy tradeoff. Evaluate current outputs, measured divergence, diversity, and task outcomes together. A close distribution can still preserve the reference's failures, and a high reward can still reflect a learned proxy error.

The probability lab can display the finite two-outcome distributions used below. For each separate view, Reset, set both n=1 and p to 0.5 or 0.75, predict the two bars, then inspect. A one-trial binomial is exactly a Bernoulli distribution, so the bars visualize the reference and ideal toy-policy masses. The instrument does not optimize rewards or compute KL; calculate those from the stated distributions. It has no language model or behavioral verification, and the two outcomes are a deliberately finite mathematical domain, not a realistic response space.

Normalize a two-response policy

For one fictional prompt, responses A and B have reference probabilities 0.5 each, rewards r(A)=ln 3 and r(B)=0, and β=1. Assume these are the entire response domain and use natural logs.

  1. The unnormalized weights are 0.5×3=1.5 for A and 0.5×1=0.5 for B. Their partition function is Z=2.

  2. Normalize to obtain p*(A)=0.75 and p*(B)=0.25. The reward expectation is 0.75 ln 3≈0.82396.

  3. KL to the reference is 0.75 ln 1.5+0.25 ln 0.5≈0.13081 nats. Their difference is approximately 0.69315=ln 2, agreeing with the optimal value β log Z.

The result

The conditional finite optimum is(0.75, 0.25), with objective ln 2. This derivation neither establishes a universal utility nor certifies any actual training run’s KL budget.

Explore the model

Interactive lab

Interactive lab · probability

Display a finite reference and reward-tilted policy

For each view: Reset, set both n=1 and p, predict, then inspect. Compare p=0.5 and p=0.75 as two-outcome distributions. This exact Bernoulli display does not calculate KL, solve a preference objective, or represent a language model.

Display a finite reference and reward-tilted policyThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA normalized finite example makes support and probability mass explicit. Behavioral and approximate-training claims need separate empirical evidence.

Check your understanding

Why does the finite derivation require attention to a zero reference probability?

Try it yourself

On a two-response domain, q=(0.5, 0.5), rewards are(ln 2, 0), and β=1. Compute the normalizer and optimal probabilities.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Multiply reference masses by the exponentiated rewards before normalizing.

Compare with the solution

The weights are 1 and 0.5, so Z=1.5 and p*=(2/3, 1/3). The optimal objective is ln 1.5 under the stated finite-domain assumptions; this is not a statement about an arbitrary neural training run.

Take it with you

  • State the finite domain, reference support, reward scale, and KL direction.
  • The ideal policy is a normalized exponential tilt under explicit assumptions.
  • A penalty, a measured constraint, and desirable behavior are separate claims.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.