Why Chunk?
- Embedding models have token limits — most accept 512-8192 tokens
- Smaller chunks are more precise — a paragraph about “authentication” matches better than a full page with mixed topics
- Overlap preserves context — overlapping boundaries prevent information loss at chunk edges
TextChunker
Splits text on a single separator (e.g., double newlines for paragraphs):RecursiveChunker
Splits text using a hierarchy of separators, falling back to finer-grained splits when chunks are too large. This is the default chunker and generally produces the best results.Ordered list of separators to try. The chunker uses the first separator that produces chunks within the size limit, then recurses with finer separators for any chunks that are still too large.
\n\n— paragraph breaks (preferred)\n— line breaks.— sentence endings— word boundaries""— character-level split (last resort)