Chunking Strategies for RAG Systems
How to split documents for RAG: fixed-size, recursive, structure-aware, semantic, late and contextual chunking, plus how to pick chunk size and overlap.
Chunking is the step in a retrieval-augmented generation (RAG) pipeline where long documents are split into smaller passages before they are embedded and indexed. The right strategy keeps each chunk small enough to retrieve precisely and fit model limits, but complete enough to make sense on its own. There is no single best chunk size: it depends on your documents, your queries and your models, so the reliable approach is to start from a sensible default and measure.
Why chunking matters
A RAG system never retrieves a "document." It retrieves chunks, each turned into a vector by an embedding model and stored in a vector database. Whatever boundaries you draw at indexing time decide what the system can find later.
There are two hard reasons to chunk and one soft one.
Model input limits. Embedding models have a maximum input. As of November 2026, OpenAI's text-embedding-3 models accept up to 8,192 tokens [7], and Voyage's current general models accept 32,000 [8]. Microsoft's Azure AI Search documentation notes that the Azure OpenAI text-embedding-3-small model caps input at 8,191 tokens, roughly 6,000 words, and that chunking "prevents data loss due to truncation" [1].
Prompt budget. Retrieved chunks have to fit into the LLM's prompt alongside the question and instructions.
Retrieval quality. Even when a document fits, a single vector for a long, multi-topic page blurs its meaning. Microsoft makes this point directly: chunking helps when content "is poorly represented as a single vector," such as a wiki page covering many sub-topics [1].
There is also a cost on the generation side. Research on long contexts found that LLMs use information best when it appears at the beginning or end of the input, and performance degrades when the relevant facts sit in the middle of a long context [9]. Stuffing many oversized chunks into a prompt doesn't guarantee the model will use them.
The core trade-off
Smaller chunks | Larger chunks |
|---|---|
Precise matches; each vector has one clear topic | More surrounding context per hit |
More chunks to store and search | Fewer chunks, cheaper index |
Risk: a chunk loses the context that explains it | Risk: the relevant sentence is diluted by unrelated text |
Good for factoid questions | Good for "explain" or "summarize" questions |
Everything below is a different way of managing that trade-off.
Chunking strategies, from simple to advanced
1. Fixed-size chunking
Split text every N characters or tokens, usually with some overlap so a sentence cut at a boundary appears in both neighbors.
It's simple, predictable and fast. It ignores meaning, so it can split mid-sentence or separate a heading from its paragraph.
Fixed-size chunking has a respectable research pedigree. The Dense Passage Retrieval paper split Wikipedia into disjoint 100-word blocks, producing 21,015,324 passages, and prepended each passage with its article title [3]. That last detail, adding the title, is a cheap trick worth copying.
Starting point from official docs. Microsoft's Azure AI Search guidance recommends "starting with a chunk size of 512 tokens (approximately 2,000 characters) and an initial overlap of 25%, which equals 128 tokens" [1]. Elsewhere on the same page it gives a character-based default of 2,000 characters with 500 characters of overlap for its Text Split skill, and mentions fixed sizes such as 200 words with 10 to 15% overlap as reasonable inputs for embedding [1]. Treat these as starting points to test, not answers.
Microsoft also warns that overlap needs vary: highly structured data may need less, while conversational or narrative text may benefit from more [1].
2. Recursive (separator-based) chunking
Instead of cutting at a fixed count, try to split at natural boundaries first, and only fall back to smaller boundaries when a piece is still too big. LangChain's RecursiveCharacterTextSplitter "attempts to keep larger units (e.g., paragraphs) intact," and if a unit exceeds the chunk size, "it moves to the next level (e.g., sentences)" [2]. LangChain recommends this splitter as the default for most use cases [2].
This is usually the best first upgrade from naive fixed-size splitting, because it respects paragraphs and sentences at almost no extra cost.
3. Structure-aware chunking
Many documents already tell you where the sections are. LangChain's docs describe splitting Markdown by headers, HTML by tags, JSON by objects, and code by functions or classes [2]. Microsoft notes that heading syntax in HTML or Markdown "can be used to chunk data by sections" [1].
Structure-aware chunking shines on manuals, policies, API docs and knowledge-base articles. A practical enhancement from Microsoft's guidance: append the document title to chunks from the middle of a long document "to prevent context loss" [1].
4. Semantic chunking
Semantic chunking breaks text into "meaningful units that preserve context and semantic relationships across sentences and paragraphs," as Microsoft puts it, and such chunks can span page boundaries [1]. A common implementation embeds each sentence and starts a new chunk when the topic shifts.
It costs more at indexing time, and the benefit depends on how messy your documents are. Well-structured content often gets most of the gain from structure-aware splitting alone.
5. Proposition-level chunking
At the fine-grained extreme, you can index propositions: short, self-contained statements that each carry one fact. The Dense X Retrieval paper found that indexing by propositions "significantly outperforms passage-level units in retrieval tasks," and that fine-grained units improved downstream question answering under a fixed compute budget [4]. Producing propositions usually requires an LLM pass over every document, which adds cost.
6. Late chunking
Normal chunking embeds each piece in isolation, so a chunk that says "its revenue grew" loses track of what "its" refers to. Late chunking, proposed by Günther and colleagues in 2024, flips the order: embed the whole long text with a long-context embedding model first, then split the token-level outputs into chunks "after the transformer model and just before mean pooling" [5]. Each chunk vector therefore carries context from the full document. The authors report better retrieval across various tasks, and the method needs no additional training [5]. It requires an embedding model with a long context window and access to token-level outputs.
7. Contextual chunking
Anthropic's Contextual Retrieval method, published in September 2024, takes another route to the same problem. Before indexing, an LLM reads the full document and writes a short context, usually 50 to 100 tokens, explaining where each chunk fits. That context is prepended to the chunk before both embedding and keyword (BM25) indexing [6].
On Anthropic's own evaluation, measured as the share of relevant chunks missing from the top 20 results:
- Contextual embeddings reduced that failure rate by 35% (5.7% to 3.7%).
- Adding contextual BM25 reduced it by 49% (5.7% to 2.9%).
- Adding a reranker on top reduced it by 67% (5.7% to 1.9%) [6].
These are vendor-reported numbers on vendor-chosen datasets, but the mechanism is easy to understand and to test. The trade-off is one LLM call per chunk at indexing time.
Strategy comparison
Strategy | Respects meaning | Indexing cost | Best fit |
|---|---|---|---|
Fixed-size + overlap | No | Lowest | Baseline, uniform text |
Recursive | Partly (paragraphs, sentences) | Low | Default for most prose [2] |
Structure-aware | Yes, via headings and tags | Low | Docs, wikis, code, HTML |
Semantic | Yes, via topic shifts | Medium | Unstructured long text |
Proposition | Yes, one fact per unit | High (LLM pass) | Factoid Q&A [4] |
Late chunking | Adds document context to vectors | Medium (long-context model) | Text with many cross-references [5] |
Contextual | Adds document context as text | High (LLM call per chunk) | High-value corpora [6] |
Practical details that matter as much as the method
Keep metadata with every chunk. Store the source document ID, title, section heading, URL, date and access permissions. You need them for citations, filtering and enforcing who can see what.
Measure in tokens, not characters, when it matters. Microsoft notes that the character counts used by its Text Split skill don't align with tokens measured by an LLM [1]. Model limits are in tokens.
Check that overlap actually happens. Microsoft's own walkthrough found that setting overlap too large relative to the content can result in no overlap appearing at all [1].
Watch tables and lists. Splitting a table row away from its header makes both halves useless. Structure-aware parsing helps.
Remember the reranker. If you add a reranking model, it has its own input limits. Cohere, for example, truncates documents beyond max_tokens_per_doc (default 4,096 for its v5.0 models) [10]. Chunk sizes should fit the whole pipeline, not just the embedder. Microsoft makes the same point: find a chunk size that works for all the models you use [1].
How to choose a chunking strategy
- Start with recursive or structure-aware chunking at a moderate size (Microsoft's 512 tokens with 25% overlap is a documented starting point [1]).
- Prepend the document title (and section heading if you have it) to every chunk. DPR did it in 2020 [3]; it costs almost nothing.
- Build a test set of real questions with known source passages.
- Measure retrieval, not just answers. Check whether the right chunk appears in the top results (recall at k). Anthropic's evaluation used the top 20 [6].
- Change one variable at a time: size, then overlap, then method.
- Escalate only if needed to semantic, late or contextual chunking, and weigh the added indexing cost against measured gains.
- Pair chunking with retrieval upgrades. Many retrieval failures blamed on chunking are better fixed with hybrid search or reranking.
Outlook
Two shifts are visible as of late 2026. Embedding context windows have grown (Voyage's current models accept 32,000 tokens [8]), which makes late chunking more practical and reduces truncation problems. And context-enrichment techniques, whether at the vector level [5] or the text level [6], are moving chunking away from pure splitting toward "split, then add back the missing context." Anthropic also notes that for knowledge bases under about 200,000 tokens, you can sometimes skip retrieval and put everything in the prompt [6].
Frequently asked questions
What is the best chunk size for RAG?
There isn't one. Microsoft recommends starting at 512 tokens with 25% overlap [1], but the right size depends on document structure, query style and the models you use. Test a few sizes against real questions.
How much overlap should chunks have?
Overlap preserves context that a hard boundary would cut. Microsoft's documented starting point is 25% [1], and it suggests less for highly structured data and more for narrative text. Verify that your splitter actually produces the overlap you set.
Is semantic chunking better than fixed-size chunking?
Sometimes. Semantic chunking keeps related sentences together, which helps with unstructured text, but costs more to compute. For well-structured documents, splitting on headings and paragraphs often captures most of the benefit.
What is the difference between late chunking and contextual retrieval?
Both restore document context to chunks. Late chunking does it inside the embedding model by pooling chunk vectors after the whole document has been encoded [5]. Contextual retrieval uses an LLM to write a short explanatory note that is added to each chunk's text before indexing [6].
Do I still need chunking with long-context models?
Usually, yes. Long contexts don't eliminate retrieval costs, and studies show models can miss facts buried in the middle of long inputs [9]. For small collections, Anthropic suggests skipping retrieval entirely can work [6].
Sources
- Microsoft Learn. "Chunk large documents for agentic retrieval and vector search." Azure AI Search. https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-chunk-documents
- LangChain. "Text splitters." https://docs.langchain.com/oss/python/integrations/splitters
- Karpukhin, V. et al. "Dense Passage Retrieval for Open-Domain Question Answering." EMNLP 2020. https://arxiv.org/abs/2004.04906
- Chen, T. et al. "Dense X Retrieval: What Retrieval Granularity Should We Use?" arXiv:2312.06648. https://arxiv.org/abs/2312.06648
- Günther, M. et al. "Late Chunking: Contextual Chunk Embeddings Using Long-Context Embedding Models." arXiv:2409.04701. https://arxiv.org/abs/2409.04701
- Anthropic. "Introducing Contextual Retrieval." September 2024. https://www.anthropic.com/news/contextual-retrieval
- OpenAI. "Vector embeddings." https://developers.openai.com/api/docs/guides/embeddings
- Voyage AI. "Text embeddings." https://docs.voyageai.com/docs/embeddings
- Liu, N. F. et al. "Lost in the Middle: How Language Models Use Long Contexts." TACL. https://arxiv.org/abs/2307.03172
- Cohere. "Best practices for using Rerank." https://docs.cohere.com/docs/reranking-best-practices