Show that the policy maximising Ey∼π[r(y)]−β KL(π ∥ πref) is π∗(y)=πref(y) er(y)/β/Z with Z=∑yπref(y)er(y)/β. For πref=(0.5,0.5), r=(1,0), find π∗ and the optimal objective value for β=1, and π∗ for β=0.5. What happens as β→0 and β→∞, and how does this lead to direct preference optimisation (DPO)?

Reinforcement learning, RLHF
Level L5 Expert. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can solve the KL-regularised objective exactly, using Gibbs' inequality, and interpret the Boltzmann-form solution.

Key idea

The objective equals βlog⁡Z−β KL(π ∥ π∗). Since KL≥0 with equality only when π=π∗, the maximiser is π∗∝πref er/β.

Steps

  1. Expand: Eπ[r]−β∑yπ(y)log⁡π(y)πref(y)=β∑yπ(y)log⁡πref(y) er(y)/βπ(y).
  2. Define π∗(y)=πref(y)er(y)/β/Z, so that πrefer/β=Zπ∗. The objective becomes β∑yπlog⁡Zπ∗π=βlog⁡Z−β KL(π ∥ π∗).
  3. The first term does not depend on π and the second is ≤0 with equality iff π=π∗. So π∗ is the unique maximiser and the optimal value is βlog⁡Z.
  4. Numbers, β=1: Z=0.5e+0.5=1.859. π∗=(0.5e/1.859, 0.5/1.859)=(0.731, 0.269). The optimal value is log⁡Z=0.620. Check: E[r]=0.731 and KL(π∗∥πref)=0.731ln⁡(1.462)+0.269ln⁡(0.538)=0.278−0.167=0.111, so 0.731−0.111=0.620.
  5. With β=0.5: Z=0.5e2+0.5, so π∗(y1)=e2/(e2+1)=0.881. A smaller β means a weaker pull towards πref and a sharper policy.
  6. Limits. As β→0, π∗ puts all its mass on arg⁡max⁡r (pure reward maximisation). As β→∞, π∗→πref.
  7. Link to DPO. Rearranging gives r(y)=βlog⁡π∗(y)πref(y)+βlog⁡Z. The log⁡Z term cancels in the Bradley–Terry difference rc−rr, so a reward model can be replaced by the log-ratio of the policy and πref, and the policy can be trained directly on preference pairs.

Common mistakes

How long your answer should be

A page; 8–10 minutes.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: How do you prove that the Bellman optimality operator is a γ-contraction in the max-norm, and what does this tell you about value iteration converging to a unique V∗ and when to stop it?
Next in Reinforcement learning: Prove the performance difference lemma: for two policies π and π′ with J(π)=Es0[Vπ(s0)], J(π′)−J(π)=11−γ Es∼dπ′, a∼π′[Aπ(s,a)], where dπ′(s)=(1−γ)∑t≥0γtP(st=s∣π′). What does it imply for policy improvement and for TRPO?