LLM evaluation
Measuring AI system quality with datasets, code checks and model-graded tests.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
Overview
Evals are the tests of AI systems. Because model output varies and "correct" is often fuzzy, you need a set of representative inputs, a way to score outputs, and a habit of running them whenever the prompt, model or retrieval changes.
Good eval work starts with error analysis: read a sample of real outputs, label what went wrong, and only then choose metrics. Scores can come from code (exact match, valid JSON, contains the right ID), from a model grading against a rubric (LLM-as-a-judge, checked against human labels), or from people. Keep the dataset small enough to look at and grow it from production failures.
What you will practise
- Read and label real outputs before choosing metrics
- Build a small golden set from real usage and known failures
- Mix code checks with rubric-based LLM grading
- Check an LLM judge against human labels before trusting it
Learning paths
- AI for test engineers
An AI course for testers: apply generative AI to everyday test automation, from AI-assisted test design to generating, healing and reviewing Playwright tests.
- AI for product managers
An AI course for product managers: prompt for usable drafts, research with sources, write a PRD from evidence, prototype with app builders and read evals.
- Building with the Claude API
Learn to build with the Claude API from your own code: the Messages API, tool use, structured output and prompt caching, then evaluate and trace what you built.
- Evals and safety for LLM features
Learn LLM evals and safety: catch regressions and attacks before users do, with error analysis, code-based evals, calibrated judges and prompt-injection tests.
- LLMOps: observability, evals and cost
Learn LLMOps in practice: trace every request, gate changes with evals in CI, calibrate judges and keep token spend visible and under control in production.
- Local models and fine-tuning
Run open-weight models on your own hardware, use them on private documents, decide when fine-tuning beats RAG or long context, and try a small LoRA fine-tune.
- Production AI agents: approval, multi-agent and evals
For engineers moving past single-agent demos: add code-level approval gates, context isolation, multi-agent patterns and automated evals you can trust in CI.
- Prompt and context engineering
A prompt and context engineering course: go from single prompts to deciding what a model sees at each step, from instructions and examples to files and tools.
- RAG engineer
A RAG course for engineers who want results they can measure: embeddings, pgvector, a pipeline built in a day, golden datasets, LLM judges and tracing.
Tutorials
- Add input and output guardrails to an LLM app
Length, topic and PII checks on input, schema and policy checks on output, then measure false positives and latency on a test set.
- Design tools an AI agent can use well
Take one badly designed agent tool, fix its names, descriptions, arguments, errors and output size, and measure the difference with a small eval you can rerun.
- Evaluate coding agents on your own repository
Run Claude Code and Codex headless against 10 closed issues from your repo, then score them with the real fix's tests and a blind review rubric.
- Optimise a prompt automatically with DSPy
Write a signature and a metric, run three optimisers on 30 labelled examples, score 20 held-out ones, and see when hand-tuning wins.
- How to test LLM applications as a QA engineer
Contract tests on a scripted model, a golden set with pass-rate floors, a calibrated LLM judge and a regression gate.
- Chunking strategies for RAG, tested
Compare fixed-size, heading-based and semantic chunking on the same documents and questions, measure retrieval hit rate, and pick a strategy with evidence.
- 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.
- Fine-tune a small model with LoRA
Fine-tune a small open model with LoRA using TRL and PEFT, measure it on a held-out set before and after, and decide whether the gain is worth keeping.
- 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.
Workflow recipes
- Move an app to a new model without regressions
LLM model migration without surprises: freeze a golden set, run old and new models side by side, fix the prompts, compare cost, then roll out behind a flag.
- Extract structured data from PDFs
Turn a folder of PDF invoices into validated JSON with Docling, a Pydantic schema and structured outputs, plus a review file for every one that fails a check.
- Evaluate RAG answers with a golden dataset
Set up RAG evaluation with a golden dataset and promptfoo: score retrieval, correctness and grounding for every question, and fail CI when answer quality drops.
- RAG pipeline in a day with Postgres and pgvector
Ingest your documents, answer with citations and measure retrieval against 20 questions written first.
- Red-team your chatbot for prompt injection
Generate attacks for its purpose, confirm each failure by hand, apply mitigations and re-run.
Articles
- How to choose an LLM for a task without trusting leaderboards
A method for choosing an LLM: build 20 test cases from your own work, then compare accuracy, cost per correct answer, latency and data terms. No rankings.
- Why AI hallucinates, and how to reduce it
AI hallucinations are fluent answers that are false. Why language models produce them, which ones you can prevent, and a checklist for work you depend on.
- Agent observability: what to log and why
What to record for AI agents in production: traces and spans, tool calls, cost per task and the signals that catch failures before users report them.
- 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.
- AI for QA engineers: where it helps and where it doesn't
Where it helps in test design, agent-written tests and self-healing, where it does not, and the testing skills worth building.
- 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.
Tools for this skill
9 of 14 tools tagged with this skill.
Arize Phoenix
Source-available tracing and evaluation for LLM applications, built on OpenTelemetry.
Braintrust
Platform for tracing production LLM traffic, running evals and catching regressions.
DeepEval
Open-source, pytest-style framework for evaluating LLM apps, RAG and agents.
DSPy
Write LLM programs as declarative modules and let optimisers tune the prompts.
garak
Scanner that probes LLMs for vulnerabilities such as prompt injection.
Inspect
The UK AI Security Institute's open-source framework for LLM and agent evals.
Langfuse
Tracing, prompt management and evals for LLM applications.
LangSmith
LangChain's tracing and evaluation platform, usable from any code.
MLflow
Open-source ML and GenAI platform with tracing, evaluation and prompt management.
Key terms
Words you will meet while learning this, defined in the glossary.
- Batch API
A provider endpoint that takes many requests at once and returns results later, typically within 24 hours, at a lower price than live requests.
- Benchmark
A public, standard test set used to compare models on a capability such as coding, maths or knowledge, under the same conditions.
- Data contamination
When benchmark or test examples appear in a model's training data, so high scores reflect memorisation rather than ability.
- Error analysis
Reading a sample of real outputs, labelling what went wrong and grouping the failures before deciding what to measure or fix.
- Eval
A repeatable test that measures how well an AI system performs on a defined set of cases, so you can compare versions instead of guessing.
- Evaluator-optimizer
A loop where one model call writes an answer and another grades it against criteria, sending feedback until the answer passes.
- Golden dataset
A curated set of inputs with expected outputs or grading notes, used as the fixed reference that your evals are scored against.
- LLM-as-a-judge
Using a model to grade another model's outputs against written criteria, ideally checked against a sample of human-labelled cases.
- Log probabilities (logprobs)
The log of the probability a model gave each token it generated, returned by some APIs to show how confident the model was.
- Needle-in-a-haystack test
A long-context test that hides one fact in a large block of unrelated text and checks whether the model can find and repeat it.
- pass@k
The probability that at least one of k generated solutions passes the tests, used to score code generation and other checkable tasks.
- Reasoning effort
An API setting that controls how much a reasoning model thinks before answering, trading cost and latency against accuracy.
- Regression eval
An eval run automatically on every prompt, model or code change, so that a drop in quality is caught before it reaches users.
- Sycophancy
A model's habit of telling users what they want to hear, agreeing with their views or praising their work even when that means being wrong.
- Synthetic data
Training or test examples generated by a model or program instead of collected from real users, used when real data is scarce.
- Trajectory evaluation
Evaluating the sequence of steps an agent took, its tool calls, arguments and order, rather than only its final answer.