Most RAG quality problems get blamed on the model, then on the vector
database, and only last on the step that quietly decides what the model can
ever see: how the documents were cut into pieces. A weak RAG chunking
strategy produces chunks that either bury the answer in noise or slice it in
half, and no amount of prompt tuning recovers information that was never
retrieved.
This post covers the decisions that matter (boundaries, size, overlap, added
context), the trade-offs of each, and how to pick by measurement instead of
copying a default from a tutorial.
Why does chunking change answer quality?
Retrieval works on chunks, not documents. Each chunk is embedded as one
vector, so it competes for a slot in your top-k results as a single unit. That
creates two opposite failure modes:
- Chunks too large. The embedding blurs several topics together, the
relevant sentence is diluted, and you spend prompt tokens on text the
question did not need.
- Chunks too small or badly cut. A chunk such as "revenue grew 3% over the
previous quarter" no longer says which company or period it is about, or the
sentence that completes the answer sits in the neighbouring chunk.
Anthropic's write-up on contextual retrieval
makes the same point: documents are typically split into pieces of no more than
a few hundred tokens, and chunk size, boundaries and overlap all affect
retrieval performance.
Which chunking strategies are there?
| Strategy | How it splits | Strength | Weakness |
|---|
| Fixed-size | Every N tokens or characters | Trivial, predictable | Cuts mid-sentence and mid-table |
| Recursive / separator-based | Tries paragraphs, then sentences, then words until chunks fit | Respects natural breaks, still simple | Ignores document structure beyond whitespace |
| Structure-aware | Splits on headings, list items, table rows, code blocks | Chunks match how authors organised ideas | Needs a parser per format |
| Semantic | Starts a new chunk where embedding similarity between sentences drops | Can follow topic shifts | Extra ingestion cost, results vary by corpus |
| Parent-child | Retrieve small chunks, return the larger section they belong to | Precise matching, fuller context for the model | Two levels to store and keep in sync |
A sensible order of effort: start with recursive splitting, move to
structure-aware splitting for the document types that matter most (contracts,
manuals, policies, help-centre articles), and only try semantic or parent-child
approaches if your evaluation shows a gap the simpler methods leave.
How do you pick chunk size?
Size is a trade-off between precision and context, and the right point depends
on the questions people ask:
- Lookup questions ("what is the notice period?") favour smaller chunks that
isolate one fact.
- Explanation questions ("how does the refund process work?") favour larger
chunks or parent-child retrieval, because the answer spans several
paragraphs.
Also check the limits you cannot change: the maximum input length of your
embedding model, and how many retrieved chunks fit in the prompt alongside the
question and instructions. Pricing is per token on both embedding and
generation, so larger chunks also raise cost on every query. Our post on
reducing LLM API costs covers how that adds up.
Resist picking one number for everything. A FAQ, a legal contract and a code
repository do not share a sensible chunk size, and a RAG system over mixed
content often needs a per-document-type configuration.
Do you need chunk overlap?
Overlap repeats the end of one chunk at the start of the next, so a fact that
straddles a boundary appears whole in at least one of them. It is a
workaround for cutting in the wrong place.
The costs are real: duplicated text enlarges the index, and a query can return
two near-identical chunks that waste slots in your top-k. If you split on
headings and paragraphs, boundaries already fall where ideas change, and you
can often use little or no overlap. If you must split mechanically, a modest
overlap is cheap insurance. Test with and without it rather than assuming.
What do you do about chunks that lose their context?
Splitting removes the surrounding document. Two common repairs:
- Prepend metadata. Attach the document title, section heading and date to
the chunk text before embedding. This is cheap and needs no model call.
- Add generated context. Anthropic's contextual retrieval has a model write
a short, chunk-specific explanation (typically 50 to 100 tokens) from the
full document, then prepends it before embedding and before building the
BM25 index. In their reported experiments, measured as the share of
relevant chunks missing from the top 20, this cut failed retrievals by 35%
with contextual embeddings alone and by 49% when combined with contextual
BM25. Adding reranking brought the reduction to 67%. Those figures are from
Anthropic's own datasets, so treat them as evidence the technique can
help, not as a number your corpus will reproduce.
Generated context costs a model call per chunk at ingestion, which is a
one-off cost per document but a real one on a large corpus. Pair it with
hybrid search and reranking,
since the techniques address different failure points.
Special cases that break naive chunkers
- Tables. Splitting a table row by row loses the header. Keep the header
with every chunk, or convert rows to short sentences.
- Code. Split on functions or classes, not on line counts.
- PDFs from scanners. Extraction errors upstream look like chunking
problems downstream. See why document intelligence is not OCR.
- Multi-tenant content. Chunk metadata must carry the tenant identifier so
filters can be applied, as discussed in multi-tenant RAG data isolation.
How do you test a chunking strategy?
Treat it as an experiment:
- Collect 30 to 100 real questions, ideally from support tickets or search
logs, each with the document passage that answers it.
- Ingest the corpus with two or three configurations (for example recursive
at two sizes, and structure-aware).
- For each question, check whether the correct passage appears in the top-k
chunks. Record that recall, plus how many prompt tokens the retrieved
context used.
- Read the failures. Misses where the answer was split across chunks point to
boundaries; misses where a chunk was retrieved but ambiguous point to
missing context.
Store the chunking configuration with each index version so you can re-run the
comparison when documents or embedding models change. This evaluation set
doubles as the regression test described in
LLM evals in CI.
What to do next
Write down your top 50 real questions before touching a chunk-size
parameter. Run a recursive-splitting baseline, measure recall, then change one
variable at a time: boundaries first, size second, overlap third, added
context last. Stop when the gain per change stops justifying its ingestion cost.
If you are building a retrieval system for an AI product and want a second
opinion on the design, see how we approach
AI SaaS development and get in touch.