Recursive Chunking
What Is Recursive Chunking?
Recursive chunking splits large documents at natural boundaries until each piece fits a size limit. In retrieval-augmented generation, or RAG, it creates passages for embedding and retrieval while avoiding cuts through paragraphs or sentences when possible.
It starts with broad boundaries, such as sections or paragraphs, then uses smaller ones only when text remains too large. Chunk size is a passage's maximum length. Overlap repeats neighboring text to reduce context loss at boundaries.
How Recursive Chunking Works in RAG
A separator hierarchy sets the preferred order for preserving structure. A common order is section breaks, paragraphs, lines, sentences, words, and characters.
- Set a maximum chunk size, preferably in tokens.
- Split first at large boundaries, such as headings or blank lines.
- Check whether each passage fits the limit.
- Split oversized passages with the next smaller separator.
- Add limited overlap when nearby context is needed.
For example, a 2,000-token product guide might split by headings first. A long section can then split by paragraphs, and an unusually long paragraph by sentences.
Recursive Chunking vs. Fixed-Size and Semantic Chunking
Semantic chunking groups text by meaning, while recursive chunking follows a predefined structural order. Semantic approaches may create more coherent topics, but need extra analysis and are less predictable.
| Method | Splitting rule | Best fit |
|---|---|---|
| Recursive | Ordered separators and size limit | Mixed documentation and web content |
| Fixed-size | Equal token or character counts | Simple, unstructured text |
| Sentence or paragraph | One document boundary type | Clean prose with consistent formatting |
| Sliding window | Fixed chunks with repeated text | High-recall retrieval |
| Semantic | Detected topic or meaning shifts | Concept-dense content |
Benefits of Recursive Chunking
It is a practical default for documents with inconsistent structure.
- Preserves natural language boundaries when possible.
- Keeps chunk lengths predictable for embedding and retrieval.
- Handles mixed-format text better than one separator rule.
- Supports focused vector-search results for RAG answers.
Practical Limits of Recursive Chunking
Recursive chunking is a heuristic, not an understanding of meaning.
- Broken PDF extraction or scraped HTML can remove useful boundaries.
- Prose separators can split code, tables, and JSON poorly.
- Important context can fall on opposite sides of a chunk edge.
- Excessive overlap duplicates content and can dilute retrieval results.
How to Choose Chunk Size, Overlap, and Separators
Test settings against the questions people actually ask.
- Measure length in tokens when possible, since language models process tokens.
- Use headings, paragraphs, and sentences for prose, but functions, classes, or records for code and structured data.
- Store titles and headings as metadata so passages retain source context.
- Keep overlap small and justify it with observed failures.
- Review retrieved chunks, not only final answers, to find splitting problems.
Recursive Chunking in AI Application Development
Recursive chunking belongs in ingestion, before text becomes embeddings and is stored for retrieval. Teams planning app design and development can use it to improve knowledge search, while AI coding assistants can help implement and test the pipeline. Emergent helps builders create context-aware AI applications, and its glossary explains related software concepts.
on Emergent today


