RAG Chunk Count Calculator
Work out how many chunks a document corpus splits into for a RAG pipeline given chunk size and overlap, plus the tokens embedded and the one-time embedding cost.
How it works
Stride = chunk size − overlap · Chunks = ⌈corpus tokens ÷ stride⌉ · Tokens embedded = chunks × chunk size
A RAG pipeline splits documents into fixed-size chunks that each become one embedding, and adjacent chunks usually overlap so a passage split across a boundary is still retrievable whole. The number of chunks is the corpus size divided by the stride (chunk size minus overlap), so more overlap means more chunks, more vectors to store and more tokens to embed. This is the number that sizes your vector database and your one-time embedding bill; smaller chunks improve retrieval precision but multiply count, so it is a direct precision-versus-cost trade.
Worked example
A 500,000-token corpus with 512-token chunks and 50-token overlap has a stride of 462. That is ⌈500,000 ÷ 462⌉ ≈ 1,083 chunks, embedding 1,083 × 512 ≈ 554,000 tokens; at $0.02 per million that is about $0.011 — roughly 11% more tokens than the raw corpus because of overlap.
Frequently asked questions
How does overlap change the chunk count?
Overlap shrinks the effective stride (chunk size minus overlap), so the corpus is divided into more, partly-repeated chunks. A 512-token chunk with 50-token overlap advances only 462 tokens each step, giving about 11% more chunks than no overlap.
What chunk size should I use?
Common choices are 256–1,024 tokens. Smaller chunks pinpoint relevant passages and improve precision but create more vectors and can lose context; larger chunks keep context but dilute relevance and raise per-chunk embedding cost. Match it to how self-contained your ideal answer passage is.
Is the embedding cost one-time?
The cost to embed the corpus is one-time (plus re-embedding when documents change). Query-time embedding of the user’s question and the vector database’s ongoing storage and search costs are separate — size those with a vector database cost calculator.
Related calculators
Educational estimate — real costs and memory depend on your provider, framework, model architecture and pricing, which change often. Verify against your own bills and profiling before committing budget.