Chunking
Chunking is splitting documents into smaller passages before they are indexed for search, so an AI system can retrieve just the relevant pieces and pass them to a language model.
A retrieval-augmented generation system does not hand a language model a whole library. It splits each document into pieces, turns every piece into an embedding, and stores those embeddings in a vector index with a link back to the original file. When someone asks a question, the question is embedded too, the closest pieces are found, and only those pieces are added to the prompt. Amazon's documentation for Bedrock Knowledge Bases describes exactly this pipeline. Chunking is the splitting step, and it decides what the model can ever be shown.
There are several ways to split. Fixed-size chunking cuts text into pieces of a set number of tokens, usually with some overlap between neighbouring chunks so that a sentence cut at a boundary still appears whole in one of them. Recursive chunking, used by LangChain's RecursiveCharacterTextSplitter, tries paragraph breaks first, then line breaks, then spaces, until each piece is small enough. Semantic chunking embeds small groups of sentences and starts a new chunk where the meaning shifts sharply. Hierarchical chunking matches on small child chunks but hands the model the larger parent chunk they came from. Bedrock's default setting splits text into chunks of about 300 tokens while keeping sentences whole.
Size is a trade-off. Small chunks match a question precisely but can lose the context needed to make sense of them. Large chunks keep context but blur the match and use up more of the model's context window. Pinecone's guide suggests testing small sizes such as 128 or 256 tokens against larger ones such as 512 or 1,024, and offers a simple test: if a chunk makes sense to a person without its surroundings, it will probably make sense to the model too.
Anthropic gave a clear example of what goes wrong in September 2024. A chunk reading that the company's revenue grew by 3% over the previous quarter names neither the company nor the quarter, so it is hard to retrieve and easy to misuse. Its fix, called contextual retrieval, has a model write 50 to 100 tokens of explanation for each chunk before it is indexed for both embedding and keyword search. In Anthropic's tests, the share of searches that missed the right passage in the top 20 results fell from 5.7% to 2.9%, and to 1.9% when a reranker was added.
In practice, when a chatbot built on company documents gives a wrong or partial answer, the fault often lies in retrieval rather than in the model, and chunking is one of the first settings to examine. There is no single correct chunk size. The right choice depends on the documents, the embedding model and the kinds of questions people ask, and it is found by testing with real queries.
It is the step that splits source documents into smaller passages before they are embedded and stored for search. At question time the system retrieves the most relevant chunks and adds them to the model's prompt. Good chunks hold one coherent idea; bad ones split ideas in half or bury them among unrelated text. There is no universal answer. Common starting points run from a few hundred tokens up to about 1,000, and Amazon Bedrock's default is roughly 300 tokens. The reliable approach is to try several sizes on your own documents and real questions and keep whichever retrieves the right passages most often. Overlap repeats a little text from the end of one chunk at the start of the next. It reduces the chance that a key sentence is cut in two and lost. Tools such as Bedrock let you set overlap as a percentage or a number of tokens; more overlap means more storage and some duplicated results. Semantic chunking places chunk boundaries where the topic changes rather than at a fixed length. It embeds groups of neighbouring sentences and splits where consecutive groups differ sharply in meaning. It can produce more coherent chunks, but it costs more to run because it uses a model during ingestion.Common questions
What is chunking in RAG?
What is a good chunk size?
What is chunk overlap?
What is semantic chunking?
Search for "chunking strategies for RAG", "semantic chunking" or "contextual retrieval" to see the main methods and how they are tested. The most useful sources are documentation from vector database and cloud providers, which explain the settings their tools expose, and engineering write-ups that publish retrieval measurements on named datasets. Be wary of guides that recommend one chunk size for every case without showing results.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.