Chunking in RAG is the process of splitting source documents into smaller passages that get embedded, indexed, and retrieved individually. Retrieval can only return chunks that exist, so the way you split your documents sets a hard ceiling on how accurate your chatbot can ever be.
Change your model later and you can re-run everything. Change your chunking and you re-index your entire corpus.
That last sentence is why this page exists.
Most guides on this topic list the same six or seven strategies and tell you to “experiment.” Almost none of them give you a number you can act on, and the ones that do contradict each other: one top-ranking guide recommends 10 to 20% overlap, another recommends 20 to 50%, and a third gives no overlap guidance at all. Meanwhile four separate benchmark studies have measured this directly, and their results overturn some of the most repeated advice in the field.
This guide uses those measurements. Every number below is attributed to a named source with a date, and where the sources disagree, that is stated rather than smoothed over.
On this page
- What is chunking in RAG?
- Why your chatbot gives wrong answers without good chunking
- Chunking, embedding, or retrieval: which one is actually broken?
- The 9 chunking strategies, ranked by measured performance
- What chunk size should you use?
- Three things the top-ranking guides get wrong
- The step almost nobody writes about: size regularization
- How to measure chunking quality before you ship
- Chunking tables, PDFs, images, audio, and video
- Pick your strategy in 60 seconds
- Production checklist
- Frequently asked questions
What is chunking in RAG?
Chunking is the step between loading a document and embedding it. You take a 40-page PDF, cut it into passages of a few hundred tokens each, and store one vector per passage instead of one vector per document.
Here is where it sits in the pipeline:
- Load — parse the PDF, HTML, or transcript into text
- Chunk — split that text into retrievable passages ← you are here
- Embed — convert each chunk into a vector
- Index — store vectors in a vector database
- Retrieve — at query time, return the top-k most similar chunks
- Generate — pass those chunks to the LLM as context

Figure 1: Chunking sits between loading and embedding. Every stage downstream inherits its decisions.
That is the classic retrieve-then-generate shape. For how the same pipeline changes when an agent decides what to retrieve, see Agentic RAG vs Traditional RAG.
The useful mental model is index cards, not books. You are not teaching the model your documents. You are writing index cards that a search engine will rank, and the model will only ever see the cards that got ranked. A fact that spans two cards is a fact your system can lose.
Why not just skip chunking?
Context windows are large now, so this is a fair question. Anthropic’s guidance is specific: if your entire knowledge base is under 200,000 tokens (roughly 500 pages), skip retrieval and put everything in the prompt. (Anthropic, September 2024)
Above that, three things break:
- Cost and latency scale with every token you send, on every single query
- Attention dilutes. The “lost in the middle” effect means models reliably miss information buried in the middle of long contexts (arXiv 2307.03172)
- You cannot rank what you did not split. If you need to tell the user which document an answer came from, you need chunks
Jina’s BEIR evaluation found one revealing exception: on two of five datasets, not chunking at all scored higher than chunking (TRECCOVID 65.18 vs 64.70; NFCorpus 30.40 vs 29.98 nDCG@10). As they note, that only helps if you never need to rank passages, which is rare in production. (Jina AI, August 2024)
Why your chatbot gives wrong answers without good chunking
Bad chunking does not produce one obvious failure. It produces four different ones, and they look like different bugs.

Figure 2: The four failure modes of bad chunking. Each one presents as a different bug.
1. The split answer
Your chunk boundary lands in the middle of the fact.
“…eligible employees may carry over up to” [CHUNK BREAK] “five unused vacation days into the following calendar year.”
Retrieval returns the first chunk because it matches “carry over vacation days.” The number is in the chunk nobody fetched. The model either says it does not know or guesses. This is the failure mode overlap was invented to fix.
2. The diluted embedding
An 1,800-token chunk covering refund policy, shipping timelines, and warranty terms gets one vector. That vector is the average of three unrelated topics, so it sits in no-man’s-land in embedding space and ranks poorly for all three queries. Nothing is broken. Nothing retrieves well either.
3. The orphan chunk
A chunk reads: “Revenue grew by 3% over the previous quarter.”
Whose revenue? Which quarter? The chunk is perfectly coherent and completely useless, because every word that identified it was in the heading two pages up. This is the exact example Anthropic uses, and it is the single most common cause of confidently wrong answers in production RAG.
4. The retrieval slot thief
This one is invisible in code review. A semantic or sentence splitter emits fragments of 0 to 4 tokens: a stray heading, a page number, a table caption. They are near-empty, they match almost anything weakly, and when they land in your top-10 they displace a chunk that had the answer. You have not lost data. You have lost a retrieval slot, which is worse because it is silent.
In the Ekimetrics 2026 evaluation, raw page-based and sentence-based splitters produced minimum chunk sizes of 0 to 4 tokens, while the same methods with size regularization had minimums of 69 to 104 tokens. (arXiv 2603.25333)
The amplification effect: why small chunking wins matter so much
Here is the finding that should change how you prioritize this work.
Ekimetrics measured chunking quality intrinsically, then ran the same RAG pipeline (same embedding model, same reranker, same generator, same prompts) on each chunking method. The intrinsic quality differences between their top methods were tiny — 0.4 to 2.4 percentage points. The downstream differences were not:
| Layer | Spread between top chunking methods |
|---|---|
| Intrinsic chunk quality | 0.4 – 2.4 pp |
| Retrieval completeness | 8 – 10 pp |
| Answer correctness | 5 – 8 pp |

Figure 3: The amplification effect. A 2-point chunking improvement becomes roughly a 6-point answer improvement.
Chunking gains compound. Slightly better chunks produce more relevant retrievals, which produce more complete context, which produces more correct answers. A 2-point improvement at the chunking layer is not a 2-point improvement at the answer layer. It is roughly a 6-point one.
And you cannot easily fix it later
Microsoft’s Azure Architecture Center is blunt about this: your chunking approach is a “semipermanent choice” that affects everything downstream. (Microsoft Learn, updated July 2026)
Swapping an LLM is a config change. Swapping a chunking strategy means re-parsing, re-chunking, re-embedding, and re-indexing every document, plus invalidating every stored chunk ID that anything else references. Decide carefully once.
Chunking, embedding, or retrieval: which one is actually broken?
Before you tune chunk size, confirm chunking is your problem. These symptoms point to different layers:
| Symptom | Most likely cause | What to check first |
|---|---|---|
| Answer is half right, cuts off mid-fact | Chunk boundary splitting the fact | Chunk size and overlap |
| Model answers confidently about the wrong entity or period | Orphan chunks with no identifying context | Contextual retrieval / metadata |
| Correct document retrieved, wrong section | Chunks too large, diluted embeddings | Reduce chunk size |
| Right chunk exists but never ranks | Embedding model mismatch, or tiny fragments stealing slots | Size regularization, then embeddings |
| Exact product codes or IDs never match | Pure dense retrieval with no keyword search | Add BM25 hybrid search |
| Tables return as meaningless rows | Table split across chunks without headers | Structure-aware chunking |
| Everything retrieves well, answers still vague | Generation or reranking, not chunking | Top-k, reranker, prompt |
If your symptom is in the bottom two rows, chunk size is not your bug and tuning it will waste a week.
The 9 chunking strategies, ranked by measured performance
Most guides present these as a neutral menu. They are not neutral. Here is the same list with measured intrinsic quality scores from the Ekimetrics 2026 study, which evaluated all of them on one heterogeneous corpus (legal, technical, and social science documents, 638,896 total tokens) using identical downstream models.
| Strategy | How it splits | Intrinsic score | Chunk runtime | Verdict |
|---|---|---|---|---|
| Recursive, size-regularized (s=1100) | Separator hierarchy, then merge/re-split to size bounds | 90.68% | 31s | Best single method |
| Page-based, size-regularized | Document pages, then size-regularized | 90.52% | 4s | Underrated; fastest |
| LLM-guided regex | LLM proposes split rules, regex applies them | 89.80% | 147s | Good, slow, costly |
| Recursive, size-regularized (s=600) | Same, smaller target | 89.24% | 28s | Good for short queries |
| Page-based, raw | Pages, no post-processing | 89.03% | 0.01s | Decent baseline |
| LangChain recursive, default params | Separator hierarchy, no post-processing | 88.62% | 0.04s | The common default |
| LangChain recursive (s=1100) | Same, tuned size | 88.37% | 6s | — |
| Semantic | Embedding-similarity boundaries | 76.49% | 389s | Worst but one |
| Sentence-based | One or few sentences per chunk | 73.26% | 30s | Worst overall |
| Adaptive (per-document selection) | Picks the best of the above per document | 91.07% | 211s | Best overall |
Source: de Moura Júnior, Lelong & Blangero, Ekimetrics, March 2026, Table 3. Differences between adaptive and every individual method are statistically significant (Wilcoxon signed-rank, p < 0.001).

Figure 4: Nine chunking strategies by measured intrinsic quality. Semantic chunking sits 14 points below plain recursive splitting.
Read that table twice. Semantic chunking, the method most guides present as the sophisticated upgrade, scored 14 points below plain recursive splitting and took 12 times longer to run. We will come back to why.
1. Fixed-size / token chunking
Split every N tokens, optionally with overlap. The honest baseline.
Use when: your corpus is homogeneous and unstructured, or you need a baseline to beat.
Watch for: splitting mid-sentence and destroying tables.
One critical detail almost every published guide gets wrong: in LangChain’s CharacterTextSplitter and RecursiveCharacterTextSplitter, chunk_size counts characters by default, not tokens. Multiple page-one guides for this keyword show code using character-based splitters while their prose recommends token counts, and never reconcile the two. A chunk_size=1000 is roughly 250 tokens of English, not 1,000. Pass a length_function tied to your actual tokenizer, or use TokenTextSplitter.
2. Recursive chunking (the quiet winner)
Try separators in order of preference — paragraph breaks, then line breaks, then sentence ends, then spaces — splitting on the biggest unit that still fits your size limit.
This is the strategy that keeps winning benchmarks it is not supposed to win. Chroma found it “consistently high performing across all evaluation metrics” and better than token splitting on every metric at sizes of 400 tokens or less with no overlap. Ekimetrics found the size-regularized version the best single method of nine.
Use when: you do not have a specific reason to use something else. This is the correct default.
One tuning note from Chroma: LangChain’s default separator list ["nn", "n", " ", ""] produces very short chunks on prose, because it falls straight from line breaks to spaces. They used ["nn", "n", ".", "?", "!", " ", ""] instead, adding sentence boundaries. (Chroma Research, July 2024)
3. Document-structure-based chunking
Split on the document’s own markup: Markdown headings, HTML tags, code functions, LaTeX sections. Carry the heading path into each chunk’s metadata.
Use when: your documents have real structure — docs sites, knowledge bases, API references, contracts with numbered clauses.
Why it works: the author already decided where the topic boundaries are. Using embeddings to re-discover boundaries that are sitting right there in <h2> tags is paying compute to guess at something you already know.
Unstructured makes the same point directly: for well-structured documents, structure-aware chunking is both better and cheaper than semantic chunking. (Unstructured, July 2026)
4. Page-based chunking (the one nobody writes about)
Split on page boundaries, then regularize sizes.
Not a single page-one guide for this keyword lists this strategy. In the Ekimetrics study it scored 90.52%, within 0.16 points of the best method, ran in 4 seconds versus 31 for recursive, and the adaptive selector chose it for 48% of all documents — more than any other method.
Use when: your corpus is paginated with page-aligned semantics — scanned reports, filings, forms, academic PDFs, anything with per-page tables or footnotes.
Why it works: in a printed document, the page break often is a deliberate structural boundary. Page-based chunking scored a near-perfect 99.9% block integrity, meaning it almost never split a table or figure.
If you are chunking PDFs and have not benchmarked page-based splitting, you are skipping a method that beat seven of the eight alternatives at a fraction of the cost.
5. Sentence-based chunking
One sentence, or a few, per chunk.
Measured result: worst of nine methods (73.26%). It had the highest internal cohesion of any method (78.4% — each chunk is tightly about one thing) and the lowest block integrity (61.9% — it shreds tables, lists, and title-body pairs). Mean chunk size of 146 tokens across 8,125 chunks.
Use when: you are doing sentence-level fact extraction or citation pinning, and you pair it with parent-document retrieval so the model sees surrounding context.
Do not use when: your documents contain tables or structured blocks.
6. Semantic chunking
Embed consecutive sentences, measure similarity between neighbours, split where similarity drops below a threshold. Unstructured’s default threshold is around 0.5 cosine similarity; lower thresholds split more often and produce smaller chunks.
The theory is excellent. The measurements are not kind to it.
| Study | Finding |
|---|---|
| Ekimetrics 2026 | Intrinsic score 76.49% vs 90.68% for size-regularized recursive. Size compliance 48.1% ± 17.6 — half its chunks fell outside the 100–1,100 token bounds. Longest chunk: 17,146 tokens. Runtime 389s vs 31s |
| Chroma 2024 | Kamradt semantic chunker recall 83.6% vs 89.5% for recursive at 400 tokens with no overlap |
| Secondary reports, Feb 2026 | A widely-cited FloTorch/Vecta test reports recursive 512-token chunking at ~67–69% end-to-end answer accuracy vs ~54% for semantic. Treat with caution: the primary report could not be verified and two different figures circulate |
The failure mode is consistent and fixable. Semantic chunkers use a relative threshold, so chunk sizes are uncontrolled. On a long document with gradually drifting topics, no boundary trips and you get a 17,000-token chunk. On a list of short items, every boundary trips and you get fragments.
Use when: your documents have genuine topic shifts and no usable structural markup — meeting transcripts, support chat logs, interview notes.
Always: pair it with a minimum and maximum size bound. Semantic chunking without size regularization is the single most common unforced error in RAG pipelines. With it, the same study lifted semantic chunking’s size compliance from 48.1% to 99.9% and its mean score from 76.5% to roughly 90%.
7. Late chunking
Invert the order. Run the whole document through a long-context embedding model first, get one vector per token with full-document context baked in, then apply chunk boundaries and mean-pool the token vectors inside each chunk.

Figure 5: Naive chunking splits then embeds. Late chunking embeds then splits, so each chunk vector carries document context.
The chunks are identical. The embeddings are not: each chunk’s vector now “knows” about the rest of the document. Jina’s measured results on BEIR (nDCG@10, jina-embeddings-v2-small-en, ~256-token boundaries):
| Dataset | Avg doc length | Naive chunking | Late chunking | Gain |
|---|---|---|---|---|
| NFCorpus | 1,590 chars | 23.46% | 29.98% | +6.52 pp |
| SciFact | 1,498 chars | 64.20% | 66.10% | +1.90 pp |
| TRECCOVID | 1,117 chars | 63.36% | 64.70% | +1.34 pp |
| FiQA2018 | 767 chars | 33.25% | 33.84% | +0.59 pp |
| Quora | 62 chars | 87.19% | 87.19% | 0.00 pp |
The pattern is clean: the longer your documents, the more late chunking helps. On Quora’s 62-character documents it does literally nothing.
Requires: a long-context embedding model (8K+ tokens). It is not a splitter you can bolt onto any stack.
Use when: long documents, heavy pronoun and reference chains — research papers, legal filings, technical manuals.
One note, because two top-ranking guides get this wrong: late chunking is not the same as post-chunking or chunking at query time. Late chunking is about when you embed. Post-chunking is about when you split. They are unrelated techniques.
8. Contextual retrieval (contextual chunking)
Before embedding each chunk, send the full document plus that chunk to an LLM and ask for one or two sentences situating it. Prepend that to the chunk. This is the direct fix for orphan chunks.
Before: “The company’s revenue grew by 3% over the previous quarter.”
After: “This chunk is from an SEC filing on ACME corp’s performance in Q2 2023; the previous quarter’s revenue was $314 million. The company’s revenue grew by 3% over the previous quarter.”
Anthropic’s measured results, using 1 − recall@20 as the retrieval failure rate against a 5.7% baseline:
| Configuration | Failure rate | Relative reduction |
|---|---|---|
| Baseline (embeddings only) | 5.7% | — |
| + Contextual embeddings | 3.7% | −35% |
| + Contextual BM25 (hybrid) | 2.9% | −49% |
| + Reranking (150 → top 20) | 1.9% | −67% |

Figure 6: Contextual retrieval, hybrid BM25, and reranking stack. Together they cut retrieval failures by 67%.
Cost: $1.02 per million document tokens, one-time at indexing, with prompt caching on the source document. Generated context runs 50 to 100 tokens per chunk.
This is the best measured return in the entire chunking literature, and it stacks with everything else. If you only implement one advanced technique from this page, implement this one.
The prompt Anthropic published, with the two placeholders in single braces:
<document>
{WHOLE_DOCUMENT}
</document>
Here is the chunk we want to situate within the whole document
<chunk>
{CHUNK_CONTENT}
</chunk>
Please give a short succinct context to situate this chunk within
the overall document for the purposes of improving search retrieval
of the chunk. Answer only with the succinct context and nothing else.
One accuracy note worth knowing: several 2026 articles attribute this “35% reduction” figure to semantic chunking. It is not a semantic chunking result. It is contextual embeddings, measured by Anthropic in September 2024. If you see that number credited to semantic chunking, the source copied it without checking.
9. LLM-based, agentic, and adaptive chunking
Three distinct things that get used interchangeably:
- LLM-based chunking — an LLM proposes the boundaries. Measured at 89.80% intrinsic quality, 147s runtime. Chroma’s LLM chunker achieved the highest recall of any method tested (91.9%). Real, works, costs money
- Agentic chunking — an agent inspects the document and picks a strategy for it. For the wider pattern this belongs to, see Agentic RAG: How It Works
- Adaptive chunking — the parameters adjust per document, not the strategy
Adaptive selection is the only one with strong published evidence, and it is worth understanding even if you never build it. Ekimetrics scored four candidate chunkers per document on five intrinsic metrics and kept the winner. Results, with everything else held constant:
| Metric | Adaptive | LangChain recursive (default) | Page (raw) |
|---|---|---|---|
| Retrieval completeness | 67.68% | 58.08% | 59.09% |
| Answer correctness | 78.01% | 70.11% | 73.33% |
| Mean | 71.77% | 62.07% | 63.80% |
| Questions answered | 65 / 99 | 49 / 99 | 49 / 99 |
+9.60 pp retrieval completeness and 16 more answered questions (+32.7%) over the default LangChain splitter, with no change to the embedding model, reranker, prompt, or LLM.
And the distribution of which method won tells you the real lesson:
| Selected method | Share of documents |
|---|---|
| Page-based, size-regularized | 48% |
| Recursive, size-regularized (s=1100) | 42% |
| LLM-guided regex | 6% |
| Recursive, size-regularized (s=600) | 3% |
Two different strategies each won on roughly half the corpus. “There is no universal best chunking strategy” is not a hedge. It is an experimental result.
What chunk size should you use?
Start at 400 to 512 tokens with a recursive splitter and zero overlap if you are using a modern embedding model. Then test 200 and 800 on your own queries. Here is the evidence behind that.
The measured numbers
Chroma’s study is the only public head-to-head on chunk size with token-level metrics. Setup: text-embedding-3-large, top-5 retrieval, 472 queries across five corpora (political speech, Wikipedia, chat logs, finance, biomedical).
| Strategy | Size | Overlap | Recall | Precision | IoU |
|---|---|---|---|---|---|
| Recursive | 800 | 400 | 85.4% | 1.5% | 1.5% |
| Recursive | 400 | 200 | 88.1% | 3.3% | 3.3% |
| Recursive | 400 | 0 | 89.5% | 3.6% | 3.6% |
| Recursive | 200 | 0 | 88.1% | 7.0% | 6.9% |
| Token | 400 | 0 | 89.2% | 2.7% | 2.7% |
| Cluster-semantic | 400 | 0 | 91.3% | 4.5% | 4.5% |
| LLM chunker (GPT-4o) | ~240 | 0 | 91.9% | 3.9% | 3.9% |
| Kamradt semantic | ~660 | 0 | 83.6% | 1.5% | 1.5% |
Source: Chroma Research, July 2024. Precision and IoU are token-level, so the absolute values are low by construction; compare them across rows, not to 100%.

Figure 7: Smaller chunks barely cost recall and sharply improve precision. The 800/400 default is the worst row in the table.
Three things fall out of this table:
1. 800/400 is a bad default. Chroma singles out the OpenAI Assistants default of 800 tokens with 400 overlap: “slightly below-average recall and the lowest scores across all other metrics.” If you are on a framework default, check what it actually is.
2. Smaller chunks trade recall for precision, and the trade is good. Going 400 → 200 costs 1.4 points of recall and nearly doubles precision. If your downstream context budget is tight, 200 tokens is usually the better buy.
3. Removing overlap improved both recall and IoU at 400 tokens. Which brings us to the most contradicted parameter in this entire topic.
Overlap: resolving the contradiction
The page-one guides for this keyword disagree flatly:
| Source | Overlap recommendation |
|---|---|
| Weaviate (Sep 2025) | 10–20% of chunk size |
| Databricks (Apr 2025) | 10–20% general, 15–25% code |
| DataCamp (Sep 2025) | 20–50% |
| Pinecone (Jun 2025) | No guidance given |
| Microsoft Learn (2026) | No value given |
They are not all wrong. They are describing different embedding models, and none of them says so. Chroma ran the same grid on a weaker model, all-MiniLM-L6-v2:
| Embedding model | 250/125 (50% overlap) | 250/0 (no overlap) |
|---|---|---|
| all-MiniLM-L6-v2 | 82.4% recall | 77.1% recall |
| text-embedding-3-large (at 400) | 88.1% recall | 89.5% recall |

Figure 8: Overlap compensates for weak embedding models. On a strong model it costs recall and precision both.
The resolution: overlap compensates for weak embedding models. On MiniLM, dropping overlap cost 5.3 points of recall — Chroma concludes that “for smaller context, overlapping chunks are necessary for high recall.” On text-embedding-3-large, overlap actively hurt, costing recall and precision while inflating your index.
Practical rule:
- Modern large embedding model (text-embedding-3-large, Voyage, Gemini, Qwen3-Embedding, Jina v3) → start at 0% overlap, add only if you can measure a gain
- Small or older model (MiniLM, MPNet, anything under 384 dimensions) → 20 to 50% overlap, and budget for the index growth
- Either way → overlap costs storage, embedding spend, and near-duplicate results in your top-k. It is a fix for boundary loss, not a free safety margin
Chunk size by content type
Measured data does not exist for every content type, so this table combines the published studies above with the recommendations of Databricks, Weaviate, and DataCamp. Treat it as a starting grid to test, not as gospel.
| Content type | Starting size | Overlap | Strategy |
|---|---|---|---|
| General prose, policy docs | 400–512 tokens | 0–10% | Recursive |
| Technical docs with headings | By section, cap 1,000 | 0 | Structure-aware |
| Source code | 100–200 tokens | 15–25% | Language-aware recursive |
| Narrative, long reports | 512–1,024 tokens | 10% | Recursive + late chunking |
| FAQ, Q&A pairs | 1 pair per chunk | 0 | Structure-aware |
| Chat and support logs | 1 conversation turn group | 0 | Semantic, size-bounded |
| Tables | 1 row group, header repeated | 0 | Custom, never split headers |
| Scanned PDFs, filings | 1 page, size-regularized | 0 | Page-based |
| Short product listings | No chunking | — | Index whole records |
Always enforce bounds regardless of row: minimum 100 tokens, maximum 1,100. Which is the next section, and the one most guides skip entirely.
Three things the top-ranking guides get wrong
Myth 1: “Semantic chunking is the sophisticated upgrade”
Every major guide for this keyword presents semantic chunking as the step up from recursive splitting. Four independent measurements disagree: 76.49% vs 90.68% intrinsic quality (Ekimetrics), 83.6% vs 89.5% recall (Chroma), and roughly 54% vs 67–69% end-to-end accuracy in secondary reports.
Semantic chunking is not bad. Unbounded semantic chunking is bad, because a relative similarity threshold gives you no control over chunk size, and size turns out to matter more than boundary elegance. Bound it and it becomes competitive. Ship it unbounded and you will ship a 17,000-token chunk without noticing.
Myth 2: “More overlap is safer”
Overlap is insurance against boundary loss, and like all insurance it has a premium: more vectors, higher embedding cost, and near-duplicate chunks crowding your top-k. On a strong embedding model, Chroma measured overlap making recall and precision worse. The “safe” choice was the worse one.
Myth 3: “chunk_size=1000 means 1,000 tokens”
It usually does not. LangChain’s character splitters count characters. Several published tutorials for this keyword — including ones ranking in the top five — show character-based code under prose recommending token counts, and never reconcile them. English runs roughly 4 characters per token, so chunk_size=1000 is about 250 tokens. If your “500-token” chunks are quietly 125 tokens, every benchmark you read will mislead you.
Check this before you tune anything else. It takes one line:
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("your-embedding-model")
lengths = [len(tok.encode(c.page_content)) for c in chunks]
print(f"mean {sum(lengths)/len(lengths):.0f} min {min(lengths)} max {max(lengths)}")
If min is under 20 or max is over double your target, your splitter is not doing what you think it is doing.
The step almost nobody writes about: size regularization
This is the highest return-on-effort change in this entire guide, and it appears in none of the page-one results for this keyword.
After you chunk, run two passes:
- Tiny-chunk merge — any chunk under your minimum (100 tokens) gets merged forward into its neighbour, up to a hard ceiling (1,150 tokens)
- Oversized re-split — any chunk over your maximum (1,100 tokens) gets recursively re-split

Figure 9: Two post-processing passes. No LLM calls, no embeddings, and 6 to 16 percentage points of measured gain.
That is it. No LLM calls, no embeddings, negligible runtime. Measured effect in the Ekimetrics study: +6 to +16 percentage points on mean intrinsic quality across every method tested.
The most dramatic case was semantic chunking:
| Measure | Raw | Regularized |
|---|---|---|
| Size compliance | 48.1% | 99.9% |
| Mean intrinsic score | 76.5% | ~90% |
Same splitter. Same embeddings. Two post-processing passes.
MIN_TOKENS, MAX_TOKENS, MERGE_CEILING = 100, 1100, 1150
def regularize(chunks, count_tokens, resplit):
# Pass 1: re-split anything oversized
expanded = []
for c in chunks:
expanded.extend(resplit(c) if count_tokens(c) > MAX_TOKENS else [c])
# Pass 2: merge anything undersized into its neighbour
out = []
for c in expanded:
if out and count_tokens(out[-1]) < MIN_TOKENS
and count_tokens(out[-1]) + count_tokens(c) <= MERGE_CEILING:
out[-1] = out[-1] + "n" + c
else:
out.append(c)
return out
Two notes from the paper. Compliance does not always reach 100%, because the authors prioritised never exceeding the ceiling over always hitting the floor — a slightly-too-small chunk is less harmful than an oversized one. And the gain comes from eliminating the retrieval slot thieves: fragments of 0 to 4 tokens that carry no meaning but still compete for space in your top-k.
If you do one thing after reading this page, do this one.
How to measure chunking quality before you ship
Every guide on this topic ends with “experiment and measure.” Almost none of them say what to measure. This is the real gap in the published literature, and it has a good answer.
There are two layers, and the first one does not require a single query.
Layer 1: intrinsic metrics (no test queries needed)
You can score chunk quality from the chunks and the source document alone. Ekimetrics formalised five metrics, and their Spearman correlations are weak to moderate (−0.44 to 0.31), meaning each one catches something the others miss.
| Metric | What it measures | What it catches |
|---|---|---|
| Size compliance (SC) | Share of chunks inside your token bounds | Oversized blobs, tiny fragments |
| Block integrity (BI) | Share of tables, figures, title-body pairs left unbroken | Split tables, orphaned headings |
| References completeness (RC) | Share of pronouns and references whose antecedent is in the same chunk | “it”, “the company”, “this policy” with no referent |
| Intrachunk cohesion (ICC) | Mean cosine similarity between each sentence and its chunk embedding | Multi-topic chunks with diluted vectors |
| Document contextual coherence (DCC) | Mean similarity between each chunk and its surrounding 3,000-token window | Chunks that lost their place in the document |

Figure 10: The five intrinsic metrics, and the two built-in tensions. You cannot maximise all of them at once.
Two deliberate tensions are built in, and understanding them is most of the skill:
- ICC vs DCC. Smaller chunks are more internally cohesive but know less about their surroundings. Larger chunks preserve context but mix topics. You cannot maximise both.
- ICC vs BI. Keeping a table with its title and explanation intact puts heterogeneous content in one chunk, which lowers cohesion. Correctly.
This is why optimising a single metric fails. A sentence splitter wins cohesion outright (78.4%, best of nine) and still finishes last overall, because it destroys block integrity (61.9%, worst of nine).
Start with SC and BI. They need no embeddings, run in seconds, and catch the two failures that actually break production systems.
Layer 2: extrinsic metrics (test queries required)
Build a query set and measure retrieval directly. Chroma’s method is the one to copy, because it scores at the token level rather than the document level — which is the only way to tell a chunk that contains the answer from a chunk that is the answer:
- Recall — share of answer tokens that appeared anywhere in the retrieved chunks
- Precision — share of retrieved tokens that were actually answer tokens
- IoU — token-level Jaccard overlap, which penalises retrieving padding. This is the metric overlap hurts
Document-level benchmarks like MTEB and BEIR cannot evaluate chunking at all, because they score whole documents. If a guide tells you to evaluate chunking with BEIR, it has not thought it through.
The 60-minute evaluation recipe
- Sample 20 documents that look like your worst cases: longest, most tables, messiest formatting
- Generate 50 to 100 test queries. Give an LLM a document, ask for a factual question plus the verbatim excerpt that answers it, and reject any excerpt that is not an exact string match in the source. Filter near-duplicate queries by embedding similarity
- Chunk four ways: recursive at 200, recursive at 400, recursive at 800, and your current production setting. All with size regularization
- Score intrinsically. Print mean, min, max token count and size compliance per variant. Discard any variant with a min under 50 or a max over double its target
- Score extrinsically. For each query, retrieve top-5 and compute token-level recall and IoU against the gold excerpt
- Pick on recall if your context budget is loose, IoU if it is tight. Re-run whenever your corpus composition or embedding model changes
Cost, from Chroma’s own figures: roughly $0.01 per generated question, so a 1,000-question evaluation set runs about $10. Query generation takes 3 to 16 seconds each, averaging 10.
Ten dollars and an hour, against a semipermanent architectural decision. There is no excuse for guessing.
What this costs in production
The only published per-token figures worth planning against:
| Operation | Cost | Source |
|---|---|---|
| Contextual retrieval, one-time at index | $1.02 per million document tokens | Anthropic, Sep 2024 |
| Evaluation set, 1,000 questions | ~$10 | Chroma, Jul 2024 |
| Prompt caching on source documents | up to 90% cost reduction, >2× latency reduction | Anthropic, Sep 2024 |
| Semantic chunking runtime penalty | 389s vs 31s per corpus (~12×) | Ekimetrics, Mar 2026 |
| LLM-guided chunking runtime | 147s vs 31s (~5×) | Ekimetrics, Mar 2026 |
Microsoft’s guidance adds the four variables that actually drive your bill: number of distinct chunking implementations you maintain, per-document processing cost of each, initial document count, and incremental document rate. The last one is the one teams forget, and it is the one that compounds.
Chunking tables, PDFs, images, audio, and video
Text chunking advice does not transfer. Here is what each modality actually needs, drawing on Microsoft’s Azure guidance and a 2025 IBM survey of multimodal chunking.
| Modality | Unit to split on | Tools | The one rule |
|---|---|---|---|
| Tables | Row groups | Custom parsers, Docling | Repeat the header row in every chunk. A table body without its headers is noise |
| PDFs | Page or section | Document Intelligence, Unstructured, Docling | Convert to Markdown first, OCR scanned pages, then chunk the Markdown |
| Images | Objects or regions | Detectron2, YOLO, region proposal | Convert to text via a vision model, then chunk the description. Carry the image URL into every chunk the description spans |
| Audio | Silence or speaker turns | Whisper, diarization | Split on silence and speaker change, never on fixed time windows |
| Video | Shots or scenes | PySceneDetect | Shot-based beats fixed-duration. Keep the transcript aligned to the shot |
| Code | Functions and classes | Language-aware recursive splitters | Never split a function body |
Sources: Microsoft Learn, Chunking Strategies for Multimodal AI Systems, arXiv 2512.00185

Figure 11: Each modality has its own natural split unit. Fixed-size windows are wrong for all but plain prose.
Two things that will bite you:
Tables are the most common silent failure in enterprise RAG. A table split across two chunks leaves the second chunk as a grid of numbers with no column labels. The model will cheerfully read values from the wrong column. Repeating the header is a two-line fix.
Multimodal chunking economics are different. Microsoft notes that image costs scale with image size and recommends a cache-aside pattern keyed on an image hash: check cache, run a cheap classifier, cache the result, then generate the expensive description only once. If your pipeline re-describes the same logo on 4,000 pages, that is your bill.
Pick your strategy in 60 seconds
Work down this list and stop at the first match.
- Corpus under 200,000 tokens total? Skip RAG. Put it in the prompt.
- Records already short and self-contained (products, tickets, FAQ pairs)? Do not chunk. Index whole records.
- Documents have real headings or markup? Structure-aware chunking, cap at 1,000 tokens.
- Paginated PDFs, filings, or scans? Page-based chunking with size regularization. Benchmark it before assuming recursive wins.
- Everything else? Recursive splitting at 400 tokens, zero overlap, size-regularized. This is the default that keeps beating its reputation.
- Unstructured transcripts or chat logs with real topic drift? Semantic chunking, size-bounded. Never unbounded.
- Still losing on pronouns, entity names, or “which quarter” style failures? Add contextual retrieval. Best measured return of any technique here.
- Long documents and a long-context embedding model? Add late chunking on top.
- Genuinely heterogeneous corpus and the budget to index properly? Score 3 to 4 chunkers per document on intrinsic metrics and keep the winner.

Figure 12: The decision path. Stop at your first match, then apply size regularization regardless.
Whatever you pick, apply size regularization. It is strategy-independent and it is free.
Production checklist
Things that break after launch, not before:
- ☐ Token counts verified against your actual tokenizer, not assumed from
chunk_size - ☐ Size bounds enforced — min 100, max 1,100 tokens, after every strategy
- ☐ Table headers repeated in every chunk of a split table
- ☐ Metadata on every chunk — source file, page, heading path, chunk index, document version
- ☐ Stable chunk IDs that survive re-indexing, or everything referencing them breaks
- ☐ Hybrid retrieval (BM25 + dense) — contextual BM25 alone took Anthropic’s failure rate from 3.7% to 2.9%
- ☐ Incremental update path. Cluster-based and globally-optimised chunkers must recompute when documents are added. Know this before you choose one
- ☐ Re-index trigger documented — what changes force a full rebuild, and how long it takes
- ☐ Loading separated from chunking, with the parsed output persisted, so you can try new chunkers without re-parsing
- ☐ A held-out query set you re-run on every pipeline change
- ☐ Chunk-length distribution monitored in production. Drift in your source documents shows up here first
Frequently asked questions
What is chunking strategy in RAG?
A chunking strategy is the rule that decides where one retrievable passage ends and the next begins. The main families are fixed-size (split every N tokens), recursive (split on a separator hierarchy), structure-aware (split on headings or markup), page-based (split on pages), sentence-based, semantic (split where embedding similarity drops), and LLM-driven. Measured across nine methods on a mixed corpus, size-regularized recursive splitting scored highest among single strategies at 90.68%, and per-document adaptive selection scored 91.07%.
What is a good chunk size for RAG?
Start at 400 to 512 tokens. Chroma measured 89.5% recall for recursive splitting at 400 tokens with no overlap, versus 85.4% at 800 tokens with 400 overlap. Drop to 200 tokens if your queries are narrow and factual — recall falls about 1.4 points but token-level precision nearly doubles. Go to 512 to 1,024 for summarization and analytical queries. Enforce a 100-token floor and a 1,100-token ceiling whatever you pick, then test two or three sizes on your own queries, because optimal size depends on your corpus and embedding model.
What is chunking with an example?
Take a 12-page HR policy PDF. Instead of storing one embedding for all 12 pages, you split it into ~40 passages of about 400 tokens each: one on eligibility, one on carry-over limits, one on the approval process, and so on. When someone asks “how many vacation days can I carry over?”, retrieval returns the carry-over passage alone. Without chunking, the system would either return all 12 pages or fail to match at all.
Is semantic chunking better than recursive chunking?
Usually not, on the published evidence. Semantic chunking scored 76.49% intrinsic quality against 90.68% for size-regularized recursive splitting, with 389 seconds of runtime against 31. Chroma measured 83.6% recall for a semantic chunker against 89.5% for recursive at 400 tokens. The reason is size control: semantic chunkers use relative similarity thresholds and produced one chunk of 17,146 tokens in testing. Bound semantic chunking with minimum and maximum sizes and it becomes competitive — unbounded, it underperforms a much simpler method.
Do I still need chunking with a 1M-token context window?
Usually yes. Anthropic’s threshold is 200,000 tokens, or about 500 pages: below that, put everything in the prompt. Above it, you still need chunking for cost control, latency, citation of sources, and because long-context attention reliably degrades in the middle of the window. There is one measured exception: Jina found that on two of five BEIR datasets, not chunking scored higher — but that only applies when you never need to rank or cite individual passages.
What is the difference between late chunking and contextual retrieval?
Both fix the orphan chunk problem, differently. Late chunking embeds the whole document first and then pools token vectors per chunk, so each chunk’s vector carries document context without changing the text. It needs a long-context embedding model and no LLM calls. Contextual retrieval uses an LLM to write a one or two sentence summary situating each chunk, and prepends it to the text before embedding. It works with any embedding model and costs about $1.02 per million document tokens. Late chunking is cheaper; contextual retrieval has the larger measured effect, cutting retrieval failures by 35% on its own and 49% paired with BM25.
How much does chunking cost?
Basic splitting is free. The variable costs: contextual retrieval runs $1.02 per million document tokens one-time at indexing; semantic chunking costs roughly 12× the runtime of recursive; LLM-guided chunking about 5×; and a 1,000-question evaluation set costs about $10. Size regularization, the highest-return technique here, costs essentially nothing. Budget by number of distinct chunking implementations, per-document processing cost, initial document count, and your incremental document rate.
Can I change my chunking strategy later?
Technically yes, cheaply no. Microsoft describes chunking as a “semipermanent choice.” Changing it means re-parsing, re-chunking, re-embedding, and re-indexing every document, and invalidating every stored chunk ID. Mitigate it up front: separate your loading step from your chunking step and persist the parsed output, so swapping chunkers does not mean re-parsing. Use stable, content-derived chunk IDs. Keep a held-out query set so you can prove a new strategy is better before you commit to the re-index.
4 thoughts on “What Is Chunking in RAG? Why Your Chatbot Gives Wrong Answers Without It”