Sub topic 9
Checking a judge against human labels and known biases
An LLM judge is a measuring instrument, and you should calibrate it before you trust its numbers. This chapter covers how to compare a judge to human labels, which numbers to report, and how to test for the most common biases. It assumes you can already write a judge prompt and parse its verdict, and that you have a small set of human-labeled cases (see the previous chapters on LLM-as-judge scoring and human labeling).
Why a judge needs validation
A judge returns a PASS or FAIL for every case, so it looks reliable. But a judge can be consistently wrong. It might approve fluent but unsupported answers, or favor whichever answer it sees first. A pass rate computed from such a judge will move when your application changes, but it may not track what users care about.
The fix is to treat human labels as the reference and measure how closely the judge matches them. If the judge matches humans well enough on a sample, you can use it on the cases nobody has labeled.
Build a calibration set
A calibration set is a group of cases that humans have labeled using the same criterion the judge receives.
- Use 100 to 200 cases when you can. Fewer than 50 gives agreement figures too uncertain to act on.
- Include enough failures. If 95% of cases pass, a judge that always says PASS scores 95% agreement. Oversample bad outputs so that each class has at least 30 examples.
- Draw cases from real traffic and from known failure modes, not only from easy examples.
- Keep this set separate from any examples you put inside the judge prompt. Otherwise you are testing the judge on material it has already seen.
- Label each case independently. If two annotators disagree, record both labels and resolve the disagreement by discussion, following your labeling guidelines.
Human agreement sets a ceiling. If two humans reach a kappa of 0.6 with each other, expecting 0.9 from a judge is unrealistic. Compute human-to-human agreement first on a doubly labeled subset.
Measure agreement
Raw agreement is the fraction of cases where judge and human give the same verdict. It misleads when classes are imbalanced. Cohen's kappa corrects for the agreement you would expect by chance. It is 1.0 for perfect agreement and 0 for chance-level agreement.
The next code block computes agreement, kappa, and how many human-labeled failures the judge catches.
def cohens_kappa(a, b):
n = len(a)
observed = sum(x == y for x, y in zip(a, b)) / n
p_a = sum(a) / n
p_b = sum(b) / n
expected = p_a * p_b + (1 - p_a) * (1 - p_b)
if expected == 1:
return 1.0 if observed == 1 else 0.0
return (observed - expected) / (1 - expected)
def calibration_report(human, judge):
n = len(human)
agreement = sum(h == j for h, j in zip(human, judge)) / n
human_fails = [i for i in range(n) if not human[i]]
caught = sum(1 for i in human_fails if not judge[i])
fail_recall = caught / len(human_fails) if human_fails else 0.0
return {
"agreement": round(agreement, 2),
"kappa": round(cohens_kappa(human, judge), 2),
"fail_recall": round(fail_recall, 2),
}
human = [1, 1, 1, 0, 0, 1, 0, 1, 1, 0] # 1 = pass
judge = [1, 1, 1, 1, 0, 1, 1, 1, 1, 0]
print(calibration_report(human, judge))
# {'agreement': 0.8, 'kappa': 0.55, 'fail_recall': 0.5}Agreement of 0.8 looks acceptable. Kappa of 0.55 is only moderate, and fail_recall shows the real problem: the judge found only half of the failures. This judge is lenient, and a pass rate computed with it would be too high.
Report at least three figures: kappa (or another chance-corrected measure), recall on failures, and the confusion matrix. Which error matters more depends on your use. If a missed failure is costly, as in a safety check, optimize for failure recall. If a false alarm blocks releases and wastes engineers' time, watch precision as well.
Kappa values are a rough guide. Below 0.4 is weak, 0.4 to 0.6 is moderate, 0.6 to 0.8 is substantial, and above 0.8 is strong. Treat these as conventions, and compare against human-to-human agreement on your own task.
The kappa from 10 cases is nearly meaningless. Use the bootstrap from the statistics chapter on these paired labels to get an interval before you decide that a judge is "good enough."
Known judge biases
Judges share a set of systematic errors. Test for each one that applies to your setup.
| Bias | What happens | How to test |
|---|---|---|
| Position bias | In pairwise comparison, the judge favors the first (or last) answer | Run each pair twice with the order swapped |
| Verbosity bias | Longer answers score higher regardless of quality | Compare scores on short and long answers with the same human label |
| Self-preference | A model rates its own style of output higher | Compare judge scores across outputs from different model families |
| Leniency | The judge passes outputs a human would fail | Check recall on human-labeled failures |
| Format and style bias | Confident tone, markdown, or lists raise scores | Rewrite the same content in a plainer style and rescore |
Test position bias
For pairwise judging, call the judge twice for each pair, once as (A, B) and once as (B, A). A sound judge picks the same underlying answer both times.
def swap_consistency(judge_pair, items):
"""judge_pair(question, first, second) returns "A" or "B"."""
consistent = 0
first_picks = 0
for question, a, b in items:
r1 = judge_pair(question, a, b)
r2 = judge_pair(question, b, a)
consistent += (r1 == "A" and r2 == "B") or (r1 == "B" and r2 == "A")
first_picks += (r1 == "A") + (r2 == "A")
n = len(items)
return consistent / n, first_picks / (2 * n)
def always_first(question, first, second):
return "A"
items = [("q1", "short", "long answer"), ("q2", "x", "y")]
print(swap_consistency(always_first, items)) # (0.0, 1.0)The two returned numbers are the consistency rate and the share of times the first slot won. A healthy judge has high consistency, and its first-slot share sits near 0.5 when the pairs are balanced. A share far from 0.5 signals position bias. When bias shows up, score both orders and count a pair as a win only if both orders agree. Count disagreements as ties.
Test verbosity bias
Take the cases that humans labeled as failures and compare the judge's pass rate for long and short answers. If long failures pass more often than short ones, the judge rewards length.
def pass_rate_by_length(cases, judge, human, threshold_words):
"""Pass rate of the judge on human-labeled failures, split by length."""
short, long_ = [], []
for case, j, h in zip(cases, judge, human):
if h == 0:
bucket = long_ if len(case.split()) > threshold_words else short
bucket.append(j)
rate = lambda xs: sum(xs) / len(xs) if xs else None
return rate(short), rate(long_)For a quick experiment, take one answer and pad it with correct but unneeded detail. If the score rises, the judge is rewarding length. The usual fix is to state in the prompt that length is not a quality signal, and to add a conciseness criterion if brevity matters to you.
The validation loop
Validation is a loop. You change the judge, measure again, and stop when the numbers meet a threshold you set in advance.
Read the disagreements by hand each round. They tell you whether the judge prompt is vague, whether the criterion itself is unclear, or whether the human label was wrong. Sometimes the judge is right and the label needs correcting.
Keep the judge calibrated over time
A judge is only validated for one combination of judge model, prompt, criterion, and kind of output. Re-run the calibration when any of these change:
- The judge model version changes. Hosted models are updated, and verdicts can shift without any change on your side.
- The judge prompt or the criterion changes.
- Your application starts producing a different kind of output, such as longer answers or a new language.
Record the judge model name, the prompt text, and the calibration results next to every evaluation run, so that old scores stay interpretable. Spot-check a few judge verdicts by hand every release, and keep adding newly labeled cases to the calibration set over time.
Common mistakes
- Reporting only raw agreement on an imbalanced set.
- Validating on cases that are also used as few-shot examples in the judge prompt.
- Using a judge from the same model family as the application under test without checking self-preference.
- Treating unparseable judge replies as failures or dropping them. Count them separately, as
parse_verdictdoes when it returnsNone. - Changing the judge between two runs you intend to compare. Differences then reflect the judge, not the application.
Exercise
A judge and a human label 20 cases. The human marks 18 as PASS and 2 as FAIL. The judge marks all 20 as PASS. Compute raw agreement and Cohen's kappa, and explain what they say about the judge.
Show answer
Raw agreement is 18/20 = 0.90. For kappa, the human pass proportion is 0.9 and the judge pass proportion is 1.0, so expected agreement is 0.9 × 1.0 + 0.1 × 0 = 0.9. Kappa is (0.9 − 0.9) / (1 − 0.9) = 0. The judge agrees 90% of the time only because it always says PASS, which kappa reveals as chance-level agreement. Its failure recall is 0 out of 2, so it is useless for finding failures. A better calibration set would include more human-labeled failures.
Exercise
You run a position-swap test on 50 pairs. Your judge picks the first slot in 70 of the 100 calls, and gives the same underlying winner in both orders for 30 pairs. What do you conclude, and what do you change?
Show answer
The first-slot share of 0.70 shows position bias, and the consistency rate of 30/50 = 0.60 means 40% of pairs flip when the order changes. Verdicts on those pairs reflect slot order, not quality. Score each pair in both orders and count a win only when both orders agree, treating disagreements as ties. Then re-measure, and consider revising the prompt or trying a different judge model.