Education › Evals & Harness › Stage 1: Evaluation foundations

LLM-as-judge, done properly

Rubrics, pairwise vs pointwise, judge biases, and calibrating judges against humans.

Intermediate ~35 min read Module 4 of 20

Many qualities that matter, such as whether an answer is faithful to the sources, complete, polite, or actually helpful, cannot be checked with string matching. The common solution is an LLM-as-judge: a model that grades outputs against a rubric. Judges scale where humans cannot, but an uncalibrated judge is just a confident random number generator. This lesson covers when to use a judge, pointwise versus pairwise judging, writing rubrics that produce consistent verdicts, the known biases of judges, and the calibration process that tells you whether to trust one.

After this module you can
  • Decide when a judge is appropriate and when code or humans are better
  • Choose between pointwise, pairwise and reference-based judging
  • Write rubrics that produce consistent, explainable verdicts
  • Detect and mitigate position, verbosity and self-preference biases
  • Calibrate a judge against human labels and monitor it over time

When to use a judge

Use code first: if a check can be written as a rule (valid JSON, contains the order ID, called the refund tool), a rule is cheaper, faster and perfectly consistent. Use humans for ground truth and for high-stakes decisions. Use a judge for the large middle: qualities that need reading comprehension, applied to more outputs than humans can review.

StyleHow it worksBest for
PointwiseGrade one output against a rubric (pass/fail or a small scale)Tracking a metric over time
PairwiseShow outputs A and B, ask which is betterComparing two versions; more sensitive
Reference-basedCompare the output to a known good answerFactual questions with a target
Reference-freeJudge against the rubric and sources onlyOpen-ended tasks without one right answer

Rubrics that produce consistent verdicts

Vague rubrics ("rate helpfulness from 1 to 10") produce vague, unstable scores. Good rubrics break quality into specific, mostly binary criteria, define each with an example, and ask the judge to reason before deciding. Binary or three-level scales are far more consistent than ten-point scales.

A faithfulness judge prompt
text
You are grading an answer from a customer-support assistant.

SOURCES:
{sources}

QUESTION:
{question}

ANSWER:
{answer}

Check each criterion:
1. Every factual claim in the ANSWER is supported by the SOURCES.
2. The ANSWER does not contradict the SOURCES.
3. If the SOURCES do not contain the answer, the ANSWER says so instead of guessing.

First write one sentence of reasoning per criterion.
Then output exactly one line: VERDICT: PASS or VERDICT: FAIL
(PASS only if all three criteria hold.)
Calling the judge and parsing a strict verdict
python
import re


def judge_faithfulness(sources: str, question: str, answer: str) -> tuple[bool, str]:
    prompt = JUDGE_TEMPLATE.format(sources=sources, question=question, answer=answer)
    out = call_llm(prompt, temperature=0)
    m = re.search(r"VERDICT:\s*(PASS|FAIL)", out)
    if not m:
        return False, "unparseable verdict: " + out[-200:]   # count as failure, investigate
    return m.group(1) == "PASS", out

Known judge biases

  • Position bias: in pairwise judging, preferring whichever answer is shown first (or second). Mitigation: judge both orders and count a win only if it holds in both.
  • Verbosity bias: preferring longer, more detailed answers even when they are worse. Mitigation: rubric criteria about concision and relevance; compare at similar lengths.
  • Self-preference: favouring outputs from the same model family as the judge. Mitigation: use a different family as judge where possible, and check against human labels.
  • Leniency: passing almost everything. Mitigation: binary criteria, explicit fail examples, calibration.
  • Format sensitivity: verdicts change with markdown, ordering or whitespace. Mitigation: normalise outputs before judging.

Pairwise judging in both orders

Pairwise judging asks a simpler question than pointwise grading (which of these two is better?), so it detects smaller differences between versions. The price is position bias. Run every comparison twice with the answers swapped, and count a win only when both orders agree; a disagreement is recorded as a tie. The share of flipped verdicts is itself a useful health metric for the judge: if it is high, the rubric is too vague for the judge to apply.

A position-debiased pairwise comparison
python
def pairwise(question: str, a: str, b: str) -> str:
    first = call_llm(PAIR_TEMPLATE.format(q=question, x=a, y=b), temperature=0)
    second = call_llm(PAIR_TEMPLATE.format(q=question, x=b, y=a), temperature=0)
    win1 = "A" if "WINNER: X" in first else "B"
    win2 = "B" if "WINNER: X" in second else "A"
    return win1 if win1 == win2 else "tie"   # order-dependent verdicts count as ties

Calibrating a judge

A judge is an instrument, and instruments need calibration. Have humans label a sample of outputs (100 is a good start, covering passes, fails and borderline cases), run the judge on the same outputs, and compare. Look at overall agreement and, more importantly, at where they disagree: false passes are usually more dangerous than false fails.

labelsgood kappaverdictsfix rubricOutput samplepass, fail, edgeHuman labelsCompareagreement, kappaFreeze + monitorspot checksJudge modelrubric prompt
Calibrate a judge before trusting it: humans and the judge grade the same sample, agreement and kappa decide whether to fix the rubric or freeze the judge.
Agreement and Cohen's kappa between human and judge labels
python
def agreement(human: list[bool], judge: list[bool]) -> dict:
    n = len(human)
    agree = sum(h == j for h, j in zip(human, judge)) / n
    ph, pj = sum(human) / n, sum(judge) / n
    expected = ph * pj + (1 - ph) * (1 - pj)          # agreement by chance
    kappa = (agree - expected) / (1 - expected) if expected < 1 else 1.0
    false_pass = sum((not h) and j for h, j in zip(human, judge))
    return {"agreement": agree, "kappa": kappa, "false_passes": false_pass}

Cohen's kappa corrects raw agreement for chance: with a 90% pass rate, two raters who both say PASS to everything agree 90% of the time but have a kappa of 0. As a rough guide, kappa above about 0.6 is substantial agreement and above 0.8 is strong. Iterate on the rubric until agreement is good, then freeze the judge prompt and model version. Re-run the calibration whenever you change either, because a judge upgrade silently changes every score you report.

Using judges responsibly

Keep a human in the loop on a small, regular sample even after calibration, and route disagreements and low-confidence verdicts to review. Report judge-based scores with the judge version and its measured agreement, so readers know how much to trust them. Remember cost: a judge call per output can double the cost of an eval, so reserve judges for criteria code cannot check, and cache verdicts for unchanged outputs.

Hands-on practice

Build and calibrate a faithfulness judge

  1. Collect 60 question, sources and answer triples from any RAG system (or write them), including some answers that invent facts.
  2. Label each PASS or FAIL yourself against the three criteria above; ask a friend to label 20 as well and compare.
  3. Implement the judge prompt and parser with any model you have access to.
  4. Run it on all 60 and compute agreement, kappa and false passes against your labels.
  5. Read every disagreement, improve the rubric, and re-run; record before and after kappa.
  6. Run a pairwise comparison of two answer styles in both orders and measure how often the verdict flips.
Cheat sheet

LLM-as-judge, done properly — at a glance

Main things to focus on

  • Code checks first, judges for comprehension-level qualities, humans for ground truth.
  • Binary criteria with reasoning beat 1-10 scales.
  • Pairwise judging is more sensitive; always judge both orders.
  • Calibrate against human labels; watch false passes.
  • Freeze judge prompt and model version; recalibrate on change.
  • Report judge scores with version and measured agreement.

Judge styles

pointwise: PASS/FAIL per rubricTrack a metric
pairwise: A vs B, both ordersCompare versions
reference-basedCompare to a known answer
reference-freeRubric and sources only
flip rate (swapped order)Judge health metric

Rubric rules

specific, mostly binary criteriaConsistency
reason first, verdict lastBetter and explainable
strict output format: VERDICT: PASS|FAILReliable parsing
temperature 0Reduce variance

Biases

positionSwap order, require agreement
verbosityConcision criterion
self-preferenceDifferent judge family, human checks
leniencyFail examples, calibration

Calibration

agreement = matches / nRaw agreement
kappa = (po - pe) / (1 - pe)Chance-corrected agreement
false passesMost dangerous error
recalibrate on judge changeScores shift silently

Common pitfalls

  • Using a judge for something a regular expression could check.
  • Ten-point scales with no anchors.
  • Pairwise judging in one order only.
  • Trusting a judge never compared with human labels.
  • Upgrading the judge model and comparing scores across the change.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →