SentenceChunker splits text into chunks while preserving complete sentences, ensuring that each chunk maintains proper sentence boundaries and context.
API Reference
To use theSentenceChunker via the API, check out the API reference documentation.
Installation
SentenceChunker is included in the base installation of Chonkie. No additional dependencies are required.For installation instructions, see the Installation
Guide.
Initialization
Parameters
Tokenizer to use. Can be a string identifier (“character”, “word”, “byte”, “gpt2”,
etc.) or a tokenizer instance
Maximum number of tokens per chunk
Number of overlapping tokens between chunks
Minimum number of sentences to include in each chunk
Minimum number of characters per sentence
Use approximate token counting for faster processing.
Delimiters to split sentences on
Specify whether to include the delimiter with the previous or next chunk.
Usage
Single Text Chunking
Batch Chunking
Using as a Callable
Supported Tokenizers
SentenceChunker supports multiple tokenizer backends:-
TikToken (Recommended)
-
AutoTikTokenizer
-
Hugging Face Tokenizers
-
Transformers
Return Type
SentenceChunker returns chunks asChunk objects:
