All posts
Fundamentals

LLM-as-a-judge, grading agents with a model

You have a dataset and rubrics. Grading every run against those rubrics by hand works for ten cases and collapses at a thousand.

The scalable answer is to use a model as the grader: LLM-as-a-judge. A judge model reads a response and scores it against your rubric, so evaluation runs at the scale of your dataset instead of the scale of your patience.

Three ways a judge grades

A judge can be asked to grade in a few different modes, and the right one depends on what you have to compare against.

Single-output grading. The judge reads one response and scores it against the rubric, on its own. "Here is a summary, here are the criteria, score it." This is the workhorse: it needs no reference answer, just the rubric, so it works when there is no single correct output.

Pairwise comparison. The judge sees two responses to the same input and picks the better one. This is useful when "which is better" is easier to judge than "how good is this in absolute terms", which is often true. It is how you compare two versions of an agent.

Reference-based grading. The judge compares the response to a known-good reference answer. This fits when you do have a gold answer and want to measure how close the response came to it.

ModeThe judge seesBest when
Single-outputOne response and the rubricThere is no single correct answer
PairwiseTwo responses to the same inputComparing two versions of the agent
Reference-basedThe response and a gold answerYou have a known-good reference

The rubric is what makes it reliable

The difference between a judge you can trust and one you cannot is the rubric. Ask a model "is this answer good?" and you get an inconsistent gut reaction that varies run to run. Give it specific criteria and you get a consistent, defensible score.

JUDGE_RUBRIC = """
You are evaluating a summary against these criteria. Score each 0 or 1.

1. Accuracy: every claim is supported by the source. No invented facts.
2. Completeness: the key findings are all present.
3. Grounding: every figure traces to the source data.

Return a JSON object with a score for each criterion and a one-line reason.
"""

Read what that does. It turns "is this good?" into three concrete, checkable questions, each scored independently, each with a reason. A judge grading against this gives you the same score for the same response, and tells you why it scored the way it did, which is what makes the result usable rather than a mysterious number.

async def judge(response: str, source: str) -> dict:
    prompt = f"{JUDGE_RUBRIC}\n\nSource:\n{source}\n\nSummary to grade:\n{response}"
    return await model_json(prompt)          # {"accuracy": 1, "completeness": 0, ...}

The judge is itself a structured-output call, the pattern from earlier in this series: a schema in, a scored object out. That structure is what lets you aggregate a thousand judgements into a number you can track.

A vague "is this good?" gives an inconsistent gut reaction; a specific rubric gives a consistent, reasoned score.A vague "is this good?" gives an inconsistent gut reaction; a specific rubric gives a consistent, reasoned score.

What a judge is good at, and where to be careful

A judge scales evaluation, and it is genuinely useful. It is also a model grading a model, which is worth being clear-eyed about.

A judge is strong at the things a clear rubric can pin down: is every claim supported, is a required element present, does a figure match the source. Give it a checkable criterion and it checks reliably.

A judge is weaker, and should be trusted less, on judgements that are subjective, or where the response itself could influence the judge. It is a model reading text and producing a score, so the same things that steer any model can steer a judge. That limit is exactly where the security series picks this up, because a judge you rely on to gate deployment is a judge worth attacking.

For now, the practical rule: keep rubrics specific and checkable, and calibrate the judge against human grades on a sample before you trust its scores at scale, so you know where its judgements agree with yours and where they drift.

What to take from this

  • LLM-as-a-judge uses a model to grade responses against your rubric, so evaluation scales past what you can grade by hand.
  • It grades in modes: single-output (against the rubric alone), pairwise (which of two is better), and reference-based (against a gold answer). Pick by what you have to compare against.
  • The rubric is what makes a judge reliable. Specific, checkable criteria give consistent, reasoned scores; a vague "is this good?" gives noise. Calibrate against human grades before trusting it at scale.

A judge turns your rubrics into scores at scale. The last piece is what you do with those scores: use them to decide what ships, and to keep making the evaluation itself better. The next post closes the loop.