Skip to content
Blog

Where did the fact die? Root-causing a wrong RAG answer

Aggregate RAG scores tell you something is wrong, not where. How to trace each expected fact through parsing, chunking, retrieval, ranking, assembly and generation, and name the stage that lost it.

Mohamad Al Assaad11 min read

A RAG system gives a wrong answer. The dashboard says faithfulness is fine, answer relevance is fine, context recall has dropped a little. You now know something is wrong. You do not know what to fix. Was the fact lost when the document was parsed, cut in two by the chunker, never retrieved, pushed out by the reranker, trimmed from the prompt, or ignored by the model? Each of those has a different fix, and guessing wrong costs a week.

This post describes a method for answering that question: follow each expected fact through the pipeline and report the first stage that lost it, with the evidence. It is the method behind FactPath, a tool I built for this.

1. What today’s evaluation tools measure

The current tools are good, and I use ideas from all of them. As of October 2026:

All of these answer “how good is it” and, at best, “retriever or generator”. Two gaps remain. First, little looks upstream of retrieval, where parsing and chunking quietly lose facts. A 2026 taxonomy of failure modes, built from a literature review, finds that retrieval and generation have had most of the research attention, while representation, evaluation and orchestration failures have had the least, although they are common in production. Second, the stage where a symptom shows is often not the stage where it starts. A study of 654 configuration issues in real RAG systems puts it plainly: “the stage of the root cause might not be at the same stage as where the symptom is identified” (Chen et al., October 2026).

Leung et al. classify each erroneous answer by stage and error type with an LLM cascade over gold chunks (EACL 2026); they report that stage classification agreed with human labels 57.8% of the time, and call the problem challenging. For multi-hop agents, AgenticRAG-FP injects a known fault at a chosen hop and checks whether diagnosers find it.

2. Anchor every expected fact to a span

Attribution needs something to follow. A question and a reference answer are not enough. You need the fact, the values that must survive, and the exact passage of the source that holds it.

{
  "question": "How much does a bailiff's check-in report cost for a flat of 50 m² or less?",
  "facts": [{
    "statement": "Up to 50 m², the report fee is 132,82 €.",
    "essential": true,
    "key_values": ["132,82 €"],
    "evidence": [[{
      "doc_id": "F31270",
      "doc_hash": "sha256:…",
      "start": 18420, "end": 18531,
      "quote": "Jusqu'à 50 m² | Frais de constat locatif : 132,82 €",
      "prefix": "…32 characters before…",
      "suffix": "…32 characters after…"
    }]]
  }]
}

Three habits make this work. Anchor to the source document, not to a chunk ID, or the golden set breaks when you change the chunker. Store offsets and the quote with its context, the same pairing the W3C annotation model uses for its position and quote selectors: offsets make lookups exact, the quote lets you find the passage again when the page is edited. And store the hash of the document version the fact was written against, so that a changed page is caught when the golden set is compiled, not three weeks later in a confusing failure.

The quote, offsets and hash above are illustrative. Write the facts as quotes and let a script compute the offsets. Nobody should maintain character positions by hand.

3. Measure five stages, judge one

With anchors in hand, most of the pipeline can be checked without a model. It comes down to string alignment and rank arithmetic, which makes it free, fast and reproducible.

Stage Question Measured how Cause if it fails
Parsing Is the quote in the parsed text, in the right version? Exact, then normalised, then fuzzy match; key values present; hash compared lost in parsing, degraded in parsing, stale document
Chunking Does one chunk hold it whole? Span mapped onto chunk offsets; one chunk must cover nearly all of it with its key values split by chunking, dropped at indexing
Retrieval Was that chunk a candidate at all? Look it up in the deep candidate list not retrieved
Ranking Did it make the top k, before and after reranking? Compare both ranks with k ranked too low, demoted by reranker
Assembly Did it reach the prompt intact? Logged prompt entries and truncation flags cut at assembly
Generation Did the answer use it? LLM judge: entailed, contradicted or omitted, with the answer span ignored, contradicted, wrongly abstained, should have abstained

That is 13 root causes across six stages. Only the last row needs a judge, and it is the only one where you should spend money on calibration against human labels.

The decision rule is short: the first point of loss wins. A reranker cannot rescue a fact the parser destroyed, so the parser gets the blame; anything that went wrong downstream is kept as a secondary cause. The core is a loop that stops at the first failure:

def first_loss(fact, trace) -> Verdict:
    for stage in (parsing, chunking, retrieval, ranking, assembly):
        result = stage.check(fact, trace)   # deterministic, no model
        if result.lost:
            return Verdict(stage.name, result.cause, evidence=result.evidence)
    return judge_generation(fact, trace.answer, trace.prompt)  # the only LLM call

Two refinements matter. A fact that the answer states correctly although its evidence never reached the prompt is a pass, but flag it as answered from memory: it will break the day the model or the facts change. And a question with several essential facts takes the most upstream cause among its failing facts.

A trace logged with Phoenix or LangSmith covers part of this. What it usually lacks is the parsed text, chunk offsets, a candidate list deeper than k and the rank before reranking. Those four fields turn a judgement into a measurement.

4. A worked example: the value that lives in a table

Take the service-public.fr page on the check-in inventory for a rental. For a flat up to 50 m² in mainland France, a bailiff’s report costs 132,82 €, plus 18,06 € for convocation letters and 11,28 € for travel: 162,16 € in all. Those figures exist only in a table.

Now plant a parser that drops tables, and ask the question from section 2. What follows is an illustration of the walk, not a log.

  1. Parsing. The exact quote is not in the parsed text. Neither is a normalised version. Fuzzy matching finds the nearest passage, a paragraph saying the bailiff’s fees are set by regulation, but the key value 132,82 € is absent. Verdict: lost in parsing. The evidence is the source row next to the parsed text after the nearest heading, so a reader can see the table is missing.
  2. Retrieval and ranking. The regulation paragraph is retrieved at rank 1 and enters the prompt. Every downstream stage looks healthy, because it is doing its job on the wrong input.
  3. Generation. The model answers that the fees are regulated and depend on the surface. That answer is faithful to its context and relevant to the question.

Here is how that answer scores on the usual dimensions:

Signal What it says What happened
Faithfulness High: every claim is supported True, and useless
Answer relevance High: on topic True, and useless
Context recall Low Points at retrieval, which worked
First loss Parsing, with the missing row shown The fix is the parser

Then the counterfactual check: put the anchored table row back into the prompt and regenerate. If the answer now says 132,82 €, the upstream cause is confirmed: nothing else was in the way. If it still fails, the parser verdict stands but its confidence drops, and “ignored” is added as a secondary cause, because the model would have failed anyway. It costs one extra generation per upstream failure.

Without this, you get the failure from the hybrid RAG post: a week of prompt tuning while tables were being dropped upstream. Parsing and chunking covers prevention.

5. Check the checker: plant defects one stage at a time

An attribution method is a classifier, and a classifier needs a test set. The cleanest one is a pipeline you break on purpose, one stage at a time: a parser that drops tables, fixed windows without overlap, an embedding model that does not speak the corpus language, a reranker that sorts by length, a context budget that is too small, a “legal caution” prompt that forbids quoting figures, an index built from older versions of some pages.

For each defect, run the golden set, and look only at the questions that newly fail against the unbroken baseline. Those failures are the defect’s doing. The score is the share of them attributed to the planted cause. “Share of all failures” is the wrong denominator: it mixes in the baseline’s own errors.

FactPath’s reference benchmark uses 32 official French housing pages from service-public.fr and 65 questions written by hand, answered by GLM 5.3 Flash. The baseline answers 91% of the questions. Then each stage was broken in turn:

Planted defect Newly failing questions attributed to it
Retrieval 100%
Stale index 100%
Parser 83%
Prompt 70%
Reranker 62%
Context assembly 62%
Chunking 44%

In all seven cases the planted cause is the most frequent verdict, and the eight live runs together cost less than 25 US cents.

Chunking at 44% is the weakest result, and the reason is instructive. Very small chunks do not only split facts across boundaries. They also strip the context that made a passage findable, so a fact that still sits whole in one chunk ranks below k. By the first-loss rule that is a ranking failure: the fact survived chunking and died at ranking. The reranker row shows a related effect: some gold chunks were below k before reranking, the baseline reranker lifted them and the broken one does not, which is “ranked too low” rather than “demoted”. The verdict answers “where was the fact lost”, not “which change broke it”. For the second question, compare runs.

One more lesson: a planted fault must actually hurt the model you test. An instruction the model shrugs off is a no-op, and validating against it proves nothing.

Common mistakes

  • Anchoring facts to chunk IDs. Rechunk once and the golden set is meaningless.
  • Asking an LLM whether a passage was retrieved. That is a lookup, not a judgement.
  • Logging only the top k. Without the deep candidate list you cannot tell “not retrieved” from “ranked too low”.
  • Ignoring document versions. A stale index looks exactly like a broken parser unless the trace records which version was indexed.
  • Counting a correct answer with no supporting evidence as a clean pass.
  • Treating answer relevance as a headline metric. It rewards on-topic waffle.

What this looks like in practice

  1. Fifty to a few hundred questions, each fact anchored to a source span with offsets, quote and document hash.
  2. A trace per question: parsed text, chunks with offsets, deep candidates, ranks before and after reranking, prompt entries with truncation flags, the answer.
  3. Five deterministic checks, one judged stage, first loss wins.
  4. A counterfactual regeneration for every upstream verdict.
  5. A set of planted defects, re-run whenever the attribution logic changes.

The output is not a score. It is a list: this many facts lost in parsing, this many ranked too low, each with the spans that prove it. That list tells you what to fix on Monday.

Sources