The Problem
You have built a RAG-powered support bot for an insurance company. Users are complaining:- “The bot said my claim was covered, but it wasn’t”
- “It gave me the wrong deductible amount”
- “It pulled up completely irrelevant policy sections”
What You Will Learn
- How to measure retrieval quality with context recall, precision, and utilization
- How to measure generation quality with faithfulness, groundedness, and answer relevancy
- How to diagnose four common failure modes: good pipeline, hallucinating LLM, bad retrieval, noisy retrieval
- How to run a RAG scorecard that tests all metrics at once
Prerequisites
Case A: Everything Works
Start with a well-functioning pipeline to establish a baseline. The retriever finds the right chunks, and the LLM generates a faithful answer.Case B: Good Retrieval, Bad Generation (Hallucination)
The retriever finds the right chunks, but the LLM invents facts not in the context.augment=True for higher accuracy.
Case C: Bad Retrieval, Faithful Generation
The retriever pulls completely wrong documents (dental coverage instead of physical therapy), but the LLM faithfully summarizes what it was given.Case D: Noisy Retrieval
The retriever returns a mix of relevant and irrelevant chunks. Two out of four chunks are noise (holiday schedule, IT help desk).RAG Scorecard: All Metrics at Once
Run all metrics in a single batch call to get a quick health check of your pipeline.RAG Debugging Checklist
What to Try Next
Now that you can diagnose RAG failures, protect your pipeline’s inputs from attacks.Next: Guardrails
Build a sub-10ms security middleware that blocks jailbreaks, code injection, PII leaks, and secret exposure.