Free sample lesson · Why Your RAG System Gives Bad Answers

Keep the Exception Attached

Why does a searchable late-arrival exception still lose its policy identity?

Lesson 1 of the Wondering course Why Your RAG System Gives Bad Answers

Searchable, Yet Incomplete

Why can a search find the late-arrival exception yet return an unreliable answer?

In this fictional policy, a traveler asks whether a $60 dinner after a 22:00 train arrival is allowed under current EX-17, and what evidence is required.

EX-17 is the code printed on this fictional current France client-travel policy. Its late-arrival exception allows dinner up to $65 when the train arrives after 21:00. It also has two requirements: an itemized receipt and manager approval. Before search, the long policy is split into shorter text pieces called chunks. Search can return one of these pieces rather than the whole policy.

Before using a search result, check two things: does it include the receipt and approval requirements, and does it say which policy those rules belong to? A result that matches the dinner amount can still be missing that essential information.

Found, but is it whole?

Keep Conditions With Rules

The standard cap is $40. The late-arrival exception says arrivals after 21:00 may claim up to $65, with an itemized receipt and manager approval.

Rule vs. exception
  • Standard cap
  • Late-arrival exception

If a split occurs before the requirements, the $65 sentence remains searchable but incomplete.

Document structure and semantic boundaries can guide splitting, rather than a size limit alone.[[1]](https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-chunk-documents) The evidence unit must keep the rule beside its qualifying conditions.

Compare the Two Splits

Compare two splits before trusting a larger answering model.

Split A: One chunk ends after “up to $65.” The receipt and approval sentence moves elsewhere.

Split B: One chunk keeps both exception sentences together. Select B because one evidence unit now contains the amount and requirements.

Two ways to split the same exception passage

Notice that Split A cuts right after the $65 amount and strands the receipt and approval sentence, while Split B keeps both sentences inside one evidence unit.

Overlap repeats some text at a chunk boundary and can preserve continuity.[[1]](https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-chunk-documents) For this exercise, inspect the actual split: are the receipt and approval requirements still beside the $65 rule?

Give the Chunk Identity

Suppose both exception sentences stay together. The chunk can still become ambiguous after its heading disappears.

Every chunk is cut from an original document, its source document. In this fictional example, that document is the current France client-travel policy EX-17, and we label it P so we can point back to it. Before indexing the passage (storing it so search can find it), attach the document title and context: current France client-travel policy EX-17; source P. Now the amount and conditions are tied to a specific policy rather than an unidentified dinner rule.

An index card cut from a handbook, with its heading tag attached

Notice the attached tag: without the handbook heading, the intact card could match the wrong policy scope, so its identity is stapled on before indexing.

Detached chunks can lose document-level context; contextual retrieval adds chunk-specific context before indexing.[[2]](https://www.anthropic.com/research/contextual-retrieval)

Like an index card cut from a handbook, the passage needs its heading. Otherwise, a useful sentence may match the wrong policy scope.

Add Context Before Search

Where should added context enter the system? Before search.

Search relies on indexes built ahead of time. An embedding turns a chunk into a numeric representation of its meaning, so similar meanings land near each other. A lexical index is word-based instead: it records which exact words appear in each chunk, so a query containing a specific term such as “EX-17” can match that term directly.[[2]](https://www.anthropic.com/research/contextual-retrieval) Prepending means placing text in front of the chunk.

A chunk-specific explanation is prepended before both embedding and lexical indexing, so those indexes represent the chunk with its context.[[2]](https://www.anthropic.com/research/contextual-retrieval)

Context is added to each document passage, then the combined text goes to both the meaning-based and word-based search indexes.

Anthropic's original diagram places chunk-specific context before both embedding and lexical indexing. · Anthropic, Introducing Contextual Retrieval (September 19, 2024), preprocessing diagram; resized.

Text added only to the final answer prompt arrives after candidate search. It cannot repair a passage that search never selected.

Keep generated context distinguishable from policy text, then verify it against source P. Added wording can change which passages become neighbors.

Inspect the Failure Stage

Suppose an answer omits manager approval. Find the earliest copy of the passage that lost that requirement.

First compare the original policy with its indexed chunk. If the chunk ends after “up to $65,” fix the split so the receipt and approval sentence stays with it. If both sentences survive but the policy title is missing, attach the document context before rebuilding the search index.

Now suppose the stored chunk is complete. Search gathers a candidate list: passages that might answer the question. During reranking, a scorer compares the question with each candidate and moves the passages judged more useful toward the front. The system then chooses passages from the ordered list and includes their text in the request sent to the answer model.

For our fictional example, inspect where P’s exception disappears:

ObservationNext thing to inspect
P’s chunk is stored but absent from candidatesCandidate search
P appears in candidates but is not chosenReranking and the passage-selection step
P is chosen but its text is missing from the model inputThe step that builds the model input
Find the failure stage
  • Answer fails: Inspect from original document toward the answer.
  • Requirements in chunks?: Check the indexed chunks.
  • Repair boundary: Use semantic splitting or careful overlap.
  • Identity present?
  • Add context, reindex: Add title, scope, and chunk-specific context.
  • Reaches selection?: Does the complete source passage reach the selected list?
  • Investigate search, reranking
  • Examine answering model: Only after complete evidence appears in its actual input.
  • No
  • Yes
  • No
  • Yes
  • No
  • Yes

Only investigate the answer model’s use of the rule after you can see the complete rule in the text it received. The next lessons examine these later stages in detail.

Choose Complete Evidence

Which evidence would you send forward for the France question?

Candidate A contains the $65 sentence, but lacks the receipt and approval requirements. It also lacks EX-17 and current France client-travel scope.

Candidate B keeps both exception sentences and carries France client travel, EX-17, current, plus source P. Choose B.

Which evidence goes forward?
  • Candidate A
  • Candidate B

Then carry the scoped standard and exception passages into the next candidate-search check. Test retrieval with complete evidence instead of compensating with a stronger answer model.

Check yourself

If requirements are present in indexed chunks, identity is present, but scoped chunks do not reach reranked selection, the next repair is to _____.

  • investigate search and reranking
  • examine the answering model

Answer: investigate search and reranking

When complete, identified chunks fail to reach selection, investigate candidate search and reranking. The answering model should be examined only after complete evidence appears in its actual input.

A fictional policy chunk says “up to $65” but loses its document title. A team adds the title only to the answer prompt. Search still never retrieves the chunk. Which change addresses that loss?

  • Attach the title to the chunk before rebuilding both search representations.
  • Keep the stored chunk unchanged and repeat the title in the answer prompt.
  • Increase the answer model’s output length while keeping retrieval unchanged.

Answer: Attach the title to the chunk before rebuilding both search representations.

The missing identity must be available to search. Context added before embedding and lexical indexing changes what those indexes represent. Adding it only after retrieval cannot help this missing passage enter the candidate list.

For a fictional late-arrival claim, the evidence bundle contains the full exception and its receipt rule, but its source tag names an archived policy. What still needs checking?

  • Whether the evidence belongs to the current policy, even though the rule text is complete.
  • Only whether the amount is below the cap; the source version cannot change the answer.
  • Only the answer model, because keeping the sentences together completes preparation.

Answer: Whether the evidence belongs to the current policy, even though the rule text is complete.

A passage needs identity as well as complete conditions. The source/version must establish which policy the rule belongs to. Sentence completeness alone does not show it governs the current question.

Keep going

This is lesson 1 of 6 in Why Your RAG System Gives Bad Answers. Next up:

  1. Retrieve the Right Policy
  2. Rank Candidates, Not the Corpus
  3. Inspect the Actual Model Input
  4. Check Claims and Missing Conditions
  5. Choose the Fix Your Trace Supports

Start this course free

Wondering turns any topic into short lessons you can read, watch, or listen to, with practice questions and an AI tutor.