Why Chunking Matters in RAG

How chunk size and overlap affect retrieval precision, recall and answer quality.

Last Updated: 27, Nov 2026

Search Tutorials

--Ads--

Module 4 · Lesson 1 of 10 · Intermediate

Why Chunking Matters in RAG

How chunk size and overlap affect retrieval precision, recall and answer quality.

Chunking is the process of splitting documents into smaller passages before embedding them. It sounds like a minor preprocessing step, but chunking decisions have more effect on retrieval quality than almost any other setting in a RAG system. This lesson explains why, and what a good chunk looks like.

Why not embed whole documents?

  1. Embedding models have input limits. Many popular models accept 512 tokens; text beyond the limit is silently cut off and never indexed. Even long-context embedding models produce worse vectors for very long inputs.
  2. One vector cannot represent many topics. A 40-page handbook covers leave, expenses, security and IT. Its single embedding is an average of all of them and is not close to any specific question.
  3. The LLM needs focused context. Sending whole documents for every question wastes tokens, increases cost and latency, and buries the relevant sentence among irrelevant ones.
  4. Citations become vague. "See the employee handbook" is much less useful than "see section 4.2, paid leave".

See the effect

This experiment compares the similarity between a question and a whole document with the similarity between the question and the best paragraph of that document.

from rag_helpers import embed

handbook = """Our offices are open from 9:00 to 18:00, Monday to Friday.

Employees get 18 days of paid leave in their first year and 24 days after that.

All laptops must use full-disk encryption and a password manager.

Travel must be booked through the company travel portal at least 7 days ahead."""

question = embed("How many vacation days do I get?", query=True)[0]

whole = embed(handbook)[0]
paragraphs = [p for p in handbook.split("\n\n")]
para_vectors = embed(paragraphs)

print(f"whole document : {whole @ question:.3f}")
for p, v in zip(paragraphs, para_vectors):
    print(f"{v @ question:.3f}  {p[:55]}")
whole document : 0.612
0.488  Our offices are open from 9:00 to 18:00, Monday to Fri
0.781  Employees get 18 days of paid leave in their first yea
0.402  All laptops must use full-disk encryption and a passwo
0.455  Travel must be booked through the company travel porta

The right paragraph scores far higher than the whole document. In a collection of thousands of documents, that difference decides whether the answer is retrieved at all.

The chunk size trade-off

Small chunks give precise matches but lose context; large chunks keep context but blur embeddings; 200 to 800 tokens is typical.
Figure 1. Smaller chunks improve precision; larger chunks preserve context.

There is no universally correct size. It depends on your documents and questions:

  • FAQ entries, product records, support tickets: one natural unit per chunk, often 100 to 300 tokens.
  • Policies, manuals, documentation: one sub-section per chunk, usually 300 to 800 tokens.
  • Legal contracts, research papers: clause or paragraph level, with section headings attached.
  • Narrative text (books, transcripts): larger chunks of 500 to 1,000 tokens with overlap.

What makes a good chunk?

  • Self-contained. A reader who sees only this chunk can understand it. "It must be submitted within 30 days" is useless if nobody knows what "it" is.
  • About one thing. The chunk covers a single topic, so its embedding is sharp.
  • Cut at natural boundaries. Never in the middle of a sentence, table row or code block.
  • Carries its context. The document title and section heading travel with the chunk.
  • Traceable. Its metadata records the source, page and position.

The chunking strategies in this module

StrategyIdeaLesson
Fixed-size and recursiveSplit by length, preferring natural separatorsFixed-size chunking
Structure-awareSplit by headings, sections or functionsStructure-aware chunking
SemanticSplit where the topic changesSemantic chunking
Parent-childSearch small chunks, return big onesParent-child chunking
Contextual and late chunkingKeep document context inside each chunkLate chunking

Key takeaways

  • Whole documents make poor retrieval units: embeddings blur, limits truncate text and prompts bloat.
  • Chunk size trades precision against context; 200 to 800 tokens is a typical range, but measure on your data.
  • Good chunks are self-contained, single-topic, cut at natural boundaries and carry their headings.