Learning path
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.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkWhat you will be able to do
- Build a small eval set from real outputs and run it on every change
- Write judge criteria and check the judge against human labels
- Trace requests with tokens, latency and cost per user action
- Explain direct and indirect prompt injection and the defences that help
- Red-team a chatbot and record which attacks succeed
- Add input and output guardrails and measure how often they block good requests
Steps
Step 1: 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.
Read first: evals start with reading outputs, not picking metrics.
Step 2: 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.
Step 3: 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.
Step 4: 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.
Optional: once you have a metric you trust, let an optimiser tune the prompt and compare it with your hand-written one on held-out examples.
Step 5: Add tracing and cost tracking to an LLM app
One trace per user action, with tokens, latency and cost for each model call, so slow and costly features stand out.
Step 6: Prompt injection basics for builders
How direct and indirect prompt injection work, why agents with tools raise the stakes, and the design choices that limit the damage when no complete fix exists.
Step 7: Red-team your chatbot for prompt injection
Generate attacks for its purpose, confirm each failure by hand, apply mitigations and re-run.
Step 8: 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.
Turn what the red-team run found into input and output checks, then measure how often they block good requests.
Step 9: 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.
Optional if you do not run a retrieval system.
Evals and safety quiz
7 questions with explanations. Your score is saved when you are signed in.
Final quiz
Related 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.
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.
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.