RAG (Retrieval-Augmented Generation) combines retrieving relevant documents and generating answers. The key metrics are retrieval accuracy (how well the system finds useful documents) and generation quality (how correct and fluent the answer is). Retrieval accuracy is often measured by recall or precision on retrieved documents. Generation quality is measured by metrics like BLEU, ROUGE, or human evaluation. Both matter because good retrieval helps the generator produce better answers.
RAG architecture overview in Prompt Engineering / GenAI - Model Metrics & Evaluation
Retrieval Results Confusion Matrix (example):
Retrieved Relevant Retrieved Not Relevant
Relevant Docs TP = 80 FN = 20
Not Relevant Docs FP = 15 TN = 85
Total Docs = 200
Precision = TP / (TP + FP) = 80 / (80 + 15) = 0.842
Recall = TP / (TP + FN) = 80 / (80 + 20) = 0.8
Generation quality is often evaluated separately using scores like BLEU or ROUGE, not confusion matrices.In RAG, precision means the retrieved documents are mostly relevant, so the generator gets good info. Recall means the system finds most of the relevant documents, even if some irrelevant ones sneak in.
Example: If you want very accurate answers, high precision is important so the generator is not confused by bad info. But if you want to make sure no important info is missed, high recall is key.
For example, a medical question answering system should have high recall to avoid missing critical info, even if some irrelevant documents are retrieved. A customer support bot might prefer high precision to avoid giving wrong answers.
- Good retrieval precision: Above 0.8 means most retrieved docs are relevant.
- Good retrieval recall: Above 0.75 means most relevant docs are found.
- Good generation quality: BLEU or ROUGE scores above 0.5 (50%) are decent; human evaluation should confirm fluency and correctness.
- Bad values: Precision or recall below 0.5 means poor retrieval, leading to bad answers. BLEU/ROUGE below 0.3 usually means poor generation quality.
- Ignoring retrieval quality: Good generation scores alone can hide poor retrieval, causing unreliable answers.
- Overfitting to training data: High scores on training but poor real-world retrieval or generation.
- Data leakage: If test documents appear in training, metrics look falsely high.
- Accuracy paradox: High overall accuracy but poor recall on rare but important documents.
Your RAG model has 98% accuracy on generated answers but only 12% recall on retrieving relevant documents. Is it good for production? Why or why not?
Answer: No, it is not good. The low recall means the system misses most relevant documents, so the generator may not have enough info to answer well in many cases. High accuracy alone is misleading if retrieval is poor.