Interview's MateAI Engineering
Interview's Mate

AI Engineering

LLMs, RAG, agents & evals

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
AI Engineering topics
Lesson 64/ 160
04. Evals

Pairwise Comparison

A/B style preference judgments that are often more reliable than absolute scores.

IntermediateA vs B · Preferences3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidHands-onQuiz (3)Practice

In plain words

Show two answers to the same question and ask which is better; do it many times and count how often each system wins.

Think of it like…

An eye test: "which is clearer, one or two?" is easier and more reliable than asking the patient to rate each lens out of ten. Repeating the question many times gives a trustworthy preference.

Where you’ve seen it

A team compares prompt v3 and v4 on 200 held-out questions with an LLM judge. Each pair is judged twice with the order swapped, and only consistent verdicts count; 18 pairs flip with order and are treated as ties. Of the remaining 182 decisive pairs, v4 wins 105 (57.7%). The 95% interval for the win rate is 57.7% ± 7.2 points (50.5%–64.9%): above 50% but only just. A paired human spot check of 60 pairs agrees with the judge on 51 (85%), so they roll v4 out to 10% of traffic and look at online metrics before full release.

Words you’ll hear

Win rate
Share of decisive comparisons in which a variant is preferred.
Tie
A comparison where neither answer is clearly better; handle explicitly.
Position bias control
Randomising or swapping answer order and keeping only consistent verdicts.
Elo / Bradley-Terry
Rating models that infer a strength score for each variant from pairwise outcomes.

Visual diagram

Loading interactive diagram

Theory & deep dive

Running pairwise comparisons well

Pose a clear question ("which answer better resolves the user's problem, according to the policy?") with explicit criteria, and show both answers for the same input with identical formatting. Randomise which system appears first, or evaluate both orders and count a verdict only if it's consistent; otherwise a judge with position bias manufactures a winner. Allow a tie option; forcing a choice between two equally good answers adds noise. For LLM judges, apply the same rubric discipline as in LLM-as-a-judge: reasoning before verdict, validation against humans, a different model family from the systems being compared.

For humans, keep sessions short, hide system identity, randomise order and sample across question types. Use enough pairs: with n decisive comparisons the standard error of a win rate p is √(p(1 − p)/n), so 100 comparisons give about ±10 points at 95% confidence and 400 give about ±5. Report the win rate with its interval and the tie rate, not just "B wins".

A win-rate interval

105 wins in 182 decisive pairs: p = 0.577, SE = √(0.577 × 0.423 / 182) ≈ 0.0366, so the 95% interval is 0.577 ± 0.072 (0.505 to 0.649). A binomial test against 50% gives p ≈ 0.04, but the lower bound shows the true advantage might be barely above a coin flip.

Key takeaway: Blind, order-controlled comparisons, with ties and confidence intervals reported.

Ranking many variants and knowing the limits

With more than two variants, running all pairs is expensive (k variants need k(k − 1)/2 matchups). Elo updates each system's rating after each comparison; Bradley-Terry fits ratings by maximum likelihood so that P(A beats B) = σ(rating_A − rating_B), giving a ranking with confidence intervals (bootstrap the comparisons). Public leaderboards such as LMArena use this approach with crowd votes. Sample matchups adaptively (compare close contenders more) to save effort.

Limits: pairwise preference tells you which is better, not how good either is or why, so pair it with rubric scores and error analysis. Preference can reward style over substance (longer, more confident answers win), so control for length and check correctness separately. Win rates are relative to the distribution of questions, so use a representative set, and remember that a significant preference may not be a meaningful business improvement. Confirm important decisions with online experiments and downstream metrics.

Bradley-Terry in one line

If variants A and B have ratings 1.2 and 0.8, P(A beats B) = 1 / (1 + e^−(1.2−0.8)) = 1 / (1 + e^−0.4) ≈ 0.60. Fitting ratings to observed wins gives a ranking that reflects all comparisons.

Key takeaway: Elo or Bradley-Terry rank many variants; preferences complement, not replace, absolute quality checks.

How it works, step by step

Step 1 of 4
Eval design

1. Define the question and criteria

State what "better" means for this task and prepare identical, held-out inputs.

better at resolving the issue per policy
Key numbers at this step
Inputs
representative

When to use it & trade-offs

What it is

Pairwise comparison evaluates two outputs side by side for the same input and asks "which is better?" (A, B or tie), instead of scoring each one on an absolute scale. Both humans and LLM judges tend to be more consistent at relative judgements than at assigning numbers like 7 out of 10. Aggregating many comparisons gives a win rate between two systems, and rating models such as Elo or Bradley-Terry turn a tournament of comparisons into a ranking of many variants, as in public chatbot arenas.

Why it matters: Choosing between two prompts, two models or two retrieval setups is the most common eval decision, and absolute scores are noisy and drift in meaning. Pairwise preference is sensitive to small quality differences, easy for annotators to understand and robust to scale differences between raters. It does need careful handling of position bias, ties and statistical uncertainty, or a "58% win rate" can be noise.

When to reach for it

  • Comparing two prompts or two models
  • Ranking several candidate configurations
  • Evaluating subjective quality such as helpfulness and style

When to avoid or be careful

  • Showing the same variant first every time
  • Forcing a winner when answers are equal
  • Reporting a win rate without sample size or interval

Pairwise vs absolute scoring

Pairwise preference
Best for: Choosing between variants; subtle quality differences

Strengths: Consistent judgements; sensitive to small gains.

Watch out: Relative only; cost grows with variants; position bias.

Rubric / absolute scoring
Best for: Tracking quality against a standard over time

Strengths: Interpretable per-criterion results.

Watch out: Noisier; scale drift between raters.

Online A/B on user metrics
Best for: Final validation of impact

Strengths: Real outcomes.

Watch out: Slower; needs traffic.

Interview signals & numbers to know

When this topic comes up

  • “Is prompt v4 better than v3?”
  • “What's the win rate?”
  • “Elo ratings for models”
  • Position bias in judges
  • Preference data

Benchmarks & rules of thumb

±10 / ±5 pts -
95% margin for 100 / 400 decisive comparisons
57.7% -
win rate in the example
k(k − 1)/2 -
number of all-pairs matchups

Common mistakes & follow-ups

Common interview mistakes

  • Declaring victory at a 55% win rate over 40 comparisons.
  • Letting a judge see the baseline answer first every time.
  • Treating preference for longer answers as better quality.

Likely interviewer follow-ups

  • How do you control position bias in pairwise judging?
  • How would you rank five prompt variants?
  • What are the limits of preference-based evaluation?
Interview tip: Report the win rate with its interval and tie rate. That one habit separates credible comparisons from noise.
Loading hands-on exercise

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Pairwise Comparison with generative AI interview Q&A and hands-on practice.

Open Generative AI Q&A →Tech Learn Q&A
Previous topic
LLM as a Judge
Next topic
Rubric Scoring