Lesson 5.3 · 8 min read · about 55 min to master at a very slow pace
LLM-as-a-Judge
Using one LLM to grade another's output against a rubric: when it works, the biases to control (position, length, self-preference), how to validate a judge against human labels, and how to write a judge prompt that gives reliable scores.
Why a judge
Many outputs have no single correct string: summaries, explanations, emails. Exact-match scoring fails and human grading does not scale to every change. An LLM judge reads the input, the output and a rubric, and returns a verdict. It costs a fraction of human review and runs in minutes.
Write the judge like a test, not a vibe
- One criterion per judge: "Is every claim supported by the sources?" is gradeable. "Is this a good answer?" is not.
- Binary or small scales: pass/fail, or 1–3 with each level defined. A 1–10 scale gives noisy, uncalibrated numbers.
- Ask for the reasoning first, then the verdict, in structured output. The reasoning helps the judge and helps you audit it.
- Give the judge what it needs: the sources, the reference answer if you have one.
Criterion: FAITHFULNESS
Given the SOURCES and the ANSWER, check each factual claim.
A claim passes if a source states or directly implies it.
Return JSON: {"unsupported_claims": [...], "verdict": "pass" | "fail"}
verdict is "fail" if any claim is unsupported.
Known biases
| Bias | What happens | Control |
|---|---|---|
| Position | In A-versus-B comparisons, prefers the first (or second) answer | Judge both orders; count only consistent wins |
| Length | Prefers longer, more detailed answers | Rubric that rewards correctness and concision explicitly |
| Self-preference | Rates outputs from its own model family higher | Use a different model as judge where possible |
| Leniency | Passes answers that sound confident | Binary, evidence-based criteria; require quotes |
Validate the judge against humans
A judge is a model too, so evaluate it. Have a person label 50–100 outputs, run the judge on the same ones, and compare.
Worked example
On 100 answers, a human marks 20 as fail. The judge flags 18 answers as fail, of which 15 are among the human's 20.
- Agreement: (both fail) (both pass: ) .
- Of the real failures, the judge catches (its recall on failures).
- Of the judge's fail flags, are right (its precision).
92% agreement looks fine, but the judge misses a quarter of real failures. Improve the rubric on the 5 missed cases, then measure again.
Agreement can mislead
If 95% of answers pass, a judge that always says "pass" agrees 95% of the time and catches nothing. Always look at how many real failures it catches.
Stuck? Common doubts
Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.
First passCan I use the same model as judge and generator?
You can, and it often works for clear, evidence-based checks. For subjective quality and A-versus-B comparisons, self-preference matters more, so a different model family is safer. Either way, validating against human labels tells you whether it works.
Going deeperIsn't a judge as unreliable as the thing it is judging?
Checking is easier than generating: verifying that a claim appears in a given source is a narrower task than writing a good answer. That's why a judge with a specific rubric can be more reliable than the generator. But you only know that after measuring agreement with humans.
Cheatsheet
Judge prompt rules
Judge biases
Agreement is not enough
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.