Bradley-Terry Model › Worked Example
Language AI HandbookAll chapters Bradley-Terry Model › Worked ExampleOne section · Sections in this chapter7 / 12 ↓
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
Let's work through a concrete numerical example to solidify these concepts and see how the mathematics plays out with real numbers from start to finish. This will make the abstract framework concrete before we move to the code implementation. Suppose we have three model responses (A, B, C) and the following comparison outcomes from human annotators:
| Comparison | Winner | Occurrences |
|---|---|---|
| A vs B | A | 7 |
| A vs B | B | 3 |
| B vs C | B | 8 |
| B vs C | C | 2 |
| A vs C | A | 9 |
| A vs C | C | 1 |
We have 30 total comparisons across three matchups. Looking at the raw data, A beats B 70% of the time, B beats C 80% of the time, and A beats C 90% of the time. These observed frequencies give a rough sense of the ranking (A is best, C is worst), but they are not the Bradley-Terry parameters. The parameters must be inferred by maximum likelihood, and they will differ from the simple observed frequencies because they must be globally consistent.
Step 1: Set the anchor. We set as our anchor. This choice is arbitrary, but it resolves the identifiability issue and allows us to interpret the other parameters as "how much better than C" each item is. With this convention, and become the only free parameters.
Step 2: Write the log-likelihood. The log-likelihood function aggregates all our comparison data:
where:
- : the log-likelihood function aggregating all comparisons
- : the observed counts (e.g., A beats B 7 times)
- : the sigmoid function mapping strength differences to probabilities
- : the unknown log-strength parameters
- : the fixed anchor value for item C ()
Each term in this sum corresponds to a set of comparisons. The first term, , contributes to the likelihood every time A beats B, which happened 7 times. The second term accounts for the 3 times B beat A. Notice how the symmetry of preferences emerges: when A beats B, we use , and when B beats A, we use .
Step 3: Take derivatives. To find the maximum, we take partial derivatives and set them to zero. We rely on the derivative property of the log-sigmoid function: . This elegant result comes from the chain rule and the fact that , giving .
Applying the chain rule to the terms involving :
- When A wins (e.g., against B): The term is . The derivative with respect to is .
- When A loses (e.g., against B): The term is . The derivative with respect to is , which simplifies to .
Substituting the counts into the gradient equation for :
where:
- : the gradient of the log-likelihood with respect to
- : the log-strength parameters
- : the sigmoid function
- : the derivative of the term for wins
- : the derivative of the term for losses
Using the property that , we can write this more compactly as:
where:
- : the probability that B beats A
- : the probability that C beats A (equivalent to )
- : the log-strength parameters
- : the sigmoid function
There is a beautiful interpretation of this gradient. The first term, , is 7 times the probability that B beats A under the current model. The second term, , is 3 times the probability that A beats B. At the maximum likelihood solution, the gradient equals zero, which means: the expected number of times B should beat A under the model equals the observed number (3), and the expected number of times A should beat B equals the observed number (7). This is the method of moments interpretation of maximum likelihood for Bradley-Terry: at the optimum, observed win counts equal expected win counts for each item.
Step 4: Solve numerically. The gradient equations don't have a closed-form solution because the sigmoid function is nonlinear. Unlike linear regression, where we can solve for parameters directly, the nonlinearity of the sigmoid means we must use numerical methods. We run gradient ascent (or equivalently, minimize the negative log-likelihood) using an efficient optimizer like L-BFGS. The convexity of the objective guarantees we will find the global maximum.
The true maximum likelihood estimates for our three-item example work out to approximately , , and (fixed). Let's verify these make sense. The gap gives , close to the observed 70% but adjusted upward by the model's use of A-vs-C information. The gap gives , close to the observed 80% but adjusted downward by the indirect information flowing through A. The Bradley-Terry model reconciles all three matchups simultaneously to find the best global explanation.