liveBook · Manning

RecursiveCharacterTextSplitter

As explained in Build Python Web Apps with Streamlit

RecursiveCharacterTextSplitter is a LangChain utility that divides documents into overlapping text chunks while attempting to preserve meaningful context.

RecursiveCharacterTextSplitter divides loaded documents into manageable, similarly sized chunks before they enter a searchable vector store. This keeps retrieved prompts smaller while preserving context between neighboring chunks. section 10.5.2

Configure the splitter by choosing:

  • chunk_size=1000, which targets 1,000 characters per chunk. section 10.5.2
  • chunk_overlap=200, which repeats 200 characters between adjacent chunks to maintain context. section 10.5.2
  • split_documents(documents), which produces texts ready for storage and embedding. section 10.5.2

Preparing support articles for RAG

Load .txt articles with DirectoryLoader, split them with RecursiveCharacterTextSplitter, and pass the resulting chunks to add_documents. Pinecone then stores the text alongside embeddings so similarity_search can retrieve relevant excerpts for a user's question. section 10.5.2

splitter = RecursiveCharacterTextSplitter(
  chunk_size=1000,
  chunk_overlap=200
)
texts = splitter.split_documents(documents)

Inspect the minimal splitter configuration and the call that converts loaded documents into searchable chunks. section 10.5.2

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains chunk size, overlap, splitting, and downstream storage, but does not detail the splitter's internal algorithm.
Examples
Uses .txt support articles, 1,000-character chunks, 200-character overlap, Pinecone indexing, and similarity-based retrieval.
What it assumes
Assumes loaded Document objects and introduces chunking before embedding, indexing, and similarity retrieval.
What you can do after
Build it from scratch to split loaded articles into overlapping chunks ready for embedding and vector-store indexing.
How it connects
Connects document loaders, embeddings, vector stores, similarity search, and retrieval-augmented generation.

Also explained in

Compare how 4 books explain RecursiveCharacterTextSplitter →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.