Evaluating AI systemsMiddleLesson 2217 min read

LLM as a judge

A language model can grade other models' answers quickly and cheaply, if you give it a clear rubric, check it for known biases and compare it with human judgement.

Lesson in motion

In 60 seconds

LLM as a judge

A language model can grade other models' answers quickly and cheaply, if you give it a clear rubric, check it for known biases and compare it with human judgement.

1/4
In simple words
Imagine a teacher who can mark a thousand answer sheets in a minute. Very useful! But what if she always gives more marks to longer answers, or to the sheet on top of the pile? Before you trust her marks, you would check them against a careful human teacher.
Many AI outputs cannot be checked with a simple rule: summaries, explanations, advice, translations. Having humans grade everything is slow and costly. LLM-as-a-judge means asking a language model to grade outputs using written instructions. It scales well, but it is a measuring tool that must itself be measured.

Two common set-ups

Set-upHow it worksGood for
Single-answer gradingThe judge reads one answer and gives a score or pass/fail against a rubric.Tracking quality over time; checking must-have points
Pairwise comparisonThe judge sees two answers to the same input and picks the better one, or a tie.Comparing two models or two prompts

Write a rubric, not a vibe

"Rate this answer from 1 to 10" gives noisy, hard-to-explain scores. A rubric breaks quality into specific questions with clear levels. Yes/no checks are often more reliable than wide number scales.
A rubric for a crop-insurance help bot (given to the judge)text
You are grading an answer to a farmer's question about crop insurance.
Use ONLY the reference facts below. Answer each check with YES or NO,
then give a one-line reason for each.

1. CORRECT: Every deadline, amount and document mentioned matches the reference facts.
2. COMPLETE: The answer includes the must-include points listed.
3. NO_INVENTION: The answer does not state any scheme, number or rule
   that is missing from the reference facts.
4. LANGUAGE: The answer is in the same language as the question.
5. CLEAR: A farmer with basic reading skills could follow it.

Return JSON: {"CORRECT": "YES|NO", "COMPLETE": ..., "NO_INVENTION": ...,
"LANGUAGE": ..., "CLEAR": ..., "reasons": [...]}

Known biases

BiasWhat happensWhat to do
Position biasIn pairwise tests, the judge tends to favour the answer shown first (or second).Run each pair twice with the order swapped. Count a win only if the judge agrees in both orders; otherwise call it a tie.
Length biasLonger, more detailed-looking answers get higher marks even when they are not better.Tell the judge not to reward length; include short correct answers in calibration; check whether scores rise with length.
Self-preferenceA judge may rate answers from its own model family more highly.Where possible, use a judge from a different family than the models being compared, and check against humans.
Style over substanceConfident tone and nice formatting can hide wrong facts.Give the judge reference facts and make correctness its own yes/no check.
Python: pairwise judging with the order swappedpython
def call_model(prompt: str) -> str:
    ...  # plug in your provider; return the judge's text reply

JUDGE = """Question: {q}
Answer A: {a}
Answer B: {b}
Which answer is more correct and helpful? Ignore length and style.
Reply with exactly one of: A, B, TIE"""

def judge_once(q, first, second):
    reply = call_model(JUDGE.format(q=q, a=first, b=second)).strip().upper()
    return reply if reply in {"A", "B", "TIE"} else "TIE"

def compare(q, ans_x, ans_y):
    r1 = judge_once(q, ans_x, ans_y)   # x shown as A
    r2 = judge_once(q, ans_y, ans_x)   # x shown as B
    if r1 == "A" and r2 == "B":
        return "X"
    if r1 == "B" and r2 == "A":
        return "Y"
    return "TIE"                       # judge changed its mind: no clear winner

Calibrate against humans

  1. 1

    Label a sample by hand

    Have people grade a sample of outputs with the same rubric.
  2. 2

    Run the judge on the same sample

    Use the exact prompt and settings you will use later.
  3. 3

    Compare

    Measure agreement (for example, Cohen's kappa from Lesson 6) and read the disagreements.
  4. 4

    Fix the rubric

    Most disagreements come from unclear wording. Tighten it and repeat.
  5. 5

    Re-check regularly

    Re-calibrate when you change the judge model, the rubric or the task.
Watch out
Do not use an LLM judge as the only check for high-stakes content such as medical, legal or financial answers. Use it to screen and prioritise, and keep expert humans in the loop for the final call.
Try this. Take one question and two answers, one short and correct, one long and slightly wrong. Ask a chatbot which is better, then swap the order and ask again. Did it stay consistent?

Watch and read more

Lab

A judge rubric, calibrated against your own grades on 10 answers.

~45 min

The problem

  1. Take 10 items from your test set (Lesson 4). For each, collect one answer from any chatbot you are allowed to use.
  2. Write a rubric with 3–5 yes/no checks, like the example in this lesson.
  3. Grade all 10 answers yourself with the rubric. Hide your grades.
  4. Give the rubric, the reference facts and each answer to an LLM (by hand in a chat window, or with the starter script and your own provider function).
  5. Count how often you and the judge agreed on each check. Read every disagreement and rewrite the unclear parts of the rubric.

Practice lab

Edit the code and run it. Python runs in your browser — nothing is sent to our server.

Output

No output. Add print(...) to see values.

You are done when

Hard questions

Try to answer before you reveal. If you can answer these, you understood the lesson.

Q1Your judge agrees with you 95% of the time on CORRECT, but your test set is 95% correct answers. Is the judge good?Reveal

You cannot tell yet. A judge that always says YES would also agree 95% of the time. Raw agreement is misleading when one label is very common. Look at how the judge does on the few wrong answers, and use a chance-corrected measure such as Cohen's kappa (Lesson 6).

Q2When is an LLM judge a poor choice even after calibration?Reveal

When mistakes are very costly and the judge cannot check facts reliably, for example dosage advice or legal deadlines without clear references; when the content is in a language or domain where the judge itself is weak; and when the outputs being graded came from the same model family as the judge, so shared blind spots go unnoticed. In these cases use expert human review, perhaps with the judge only as a first filter.

Please sign in to continue.

Questions people ask

Why not just use a bigger model as the judge and trust it?

A stronger judge often helps, but the known biases do not disappear on their own, and the judge does not know your domain rules unless you give them. You only know how much to trust it after comparing it with human labels on your own data.

Should the judge see a reference answer?

When you have one, usually yes. Grading against reference facts is more reliable than asking the judge to decide what is true from its own knowledge. Without references, the judge can reward confident mistakes.

Should the judge explain its reasoning?

Asking for a short reason for each check helps you debug disagreements and makes the grade easier to audit. Ask for the reasons in a fixed format, and read a sample of them.

Will the judge give the same grade every time?

Not always. Model outputs can vary between runs. Use settings that reduce randomness where your provider supports them, run important comparisons more than once, and look at the rate of changes between runs.

Lesson test

5 questions. Get 3 right (60%) to pass and complete this lesson.

Sign in to take the test and save your progress