AI evaluation

LLM-as-a-Judge: How It Works and How Reliable It Is

What LLM-as-a-judge is, how to set one up and how far to trust it, with a worked example of checking a judge against people: the metrics to report, how many labels you need and what it costs to run.

By Deepen Team10 min read

LLM-as-a-judge, also written LLM as a judge, means asking one language model to grade the output of another, against criteria you write down. A model can read 50,000 answers overnight, which makes it the usual way to evaluate AI at scale.

Setting up a judge takes an afternoon. Knowing whether its grades are right takes more work, and it's easy to skip. A judge can agree with your reviewers on nearly 90% of answers and still miss half of the answers that were actually wrong. The worked example below shows how that happens, and how to catch it.

What an LLM judge does

The judge gets the input, the answer to grade and your criteria, and returns a verdict, usually with a short reason. Judges come in four common forms:

  • Pass or fail. One answer, one criterion, a yes or no. For example: does every claim in this answer appear in the policy?
  • A score. One answer rated on a scale, such as 1 to 4 for helpfulness. Each point on the scale needs its own written definition, or the judge and your reviewers will read the middle of the scale differently.
  • Pairwise. Two answers to the same input, and the judge picks the better one. Used to compare model versions or prompts.
  • With a reference. Any of the above, with the correct answer or the source document included in the prompt. The judge then checks the answer against the reference, a much easier task than knowing the facts itself.

Start with pass or fail, one criterion per judge. A yes or no is easier to check against people, and it's easier to act on: a failed answer goes to a person, a passed one doesn't. Add a scale later if you need to rank answers that all pass.

When to use a judge, and when to use something else

What you need to knowUseWhy
Is the output valid JSON, under the length limit, in the right language?CodeOne right answer. Code is exact, instant and free.
Does the answer match a known correct answer?Code, or a judge with the referenceExact match where you can, a judge where wording varies.
Is every claim supported by the source documents?Judge with the documentsA question of meaning, asked thousands of times.
Did the answer follow the policy, in a friendly tone?JudgeEasy to describe in writing, hard to check in code.
Is this dosage, clause or calculation correct?Experts, or a judge with a reference they wroteA judge without the answer is guessing.
Are the judge's grades right?PeopleSomeone has to set the standard it's measured against.

Two cases need extra care. Judges are weak at checking reasoning on their own: in the MT-Bench study, GPT-4 accepted wrong answers to a small set of math questions 70% of the time, and 15% of the time once it was given a reference solution. And a judge may prefer answers from its own model family. The same study saw GPT-4 favor itself with a 10% higher win rate and Claude-v1 with a 25% higher one, though the authors say their data can't settle it. Using a judge from a different model family is a cheap precaution.

Write the judge prompt

A good judge prompt has five parts:

  1. One criterion, defined precisely, with what counts as a pass and what counts as a fail.
  2. The reference, if there is one: the policy, the source passages or the correct answer.
  3. Evidence before the verdict. Ask the judge to quote the line that supports each claim, then decide. A verdict that comes after its evidence is easier to check. In the MT-Bench math test, asking GPT-4 to work through the problem before judging cut the wrong answers it accepted from 70% to 30%.
  4. A few examples from your reviewers, each with their one-line reason. Pick answers that are hard to call, including near-misses that pass.
  5. A fixed output format you can parse, such as JSON with the evidence, the verdict and the reason.

For example, a judge for a billing assistant that answers from the help-center policy:

You are checking an answer from a billing support assistant.

Criterion: the answer is SUPPORTED. Every factual claim in it (prices,
dates, eligibility, what happens next) is stated in the policy below,
and it answers the customer's actual question.

Policy:
<policy>{policy_text}</policy>

Customer question:
<question>{question}</question>

Answer to check:
<answer>{answer}</answer>

Steps:
1. List each factual claim in the answer.
2. For each claim, quote the policy line that supports it, or write NONE.
3. Say whether the answer addresses the question that was asked.
4. Verdict: PASS only if every claim has a supporting line and the
   question is answered. If unsure, FAIL.

Examples:
{examples_from_reviewers}

Reply as JSON:
{"claims": [{"claim": "...", "policy_line": "..."}],
 "answers_question": true,
 "verdict": "PASS" | "FAIL",
 "reason": "one sentence"}

"If unsure, FAIL" is there on purpose. A failed answer costs a person a minute to look at. A missed failure reaches a customer.

Pairwise judging and position bias

When a judge compares two answers, the order matters more than it should. In the MT-Bench study, GPT-4 gave the same verdict after the two answers swapped places only 65% of the time. GPT-3.5 managed 46% and Claude-v1 24%, mostly by favoring whichever answer came first.

Run every comparison twice, once in each order, and count a win only when the judge picks the same answer both times. Anything else is a tie. Those were 2023 models and today's do better, but the double run is cheap, so keep it.

Length can sway judges too. In the same study, padding an answer with a rephrased copy of its own list items fooled GPT-3.5 and Claude-v1 in 91% of attempts and GPT-4 in 9%. If longer answers keep winning, check a few by hand.

A worked example: checking a judge against people

Suppose the billing assistant above answers 50,000 questions a month. An answer fails if it states something the policy doesn't support, or answers a different question from the one asked.

Two trained reviewers label 400 recent answers pass or fail, each with a one-line reason, and a lead settles the cases where they disagree. 60 of the 400 fail. Then the first version of the judge, which sees only the question and the answer, grades the same 400.

Round 1

The judge agrees with the reviewers on 89.5% of the 400 answers. That sounds fine until you work out that a judge that passed everything would score 85%. When most answers pass, a judge can agree with people almost all the time just by passing things.

The share of wrong answers it catches tells you more: 30 of 60, a coin flip. It also fails 12 of the 340 good answers, and its Cohen's kappa, which discounts the agreement you'd get by chance, is a moderate 0.53.

What the misses had in common

The reviewers' reasons for the 30 missed failures fell into three groups:

  • 16 quoted a real policy that didn't apply to this customer, such as the monthly-plan refund window given to an annual-plan customer.
  • 9 answered a related question instead of the one asked.
  • 5 promised a timeline the policy doesn't give, such as "within 24 hours".

The judge couldn't catch the first and third groups, because it never saw the policy. It judged whether answers sounded right.

Round 2

Four changes: the judge now gets the policy text, quotes the supporting line for each claim before deciding, checks separately whether the question was answered, and sees six examples taken from the reviewers' reasons. Then it's tested on 400 new answers that nobody looked at while the prompt was being changed. Reviewers fail 64 of them, and the judge catches 54. It also fails 22 of the 336 good answers.

MeasureRound 1Round 2
Failures caught50% (38% to 62%)84% (74% to 91%)
False alarms3.5%6.5%
Cohen's kappa0.530.72
Accuracy89.5%92%

Accuracy moved less than 3 points. The failures caught went from half to five in six. False alarms rose a little, which is the price of "if unsure, FAIL", and an acceptable one when a person checks every flagged answer anyway.

To see how good it could get, the two reviewers had also labeled 200 answers independently, before any discussion. They agreed on 94%, with a kappa of 0.78. A judge can't be measured more precisely than the people it's measured against, so at 0.72 this judge is close to the ceiling. The next gains come from a clearer policy and clearer labeling rules, as much as from the prompt.

Testing on new answers matters. Prompt changes made while looking at the 400 answers from round 1 would score well on those same 400 whether they generalize or not.

The metrics to report for an LLM judge

  • Failures caught (recall on failures, or true negative rate if pass is your positive class): of the answers people failed, the share the judge failed too. Report it with its range.
  • False alarms: of the answers people passed, the share the judge failed. This sets how much flagged work lands on people.
  • Cohen's kappa (or Scott's pi): agreement with chance removed. Percent agreement alone can't tell judges apart. In a study comparing judges on question answering, Llama-3 8B agreed with people on well over 80% of answers but scored only 59 on Scott's pi, while the best judges scored in the high 80s.
  • Agreement between people: the same measures for two reviewers on the same answers. It's the ceiling, and if it's low, fix the rubric before the judge.

One often-quoted figure needs its context. MT-Bench found GPT-4 agreed with human experts 85% of the time, against 81% between the experts themselves. Those numbers leave out every comparison where someone called a tie. Counting ties, the first-turn figures were 66% and 63%. So a strong judge can agree with people about as well as people agree with each other, and the 85% describes the clear-cut cases.

How many labels you need

The precision of the failures caught depends on how many failures are in your labeled set. The total number of answers matters much less. If a judge catches 80% of the failures, this is the 95% range you can quote:

These are 95% Wilson intervals. At 10 failures the real rate could be anywhere from 49% to 94%, so you can't tell a good judge from a mediocre one. About 50 is the useful minimum, and 100 is comfortable. If 10% of your answers fail, 50 failures means labeling about 500 answers. When failures are rare, add known failures from past incidents and user complaints, so the set has enough of them to measure against.

Keep two sets: one to improve the prompt on, and one you only use for the final test. For sample sizes when you're estimating a failure rate itself, see how many runs to review in the guide to evaluating AI agents.

What a judge costs to run, with people in the loop

Back to the 50,000 answers a month. Suppose a judge call costs $0.002, and a trained reviewer checks one answer a minute at $5 per person-hour. The judge fails about 19% of answers, as it did in round 2, and a person checks each of those.

Judge plus people comes to about $909 a month against $4,167 for checking everything by hand, roughly a fifth, and every flagged answer still gets a person. The trade-off is the failures the judge misses, about 16% of them in round 2. The monthly random sample measures that number, so you know what it is.

Keep checking the judge after launch

A judge that passed its test can drift. The judge model gets updated, the assistant's model changes, the policy changes, and customers start asking about things your labeled set never covered.

  • Pin the judge to a specific model version, so it only changes when you change it.
  • Label a fresh random sample every month, and track the failures caught and false alarms over time.
  • Re-run the full check whenever you change the judge's model or prompt, the model it grades, or the policy.
  • Add every failure people find that the judge passed to the labeled set, with the reviewer's reason.

If the monthly failures caught falls below the range you measured at launch, treat the judge as unchecked until it's measured again.

Judging AI agents, and agent as a judge

Agents produce a run, a series of tool calls and actions, and the final reply can look fine when a step in the middle broke a rule. To judge an agent, give the judge the whole run, including the tool results, and ask one question per step or per rule. Check the end state of the systems it touched in code. The guide to evaluating AI agents covers this in full, with a scoring sheet for people.

Agent as a judge goes one step further: the judge is itself an agent, able to open files, run code or look things up to verify a claim, where an LLM judge only reads. The idea was introduced in Agent-as-a-Judge for grading coding agents. It suits work with checkable outputs, such as code and data changes. It needs the same check against people as any other judge.

Questions

What does LLM-as-a-judge mean?

Using a language model to grade another model's outputs against criteria you write, such as whether an answer is supported by a source or follows a policy. The judge returns a verdict, a score or a preference between two answers, usually with a reason.

How good is an LLM-as-a-judge?

It depends on the task, the prompt and the model, so measure it on yours. In the MT-Bench study, GPT-4 agreed with human experts 85% of the time on answers where neither called a tie, about as often as experts agreed with each other. On your own task, report the share of real failures the judge catches as well as overall agreement.

Which LLM is best for LLM-as-a-judge?

The strongest model you can afford, from a different family than the model it grades, checked on your own task. In the MT-Bench study GPT-4 was the most consistent of the judges tested, and in a later comparison the largest models came closest to people while smaller ones tended to pass answers when in doubt. Rankings change with each release, so try two or three on your labeled set and keep the one that catches the most failures.

How many human labels do I need to validate an LLM judge?

Enough to include at least 50 failures, and ideally 100. With 50 failures, a judge that catches 80% of them has a 95% range of about 67% to 89%. If 10% of answers fail, that means labeling about 500 answers.

How do you use LLM-as-a-judge for RAG evaluation?

Give the judge the retrieved passages and check two things separately: whether every claim in the answer is supported by the passages (faithfulness), and whether the answer addresses the question (relevance). Asking it to quote the supporting passage for each claim makes its verdicts easier to check.

Can an LLM judge replace human evaluation?

It can replace most of the reading, once it's been checked against people on your task. People are still needed to set the standard, check what the judge flags, and label a fresh sample regularly so you know the judge is still right.

Have trained reviewers check your LLM judge

A plan and a price within 2 working days. No sales call.