Homeglossary

Recursive Chunking

Recursive chunking is a text-splitting method that divides large documents at natural boundaries until each piece fits a chosen size limit. In retrieval-augmented generation and other LLM pipelines, it helps preserve readable context better than blindly cutting text at fixed intervals. Its results depend on the separator order, the measurement unit, and the structure of the source material.

Build context-aware AI apps with Emergent.

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.

  1. Set a maximum chunk size, preferably in tokens.
  2. Split first at large boundaries, such as headings or blank lines.
  3. Check whether each passage fits the limit.
  4. Split oversized passages with the next smaller separator.
  5. 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.

MethodSplitting ruleBest fit
RecursiveOrdered separators and size limitMixed documentation and web content
Fixed-sizeEqual token or character countsSimple, unstructured text
Sentence or paragraphOne document boundary typeClean prose with consistent formatting
Sliding windowFixed chunks with repeated textHigh-recall retrieval
SemanticDetected topic or meaning shiftsConcept-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.

Start Building
on Emergent today
Start Building