LJ

    LLM Judge Bias Check: Position and Length Swap Test

    by Vijay Kumar

    1

    Pairwise judges, where an LLM picks the better of two answers, are cheap and popular.

    Free

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+23 more

    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.”

    LJ

    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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Frequently Asked Questions

    This skill detects if an AI judge is making unfair decisions based on the order of answers or how long they are. It helps you decide if you can trust a model win rate before you publish it or use it to rank different AI models.

    You need a CSV file containing the pairs of answers you want to compare. You also need to provide the verdicts from your judge model for both the original and swapped versions of those pairs.

    The skill provides a detailed report showing the conflict rate, which is how often the judge changes its mind when the answer order is flipped. It also identifies if the judge favors longer answers and calculates how well the AI judge agrees with human labels.

    While it identifies if a judge is consistent, it does not catch every type of bias, such as a model preferring its own style or specific formatting. It also requires at least 100 pairs of answers to provide high quality results.

    You can ask your agent to run a swap test or check your LLM judge for position and verbosity bias. It can also help you prepare two versions of every pair to test the judge or analyze a judged CSV file to generate a trust verdict.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.

    Free