Interactive engineering lab

Embedding chunks: token limits, overlap and dropped text

Size chunks against an embedding input limit, see which tokens and facts never reach a vector, and export the spans.

By Sandeep Belgavi · Published 2026-12-05

Synthetic local computation. No model or remote service is contacted.

Experiment workspace

Decision trace

    The mechanism

    An embedding model reads at most a fixed number of tokens. Special tokens and any prefix or header take some of them, so the text budget per chunk is the limit minus both. A chunker splits the document into windows of a chosen size with a chosen overlap. Each window that fits is embedded whole. A window that does not fit is either truncated, keeping only its first usable tokens, or rejected. Tokens outside every embedded span are invisible to vector search.

    Synthetic fixture and controls

    The fixture is a 1,400-token synthetic store policy with six facts at fixed token positions, from returns at token 40 to lost parcels at token 1,290. All counts are declared integers, not output from a real tokenizer. Controls set document length, chunk size, overlap, model limit, prefix tokens, special tokens and the overflow mode. Overlap must be smaller than the chunk size, and the prefix plus special tokens must leave room for text.

    Expected outcomes

    The default uses 400-token chunks with 50 tokens of overlap against a 256-token limit with 2 special and 8 prefix tokens, leaving 246 for text. Four chunks are created and all four are truncated. 416 tokens, 29.7 percent, are never embedded, and facts F2 at token 300 and F5 at token 1,010 are unreachable. Chunks of 240 with overlap 40 give seven chunks that all fit. A 512-token limit makes the original four chunks fit. Reject mode indexes nothing from the default chunks.

    Read the decisions

    The setup line shows the usable text budget. Each chunk line states the chunk range and whether it fitted, was truncated with the number of dropped tokens, or was rejected. Fact lines state whether each fact lies inside an embedded span. The span list below the metrics shows exactly which token ranges a vector represents, which is what a citation should point at.

    Experiment before choosing a chunker

    Raise the overlap from 50 to 150 in the default and watch the uncovered count fall but not reach zero; overlap duplicates chunk starts, while truncation removes chunk ends. Set the prefix to zero and see how much the prefix cost. Switch to reject mode to see why failing closed surfaces the problem at ingestion. Then find the largest chunk size that still fits the usable budget. Export records the inputs, chunk spans, facts and full trace.

    Limits and production verification

    Token positions here are declared, and facts are single points. Real tokenizers produce different counts for the same text, models count special tokens differently, and runtimes differ in whether they truncate, reject or let you choose. Sentence-aware chunkers do not cut at fixed offsets. Measure token counts with the tokenizer of the embedding model, ask the runtime to fail rather than truncate where possible, and test retrieval of facts near the end of long sections, as the linked article describes.

    Views are my own and do not represent any employer, past or present.