RAG Auditor
Systematic RAG pipeline evaluation across the full retrieval-generation chain: designs
evaluation query sets, measures retrieval metrics (Precision@K, Recall@K, MRR), evaluates
generation quality (groundedness, completeness, hallucination rate), diagnoses component-level
failures, and recommends targeted improvements.
Reference Files
| File |
Contents |
Load When |
references/retrieval-metrics.md |
Precision@K, Recall@K, MRR, NDCG definitions and calculation |
Always |
references/generation-metrics.md |
Groundedness, completeness, hallucination detection methods |
Generation evaluation needed |
references/failure-taxonomy.md |
RAG failure categories: retrieval, generation, chunking, embedding |
Failure diagnosis needed |
references/diagnostic-queries.md |
Designing evaluation query sets, known-answer questions, difficulty levels |
Evaluation setup |
Prerequisites
- Access to the RAG pipeline (or its outputs for post-hoc evaluation)
- A set of test queries with known-correct answers
- Understanding of the pipeline components (embedding model, retriever, generator)
Workflow
Phase 1: Pipeline Inventory
Document the RAG pipeline configuration:
- Document source — What documents are indexed? Format, count, size.
- Chunking — Strategy (fixed-size, semantic, paragraph), chunk size, overlap.
- Embedding — Model name and version, dimensionality.
- Vector store — Type (FAISS, Pinecone, Chroma, pgvector), index type.
- Retrieval — Method (similarity, hybrid, reranking), top-K parameter.
- Generation — Model, prompt template, context window usage.
Phase 2: Design Evaluation Queries
Create a diverse set of test queries:
| Query Type |
Purpose |
Count |
| Known-answer (factoid) |
Measure retrieval + generation accuracy |
10+ |
| Multi-hop |
Require combining info from multiple chunks |
5+ |
| Unanswerable |
Not in the corpus — should abstain |
3+ |
| Ambiguous |
Multiple valid interpretations |
3+ |
| Recent/updated |
Test freshness |
2+ |
For each query, document the expected answer and the source chunk(s).
Phase 3: Evaluate Retrieval
For each test query, measure:
- Precision@K — Of the K retrieved chunks, how many are relevant?
- Recall@K — Of all relevant chunks in the corpus, how many were retrieved?
- MRR (Mean Reciprocal Rank) — How high is the first relevant chunk ranked?
- Chunk relevance — Score each retrieved chunk: Relevant, Partially Relevant, Irrelevant.
Phase 4: Evaluate Generation
For each test query with retrieved context:
- Groundedness — Is every claim in the response supported by the retrieved context?
Score: 0 (hallucinated) to 1 (fully grounded).
- Completeness — Does the response use all relevant information from the context?
Score: 0 (ignored context) to 1 (complete).
- Hallucination detection — Identify specific claims not supported by context.
- Abstention — For unanswerable queries, does the model correctly say "I don't know"?
Phase 5: Diagnose Failures
For every incorrect or low-quality response, classify the root cause:
| Failure Type |
Diagnosis |
Indicator |
| Retrieval failure |
Relevant chunks not retrieved |
Low Recall@K |
| Ranking failure |
Relevant chunk retrieved but ranked low |
Low MRR, high Recall |
| Chunk boundary issue |
Answer split across chunk boundaries |
Partial matches in multiple chunks |
| Embedding mismatch |
Query semantics don't match chunk embeddings |
Relevant chunk has low similarity score |
| Generation failure |
Correct context but wrong answer |
High retrieval scores, low groundedness |
| Hallucination |
Model invents facts not in context |
Claims not traceable to any chunk |
| Over-abstention |
Model refuses to answer when context is sufficient |
Unanswered with relevant context present |
Phase 6: Recommendations
Based on failure analysis, recommend specific improvements:
| Failure Pattern |
Recommendation |
| Chunk boundary issues |
Increase overlap, try semantic chunking |
| Low Precision@K |
Reduce K, add reranking stage |
| Low Recall@K |
Increase K, try hybrid search |
| Embedding mismatch |
Try different embedding model, add query expansion |
| Hallucination |
Strengthen grounding instruction in prompt, reduce temperature |
| Over-abstention |
Soften abstention criteria in prompt |
Output Format
## RAG Audit Report
### Pipeline Configuration
| Component | Value |
|-----------|-------|
| Documents | {N} ({format}) |
| Chunking | {strategy}, {size} tokens, {overlap}% overlap |
| Embedding | {model} ({dimensions}d) |
| Retrieval | {method}, K={N} |
| Generation | {model}, temperature={T} |
### Evaluation Dataset
- **Total queries:** {N}
- **Known-answer:** {N}
- **Multi-hop:** {N}
- **Unanswerable:** {N}
### Retrieval Quality
| Metric | Score | Target | Status |
|--------|-------|--------|--------|
| Precision@{K} | {score} | {target} | {Pass/Fail} |
| Recall@{K} | {score} | {target} | {Pass/Fail} |
| MRR | {score} | {target} | {Pass/Fail} |
### Generation Quality
| Metric | Score | Target | Status |
|--------|-------|--------|--------|
| Groundedness | {score} | {target} | {Pass/Fail} |
| Completeness | {score} | {target} | {Pass/Fail} |
| Hallucination rate | {score} | {target} | {Pass/Fail} |
| Abstention accuracy | {score} | {target} | {Pass/Fail} |
### Failure Analysis
| # | Query | Failure Type | Root Cause | Recommendation |
|---|-------|-------------|------------|----------------|
| 1 | {query} | {type} | {cause} | {fix} |
### Recommendations (Priority Order)
1. **{Recommendation}** — addresses {N} failures, expected impact: {description}
2. **{Recommendation}** — addresses {N} failures, expected impact: {description}
### Sample Failures
#### Query: "{query}"
- **Expected:** {answer}
- **Retrieved chunks:** {chunk summaries with relevance scores}
- **Generated:** {response}
- **Issue:** {diagnosis}
Calibration Rules
- Component isolation. Evaluate retrieval and generation independently. A great
retriever with a bad generator looks like retrieval failure if you only check end output.
- Known answers first. Start with factoid questions where the correct answer is
unambiguous. Multi-hop and ambiguous queries are harder to evaluate.
- Quantify, don't qualify. "Retrieval is bad" is not a finding. "Precision@5 is
0.3 (target: 0.8) with 70% of failures due to chunk boundary splits" is actionable.
- Sample failures deeply. Aggregate metrics identify WHERE the problem is. Individual
failure analysis identifies WHY.
Error Handling
| Problem |
Resolution |
| No known-answer queries available |
Help design them from the document corpus. Pick 10 facts and formulate questions. |
| Pipeline access not available |
Work from recorded inputs/outputs. Post-hoc evaluation is possible with query-context-response triples. |
| Corpus is too large to review |
Sample-based evaluation. Select representative documents and generate queries from them. |
| Multiple failure types co-exist |
Address retrieval failures first. Generation quality cannot exceed retrieval quality. |
When NOT to Audit
Push back if:
- The pipeline hasn't been built yet — design it first, audit after
- The corpus has fewer than 10 documents — too small for meaningful retrieval evaluation
- The user wants to compare embedding models — that's a benchmark task, not an audit
1---2name: rag-auditor3description: Evaluates RAG pipeline quality across retrieval (precision, recall, MRR) and generation (groundedness, hallucination rate). Triggers on: "audit RAG pipeline", "RAG quality", "hallucination detection", "why is RAG failing", "grounding check". NOT for general architecture audits, use architecture-reviewer.4---56# RAG Auditor78Systematic RAG pipeline evaluation across the full retrieval-generation chain: designs9evaluation query sets, measures retrieval metrics (Precision@K, Recall@K, MRR), evaluates10generation quality (groundedness, completeness, hallucination rate), diagnoses component-level11failures, and recommends targeted improvements.1213## Reference Files1415| File | Contents | Load When |16| ---------------------------------- | -------------------------------------------------------------------------- | ---------------------------- |17| `references/retrieval-metrics.md` | Precision@K, Recall@K, MRR, NDCG definitions and calculation | Always |18| `references/generation-metrics.md` | Groundedness, completeness, hallucination detection methods | Generation evaluation needed |19| `references/failure-taxonomy.md` | RAG failure categories: retrieval, generation, chunking, embedding | Failure diagnosis needed |20| `references/diagnostic-queries.md` | Designing evaluation query sets, known-answer questions, difficulty levels | Evaluation setup |2122## Prerequisites2324- Access to the RAG pipeline (or its outputs for post-hoc evaluation)25- A set of test queries with known-correct answers26- Understanding of the pipeline components (embedding model, retriever, generator)2728## Workflow2930### Phase 1: Pipeline Inventory3132Document the RAG pipeline configuration:33341. **Document source** — What documents are indexed? Format, count, size.352. **Chunking** — Strategy (fixed-size, semantic, paragraph), chunk size, overlap.363. **Embedding** — Model name and version, dimensionality.374. **Vector store** — Type (FAISS, Pinecone, Chroma, pgvector), index type.385. **Retrieval** — Method (similarity, hybrid, reranking), top-K parameter.396. **Generation** — Model, prompt template, context window usage.4041### Phase 2: Design Evaluation Queries4243Create a diverse set of test queries:4445| Query Type | Purpose | Count |46| ---------------------- | ------------------------------------------- | ----- |47| Known-answer (factoid) | Measure retrieval + generation accuracy | 10+ |48| Multi-hop | Require combining info from multiple chunks | 5+ |49| Unanswerable | Not in the corpus — should abstain | 3+ |50| Ambiguous | Multiple valid interpretations | 3+ |51| Recent/updated | Test freshness | 2+ |5253For each query, document the expected answer and the source chunk(s).5455### Phase 3: Evaluate Retrieval5657For each test query, measure:58591. **Precision@K** — Of the K retrieved chunks, how many are relevant?602. **Recall@K** — Of all relevant chunks in the corpus, how many were retrieved?613. **MRR (Mean Reciprocal Rank)** — How high is the first relevant chunk ranked?624. **Chunk relevance** — Score each retrieved chunk: Relevant, Partially Relevant, Irrelevant.6364### Phase 4: Evaluate Generation6566For each test query with retrieved context:67681. **Groundedness** — Is every claim in the response supported by the retrieved context?69 Score: 0 (hallucinated) to 1 (fully grounded).702. **Completeness** — Does the response use all relevant information from the context?71 Score: 0 (ignored context) to 1 (complete).723. **Hallucination detection** — Identify specific claims not supported by context.734. **Abstention** — For unanswerable queries, does the model correctly say "I don't know"?7475### Phase 5: Diagnose Failures7677For every incorrect or low-quality response, classify the root cause:7879| Failure Type | Diagnosis | Indicator |80| -------------------- | -------------------------------------------------- | ---------------------------------------- |81| Retrieval failure | Relevant chunks not retrieved | Low Recall@K |82| Ranking failure | Relevant chunk retrieved but ranked low | Low MRR, high Recall |83| Chunk boundary issue | Answer split across chunk boundaries | Partial matches in multiple chunks |84| Embedding mismatch | Query semantics don't match chunk embeddings | Relevant chunk has low similarity score |85| Generation failure | Correct context but wrong answer | High retrieval scores, low groundedness |86| Hallucination | Model invents facts not in context | Claims not traceable to any chunk |87| Over-abstention | Model refuses to answer when context is sufficient | Unanswered with relevant context present |8889### Phase 6: Recommendations9091Based on failure analysis, recommend specific improvements:9293| Failure Pattern | Recommendation |94| --------------------- | -------------------------------------------------------------- |95| Chunk boundary issues | Increase overlap, try semantic chunking |96| Low Precision@K | Reduce K, add reranking stage |97| Low Recall@K | Increase K, try hybrid search |98| Embedding mismatch | Try different embedding model, add query expansion |99| Hallucination | Strengthen grounding instruction in prompt, reduce temperature |100| Over-abstention | Soften abstention criteria in prompt |101102## Output Format103104```text105## RAG Audit Report106107### Pipeline Configuration108| Component | Value |109|-----------|-------|110| Documents | {N} ({format}) |111| Chunking | {strategy}, {size} tokens, {overlap}% overlap |112| Embedding | {model} ({dimensions}d) |113| Retrieval | {method}, K={N} |114| Generation | {model}, temperature={T} |115116### Evaluation Dataset117- **Total queries:** {N}118- **Known-answer:** {N}119- **Multi-hop:** {N}120- **Unanswerable:** {N}121122### Retrieval Quality123124| Metric | Score | Target | Status |125|--------|-------|--------|--------|126| Precision@{K} | {score} | {target} | {Pass/Fail} |127| Recall@{K} | {score} | {target} | {Pass/Fail} |128| MRR | {score} | {target} | {Pass/Fail} |129130### Generation Quality131132| Metric | Score | Target | Status |133|--------|-------|--------|--------|134| Groundedness | {score} | {target} | {Pass/Fail} |135| Completeness | {score} | {target} | {Pass/Fail} |136| Hallucination rate | {score} | {target} | {Pass/Fail} |137| Abstention accuracy | {score} | {target} | {Pass/Fail} |138139### Failure Analysis140141| # | Query | Failure Type | Root Cause | Recommendation |142|---|-------|-------------|------------|----------------|143| 1 | {query} | {type} | {cause} | {fix} |144145### Recommendations (Priority Order)1461. **{Recommendation}** — addresses {N} failures, expected impact: {description}1472. **{Recommendation}** — addresses {N} failures, expected impact: {description}148149### Sample Failures150151#### Query: "{query}"152- **Expected:** {answer}153- **Retrieved chunks:** {chunk summaries with relevance scores}154- **Generated:** {response}155- **Issue:** {diagnosis}156```157158## Calibration Rules1591601. **Component isolation.** Evaluate retrieval and generation independently. A great161 retriever with a bad generator looks like retrieval failure if you only check end output.1622. **Known answers first.** Start with factoid questions where the correct answer is163 unambiguous. Multi-hop and ambiguous queries are harder to evaluate.1643. **Quantify, don't qualify.** "Retrieval is bad" is not a finding. "Precision@5 is165 0.3 (target: 0.8) with 70% of failures due to chunk boundary splits" is actionable.1664. **Sample failures deeply.** Aggregate metrics identify WHERE the problem is. Individual167 failure analysis identifies WHY.168169## Error Handling170171| Problem | Resolution |172| --------------------------------- | ------------------------------------------------------------------------------------------------------- |173| No known-answer queries available | Help design them from the document corpus. Pick 10 facts and formulate questions. |174| Pipeline access not available | Work from recorded inputs/outputs. Post-hoc evaluation is possible with query-context-response triples. |175| Corpus is too large to review | Sample-based evaluation. Select representative documents and generate queries from them. |176| Multiple failure types co-exist | Address retrieval failures first. Generation quality cannot exceed retrieval quality. |177178## When NOT to Audit179180Push back if:181182- The pipeline hasn't been built yet — design it first, audit after183- The corpus has fewer than 10 documents — too small for meaningful retrieval evaluation184- The user wants to compare embedding models — that's a benchmark task, not an audit