Document chunking: choosing size, semantic boundaries, and overlap
Document chunking is the preprocessing step of dividing long material into smaller pieces (chunks) suited to retrieval and model input. Chunks that are too large can mix irrelevant material into search results; chunks that are too small can separate conditions and explanations needed to answer a question. Choose boundaries based on document structure and question types, then compare accuracy and cost in a real retrieval and answer evaluation. There is no universally best size or overlap ratio.
Document chunking: choosing size, semantic boundaries, and overlap
Document chunking is the preprocessing step of dividing long material into smaller pieces (chunks) suited to retrieval and model input. Chunks that are too large can mix irrelevant material into search results; chunks that are too small can separate conditions and explanations needed to answer a question. Choose boundaries based on document structure and question types, then compare accuracy and cost in a real retrieval and answer evaluation. There is no universally best size or overlap ratio.
Why is chunking needed?
Embedding and generative models have input limits, and a search system may not distinguish different topics well when an entire document is represented as one indexed unit. Indexing chunks lets the system find a relevant passage and pass that portion to the answer model. But the point where the source is split becomes a boundary for both search units and evidence. A poorly split chunk can detach an important exception or context from the search result.
Chunking is a design choice in the indexing process. Changing size, segmentation method, or preprocessing may require rebuilding the index or regenerating embeddings, and it can affect retrieval scores and downstream answers. Gather representative documents and questions first instead of choosing a production setting from a single document.
What methods can you use?
| Method | Boundary rule | Suitable when | Main risk |
|---|---|---|---|
| Fixed size | A consistent token or character length | Documents have little structure; a quick baseline or uniform processing is needed | May split sentences or tables; character length is not the same as token length |
| Sentence, paragraph, or heading based | Punctuation, blank lines, Markdown headings, or document sections | Wikis, policies, manuals, and documents with headings | Unit sizes vary; long sections may need another split |
| Semantic segmentation | Context shifts, topic changes, or meaning units | Topics are mixed or paragraph boundaries are insufficient | Segmentation rules or model analysis add cost, and implementations differ |
| Hybrid | Prefer structural boundaries, using a length limit as a secondary rule | Long sections and material with headings and paragraphs | Overlapping rules can make boundaries hard to understand and debug |
“Semantic chunking” can mean different things across products. It may refer to preserving meaningful document structure such as headings, paragraphs, and sentences, or to implementations that use embeddings or language models to detect topic changes. Microsoft’s Azure AI Search documentation also describes structure-aware or semantic section splitting and fixed-size splitting as distinct options. Do not assume identical algorithms or quality from a feature name; check the actual segmentation behavior and limits of the product you use.
How should you choose chunk size?
Small chunks can make it easier to retrieve a specific fact or short procedure, but may omit the exception, definition, or condition that governs it. Larger chunks preserve surrounding explanation, but can include more irrelevant paragraphs in a result and use more of the answer model’s input budget. If the question is narrow, such as “What is the fee?”, start small enough to retrieve the conditions attached to the amount. If an answer must combine several clauses, compare a self-contained section or a larger passage.
Character count alone is a poor proxy for size because actual token counts vary with language, symbols, code, and tables. Check the token limits of both the embedding model and answer model, and inspect the minimum, median, and maximum chunk lengths as well as unusually long units. Azure documentation gives example starting sizes for certain Azure AI Search configurations, but those numbers should not be treated as universal recommendations for other products, languages, or materials.
When document structure is available, use this as a baseline:
Extract headings, tables, lists, code blocks, and page or clause boundaries.
Attach headings and parent paths to a chunk or retain them as metadata so a middle passage has context.
Split further at sentence or paragraph boundaries only when a section is too long for the model limit or retrieval purpose.
Preserve row and column relationships and headers in tables; keep code examples with the explanation they require.
Store source IDs, page or clause locations, language, effective dates, and other details needed to trace evidence.
When does overlap help?
Chunk overlap repeats the ending of one chunk at the start of the next to reduce the chance that a sentence or short condition is split at a boundary. It can help with prose divided by fixed length when two neighboring pieces are needed together for understanding. But too much overlap returns nearly identical content in several search results, increases index size, embedding cost, and storage, and can fill the answer context with repeated sentences.
If complete units can be split at headings or paragraph boundaries, test a baseline with little or no overlap. If fixed-length segmentation is unavoidable, some overlap can be a starting point, but do not assume the same ratio suits all material. Overlap can reduce context loss; it cannot repair badly segmented chunks or solve a retrieval-model problem by itself.
For example, suppose a return policy’s eligibility condition is at the end of one chunk and its exception begins at the start of the next. A small overlap or segmentation that respects headings and paragraphs may help retrieve both together. By contrast, if each FAQ is independent and its heading and answer remain in one unit, overlap may only increase the chance of returning the same answer twice. This illustrates a design choice; it is not a measurement of retrieval performance.
How should you evaluate the choices?
Compare chunking strategies in the actual retrieval and answer pipeline. At minimum, prepare a fixed-size baseline, structure-aware segmentation, and semantic segmentation if it is relevant. Adjust size and overlap one at a time. With the same document set and questions, check whether relevant evidence appears near the top, whether the necessary conditions and exceptions are included, and whether citations point back to the source location.
Include simple questions answerable from one passage, questions requiring information from multiple sections, questions that depend on tables, lists, or code, and questions about boundary conditions or exceptions. Better retrieval metrics do not guarantee a correct answer if evidence was split; also evaluate factuality, grounding, and output format of the final answer. Track chunk count, index size, embedding regeneration time, retrieval latency, and token use alongside quality.
| Observed problem | First adjustment to inspect |
|---|---|
| Retrieved chunks are too broad and cover several topics | Reduce size or split by heading/section; check for duplicate content |
| A definition is retrieved but its conditions are missing | Preserve neighboring conditions with structural segmentation or test a small overlap |
| Table values are separated from column headings | Structure the table by rows or groups and attach headers to each unit |
| Top results repeat the same sentence | Reduce overlap and inspect result deduplication or grouping by source document |
| Chunk lengths or reindexing costs are excessive | Review token distribution, preprocessing, and the cost of optional semantic analysis |
Because segmentation changes the search index and citation locations, rerun both previous evaluation questions and held-out new questions after replacing a strategy. Updating a document parser or segmentation model can also change results under the same chunking settings. Record source versions, segmentation rules, model and parser versions, metadata, and chunk IDs so you can reconstruct the evidence behind an answer.
Summary
Chunking is not just a choice of size number; it is the design of how well each retrieval unit preserves a source’s meaning, conditions, and provenance. When structure exists, start with headings and paragraphs; compare fixed-size segmentation as a baseline; and evaluate semantic segmentation with its added cost and implementation differences in mind. Use overlap selectively when boundary loss causes real errors, and choose settings by evaluating both evidence retrieval and final answers on real questions.
Sources
[Microsoft Learn: Chunk large documents for RAG and vector search in Azure AI Search](https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-chunk-documents) — trade-offs among fixed, structure-aware, semantic, and hybrid chunking, overlap, and Azure-specific examples. Checked 2026-11-23.
[Microsoft Learn: Develop a RAG solution on Azure — Chunking phase](https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/rag/rag-chunking-phase) — chunking choices by document type, preprocessing, and operational evaluation. Checked 2026-11-23.
[Microsoft Learn: Chunk and vectorize by document layout](https://learn.microsoft.com/en-us/azure/search/search-how-to-semantic-chunking) — Azure Document Layout splitting by headings and paragraphs and its scope. Checked 2026-11-23.