How it works · 6 of 37 Core
What is chunking in RAG, and how should documents be split?
Cutting documents into findable pieces
Chunking: Documents are split into chunks before embedding; where you cut decides what search can find.
Loading the animation…
Say it like this Documents are cut into pieces before search, and search hands the model one piece; cut in the wrong place and the answer is split.
Under the hood — for builders
- What indexing means
- The one-time step before anyone asks: each chunk is turned into numbers (its embedding) and saved, so every search can compare against it. A chunk from this page:
- Biggest proven fix: give each chunk its context
- A chunk cut from a long document can lose who and when. Anthropic's example (2024), word for word:
- Result
- Anthropic tested this on real documents. Missed searches, lower is better:
- Typical size
- Measured in tokens, not words. LlamaIndex default: 1,024 per chunk, 200 shared with the next.
- Methods
- Fixed + overlap (default) · Recursive (LangChain) · By section · By meaning. See the tabs.
- Measure it
- recall@k on your own test questions; rerun the same set after every change (see Semantic search).
- Watch out
- Too small: no context (“14 days” of what?). Too big: mixed topics. Clean tables, PDF columns and scans first.
- Sources
- Anthropic, Contextual Retrieval (Sep 2024) · LlamaIndex SentenceSplitter · LangChain RecursiveCharacterTextSplitter.
What happens in the chunking animation, step by step?
- Search can't hand the model a whole document, only a small piece of it. So every document is cut into pieces ("chunks") before it's searched.
- Where you cut matters. Cut blindly every 3 words and the refund sentence is split: "We refund" | "you 14 days".
- A customer asks how long refunds take. The search finds the piece that matches best, so the model gets only "Refunds: We refund", and can't answer.
- Cut where the meaning breaks instead, here at each heading. Now the piece holds the whole rule, and the answer is right.
- There are four common ways to cut. Tap each tab and watch where it puts the cuts.
What everyday example explains chunking?
Cutting a cookbook into recipe cards. Cut mid-recipe and the ingredients lose their method.
Why should a team care about chunking?
The model can only answer from the piece it's handed, so a bad cut breaks RAG even when search and model are fine.