LLM as a Judge: The Complete Guide
MarkdownLLM-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.
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.
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 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. 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 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..
- 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.
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. 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 judging prompt
The simplest useful judge is a single-answer faithfulness rubric for a RAG response.
Faithfulness 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}
Truncated context is explicitly handled so the judge does not treat partial sentences as full support.
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 model is fixed by your provider, the scoring scale is fixed by your rubric design, and the gold set is fixed by your domain.
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 is chain-of-thought). 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." 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
Three biases show up consistently enough that they have names.
- 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. .
- Verbosity bias is the tendency to prefer longer responses. 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. The size of this effect is contested (some replications find it small, others find it large), but it is large enough that you should not use Model A as the judge in an A-versus-B comparison if either A or B is Model A. Use a third model as judge, or use human raters for that specific comparison.
Calibrating the judge against a labelled gold set
A judge prompt that looks reasonable on three examples will fail in production. 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.
The minimum viable calibration loop has three inputs. A gold set drawn from the actual evaluation distribution and labelled by domain experts. A baseline run that records multiple metrics, not just one. An optimization step that rewrites the prompt against the worst-performing examples.
Why all seven metrics, not just accuracy: aggregate accuracy hides per-class recall. Reporting accuracy alone is the most common mistake teams make when they think they have a working 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. Inter-rater agreement on the gold set should be measured before it is used.
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 is not the same as alignment. 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.
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. 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, the floor is: measure on a labelled gold set, report at least accuracy plus Cohen's Kappa, and treat any single-metric claim with suspicion.
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
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. The mistake most teams make is shipping the prompt-and-eval loop without versioning, then losing the ability 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 has to exist.
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.
With 1,284 models and variants across 15 categories, Ailoot is one of the world’s largest AI routers by model count. Explore Ailoot’s LLM API with a key issued by Ailoot. Work with Grok or DeepSeek for text and code, Seedream for images, Seedance for video, Scribe for audio transcription, Lyria for music, Tripo3D for 3D and BGE for semantic search.
“llm evaluation api” — Put GPT, Claude, Gemini and DeepSeek to work in your app through one Ailoot key. Add document analysis, images, speech and video from the same balance.
Use Ailoot Arena to compare models and agents, or bring Ailoot into an editor, CLI, SDK or automation tool through one of 77 integrations.
Ailoot adds new flagship models at launch, and one subscription covers the full catalogue. Find a promo code in your account at https://ailoot.ai/. Ailoot subscriptions and promo codes offer up to 50% off official provider API prices.