The Late Chunker generates contextual embeddings for each token before chunking, enabling more semantically aware chunk boundaries.
Examples
Text Input
from chonkie.cloud import LateChunker
chunker = LateChunker(
embedding_model="minishlab/potion-base-8M",
chunk_size=512
)
text = "Your text here..."
chunks = chunker.chunk(text)
from chonkie.cloud import LateChunker
chunker = LateChunker(
embedding_model="minishlab/potion-base-8M",
chunk_size=512
)
# Chunk from file
with open("document.txt", "rb") as f:
chunks = chunker.chunk(file=f)
Request
Parameters
The text to chunk. Can be a single string or an array of strings for batch processing. Either text or file is required.
File to chunk. Use multipart/form-data encoding. Either text or file is required.
embedding_model
string
default:"minishlab/potion-base-8M"
The embedding model to use.Chosen embedding model must return token level embeddings. Request will fail
otherwise
Maximum number of tokens per chunk.
Language of the document to chunk
Response
Returns
Array of Chunk objects, each containing:
Starting character position in the original text.
Ending character position in the original text.
Number of tokens in the chunk.