# Chunking documents for RAG

Published 2026-09-02 · Topics: RAG

Splitting on the document's own structure, and why overlap is a patch rather than a fix.

A retriever can only return what the chunker produced. If an answer is split across two chunks, no ranking will bring it back in one piece.

## Split on structure first

Documents already say where their ideas begin and end: headings, sections, lists, tables. A chunker that follows them keeps each idea whole, and a chunk's heading path becomes metadata the retriever can use.

1. Split on the headings.
2. Split a section that is still too long on its paragraphs.
3. Split a paragraph that is still too long on its sentences.

Each step runs only where the one before it left something too large.

## Overlap is a patch

Repeating a few sentences between neighbouring chunks hides the cut, but it also stores the same text twice and lets near-duplicates crowd the results. When chunks follow the structure, little overlap is needed.

## Keep the context with the chunk

A chunk that starts with "It also supports streaming" means nothing alone. Prefixing it with its document title and heading path costs a few tokens and makes it retrievable on its own.

[All articles](https://danielealbano.me/blog)

## Building something with RAG, search or AI? Write to me.

[Open the contact form](https://danielealbano.me/contact)

---

Every page of this site is available in Markdown: request its URL with the header `Accept: text/markdown`.
