AI Glossary

Chunking

In retrieval systems, chunking divides source material into smaller pieces that can be indexed and returned as evidence. Chunk boundaries determine how much context survives when a passage is retrieved on its own.

· Updated · Chain of Thought

RAG & Retrieval

Consider a returns policy with a general 30-day rule and an exception for custom orders. If the exception lands in a separate chunk, a search can find the general rule and miss the qualification. Keep the rule and its relevant exception together, or give retrieval a way to return both.

A chunk saying “the limit is 30 days” also needs the product or customer tier named by its heading. Preserve useful headings and source identifiers with the text. Anthropic’s Contextual Retrieval approach addresses this loss of context by adding a short explanation of each chunk’s place in the document before indexing it.

There is no universal best size. Small chunks can retrieve a precise passage but omit context; large ones can include the context but also unrelated text. Overlap can protect boundaries at the cost of duplicates. Test representative questions and inspect whether their supporting evidence survives the split, using retrieval evaluation.

Keep the exception with the ruleA returns policy has a general 30-day rule and an exception that custom orders cannot be returned. Splitting them into separate chunks can leave an answer with only the general rule. A context-preserving chunk includes the heading, rule and exception, with its source. Keep the exception with the rule Chunk boundaries change the evidence an answer seesSOURCE: RETURNS POLICYReturns accepted within 30 days.Exception: custom orderscannot be returned.CHUNK AReturns accepted within 30 days.CHUNK BCustom orders cannot be returned.Retrieving only A misses the exception.CONTEXT-PRESERVING CHUNKReturns policy: within 30 days, except custom orders.Retain the heading and source; retrieve the qualification too.
An illustrative returns policy. Anthropic’s Contextual Retrieval article explains why isolated chunks need their document context. Download the image

Sources

Go deeper