RAG Chunk Size Planner
When you split documents into chunks for retrieval-augmented generation (RAG), overlap keeps context across boundaries but also duplicates text you must embed and store. Enter your corpus size, how many documents it holds, the chunk size and the overlap, and see the effective stride, the number of chunks, the duplicated tokens and what that means for storage and retrieval.
Result
Exact arithmetic on your numbers
Enter the corpus size and chunk settings to plan the chunks.
- Overlap in tokens
- Effective stride (tokens)
- Chunks per document
- Total chunks
- Duplicated overlap tokens
- Tokens to embed
- Overlap overhead
- Chunks with no overlap
- Extra chunks from overlap
- Average stored chunk (tokens)
- Raw vector storage
- Tokens retrieved per query
Exact arithmetic under two simplifications: documents are equal in size and chunks are a fixed number of tokens. Real chunkers that split on sentences or headings produce uneven chunks.
Examples
Worked examples:
| Corpus (tokens) | Documents | Chunk / overlap | Chunks | Tokens to embed |
|---|---|---|---|---|
| 1,500 | 1 | 512 / 15% | 4 | 1,728 |
| 1,000,000 | 100 | 512 / 10% | 2,200 | 1,107,100 |
| 50,000,000 | 20,000 | 1,024 / 20% | 60,000 | 58,160,000 |
| 10,000,000 | 100,000 | 512 / 15% | 100,000 | 10,000,000 |
Formula & Methodology
For fixed-size chunks with token overlap the counts are exact:
overlap tokens = floor(chunk size × overlap %)stride = chunk size − overlap tokenschunks per document = 1 + ceil((document tokens − chunk size) ÷ stride), or 1 if the document fits in one chunkduplicated tokens = documents × (chunks per document − 1) × overlap tokenstokens to embed = corpus tokens + duplicated tokensGood to know
- The best chunk size depends on your content and your questions. Many teams start with a few hundred to about a thousand tokens and 10–20% overlap, then test retrieval quality on real queries.
- Overlap helps keep sentences and ideas from being cut at a boundary, but every overlapping token is embedded, stored and indexed twice.
- Smaller chunks mean more vectors to store and search; larger chunks mean fewer vectors but more irrelevant text sent to the model per match.
- Embedding APIs bill by tokens, so “tokens to embed” is also your embedding volume. Add the overlap to the cost, not just the corpus.
- Splitting on structure (paragraphs, headings, code blocks) usually beats a fixed token count. Use the numbers here as a planning baseline.
How to Use
- Enter the corpus size in tokens, or in words, and the number of documents.
- Set the chunk size and the overlap percentage.
- Optionally add your embedding dimensions and precision and the chunks retrieved per query.
- Read the stride, chunk count, duplicated tokens and storage, and compare overlaps.
Frequently Asked Questions
What is the stride in chunking?
The stride is how far the chunk window moves each step: the chunk size minus the overlap. With 512-token chunks and 76 tokens of overlap the stride is 436, so each new chunk starts 436 tokens after the previous one.
How much overlap should I use?
There is no universal answer. Many teams use around 10–20%. Zero overlap is smallest but can cut ideas in half; very high overlap multiplies your vectors and embedding cost. Test retrieval quality with your own questions.
How is the number of chunks calculated?
If a document fits in one chunk it makes one chunk. Otherwise it makes 1 plus the number of strides needed to cover the rest: 1 + ceil((document tokens − chunk size) ÷ stride). The calculator multiplies that by the number of documents.
Why does overlap increase embedding cost?
Overlapping tokens appear in two chunks, so they are embedded and stored twice. The “tokens to embed” figure adds those duplicated tokens to your corpus size.
Is this exact for my documents?
The arithmetic is exact for equal-sized documents and fixed token chunks. Real documents differ in size and many chunkers split on sentences or headings, so treat the result as a planning estimate and verify against your own pipeline.
Last updated: