Module 1 · Beyond naive RAG

The 7 classic failure points

6 min read

When a RAG gives a wrong answer, the temptation is to switch models or rewrite the prompt. But the error can come from seven different places, and most of them are upstream of generation. This lesson presents the seven classic failure points of a RAG pipeline — a typology drawn from published experience reports on real systems — and, above all, the method for finding which one is at fault.

The seven failure points

#FailureSymptomWhere to act
1Missing contentThe answer is not in the database; the system answers anywayCorpus; ability to say "I don't know"
2Right document not retrievedIt exists, but is not in the resultsEmbeddings, hybrid search, chunking, query
3Retrieved but not in contextIt is retrieved, but too low: cut off by the k or context limitRe-ranking, k, passage size
4In context but not extractedThe model received it but does not use it (lost in noise, contradictions)Fewer, more relevant passages, order, prompt
5Wrong formatThe information is there, but not in the requested form (table, list)Prompt, structured outputs
6Wrong specificityToo general or too detailed for the questionPrompt, clarifying the question
7Incomplete answerOnly part of the answer is givenDecomposition, multi-source, agent

The first four points concern retrieval and context; the last three concern generation. Experience shows that most errors of a production RAG sit in the first half of the table.

Diagnose before fixing

For a failing question, three questions, in order, are enough to locate the problem:

  1. Is the answer in the corpus? If not, it is point 1: no retrieval technique will find it. The corpus must be completed, and the system must admit its ignorance instead of inventing.
  2. Is the right passage among the retrieval results? If not, points 2 or 3: the problem is in retrieval.
  3. Did the model receive the right passage? If it received it but answers badly, points 4 to 7: the problem is in generation.

This approach requires being able to observe every step: the retrieved passages, their scores, the context actually sent. A pipeline where you only see the question and the answer is a pipeline you cannot improve (lesson 5.4).

Measuring retrieval: recall, MRR, nDCG

Retrieval is measured separately from generation, with a set of questions whose relevant documents are known. Prism uses three metrics, computed at the article level (the chunking can change, the test set stays valid):

def recall_at_k(ranked: list[str], relevant: list[str], k: int) -> float:
    return len(set(ranked[:k]) & set(relevant)) / len(relevant)


def reciprocal_rank(ranked: list[str], relevant: list[str]) -> float:
    return next((1 / i for i, a in enumerate(ranked, start=1) if a in relevant), 0.0)


def ndcg_at_k(ranked: list[str], relevant: list[str], k: int) -> float:
    dcg = sum(1 / math.log2(i + 1) for i, a in enumerate(ranked[:k], start=1) if a in relevant)
    ideal = sum(1 / math.log2(i + 1) for i in range(1, min(len(relevant), k) + 1))
    return dcg / ideal
MetricQuestionFailure point measured
Recall@kAre the relevant documents in the top k?2
MRRAt what rank does the first relevant document appear?3
nDCG@kAre all relevant documents ranked high?2 and 3

Recall tells whether the information can reach the model; MRR and nDCG tell whether it arrives in a good position. Both matter: a relevant passage ranked fifth out of five risks being ignored by the model (point 4), or cut off if k is reduced.

Reading a report by question type

A global average hides what matters. Prism breaks recall down by question type, and that breakdown is what guides the fixes:

Configuration      R@5   MRR   anglais  factuelle  lexicale  multi  reformulée
BM25              0.74  0.70     0.00       1.00      1.00   1.00        0.55
Dense             0.90  0.82     0.92       0.90      1.00   0.75        0.90

(The columns are the French type names: English, factual, lexical, multi-source, rephrased.) You can read immediately that BM25 fails on English and on rephrasings (point 2: different vocabulary), and that dense search misses a quarter of multi-source questions (point 7 in the making: only one of the needed articles is retrieved). The two failures do not call for the same fix — lesson 3.1 shows that a single technique, hybrid search, fixes both.

The report also lists the failing questions one by one. Always read them: a 90% average can hide that every question on one topic fails.

Generation failures can be measured too

Points 4 to 7 are measured with an LLM judge, which checks for instance that every claim in the answer is supported by the context (faithfulness), or that everything needed was in the context (context recall). Module 5 is devoted to them. The rule of order stays the same: fix retrieval first, because a perfect generation from a bad context is still a bad answer.

Key takeaways

  • Seven failure points: missing content, not retrieved, badly ranked, not used, wrong format, wrong specificity, incomplete answer.
  • Diagnosis in three questions: does the answer exist, is it retrieved, is it received by the model?
  • Recall@k measures whether the information is retrieved; MRR and nDCG whether it is well ranked.
  • Break down by question type and read failures one by one: the average hides the causes.
  • Fix retrieval before generation.

Practice

  1. For each failing BM25 question in the test bench, identify the failure point involved.
  2. Compute by hand recall@3, MRR and nDCG@3 for the ranking ["a", "b", "c"] with relevant documents ["b", "c"].
  3. Add the MRR per question type to the report in prism/metrics.py.

Resources