Lesson 5.4 · 8 min read · about 55 min to master at a very slow pace
Evaluating RAG and Agents in Production
The metrics that matter for RAG answers (faithfulness, answer relevance, correctness, refusal behaviour) and for agents (task success, steps, cost), plus offline regression suites, online monitoring and user feedback as one evaluation loop.
The RAG metrics
| Metric | Question it answers | How to score |
|---|---|---|
| Context recall | Did retrieval find the evidence? | Recall@k against labelled chunks (lesson 5.2) |
| Faithfulness (groundedness) | Is every claim supported by the retrieved sources? | LLM judge, claim by claim |
| Answer relevance | Does it address the question asked? | LLM judge |
| Correctness | Does it match the reference answer? | LLM judge against the reference, or exact match for facts |
| Refusal accuracy | Does it refuse when it should, and only then? | Should-refuse and should-answer test cases |
| Citation accuracy | Do the cited sources support the cited claims? | Code check + LLM judge |
Faithfulness and correctness differ: an answer can faithfully repeat an outdated source (faithful but incorrect) or be right from the model's general knowledge (correct but unfaithful). For client systems you usually want both.
Agent metrics
- Task success rate: did it achieve the goal? Best checked on the end state (was the right ticket created with the right fields?) rather than on the text it wrote.
- Steps and tool calls per task; cost and latency per task.
- Tool-call accuracy: right tool, valid arguments.
- Safety: actions attempted without approval, policy violations (should be zero).
Agents are non-deterministic: run each task several times and report the rate, not a single pass or fail.
Offline and online, one loop
- Offline: the eval set runs in CI on every change. Release only if no metric regresses beyond its noise.
- Online: in production, sample real conversations and run the judges on them; track refusal rate, latency, cost and errors on a dashboard.
- User feedback: thumbs up/down, "was this helpful?", escalations to a human, edits to drafts. Cheap signals; low-rated cases go to review.
- Close the loop: reviewed failures become new eval cases, and the next change is tested against them.
A release decision
A new reranker raises context recall from 0.82 to 0.90 and correctness from 78% to 84% on 300 cases, with faithfulness unchanged at 96%, and adds 150 ms latency. Standard error on 300 cases at 80% is about 2.3 points, so the 6-point gain is real. Ship it, and watch latency online.
Stuck? Common doubts
Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.
First passDo I need an evaluation platform?
Not to begin. A spreadsheet or JSON file of cases, a script that runs the system and the judges, and a results table work. Platforms help with tracing, dataset versioning, comparing runs and online sampling; adopt one when the number of cases, people or releases makes the script painful.
Going deeperIs it acceptable to run judges on real user conversations?
It can be, but it is processing of personal data. Tell users in the privacy notice, minimise what you keep, redact personal details where possible, and make sure the judge model's provider terms (data retention, region) fit the client's requirements (lesson 6.3).
Cheatsheet
RAG metrics
Faithful vs correct
Agent metrics
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.