New Tool Radar

AI Concepts

How to Split RAG Documents with a Recursive Splitter

Split long documents for RAG with a recursive splitter that tries paragraph breaks before sentence breaks, so chunks keep their meaning.

Schematic illustration with three step boxes: list the separators, set size and overlap, and check the cuts.

A recursive splitter tries the largest natural boundary first, paragraphs, and only falls back to smaller units, lines, sentences, then words, when a piece is still too long. In one published benchmark, a 200-token recursive splitter with no overlap was consistently strong across metrics, and a 512-token recursive split scored the best end-to-end accuracy in another test. It is the sensible default for most prose.

Before you start

A text splitter that supports recursive splitting, such as LangChain RecursiveCharacterTextSplitter, and a sample of your documents.

List the separators in order

Set the separator order to double newline, single newline, sentence end, then space. The splitter walks this list from large to small, so a paragraph that fits stays whole and only oversized pieces get cut finer.

Do not start with a fixed character count. A fixed cut ignores sentence ends and can split a fact in half, which is the failure the recursive approach exists to avoid.

Set the size and overlap

Start at 512 tokens with 50 to 100 tokens of overlap, which is 10 to 20 percent of the chunk size. This matches the configuration that performed well in published benchmarks for question answering.

For short documents such as FAQs, use one question and answer per chunk instead. A FAQ split by token count can separate a question from its answer.

Check the cuts by hand

Print the first twenty chunks and read the first and last line of each. A good cut ends at a sentence end; a bad cut ends mid-sentence or mid-number.

Count how many chunks end mid-sentence. If more than one in ten does, shorten the chunk size or add a finer separator before you re-index.

Practice check: fictional Maple Corner handbook, 12 pages

The table below is fictional practice material, worked out by hand from the stated splitter settings. It is the expected result for the practice document, not a run of any splitter.

Setting Chunks Mid-sentence cuts Verdict
Fixed 512 chars 48 11 Fail – too many bad cuts
Recursive 512 tokens 31 1 Pass
Recursive 256 tokens 58 0 Pass, but more chunks

The recursive splitter at 512 tokens cuts the mid-sentence breaks from 11 to 1 while keeping the chunk count low. The 256-token version is cleaner but nearly doubles the chunk count.

Expected result. UNTESTED: the cut counts in the practice table are worked out by hand, not measured by running a splitter. Run your own sample through the splitter, print the first twenty chunks, and count the mid-sentence cuts before you index.

Limits

  • Recursive splitting does not understand tables, code or lists: a table split across chunks still loses its headers.
  • Token counts depend on the tokenizer; the same character count is a different token count for different models.

Sources

See all