DPO Concept › The Key Insight: Reparameterizing the Reward
Language AI HandbookAll chapters DPO Concept › The Key Insight: Reparameterizing the RewardOne section · Sections in this chapter3 / 14 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The key insight behind DPO comes from recognizing a mathematical relationship within the RLHF objective. To understand this insight, we need to look carefully at the RLHF objective and ask whether we can express the same goal in a different, more tractable way.
The insight, stated plainly before we get into the math: any reward function uniquely determines the optimal aligned policy, and conversely, any policy uniquely determines the reward function that would make it optimal. Reward functions and optimal policies are two descriptions of the same thing. Once you realize this, the reward model becomes unnecessary. You can work directly in policy space, using the policy itself as an implicit reward model.
Consider the RLHF objective we have been working with throughout this book:
Let's carefully examine each component of this expression to build understanding:
- : the policy model being trained, parameterized by weights
- : the dataset of prompts that we want the model to respond to well
- : the reward model score for completion given prompt , representing how much humans would prefer this response
- : the KL penalty coefficient that controls how much the policy can deviate from the reference, balancing preference optimization against stability
- : the reference model (usually the initial SFT model) used as an anchor to prevent the policy from changing too drastically
This objective captures a basic tradeoff. We want a policy that generates high-reward outputs, meaning outputs that humans would prefer according to our reward model. At the same time, we want to stay close to the reference model. This keeps we don't lose the useful capabilities the model learned during pretraining and supervised fine-tuning. The term measures how much the policy has diverged from the reference, and controls how heavily we penalize this divergence. Small allows large deviations; large keeps the policy anchored near its starting point.
Now here is where the key insight emerges. This constrained optimization problem, despite its apparent complexity, has a closed-form solution. Given any reward function , we can write down exactly what the optimal policy looks like without doing any iterative optimization:
where:
- : the optimal policy for the given reward function, meaning the policy that maximizes our objective
- : a completion sequence, any possible output the model could generate
- : a prompt sequence, the input the model is responding to
- : the partition function (normalizing constant) that ensures probabilities sum to 1 over all possible completions for prompt
- : the reference model distribution, our starting point before reward-based shaping
- : the reward function defining what outputs we prefer
- : the temperature parameter controlling the sharpness of the distribution
The formula has a beautiful interpretation. The optimal policy takes the reference model and reweights each possible output according to its reward. Outputs with high reward get amplified by the exponential term, while outputs with low reward get suppressed. The partition function then normalizes everything so probabilities sum to one. The parameter controls how aggressive this reweighting is: small creates sharp distributions concentrated on high-reward outputs, while large keeps the distribution closer to the original reference. Think of as controlling how strongly you "listen" to the reward signal versus how strongly you "remember" where you started.



This relationship works in both directions. We can go from reward to optimal policy using the formula above. But we can also go in the other direction, from policy to reward. If we take the expression for the optimal policy and solve for the reward, we get:
where:
- : the reward function value we are trying to recover
- : the scaling parameter derived from the KL coefficient
- : the optimal policy probability for generating given
- : the reference model probability
- : the partition function, a constant that depends only on the prompt and not on the completion
The key observation is that does not depend on . It is a normalizing constant that ensures the optimal policy integrates to one over all completions, but it is the same constant for every completion given a fixed prompt. This means that when we compare two completions and for the same prompt, cancels out.
This reparameterization is the engine of DPO. It says that any reward function corresponds to some optimal policy, and conversely, any policy implicitly defines a reward function. The reward a policy assigns to an output is simply, up to a constant, the log-probability ratio between that policy and the reference model, scaled by . When the policy assigns much higher probability to a response than the reference model does, that response has high implicit reward. When the policy assigns lower probability than the reference, the response has low implicit reward.
The reward function implicitly defined by a policy relative to reference model is:
Higher probability under relative to means higher implicit reward. This is not an approximation; it is an exact mathematical relationship that holds for any policy. The log-ratio measures exactly how much the policy has boosted or suppressed the probability of a given completion relative to where it started.
This duality between rewards and policies suggests a different approach to preference learning. Instead of learning a reward function and then finding the optimal policy for that reward, we might be able to learn the optimal policy directly. The reward function would then be implicitly defined by whatever policy we learn. We never need to write down the reward explicitly.
Why the Partition Function Matters
The partition function is a sum over all possible completions for the prompt . For a language model with a vocabulary of even 32,000 tokens and sequences of even 100 tokens, this sum has terms. It is completely intractable to compute directly.
This is why the traditional RLHF approach never tries to compute it. When you train a reward model with the Bradley-Terry loss, you compare two specific completions, and the partition function drops out of the comparison. When you optimize with PPO, you generate samples from the current policy, and again you never need to enumerate all possible completions.
DPO inherits this tractability advantage. As we will see in the next section, the partition function cancels when we compute preference probabilities, because it appears identically in both terms of the comparison. The fact that cancels is not a coincidence or a lucky accident; it is a direct consequence of the mathematical structure of the reward-policy duality. Understanding why it cancels is central to understanding why DPO works at all.