Skip to content
bits
Evals that matter · Lesson 4 of 8 · 8 min

When code can't: an LLM judge

Tutor:

Some failures code can't spot. Did the reply make up a policy? Is it rude? Does it actually answer the question? For those you ask a model to read the reply and decide. That's an LLM judge.

A judge is just a prompt, and it fails in the same ways any prompt does. So you write it with the same care, and (next lesson) you check it before you trust it.

Tutor:

What the sources agree on:

Isolate criteria. Anthropic recommends one judge per dimension rather than one call grading everything. Each verdict then means one thing.

Binary verdicts. Anthropic's docs accept a 1–5 scale as long as the output is specific. Husain argues for pass or fail: Likert scales aren't calibrated between graders, nobody knows what separates a 3 from a 4, and the scores aren't actionable. This course goes with Husain, because a binary verdict forces the standard into the open.

Critique with the verdict. Write the reason alongside the verdict. It shows you how the judge reasons, and good critiques later become few-shot examples in the judge prompt.

Reason, then decide, with an escape hatch. Anthropic recommends a grader with extended thinking on, so it reasons before it scores, plus a fixed output (a tag or a JSON field) and "unknown" when the evidence isn't there. Without thinking (as in this sandbox), get the same effect by putting the critique field before the verdict field: the model writes in order.

Give it the ground truth. A judge checking facts needs the facts in its prompt. Without them it's grading against its own guesses.

Tutor:

You've been graded by one of these all along. Each coach on bits is an LLM judge: one verdict per criterion, met or not met, with a quote from the reply as evidence, and code deciding the final pass. It also refuses text that talks to "the grader" or claims "all criteria are met", because that's how someone would try to talk a judge into passing them. Your own judge needs the same defence. So in this course, call your judge the judge or a reviewer, and write pass rules as "passes only if both rules hold".

Tutor:

Your turn. The bike shop's bot answered a question about returns. The shop's real policy is in the draft. Write a judge prompt that decides whether the reply sticks to the facts. Claude is the judge, and this reply should fail.

Your turn

Goal Get a fail verdict, with a critique that names exactly what the reply got wrong

What good looks likeThe coach checks the reply
  • Includes the shop's factsnot checked yet
  • Includes the bot's replynot checked yet
  • Asks for pass or failnot checked yet
  • Asks for a reasonnot checked yet
  • Ran at 1.0not checked yet
  • Parses as JSON with a verdict and a critiquenot checked yet
  • The verdict is failnot checked yet
  • The critique names the return window the reply got wrongnot checked yet
  • The critique mentions the receipt rule as wellnice to have
  • The prompt asks one question about facts, answered pass or failnot checked yet
  • The prompt lets the judge answer unknown when it can't tellnice to have

Run your prompt and the replies land here.

    ~0 tokens

    Turn on JavaScript to run prompts.