Fixed-Size and Recursive Chunking
In this article
- Work out by hand where a fixed-size splitter cuts a document and which tokens its overlap repeats.
- Predict where a recursive splitter cuts, including 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.
- Terms defined here: fixed-size chunking, chunk overlap, recursive chunking, stable chunk ID.
Overview
Every chunker has to answer one question again and again: where does this piece end? The simplest answer is "after 500 tokens", and it is a good one more often than you would think. A slightly better answer is "at the last paragraph edge before 500 tokens, and only if there is none, somewhere smaller". Both answers are plain code with no model inside, so they give the same cuts every time, and that is what makes them the baseline every cleverer strategy is measured against.
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
- The chapter
- 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