Why RAG retrieves relevant documents but still gives wrong answers
Trace a wrong RAG answer through source coverage, retrieval, context assembly, and generation, then choose a diagnostic that targets the failing boundary.
The direct answer
Relevant documents may discuss the right topic while omitting the facts needed to answer a particular question. Trace those required facts from the current source through retrieval and the exact context sent to the model, then check the answer claim by claim; the first missing or misused fact tells you what to investigate next.
Define what the answer must establish
Start with one failed question and write down the facts a satisfactory answer must establish. Include the entity, product version, region, date, and requested exceptions when they change the answer. “The documents discuss exports” is a weaker finding than “the documents establish this plan's scheduling entitlement and retention period.”
A retriever selects candidates according to its matching method. Haystack's retriever documentation describes scoring and returning candidates, including approximate search in many dense retrieval implementations. That operation does not certify that the selected passages jointly establish every required fact. Haystack Retrievers
For the failing request, preserve four inspectable artifacts within the application's existing data-access rules:
- The question as asked, relevant conversation context, and the query actually used for retrieval.
- Retrieved passage text and IDs, source revisions, effective filters, ranks, and the passages retained after reranking.
- The final messages or rendered prompt sent to the model, including source labels and any trimming or summaries.
- The generated answer, its citations, and the model and prompt versions.
Record the authoritative passages that support the expected answer separately. A source URL alone is insufficient for comparison if its contents can change. This record is a proposed debugging method, not a claim that a tracing integration captures these fields automatically.
The distinction between evidence selection, faithful use, and response quality follows the original RAGAS paper. The boundary-by-boundary procedure below is editorial synthesis: it turns those separate questions into checks on a concrete request.
Follow the evidence until it disappears
Use this decision tree when the answer is wrong despite plausible search results. At each step, inspect the evidence for the required facts, not just a document title or similarity score. If the answer to a check is unknown, collect that artifact before treating the check as passed.
- Source coverage: Find current, authoritative evidence for each required fact in the corpus the application may use. If it exists in the original document, verify that ingestion preserved it in the searchable representation, including table headers and qualifiers. If it does not exist or access excludes it, choose a source update, an authorized source lookup, clarification, or an explicit statement of uncertainty.
- Retrieval and ranking: Locate those passages in the results before and after ranking and filtering. If they are indexed and eligible but absent, inspect the query, filters, matching method, and cutoffs.
- Context assembly: Compare the retained passages with the final model input. A correct search result can still lose its date, table header, exception, or entire paragraph during rendering, deduplication, summarization, or trimming.
- Answer generation: If sufficient, applicable evidence reached the model, identify the exact unsupported, contradicted, or omitted answer claim. Investigate how the prompt and model used that evidence.
The first failed check selects the next investigation; it does not establish that downstream behavior is sound. Missing evidence and a model that guesses instead of acknowledging the gap can both need correction. After repairing a boundary, repeat the downstream checks.
Conceptual decision tree: where did the needed facts go?
Work through a relevant-but-insufficient result
Hypothetical example. AcmeFiles, its plans, documents, dates, and responses below are invented to illustrate diagnosis. No RAG system was run.
A user asks: “For an AcmeFiles Starter workspace in the EU on 19 September 2026, can I schedule daily exports, and how long are those exported files retained?”
Suppose the retrieved passages are:
| Passage | What it actually establishes | What remains missing |
|---|---|---|
| D1: The export overview says every workspace can manually export CSV files. | Manual export availability. | Whether Starter EU supports scheduled exports. |
| D2: The scheduler guide explains daily schedules for eligible plans. | A daily scheduling capability exists. | Which plans and regions are eligible on the requested date. |
| D3: A Pro-plan guide gives a 30-day retention period for scheduled exports. | A retention rule scoped to Pro. | The retention rule for Starter EU scheduled exports. |
An imagined answer, “Yes, schedule a daily export; the files are retained for 30 days,” answers the right topics but makes two unsupported moves: it assumes Starter eligibility and transfers a Pro retention rule to Starter. Adding citations to D2 and D3 would make those moves traceable, not valid.
Write the missing evidence explicitly:
| Required fact | Evidence that would settle it |
|---|---|
| Daily scheduling is available for this plan, region, and date. | An applicable entitlement entry with its effective date. |
| The scheduled files have a particular retention period. | An applicable retention rule for that export type, plan, and region. |
With only D1–D3, an appropriate response would explain that the passages establish manual export and eligible-plan scheduling, but do not establish Starter EU eligibility or retention. It should seek the missing evidence if the application supports that lookup. The absence of an entitlement in these snippets does not establish that the feature is unavailable.
Now suppose two additional, authoritative fictional entries exist: E1 enables daily scheduling for Starter EU from 1 September 2026; E2 specifies seven-day retention for Starter EU scheduled exports. Assume neither has been superseded at the question's date. Together they support “Yes; seven days,” with a citation for each claim.
The next action depends on where E1 and E2 went. If they were never ingested, repair coverage. If indexed but missing from candidates, inspect retrieval. If selected but E2 was trimmed, inspect assembly. If both reached the model and it still chose Pro's 30-day rule, inspect evidence use. Changing chunk size is a candidate only when the trace shows a chunk boundary separating a needed fact from its scope.
Measure coverage, grounding, and correctness separately
The Ragas metric catalog contains separate measures because these questions need different evidence. Use the following distinctions when choosing a diagnostic; the rows are not interchangeable quality scores.
| Diagnostic question | Useful input and documented measure | What the result cannot establish |
|---|---|---|
| Retrieval coverage: Did the required evidence arrive? | With a vetted reference answer, Ragas LLM-based Context Recall checks whether its claims are supported by retrieved contexts. | Whether the reference omitted an important exception; whether the model later used the evidence correctly. |
| Retrieval ordering: Are useful passages ranked ahead of distractions? | Context Precision assesses the order of relevant retrieved chunks. Its reference-based variant uses a reference answer. | Whether all necessary facts were retrieved. Several well-ranked passages may cover the same partial fact. |
| Grounding: Are the answer's claims supported by the context supplied? | Faithfulness decomposes the response into claims and checks support in context. For this diagnosis, supply the passages actually given to the generator. | Whether the sources are current and authoritative, or whether the answer omitted part of the question. |
| Answer correctness: Does the answer agree with the applicable facts? | Factual Correctness compares response and reference claims, with precision, recall, or F1 modes. Pair this with explicit checks for the required date, scope, and values. | Truth beyond the reference's coverage, or correctness of the judge's claim decomposition. |
| Answer relevance: Does the response address the question? | Response Relevancy evaluates alignment between question and response. | Factual accuracy: the documentation explicitly excludes it from this measure. |
Definitions: Context Recall, Context Precision, Faithfulness, Factual Correctness, and Response Relevancy.
An answer can faithfully repeat a stale policy and still be wrong for today's question. It can also state a true fact from model knowledge without support in the retrieved passages. Those are different defects under a requirement for answers supported by current sources.
When a reference answer is unavailable, inspect answer-to-context support and collect the missing reference evidence. Do not substitute the system's own answer as an independent completeness standard: omitted facts would then disappear from both sides of the check. Ragas also documents context-recall variants using reference passages or passage IDs; select one only when those labels represent the evidence the task actually requires. Context Recall
Choose a change that matches the observed failure
This table gives proposed investigations, not guarantees about which configuration will win.
| Observation from the trace | Next diagnostic | Change justified if confirmed |
|---|---|---|
| The authoritative original contains the fact, but the searchable text does not. | Compare extracted text, table structure, source revision, and indexed content. | Repair parsing or refresh ingestion before tuning retrieval. |
| The fact is indexed but excluded for this query. | Inspect the effective filters and the user's permitted scope. | Correct an unintended filter; preserve intentional access restrictions. |
| The required eligible passage ranks poorly or is absent from candidates. | Compare the actual query with its wording and identifiers; examine ranks before and after reranking. | Try a targeted query, keyword/dense combination, or candidate budget change, then verify required-fact coverage. |
| The passage is found but its exception or column heading is separate. | Inspect the chunk with its neighboring text and original layout. | Preserve the relevant structure or retrieve the needed surrounding context. |
| The retained result contains the fact, but the final prompt does not. | Diff the passage against rendered messages and summaries; inspect trimming. | Fix the assembly step that removed or changed it. |
| Correct and superseded rules both reach the model. | Check whether effective dates and authority are preserved and a precedence rule exists. | Resolve supersession from source metadata or state the unresolved conflict. |
| Complete, applicable evidence reaches the model but the answer ignores it. | Check the faulty claim against the exact input and prompt requirements. | Evaluate clearer scope instructions, claim-level source use, or a different model on that case. |
Haystack documents both combining retrieval methods and applying metadata filters; these are concrete examples of controls at the retrieval boundary. They do not repair facts absent from the source. Retrievers
Assembly deserves its own check. In Haystack documentation version 3.1, PromptBuilder renders supplied variables into a template. The documented default requires all template variables; if a variable is explicitly made optional and omitted, it is replaced with an empty string. A successful render therefore needs to be interpreted alongside that configuration, and even a required variable's presence does not prove its contents are sufficient. Inspect the actual rendered text. PromptBuilder
Use controlled comparisons to narrow the cause
After finding a suspected boundary, test one change at a time against the captured failure. These are suggested comparisons for the reader to perform, not experiments reported by this guide.
| Comparison | What to keep fixed | What the result would suggest |
|---|---|---|
| Substitute a small, manually verified evidence set for the retrieved context. | Question, prompt instructions, model, and generation settings. | A corrected answer points toward evidence selection or presentation; inspect the original trace to distinguish them. |
| Send identical selected passage text through and around the assembly step. | Question, passage order, and model configuration. | Differences in the final input reveal assembly losses before interpreting output differences. |
| Move the same supporting passages within an otherwise unchanged context. | Passage contents, distractors, question, and model settings. | A repeatable answer change suggests sensitivity to evidence position in this setup. |
| Compare the current prompt with one that requires an explicit unresolved-evidence response. | The same insufficient or conflicting context. | Fewer unsupported assertions may improve handling of gaps; separately check that answerable cases still get answered. |
The evidence-substitution comparison changes both content and potentially length, so a success alone does not isolate a retrieval algorithm. Likewise, one improved answer is not proof of a cause. Repeat generation comparisons enough to assess variability for the decision at hand, and retain the outputs rather than presenting a single favorable sample.
The 2023 study Lost in the Middle, v3 found position-dependent performance in its evaluated models and tasks. That motivates testing context placement; it does not establish the behavior of every model available in 2026 or a universal best ordering.
Turn the original failure into a regression case with required claims, applicable source passages, and acceptable handling of missing information. Add nearby cases that could expose a tradeoff: another plan, an earlier effective date, a superseded rule, a genuinely unanswerable question, and a question needing both documents. Keep answer correctness and unsupported-claim checks separate so that a system cannot appear improved merely by declining every question.
Keep a reusable diagnosis record
For each failed question, complete this checklist before selecting a broader retrieval or model change:
- Specify the required facts, scope, date, and acceptable uncertainty or clarification.
- Identify authoritative supporting passages, or record exactly which evidence is unavailable.
- Check that ingestion preserved those passages and their qualifiers in the allowed searchable corpus.
- Record the effective query and filters; locate each required passage before and after ranking.
- Compare selected passages with the exact final model input, including dates, labels, tables, summaries, and trimming.
- Map each disputed answer claim to supporting or contradicting text; record omitted requirements separately.
- Name the earliest observed failure and any additional downstream failure.
- Choose one targeted change and define what observation would support or reject the diagnosis.
- Retain a regression case and check both answerable and insufficient-evidence variants.
A completed record should produce a decision such as: “The retention passage was retrieved but omitted during prompt assembly; preserve that passage and verify the answer uses its seven-day rule.” “Improve RAG quality” is too broad to tell whether the chosen change addressed the failure.
Documentation context, checked 19 September 2026: Haystack pages identify documentation version 3.1. Ragas links use the moving latest documentation; the metric pages distinguish their collections API examples from legacy APIs. This guide uses their definitions, not a tested SDK installation. Before implementing a metric, record the installed Ragas version, exact metric variant, judge model, and reference-data revision so later comparisons mean the same thing. The 2023 RAGAS paper supplies the conceptual background, while current metric definitions come from the linked docs. Context Precision No SDK code, evaluation scores, or production measurements are reported here.
Sources & further reading
Documentation informs the product behavior described here. The worked scenarios and conceptual diagrams explain how those behaviors fit together.
- Retrievers (documentation version 3.1) ↗deepset · Accessed 2026-09-19
- PromptBuilder (documentation version 3.1) ↗deepset · Accessed 2026-09-19
- List of available metrics ↗Ragas · Accessed 2026-09-19
- Context Precision ↗Ragas · Accessed 2026-09-19
- Context Recall ↗Ragas · Accessed 2026-09-19
- Faithfulness ↗Ragas · Accessed 2026-09-19
- Response Relevancy ↗Ragas · Accessed 2026-09-19
- Factual Correctness ↗Ragas · Accessed 2026-09-19
- RAGAS: Automated Evaluation of Retrieval Augmented Generation (v1, 26 September 2023) ↗Es et al. / arXiv · Accessed 2026-09-19
- Lost in the Middle: How Language Models Use Long Contexts (v3, 20 November 2023) ↗Liu et al. / arXiv · Accessed 2026-09-19