Evaluation lab · San Francisco · London · Zürich
Reinforced Labs Request a briefing
Glossary

KL penalty

Also called: KL regularisation, KL divergence penalty, reference policy, reference model, KL control

A KL penalty subtracts a multiple of the KL divergence from a frozen reference policy from the reward, keeping an RL-tuned model close to where it started.

A KL penalty is a term in an RL objective that charges the policy for moving away from a fixed reference policy, measured by Kullback-Leibler divergence. In RLHF the reference policy is usually the supervised fine-tuned model, and the penalty stops the policy from drifting into degenerate text that only a reward model could love.

The objective

Here is the policy being trained, is the frozen reference policy, is the reward and sets the strength of the penalty. In practice the KL is estimated per sample as , summed over tokens, and is either folded into the reward or added to the loss.

What the penalty does

This objective has a closed-form maximiser:

where normalises the distribution. The optimal policy reweights the reference rather than replacing it: responses the reference considers impossible stay impossible, and acts as a temperature on the reward. DPO is derived from exactly this formula.

Worked example

Two responses each have reference probability 0.5; one has reward 1, the other 0. With , the optimal policy puts on the better response. With it puts only there. As the policy greedily picks the highest reward; as it stays equal to the reference.

Choosing beta

  • Too small: the policy finds reward-model blind spots, the signature of reward overoptimisation.
  • Too large: almost nothing is learned.
  • Adaptive schemes, as in Ziegler et al. (2019), tune to hit a target KL per batch. Reporting KL alongside reward makes runs comparable.

Why it matters

KL from the reference is the most useful single dial for how much a model has changed during RL. Gao et al. (2022) plotted true quality against and found it peaks and then declines, so KL budget is effectively a safety margin against reward hacking. It also preserves capabilities and calibration learned in pretraining that a narrow reward would otherwise erode.

Sources

  1. Daniel M. Ziegler, Nisan Stiennon, Jeffrey Wu, Tom B. Brown, Alec Radford, Dario Amodei, Paul Christiano, Geoffrey Irving. Fine-Tuning Language Models from Human Preferences, 2019. arxiv.org
  2. Leo Gao, John Schulman, Jacob Hilton. Scaling Laws for Reward Model Overoptimization, 2022. arxiv.org

Know the number before you ship.

A 45-minute working session with an evaluation engineer. Bring one use case; leave with a threat model, a draft eval plan with sample sizes, and an honest read on where you stand.