Skip to main content
The SentenceChunker splits text into chunks while preserving complete sentences, ensuring that each chunk maintains proper sentence boundaries and context.

API Reference

To use the SentenceChunker 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
Union[str, Callable, Any]
default:"character"
Tokenizer to use. Can be a string identifier (“character”, “word”, “byte”, “gpt2”, etc.) or a tokenizer instance
chunk_size
int
default:"2048"
Maximum number of tokens per chunk
chunk_overlap
int
default:"0"
Number of overlapping tokens between chunks
min_sentences_per_chunk
int
default:"1"
Minimum number of sentences to include in each chunk
min_characters_per_sentence
int
default:"12"
Minimum number of characters per sentence
approximate
bool
default:"False"
Use approximate token counting for faster processing.
This field is deprecated and will be removed in future versions.
delim
Union[str, list[str]]
default:"['.', '!', '?', '\\n']"
Delimiters to split sentences on
include_delim
Optional[Literal["prev", "next"]]
default:"prev"
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 as Chunk objects: