14 Evaluating RAG systems
This chapter covers
- Classical retrieval metrics and why they mislead in RAG
- The RAGAS evaluation triad: faithfulness, relevance, context
- LLM-as-judge techniques from G-Eval through ARES
- Generating synthetic evaluation datasets from your corpus
- Building evaluation pipelines that diagnose failure points
Three weeks into improving a compliance assistant, a team at a mortgage lender added a cross-encoder reranker. Retrieval improved: the documents coming back were now the ones that answered the question. They shipped.
Faithfulness fell: the answers drifted away from the documents behind them. Nothing caught it. The score was lower than the week before and still above the threshold the team had set, and a threshold cannot see a trend. An engineer did, by setting last week's report beside this week's. The case study at the end of this chapter takes the regression apart claim by claim.
That failure has two halves, and this chapter is about both. The system got worse in a way its own tests were configured not to report. And the measure that moved was not the measure anyone was working on. Both problems yield to measuring differently, which for most of this chapter means asking a language model.