Cheat sheet
LLM evals cheat sheet
Check types, a judge prompt template, which metrics to use for RAG, agents, classification and extraction, sample sizes and a CI snippet, on one page.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
A one-page reference for building evaluations of LLM features. The method behind it: read real outputs first, name the failures, then pick the cheapest check that catches each one. Start your evals by reading outputs explains why that order matters.
The process in six lines
- Collect 50 to 100 real inputs (or realistic ones) with outputs from the current system.
- Read them. Write a one-line note on every bad output.
- Group the notes into failure types. Count them.
- For the top failure types, write a check: code first, judge if code cannot.
- Turn inputs and checks into a test set; run it on every change.
- Add a case every time production shows a new failure.
Check types, cheapest first
| Check | Use for | Example |
|---|---|---|
| Exact or set match | Labels, IDs, yes/no | output.category == expected.category |
| Schema validation | Structured output | Parses as JSON and matches a JSON Schema or Pydantic model |
| Contains / regex | Required or forbidden content | Must mention the order number; must not contain “guarantee” |
| Code assertion | Anything computable | Total equals sum of line items; SQL runs and returns the expected rows |
| Tool-call assertion | Agents | issue_refund called once, after lookup_order; never called delete_* |
| State check | Agents | The database or file system ends in the expected state |
| Similarity | Paraphrase allowed, meaning fixed | Embedding similarity to a reference above a threshold |
| LLM judge | Tone, helpfulness, faithfulness, policy | Pass/fail with a reason against a written rubric |
| Human label | Calibrating judges, ambiguous cases | Domain expert marks pass/fail on a sample |
Judge prompt template
You are checking one output from a customer-support assistant.
Criterion: {criterion, e.g. "Every factual claim is supported by the
provided policy excerpt. Claims not in the excerpt count as unsupported."}
Policy excerpt:
<context>{retrieved_context}</context>
User question:
<question>{question}</question>
Assistant answer:
<answer>{answer}</answer>
Think about whether the criterion is met. Then reply on the last line
with exactly PASS or FAIL, followed by one sentence explaining why.
Rules for judges:
- One criterion per judge call. Several criteria in one prompt blur together.
- Give the judge the same evidence the system had (retrieved context, tool results).
- Calibrate: label 30 to 50 outputs yourself, run the judge, and measure agreement. Fix the rubric where it disagrees. LLM-as-a-judge covers this.
- Use a different or stronger model than the one under test where you can, and pin its version.
Metrics by task
Classification and routing
- Accuracy only if classes are balanced; otherwise per-class precision, recall and F1.
- A confusion matrix: which classes get mixed up tells you what to fix.
Extraction to a schema
- Valid output rate (parses and matches schema).
- Per-field accuracy, not just whole-record exact match.
- Null handling: correct
nullwhen the field is absent, no invented values.
RAG
Separate retrieval from generation:
| Stage | Metric | Question it answers |
|---|---|---|
| Retrieval | Hit rate at k / context recall | Is the evidence in the top k chunks? |
| Retrieval | MRR / context precision | Is the evidence near the top, and is the rest relevant? |
| Generation | Faithfulness (groundedness) | Is every claim supported by the retrieved context? |
| Generation | Answer relevance | Does it answer the question asked? |
| End to end | Correctness against a reference answer | Is it right? |
Ragas implements the generation metrics (faithfulness, answer relevancy, context precision and recall) with LLM judges; you can also write them as judge prompts yourself.
Summarisation
- Faithfulness: no claims absent from the source.
- Coverage: the key points from a reference list are present.
- Length and format constraints met.
Agents
- Task success: final state correct (state check).
- Trajectory rules: required order, forbidden tools, step budget.
- Pass rate over k trials per task, and whether all k pass.
- Cost and latency per completed task.
Evaluate AI agents builds a harness for these.
Safety
- Refusal rate on disallowed requests, and over-refusal rate on allowed ones.
- Prompt injection success rate on a fixed attack set (promptfoo red-team or garak).
How many cases?
| Purpose | Rough size |
|---|---|
| Smoke test in CI on every prompt change | 20 to 50 well-chosen cases |
| Comparing two prompts or models | 100+ cases, and look at the differences, not just the totals |
| Calibrating a judge | 30 to 50 human-labelled outputs |
| Agent tasks | 10 to 30 tasks × 3 to 5 trials each |
Small differences on small sets are noise. If two variants differ by two cases out of fifty, read those cases rather than trusting the score.
CI snippet (promptfoo)
# promptfooconfig.yaml
prompts: [file://prompts/answer.txt]
providers:
- anthropic:messages:claude-haiku-5-5
defaultTest:
assert:
- type: is-json
tests: file://evals/cases.yaml
# in a GitHub Actions job
- run: npx promptfoo@0.126.0 eval -c promptfooconfig.yaml -o results.json
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- run: test "$(jq '.results.stats.failures' results.json)" -eq 0
Full walkthrough: Run LLM evals in CI with promptfoo.
Common mistakes
- Choosing metrics before reading outputs.
- Generic metrics (“helpfulness”) that do not map to a failure you have seen.
- Judges nobody calibrated.
- One trial per agent task.
- Test sets that never grow after launch.
- Evaluating on data the prompt was tuned against.
Tools
promptfoo (config-driven, CI-friendly), Ragas (RAG metrics), DeepEval (pytest-style), Inspect (UK AISI’s framework), and the evaluation features in Langfuse, LangSmith and Arize Phoenix.
Covers
Related
- Write your first LLM eval
Turn real outputs into a small test set, add code-based checks in promptfoo and run them in CI to catch regressions on every change.
- LLM-as-a-judge: grading outputs you can trust
Write narrow grading criteria, check the judge's verdicts against your own labels and decide when its agreement is good enough.
- Run LLM evals in CI with promptfoo
Write a promptfoo config with deterministic and model-graded assertions, run it in GitHub Actions, fail the build on regressions and keep the bill small.
- Evaluate AI agents: outcomes, trajectories and tool use
Build an agent eval harness that checks the final state, the tool-call trajectory and a judged transcript, run each task several times and read the traces.
- Start your evals by reading outputs, not by picking metrics
The fastest way to useful LLM evals is to read real outputs and write down what is wrong. Why error analysis comes before metrics, and how to do it.