rag.splitters.recursive
Split text recursively by a prioritized list of separators.
Split text recursively by a prioritized list of separators.
- class RecursiveChunker(chunk_size=1000, chunk_overlap=200, metadata=None, separators=None, keep_separator=True)[source]
Bases:
ChunkerBaseRecursive chunking that splits hierarchically by separators.
- Parameters:
chunk_size (int) – Maximum characters per chunk.
chunk_overlap (int) – Overlap between consecutive chunks.
metadata (dict[str, Any] | None) – Default metadata for all chunks.
separators (list[str] | None) – List of separators in order of preference.
keep_separator (bool) – Whether to keep the separator with chunks.
- DEFAULT_SEPARATORS = ['\n\n\n', '\n\n', '\n', '. ', '! ', '? ', '; ', ', ', ' ', '']
Classes
- class RecursiveChunker(chunk_size=1000, chunk_overlap=200, metadata=None, separators=None, keep_separator=True)[source]
Bases:
ChunkerBaseRecursive chunking that splits hierarchically by separators.
- Parameters:
chunk_size (int) – Maximum characters per chunk.
chunk_overlap (int) – Overlap between consecutive chunks.
metadata (dict[str, Any] | None) – Default metadata for all chunks.
separators (list[str] | None) – List of separators in order of preference.
keep_separator (bool) – Whether to keep the separator with chunks.
- DEFAULT_SEPARATORS = ['\n\n\n', '\n\n', '\n', '. ', '! ', '? ', '; ', ', ', ' ', '']