Unit 5 of 10 · about 4 hours · derive

Reward overoptimization and the KL-regularized objective with a reference policy

A reference policy constrains how a learned proxy is exploited. The derivation gives a precise optimization target, but it does not turn a misspecified reward into a trustworthy measure of behavior.

You'll be able to

  • Derive the optimal policy of a fixed-reward, KL-regularized objective and state its support assumptions.
  • Distinguish a sampled log ratio, a policy KL estimate and an offline preference margin.
  • Explain why rising proxy reward can accompany worse independent behavior and why KL control is not a reward repair.

Covers

Reward overoptimization, Goodhart effects and proxy regressionsReference policies, KL-regularized RL objective and policy distance
1

Read

In this order, only the parts listed

0 of 3 done

  1. DPO: the KL-regularized optimumDirect Preference Optimization

    arXiv:2305.18290v3, Section 3 equation 3; Section 4 equation 4; Appendix A.1, Deriving the Optimum of the KL-Constrained Reward Maximization Objective

  2. The RLHF Book: Chapters 14 and 15, Over-Optimization and RegularizationRLHF Book - Reward Models, Direct Alignment and Preferences

    Chapter 14, Managing Proxy Objectives and Quantitative Over-Optimization; Chapter 15, KL Divergence in RL Optimization and Reference Model to Generations, at https://rlhfbook.com/c/15-regularization.html

    Use the KL definition from the Math Foundations unit on entropy, cross-entropy, KL divergence and mutual information. Skip Chapter 15's implementation example here; derive the distribution and sampling units yourself. The book's claims that direct alignment fixes a KL distance are too strong: a fixed coefficient does not fix realized KL.

  3. Scaling Laws for Reward Model OveroptimizationScaling Laws for Reward Model Overoptimization (Gao et al., 2022)

    arXiv:2210.10760v1, Sections 2 to 4, especially 2.1 Synthetic Data Setup, 3.5 RL vs BoN and 3.6 Effect of KL Penalty

    Read the proxy/gold design and its curve shapes, not a universal threshold. The gold scorer is a larger model standing in for humans, and the horizontal optimization measure uses the square root of KL.

2

Focus on

  • For each prompt and fixed reward, maximize . Assume , finite normalizer and support compatible with the reference.
  • The solution is . Certify it by rewriting , not only by taking derivatives.
  • A sampled sequence log ratio can be negative. Its expectation under the current policy gives the declared KL only with the correct sampling distribution, response support and termination convention. An average over fixed preference pairs is not that expectation.
  • Plot independent task quality beside proxy reward and policy drift. Different optimization procedures can exploit the same reward differently; the paper's best-of-many and RL results do not establish a universal safe KL budget.
Common mistakes · 3
  • Treating a single negative sampled log ratio as a negative KL divergence. Non-negativity applies to the population divergence, not each draw.
  • Ignoring reference zeros. A policy putting mass where the reference is zero incurs infinite KL; finite offline observations do not certify useful coverage elsewhere.
  • Claiming a higher penalty guarantees safety. It restrains movement for a fixed reward optimization problem, but does not validate the reward or prescribe the realized drift of a finite training run.
3

Try it yourself

Closed-book, before checking anything

Derive the optimum closed-book. For one prompt with three possible completions, reference probabilities , rewards and , obtain , optimal probabilities and objective . Check normalization and the KL rewrite on CPU with PyTorch 2.14.1, torch.float64, natural logs and absolute tolerance . No model or random sampling is involved.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Why does a prompt-only reward offset not change the optimum?Answer

    It multiplies every unnormalized probability for that prompt by the same factor, which cancels in normalization. The optimal objective value shifts, but the policy does not.

  2. 2.Why is the gold score in Gao et al. not direct human evidence?Answer

    A larger reward model supplies the synthetic labels and evaluation score. It permits controlled proxy/gold comparisons, but its errors and population coverage remain assumptions.

  3. 3.What is wrong with calling the fixed preference-set mean log ratio the deployed policy KL?Answer

    Its responses were not necessarily sampled from the current policy. Without the right sampling or weighting it measures a different distribution, even if the arithmetic is correct.

5

Practice

  • TensorTonic: Score a KL-Regularized Policy Batch

    Implement kl_regularized_policy_objective(policy_log_probs, reference_log_probs, rewards, response_mask, beta)

    Free. Public cases cover positive sampled divergence, a mixed masked batch and a fully masked response. Keep its sum-over-response-tokens convention and do not clamp negative sampled divergences. These cases check supplied scores, not whether the responses came from the correct policy.

You're done when

You certify the three-completion optimum, pass the named masked-batch examples, and can explain what additional independent evidence would expose reward overoptimization.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 17 more in the section
  • RLHF Book - Reward Models, Direct Alignment and PreferencesNathan Lambert · primary

    Read Chapter 5 (reward models), Chapter 8 (direct alignment), Chapters 10 and 11 (preferences and preference data) and Chapters 14 and 15 (over-optimization and regularization) at rlhfbook.com/c/NN-slug.html. Only Chapters 5 and 8 have Suggested Experiments; do those. Trace preference data through reward modeling or DPO and list each distribution and evaluator assumption before training.

  • Direct Preference OptimizationStanford University · required

    Read Section 4 and Appendix A: derive the objective from the KL-constrained reward formulation, implement it from policy and reference log probabilities summed over response tokens, and gradient-check , sign, masking and identical-pair cases. TRL's sigmoid_norm variant normalizes by length, which the paper does not.

  • Scaling Laws for Reward Model Overoptimization (Gao et al., 2022)OpenAI · required

    Read Sections 2 to 4: a gold reward model stands in for humans, and gold score against optimization pressure takes different forms for best-of-n and RL. The lesson is the shape, not a universal KL threshold.

Also in this section