Modules/Gen AI/ Chunking Lab

Chunking Strategies for RAG

Before anything can be embedded or retrieved, a document has to be cut into pieces. Where you cut decides how much sense each piece makes on its own.

Chunking

30
0

Resulting Chunks

Counts

Chunks6
Avg words/chunk28
Mid-Sentence Cuts
4

 

Chunking: A Practical Guide

The retrieval step can only ever be as good as the pieces it is choosing between.

Quick Context

Every piece of RAG downstream of chunking — embedding, indexing, retrieval, reranking — operates on whatever the chunk boundaries produced. Cut a sentence in half and both halves lose the context that made the original sentence meaningful; the embedding of a fragment is not a fragment of the embedding.

Fixed-size vs semantic

Fixed-size chunking counts a fixed number of words or tokens and cuts there, with no regard for what is at that position — a heading, mid-word, mid-sentence, anywhere. It is simple, predictable, and blind. Semantic chunking respects natural boundaries — sentences, paragraphs, headings — and only splits at those boundaries, accepting some variation in chunk size in exchange for every chunk being a coherent unit.

Why overlap exists

Even a well-placed boundary loses something: whatever came just before a chunk starts is not in it, even though it might be exactly the context needed to make the chunk's first sentence make sense. Overlap re-includes the last few words of the previous chunk at the start of the next one, at the direct cost of storing and embedding the same words twice.

Interactive Exploration Guide

  1. Start at 30 words, fixed-size. Several chunks end mid-sentence — the cut counter is not zero.
  2. Switch to semantic. The cut counter drops to zero at any size — chunks vary a little in length but every one ends on a real sentence boundary.
  3. Shrink fixed-size chunks to 15 words. More chunks, and more of them are mid-sentence cuts — small fixed windows are the worst case for this failure.
  4. Add overlap. The highlighted words at the start of each chunk (after the first) are the ones repeated from the end of the previous chunk — visible context carried across the boundary, at the cost of storing it twice.

Key Takeaway

Fixed-size chunking is simple and fast but blind to meaning, and will cut sentences in half whenever the count lands mid-sentence. Semantic chunking respects real boundaries at the cost of variable chunk sizes. Overlap recovers some of the context lost at any boundary by duplicating a small window of text between neighbouring chunks. None of this is free — every choice trades simplicity, storage, or coherence against the others, and the right trade depends on how structured the source documents already are.

Predict, then reveal

About to run: Start at 30 words, fixed-size. Before it does — what happens to the readout?

Committing to an answer first is the point — the reveal runs the experiment on the visualisation above and reads the real value back, so nothing here is scripted.

Recall check

0 of 3

Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.

  1. Without scrolling back — what is the one-line takeaway from this module?

  2. What does this module say about “Quick Context”?

  3. What does this module say about “Fixed-size vs semantic”?

Cheat sheet

Chunking Strategies for RAG

Before anything can be embedded or retrieved, a document has to be cut into pieces. Where you cut decides how much sense each piece makes on its own.

GEN AI · vizlearn.in/gen_ai/chunking_strategies_for_rag.html