Sub topic 9
Checking a Judge Against Human Labels and Known Biases
This chapter assumes you can write basic Python and have used an LLM API. It also assumes you know what an LLM judge is, from the previous chapter, and basic statistics such as proportions. A judge is a model that grades outputs. Its scores are only useful if they agree with what people would say. Here you will measure that agreement and look for biases that distort it.
Why a judge needs checking
A judge is a model with its own errors. If it passes bad answers or fails good ones, your pass rate is wrong, and you may ship the wrong version. The check is simple. Have humans label a sample of outputs, run the judge on the same outputs, and compare.
Measuring agreement
Start with a set of 50 to 100 outputs that humans have labeled PASS or FAIL. Use a different set from the one you used to write the judge prompt. Otherwise you only measure how well you tuned the prompt to those examples.
Raw agreement is the share of cases where judge and human match. It can mislead when one label is common. If 90% of answers pass, a judge that always says PASS gets 90% agreement. Cohen's kappa corrects for agreement expected by chance.
def agreement_and_kappa(human, judge):
n = len(human)
observed = sum(h == j for h, j in zip(human, judge)) / n
p_h = sum(human) / n
p_j = sum(judge) / n
expected = p_h * p_j + (1 - p_h) * (1 - p_j)
if expected == 1:
return observed, 1.0
return observed, (observed - expected) / (1 - expected)
human = [True, True, False, True, False, True, True, False, True, True]
judge = [True, True, True, True, False, True, False, False, True, True]
print(agreement_and_kappa(human, judge)) # (0.8, 0.5833...)Here raw agreement is 0.8, but kappa is about 0.58. Values near 0.6 are often called moderate to substantial, though no universal cutoff exists. Choose a threshold that fits the stakes of your decision.
Also look at the error types. A judge that wrongly passes bad answers (false passes) hides problems. A judge that wrongly fails good answers (false fails) wastes engineering time. Count both in a confusion table of judge verdict against human label.
Known biases
Judges show consistent biases. Test for each one directly.
| Bias | What happens | How to test |
|---|---|---|
| Position bias | In pairwise comparisons, the judge favors the answer shown first (or last). | Run each pair twice with the order swapped. Count verdicts that flip. |
| Verbosity bias | Longer answers score higher regardless of quality. | Check whether the judge's scores correlate with answer length among human-equal answers. |
| Self-preference | A model rates text from its own family higher. | Compare scores for outputs from the judge's model against outputs from other models. |
| Format bias | Polished formatting such as bullets raises scores. | Reformat the same content and see whether the verdict changes. |
Order swapping is the cheapest test. If the verdict changes when you only swap positions, the judge is not reading the content reliably.
def position_flip_rate(judge_pair, pairs):
flips = 0
for a, b in pairs:
first = judge_pair(a, b) # returns "A" or "B"
second = judge_pair(b, a)
# Consistent only if the same answer wins in both orders.
same_winner = (first == "A") == (second == "B")
flips += not same_winner
return flips / len(pairs)Fixing problems
- Tighten the criterion. State one property to check, as in the faithfulness prompt from the previous chapter.
- Add a few labeled examples to the prompt, including borderline ones.
- Randomize or swap order in pairwise judging, and keep only consistent verdicts.
- Report unparseable verdicts as their own count.
- Re-check after any change to the judge model or prompt. A new model version can shift agreement.
Exercise
A judge agrees with human labels on 92% of cases, but 95% of the human labels are PASS. Why is 92% not good evidence, and what would you compute?
Show answer
A judge that always answers PASS would already agree on 95% of cases, so 92% is worse than that baseline. Compute Cohen's kappa to correct for chance agreement, and build a confusion table to see how many of the few human FAIL cases the judge catches.