Sub topic 7
Position bias in pairwise comparisons
This chapter assumes you can read Python, have prompted an LLM before, and know what a pairwise judge is from the chapter on judging formats. You will learn what position bias is, how to measure it in your own setup, and how to reduce it by judging both orders and treating disagreement as a tie.
What position bias is
In a pairwise comparison, the judge sees a question and two candidate answers and picks the better one. Position bias is a tendency to favor an answer because of where it appears in the prompt, not because of its content. Some judge models lean toward the first answer, some toward the second, and some change their lean depending on the task or prompt wording.
The bias matters because the order is usually arbitrary. If you compare model A and model B and always put A first, a first-position preference gives A extra wins that it did not earn. You then report a difference between systems that is really a property of your prompt layout.
Position bias is strongest when the two answers are close in quality. When one answer is clearly better, most judges pick it in either slot. When the answers are nearly equal, the judge has little to go on, and the slot decides.
Seeing the bias in a small experiment
The simplest test is to run every pair twice, once in each order, and see whether the verdict follows the answer or follows the slot.
| Order shown | Judge says | What it means |
|---|---|---|
| A first, B second | first | A wins |
| B first, A second | second | A wins again, so the verdict follows the answer |
| A first, B second | first | A wins |
| B first, A second | first | B wins, so the verdict follows the slot |
The last two rows show a position-driven result. The judge picked "first" both times, so the content of the answers did not decide the outcome.
The swap-and-agree procedure
The mitigation has three steps:
- Call the judge with the answers in the original order.
- Call it again with the answers swapped.
- Map each verdict back to the answer identity. Report a winner only if both runs name the same answer. Otherwise report a tie.
def judge_pair(call_judge, question, a, b):
"""call_judge(question, first, second) returns "first" or "second"."""
r1 = call_judge(question, a, b)
r2 = call_judge(question, b, a)
win1 = "A" if r1 == "first" else "B"
win2 = "B" if r2 == "first" else "A"
return win1 if win1 == win2 else "tie"The mapping lines are where bugs happen. In the second call, b was shown first, so a verdict of "first" means B won. If you forget to flip it, a judge that always answers "first" would appear to agree with itself. Check this with fake judges that have known behavior:
def judge_pair(call_judge, question, a, b):
"""call_judge(question, first, second) returns "first" or "second"."""
r1 = call_judge(question, a, b)
r2 = call_judge(question, b, a)
win1 = "A" if r1 == "first" else "B"
win2 = "B" if r2 == "first" else "A"
return win1 if win1 == win2 else "tie"
def always_first(question, first, second):
return "first"
def longer_wins(question, first, second):
return "first" if len(first) >= len(second) else "second"
short, long_ = "Paris.", "The capital of France is Paris."
print(judge_pair(always_first, "Capital of France?", short, long_)) # tie
print(judge_pair(longer_wins, "Capital of France?", short, long_)) # BThe always-first judge is fully position-driven, so the two runs disagree and the result is a tie. The longer_wins judge ignores position, so both runs name B. Note that longer_wins is a different bias, verbosity, which the next chapter covers. Swapping removes position effects but cannot remove a bias that travels with the answer.
Measuring how much bias you have
Before you rely on a judge, estimate its position bias on your own data. Two numbers are enough:
- First-slot rate. Across all calls, in both orders, count how often the judge picks "first". A judge with no position preference should be near 50%, because each answer occupies the first slot half the time. A value far from 50% signals a lean.
- Inconsistency rate. The share of pairs where the two orders disagree. This is the share that
judge_pairturns into ties.
def position_stats(call_judge, pairs):
first_picks = 0
inconsistent = 0
for question, a, b in pairs:
r1 = call_judge(question, a, b)
r2 = call_judge(question, b, a)
first_picks += (r1 == "first") + (r2 == "first")
win1 = "A" if r1 == "first" else "B"
win2 = "B" if r2 == "first" else "A"
inconsistent += win1 != win2
n = len(pairs)
return first_picks / (2 * n), inconsistent / nThe first-slot rate tells you the direction of the lean. The inconsistency rate tells you how much data the swap costs you. A high inconsistency rate does not mean the answers are equal. It means this judge, with this prompt, cannot separate them reliably.
Reading the results
Treat swap disagreement as a ties signal, not as noise to average away. Three practical points follow.
Report ties separately. If 30% of pairs become ties, say so. A win rate computed only over the non-tie pairs hides how often the judge could not decide. Report the win, tie, and loss counts together.
Ties are a mix. A tie from swapping can mean the answers are truly equal, or that the judge is unreliable on those pairs. You cannot tell which from the verdicts alone. Spot-check some ties against human labels to see which kind dominates.
Cost doubles. Every pair needs two judge calls. For large comparisons this is real money and latency, but skipping the swap is rarely a safe saving unless you have measured that your judge shows almost no position bias on your data.
Other ways to reduce position bias
Swap-and-agree is the default, but other techniques can stand alone or add to it:
| Technique | How it works | Limit |
|---|---|---|
| Randomize order | Assign slots at random per pair, with one call | Removes systematic skew from the aggregate but keeps per-pair noise |
| Swap and agree | Judge both orders and tie on disagreement | Doubles the calls and may produce many ties |
| Swap and average scores | Ask for a score per answer in each order and average | Needs scores, which add their own scale bias |
| Neutral labels | Use "Answer 1" and "Answer 2" or random IDs instead of letters with implied rank | Reduces label effects but does not remove slot effects |
| Pointwise scoring | Grade each answer alone, with no second answer to place | Loses direct comparison and can be less sensitive |
Randomizing the order is the cheapest option. It turns a systematic error into random error, and with enough pairs the average lands near the truth. It does not fix individual verdicts, so it suits aggregate system comparisons more than per-example decisions.
Also keep the order of the two answers independent of any other property. If your better system tends to produce longer answers and you always put the longer one second, you have confounded position with length, and you cannot tell which one the judge responded to.
Edge cases
- Judges that allow ties. If the judge can say "tie" itself, treat that as a verdict. Two runs of "tie" agree. A run of "tie" and a run of "A" disagree, so report a tie.
- More than two candidates. Full order permutations grow quickly. With a ranking of several answers, use a few random orderings per item and aggregate, or run pairwise comparisons on a sample of pairs.
- Position bias can change. A new judge model, a changed prompt, or a different task type can shift the lean. Re-run
position_statswhenever you change any of them. - Long contexts. When both answers are long, the judge may attend more to the end of the prompt, and the second slot can gain weight. Measure instead of assuming a direction.
Key points
Position bias makes the slot, not the content, decide some verdicts. You measure it by running both orders and computing the first-slot rate and inconsistency rate. You reduce it by swapping and treating disagreement as a tie, or by randomizing order. Swapping handles position effects only. Verbosity and self-preference stay with the answer, so they need separate checks.
Exercise
A judge is run on 200 pairs in both orders. It picks "first" in 290 of the 400 calls. In 60 of the 200 pairs the two orders name different winners. What are the first-slot rate and the inconsistency rate, and what do they suggest about using this judge with a single call per pair?
Show answer
The first-slot rate is 290 / 400 = 72.5%. The inconsistency rate is 60 / 200 = 30%. A first-slot rate that far above 50% shows a strong lean toward the first answer. A single call with a fixed order would give the answer in the first slot an unearned advantage. You should swap and agree, or at least randomize the order, and report the 30% of pairs that end as ties.
Exercise
A teammate changes judge_pair so the second call is call_judge(question, b, a) but keeps win2 = "A" if r2 == "first" else "B". What goes wrong, and which fake judge from this chapter exposes it?
Show answer
The second verdict is mapped to the wrong answer. In that call B was in the first slot, so "first" means B won. With the bug, a judge that always says "first" yields win1 = "A" and win2 = "A", so it reports A as the winner every time instead of a tie. Running always_first exposes the bug, because the correct result is "tie".