Quality and safety
Pairwise judge comparisons
When comparing two prompts or models, ask which answer is better on one criterion, then swap the order and only count consistent winners.
When comparing prompt A vs prompt B, or model A vs B, pairwise often matches human preference better than scoring each answer alone on a 1–10 scale. Pointwise scores drift: today's 7 and yesterday's 7 are not the same ruler. A forced choice on the same input is a stabler question.
The catch is position bias: the judge may prefer whichever answer you listed first. The protocol below cancels that.
Concept
Before you start: pick one criterion. "Which is better on faithfulness?" is a question. "Which is better overall?" is a mushy one you cannot debug.
The protocol
- Same input → generate answer A and answer B.
- Ask the judge which is better on one criterion (or overall, if you must).
- Run again with A and B swapped.
- Tally: A wins both → A. B wins both → B. Split → tie.
def pairwise_winner(prefer_first: bool, prefer_first_swapped: bool) -> str:
# prefer_first True means the first argument won in that ordering
a_wins = prefer_first and (not prefer_first_swapped)
b_wins = (not prefer_first) and prefer_first_swapped
if a_wins:
return "A"
if b_wins:
return "B"
return "tie"
print(pairwise_winner(True, False)) # A first, B first after swap → A
print(pairwise_winner(True, True)) # first slot wins both times → tie
print(pairwise_winner(False, True)) # B, then A after swap → BOutput:
A
tie
BReport win rate with ties, and confidence intervals when n is small. The same statistical humility as in eval noise and experimentation pitfalls.
40 pairs, 22 A wins, 14 B wins, 4 ties
A win rate among decisive = 22 / 36 ≈ 61%
but n is small: a few flips change the story
400 pairs, 220 A, 140 B, 40 ties
A win rate among decisive = 220 / 360 ≈ 61%
now the same 61% is evidence, not a moodA 55% win rate on 40 pairs is weak. On 400 pairs it is interesting. Pairwise doubles judge calls (two orderings). Cache identical (judge_version, A, B, order) so a re-run does not double the bill again.
Common mistakes
- Skipping the swap. Position bias picks the winner.
- Celebrating 55% of 40 pairs. That is noise-sized.
- Several criteria in one pairwise prompt. You will not know why A won.
Check yourself
- A wins when listed first and B wins when listed first. What do you record? A tie. The orders did not agree.
- Why is 55% of 40 pairs weak evidence? Small n. The same humility as a 3-point pass-rate move on a small suite.
Key takeaways
- Pairwise matches human preference better than two independent 1–10 scores.
- Always swap order. Only consistent winners count.
- Report ties. Do not hide them in the win rate.
- Need more pairs than you think. 40 is weak. 400 is interesting.
Further learning
Back to LLM-as-a-judge. For sample-size intuition, see eval noise.
Related
LLM-as-a-judge
Using models to grade models: when a judge is the right grader, how to design one, and why an uncalibrated judge is a vibes function.
Judge biases
Judges prefer some answers for reasons that are not quality. Position, verbosity and self-preference are the ones to plan for.
Experimentation pitfalls
Peeking, metric fishing, sample ratio mismatch, novelty effects, network interference, CUPED and Twyman's law — how trustworthy experiments go wrong and how to catch them.