Why I Started Using AI to Grade AI
A few months ago I was testing a new customer support prompt. I had fifty sample responses and I needed to know: are these actually good? My first instinct was to read every single one myself. That took about an hour, my eyes glazed over around response thirty, and I still wasn't confident my scores were consistent.
Then I remembered something I'd read about "LLM-as-Judge" — the idea of using a language model to evaluate the outputs of another language model. It sounded almost circular at first. Grade the AI with... the AI? But it turns out this is a real, widely-used technique in production eval pipelines, and once you understand both its power and its failure modes, it's genuinely useful.
Let me show you how to actually build one, and then — this is the important part — how to keep it honest.
What LLM-as-Judge Actually Is
The concept is simple: instead of writing rigid rule-based checks ("does the output contain the word 'sorry'?"), you write a prompt that asks a model to evaluate quality on dimensions that are hard to measure programmatically — things like tone, helpfulness, factual accuracy, or whether an answer actually addressed the question.
You feed it the original question, the response you're evaluating, and a rubric. The judge model returns a score, a label, or a short explanation. You then aggregate those scores across your eval set to compare prompts, models, or versions.
Here's the simplest version of a judge prompt:
# Basic LLM-as-Judge prompt structure
You are an impartial evaluator.
Question asked: {question}
Response to evaluate: {response}
Rate this response on the following criteria:
- Accuracy (1-5): Does it answer the question correctly?
- Clarity (1-5): Is it easy to understand?
- Helpfulness (1-5): Would a user find this genuinely useful?
Return JSON: {"accuracy": N, "clarity": N, "helpfulness": N, "reason": "..."}That's it. You can call this programmatically in a loop against every output in your eval set, then average the scores to compare two prompt versions side by side.
Building a Simple Judge in Python
Here's how I wire this up in practice. I'll use the OpenAI client but the same pattern works with Anthropic or any API:
# A minimal LLM-as-Judge implementation
import json
from openai import OpenAI
client = OpenAI()
def judge_response(question, response):
prompt = f"""You are an impartial evaluator.
Question: {question}
Response: {response}
Rate on each dimension (1-5):
- accuracy: Does it correctly answer the question?
- clarity: Is it easy to follow?
- helpfulness: Is it genuinely useful?
Return only valid JSON with keys: accuracy, clarity, helpfulness, reason"""
result = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": prompt}],
response_format={"type": "json_object"}
)
return json.loads(result.choices[0].message.content)
# Run it against your eval set
scores = []
for item in eval_set:
score = judge_response(item["question"], item["response"])
scores.append(score)
print(score)Now you can compare prompt_v1 vs prompt_v2 by running both sets of outputs through the judge and comparing average scores. That's genuinely powerful — especially when your eval set has hundreds of examples you can't read manually.
Where It Actually Works Well
LLM-as-Judge is legitimately great for a specific category of evaluation tasks:
Subjective quality dimensions. Does this response sound empathetic? Is this explanation clear for a beginner? Is this code review constructive rather than harsh? These are things humans can judge intuitively but are almost impossible to encode as rules. A model can approximate them surprisingly well.
Format and structure checks. Did the response follow instructions? Does it include a summary at the end? Is it under 200 words? You could use regex for some of these, but a judge handles edge cases more gracefully.
Consistency across a large batch. When you need to evaluate 500 responses and don't have time to read them all, a judge gives you a first pass. It won't be perfect, but it's much better than nothing — and it's consistent in a way that human spot-checking isn't.
Use a stronger model as the judge
If you're evaluating GPT-4o-mini outputs, judge with GPT-4o or Claude Opus. A model grading outputs from a smarter model will miss errors the larger model would catch. The judge should be at least as capable as what it's grading.
The Failure Modes That Make It Lie to You
Here's where I want to slow down, because this is the part most tutorials skip. LLM judges have real, documented failure modes that can silently corrupt your eval results. I've hit most of these myself.
1. Verbosity bias. Models tend to rate longer, more detailed responses higher — even when a shorter answer is objectively better. If you're comparing a concise prompt against a verbose one, the judge will often favor the verbose one not because it's more correct, but because it looks more thorough. I ran into this hard when testing a "be brief" prompt variant. The judge consistently scored it lower, even though users preferred it.
2. Self-preference bias. When you use GPT-4o to judge GPT-4o outputs vs Claude outputs, it subtly favors outputs that sound like how it would have answered. Same problem in reverse with Claude judging Claude. This is real and measurable — researchers have documented it. The fix is to either use a different model family as your judge, or use multiple judges and average them.
3. Positional bias. If you ask a judge to compare two responses (A vs B), it tends to favor whichever is listed first. This is wild but true. The fix: run the comparison twice with the order swapped. If the judge changes its answer when you flip the order, it's not actually judging quality — it's anchoring on position.
4. Sycophantic grade inflation. Ask a model to rate something on a 1-5 scale and watch how often it gives 1s or 2s. Almost never. Models are trained to be agreeable, which means their scores cluster at 4-5 for almost everything. If you need discrimination between good and mediocre outputs, force a relative comparison ("which of these two is better and why?") instead of an absolute score.
5. Rubric drift. The judge interprets your rubric differently on item 1 vs item 300. Its internal sense of what a "4 for clarity" means drifts across a long eval run. You can partially mitigate this by including anchor examples — show the judge a known "2" and a known "5" in the prompt so it has reference points.
# Anchored rubric to fight score drift
Clarity scoring guide:
1 = Incomprehensible, contradictory, or completely off-topic
2 = Hard to follow, requires re-reading multiple times
3 = Understandable but awkward phrasing or missing steps
4 = Clear and easy to follow with minor rough edges
5 = Perfectly clear, well-structured, nothing to improve
# Example anchor (include in your prompt)
Example of a 2: "The thing you do is first maybe step and then
the other part which connects, so do that."
Example of a 5: "Click File > Save. Then press Ctrl+Z to undo
any accidental changes before closing."Making Your Judge More Trustworthy
None of the failure modes above make LLM-as-Judge useless — they just mean you need to be deliberate. Here's my practical checklist:
Spot-check a sample manually. Take 10-15 items where the judge gave strong scores and read them yourself. If your gut and the judge agree most of the time, you can trust the aggregate. If you keep finding cases where the judge got it wrong, your rubric needs work.
Use pairwise comparison over absolute scores. Instead of "rate this 1-5", ask "which response better answers this question: A or B?" Pairwise comparisons are more reliable and less prone to grade inflation. You can still build rankings from them.
Run contested cases twice with order flipped. For any close calls (scores within 0.5 of each other), flip the order and re-run. If the winner flips, call it a tie.
Validate against a golden set. Build a small set of examples where you know the correct answer (5 great responses, 5 bad ones). Run your judge against them first. If it can't correctly identify your obviously-bad examples as bad, your judge prompt needs rethinking before you trust it on the rest.
Ask for reasoning before the score
Prompt your judge to explain its reasoning before giving a number. "Think through what's strong and weak about this response, then assign a score." Chain-of-thought scoring is measurably more accurate than asking for a number directly.
When Not to Use It
LLM-as-Judge is a terrible choice for factual accuracy evaluation unless you give the judge a reference answer to compare against. If you just ask "is this response factually correct?" the judge will hallucinate confidence about facts it doesn't actually know. Always include a ground-truth reference when evaluating factual claims.
It's also a bad fit for safety-critical checks. If you're evaluating whether a response contains harmful content, don't rely solely on a model judge — it can be manipulated or miss subtle cases. Use a dedicated content moderation API or classifier for that layer.
Used thoughtfully, though? LLM-as-Judge is one of the most practical eval tools I've added to my workflow. It's not a replacement for human judgment — it's a force multiplier that lets you apply something like human judgment at scale. Just keep one eye on it, spot-check regularly, and never trust a score you haven't validated against examples you personally understand.
More tutorials in this category, or explore the full field guide.