Bradley-Terry model for pairwise preferences
Model P(a preferred over b) = σ(s_a − s_b), where σ is the logistic sigmoid, and fit the scores s by maximum likelihood on comparison data, such as people choosing the better of two responses. Explain why only score differences are identifiable.
Builds on: Maximum likelihood as cross-entropy minimization, From base model to assistant
What the animation says
Choices into scores
People see two answers and pick the better one, thousands of times. Each person judges only a few pairs, and many pairs are never compared at all. We want one number per answer that predicts how often it beats any other, even for pairs nobody compared. That is the Bradley-Terry model. Reward models are trained exactly this way.
Only gaps matter
Give every answer a hidden strength score. When A meets B, only the gap matters: A's score minus B's score. The sigmoid squashes that gap into a win chance. A gap of zero gives fifty percent. A big positive gap pushes toward a hundred percent; a big negative gap, toward zero. Now add ten to every score. What happens to A's chance of beating B?
Pin one score, fit the rest
It stays the same. Shifting all scores changes nothing, so the data can't fix the absolute level. So we pin one score, say A at zero. To fit, add up the log of each winner's predicted win chance, and choose the scores that maximize that sum. That is the same as minimizing cross-entropy against the observed choices. But scores are fixed only where comparisons link items to the pinned one. A is pinned. Tap the answers whose scores the data cannot fix.
Fit two answers by hand
A beats B three times out of four. Call the score gap delta. The best delta makes predicted wins match observed wins: four times the win chance equals three. So the win chance is three quarters. Undo the sigmoid: the gap is the log of win chance over lose chance. Here that is log of three, about one point one. Scores of one point one and zero fit exactly as well as five point one and four. Now fix A at five point one instead. What must B be?
Three items, numerically
Four. Fix one score, and the gap fixes the other. With three items we fit numerically. Eight comparisons, written as winner, loser. Each comparison pushes the winner up by its chance of having lost, and the loser down equally. Sum the pushes, step by point one, and re-pin item zero. It settles where observed wins equal predicted wins: zero, minus one point two five, minus two point one one. Danger: an item that never loses runs off to infinity. Tap the one pair whose removal does that to item zero.
Hidden strengths, only gaps matter
The Bradley-Terry likelihood
Fit two responses by hand
Fitting three items numerically
import numpy as np
wins = [(0,1),(0,1),(0,1),(1,0),(1,2),(1,2),(2,1),(0,2)] # (winner, loser)
sig = lambda x: 1/(1+np.exp(-x))
s = np.zeros(3)
for _ in range(5000):
d = np.zeros(3) # slope of log-likelihood wrt each score
for w, l in wins:
miss = 1 - sig(s[w] - s[l]) # d/ds_w of log sig(s_w - s_l)
d[w] += miss; d[l] -= miss
s += 0.1 * d
s -= s[0] # pin s_0 = 0: only differences are identifiable
print(s.round(2)) # about [0, -1.25, -2.11]: s_0 > s_1 > s_2
Remember
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses