TL;DR

A chunk is the unit your retriever can find and your model can read. Too small and it loses context; too big and it drowns the answer. Start structural, add overlap, measure — and only then look at fancier methods.

Every RAG tutorial spends three paragraphs on chunking and thirty on vector databases. In our client projects it is almost always the other way around: the database is a commodity, the cutting strategy is where the quality is won or lost. This article is the ruler-and-scissors version. No embeddings yet; those come in part 2.

The problem in one picture

You have a 40-page document and a question. The model can read maybe 3 pages’ worth of text comfortably. Something has to decide which 3 pages — and what counts as a “page”. That something is chunking. Drag the slider and watch how the same text gets cut differently.

This agreement terminates automatically at the end of the initial term. It is renewed for successive periods of one year unless either party gives written notice at least ninety days before the end of the current period. Notice must be sent by registered mail to the address stated in Annex A. During any renewal period the fees are adjusted according to the index published in Annex B. Either party may terminate for material breach if the breach is not cured within thirty days of written notice. Termination does not affect accrued rights or the survival of the confidentiality obligations set out in section twelve.
5 chunks · avg 20.8 words · min 8 · max 24 · indexed words 104 (source 104)
Fig. 1 — Alternating tint = alternating chunks. Solid accent = text present in two chunks (overlap).

Fixed-size chunks

The baseline: cut every N tokens, no questions asked. It is fast, predictable and it is what most frameworks default to. Its failure mode is visible in the figure above at small sizes — sentences are sliced mid-thought, and the chunk containing “the contract terminates” may not contain “unless notice is given 90 days before”.

def fixed(tokens, n):
    return [tokens[i:i+n] for i in range(0, len(tokens), n)]

Overlap

The cheapest fix: let consecutive chunks share a tail. An overlap of 10–20 % means a sentence cut in half at the end of chunk k appears whole at the start of chunk k+1. You pay for it in index size (more chunks) and in duplicated retrieval results, which you will need to de-duplicate later.

Overlap is not a strategy; it is a bandage on a strategy. Use it, but know what it is covering.

Cutting along structure

Documents already have cuts in them: headings, paragraphs, list items, table rows. Cutting there keeps units that a human would consider “one idea”. Tick the checkbox in Fig. 1 to see the difference. In practice this means parsing Markdown/HTML/DOCX structure first and only falling back to fixed-size inside very long sections.

Semantic chunking

The fashionable option: embed sentences, cut where the embedding shifts. It is elegant and sometimes better — but it is slow, it depends on the embedder you have not chosen yet, and in our tests it rarely beats good structural chunking on well-formatted documents. Where it shines: transcripts, emails, anything without structure to lean on.

How to pick

Rule of thumb we use on projects

Structural first. Overlap 10 %. Chunk target 200–400 tokens for Q&A, 600–1,000 for summarisation. Then measure with 30 hand-written questions before touching anything else. Chunking changes that don’t move that number are noise.

Try the strategies on your own PDF in the playground below — it runs on our infrastructure, no sign-up needed for this one.

An annotated printed document on a desk
An illustration, not a figure: photos sit in the same frame as charts and are slightly desaturated so the accent blue stays the only saturated colour on the page.Photo · Principia
live · streamlit · demos.principia.vldv.ovhOpen in new tab ↗
Demo — Upload a PDF, compare 4 strategies side by side. The demo lives on a separate host and is embedded here.

Next in the series

RAG from first principles
  1. Chunking, explained with a ruler and a pair of scissors
  2. Embeddings: what close means and why your model disagrees
  3. Hybrid search — BM25 is not dead
  4. Reranking, the step that actually moves accuracy
  5. Evaluating RAG with 30 questions and a spreadsheet
  6. Updating the index without breaking everything