Skip to content

About

Rank anything from pairwise comparisons with uncertainty: Bradley-Terry, Davidson and Plackett-Luce in PyMC, applied to LLM arena votes, food preferences and tennis

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

bayesian-pairwise-ranking

Documentation in Japanese: README.ja.md

Uncertainty-aware ranking from pairwise comparisons. Bradley-Terry, Davidson (ties) and Plackett-Luce models in PyMC, applied to LLM arena votes, sushi preferences and ATP tennis results.

Forest plot of LLM arena strengths with 94% HDIs

A leaderboard hides how sure it is. This project fits the classical pairwise comparison models as Bayesian models and reports the posterior distribution of the ranking itself: which items are separated by the data, which orderings are coin flips, and how much certainty each extra vote, match or survey answer buys. The same three-line likelihood covers 1927 psychophysics (Thurstone), 1952 statistics (Bradley-Terry) and 2024 LLM leaderboards.

Notebooks

# Notebook What it does
01 Bradley-Terry from scratch Derives the BT likelihood, fits it by MLE and MCMC on simulated data, and recovers known true strengths (r > 0.99) while HDI widths track the amount of data
02 LLM arena ranking Rebuilds an LLM ranking from 57k arena votes; the top is a cluster of overlapping HDIs, and the Davidson model keeps the 31% of battles that end in ties without changing the order
03 Thurstone and sushi Fits probit (Thurstone Case V) and logit (BT) models to 5,000 sushi rankings decomposed into pairs; identical ranking, strengths proportional with slope 1.65
04 Hierarchical tennis Pools two ATP seasons with surface-specific deviations; partial pooling stabilizes the sparse Grass estimates while clay specialists keep their gap
05 Plackett-Luce partial rankings Models rankings directly; top-k truncation keeps the head of the ranking but promotes polarizing items (uni) and widens HDIs, and PL reduces exactly to BT on pairs

Models

Model Handles Data Notebook
Bradley-Terry (logit) win/loss pairs simulation, arena votes, sushi pairs, tennis 01, 02, 03, 04, 05
Thurstone Case V (probit) win/loss pairs sushi pairs 03
Davidson win/loss/tie arena votes 02
Hierarchical Bradley-Terry context-specific strengths tennis by surface 04
Plackett-Luce full and top-k rankings sushi rankings 05

All models identify strengths with a ZeroSumNormal prior (sum-to-zero constraint) and are sampled with NUTS; every notebook checks R-hat, effective sample size and divergences before using a posterior.

Quickstart

Python 3.11.

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python scripts/download_data.py --dataset all
jupyter lab

Notebook 02 runs without any download: the aggregated arena pair counts are committed as data/sample/arena_pair_counts.csv. Notebooks 03 to 05 look for the downloaded data and fall back to clearly labeled synthetic data when it is absent.

Data and licenses

Dataset Source License Committed here
Simulated games pairrank.data.simulate_bt - generated at run time
LMSYS Arena Human Preference 55k Hugging Face Hub, lmsys/lmsys-arena-human-preference-55k Apache 2.0 aggregated pair counts only (data/sample/)
SUSHI Preference Data Sets (set A) kamishima.net/sushi research use only, no redistribution nothing; download script only
tennis_atp (Jeff Sackmann) github.com/JeffSackmann/tennis_atp CC BY-NC-SA 4.0 nothing; download script only

Notes:

  • Arena: only model names and win/tie labels are used; prompt and response text is discarded at download time and never enters the repository.
  • SUSHI: no part of the data is committed, following its no-redistribution condition. Publications using it must cite Kamishima, "Nantonac Collaborative Filtering: Recommendation Based on Order Responses" (KDD 2003).
  • Tennis: attribution "Tennis data by Jeff Sackmann / Tennis Abstract, licensed under CC BY-NC-SA 4.0". The NC clause means notebook 04's data must be excluded from any commercial reuse of this repository. The canonical GitHub repository was not reachable when this project was built (2026-07), so scripts/download_data.py tries it first and falls back to community mirrors of the same CSVs.

Repository layout

notebooks/            executed notebooks (outputs committed)
notebooks_src/        jupytext py:percent sources of the same notebooks
src/pairrank/         data converters, likelihoods, PyMC builders, summaries, plots
tests/                pytest suite, including checks against choix and known solutions
scripts/download_data.py
data/sample/          redistributable arena pair counts (Apache 2.0)
assets/               representative figure used above

Limitations

  • Voter and respondent effects are not modeled; arena votes have no stable voter identity and each SUSHI respondent contributes one ranking.
  • Strengths are static within each dataset; no Elo-style time dynamics.
  • The tennis model covers surface effects only, not home advantage, tournament tier or scores.
  • Rankings are reported with uncertainty by design; there is no plain point-estimate table.

References

  • Bradley, R. A. and Terry, M. E. (1952). Rank analysis of incomplete block designs: I. The method of paired comparisons. Biometrika 39(3/4).
  • Davidson, R. R. (1970). On extending the Bradley-Terry model to accommodate ties in paired comparison experiments. JASA 65(329).
  • Thurstone, L. L. (1927). A law of comparative judgment. Psychological Review 34(4).
  • Luce, R. D. (1959). Individual Choice Behavior. Wiley. / Plackett, R. L. (1975). The analysis of permutations. JRSS C 24(2).
  • Kamishima, T. (2003). Nantonac collaborative filtering: recommendation based on order responses. KDD 2003.
  • Chiang, W.-L. et al. (2024). Chatbot Arena: an open platform for evaluating LLMs by human preference. arXiv:2403.04132.

License

Code is MIT licensed (see LICENSE). Data licenses are listed in the table above and remain with their owners.

About

Rank anything from pairwise comparisons with uncertainty: Bradley-Terry, Davidson and Plackett-Luce in PyMC, applied to LLM arena votes, food preferences and tennis

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages