Fixed-Size and Recursive Chunking
In this article
- Work out by hand where a fixed-size splitter cuts a document and which words its overlap repeats.
- Predict where a recursive splitter cuts, and say what happens to a piece that no separator can make small enough.
- Give every chunk an id and offsets that lead back to the exact text, and say what must stay pinned for a rerun to give the same ids.
- Treat a simple splitter's settings as a starting point to test, not as the answer.
- Terms defined here: fixed-size chunking, chunk overlap, recursive chunking, stable chunk ID.
Overview
A long document has to be cut into pieces before a search can find the part that answers a question, and somebody has to write the code that decides where the cuts go. The easiest code counts to a number and cuts. That is fast and predictable, and it happily cuts a rule in half between "who may" and "who may not". A slightly smarter version looks for a paragraph edge first and counts only when it has to.
After this you can work out by hand where each kind of splitter cuts, and spot the case where even the smarter one cuts mid-sentence. Every piece gets an id and a pair of positions that lead back to the exact text, and you will see why a rerun next month must give the same cuts.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- Cutting by count
- Five hundred of what
- Cutting at the largest edge that fits
- Running both
- When no edge fits
- Ids that point back
- Common mistakes
- Sources
- Check yourself, 13 questions