Before retrieval can work, documents must be split into chunks. See how fixed-size, recursive, and document-structure chunking behave on the same text, and how overlap affects retrieval quality.
1 / 3 strategies tried
Sign in to save progress
Select a chunking method to see it applied live to the sample text below.
Pros
Simple, predictable chunk sizes, easy to implement at scale
Cons
May split mid-sentence, losing context across boundaries
Best For
Uniform documents, large-scale ingestion pipelines
Each color block is one chunk. Adjust the sliders to see boundaries shift in real time.
The transformer architecture revolutionized natural language processing. Before transformers, recurrent neural networks
ent neural networks struggled with long-range dependencies. The attention mechanism allows each token to directly attend
n to directly attend to all other tokens. This breakthrough enabled models like BERT and GPT to achieve state-of-the-ar
ieve state-of-the-art results. BERT uses bidirectional attention for understanding tasks. GPT uses autoregressive genera
utoregressive generation for creative and generative tasks. Transfer learning became standard practice. Pre-training on
ice. Pre-training on large corpora, then fine-tuning on specific tasks, dramatically reduced the data requirements.
a requirements.
Small chunks improve retrieval precision but lose context. Large chunks carry more context but reduce precision. For many general text corpora, 256–512 tokens is a common starting range, but the right size depends on your documents, queries, and embedding model, and should be tuned with retrieval evals.
Overlap ensures that context near a chunk boundary appears in both adjacent chunks, reducing information loss at split points.
15 tokens shared between adjacent chunks
Match the chunking approach to your document type for the best retrieval results.
Customer support docs
Recursive
Keeps paragraphs and sentences intact without requiring document markup
Legal contracts
Document-Structure
Clauses and numbered sections are the meaningful retrieval units; splitting mid-clause destroys meaning
Chat logs / transcripts
Fixed-Size
Little inherent structure, so uniform windows with overlap are a reasonable default
Code documentation
Document-Structure
Respects functions, classes, and section hierarchy
Insight
Small chunks (128 tokens) = precise retrieval but may lack context. Large chunks (1024 tokens) = rich context but retrieval is less precise. A common starting point is around 512 tokens with ~10% overlap; from there, measure retrieval quality on your own data and adjust.
Up Next
Once your documents are chunked and retrieved, how you structure the prompt determines whether the LLM uses that context well. Explore the techniques.
Explore Prompt Engineering →