Sub topic 8
Check labeling quality with annotator agreement
This chapter assumes you can read JSONL, write basic Python, and know what a proportion and a sample size are. You should also have a labeled dataset, or the start of one, from the earlier chapter on reference answers and rubrics.
Why agreement matters
A label is only useful if another careful person would give the same one. If two annotators disagree on a third of your cases, the rubric is unclear or the task is subjective. Your eval score then measures the noise in the labels, not the quality of the app.
Agreement also sets a ceiling. An app cannot reliably score higher than the humans who wrote the labels agree with each other.
Raw agreement is not enough
The simplest measure is the share of cases where two annotators gave the same label. It is misleading when one label dominates. If 95% of cases are "pass", two annotators who label at random in that proportion will still agree about 90% of the time.
Cohen's kappa corrects for this. It compares observed agreement with the agreement expected by chance, given how often each annotator uses each label.
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)A kappa of 1 means perfect agreement. A kappa of 0 means no better than chance. Negative values mean worse than chance.
A worked example
Two annotators label ten answers as pass or fail.
ann_a = ["pass", "pass", "pass", "fail", "pass", "pass", "fail", "pass", "pass", "pass"]
ann_b = ["pass", "pass", "fail", "fail", "pass", "pass", "pass", "pass", "pass", "pass"]
print(round(cohens_kappa(ann_a, ann_b), 2))They agree on 8 of 10 cases, so observed agreement is 0.80. Annotator A says pass 80% of the time and B says pass 80% of the time. Chance agreement is 0.8 × 0.8 + 0.2 × 0.2 = 0.68. Kappa is (0.80 − 0.68) / (1 − 0.68) = 0.375. The raw 80% looked good, but kappa shows much of it came from the skewed labels.
Reading the number
Common rough guidance treats kappa below 0.4 as weak, 0.4 to 0.6 as moderate, 0.6 to 0.8 as substantial, and above 0.8 as strong. These bands are conventions, not laws. A small sample makes kappa unstable, so use at least a few dozen doubly labeled cases.
| Kappa | Typical meaning | Usual action |
|---|---|---|
| Below 0.4 | Labels are unreliable | Rewrite the rubric before labeling more |
| 0.4 to 0.6 | Moderate | Review disagreements, tighten wording |
| 0.6 and above | Usable | Proceed, keep spot checks |
Improve agreement
Follow these steps:
- Pick a random sample of 30 to 50 cases and have two people label them independently, without talking.
- Compute kappa overall and for each slice. A good overall number can hide a weak slice.
- Read every disagreement. Most come from a vague rubric line or a missing edge-case rule.
- Add a rule or a worked example to the rubric, then relabel a fresh sample.
- Resolve remaining disagreements by discussion or a third reviewer, and record the final label.
Common errors
- Letting annotators see each other's labels, which inflates agreement.
- Reporting raw agreement on an imbalanced dataset.
- Computing kappa on too few cases and trusting it.
- Treating low agreement as annotator error when the task itself is ambiguous. In that case, change the task definition or accept a range of valid answers.
Exercise
Two annotators agree on 90% of cases. Annotator A labels 95% of cases "pass" and B labels 95% "pass". Compute chance agreement and kappa. What does the result tell you?
Show answer
Chance agreement is 0.95 × 0.95 + 0.05 × 0.05 = 0.905. Observed agreement is 0.90, so kappa is (0.90 − 0.905) / (1 − 0.905), about −0.05. Despite 90% raw agreement, the annotators agree no better than chance, so the labels are not reliable, especially for the rare "fail" class.