How Document Chunking Changes Retrieval

How Document Chunking Changes Retrieval

user avatar

by me1afon

15 minutes ago


AI tools helped gather research and write the first draft of this article. I edited it and checked every quote and figure against the source page listed at the end, read on 1 December 2026. The illustrations are AI-generated. Details at the end.

A retrieval system never searches your documents. It searches pieces of them. How a document is cut decides what the retriever can return, how much of the answer travels with each piece, and what the model finally reads. A cut in the wrong place can separate a number from the thing it measures; a piece that is too large can blur several topics into one.

This article covers why systems cut documents, what size and overlap trade against each other, where the cuts fall, how lost context is restored, and what a boundary count showed on one real article. It does not cover choosing between context, retrieval and tools, hybrid search, reranking or citations.

Why documents are cut at all

Anthropic's description of a typical retrieval-augmented generation (RAG) pipeline starts here: break the corpus "into smaller chunks of text, usually no more than a few hundred tokens", embed each chunk, store the vectors, and at question time add the chunks most similar to the query to the prompt [1].

There are two reasons. One is a hard limit: Microsoft's Azure AI Search documentation notes that the maximum input for its text-embedding-3-small model is 8,191 tokens, and that partitioning content "prevents data loss due to truncation" [3]. The other is quality. The same page says chunking "is only required if the source documents are too large for the maximum input size imposed by models, but it's also beneficial if content is poorly represented as a single vector", citing a wiki page with many sub-topics [3].

LangChain's documentation puts the consequence directly: "Chunk boundaries decide what a retriever can return: a chunk that mixes several topics dilutes its embedding, and a chunk that splits one idea across two pieces hides context from the model" [2]. It calls chunking "one of the largest factors in RAG quality" [2], a vendor's judgement, not a measurement.

Size: precision against context

LangChain describes the trade in two lines. Small chunks "produce focused embeddings and precise matches, but a single chunk may lack the surrounding context the model needs to answer". Large chunks "carry more context per chunk, but their embeddings blur together multiple topics" [2]. Its verdict: "there is no universal best value"; it depends on the documents, the embedding model and the expected questions [2].

Size also decides how much the model reads. OpenAI's file search guide says limiting the number of results "can help reduce both token usage and latency, but may come at the cost of reduced answer quality" [8]. Anthropic found 20 chunks better than 10 or 5 in its tests, while warning that "more information can be distracting for models so there's a limit to this" [1].

Overlap: a repeat that repairs a cut

Overlap repeats the end of one chunk at the start of the next, so an idea cut at the boundary appears whole in at least one chunk. Starting values differ:

Source Setting stated on the page
LangChain chunking guide Overlap of 10% to 20% of the chunk size as a common starting point [2]
Azure AI Search Start with 512 tokens and 25% overlap (128 tokens) [3]
LlamaIndex SentenceSplitter example Chunk size 1024 with overlap 20 [6]
OpenAI vector stores, default "auto" strategy A maximum of 800 tokens per chunk and 400 overlap tokens; for a custom strategy the size can be set from 100 to 4096 [5]

The table shows settings, not results. The spread, from a few percent to half a chunk, shows the sources do not agree on one value; Azure adds that highly structured data may need less overlap and narrative text more [3].

Overlap has a price. By inference from how it works, the same text is embedded and stored twice, and a query can match both copies. Azure's Text Split skill also caps it: the overlap must be "less than half the maximum page length" [3].

Where the cut falls

A fixed window ignores the text. Azure lists the alternatives: fixed-size chunks (for example 200 words or 600 characters), variable-sized chunks that follow end-of-sentence marks, line breaks or heading syntax, and semantic chunks that preserve "context and semantic relationships across sentences and paragraphs" [3].

LangChain recommends a recursive splitter that tries paragraphs, then sentences, then words, "which keeps semantically related text together whenever it fits within the target size" [2]. For Markdown and HTML it advises splitting on headers and keeping them as metadata [2].

Chunking by meaning is the costly option. LangChain describes it as placing boundaries where the topic shifts, which means embedding the document while splitting it, and says its SemanticChunker lives in an unmaintained package, recommending recursive or structure-aware splitting for new work [2]. Bedrock states that its semantic chunking carries "additional costs" because it uses a foundation model [4]. Neither page shows that the extra step pays off; Bedrock says only that it "may help" with precision [4].

What a chunk forgets

Even a clean cut loses something: the chunk no longer sits inside its document. Anthropic's example is a chunk reading "The company's revenue grew by 3% over the previous quarter", which "doesn't specify which company it's referring to or the relevant time period" [1]. The example below is invented to show the same effect on a help page.

A fictional example

Example Exchange is a made-up service. Its help page "Withdrawal limits" has a section for each account level. The section for Level 1 reads: "Level 1 accounts can withdraw up to 5,000 units per day. This limit resets at midnight UTC." The next section begins with the heading "Level 2 accounts" and a different number.

A user asks: "What is the daily withdrawal limit for a Level 1 account at Example Exchange?" Suppose a fixed window ends after "Level 1 accounts can withdraw" and the next chunk begins "up to 5,000 units per day. This limit resets at midnight UTC." That second chunk matches "daily limit" well but names neither the account level nor the service. Returned alone, or competing with other pages that mention a daily limit, it leaves the model unable to tell what the 5,000 refers to.

Sources read describe four repairs, each at a different cost:

  • Overlap repeats the previous words, so some chunk holds the whole sentence [2][3].
  • Cutting on structure keeps the section whole, with its heading [2][3].
  • Adding the missing context to each chunk before it is indexed. Azure suggests appending the document title to chunks from the middle of a document [3]. Anthropic's Contextual Retrieval has a model write a short explanation of each chunk from the whole document, "usually 50-100 tokens", and prepends it before embedding and before building the keyword index [1].
  • Returning more than was matched, covered below.

The fictional Example Exchange help page cut in two ways: a fixed window that ends in the middle of the Level 1 sentence, so the second piece shows a limit with no account level or service name, and a cut at the section boundary where the heading and both sentences stay together.

How much the context repair is worth

Anthropic reports numbers for its own method. The tests covered codebases, fiction and papers, with the average shown for its best embedding configuration (Gemini Text 004); the metric was 1 minus recall@20, the share of relevant documents not retrieved in the top 20 chunks [1]. Contextual embeddings reduced the failure rate by 35% (5.7% to 3.7%), adding a contextual keyword index by 49% (to 2.9%), and adding a reranking step by 67% (to 1.9%) [1].

Three limits matter. These are one vendor's tests on its chosen datasets. The gain comes from adding context, not from a different cut. And it costs a model call per chunk: Anthropic estimates a one-time $1.02 per million document tokens, under assumptions of 800-token chunks, 8,000-token documents and its prompt caching [1].

Small to find, large to read

A second repair separates the unit that is searched from the unit that is read. LangChain calls it the small-to-big pattern: "embed and index small chunks for accurate matching, then return the larger passage that contains the matched chunk to the model" [2]. Bedrock's hierarchical chunking retrieves child chunks and replaces them with their parents "so as to provide the model with more comprehensive context" [4]. LlamaIndex's HierarchicalNodeParser, shown with sizes of 2048, 512 and 128, does the same with an auto-merging retriever [6].

The cost of this approach is the size of what is read. A study of long inputs found that performance "can degrade significantly when changing the position of relevant information", often highest at the beginning or end of the input and lower "when models must access relevant information in the middle of long contexts" [7]. That abstract concerns long inputs in general, not chunked retrieval, and says nothing about how big a returned passage should be. It is a reason to test with the real prompt, not a rule.

One real article, six ways to cut

To see boundaries instead of describing them, a short pure-Python script was run on 1 December 2026 on the text of article 085 of this publication ("Why General-Purpose Entity Recognition Misses Domain Meaning"), front matter removed: 14,630 characters, 2,497 words, 51 blocks separated by blank lines, 144 sentences and 13 headings. The script and log are saved as research/chunk_check.py and chunk_check.log.

It cut the text six ways: fixed windows of 500 and 1,500 characters, each with no overlap and with 20% overlap, and a splitter that packs whole paragraphs up to the same two limits (a paragraph longer than the limit is packed by sentences). By the Azure page's rule of about four characters per token, 500 and 1,500 characters are roughly 125 and 375 tokens. It then counted what each boundary did:

Cut Chunks Chunks that start mid-sentence Adjacent sentence pairs within a paragraph split (of 93) Headings cut from their first sentence (of 13) Chunks containing 2+ section headings
Fixed 500, no overlap 30 29 38 3 0
Fixed 500, overlap 100 37 36 27 2 0
Paragraphs up to 500 36 0 12 5 0
Fixed 1,500, no overlap 10 9 11 0 2
Fixed 1,500, overlap 300 12 11 0 0 2
Paragraphs up to 1,500 11 0 0 4 1

What the counts show, and what they do not:

  • Small windows cut a lot. At 500 characters with no overlap, 38 of the 93 neighbouring sentence pairs inside paragraphs were separated, so no chunk held both. A real boundary fell at the 2,500th character of the article: one chunk ended with a sentence that lists a model's labels and names its training sources, and the next began with ". The page also reports precision of 84.30, recall of 84.36 and an F-score of 84.33 for entities". The scores now sit in a chunk that no longer says which model they describe.
  • Overlap repaired part of the damage: 27 pairs split instead of 38 at 500 characters, none at 1,500.
  • Cutting on paragraphs removed mid-sentence starts, but the plain packer still left 4 to 5 headings at the end of a chunk, away from the text they introduce. A structure-aware splitter is not safe by name; it depends on how it packs.
  • Large chunks cut less, but they mix sections: seven of the ten fixed 1,500-character chunks crossed a section heading, and two contained two headings, so they held text from three sections. This is the mixing of topics that LangChain warns about [2]. (The seven is counted separately from the table, with the same cuts.)

The limits: one article, characters rather than tokens, no embeddings, no questions, no retrieval. It shows how often a cut damages the text, not how much that changes an answer.

A fictional article strip cut into numbered chunks at three sizes, with small chunks showing many cut sentences, medium chunks with an overlap band repairing a cut, and large chunks each mixing two section colours.

A five-step check for your own corpus

This is the author's proposal, following the evaluation advice in [2] and Anthropic's "Always run evals" [1].

  1. Write 20 to 30 real questions, each with the passage that answers it.
  2. Index the corpus with two or three settings, such as a small and a large size, with and without overlap, and a structure-aware cut.
  3. For each question, check whether the right passage is in the top results, as in Anthropic's recall@20 measure [1].
  4. Read the chunks a model would receive for ten of the questions. Look for numbers with no subject, headings with no text and two topics in one chunk.
  5. Change one setting at a time and keep the log.

What this article cannot tell you

It does not give a best chunk size; the sources say there is none. It does not show that any splitter beats another on answer quality: the only measurement here counts boundaries on one article, and the only retrieval figures are Anthropic's. Documentation was read on one day; defaults and prices change. The arXiv paper is cited from its abstract only. Example Exchange is invented, and the checklist is the author's proposal.

How this article was made

Task What the AI did What a person did How it was checked
Research Gathered candidate sources and drafted notes Chose the question and which pages to rely on Every quote checked against the raw page text named in the sources, read on 1 December 2026
Boundary count Wrote and ran the script on article 085 Reviewed the method and the numbers Script and log saved in research/; a second run gives the same numbers
Draft Wrote the first draft from the notes Edited the text, the fictional example and the checklist An independent review compares claims with the sources before publication
Images Generated the cover and inline illustrations Chose and checked them Labelled as AI-generated in the disclosure line and alt text
Not done by AI — The decision to publish and responsibility for the text —

Conflicts of interest: none. The author has no commercial relationship with the organisations named here.

Responsible for this article: Dmitriy Lastovka, author. Corrections: contact form.

Sources

Labels: guidance (vendor or project documentation), vendor research (a company's description of its own tests), paper (research abstract). Quotes are as on the pages read on 1 December 2026.

  1. Anthropic, "Introducing Contextual Retrieval". https://www.anthropic.com/news/contextual-retrieval Vendor research; page shows "Published Sep 19, 2024".
  2. LangChain, "Chunk documents for retrieval". https://docs.langchain.com/oss/python/langchain/chunking Guidance; no revision date in the text read.
  3. Microsoft Learn, "Chunk large documents for RAG and vector search in Foundry IQ (Azure AI Search)". https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-chunk-documents Guidance; page metadata dated 2026-11-09.
  4. Amazon Web Services, "How content chunking works for knowledge bases" (Amazon Bedrock User Guide). https://docs.aws.amazon.com/bedrock/latest/userguide/kb-chunking.html Guidance; no revision date in the text read.
  5. OpenAI API reference, "Create vector store file" (chunking_strategy). https://developers.openai.com/api/reference/resources/vector_stores/subresources/files/methods/create Guidance; no revision date in the text read.
  6. LlamaIndex, "Node Parser Modules". https://developers.llamaindex.ai/python/framework/module_guides/loading/node_parsers/modules/ Guidance; no revision date in the text read.
  7. Liu et al., "Lost in the Middle: How Language Models Use Long Contexts", arXiv 2307.03172, abstract page. https://arxiv.org/abs/2307.03172 Paper; abstract only.
  8. OpenAI, "File search" guide (retrieval customization). https://developers.openai.com/api/docs/guides/tools-file-search Guidance; no revision date in the text read.

Tier I

Sector: #18291

Sealed Hiding Place Room

Resource Cache

Resource Cache

Tier I

Requires 25% Tier Progress to Claim
Meme Cache

Meme Cache

Tier I

Requires 50% Tier Progress to Claim
Equipment Cache

Equipment Cache

Tier I

Requires 75% Tier Progress to Claim

After collecting, hiding places will be stored in your inventory and can be opened with Keys.

Other articles

Context, Retrieval, or Tools: Choosing a Knowledge Path

When an AI chat can read everything in its prompt, when it needs retrieval, and when only a live tool call is right: what the docs and the RAG paper say.

user avatarme1afon

Designing for Waiting Time in AI Chat

How reply delay shapes an AI chat: three clocks, what streaming changes, progress during tool steps, broken streams and status messages for screen readers.

user avatarme1afon

Retries That Do Not Repeat the User’s Action

How to set timeouts and retries in an AI chat so one user action runs once: idempotency keys, one retry layer, unknown outcomes and a fictional transfer.

user avatarme1afon

Structured Output Is Only Part of the Contract

Why a reply that matches its JSON Schema can still trigger the wrong action: what vendor docs and the spec promise, what stays with your code, and a checklist.

user avatarme1afon

Routing Requests in an AI Product

How an AI product can send each request to the right path, model or tool: what routing is, cheap layers first, a fictional wallet-chat example and tests.

user avatarme1afon

What Should an AI Chat Remember?

Memory is not one thing. Sort what a chat keeps by purpose, scope and expiry: vendor docs, GDPR storage limitation, a fictional example and a template.

user avatarme1afon

Important disclaimer: The information presented on the Dapp.Expert portal is intended solely for informational purposes and does not constitute an investment recommendation or a guide to action in the field of cryptocurrencies. The Dapp.Expert team is not responsible for any potential losses or missed profits associated with the use of materials published on the site. Before making investment decisions in cryptocurrencies, we recommend consulting a qualified financial advisor.