Why Chunking Matters in RAG (and What Makes a Good Chunk)

JS
Jai Singh
16 Nov, 2026 3 min read 20 views

Chunking means splitting documents into smaller passages before you embed them. You must do it because embedding models have input limits, because one vector for a whole document blurs many topics together, and because the language model needs focused context. Chunk size and boundaries are among the biggest levers on retrieval quality.

Why not embed whole documents?

  • Input limits. Models read a limited number of tokens. Anything beyond is dropped.
  • Blurred meaning. A 20-page manual covers many topics. A single vector averages all of them, so no query matches it strongly.
  • Wasted prompt space. If the answer is one paragraph, sending the whole manual to the model costs money and distracts it.
  • Poor citations. "See the manual" is less useful than pointing at one section.

Why not split into tiny pieces?

Very small chunks have the opposite problem. A single sentence often lacks context. "It must be renewed every year" means nothing if the sentence naming "it" is in the previous chunk. Tiny chunks also multiply your vector count, which raises storage and search cost, and they push you to retrieve many pieces to cover one answer.

The trade-off

Small chunksLarge chunks
Match precisionHigh: one topic per vectorLower: mixed topics
Context for the modelOften missingUsually enough
Vector count and costHigherLower
Prompt tokens per chunkFewMany

A common starting point is 200 to 500 tokens per chunk with a small overlap, but treat that only as a first guess. The right size depends on your content and questions. Short FAQ entries want small chunks. Long narrative documents want larger ones. Later posts show how to measure this on your own data.

Qualities of a good chunk

  1. Self-contained. A person could read it alone and understand it. Resolve pronouns or add a heading so it makes sense.
  2. One main topic. The embedding should represent a single idea.
  3. Respects boundaries. It does not cut a sentence, a code block, a table row or a list in half.
  4. Carries its source. It stores the document title, section heading and position so you can cite and re-fetch it.
  5. Fits the embedding model. It is within the model's input limit.

Always look at your chunks

The most valuable chunking habit is to print a sample and read it. Bad boundaries are obvious to a human and invisible in metrics. The script below prints size statistics and a few random chunks from a list of strings.

import random
import statistics

def inspect_chunks(chunks, sample=5):
    sizes = [len(c.split()) for c in chunks]
    print(f"chunks: {len(chunks)}")
    print(f"words per chunk: min={min(sizes)} "
          f"median={statistics.median(sizes)} max={max(sizes)}")
    print("tiny chunks (<20 words):", sum(s < 20 for s in sizes))
    for c in random.sample(chunks, min(sample, len(chunks))):
        print("-" * 60)
        print(c)

Look for three warning signs: many tiny chunks (usually headings split from their content), a few huge chunks (a missing separator), and chunks that start or end mid-sentence.

Overlap

Overlap repeats the last bit of one chunk at the start of the next, for example 10 to 20 percent. It helps when an idea straddles a boundary. Too much overlap inflates your index with near-duplicate vectors and makes the same text appear several times in the top results. Structure-aware splitting reduces the need for overlap, which the next posts cover.

Strategies you will meet

  • Fixed-size splitting by characters, words or tokens. Simple and predictable.
  • Structure-based splitting on headings, paragraphs and list items.
  • Recursive splitting that tries larger separators first and falls back to smaller ones.
  • Semantic splitting that cuts where the topic changes.
  • Small-to-big retrieval that matches small chunks but returns their larger parent.

Common mistakes

  • Picking a chunk size once and never testing alternatives.
  • Splitting on a fixed character count that cuts words and code in half.
  • Dropping headings, so a chunk like "Step 3: restart the server" has no product name.
  • Using the same settings for every content type, such as prose, tables and code.
Was this article helpful?

Comments

No comments yet. Have a question or a tip? Be the first to share it.

Leave a comment

Comments are reviewed before they appear.