LLM-as-Judge with Claude: Calibrate Against Human Labels
👋 In plain words: Some outputs cannot be checked with a simple rule: is this test plan complete? Is this bug summary accurate? An LLM-as-judge uses Claude to grade them against a rubric. But a judge is only trustworthy if it agrees with careful human reviewers, so this lesson shows how to measure and improve that agreement, step by step.
The CCDV-F exam specifically names “LLM-as-judge harnesses calibrated against human-labeled data”. In this lesson you will write a rubric, build a judge that returns structured verdicts, collect a small set of human labels, measure agreement and Cohen’s kappa between the judge and the humans, find where they disagree, revise the rubric to close the gap, and learn the biases to guard against.
🔑 Key terms
- LLM-as-judge: using a model to grade outputs against a rubric.
- Rubric: explicit criteria and score definitions the judge applies.
- Calibration: checking and improving how well the judge matches trusted human labels.
- Agreement: the share of items where judge and humans give the same grade.
- Cohen’s kappa: agreement corrected for the agreement you would expect by chance; 1 is perfect, 0 is chance level.
🪜 Step 1: Write a rubric
The judge grades generated bug summaries. Vague rubrics (“is it good?”) give vague grades. Define each criterion and what pass means:
📄 rubric.txt
Grade the bug summary against the original report.
PASS only if ALL are true:
1. Accurate: every fact in the summary appears in the report (no invented details).
2. Complete: it includes the affected feature, the observed behaviour and the expected behaviour.
3. Actionable: a developer could start reproducing from it.
Otherwise FAIL. Give a one-sentence reason naming the first criterion that fails.
🪜 Step 2: Build the judge with structured output
Return a verdict and a reason in a fixed shape (Lesson 22), so grades are easy to aggregate:
📄 judge.py
import anthropic
from pydantic import BaseModel
from typing import Literal
client = anthropic.Anthropic()
RUBRIC = open("rubric.txt").read()
class Verdict(BaseModel):
verdict: Literal["PASS", "FAIL"]
reason: str
def judge(report: str, summary: str) -> Verdict:
r = client.messages.parse(
model="claude-opus-5-5", max_tokens=300, output_format=Verdict,
system=RUBRIC,
messages=[{"role": "user", "content": f"<report>{report}</report>\n<summary>{summary}</summary>"}],
)
return r.parsed_output
🪜 Step 3: Collect human labels
Ask two people to grade the same items independently with the same rubric, and resolve disagreements between them first. Their agreed labels are the reference:
📄 labelled.py
ITEMS = [
{"id": 1, "report": "Checkout total ignores the 10% coupon; expected 90, got 100.", "summary": "Coupon not applied at checkout: total 100 instead of 90.", "human": "PASS"},
{"id": 2, "report": "Login button does nothing on Safari 17; works on Chrome.", "summary": "Login button broken in all browsers.", "human": "FAIL"},
{"id": 3, "report": "Export CSV is empty when the table has 0 rows.", "summary": "Empty export for empty tables.", "human": "FAIL"},
{"id": 4, "report": "Search shows results from other users' private projects.", "summary": "Search leaks other users' private projects in results.", "human": "PASS"},
{"id": 5, "report": "Upload of 20 MB PDF times out after 30 s; expected success.", "summary": "Large PDF upload (20 MB) times out at 30 s instead of succeeding.", "human": "PASS"},
{"id": 6, "report": "Password reset email arrives after 15 minutes.", "summary": "Reset email delayed; link also expired, crashing the app.", "human": "FAIL"},
]
🪜 Step 4: Measure agreement and kappa
📄 calibrate.py
from judge import judge
from labelled import ITEMS
def cohen_kappa(a: list[str], b: list[str]) -> float:
labels = sorted(set(a) | set(b))
n = len(a)
observed = sum(x == y for x, y in zip(a, b)) / n
expected = sum((a.count(l) / n) * (b.count(l) / n) for l in labels)
return (observed - expected) / (1 - expected) if expected < 1 else 1.0
judged = [judge(i["report"], i["summary"]) for i in ITEMS]
human = [i["human"] for i in ITEMS]
model = [j.verdict for j in judged]
print(f"agreement: {sum(h == m for h, m in zip(human, model))}/{len(ITEMS)}")
print(f"kappa : {cohen_kappa(human, model):.2f}")
for item, j in zip(ITEMS, judged):
if j.verdict != item["human"]:
print(f" disagree on #{item['id']}: human={item['human']} judge={j.verdict} ({j.reason})")⌨️ Terminal
python calibrate.py🖥️ Output (sample run)
agreement: 5/6
kappa : 0.67
disagree on #3: human=FAIL judge=PASS (Short but accurate.)
The judge agrees on 5 of 6 items. The disagreement is informative: the judge passed “Empty export for empty tables” as “short but accurate”, while humans failed it because it never states the expected behaviour. The rubric’s word “complete” was not specific enough.
🪜 Step 5: Revise the rubric and re-measure
Close the gap by making the criterion explicit, then re-run the same items:
📄 rubric_v2.txt
Grade the bug summary against the original report.
PASS only if ALL are true:
1. Accurate: every fact in the summary appears in the report (no invented details).
2. Complete: the expected behaviour must be stated, along with the affected feature and the observed behaviour.
3. Actionable: a developer could start reproducing from it.
Otherwise FAIL. Give a one-sentence reason naming the first criterion that fails.
📄 calibrate_v2.py
import shutil
shutil.copy("rubric_v2.txt", "rubric.txt") # the judge reads rubric.txt
from judge import judge # noqa: E402
from labelled import ITEMS # noqa: E402
model = [judge(i["report"], i["summary"]).verdict for i in ITEMS]
human = [i["human"] for i in ITEMS]
print(f"agreement after revision: {sum(h == m for h, m in zip(human, model))}/{len(ITEMS)}")⌨️ Terminal
python calibrate_v2.py🖥️ Output (sample run)
agreement after revision: 6/6
In practice, calibrate on a few dozen to a few hundred labelled items, keep a held-out set to confirm the revised rubric, and re-check calibration whenever you change the judge model, the rubric or the kind of outputs being graded.
🪜 Step 6: Guard against judge bias
| Bias | What happens | Mitigation |
|---|---|---|
| Verbosity | Longer answers get better grades | Rubric criteria about correctness, not length; length-matched examples |
| Position | In pairwise comparisons, the first (or second) option wins more | Randomise order; grade both orders |
| Self-preference | The judge favours outputs like its own | Different model or configuration; human spot checks |
| Leniency drift | Grades get softer on unusual outputs | Fixed rubric, examples of FAIL, periodic re-calibration |
| Vague criteria | Inconsistent grades | Binary criteria with explicit definitions |
🌍 Real-world example: Ravi’s judge
Ravi used a Claude judge to grade generated test cases for “covers the requirement”. On 80 human-labelled cases, the first judge agreed only 70% of the time: it passed suites that tested the happy path well but skipped negative cases. After adding “at least one negative case per rule” to the rubric and two FAIL examples, agreement reached 93% (kappa 0.85), and the judge became part of the release gate, with a weekly human spot check of 10 items.
🧪 Practice Questions
Question 1. A team uses a Claude judge to gate releases but has never compared its grades with human reviewers. What should they do first?
- A. Switch to a larger judge model
- B. Collect human labels on a sample, measure agreement and kappa, and revise the rubric where they disagree
- C. Increase the pass threshold
- D. Use temperature 0 for the judge
Show answer
Answer: B. Without calibration against trusted labels, you do not know whether the judge’s grades mean anything.
Question 2. Two raters agree on 90% of items, but almost all items are PASS. Why might Cohen’s kappa still be low?
- A. Kappa corrects for chance agreement, which is high when one label dominates
- B. Kappa ignores agreement
- C. Kappa only works for numeric scores
- D. Kappa requires three raters
Show answer
Answer: A. When one class dominates, raters agree often by chance. Kappa measures agreement beyond that.
Question 3. Which two changes reduce verbosity bias in a judge? (Choose 2.)
- A. Criteria focused on correctness and completeness rather than detail or length
- B. Instructing the judge to prefer longer answers
- C. Including examples where a short answer passes and a long one fails
- D. Removing the rubric
Show answer
Answer: A and C. Explicit criteria and counter-examples keep length from driving grades.
Question 4. The judge and humans disagree mostly on whether summaries state the expected behaviour. What is the best fix?
- A. Remove those items from the eval
- B. Make that requirement explicit in the rubric, then re-measure agreement on held-out items
- C. Replace human labels with the judge’s labels
- D. Lower the agreement target
Show answer
Answer: B. Disagreements point to an under-specified criterion; fixing the rubric and re-measuring closes the gap honestly.
📝 Assignment
- Task 1: Write a binary rubric for one output your team produces (test plans, bug summaries, release notes).
✅ Done when: each criterion has a clear pass definition. - Task 2: Label 20 items yourself (and ideally with a colleague), run the judge with your key and compute agreement and kappa.
✅ Done when: you have both numbers and a list of disagreements. - Stretch: Run the judge twice on each item with the summaries in different orders inside a pairwise comparison, and measure position bias.
✅ Done when: you can say how often the verdict flips with order.
❓ Frequently Asked Questions
🤔 What is LLM-as-judge?
Using a language model to grade outputs against a rubric, for qualities that simple rules cannot check.
🤔 How do I know if my LLM judge is reliable?
Compare its grades with trusted human labels on a sample: report agreement and Cohen’s kappa, inspect disagreements, and re-check after changes.
🤔 What is a good Cohen’s kappa for an LLM judge?
It depends on the stakes. Values above about 0.8 are commonly treated as strong agreement; for a release gate, also look at the specific disagreements.
🤔 Should the judge use the same model as the generator?
Preferably not the identical configuration. A different model or setting reduces shared blind spots; human spot checks help in either case.
🏁 Summary
- Write binary, explicit rubric criteria; return structured verdicts with reasons.
- Calibrate against human labels: agreement plus Cohen’s kappa.
- Use disagreements to sharpen the rubric, then re-measure on held-out items.
- Guard against verbosity, position and self-preference bias.
- Re-calibrate when the judge, rubric or output type changes.
Next, continue with Pytest for Claude Apps: Mocking Claude API Responses.
Independent study material by SQA Tools. Not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic. Practice questions are original, not real exam content. Code outputs marked “sample run” come from running the exact code against a local stand-in for the Claude API, so real replies, IDs and token counts will differ. Exam facts checked against Anthropic’s official CCDV-F exam guide v1.1 on 24 Nov 2026.