Sub topic 11
Checking the Judge Against Human Labels
This chapter assumes you can read Python and have a small evaluation set. It also assumes you know how a pointwise judge prompt works (a judge prompt scores one answer at a time) and what a proportion is. Earlier chapters covered rubrics and structured output. Here you test whether the judge's verdicts deserve trust.
Why a judge needs validation
A judge is a proxy. It stands in for a human reviewer, and nothing guarantees that it agrees with one. A judge can return clean JSON, give plausible reasoning, and still grade differently from the people whose standards you care about.
Validation means comparing the judge's verdicts with human verdicts on the same items. If the two agree closely enough, you can use the judge on the much larger set of items that no human has labeled. If they don't, you fix the rubric or the prompt, or you stop using a judge for that criterion.
Build the human-labeled set
The human labels are your ground truth, so their quality limits everything that follows.
- Sample from real traffic. Use outputs your system actually produces, not invented examples. Include the hard cases, such as borderline answers and long answers.
- Cover the failures. If 95% of outputs are good, a random sample of 100 holds about five bad ones. Add known failures deliberately so you can measure how well the judge catches them. Record how you sampled, because that changes how you read the metrics.
- Use the same rubric. Give the labelers the exact criterion text the judge sees. Otherwise any disagreement may come from different instructions, not from judge error.
- Label blind. Do not show labelers the judge's verdict.
- Keep a test split. Tune the rubric and prompt on one part of the labeled set. Report agreement on a part you never tuned against. Otherwise you will overestimate how well the judge generalizes.
Aim for at least a few hundred labels when you can. With 100 items, an observed agreement of 85% carries a margin of roughly plus or minus 7 percentage points (1.96 × √(0.85 × 0.15 / 100) ≈ 0.07).
Raw agreement is not enough
The simplest metric is observed agreement, the fraction of items where judge and human give the same label. It is easy to compute and easy to misread.
Suppose 90 of 100 answers are good. A judge that always says "pass" agrees with humans on 90% of items while detecting nothing. When one class dominates, high agreement can come almost entirely from chance.
Chance-corrected agreement: Cohen's kappa
Cohen's kappa subtracts the agreement you would expect if the judge and the human labeled independently, using their own label frequencies:
kappa = (observed − expected) / (1 − expected)
A kappa of 1 means perfect agreement. A kappa of 0 means no better than chance. A negative kappa means worse than chance.
from collections import Counter
def cohens_kappa(human, judge):
n = len(human)
observed = sum(h == j for h, j in zip(human, judge)) / n
hc, jc = Counter(human), Counter(judge)
expected = sum(hc[k] * jc[k] for k in hc) / (n * n)
if expected == 1:
return 1.0 if observed == 1 else 0.0
return (observed - expected) / (1 - expected)
# A judge that always says "pass" on a skewed dataset
human = ["pass"] * 90 + ["fail"] * 10
judge = ["pass"] * 100
agree = sum(h == j for h, j in zip(human, judge)) / len(human)
print("observed agreement:", agree)
print("kappa:", round(cohens_kappa(human, judge), 3))
# A judge with some real signal
human = ["pass", "pass", "fail", "pass", "fail", "fail"]
judge = ["pass", "pass", "fail", "fail", "fail", "pass"]
print("kappa:", round(cohens_kappa(human, judge), 3))The first case prints 0.9 agreement but a kappa of 0.0. The second prints a kappa of 0.333, because observed agreement is 4/6 and chance agreement is 0.5.
A commonly quoted rough scale (Landis and Koch) reads kappa below 0.2 as slight, 0.2 to 0.4 as fair, 0.4 to 0.6 as moderate, 0.6 to 0.8 as substantial, and above 0.8 as near perfect.
Scores on a scale
For 1 to 5 scores, exact-match kappa treats a 4 versus a 5 the same as a 1 versus a 5. Two better options:
- Weighted kappa penalizes disagreements by distance. Quadratic weights are common.
- Rank correlation such as Spearman's rho checks whether the judge orders items the way humans do, even if its scores sit consistently higher or lower.
A judge that is consistently one point more generous still ranks items correctly. That may be fine for comparing two systems and wrong for a fixed pass threshold.
Look at the kinds of errors
One agreement number hides which mistakes the judge makes. If you use the judge to catch failures, you care most about two rates:
- Recall on failures: of the answers humans marked bad, how many did the judge flag?
- Precision on failures: of the answers the judge flagged, how many did humans also mark bad?
from collections import Counter
def failure_metrics(human, judge, positive="fail"):
pairs = Counter(zip(human, judge))
tp = pairs[(positive, positive)]
fp = sum(c for (h, j), c in pairs.items() if h != positive and j == positive)
fn = sum(c for (h, j), c in pairs.items() if h == positive and j != positive)
precision = tp / (tp + fp) if tp + fp else 0.0
recall = tp / (tp + fn) if tp + fn else 0.0
return precision, recall
human = ["pass", "pass", "fail", "pass", "fail", "fail"]
judge = ["pass", "pass", "fail", "fail", "fail", "pass"]
p, r = failure_metrics(human, judge)
print(f"precision={p:.2f} recall={r:.2f}")Low recall means real failures get through. Low precision means you waste time on false alarms. Which matters more depends on the use. A release gate wants high recall. A triage queue for reviewers can tolerate lower precision.
After computing the numbers, read the disagreements. Pull 20 or so items where judge and human differ and ask why. Common causes are an ambiguous rubric, a judge that ignores part of the context, or a human label that was simply wrong.
The workflow
How much agreement is enough
Humans disagree with each other too. Have two people label a subset and compute kappa between them. That human-to-human figure is a practical ceiling. If two careful people reach only a kappa of 0.6, demanding 0.9 from the judge is unrealistic, and the real problem is probably a vague rubric.
The target depends on the decision:
| Use of the judge | What to look for |
|---|---|
| Compare two system versions on average | Moderate to substantial kappa, no strong bias toward one version |
| Gate a release on a pass rate | High recall on failures, with the interval reported |
| Flag items for human review | High recall, and moderate precision is acceptable |
| Make decisions about individual users | Do not rely on a judge alone |
Common errors
- Tuning on the test split. Each prompt edit that you check against the same labels leaks information. Hold out a set.
- Reporting only observed agreement. Always add kappa or per-class precision and recall.
- Labeling with different instructions. The humans and the judge must use the same criterion.
- Validating once and forgetting. A new judge model version, a new prompt, or new kinds of outputs can all break earlier results. Re-run the check, and keep a small fixed labeled set for that purpose.
- Ignoring subgroups. Check agreement separately for long and short answers, for different topics, and for different source systems. A good overall number can hide a weak segment.
- Trusting a small sample. A few dozen labels give a wide interval. Report it, as the chapter on confidence intervals shows.
Exercise
A judge labels 200 answers. Humans marked 180 as "pass" and 20 as "fail". The judge marked every answer "pass". Compute the observed agreement and Cohen's kappa, and explain what the result says about the judge.
Show answer
Observed agreement is 180/200 = 0.90. Expected agreement is (180 × 200 + 20 × 0) / 200² = 0.90. Kappa = (0.90 − 0.90) / (1 − 0.90) = 0. The 90% agreement comes entirely from the dominant "pass" class, so the judge has no ability to detect failures. Its recall on failures is 0.
Exercise
You tuned your judge prompt over six rounds, checking the kappa on the same 150 labeled items each time. The final kappa is 0.72. Why might this overstate real performance, and what should you do?
Show answer
Each round of edits was guided by results on the same items, so the prompt has partly adapted to those items and the kappa is optimistically biased. Label a fresh test set that was never used for tuning (or split the data beforehand), then report kappa on that held-out set along with a confidence interval.