RAG Evals: Is It Retrieval or Generation That Broke?
Short answer: when a RAG app gives a wrong answer, the fault is in retrieval (the right chunk was not found), in generation (the model ignored or added to the chunk), or in the question. Measure the two parts separately. Retrieval hit rate tells you if the right chunk came back. Faithfulness and correctness tell you what the model did with it. The free Evals Lab has a script for each.
Why one score is not enough
A single "correctness" score hides where the failure is. Developers on Reddit ask the same thing, for example in [How do you evaluate RAG retrieval quality in production?](https://www.reddit.com/r/Rag/comments/1x1jtsq/how_do_you_evaluate_rag_retrieval_quality_in/) and [How are you guys testing your RAG beyond the usual accuracy metrics?](https://www.reddit.com/r/Rag/comments/1y7q3tn/how_are_you_guys_testing_your_rag_beyond_the/). A common answer is to measure retrieval (hit rate, precision, recall) and generation (faithfulness, correctness) on their own.
The diagnosis table
| What you see | Most likely cause | What to change | |---|---|---| | Right chunk not in the results | Retrieval | Chunk size or overlap, chunking method, number of chunks (k), embedding model | | Right chunk found, answer wrong | Generation | The prompt, or a stronger model | | Answer true but not in the chunks | Faithfulness | Tell the model to use only the context | | Answer ignores the question | Relevance | The prompt | | Everything fails on one topic | The document or the question | Check the expected answer |
Step 1: did retrieval find the chunk?
The lab includes `01_retrieval_hit_rate.py`. For every question generated from a chunk, it asks the vector database for the top K chunks and checks whether the source chunk is among them. It runs two searches side by side: by meaning (ChromaDB vectors) and by keyword (BM25). If the hit rate is low, no prompt will fix the answers. Change the chunking in the Documents tab and run it again.
It only works for questions that know their source chunk, which are the ones generated in the Test cases tab. Questions you wrote yourself do not have one.
Step 2: did the model use the chunk?
`run_eval.py` passes the retrieved chunks to the judge as `retrieval_context`. That makes it possible to add DeepEval's **Faithfulness** metric (`build_faithfulness_metric()` in `eval_criteria.py`), which checks whether every claim in the answer is supported by the chunks. Correctness compares the answer with the expected answer. Read them together:
- Correct **and** faithful: the app works for this question.
- Correct but **not** faithful: right by luck, from the model's own knowledge. This will break when the question moves outside what the model knows.
- Faithful but **not** correct: retrieval fetched a chunk that does not answer the question.
Step 3: stress it
Add questions that are hard on purpose: ones that need two chunks, ones with different wording from the document, and ones the document cannot answer. Put them in `goldens.csv`. See how to build a golden dataset.
Run it
Open the Evals Lab, generate test questions, run `python 01_retrieval_hit_rate.py`, then `python run_eval.py`. Open the MLOps panel to compare runs.
Related tool pages
- LLM as a Judge Playground: Grade AI Answers Free: Try LLM as a judge free on your laptop: write a judge prompt or a DeepEval G-Eval metric, run it on every test question and read a score and a reason for each answer.
- RAG Evaluation Playground: Test Chunking and Retrieval: Evaluate a RAG app free on your computer: chunk a document into ChromaDB, test retrieval by meaning, grade every answer and compare chunk sizes side by side in MLflow.
- DeepEval Playground: Try G-Eval Free on Your Laptop: Learn DeepEval hands-on, free: a Python IDE with a ready G-Eval project, goldens.csv, your own Gemini, Claude or OpenAI key and MLflow tracking. Runs in Docker.
- Chunk a Document Into ChromaDB: Free Local Vector DB: Upload a document, pick a chunking method and see every chunk and vector stored in ChromaDB, free in Docker. Then connect your own AI agent to that database. No API key.
Also try
- Which chunk size is best for RAG?
- Chunk a document into ChromaDB
- DeepEval G-Eval: write evaluation steps
How to use the Evals Lab: step by step
- Generate test questions from your chunks
- Run python 01_retrieval_hit_rate.py
- Run python run_eval.py and read the reasons
- Change one thing and run both again
When to use the Evals Lab
- Finding out whether to fix chunking or the prompt
- Comparing vector search with keyword search
- Catching answers that are right by luck
- Debugging a RAG app that fails on one topic
Example
Input: northwind_support_handbook.txt, chunked and stored in ChromaDB
Output: A score and a reason for every answer, and each run logged in MLflow
Frequently asked questions
How do I know if my RAG problem is retrieval or generation?
Check whether the right chunk is in the retrieved results (hit rate). If it is and the answer is still wrong, the problem is generation. If it is not, fix retrieval first.
What is faithfulness?
A check that every claim in the answer is supported by the retrieved chunks. It catches answers that are true but not grounded in your documents.
Does the lab compare vector and keyword search?
Yes. 01_retrieval_hit_rate.py reports the hit rate for ChromaDB vector search and for BM25 keyword search on the same questions.
Tip: Always fix retrieval first. A perfect prompt cannot answer from a chunk that was never fetched.