liveBook · Manning

Partition function

As explained in Reinforcement Learning from Human Feedback

A partition function is a normalization factor that converts unnormalized nonnegative weights into a probability distribution.

A partition function normalizes nonnegative, reward-weighted reference probabilities into a valid distribution. For each fixed x, Z(x) sums the weights across all possible y. section 8.1.2

In KL-regularized reinforcement learning, Z(x) normalizes π_ref(y|x) exp(r(x,y)/β). The resulting reward-tilted distribution is the optimal policy, while Z(x) remains independent of π. section 8.1.2 section 15.2.2

The derivation uses the partition function to:

  • Turn an unnormalized reward-tilted density into a probability distribution over responses. section 8.1.2
  • Rewrite the RL objective as a KL divergence minus the constant log Z(x). section 15.2.2
  • Show that minimizing the KL divergence produces the reward-tilted optimal policy. section 8.1.2
  • Cancel from pairwise Bradley–Terry preference probabilities because the same Z(x) multiplies every candidate. section 8.1.2

Reward-tilted policy

Given Z(x) = Σ_y π_ref(y|x) exp(r(x,y)/β), the optimal policy is π*(y|x) = π_ref(y|x) exp(r(x,y)/β) / Z(x). section 8.1.2

Equation 8.5
\[\label{eq:rlhf_opt_eq_repeat} \max_{\pi} \mathbb{E}_{x \sim \mathcal{D}}\mathbb{E}_{y \sim \pi(y|x)} \left[r_\theta(x, y)\right] - \beta \mathcal{D}_{\text{KL}}\left(\pi(y|x) \| \pi_{\text{ref}}(y|x)\right).\]

Trace the KL-regularized RL objective before normalization is introduced. section 8.1.2

How Reinforcement Learning from Human Feedback covers it

How deep it goes
Derives the summation, KL reformulation, optimal policy, and preference cancellation, but does not discuss numerical computation.
Examples
Uses reward-weighted reference policies, explicit Z(x) summations, optimal-policy equations, and Bradley–Terry preference probabilities.
What it assumes
Assumes probability distributions, expectations, exponentials, logarithms, and KL divergence within KL-regularized reinforcement learning.
What you can do after
Evaluate how normalization yields an optimal policy and explain why the partition function cancels from pairwise preference probabilities.
How it connects
Connects probability distributions, reward functions, reference policies, KL divergence, reinforcement learning, and preference optimization.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Reinforcement Learning from Human Feedback. The section links point to the parts of the book it draws on.