LLM Judge Bias Check: Position and Length Swap Test
by Vijay Kumar
Pairwise judges, where an LLM picks the better of two answers, are cheap and popular.
Free
Works with the AI Agents you already use
What it does
- Builds both orderings of every A/B pair so the judge sees each answer in each position
- Measures the conflict rate, meaning how often the verdict flips with order, with a 95% interval
- Reports first-slot win rate to expose position bias, and swap-to-tie label shares
- Compares how often the longer answer wins for the judge and for humans, and checks equal-length pairs
- Reports agreement with human labels as exact match and Cohen's kappa, with and without ties
- Runs sanity checks on identical and empty answers and gives a clear trust verdict
Who it's for
ML engineers building evals
Check your judge before you trust a leaderboard.
Try asking: “Check whether my pairwise judge is biased using this CSV.”
Teams comparing two models
Find out if the winner is real.
Try asking: “Model X wins 58% on the judge. Is that real or length bias?”
People training preference models
Clean up the labels first.
Try asking: “Run a swap test on my preference data.”
LLM Judge Bias Check: Position and Length Swap Test
Example session with this skill installed
I judged 60 answer pairs twice, once in each order, with my GPT judge. Results are in judged_pairs.csv along with human labels. Is the judge trustworthy?
- Read your context and instructions
- Compiled the llm judge bias
(bundled synthetic data, deliberately biased for the demo)
$ python3 scripts/swap_test.py score examples/judged_pairs.csv
Pairs: 60
Conflict rate (verdict flips with order): 45.0% (95% CI 33.1% to 57.5%)
First-slot win rate (non-tie, both orders): 0.68 (95% CI 0.59 to 0.76; 0.50 = no position bias)
After swap-to-tie: A 0.17 | B 0.28 | tie 0.55
Longer answer wins (judge, non-tie): 0.85 (n=26, 95% CI 0.66 to 0.94)
Longer answer wins (human, non-tie): 0.51 (n=45)
Equal-length pairs (|r|<0.05): n=7, judge A/B/tie = 1/0/6
Agreement with humans (swap-to-tie): exact match 0.53, Cohen's kappa 0.36 (n=60, ties kept)
ties removed: exact match 0.96 (n=26)
Sanity checks:
identical-answer pairs: 4 (all tie, ok)
pairs with an empty answer: 0
Verdict: NOT trustworthy as-is: conflict rate 45% is above 30%; strong length preference: report it next to any win rate
Agent report: Do not publish win rates from this judge as they stand. The verdict flips with order on 45% of pairs, and the first-shown answer wins 68% of decided comparisons. The judge picks the longer answer 85% of the time while humans pick it 51%, a clear length bias. Next steps: add a rubric and an explicit "ignore length and order" instruction, try a second judge, send the 27 conflicting pairs for human labels, and re-run this test.
Connects securely to your tools. The creator never sees your data.
About this skill
Pairwise judges, where an LLM picks the better of two answers, are cheap and popular. They are also biased in known ways: they tend to favour whichever answer is shown first, and they tend to favour longer answers. If you publish a win rate without checking, the number may be mostly an artifact.
LLM Judge Bias Check gives your agent a short, rigorous procedure. First it sanity-checks your data: label balance, identical answers (the judge should say tie), empty answers, and whether one model always sits in slot A. Next, the prepare command writes every pair in both orders so you can run your judge twice. Then the scorer reports the conflict rate with a confidence interval, the first-slot win rate (0.50 means no position bias), how often the longer answer wins for the judge versus your human labels, behaviour at equal length, and agreement with humans as exact match and kappa.
It finishes with a verdict you can quote: usable with swap-averaging, usable only with swap-to-tie, or not trustworthy as-is, and a reminder that a consistent judge can still be biased toward length. A report template and notes on writing a better judge prompt are included.
The script is pure local analysis in standard-library Python: no network, no packages.
You end up with numbers and a defensible sentence for your eval write-up, and a clear decision on whether to keep, fix or replace the judge.
Needs at least 100 pairs for reliable results. It only detects order and length bias, not other style or formatting preferences.
Files: `SKILL.md`, `README.md`, `scripts/swap_test.py` (about 7 KB, standard library only; commands `prepare` and `score`, option `--raw-ba`), `references/report-template.md`, `examples/pairs.csv`, `examples/judged_pairs.csv`. Permissions to expect in the scan: file read only, no network, no subprocess.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed today
- Free with an Agensi account
Permissions
What's inside
Frequently Asked Questions
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.