# LLM as a Judge: The Complete Guide

> LLM-as-a-judge is the practice of using one language model to evaluate another model’s outputs against a rubric, making scalable AI evaluation practical for chatbots, RAG systems, and agents. The article explains the three core judging modes, where LLM judges work well, where they fail, how to write reliable rubrics, and why calibration against a labelled gold set is mandatory before production use.

Source: https://ailoot.ai/blog/en/llm-as-a-judge-the-complete-guide/
Canonical: https://ailoot.ai/blog/en/llm-as-a-judge-the-complete-guide/
Language: en
Publisher: Ailoot (https://ailoot.ai/)
Translation: guide-100299
Revision: sha256-c90099337c81d8d4328f8a81a1ee58e90c8604f60d4fa26a29a72f97f2387746



LLM-as-a-judge is the practice of using one language model to evaluate another model’s outputs against a rubric, making scalable AI evaluation practical for chatbots, RAG systems, and agents. The article explains the three core judging modes, where LLM judges work well, where they fail, how to write reliable rubrics, and why calibration against a labelled gold set is mandatory before production use.

> **TL;DR —** LLM as a judge is the practice of using a language model to score another model's output against a written rubric, in place of (or alongside) human raters. Use single-answer scoring with an explicit rubric for production evaluation, pairwise comparison for ranking model versions, and never trust a judge you have not measured against a labelled gold set.

This piece is for engineers who already build evaluations and want a defensible answer to "should we use an LLM judge here, and if so, how?" If you have never written an evaluation before, begin with a small labelled set of examples.

## What "LLM as a judge" actually means

An LLM judge is a model called with a prompt that asks it to evaluate something, usually another model's response. It returns a score, a label, or a preference. That is the entire architecture. Everything interesting is in the prompt, the rubric, and how you measure whether the judge's verdicts agree with reality.

The reason it caught on is operational, not philosophical. A human-only evaluation pipeline scales badly. The tradeoff is that the judge brings its own biases, and unlike human raters, those biases are systematic.

## How an LLM judge scores outputs

There are three scoring modes, and the choice between them changes what your evaluation can and cannot tell you.

- ‍**Pairwise comparison** asks the judge to pick which of two responses is better. Use pairwise when you are A/B testing two model versions or two prompts. Do not use it when you need an absolute quality threshold, because pairwise scores have no ground floor: response B can win every comparison and still be unusable.**‍**
- **Single-answer grading with a rubric** asks the judge to score one response against an explicit standard. This is the mode you want in production, because every response gets a score on the same axis, and you can set deployment gates around it ("ship if the faithfulness criterion passes on the canary set"). Pick the lowest-precision scale that captures the distinction you care about: binary pass/fail when the question is "did the model violate the rubric, yes or no," a three-point scale (fail / partial / pass) when degrees of failure matter for triage, and only go to 1-to-5 or 1-to-10 if you genuinely need the resolution and have the gold-set data to validate that the judge can use it. Fine-grained scales invite the judge to invent distinctions it cannot defend, and the resulting noise eats the signal you wanted to measure. Rubric quality matters more than scale choice. A vague rubric ("rate the helpfulness from 1 to 5") gives you a number with no information content. A claim-level rubric ("score 0 if any factual claim is not directly supported by the retrieved passage") gives you a number you can act on. Rubrics should be reviewed when evaluation requirements change.**‍**
- **Reference-based grading** gives the judge a known-good answer and asks how close the candidate is to it. This is the closest analogue to traditional NLP metrics like BLEU and ROUGE, but with semantics rather than n-gram overlap. It works well for tasks with constrained outputs (translation, summarization against a gold summary, structured data extraction). It collapses on open-ended tasks, because there are usually many acceptable answers and the judge will penalise responses that are good but different.

In practice most production setups use single-answer grading per criterion (faithfulness, relevance, and format compliance) and use pairwise comparison only during development to choose between candidate prompts.

## When an LLM judge is the right tool

An LLM judge works well on tasks where the judgment is essentially a reading-comprehension problem against a clearly stated rubric. "Does this response contain any factual claim not supported by the retrieved context?" is a reading-comprehension question. So is "Does this response refuse to answer in the cases the spec requires it to refuse?" The judge model has to extract the claim, locate the supporting passage (or note its absence), and return a verdict. Frontier models do this well.

It works less well on tasks that require the judge to know things the prompt cannot encode. "Is this response funny?" is a question every model will answer, but the answers will reflect the judge's priors, not your readers'. "Is this code idiomatic Rust?" requires the judge to have absorbed the same conventions as your team, which it probably has not. For these tasks, treat the judge as one signal among several rather than as ground truth.

It actively hurts on tasks where the cost of a missed failure is high and the failure pattern is rare. A judge can miss failures, which matters when the consequences of a missed issue are high. In those cases, the judge is a triage filter (it cuts the volume of cases human reviewers see), not the final word.

## A worked example: a faithfulness judge in 40 lines

The simplest useful judge is a single-answer faithfulness rubric for a RAG response. Here is an example using the OpenAI Python SDK:

```

from openai import OpenAI
from pydantic import BaseModel

client = OpenAI()

JUDGE_PROMPT = """You are evaluating whether an assistant's response is faithful
to a retrieved context passage. Faithful means every factual claim in the response
is directly and explicitly supported by the context. A claim is unfaithful if it
is added, modified, or drawn from outside the context.

Steps:
1. Enumerate every factual claim in the response (numbers, rules, entity names,
   negations, comparisons).
2. For each claim, locate the specific sentence in the context that supports it.
3. If any claim has no direct support, the response is unfaithful.
4. Truncated or cut-off context counts as zero support for whatever follows.

Return JSON: {{"verdict": "faithful" | "unfaithful", "reason": ""}}.

CONTEXT:
{context}

RESPONSE:
{response}
"""

class Verdict(BaseModel):
    verdict: str
    reason: str

def judge(context: str, response: str) -> Verdict:
    completion = client.beta.chat.completions.parse(
        model="gpt-4o-2024-11-20",
        messages=[{"role": "user",
                   "content": JUDGE_PROMPT.format(context=context, response=response)}],
        response_format=Verdict,
        temperature=0.0,
    )
    return completion.choices[0].message.parsed
  
```

The prompt asks the judge to enumerate claims before evaluating them, creating a claim-level check. Truncated context is explicitly handled, because retrieval pipelines truncate at chunk boundaries and the judge will otherwise treat partial sentences as full support. Temperature is zero, because non-zero temperature on a binary classification task introduces variance you cannot interpret.

This is enough to run, not enough to ship. The next two sections cover the parts that turn a working example into a deployable judge: getting the prompt right, then measuring whether it actually agrees with humans.

## Writing the judge prompt and rubric

The judge prompt is where most of the gains in an LLM-as-a-judge setup actually come from. The model is fixed by your provider, the scoring scale is fixed by your rubric design, and the gold set is fixed by your domain. The prompt is one part you can iterate on as you compare the judge with labelled examples.

A working judge prompt has four elements. A definition of the criterion in the words your domain uses, not generic ML vocabulary ("faithful to the retrieved context" is a domain definition; "high quality" is not). An explicit reasoning structure that tells the judge to enumerate the discrete claims, conditions, or tool calls before scoring (this gives the judge an explicit sequence of checks). A scoring rule that maps the reasoning result onto the scale, like "if any enumerated claim is not directly supported by the retrieved context, score 0," not "use your judgment." And a handling clause for the edge cases that show up in production: truncated context, empty retrievals, partial answers, refusals.

What you should not put in the prompt is a long list of "make sure your answer is helpful, honest, and harmless." Generic instructions get ignored. Specific claim-level rules get followed. The other thing to avoid is over-specifying the format of the verdict; if the model has to produce a long structured rationale before its score, you are paying for tokens you will not read.

## The biases that make naive judges unreliable

Several biases can affect LLM judges; account for them when designing an evaluation.

- ‍**Position bias** is the tendency to favour whichever response appears first (or sometimes last) in a pairwise comparison. The fix is to evaluate every comparison in both orders and only count cases where the verdict is consistent. It requires scoring the comparison in both orders.**‍**
- **Verbosity bias** is the tendency to prefer longer responses. Longer responses can receive preference even when length is not a rubric criterion. If your rubric does not say "concise responses score equal to or better than verbose ones at equivalent correctness," your judge is implicitly optimising for length. The mitigation is to put length neutrality into the rubric explicitly.**‍**
- **Self-preference bias** is the tendency for a judge to favour outputs from the same model family it belongs to. Avoid using a model to judge a comparison that includes outputs from that same model family. Use a third model as judge, or use human raters for that specific comparison.

Other possible issues include sentiment and sycophancy biases. Include relevant failure patterns in the labelled gold set used for calibration.

## Calibrating the judge against a labelled gold set

A judge prompt should be checked against a labelled gold set before deployment. The way to find out before deployment is calibration: run the judge against a labelled gold set, measure the gap between its verdicts and the human labels, and iterate the prompt until the gap closes.

A calibration loop has three inputs: a labelled gold set drawn from the evaluation distribution; a baseline run that records relevant agreement and error metrics; and an optimization step that revises the prompt against examples where the judge disagrees with the labels. Repeat calibration when the prompt or evaluation distribution changes.

Aggregate accuracy hides per-class recall. A low Kappa despite high accuracy can indicate agreement close to chance. A higher Kappa indicates stronger agreement beyond chance. Report more than accuracy when evaluating a judge.

## Building the gold set

Calibration depends on a gold set, and gold sets do not exist by default. Building one is the prerequisite step that determines whether everything downstream is measuring something real or measuring noise.

A gold set is a collection of input-output pairs labelled by domain experts with the verdict you want the judge to produce. Three properties make a gold set load-bearing for evaluation. It has to be drawn from the actual evaluation distribution: real queries, real retrieved contexts, real agent responses, not synthetic examples that look plausible to whoever wrote the dataset. The failure classes have to be represented; a gold set of 100 examples that are all faithful tells you nothing about whether the judge catches unfaithfulness, which is the only failure that matters. And inter-rater agreement on the gold set has to be measured before it gets used; if domain experts often disagree on labels, clarify the rubric before calibration to avoid optimizing against noise rather than the failure modes.

Generating the queries and synthetic-but-realistic answers for a gold set is its own engineering problem. Several frameworks now exist to do this from your source documents, and the differences between them affect what kinds of failures the resulting gold set surfaces. 

## Judge-human agreement is task-specific

Agreement between an LLM judge and human evaluators can vary by task, and several distinctions matter.

Agreement tends to be easier to interpret on closed tasks with verifiable outcomes than on open-ended tasks where evaluators may disagree. A judge cannot be assessed apart from agreement among human evaluators on the underlying task.

The second is that agreement is not the same as alignment. A judge can look accurate overall while missing the failure class that matters (for example, passing unsupported responses as faithful). The aggregate number flatters the judge; the per-class recall is what tells you whether to ship it. The calibration section above is what fixes this: measure both, fix the prompt against the failures, repeat.

The third is that agreement metrics depend on the metric. Reporting raw accuracy on an imbalanced gold set (mostly passing examples, few failures) flatters the judge. Reporting Cohen's Kappa, which adjusts for chance agreement, is harder to fake. A low Kappa despite apparently high accuracy can indicate that agreement is close to chance. Pearson correlation is useful for continuous scores; Spearman holds up better if you only trust the ranking and not the absolute values.

For production pipelines, measure on a labelled gold set and report more than one suitable agreement or error metric.

The decision of when to use an LLM judge alone, when to use it as a triage filter with humans on the flagged subset, and when to skip the judge and use humans-only depends on three variables: the cost of a missed failure, the volume of evaluations, and the rate at which the evaluation distribution drifts.

## From example to production: wiring the judge in

The 40-line example earlier in this article is enough to grade one response in a Python REPL. Putting a judge in front of every production response (or running it on every pull request in CI) is a different engineering problem.

The bits that come up at scale are unsexy. Batching requests so judge inference does not dominate end-to-end latency. Retry handling for the cases where the judge returns malformed JSON, exceeds rate limits, or times out. Structured logging of verdicts and reasoning traces so you can diagnose later why a specific case was flagged. Regression detection that fires when alignment on the canary gold set drops between deploys. Versioning of judge prompts the same way you version the application code, so you can attribute alignment changes to specific prompt edits. And integration with your CI system so a judge run is part of the deploy gate rather than a manual check someone forgets to do under time pressure.

None of these are intellectually hard. All of them are work, and the order in which you implement them affects which production failures you hit first. Without prompt versioning, it becomes harder to attribute regressions when alignment shifts.

## When NOT to use an LLM judge

Three situations where you should not reach for a judge, and where teams routinely do anyway.

When the task has a deterministic correctness check, do not use a judge. SQL query equivalence, JSON schema validation, regex matching, exact-string comparison, and tool-call argument matching are all solved problems. An LLM judge wrapping any of these adds latency, cost, and a non-zero chance of being wrong about something that has a definitive answer. Run the deterministic check, fail fast on mismatch, and only call the judge for the parts that genuinely require natural-language reasoning.

When you have not built a labelled gold set, do not use a judge in production. The judge gives you a number. Without ground truth, you cannot tell whether the number means anything. The gold set should represent the actual evaluation task and include important failure cases.

When the cost of a missed failure exceeds the cost of human review, do not use a judge as the final gate. Use it as a triage filter that cuts the volume of cases humans review. A judge deployed without a human in the loop in a regulated domain is a different decision, and one that should be made explicitly with the legal and compliance functions involved, not implicitly because the judge happened to score high on a dev-set.

The judge is a tool, not a verdict. It earns its place by catching the failures you would otherwise ship. It loses its place the moment you stop measuring whether it still does.

‍



<!-- ailoot-promo:9e3272784ffb8649f9315d554d7ba8e5e33f918cb2ab4be53187053da2bd506f -->
<p>With 1,284 models and variants across 15 categories, Ailoot is one of the world’s largest AI routers by model count. Explore <a href="https://ailoot.ai/">Ailoot’s unified AI API</a> with a key issued by Ailoot. The same key covers GPT, Claude, Gemini, Grok, Qwen and DeepSeek, plus Nano Banana for photos, Veo for video, Eleven v4 for speech, Suno for music, Tripo3D for 3D and BGE for search.</p>
<p>Use one <a href="https://ailoot.ai/">Ailoot-issued API key</a> to call GPT, Claude or Gemini when comparing model outputs or building an LLM judge. The same key connects image, video, speech and 3D models to your product.</p>
<p>Connect to Ailoot with a supported SDK or a ready-to-use coding or automation integration. One account covers the subscription, project keys and usage.</p>
<p>One subscription covers the full Ailoot catalogue, with day-one access to new flagship models through the same key. Subscriptions and promo codes offer savings of up to 50% compared with official provider API prices. Get your key at <a href="https://ailoot.ai/">https://ailoot.ai/</a> and check your account for a promo code.</p>
<!-- /ailoot-promo -->


## Ailoot · The company and its project portfolio

Ailoot combines established operating experience, a large client base, stable service and ongoing KPI control.

The company and its project portfolio: millions of customers; monthly sales in the billions.

Ailoot brings that operating experience to API access for AI features in customer products, agents, applications and automations.
