How to Evaluate an LLM App: A Minimal Setup in an Afternoon
To evaluate an LLM app, build a golden set of 30 to 100 real cases, run cheap deterministic checks first, add a calibrated LLM judge for the rest, and compare baseline against candidate per case before every change ships.
- Start with 30 to 100 versioned golden cases drawn from real traffic, edge cases, adversarial inputs and past failures, not thousands of synthetic ones.
- Layer checks cheapest first: deterministic assertions, then reference-based metrics, then an LLM judge only for what remains.
- Use a binary rubric per criterion, reasoning before verdict, a pinned judge at temperature 0, and hand-label 30 to 50 outputs to confirm agreement before trusting it.
- Compare baseline and candidate per case and per slice, repeat runs 3 to 5 times, and treat a 2 to 3 point change on a small set as noise.
- Feed production failures back into the golden set weekly so the eval grows with every bug.
Why does checking LLM outputs by eye fail?
Reading a few outputs after each prompt change feels like testing, but it breaks in three ways. Outputs are non-deterministic, so the same input can pass once and fail the next run. A sample of 5 to 10 is too small to show a 5 or 10 point change. And you anchor on the last few outputs you read: the one you just fixed looks like proof, while the three you did not reread may have broken.
Evals fix this by acting as unit tests for prompts: a fixed set of inputs, automatic checks, and a number you can compare before and after. The goal is not a perfect score. It is being able to say whether a change made things better, worse or no different.
How to evaluate an LLM app: what belongs in a golden set?
Aim for 30 to 100 cases. That is enough to catch large regressions and small enough to label by hand in an afternoon. Thousands of cases mostly add cost and noise before you have a working loop.
Fill it from four sources: real production inputs (anonymised), edge cases (empty input, very long input, other languages, ambiguous requests), adversarial inputs (prompt injection, requests outside scope), and every failure you have already seen. Stratify by use case and difficulty so each slice has at least 5 to 10 cases, and keep roughly 20 percent as a held-out split you do not tune against.
{"id":"sup-017","input":"I was charged twice for my May invoice","context_ids":["kb-112"],"expected":{"must_call_tool":"lookup_invoice","must_mention":["refund","3-5 business days"]},"criteria":["Answer is supported by the retrieved context"],"tags":["billing","medium","critical"],"split":"dev"}Which checks should I run first, and when do I need an LLM judge?
Work in layers, cheapest and most reliable first. Each layer removes cases the next one would otherwise have to judge, which also answers how to evaluate without manual review: most of the work is code, not people.
Layer 1 is deterministic assertions. They are free, instant and exact. Layer 2 compares against a reference. Layer 3, the LLM judge, handles only criteria that code cannot express, such as faithfulness or tone.
| Layer | Examples | Cost | Use for |
|---|---|---|---|
| 1. Deterministic | Valid JSON or schema, required fields, regex, length limit, banned phrases, citation present, correct tool and arguments | Near zero | Format, safety rules, tool calls |
| 2. Reference-based | Exact match, field-level F1, embedding similarity above a tuned threshold | Low | Classification, extraction, short factual answers |
| 3. LLM judge | Faithfulness, completeness, tone, resolution | One model call per criterion per case | Open-ended text only |
import json, re
def run_assertions(case, out):
results = {}
results["valid_json"] = is_json(out["text"])
results["under_120_words"] = len(out["text"].split()) <= 120
results["no_banned"] = not re.search(r"(?i)as an ai|guarantee", out["text"])
exp = case["expected"].get("must_call_tool")
if exp:
results["right_tool"] = exp in [t["name"] for t in out["tool_calls"]]
return results
def is_json(s):
try:
json.loads(s); return True
except ValueError:
return False How do I set up an LLM judge, and what are the pitfalls?
Judge one criterion per call, with a binary pass or fail (or at most a 3-point scale) instead of a 1 to 10 score. Ten-point scales cluster at 7 or 8 and do not separate versions. Ask for reasoning first and the verdict last, pin an exact model version, and use temperature 0.
The judge is a model with its own biases, so it must be calibrated before you trust it.
| Pitfall | What happens | Mitigation |
|---|---|---|
| Position bias | In pairwise comparison the first or second answer wins more often | Run both orders and keep only consistent verdicts, or score each answer alone |
| Verbosity bias | Longer answers are rated higher | Score against a rubric, add a length assertion |
| Self-preference | A judge favours output from its own model family | Judge with a different family than the generator |
| Judge drift | A provider updates the model and scores shift | Pin the version and re-run calibration when you change it |
| Vague criterion | 'Is this good?' gives inconsistent answers | One concrete, checkable criterion per prompt |
- Hand-label 30 to 50 outputs as pass or fail, including clear failures.
- Run the judge on the same outputs.
- Compute percent agreement and Cohen's kappa. Aim for kappa around 0.6 or higher, or at least 85 percent agreement on a balanced sample.
- Read every disagreement and tighten the rubric, then re-measure.
- Never change the judge and the candidate in the same experiment.
You are checking whether an answer is faithful to the provided context.
Context:
{context}
Answer:
{answer}
Criterion: Every factual claim in the answer is directly supported by the context.
If any claim is missing from the context or contradicts it, the answer FAILS.
Ignore style and length.
First write a short reasoning listing each claim and whether it is supported.
Then output the final line exactly as: VERDICT: PASS or VERDICT: FAIL How do I compare two prompts or models and catch regressions?
Run baseline and candidate on the identical set with the same judge. Then look beyond the average: compare per slice, and list the cases that flipped from pass to fail, since a stable average can hide five new failures offset by five fixes.
Account for noise by running each case 3 to 5 times and recording a pass rate, or by counting a case as passing at 2 of 3 runs. On a 40-case set, one case is 2.5 points, so a 2 to 3 point change is usually noise. Use a paired comparison (McNemar-style counts of flips) or a bootstrap confidence interval over cases, and treat a result as real only if the interval excludes zero.
Here is a 40-case support-bot set with three assertions (valid format, correct tool, no banned phrase) and one faithfulness judge. A case passes only if all four pass.
| Metric | Baseline | Candidate | Reading |
|---|---|---|---|
| Overall pass rate | 31/40 (77.5%) | 33/40 (82.5%) | +5 points, but see flips |
| Critical slice (billing, 12 cases) | 12/12 | 10/12 | Regression, blocks ship |
| Faithfulness judge | 34/40 | 36/40 | Improved |
| Fail to pass flips | n/a | 6 | Fixed |
| Pass to fail flips | n/a | 4 | Inspect each one |
| Median latency / tokens | 1.8 s / 920 | 2.6 s / 1,400 | Cost up about 50 percent |
How do I gate changes in CI and learn from production?
Turn the comparison into a gate that runs on every pull request touching a prompt, model or retrieval setting. Example rules: critical-slice pass rate must not drop at all, overall pass rate may not drop more than 3 points, and no new schema failures. Report cost, latency and token counts in the same output, because a better prompt that doubles spend is still a trade-off.
Production keeps the set honest. Log the input, output, prompt version, model and retrieved context for every request. Randomly sample 1 to 5 percent, and oversample low-confidence answers, thumbs-down, long conversations and escalations. Review 20 to 50 per week, and turn each confirmed failure into a golden case.
Watch online signals as a cheap early warning: thumbs, retries, user edits, handoffs to humans and abandonment.
- Run the golden set on every change and save results with the git hash and prompt version.
- Fail the build if the critical slice drops or the overall rate falls past your threshold.
- Print the list of flipped cases in the CI log.
- Sample production weekly and add failures to the dev split.
- Re-run judge calibration whenever the judge model changes.
Which metrics fit my task, and what mistakes should I avoid?
Pick metrics by task, not by what a library offers. For open-ended output, BLEU and ROUGE mostly measure word overlap, not quality, so rely on rubric checks instead.
Tooling can stay simple: a Python script plus pytest is enough for the first version. Promptfoo, Ragas, DeepEval, LangSmith, Braintrust and OpenAI Evals add dashboards, tracing and prebuilt metrics once the loop exists.
| Task | Metrics |
|---|---|
| Classification | Accuracy, precision and recall per class, confusion matrix |
| Extraction | Field-level F1, schema validity |
| RAG | Retrieval recall@k, faithfulness, answer relevance; score retrieval and generation separately |
| Summarization | Coverage and factual consistency via judge, not ROUGE alone |
| Agents and tool use | Task success, correct tool and arguments, step count |
| Chat | Resolution, tone, safety |
Common questions
Can I evaluate an LLM app without manual review?
Mostly, once the setup exists. Deterministic checks and reference metrics need no reading, and a calibrated judge covers the rest. You still need a one-time hand-labelling of 30 to 50 outputs to calibrate the judge, plus a weekly look at 20 to 50 sampled production cases.
How many runs per case do I need because of non-determinism?
Run each case 3 to 5 times and record a pass rate, or count a pass at 2 of 3. Setting temperature to 0 reduces variance but does not remove it, especially across provider updates.
Should I use a stronger model as judge?
A stronger judge helps on subtle criteria, but calibration matters more than size. Choose a different family from the generator to limit self-preference, then verify agreement with your own labels.
What do I do when the judge and my labels disagree?
Read each disagreement and decide who is right. Most of the time the rubric is ambiguous, so add a concrete rule or a borderline example, then re-measure agreement on the same labelled set.
When should I move from a script to an eval framework?
Move when you need shared dashboards, tracing of multi-step runs, or many teammates running experiments. Until then a script, a JSONL file and pytest are easier to understand and debug.