1:1 mentoring with Big Tech AI engineers
RAG & MCP

Chunking Strategies

Choose what to cut on, size chunks in the embedder's own tokens, keep headings, tables and code whole, search small but return big, and measure any change with recall@k on real questions.

Last updated

Core12 min readFirst readDocument ProcessingEmbeddings

After this section you can

  • Choose what to cut on from the document’s structure, and say what each kind of cut breaks on
  • Fit heading path, overlap and text inside the embedder’s window, and return a parent when a child matches
  • Compare two chunkers by recall@k on real questions and tell a gain from noise
04

Chunking: Cut on Structure, Size for the Embedder

A chunk is the smallest piece search can return. Cut where the document’s own structure ends an idea, fit each chunk to the embedder’s window, and measure every change on real questions.

Key idea

The vector from Embeddings stands for whatever lands in one chunk, so the cut decides what search can find. Cut on the document’s own units, keep the heading path (the section titles above a chunk), overlap and text inside the embedder’s window, and choose between chunkers by how often the right chunk comes back (recall@k) on real questions, not by a library default.

A size cut can strand a heading from its text; a heading cut keeps them together
refund-policy.pdf, page 4Cut by sizeCut on headings Returns Refunds Refunds are accepted within 30 days of delivery. Refunds go to the original payment method. Annual plans Unused months are refunded pro rata. Requests must arrive within 60 days. size cutheading cut chunk Aends with the heading chunk Bno “annual plans” in it chunk 12Returns > Refunds chunk 13path travels with the textReturns > Refunds > Annual plans

Acme’s refund-policy.pdf, page 4; the size cut is a toy (a recursive splitter at 150 characters). Question: “How long do I have to ask for a refund on an annual plan?” The answer, 60 days, is in chunk 13. On a phone the figure pans sideways.

Related

More in RAG & MCP

Get full access to all 149 sections with code examples, diagrams, and interactive animations.

Unlock Premium