Skip to main content

Overview

Semantic splitter identifies boundaries by embedding sentences and finding points of high cosine distance between adjacent sentences, indicating topic changes. Uses statistical methods to determine breakpoint thresholds. Requires an embedding provider. Splitter Class: SemanticChunker Config Class: SemanticChunkingConfig

Dependencies

Also requires an embedding provider (e.g., OpenAIEmbedding).

Examples

Parameters

ParameterTypeDescriptionDefaultSource
chunk_sizeintTarget size of each chunk1024Base
chunk_overlapintOverlapping units between chunks200Base
min_chunk_sizeint | NoneMinimum size for a chunkNoneBase
length_functionCallable[[str], int]Function to measure text lengthlenBase
strip_whitespaceboolStrip leading/trailing whitespaceFalseBase
embedding_providerEmbeddingProviderRequired embedding provider instanceRequiredSpecific
breakpoint_threshold_typeBreakpointThresholdTypeStatistical method for breakpointsPERCENTILESpecific
breakpoint_threshold_amountfloatNumeric value for threshold type95.0Specific
sentence_splitterCallable[[str], list[str]]Function to split text into sentencesDefault regexSpecific