Area 04 · Evals · Concept 03 of 20

LLM as a Judge

A strong model with a clear rubric grades outputs, so you can score thousands of them.

01–10 · The basePhase 4 · Weeks 15–17≈ 1.5 hours

The idea

Many outputs cannot be checked with exact match: summaries, explanations, support replies. An LLM judge reads the input, the output (and the reference or sources if you have them) and a rubric, and returns a verdict with a short reason.

Make judges narrow: one judge per criterion with a binary or small-scale answer works better than one judge scoring "quality" 1–10. Ask for the reasoning before the verdict, use temperature 0, and require structured output.

A judge is itself a model that can be wrong. Validate it against human labels (aim for high agreement on a sample) before trusting its numbers.

Why it matters

Judges make evaluation scale from 30 hand-read cases to thousands of automated ones.

Picture it

Words to know

  • RubricWritten criteria the judge applies.
  • Agreement rateHow often the judge matches human labels.

Try it without code

Judge by hand

  1. Write a 3-line rubric for "answers the question asked".
  2. Paste a question, an answer and the rubric into a chat app.
  3. Ask for reasoning then PASS or FAIL.

Use it in code

A binary judge with structured output.

python
import json, anthropic
client = anthropic.Anthropic()

RUBRIC = """PASS if the answer directly addresses the user's question and gives a usable answer.
FAIL if it answers a different question, is evasive, or only partly answers."""

def judge(question, answer):
    msg = client.messages.create(model="claude-sonnet-5-5", max_tokens=300, temperature=0,
        messages=[{"role": "user", "content":
            f"<rubric>{RUBRIC}</rubric>\n<question>{question}</question>\n<answer>{answer}</answer>\n"
            'Return JSON only: {"reason": "...", "verdict": "PASS" or "FAIL"}'}])
    return json.loads(msg.content[0].text)

print(judge("How long do refunds take?", "Refunds are processed within 5 business days."))
PRACTICE · TICK IT AFTER THIS

Hand-label 30 outputs, run your judge on them, and compute agreement. Adjust the rubric until agreement is above 85%.

Common mistakes

  • Using the same model to generate and judge without checking bias.
  • 1–10 scales with no anchors.
  • Never validating the judge.

Go deeper