chunking.late_chunking

chunktuner.chunking.late_chunking

late_chunking: fixed-token fallback; true late chunking is not implemented.

Late chunking is an embedding-side technique (pooling per-token vectors from a whole-document forward pass), so it cannot be expressed as a pure text splitter. This strategy is excluded from default all-strategy tuner runs and must be requested explicitly.

LateChunkingStrategy

LateChunkingStrategy(encoding_name='cl100k_base')

Fixed-token fallback: delegates to FixedTokenStrategy (no late pooling).

Source code in src/chunktuner/chunking/late_chunking.py
def __init__(self, encoding_name: str = "cl100k_base"):
    self._inner = FixedTokenStrategy(encoding_name=encoding_name)

chunk

chunk(doc, config)

Chunk with inner FixedTokenStrategy using chunk_size_tokens / overlap.

Source code in src/chunktuner/chunking/late_chunking.py
def chunk(self, doc: Document, config: ChunkConfig) -> list[Chunk]:
    """Chunk with inner `FixedTokenStrategy` using ``chunk_size_tokens`` / overlap."""
    validate_content_type(self.name, self.supported_content_types, doc.content_type)
    max_tokens = int(
        config.params.get("chunk_size_tokens", config.params.get("max_tokens", 256))
    )
    overlap = int(config.params.get("overlap_tokens", 0))
    return self._inner.chunk(
        doc,
        ChunkConfig(
            name="fixed_tokens",
            params={"max_tokens": max(16, max_tokens), "overlap_tokens": overlap},
        ),
    )