Chunking Documents for Retrieval Augmented Generation
This lesson explains how documents are split into chunks before embedding for RAG, one of the strongest levers on RAG quality, since chunks that are too small lose context and chunks that are too large dilute relevance.
Learning outcomes
After completing this lesson, you will be able to:
- Explain why chunk size matters.
- Choose a chunking strategy in Bedrock Knowledge Bases.
- Test chunking strategies against real questions.
Why chunk size matters
Each chunk becomes one vector. A small chunk produces a precise vector for one idea, which retrieves well, but it may lack the surrounding context needed to answer. A large chunk carries more context, but its vector averages several ideas and matches queries less sharply, and every retrieved chunk adds input tokens to the prompt. Chunks must also fit within the embedding model's input limit. Overlap between consecutive chunks keeps sentences that span a boundary available in both.
Too small or too large?
Chunking strategies in Bedrock Knowledge Bases
Bedrock Knowledge Bases offers several strategies, chosen per data source. Fixed-size chunking splits by a maximum number of tokens with an overlap percentage; it is predictable and a good default. Hierarchical chunking creates large parent chunks and small child chunks; search runs on children for precision, and the parent is returned for context. Semantic chunking uses an embedding model to split where meaning changes, keeping related sentences together at extra cost. No chunking treats each file as one chunk, for documents that are already small. Custom chunking runs your own Lambda function, for example to split by legal clause or by heading.
The chunking configuration of a data source cannot be changed after it is created, so changing it means creating a new data source and re-ingesting. The following table summarises the strategies.
| Strategy | Best for | Trade-off |
|---|---|---|
| Fixed-size with overlap | General documents, a reliable default | May split mid-idea |
| Hierarchical | Long structured documents needing context | Returns fewer, larger passages |
| Semantic | Unstructured text with topic shifts | Extra embedding cost at ingestion |
| No chunking | Pre-split or very short documents (FAQs) | Large files become one weak vector |
| Custom (Lambda) | Domain structure such as clauses or code | Code to maintain |
Bedrock chunking strategies
Choosing and testing a strategy
The right chunking strategy depends on the structure of the documents and the questions users ask. Frequently asked questions with short answers need small chunks, or no chunking at all, so each answer is retrieved on its own. Manuals in which answers span several sections benefit from hierarchical chunking, which retrieves small chunks but passes their larger parent sections to the model. Contracts with numbered clauses suit custom chunking that splits on clause boundaries.
Strategies should be compared with evidence rather than chosen by intuition. A test set of questions with known source passages is built, each strategy is evaluated with retrieval metrics such as recall at k, and the best performer is used in production.
The following diagram compares what three chunking strategies return for a question about step 4 of a multi-step procedure.

Test a chunking change
Technical manuals
A RAG assistant for 300-page equipment manuals uses fixed 200-token chunks. Users complain that answers describe step 4 of a procedure without steps 1 to 3.
Strategy Retrieved passage Answer quality
Fixed 200 tokens Step 4 only Incomplete
Fixed 1,500 tokens Whole procedure + unrelated section Complete but noisy, 7x tokens
Hierarchical Child: step 4 (match) -> parent: Complete and focused
(parent 1,500 / whole procedure (returned)
child 300)Hierarchical chunking keeps precise matching on small children while returning the full procedure as context. Because chunking cannot be changed on the existing data source, the team creates a new data source with hierarchical chunking, syncs it and switches after the evaluation confirms the gain.
When is hierarchical chunking better than fixed-size chunks?
Show answer
When answers need wider context than the matched text: small chunks are matched and their larger parent is returned.
Exam Tips
Remember for the exam
- Default: fixed-size chunking with overlap.
- Answers need wider context than the matched text: hierarchical chunking.
- Split where topics change: semantic chunking (extra cost).
- Domain-specific boundaries: custom chunking with Lambda.
- Chunking cannot be changed on an existing data source; re-ingest into a new one.