Chunking Strategies for Documents
A chunk cut from its document can lose the context needed to say what it is about, and augmentation is a way to restore that context before retrieval.
A Chunk That Loses Its Surroundings
When a long document is split into smaller chunks, each piece becomes a separate unit that a retrieval system can return. That split is useful, but it carries a cost. A chunk is cut out of its surroundings, so it may no longer say what it is about. A paragraph that reads 'Restart the service and check the logs' is perfectly clear to someone who has just read the troubleshooting guide. Pulled out alone, it does not mention which service, which problem, or which product it belongs to.
Consider a support knowledge base. One chunk, taken from a longer article, reads: 'Open the security page, choose Reset, and follow the link sent to your inbox.' A customer types the query 'how do I reset my password?' For a person who reads the whole article, the chunk is clearly relevant. For a retriever, however, the match depends entirely on how well the query can be connected to the chunk's own content. The chunk never uses the word password.
What do you think happens?
Looking only at the chunk text, would a plain keyword search for the word 'password' find this chunk?
Reveal answer
No, because the word password does not appear in the chunk text.
The chunk talks about a security page, a Reset choice, and a link, but the word password never appears. A search that depends on the chunk's own wording cannot connect the query's most important word to this passage. Contextual retrieval exists to close this gap.
The response to this problem is called contextual retrieval. Instead of accepting each chunk exactly as it was cut, information is added to it, so that the retriever has more to match against and the reader has more to understand. The rest of this article follows one chunk through that process and examines three kinds of added information: metadata, questions the chunk can answer, and context borrowed from the original document. It then looks at how AI models can generate a short context to tie the chunk back to its source.
Tracing One Chunk Through Augmentation
It helps to think of augmentation as a sequence of steps that a chunk passes through between the original document and the form in which it is stored for retrieval. The source describes three kinds of added information and one generated addition. The order shown in the diagram is a teaching sequence that makes the progression easy to follow; the source does not present a fixed order. What matters is that each step adds something the bare chunk lacked before it becomes retrievable.
Notice that the chunk's own text stays in the middle of the process. Augmentation does not replace the passage. It wraps the passage in labels, likely questions, and references to the larger document, so that a query has more places to land and a reader has more to go on.
Metadata as Direct Labels
The simplest kind of augmentation attaches metadata to a chunk. Metadata is information about the content rather than the content itself. For retrieval, the most common forms are tags and keywords. Because these labels are stored alongside the chunk, a search can match on them directly, without needing the wording of the chunk body to line up with the wording of the query.
A tag is a label that places the chunk in a category. A keyword is a term that the chunk is known to be about. An extracted entity is a specific thing the text refers to, such as a product name, a person, an organization, or an error code.
Extracted entities deserve a special note. Because they are extracted automatically, the labels are generated from the text itself. They do not depend on someone writing them by hand for every chunk, which matters when a collection holds many fragments.
| Metadata type | What it holds | Source example |
|---|---|---|
| Tag | A label that places the chunk in a category | Named as a category label; no specific example given in the source |
| Keyword | A term that the chunk is known to be about | The error code EADDRNOTAVAIL (99) added to a document's metadata |
| Extracted entity | A specific thing the text refers to, such as a product, person, organization, or error code | Labels generated automatically from the text itself |
Kinds of metadata that give a chunk labels a search can match directly
Specific technical terms are a strong case for this technique. Suppose a document contains the error code EADDRNOTAVAIL (99). If that code is added to the document's metadata, a user who searches for the code can reach the document through that keyword. The source makes the important point that this works even after the document has been converted into embeddings, so the keyword remains a direct route to the content.
The source also gives examples for other content types. For ecommerce, a product can be augmented with its description and its reviews, so that a search for a feature mentioned only in reviews can still find the product. Images and videos can be queried by their titles or captions, because those short texts stand in for what the media contains.
Questions a Chunk Can Answer
A different kind of augmentation attaches to each chunk the questions it can answer. Users rarely search with the wording of a document. They ask questions, describe symptoms, or use informal phrasing. If the chunk is stored with the questions it answers, the search can match the user's phrasing directly to those questions rather than hoping the chunk's body uses the same words.
The source gives a customer support case. An article explaining how to reset a password can be augmented with queries such as 'How to reset password?', 'I forgot my password', 'I can't log in', or even 'Help, I can't find my account'. Each of these is a different way a frustrated customer might describe the same article, and none of them uses the article's own headline wording.
- How to reset password?
- I forgot my password
- I can't log in
- Help, I can't find my account
Borrowing Context from the Whole Document
Metadata and questions add information about a chunk from outside its text. A third approach adds information from the document the chunk came from. The motivation is the problem described at the start: when a document is split into several chunks, some of them may lack the context needed to say what they are about. A chunk that begins in the middle of a procedure may never mention the procedure's name.
The remedy is to augment each chunk with context from the original document, such as that document's title and summary. The title names the topic of the whole document, and the summary describes what the document covers. Attaching these to each chunk means that a fragment carries a reference to the larger whole it came from, so the reader can place it within a familiar subject.
Generated Context Linking Chunk to Source
Titles and summaries help, but a chunk about a particular step may need a sentence explaining what that step is for and where it sits in the larger document. Writing such a sentence by hand for every chunk is slow, so the source describes using AI models to produce it automatically. The model is given both the chunk and the original document, so the generated sentence can connect the passage to its place in the whole.
The output is a short context. Anthropic, as the source reports, used AI models to generate a context usually between 50 and 100 tokens long. That context explains what the chunk is about and how the chunk relates to the original document. It covers detail that a title and summary cannot, because it is written for the specific passage rather than for the whole.
Worked Example: Augmenting the Password Chunk
Augmenting the password reset chunk
The chunk 'Open the security page, choose Reset, and follow the link sent to your inbox' must become retrievable for the query 'how do I reset my password?' The chunk itself does not contain the word password. Show how each kind of added information changes what a search can match.
- 1Start with the bare chunk
The chunk has terms such as security page, Reset, and inbox. The query's word password matches nothing in the body, so a body-only search struggles to connect them.
- 2Add metadata labels
Add keywords such as password and account to the chunk's metadata. A search can now match password directly against a stored label, without relying on the body text.
- 3Attach answerable questions
Store questions such as 'I forgot my password' and 'I can't log in' with the chunk. The customer's informal phrasing can now match a stored question.
- 4Borrow the title and summary
Attach the source article's title, which names the topic of resetting access. The chunk now carries a reference to the larger subject, so a reader knows it belongs to that article.
- 5Generate a short passage context
An AI model reads the chunk and the article and produces a short context, for example a sentence stating that this passage is the final step of the password reset procedure. This connects the chunk to its place in the whole.
The final stored chunk holds its original text plus labels, likely questions, a reference to the larger topic, and a generated link to its source. The query now has several routes to reach the chunk, and the chunk still reads clearly to a human.
Mistakes When Augmenting Chunks
Common mistake Assuming the title and summary explain every chunk
What it looks likeA chunk about one specific step is given only the article title and summary, and no sentence about what that step is for.
Why it failsTitles and summaries describe the whole document, not the specific passage inside a chunk.
Do this insteadAdd generated context that explains the passage and its relationship to the document.
Common mistake Treating metadata as a replacement for the chunk text
What it looks likeStoring only keywords and discarding the passage because the labels seem to say what it is about.
Why it failsMetadata is information about the content rather than the content itself. The reader still needs the passage.
Do this insteadKeep the chunk text and attach metadata alongside it.
Common mistake Believing metadata only helps before embeddings are created
What it looks likeDropping an error code from the metadata after the document is converted into embeddings.
Why it failsThe source states that a keyword such as EADDRNOTAVAIL (99) still works as a direct route to the content after embedding conversion.
Do this insteadKeep exact identifiers in the metadata so they remain available for direct matching.
Common mistake Writing questions in the document's own headline wording only
What it looks likeStoring only 'Password reset procedure' as the question for a chunk about resetting access.
Why it failsUsers rarely search with a document's wording. The source's examples use phrasings such as 'I can't log in'.
Do this insteadAttach questions in the informal ways users actually describe their need.
Common mistake Expecting generated context to be long: the source describes a usual length of 50 to 100 tokens, not a full summary of the document.
Practice: Adding Context to a Log Step
A chunk reads: 'Restart the service and check the logs.' It was cut from a troubleshooting guide. Name one kind of metadata, one set of questions, and one piece of document-level context you would attach to it, and say in a sentence what each would help a search or reader do.
Hints
- Think about which exact terms a user might search for, such as a service or product name.
- Think about how a frustrated user might phrase the problem without using the guide's headline words.
- A title names the topic of the whole document, and a generated context can name where this step sits in the procedure.
Summary of Augmentation Approaches
- 1A chunk cut from its document can lose the context needed to say what it is about, so it may be hard to match to a query.
- 2Metadata such as tags, keywords, and extracted entities gives a chunk labels a search can match directly, which is especially useful for exact identifiers like error codes.
- 3Attaching the questions a chunk can answer lets informal phrasings reach the right content, and adding the document's title and summary restores the larger topic.
- 4AI models can generate a short context, usually 50 to 100 tokens, that explains a chunk and its relationship to the original document.
- 5The approaches are not competing answers: a chunk can carry several at once, and the right mix depends on what users search for and what the chunk lacks.
At a glance
- A chunk cut from its document can lose the context needed to say what it is about, and augmentation restores that context before retrieval.
- Metadata such as tags, keywords, and extracted entities gives a search direct labels to match, which is especially useful for exact identifiers like error codes.
- Questions a chunk can answer let informal user phrasings reach the right content, and the document's title and summary restore the larger topic.
- AI models can generate a short context, usually 50 to 100 tokens, that explains a chunk and links it to its source document.