Skip to content
mentoor

Topic 4 of 5 · 4 min read

Chunks that lose their meaning

Goal: Diagnose from a retrieved chunk and a wrong answer which chunking failure caused it and propose the fix.

When a RAG answer is wrong, read the retrieved chunks first: many wrong answers come from a chunk that lost the context it needed. The model answered correctly from what it was given. What it was given was broken.

Check yourself · 1 of 3

A retrieved chunk reads 'It expires after 90 days.' with no subject. Which failure is this?

Choose one answer

Why it matters

Chunking cuts documents into pieces that are later read alone. Anything a piece needs from outside itself is gone. The retriever and the model cannot recover it. Learning to name the failure from a chunk and a wrong answer lets you fix the pipeline instead of rewriting prompts.

The common failures

Failure What the chunk looks like Typical wrong answer Fix
Split table Rows without the header row Values attached to the wrong column Keep a table whole, or repeat headers in each piece
Orphaned pronoun "It must be renewed yearly." Answer about the wrong thing Add title and section path to the chunk text, or use a larger window
Cut-off steps Steps 4 to 6 with no steps 1 to 3 Missing prerequisites Split on the list boundary, keep procedures whole
Heading separated Body text without its heading Wrong product or scope Prepend the heading path to every chunk
Duplicated boilerplate A legal footer in every chunk Noise crowds results Strip it at parse time
Mixed topics Two unrelated sections in one chunk Vague matches Split on section boundaries

How to diagnose

  1. Take a wrong answer and print the top 5 chunks that were retrieved.
  2. Ask: does any chunk contain the right information? If no, the problem is retrieval or missing content. If yes, but it is incomplete or ambiguous, the problem is chunking.
  3. Read that chunk alone, as the model would. What is missing: a header, a subject, an earlier step?
  4. Fix the cause in the pipeline, then re-run your question set to check that nothing else got worse.

Before and after

A chunk reads: "Maximum: 5 devices. Contact support to raise it." The question was about the Basic plan and the answer said 5, but 5 belongs to the Free plan. The heading "Free plan" was in the previous chunk.

# after: heading path added to the stored text
text = f"{section_path}\n{body}"
# "Plans > Free plan\nMaximum: 5 devices. Contact support to raise it."

What goes wrong

  • Fixing the prompt. Adding "be careful about plans" does not restore a heading the model never saw.
  • Blaming the model. The model followed the chunk faithfully.
  • Fixing one case. A rule that repairs this table breaks another document type, so always re-run the whole test set.

Examples

Reading a bad chunk

Question: 'How long is the warranty on the Pro model?' Answer: '12 months.' The correct answer is 24.

Top chunk: | Standard | 12 months | with no header or model name. The table was split after its title row. Diagnosis: split table. Fix: keep tables as one chunk and include the caption 'Warranty by model'.

A cut-off procedure

A chunk begins at 'Step 4: Restart the service.' The user asks how to deploy and the answer starts at restart, skipping backup and migration. Diagnosis: cut-off steps. Fix: split on the list boundary so steps 1 to 6 stay together, or link neighbouring chunks by chunk_index.

Key points

  • Read the retrieved chunks before changing prompts, because the model usually answers faithfully from broken input.
  • If the right information is in no retrieved chunk, the cause is retrieval or missing content, not chunking.
  • Tables need their header row, so keep them whole or repeat headers in each piece.
  • Prepend title and heading path to chunk text so pronouns and local facts keep their subject.
  • Keep procedures and numbered lists together, and strip boilerplate that repeats in every chunk.
  • After any chunking fix, re-run the full question set to catch regressions.

Common mistakes

  • Rewriting the prompt before reading the retrieved chunks.
  • Assuming every wrong answer is a model problem.
  • Splitting a table or numbered list at an arbitrary character count.
  • Embedding body text without the heading or title that gives it a subject.

Check yourself · 2 of 3

You trace a wrong answer and read the top 5 retrieved chunks. None of them mentions the correct fact, not even in part. Where should you look next?

Choose one answer

Check yourself · 3 of 3

Chunks from a pricing table show values like '$12' and '$29' with no column names, and the answers mix up plans. What is the best fix?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic