ChonkieSentenceDocumentSplitter
Split documents into chunks at sentence boundaries using the Chonkie chunking library. Use this component in indexing pipelines to prepare documents for embedding and retrieval.
Key Features
- Splits text at sentence boundaries to preserve semantic coherence within chunks.
- Supports multiple tokenizer backends including character-based, word-based, and model-specific tokenizers.
- Configurable minimum sentences per chunk and minimum characters per sentence.
- Preserves page break information and source document metadata.
- Adds split metadata to each chunk:
source_id,page_number,split_id,split_idx_start,split_idx_end, andtoken_count.
Configuration
Add Workspace-Level Integration
- Click your profile icon and choose Settings.
- Go to Workspace>Integrations.
- Find the provider you want to connect and click Connect next to them.
- Enter the API key and any other required details.
- Click Connect. You can use this integration in pipelines and indexes in the current workspace.
Add Organization-Level Integration
- Click your profile icon and choose Settings.
- Go to Organization>Integrations.
- Find the provider you want to connect and click Connect next to them.
- Enter the API key and any other required details.
- Click Connect. You can use this integration in pipelines and indexes in all workspaces in the current organization.
- Drag the
ChonkieSentenceDocumentSplittercomponent onto the canvas from the Component Library. - Configure the
chunk_sizeto control the maximum number of tokens per chunk. - Optionally set
chunk_overlapto include overlapping content between adjacent chunks for better retrieval continuity.
Connections
ChonkieSentenceDocumentSplitter receives a list of Document objects as input from a document converter or file router. It outputs a list of smaller Document objects (chunks) you can connect to a document embedder.
Source Code
To check this component's source code, open sentence_splitter.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
ChonkieSentenceDocumentSplitter:
type: haystack_integrations.components.preprocessors.chonkie.sentence_splitter.ChonkieSentenceDocumentSplitter
init_parameters:
tokenizer: character
chunk_size: 512
chunk_overlap: 50
Parameters
Inputs
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | A list of documents to split into sentence-based chunks. |
Outputs
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | A list of document chunks with updated metadata. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
tokenizer | str | character | The tokenizer to use for counting tokens. Use character for character-based counting, or a model name (for example, gpt2) for model-specific tokenization. |
chunk_size | int | 2048 | The maximum number of tokens per chunk. |
chunk_overlap | int | 0 | The number of tokens to overlap between adjacent chunks. |
min_sentences_per_chunk | int | 1 | The minimum number of sentences to include in each chunk. |
min_characters_per_sentence | int | 12 | The minimum number of characters a sentence must have to be included. |
approximate | bool | False | Whether to use approximate token counting for faster processing. |
delim | Any | None | Custom sentence delimiters. If None, uses default sentence-ending punctuation. |
include_delim | str | prev | Where to include the delimiter in the chunk. One of prev or next. |
skip_empty_documents | bool | True | Whether to skip documents with no content. |
page_break_character | str | \f | The character used to represent page breaks in document text. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
documents | List[Document] | The documents to split. |
Related Information
Was this page helpful?