Calibrating a judge against human labels: agreement, kappa and choosing a threshold

Study time
≈ 2 h (estimate)
Needs
L2-M04-L03
Updated
2026-11-03

Progress is saved in this browser only. No account, nothing is sent to a server.

Draft · reviewed by AI, not yet by a person. Content may change. English translation: AI-assisted, not human-reviewed.
On this page

Module: L2-M04 · Duration: ~120 min (estimate, including the independent exercise) · Previous: L03 · Next: L05

1. Introduction

A judge that has not been compared with humans is only an opinion. Calibration means comparing the judge with human labels on your data, reading the result correctly, choosing a threshold for its scores, and deciding what the judge may be used for. This lesson puts three things together: the error rates from the confusion matrix, Cohen's kappa (agreement after removing the part due to chance; the teaching part computes it only for pass or fail labels, §9 extends it to multiple levels as an advanced exercise; L2-M05-L02 goes deeper), and a threshold-choosing procedure that does not fool itself.

The "human" labels and the judge in the lab are simulated (L01 §5.1): the figures describe the simulation, the method is real. The output of this lesson is a calibration report and a decision about the threshold.

2. Learning objectives

  1. Split the human label set into dev and test with no overlap, stable by item id. Practice: §8.2 part A.
  2. Compute the confusion matrix, raw agreement, chance agreement and kappa, and explain why kappa can be 0 when raw agreement is high. Practice: §8.3.
  3. Choose a threshold on dev under a ceiling on the false-accept rate and report on test with confidence intervals. Practice: §8.2 parts B, C.
  4. Read a per-group report (borderline cases) and compare it with the "always pass" baseline. Practice: §8.2 parts C, D.
  5. Decide what the judge is used for, from the evidence. Practice: §8.2 part E, §9 (TODO 3).

3. Prerequisites and tools

  • L2-M02-L03: human-assigned labels, borderline cases, raw and chance agreement (this lesson reuses them and does not teach them again).
  • L2-M01-L03 to L05: the confusion matrix, the Wilson interval, decision rules based on intervals.
  • L2-M04-L02, L03: prompts, parsers, biases. The code lab code-labs/l2-m04 (self-contained).

4. Concepts

4.1 What calibration is

Anthropic writes that a judge should be "closely calibrated with human experts" so that the difference between human and model scoring can be trusted to be small [R5]. OpenAI advises "validate agreement against your human labels before optimizing for cost or latency" [R4]. Three conditions make calibration meaningful: human labels on your data, with a guideline and a way of handling borderline cases (L2-M02-L03); a record of how the sample was drawn; and a separation between the part used for tuning and the part used for reporting.

In this lesson the positive class is "PASS": for the judge, a score at or above the threshold; for the human, a pass label. (In L2-M03 the positive class is "the metric accepts the answer"; in L01 §5.2 it is "judged to have the right number"; in L2-M01-L03 it is the curt reply, that is, the bad one, so fp there was a false alarm whereas here fp is a false accept.)

4.2 The confusion matrix and two error rates

With "pass" as the positive class: tp the judge passes and the human passes; fp the judge passes but the human fails it (a false accept: a bad reply slips through); fn the judge fails but the human passes it (a false reject); tn both fail. From these: precision = tp / (tp + fp), the share of the judge's passes that the human agrees with; recall = tp / (tp + fn), the share of the human's passes that the judge keeps. The two error rates that read most easily when deciding on a release: the false-accept rate = fp / (fp + tn) (among the replies the human fails, how many the judge lets through) and the false-reject rate = fn / (fn + tp). When the denominator is 0 the result is None, not 0 or 1.

4.3 Raw agreement, chance agreement and kappa

Raw agreement p_o = (tp + tn) / n. Chance agreement p_e is the agreement expected if the judge and the human assigned labels independently, computed from each side's pass rate: p_e = (judge passes × human passes + judge fails × human fails) / n². Cohen's kappa is κ = (p_o − p_e) / (1 − p_e): 0 is chance-level agreement, 1 is perfect agreement, and it can be negative [R3]. With tp = 40, fp = 10, fn = 5, tn = 45: p_o = 17/20, p_e = 1/2, κ = 7/10. Kappa is undefined (None) when p_e = 1, that is, when both sides assign a single label to every item.

Why kappa is needed: when labels are skewed, raw agreement misleads. The lab has an example with tp = 95, fp = 3, fn = 2, tn = 0: p_o = 0.95 but the false-accept rate = 1 (the judge catches no bad reply) and κ = −3/122 (slightly negative). The "always pass" example gives κ = 0 and a raw agreement exactly equal to the share the human passes.

Three warnings from the sources. McHugh writes that the interpretation attributed to Cohen (from "none to slight" to "almost perfect") allows very low agreement to be called "substantial" [R3]: do not apply a table of words to kappa, choose the threshold by the consequences of the decision. Thakur et al. write that a measure beyond percent agreement is needed, because a judge with high agreement can still assign scores very different from humans [R2, abstract]; their first version used kappa, the current version uses Scott's pi because kappa computes chance probability from each side's own distribution, something they regard as theoretically problematic [R2, Appendix B]. And Zheng et al. define agreement as the probability that two individuals chosen at random (not the same one) fall in the same voting category; the figure "over 80%" in their abstract corresponds to the case of counting only non-tie votes: GPT-4 against humans 85%, human against human 81%, where chance is 50%. When ties and inconsistent votes are counted too (chance 33%), GPT-4 against humans is 66% and human against human 63% (the first turn of MT-bench) [R1, Table 5, D.3]. The same study gives two figures depending on how ties are counted: always ask what the denominator is.

4.4 Choosing a threshold and splitting dev and test

A pointwise judge gives a score from 1 to 5; "pass" needs a threshold. The lab uses three steps. (1) split_dev_test splits by a hash of the item id: an item is always on the same side regardless of the order or size of the list; assert_disjoint checks there is no overlap. (2) sweep computes the confusion matrix for each threshold from 1 to 5 on dev; choose_threshold(rows, cap) picks the threshold with the highest kappa among those whose false-accept rate is no more than cap (inclusive), breaks ties by taking the stricter threshold, and returns None if no threshold qualifies: the judge does not meet the requirement, and says so. (3) report computes the figures on test, which was never used for choosing.

5. Technical deep dive

5.1 The procedure on the lab's label set

Flow diagram: 200 replies with human labels → the judge grades and unreadable outputs are dropped → split into dev and test by a hash of the item id → sweep thresholds on dev → does a threshold meet the false-accept cap? No: report that the judge does not meet the requirement. Yes: choose the threshold and report on test by group → release gate on n, false-accept rate and kappa: pass means use the judge, fail means the judge only triages and a person decides.
Diagram: The procedure on the lab's label set

Printed numbers are rounded to 3 decimal places; comparisons with the threshold use exact Fraction, and only the Wilson interval uses floating point. Part A of the demo: the simulated judge with a reference answer scores 200 replies, 2 unreadable outputs are dropped, leaving 198; dev 95, test 103. The threshold sweep on dev (tp, fp, fn, tn; agreement; kappa; false-accept rate): threshold 3 gives 45, 42, 0, 8 (kappa 0.153, false accept 0.840); threshold 4 gives 45, 25, 0, 25 (kappa 0.486, false accept 0.500); threshold 5 gives 43, 8, 2, 42 (agreement 0.895, kappa 0.790, false accept 0.160). With a false-accept cap of 0.2, the chosen threshold is 5. The threshold of 4 from L03 gives a false accept of 0.500: a lenient judge needs a strict threshold.

5.2 The report on test, per group

On test (n = 103): agreement 0.806 (95% interval 0.719 to 0.871), kappa 0.625, false-reject rate 0.000, and false-accept rate 20/60 = 0.333 (interval 0.227 to 0.459) against the cap of 0.2. The false-accept rate on dev is 8/50 = 0.160 (interval 0.083 to 0.285): the two intervals overlap, so the gap between 0.160 and 0.333 may be only chance in two small samples; but the point estimate (the value computed directly from the sample) on test is already above the cap, and the lab's release rule uses the point estimate (§5.3).

By the borderline group (borderline cases, L2-M02-L03): the regular group (n = 89) has agreement 0.876 and kappa 0.756; the borderline group (n = 14) has agreement 0.357 and kappa 0.000. The judge passes all 14 borderline replies, while the human passes only 5; a sample size of 14 makes the figures very uncertain. The overall 0.806 hides the weakest group (the lesson of L2-M03-L05).

5.3 Baseline, release gate and consequences

A judge that "always passes" on test: agreement 0.417 (equal to the share the human passes) and kappa 0.000: a reference point. release_gate(rep, min_n=80, max_false_accept=Fraction(1, 5), min_kappa=Fraction(3, 5)) is a rule chosen by the lab: minimum n, maximum false-accept rate, minimum kappa; anything missing or undefined means not met. Unlike L2-M01-L05 (which uses a bound of the Wilson interval), this gate deliberately uses the point estimate for simplicity. Result: NOT_READY, the reason being that the false-accept rate exceeds the cap (kappa 0.625 passes, n = 103 passes). If the Wilson upper bound were used (0.285 on dev, 0.459 on test) the conclusion would be even stricter: no threshold meets the cap of 0.2.

Part F runs the same procedure for the judge without a reference answer: the chosen threshold is 5; on test kappa is 0.556 and the false-accept rate is 24/60 = 0.400. The reasonable conclusion under the decision checklist of L01: the judge only flags replies for a human to review (especially borderline cases), does not block a release on its own, and is recalibrated when more labels arrive.

6. The QA perspective

6.1 What calibration does not prove

  • Agreement holds only for these labels, this distribution: bad labels give a bad conclusion; different data needs to be measured again.
  • Sample size: 103 test items give a wide interval; small differences between two judges usually cannot be told apart from chance (L2-M07, not yet written).
  • Leakage: if you tune the prompt or the threshold by looking at test, test is no longer a test. Tune on dev; use test once for the report.
  • The lab's release gate uses the point estimate and made-up thresholds; your organisation needs thresholds based on risk (L2-M01-L05).
  • Calibration holds only for the judge configuration that was measured. Changing the model, prompt or rubric changes the judge (L05).

6.2 A minimal calibration report

A usable report states: the judge (model, version, prompt, rubric, threshold) and on which data the threshold was chosen; the human labels (how many, who assigned them, the guideline, how they were sampled); the number of dev and test items, the number of unreadable outputs dropped; the confusion matrix on test; agreement with its interval, kappa, the false-accept rate with its interval, the false-reject rate; results per group with n; the always-pass baseline; and the decision with its reason.

7. Real-world scenarios

Scenario 1 (fictional): "95% agreement". The HocVui Tutor team tested a judge for a safety criterion on a label set in which 97% of replies passed and reported "95% agreement with humans". The confusion matrix showed that the judge caught no bad reply (false-accept rate 1) and kappa was slightly negative. They did not use the judge for that criterion and added bad cases to the label set.

Scenario 2 (fictional): "The best threshold on everything". Someone chose the threshold on all 198 labels and then reported on those same 198 labels: the false-accept rate looked good, and on the next batch of new labels it was clearly higher. The team switched to splitting dev and test by a hash of the item id and recorded which set the threshold was chosen on.

8. Hands-on tutorial

8.1 Setup

cd academy-content/code-labs/l2-m04
python3 -m venv .venv && source .venv/bin/activate     # Windows: .venv\Scripts\activate
python -m pip install -r requirements.txt
python -m pytest            # 79 passed

8.2 Run the demo

python -m lab.demo l04

Output (copied from a real run on Python 3.14.6 and 3.12.14, 2026-11-03; the two versions give identical output):

A. 200 labelled replies, judge with the reference, 2 unreadable dropped; dev 95, test 103
   threshold  tp  fp  fn  tn  agreement  kappa  false-accept
       1      45  50   0   0  0.474     0.000  1.000
       2      45  50   0   0  0.474     0.000  1.000
       3      45  42   0   8  0.558     0.153  0.840
       4      45  25   0  25  0.737     0.486  0.500
       5      43   8   2  42  0.895     0.790  0.160
B. threshold chosen on dev with false-accept <= 0.2: 5
C. report on test (n=103): agreement 0.806 (95% 0.719-0.871), kappa 0.625, false-reject 0.000
   false-accept 20/60 = 0.333 (95% 0.227-0.459) against the cap 0.2
   borderline=False n= 89 agreement 0.876 kappa 0.756
   borderline=True  n= 14 agreement 0.357 kappa 0.000
D. trivial judge that passes everything, on test: agreement 0.417, kappa 0.000
E. release gate (lab rule: n >= 80, false-accept <= 0.2, kappa >= 0.6): ('NOT_READY', ['false-accept rate missing or above the cap'])
F. the same procedure for the judge WITHOUT the reference: threshold 5; on test kappa 0.556, false-accept 24/60 = 0.400

Reading the output:

  • A, B. The threshold sweep table on dev and the chosen threshold (5).
  • C. The report on test: false-accept rate 20/60 against the cap of 0.2, and the two borderline groups.
  • D, E. The always-pass baseline (kappa 0) and the release gate: NOT_READY.
  • F. The judge without a reference answer, same procedure: lower kappa, higher false-accept rate.

8.3 Try it yourself

Save it as try_l04.py in the lab's root folder (next to lab/), run python try_l04.py, then delete the file:

from fractions import Fraction
from lab import calibrate as C

c = {"tp": 40, "fp": 10, "fn": 5, "tn": 45}
print(C.raw_agreement(c), C.chance_agreement(c), C.cohens_kappa(c))
skewed = {"tp": 95, "fp": 3, "fn": 2, "tn": 0}
print(C.raw_agreement(skewed), C.false_accept_rate(skewed), C.cohens_kappa(skewed))
print(C.cohens_kappa({"tp": 10, "fp": 0, "fn": 0, "tn": 0}))
rows = [{"threshold": 3, "kappa": Fraction(1, 2), "false_accept": Fraction(1, 2)},
        {"threshold": 4, "kappa": Fraction(3, 5), "false_accept": Fraction(1, 5)},
        {"threshold": 5, "kappa": Fraction(3, 5), "false_accept": Fraction(1, 10)}]
print(C.choose_threshold(rows, Fraction(1, 5)), C.choose_threshold(rows, Fraction(1, 20)))

Output (identical on Python 3.14.6 and 3.12.14):

17/20 1/2 7/10
19/20 1 -3/122
None
5 None

Reading: line 1 is p_o = 17/20, p_e = 1/2, κ = 7/10 as in §4.3; line 2 is the skewed example (agreement 19/20, false accept 1, κ = −3/122); line 3 is kappa undefined (None); line 4: with a cap of 1/5 both threshold 4 and 5 qualify and have the same kappa so the stricter one is chosen (5); with a cap of 1/20 no threshold qualifies (None).

8.4 Run the lesson's tests

python -m pytest tests/test_l04_calibration.py tests/test_data.py -v

Result: 22 passed (17 tests for this lesson, 5 data checks). Read test_kappa_hand_computed, test_high_raw_agreement_with_a_skewed_label_can_hide_a_bad_judge, test_choose_threshold_rules and test_release_gate_fails_closed.

8.5 Troubleshooting

Symptom Cause Fix
TypeError: every score must be an int; drop unreadable outputs first A "ERROR" or "UNKNOWN" score is still present Use pipeline.usable and report the number dropped
choose_threshold returns None No threshold meets the cap A valid result: the judge does not meet the requirement
kappa is None The judge and the human both assign a single label (p_e = 1) Add items of the missing class; if only one side assigns a single label, kappa is 0

9. Independent exercise

Problem: Calibrate a judge on 80 labelled items: choose the threshold under two different false-accept caps, extend kappa to multiple score levels, and write a recommendation.

Requirements: complete exercises/test_l04_calibration.py:

  1. TODO 1: fill in THRESHOLD_CAP_2_5 and THRESHOLD_CAP_1_4: the threshold that choose_threshold picks on all 80 items with a false-accept cap of 2/5 and 1/4 (an integer, or None if no threshold qualifies). This is a drill in the mechanics; in practice you choose on dev, not on all items.
  2. TODO 2: write the function kappa_five_levels(judge_scores, human_scores): Cohen's kappa for two label lists with more than two values (here 1 to 5), returning a Fraction or None if undefined; the two lists must have the same length, other than 0 (otherwise ValueError). Unweighted kappa ignores the order of the scale (confusing 1 with 5 counts the same as confusing 4 with 5); weighted kappa is taught in L2-M05-L02.
  3. TODO 3: write DECISION_NOTE: at least 30 words saying what you would advise the team to do with this judge, using numbers from the evidence.

Test data: exercises/labels.jsonl (80 items: the judge's score, human pass or not, human_score 1 to 5, borderline).

Deliverable: two variables, the function kappa_five_levels and DECISION_NOTE in the file exercises/test_l04_calibration.py itself.

Acceptance criteria: python -m pytest exercises/test_l04_calibration.py passes (4 tests). The test checks the thresholds, and checks kappa on small tables and on the 80 items; for DECISION_NOTE it only counts words, the reasoning is for a reviewer to judge.

Hint: use calibrate.sweep and read the false-accept column before calling choose_threshold. For TODO 2, the two labels are no longer pass or fail: think about how chance agreement is computed when there are five values, and check the function against very small lists you work out by hand.

10. Knowledge check

0/18 done · Results are kept in this browser only.

P02 · True or false

A simulated judge matches the human labels on 96/100 items (tp = 96, fp = 2, fn = 2, tn = 0), so that judge is trustworthy because the agreement of 0.96 is very high.

P04 · Select all that apply

Select every action that leaks the test set (the test is no longer a test).

P05 · Put in order

Put the lab's threshold calibration workflow in order.

  1. Sweep thresholds 1 to 5 on dev to get the confusion matrix for each threshold
  2. Choose the threshold with the highest kappa among the thresholds whose false accept rate does not exceed the cap (or has no cap)
  3. Split dev and test by the hash of the item id, check there is no overlap
  4. Compare with the always-pass baseline and apply the release gate
  5. Report on test, with results for the borderline group

P06 · Match

Match the name of each measure to its meaning.

P07 · Spot the bug

The function below is meant to implement choose_threshold, but has one bug: with a cap of 4/25 and threshold 5 having a false accept rate of exactly 4/25 on dev, it returns None instead of 5. Find the bug.

def choose_threshold(rows, max_false_accept):
    ok = [r for r in rows
          if r["false_accept"] is not None and r["kappa"] is not None
          and r["false_accept"] < max_false_accept]
    if not ok:
        return None
    return max(ok, key=lambda r: (r["kappa"], r["threshold"]))["threshold"]

P08 · Short answer

After a made-up update (lenience = 15), the simulated judge with a reference answer has, on dev, a false accept rate of 19/25 at threshold 4 and 19/50 (0.38) at threshold 5; choose_threshold(rows, Fraction(1, 5)) returns None. What do you report and what do you decide?

P09 · Essay

The HocVui team calibrates a judge for the "safety" criterion on a label set where 97% of answers pass and reports "95% agreement with humans", then plans to turn the judge on to block releases. Write 5-8 sentences: what else do you demand in the calibration report, and why is 95% not enough?

P11 · Recall

Lesson: L2-M04-L03

According to L2-M04-L03, how is leniency bias (the judge lets pass an answer a human failed) mainly handled?

P12 · Recall

Lesson: L2-M02-L03

Two people label independently, and each marks "pass" on 95% of the items. According to L2-M02-L03, what raw agreement is expected when they are completely independent?

P13 · True or false

If both the judge and the human label "pass" on every item, kappa equals 0.

P14 · Multiple choice

A threshold sweep on dev gives three rows (kappa; false accept rate): threshold 3: 0.7; 0.3. Threshold 4: 0.6; 0.1. Threshold 5: 0.5; 0.05. Which threshold does choose_threshold choose with a false accept cap of 0.2?

P15 · Select all that apply

A report gives kappa 0.70 on 103 test items. Select everything that number does not prove.

P16 · Multiple choice

On test, the false accept rate is 6/40 = 0.15 (95% Wilson interval: 0.071 to 0.291), the cap is 0.2. How does the lab's release_gate (which uses the point estimate) treat the false accept criterion, and what else needs to be said?

P17 · Fill in the blank

A lenient simulated judge (lenience = 15) with a reference answer, on dev: thresholds 1 to 3 have a false accept rate of 1, threshold 4 has 19/25 and kappa 108/469, threshold 5 has 19/50 and kappa 558/919. choose_threshold(rows, Fraction(1, 2)) returns ___; choose_threshold(rows, Fraction(1, 5)) returns ___.

P18 · Short answer

On a test set of 100 items where a human passed 70 items, a simulated judge agrees with the human on 78 items. A colleague praises "78% agreement". How do you reply, and which numbers do you need in addition?

11. Summary

  • Concepts: calibration compares a judge with human labels on your data; the positive class is "pass"; false accept and false reject; kappa removes the chance part; the threshold is chosen on dev and reported on test.
  • Skills: split dev and test by hash, choose a threshold under a false-accept cap, report per group with intervals, compare with the always-pass baseline.
  • Traps: trusting raw agreement when labels are skewed; applying a table of words to kappa; choosing the threshold and reporting on the same data; reading a small group as a firm number; forgetting that calibration holds only for the configuration that was measured.
  • You can now: take a figure "the judge agrees X% with humans" and ask: which positive class, which denominator, what kappa and false-accept rate, and the threshold chosen on which set.

12. References

ID Title Publisher URL Accessed Relevance
R1 Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (Zheng et al., 2023) arXiv https://arxiv.org/abs/2306.05685 2026-11-03 Full-text PDF; §4.1, §4.2, Table 5, Appendix D.3
R2 Judging the Judges: Evaluating Alignment and Vulnerabilities in LLMs-as-Judges (Thakur et al., 2024) arXiv https://arxiv.org/abs/2406.12624 2026-11-03 Full-text PDF; read the abstract, the part on measuring agreement, Appendix B
R3 Interrater reliability: the kappa statistic (McHugh, 2012) Biochemia Medica (PMC) https://pmc.ncbi.nlm.nih.gov/articles/PMC3900052/ 2026-11-03 Whole page: definition of kappa, range of values, interpretation
R4 Evaluation best practices OpenAI https://developers.openai.com/api/docs/guides/evaluation-best-practices 2026-11-03 Whole page; the LLM-as-a-judge section
R5 Demystifying evals for AI agents Anthropic https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents 2026-11-03 Whole page; calibrating a judge against experts

Key terms (English ↔ Vietnamese)

English Tiếng Việt
Calibration (of a judge) Hiệu chuẩn judge bằng nhãn người
Cohen's kappa Hệ số kappa của Cohen (đồng thuận đã trừ phần ngẫu nhiên)
Chance agreement (p_e) Độ đồng thuận ngẫu nhiên
False-accept rate / false-reject rate Tỷ lệ lọt / tỷ lệ oan
Dev set / test set Tập dev (để chỉnh) / tập test (để báo cáo)
Release gate Cổng phát hành (quy tắc n, lọt, kappa)