How do you evaluate an LLM app? (including LLM-as-a-judge)
How do you evaluate an LLM application, and can you trust LLM-as-a-judge?
TL;DR
Build an eval set: a few dozen to a few hundred real, representative inputs (including edge cases and past failures), each with the expected answer or the criteria for a good one. Run it on every change (prompt, model, retrieval) and compare scores, like a test suite. Grade with the cheapest method that works: code checks (valid JSON, exact match, required fields, regex), then an LLM-as-a-judge for fuzzy qualities (faithfulness, helpfulness, tone), then human review for calibration and high-stakes cases. LLM judges are useful but biased, so validate them against human labels before trusting them.
Key points
- Offline evals (before shipping) catch regressions; online monitoring (production traces, user feedback, sampled reviews) catches what the eval set missed. Feed production failures back into the eval set.
- For RAG, evaluate retrieval (recall@k, MRR) and generation (faithfulness to the context, answer relevance) separately.
- For agents, score task success and inspect trajectories (tool choice, steps, cost).
- Making LLM judges reliable:
- A specific rubric and asking for a reason before the score.
- Binary or pairwise judgments (A vs B) are more reliable than 1–10 scales.
- Watch for position bias (swap the order), verbosity bias, and self-preference (a model favoring its own outputs).
- Measure agreement with human labels on a sample.
- Track cost and latency alongside quality; a better answer that's 5× slower may not ship.
Example
eval_set = [
{"question": "Refund window for EU customers?", "must_include": "14 days"},
{"question": "Do you ship to Mars?", "expect_refusal": True},
]
def grade(case, output):
if "must_include" in case:
return case["must_include"] in output # cheap code check
return judge(rubric=REFUSAL_RUBRIC, output=output) # LLM judge for the fuzzy case
score = mean(grade(c, app(c["question"])) for c in eval_set)Common follow-ups
- Where do eval cases come from? Real user queries, support tickets, known failures, and synthetic cases generated by an LLM and then reviewed by people.
- Are public benchmarks enough? No. They measure general ability, not your task, your data or your users.
What interviewers look for
Tip
Evals as a regression test suite on real data, layered graders, judge biases and validation, and the offline-to-online loop.
- Red flag: "we tested a few prompts manually and it looked good."