Sub topic 10
Calibrate an LLM Judge Against Human Labels
This chapter assumes you can read Python and JSONL, have called an LLM API, and know what a proportion and a sample size are. It also assumes you have met Cohen's kappa in the annotator agreement chapter. Here you use it to decide whether an LLM judge can stand in for human graders.
Why a judge needs calibration
An LLM judge is a model prompted to grade another model's output, usually as pass or fail against a rubric. It scales to thousands of cases. But it has biases. It may prefer longer answers, favor its own style, or accept fluent answers that are wrong.
Calibration means comparing the judge's verdicts with human labels on the same cases. If they agree well enough, you can trust the judge on the rest of the dataset. If they do not, you fix the judge prompt or use humans.
Step 1: Build a calibration set
Pick 50 to 100 cases that humans label with the same rubric you gave the judge. Include passes and failures, and include cases from each important slice. If nearly every case passes, agreement looks high by accident, which is why you use kappa and not raw agreement.
Split this calibration set too. Tune the judge prompt on one part and measure final agreement on a held-out part. Otherwise you overfit the prompt to the cases you are scoring it on.
Step 2: Measure agreement
Use the same kappa function as for annotators. Treat the judge as a second annotator.
def cohens_kappa(a, b):
n = len(a)
observed = sum(x == y for x, y in zip(a, b)) / n
labels = set(a) | set(b)
expected = sum((a.count(l) / n) * (b.count(l) / n) for l in labels)
if expected == 1:
return 1.0
return (observed - expected) / (1 - expected)
human = ["pass", "pass", "fail", "pass", "fail", "pass", "pass", "fail", "pass", "pass"]
judge = ["pass", "pass", "fail", "pass", "pass", "pass", "pass", "fail", "pass", "fail"]
agree = sum(h == j for h, j in zip(human, judge)) / len(human)
print(f"raw agreement: {agree:.2f}")
print(f"kappa: {cohens_kappa(human, judge):.2f}")Here raw agreement is 0.80, but kappa is about 0.52. Seven of the ten human labels are passes, so a judge that said "pass" often would agree a lot by chance. Kappa removes that chance agreement. A common rule of thumb reads 0.6 to 0.8 as substantial and above 0.8 as near perfect. Choose your threshold based on the decision the score drives.
Step 3: Read the disagreements
A single number does not tell you what is wrong. List the cases where the judge and human differ, and sort them by direction.
| Pattern | Likely cause | Fix |
|---|---|---|
| Judge passes, human fails | Judge is too lenient, or the rubric is vague | Add a failing example and a stricter criterion |
| Judge fails, human passes | Judge penalizes style, not correctness | Tell it to ignore wording that does not change meaning |
| Errors cluster in one slice | Rubric does not fit that input type | Add slice-specific instructions |
| Judge flips on rerun | Sampling randomness | Set temperature to 0 and compare repeat runs |
Sometimes the humans are wrong. If a disagreement shows a labeling mistake, correct the label. This improves the dataset itself.
Common errors
- Calibrating once and never again. Rerun the check when you change the judge model, the prompt, or the app's output style.
- Reporting only overall kappa. A judge can be good on easy cases and poor on adversarial ones, so check per slice.
- Leaving reference answers out of the judge prompt when the rubric depends on them.
- Using the same model to generate answers and to judge them. It tends to rate its own output higher.
Exercise
A judge and a human agree on 90 of 100 cases, but 92 of the human labels are "pass". Why is raw agreement of 0.90 not enough to trust the judge, and what do you compute instead?
Show answer
With 92% passes, a judge that almost always says "pass" would agree with humans often by chance alone. Compute Cohen's kappa, which subtracts the expected chance agreement, and also check how the judge does on the 8 failing cases specifically.