What you’ll take away
- Chunking determines the unit that is embedded, searched and shown to the reader, so boundaries can separate an answer from the context needed to interpret it [1][3].
- Fixed-size, sentence-based, structure-based and semantic methods trade predictability, coherence and topical focus differently; none is universally optimal [1][2].
- Overlap can preserve continuity across boundaries but adds duplication and may crowd out distinct evidence in a fixed top-k [1][3].
- Chunk size must be chosen jointly with embedding token limits, reader context length, retrieval depth and reranking, and tested on context-dependent questions [1][3].
Why split a document before searching it
Imagine a library where every book is one enormous card. To answer a small question, a librarian would have to read the whole book, even if the answer is one paragraph. Retrieval systems work similarly: they search smaller passages, called chunks, so a question can find a relevant piece without carrying an entire document into the answer step [1][2].
Splitting also helps a system stay inside model limits. Embedding and chat models accept only a limited number of tokens, and text that is too long can lose information through truncation [1]. A chunk is therefore a practical unit: small enough to embed and pass to a reader model, but large enough to contain meaning. The same passage may need to satisfy both the embedding model and the reader, so its size cannot be chosen for one model alone [1].
A finer grain can also improve representation. A long page covering many sub-topics may fit a model limit as a single unit, yet its overall meaning is mixed [1]. Dividing it lets each sub-topic be represented separately. That does not guarantee a better answer. It changes what the search can match, what context is preserved, and what irrelevant material may be retrieved alongside the useful passage [1][3].
The main methods choose boundaries from different signals. Fixed-size chunking uses a length budget; structure-based chunking uses headings or markup that group related material [1][2]. The comparison below shows why the choice matters before any search takes place. A length rule gives predictable units but may divide an explanation. A heading can keep a topic together, but a long section still needs a size check. Both approaches need inspection of the chunks they actually produce.
Chunking partitions a source document into retrievable units whose embeddings are indexed and later matched against a query embedding [1][3]. The partition is required when source length exceeds embedding or chat-completion input limits, where truncation would otherwise lose content [1]. It is also a representation decision: content may be poorly represented as a single vector, for example a page covering numerous varied sub-topics, and chunking at a finer grain might give better results [1].
The chunk is the granularity at which similarity is computed. Once chunks are embedded and stored, a query is embedded with the same model and nearest neighbours are returned for the reader [3]. Consequently, chunking determines the candidate set before any reranking or generation occurs. A passage that was never formed, or whose embedding does not reflect the query, cannot be recovered by a downstream reader that only sees retrieved context [3].
This creates a coupled design problem across indexing and query time. Chunk size must respect the embedding model's maximum input, the reader model's context budget, and the semantic coherence of the source [1]. In the tutorial example, the retrieved context consists of five documents of 512 tokens each, and the authors aim for a reader window of at least 4k tokens to accommodate the complete prompt [3]. The five passages account for 2,560 tokens before the question and other prompt text; 4k is the tutorial's chosen window target, not the sum of the passage lengths. Chunking is therefore not a preprocessing convenience; it is a constraint on both representation and generation.
Boundary selection and size validation are separate decisions. Fixed-size methods use an explicit length measure, while structure-based methods use markup such as section headings or logical code blocks [1][2]. The comparison below separates their boundary rules from their limitations. Authorial structure can group related content, but it does not establish token fit; a repeatable size rule can control length, but it does not establish semantic completeness. Evaluate those properties independently before comparing retrieval results.
Fixed-size chunks: simple, predictable, and blind to meaning
Fixed-size chunking cuts text after a set number of words, characters or tokens, regardless of what the text is about [1][2]. Think of slicing a long loaf at equal intervals. Every slice is a similar size, which makes storage and limits easy to predict. One described starting point is 200 words or 600 characters, with a small overlap, although that is an example rather than a universal rule [1].
The strength of this method is control. A team can set a repeatable length budget and estimate how many chunks a document will produce. To verify a model's token limit, it must count the actual chunks with the relevant tokenizer; a word or character cap alone does not establish token fit [1][2]. Token-based splitting is especially useful when a language model limit is the binding constraint, while character-based splitting can be more consistent across different kinds of text [2]. Predictability matters when many documents must be processed the same way.
The weakness is blindness to meaning. A cut can fall in the middle of a sentence, a list, or an explanation, separating words that belong together [1][2]. Two chunks may also contain very different amounts of useful information even though their lengths match. Fixed-size chunks are therefore a baseline to test, not evidence that equal length means equal quality [1].
Fixed-size splitting enforces a maximum in its chosen length measure: characters, words or tokens [1][2]. A character or word cap does not itself guarantee compliance with an embedding model's token limit. That check requires the appropriate tokenizer and the actual text submitted, since token length can vary with chunk contents [1]. Token-based variants align directly with model context accounting, whereas character-based variants offer cross-text stability but only approximate token counts [2]. The Azure guidance gives 200 words or 600 characters as an example of a semantically meaningful paragraph scale, and separately recommends starting at 512 tokens with 25 percent overlap for fixed-size chunking [1]. These are starting points tied to a specific service context, not universal optima [1].
The cost is boundary arbitrariness. Because length is independent of syntax or discourse structure, fixed-size cuts can split sentences, separate a term from its definition, or divide a procedure across chunks [1][2]. Chunk character counts also vary when sentence boundaries influence the cut, and token length varies with content even at a fixed character budget [1]. Evaluation must therefore measure retrieval quality, not merely compliance with a length limit [1][3].
Sentence and recursive splitting: following the text's own hierarchy
Text already has natural layers: paragraphs contain sentences, and sentences contain words. Recursive splitting uses that hierarchy. It tries to keep a paragraph together, and only breaks it into sentences if it is too large, then into words if necessary [2][3]. This is like unpacking boxes: open the large box first, and only open smaller boxes when the contents will not fit.
Sentence-based splitting can preserve complete thoughts better than cutting at an arbitrary point [1][2]. A chunk that ends at a sentence boundary is less likely to leave a half-finished idea. Recursive methods still need a maximum size, so a very long paragraph will be divided, but the division follows the structure of the writing instead of ignoring it [2][3].
The trade-off is uneven chunk sizes. Some chunks may be short because a paragraph or section was short, while others approach the limit [3]. That variation is not a defect by itself. It reflects the source. The risk is assuming that a natural boundary always matches the question being asked. A paragraph can be coherent as writing yet still contain several different facts that a search might need to separate [1][2].
Recursive character splitting implements a hierarchical fallback: attempt to retain larger units such as paragraphs, descend to sentences when a unit exceeds the size budget, and continue to words if required [2]. Separators are ordered from most to least significant, for example double line breaks before single line breaks and sentence punctuation, so global structure is preserved at the expense of chunk-size variation [3]. LangChain presents this as a default starting strategy because it balances context retention against size control [2].
Sentence-aware splitting, including splitting by sentences in built-in skills, can maintain semantic coherence within a chunk [1]. However, coherence at the sentence level does not imply topical homogeneity at the chunk level. A paragraph may contain multiple claims, and a chunk formed from several sentences may still mix topics. The method reduces syntactic fragmentation; it does not solve retrieval granularity, which depends on how query-relevant information is distributed across the resulting units [1][3].
Structure-based chunks: headings, markup and logical blocks
Many documents announce their own organisation. Headings divide a report into sections, Markdown marks levels of importance, and code is grouped into functions or classes [1][2]. Structure-based splitting respects those signals. Instead of cutting every 500 characters, it keeps a section together or starts a new chunk at a heading [1][2].
This approach can help retrieval because related ideas are often placed under the same heading [2]. A chunk taken from one section is more likely to discuss one topic than a chunk that crosses several sections. It can also help a reader understand where a passage came from, because the heading provides context that a bare fragment may lack [1][2].
Structure is not always clean. A heading may introduce a very long section, a table may be split across pages, or a document may use formatting inconsistently [1]. A system may therefore combine methods: split at headings first, then divide any section that is still too large [1]. The lesson is to treat structure as evidence about meaning, not as a guarantee that every section is a perfect chunk [1][2].
Structure-based splitting exploits explicit markup, including HTML and Markdown heading syntax, to partition content by sections that often group semantically related text [1][2]. For code, analogous logical blocks such as functions and classes provide natural partition points [2]. This can improve downstream retrieval and summarisation because chunk boundaries align with authorial organisation rather than arbitrary length thresholds [2].
The approach has failure modes when markup is sparse, inconsistent or misleading, or when a single section exceeds model limits. Variable-sized chunking based on end-of-sentence punctuation, end-of-line markers or document-structure detection is therefore often combined with a size cap [1]. Custom combinations may also append document titles to chunks from the middle of a document to reduce context loss [1]. Such augmentation changes the embedded text and must be evaluated as part of the chunking strategy, not assumed to be neutral [1].
Semantic chunks: grouping by meaning instead of markers
Semantic chunking tries to break text where the meaning changes, rather than where a fixed number of characters ends [1]. Imagine sorting a pile of notes by topic instead of cutting the pile into equal stacks. Sentences about the same idea stay together, and a new chunk begins when the subject shifts. The aim is to preserve context and relationships across sentences and paragraphs [1].
This can produce chunks that read as coherent units, which may help search and answering [1]. A focused chunk may make a sub-topic easier to represent, but whether it is retrieved more reliably must be checked on the actual questions. Semantic coherence and measured retrieval performance are separate considerations [1][3]. Semantic methods can also span page boundaries when a topic continues, instead of forcing a break because a page ended [1].
Semantic does not mean perfect. A chunk can still be too large for a model or too small to answer a question that needs background, and the sources do not describe a universal grouping rule for every document. Semantic chunking should therefore be compared with simpler methods on real questions, not chosen because its name sounds more intelligent [1].
Semantic chunking partitions content into units that preserve context and semantic relationships across sentences and paragraphs, and can span page boundaries [1]. The sourced description presents these chunks as better maintaining semantic coherence [1]. This describes the objective of the chunking approach rather than a universal algorithm. A coherent unit still needs a model-length check, and its usefulness depends on whether the resulting passage contains the information a real question requires.
A semantically coherent chunk is not necessarily an optimal retrieval unit. Retrieval depends on the alignment between query phrasing and chunk content, the density of relevant information within the chunk, and the amount of competing material included [1][3]. Overly broad units may include competing material, while overly narrow units may omit prerequisites needed to interpret a passage. Semantic segmentation therefore trades one form of fragmentation for another and requires task-specific evaluation [1][3].
Overlap: buying continuity with duplication
Overlap means the end of one chunk is repeated at the start of the next. If a chunk ends in the middle of an explanation, the next chunk begins with some of the same words, so the idea is less likely to be cut in half [1][3]. Think of overlapping roof tiles: each tile covers part of the previous one, leaving no gap where rain could enter.
A small overlap can preserve continuity and context, especially for narrative or conversational text [1]. One recommended starting point is 512 tokens with 25 percent overlap, equal to 128 tokens, described as a way to smooth transitions without excessive duplication [1]. Another tutorial uses overlap of one tenth of the chunk size as an arbitrary starting value to test [3]. These examples show that overlap is a tunable parameter, not a fixed law.
Duplication has costs. Overlapping chunks store and embed repeated text, can return near-duplicate results, and may crowd out different passages in a fixed number of retrieved results [1][3]. Highly structured data may need less overlap, while narrative text may benefit from more [1]. If the overlap is larger than a short chunk, it can even eliminate the intended overlap effect in some implementations, so the actual output should be inspected [1].
Overlap duplicates a span of content across adjacent chunks to reduce the probability that a relevant idea is split by a boundary [1][3]. The Azure guidance recommends starting with 512 tokens and 25 percent overlap, or 128 tokens, while noting that optimal overlap varies by content type and use case [1]. Structured data may require less overlap; conversational or narrative text may benefit from more [1]. The Hugging Face tutorial uses one tenth of chunk size as an arbitrary initial value, reinforcing that overlap is an experimental parameter [3].
Overlap increases index size, embedding cost and the chance of duplicate or near-duplicate retrieval results competing for top-k slots [1][3]. It also does not guarantee that a query-relevant span is intact: if the relevant context extends beyond the overlap window, the boundary problem persists. Overlap should be evaluated jointly with chunk size and top-k, because increasing overlap while holding top-k fixed can reduce the diversity of distinct evidence returned [1][3].
When a boundary separates the question from its answer
A chunk boundary can separate a question from its answer in a simple way: the words that make a passage understandable end up in different chunks. A heading may name a topic, while the details appear after the cut. A pronoun may refer to something mentioned earlier, or a step may depend on a warning placed just before it [1][3]. The search may find one fragment, but the fragment alone may not contain enough context to answer correctly.
This is why context matters as much as keywords. A chunk containing the word a user asks about may still omit the condition, exception or definition that determines the answer [1]. Larger chunks and overlap can preserve more surrounding context, which helps queries that target specific information but need semantic richness [1]. Structure-based chunks can also help by keeping a heading with its section [1][2].
No boundary strategy removes the risk entirely. Even a well-formed chunk may lack information from another part of the document. A source-grounded answer needs support in the retrieved passages; missing context can leave the reader without enough evidence [3]. The system should retrieve the missing material or acknowledge the limitation instead of guessing an absent qualification. The tutorial instructs its reader to answer from context and decline when that context is insufficient, but an instruction is not a guarantee of model compliance [3]. Test questions whose answers depend on headings, references, lists and exceptions, not only questions matching a single sentence [1][3].
Boundary-induced context loss occurs when anaphoric references, headings, definitions, qualifications or procedural prerequisites are partitioned away from the span containing the answer [1][3]. The retrieved chunk may have high lexical or embedding similarity to the query while lacking the discourse context required for correct interpretation. Larger chunks and overlapping strategies can preserve context and semantic richness for specific-information queries, but they also include more non-relevant material [1].
Mitigations include structure-aware boundaries, overlap, and appending document titles or section headings to chunks to reduce context loss [1]. Each mitigation alters the indexed representation: added titles may improve matching for title-dependent queries while diluting content for others. When retrieved passages omit necessary context, the reader may lack sufficient evidence; an answer could then contain unsupported inference or miss a qualification [3]. These are possible failure modes, not inevitable outcomes or a guarantee that a grounding instruction will be followed. Chunking evaluation should therefore include context-dependent queries, not only keyword-matching queries [1][3].
Chunk size: the trade between finding more and finding precisely
Chunk size controls a basic trade. Larger chunks can retain background needed to understand an answer [1]. Smaller chunks can focus on one specific idea [1][3]. Neither choice is automatically better, and this design rationale does not guarantee an improvement in measured retrieval. The useful size depends on the documents, the questions and the models involved, so compare the actual results [1].
Recall and precision describe two sides of that trade. Recall asks whether the useful passage is found at all. Precision asks whether the passages returned are actually useful rather than filled with extra material [3]. Very small chunks can miss context and lower recall for questions that need background. Very large chunks can be found, yet bring so much unrelated text that the useful part is harder to identify [1][3].
A hypothetical example makes the trade concrete. Assume, purely for illustration, a 1,000-word guide with one paragraph answering a question and nine paragraphs on other topics. A single large chunk would contain the answer but also nine irrelevant paragraphs. If the alternative uses exactly one paragraph per chunk, those ten chunks would isolate the answer paragraph, but if the question needs a heading from the previous paragraph, the small chunk might lack that context. The example is invented to show the mechanism; it is not a measured result [1][3].
Chunk size changes the evidence available within each indexed unit. Larger chunks can preserve surrounding context needed to interpret an answer; the guidance recommends considering them for queries that depend on that context [1]. Smaller units can isolate a sub-topic that a single broad vector represents poorly [1]. Neither observation guarantees an improvement in measured retrieval recall or precision. As an evaluation implication, check both whether the answer-bearing passage is retrieved and whether the retrieved material contains enough relevant context. Which size works better remains a task-specific result [1][3].
Retrieval depth interacts with granularity. Increasing top-k raises the chance of including relevant elements despite retrieval noise, but also admits more irrelevant passages into the reader context [3]. Reranking can retrieve a larger candidate set and then keep only the top-k, partially decoupling candidate recall from final precision [3]. Chunk size, top-k and reranking should consequently be tuned as a system, rather than optimised independently against a single metric [1][3].
Tokens, embeddings and the limits that force a cut
A token is a small piece of text that a model processes. It is not exactly a word or a character, so counting words alone cannot guarantee that a chunk fits a model [1][2]. One model described in the sources accepts up to 8,191 tokens, which is roughly 6,000 words for common models, but that figure belongs to that model and should not be copied to others [1].
Embedding models turn a chunk into numbers that represent its meaning. The search then compares the numbers for a question with the numbers for chunks to find close matches [3]. If a chunk is too long for the embedding model, part of it may be lost. If it is too short, its numbers may represent only a fragment of the idea [1][3]. The chunk must therefore fit the embedding model and still be meaningful.
The reader model has its own limit. Retrieved chunks are combined into a prompt, so several chunks together must fit the reader's context [3]. A system can use small chunks for precise search but still overflow the reader if it retrieves too many of them. Chunk size, number of retrieved chunks and reader limit must be planned together [1][3].
Token limits impose hard constraints on both embedding and generation. Partitioning content helps meet input token requirements and prevents data loss from truncation [1]. The cited maximum of 8,191 tokens for text-embedding-3-small, approximated as around 6,000 words at roughly four characters per token for common OpenAI models, is model-specific and must not be generalised [1]. Token-based splitting aligns chunk construction with these limits, while character-based splitting provides only an approximation [2].
An embedding represents the input actually supplied to its model. If a long passage is truncated, omitted material cannot contribute to that embedding; the supplied guidance does not specify which part is retained in every implementation [1]. A much shorter chunk may instead omit context needed to interpret its topic. In the cited retrieval tutorial, vectors are used to match queries with stored records, and the original retrieved passage text is then placed in the reader prompt [3]. The passage is not reconstructed by decoding its embedding. This creates two separate size checks: each chunk must fit the embedding input, and the combined passage text, question and instructions must fit the reader’s total context budget [1][3].
Choosing a strategy and testing it on real questions
Start by examining the documents. Note their length, headings, lists, tables and how topics change [1][2]. Measure token counts where possible, because the average and maximum length give evidence for a size limit [1]. Then choose a simple starting strategy, such as recursive splitting that preserves paragraphs and sentences, and record the chunk size and overlap used [2][3]. A starting point is a hypothesis to test, not a final answer.
Build a small set of test questions from the documents, including questions that need a heading, a definition, an exception or steps from more than one paragraph [1][3]. Run the system with different chunk sizes and overlaps, and check whether the correct passage is retrieved and whether the answer uses only that evidence [3]. Compare fixed-size, sentence-based, structure-based and semantic options on the same questions, because a method that works for one document may fail for another [1][2].
Use a checklist before changing a live system. Confirm that chunks fit the embedding and reader limits [1][3]. Inspect actual chunks for split sentences, missing headings and excessive duplication [1]. Check for near-duplicate results in the top retrieved passages [3]. Test structured data separately from narrative text, because the best overlap may differ [1]. Keep the document title or section heading with a chunk when losing it would remove essential context [1]. Finally, change one setting at a time so the effect of chunk size, overlap or top-k can be understood [3].
A defensible selection procedure begins with corpus profiling: token-length distribution, structural markup, topical heterogeneity and query distribution [1][2]. Token counts per page or section inform chunk sizing; in the worked Azure example, page token counts ranged to a maximum of 1,583 with an average of 189, suggesting that a generic 2,000-character recommendation might be inappropriate for that document [1]. The example also warns that an overlap larger than a chunk can produce no effective overlap, so realised chunk statistics must be inspected [1].
Evaluation should vary chunk size, overlap, splitting strategy and retrieval depth while holding the test questions constant, and should measure both retrieval of the correct passage and correctness of the generated answer [3]. Recursive splitting is a reasonable default starting point, but library guidance explicitly frames it as a starting point rather than a universal optimum [2]. Semantic, structure-based and fixed-size methods should be compared under identical embedding and reader constraints, because chunking interacts with embedding context, top-k and reranking [1][3]. Any claimed improvement should be reported with the dataset, model versions and parameters used, since the sources provide no universal optimal chunk length [1].
Sources & further reading
Explore the references behind this guide. External pages may change after our review.
- Chunk Documents - Azure AI Search | Microsoft LearnMicrosoft · Accessed 6 Nov 2026
- Text splitter integrations - Docs by LangChainLangChain · Accessed 6 Nov 2026
- Advanced RAG on Hugging Face documentation using LangChain · Hugging FaceHugging Face · Accessed 6 Nov 2026
Article updated 6 Nov 2026.
Found something we should revisit?
Good explanations get better with thoughtful feedback.