Building a Retrieval-Augmented Generation (RAG) prototype takes an afternoon, as shown in our runnable Python RAG tutorial. Making it reliable in production requires separating retrieval quality from generation quality using a repeatable evaluation dataset.
1. Labeled Dummy Golden Dataset (3 Examples)
golden_set = [
{"q": "Max webhook payload?", "expected_doc": "webhooks.md", "facts": ["256 KB", "HTTP 413"]},
{"q": "Token expiry window?", "expected_doc": "auth.md", "facts": ["15 minutes"]},
{"q": "Free tier rate limit?", "expected_doc": "limits.md", "facts": ["60 req/min"]}
]2. Worked Metric Calculations
- Context Recall (Retrieval): Suppose top-3 retrieval returned
webhooks.mdandauth.md, but missedlimits.md. Context Recall = 2 / 3 = 66.7%. Fix: improve chunking or add BM25 hybrid search. - Answer Faithfulness (Generation): Suppose the generated answer states 4 claims, 3 of which appear verbatim in the retrieved chunks and 1 invents an unstated retry delay. Faithfulness = 3 / 4 = 75.0%. Fix: tighten grounding instructions and abstain when context is missing.
3. Workflow
Run this small evaluation script before every embedding, chunk-size, or prompt change so you catch regressions before users do.