Search

Search IconIcon to open search

Recursive Chunking

Last updatedUpdated: by Jakub Žovák · 1 min read

Properties
created 07.02.2025, 16:04
modified 02.08.2026, 10:12
published Empty
sources Empty
topics Empty
authors Empty
ai-assisted No

Sources: Pinecone Chunking Strategies
Recursive chunking divides the input text into smaller chunks in a hierarchical and iterative manner using a set of separators. If the initial attempt at splitting the text doesn’t produce chunks of the desired size or structure, the method recursively calls itself on the resulting chunks with a different separator or criterion until the desired chunk size or structure is achieved. This means that while the chunks aren’t going to be exactly the same size, they’ll still “aspire” to be of a similar size.

1
2
3
4
5
6
7
8
9
text = "..." # your text
from langchain.text_splitter import RecursiveCharacterTextSplitter
text_splitter = RecursiveCharacterTextSplitter(
    # Set a really small chunk size, just to show.
    chunk_size = 256,
    chunk_overlap  = 20
)

docs = text_splitter.create_documents([text])