AI systemschunkchunkstext splittingchunk overlap

Chunking

Definition

Chunking is the ingestion step that divides a document into smaller passages, by size or by structure and often with overlap, each of which is embedded and indexed separately.

In practice

Embedding models accept limited input, and one vector for a long document blurs its topics together. Chunks of a few hundred tokens, split along headings, paragraphs or table rows where possible, retrieve better than fixed character counts. Each chunk carries metadata such as document id, chunk index, section title, tenant and permissions, and a deterministic id like documentId#chunkIndex makes re-ingestion idempotent.

Chunk size is a retrieval decision with no universal answer. Small chunks are precise but lose surrounding context; large ones carry context but dilute relevance and fill the context window faster. Changing the strategy means re-chunking and re-embedding the corpus, so evaluate it on real questions before ingesting millions of documents.

Example

A 40-page policy PDF is split by heading into 120 chunks of about 400 tokens with 50 tokens of overlap, upserted as policy-17#0 to policy-17#119.