In RLHF, a reward model gives scores rc=2.0 to the human-preferred answer and rr=0.5 to the rejected one. Under the Bradley–Terry model, P(chosen preferred)=σ(rc−rr). Compute this probability, the loss −log⁡σ(rc−rr), and the gradients with respect to rc and rr. What happens when the scores are the other way round, and why does the loss depend only on the difference?

Reinforcement learning, RLHF
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can derive the pairwise preference loss used to train reward models and interpret its gradient.

Key idea

The reward model is trained with L=−log⁡σ(rc−rr). Its gradient with respect to rc is −(1−σ(rc−rr)), so a wrongly ordered pair gets a large push and a correctly ordered pair gets a small one.

Steps

  1. The model says P(chosen preferred)=σ(rc−rr)=ercerc+err. Maximising its log-likelihood over human comparisons gives the loss.
  2. With rc−rr=1.5: σ(1.5)=1/(1+e−1.5)=0.8176.
  3. Loss: −log⁡0.8176=0.2014.
  4. Gradients. Using ddx[−log⁡σ(x)]=−(1−σ(x)), with x=rc−rr: ∂L/∂rc=−(1−0.8176)=−0.1824 and ∂L/∂rr=+0.1824. Gradient descent raises rc and lowers rr by equal amounts.
  5. Reverse the scores (rc=0.5, rr=2.0): x=−1.5, σ(−1.5)=0.1824, the loss is −log⁡0.1824=1.7014, and the gradient magnitude is 1−0.1824=0.8176. A wrong ranking costs more and pushes harder.
  6. The loss depends only on rc−rr because adding a constant to every score leaves σ(rc−rr) unchanged. So the reward is defined only up to a shift, and its absolute level means nothing.
  7. Link to Stage 3. The RL stage uses rϕ(x,y) as the reward, so the shift is harmless, but the scale and the quality of the ranking matter, and the KL penalty is needed to stop over-optimisation of an imperfect reward model.

Common mistakes

How long your answer should be

Half a page; 5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: Show that generalised advantage estimation A^t=∑l≥0(γλ)lδt+l, with δt=rt+1+γV(st+1)−V(st), equals δt when λ=0 and the Monte Carlo advantage Gt−V(st) when λ=1. How do these limits explain the bias–variance role of λ? How do you check your claim on rewards (1,0,2) and values (3,2,1) with γ=0.9?
Next in Reinforcement learning: State and prove the policy improvement theorem. If qπ(s,π′(s))≥vπ(s) for every state s, why does it follow that vπ′(s)≥vπ(s) for every s? How does this justify greedy policy improvement in policy iteration?