← All topics

Embeddings & Data Prep · Topic 25

Overlapping chunks vs. fixed-size chunks

Fixed-size chunking splits text into segments of constant length (e.g. 512 tokens or 500 characters) with no overlap. Overlapping chunking slides a window so adjacent chunks share some text. The choice affects how many vectors you store, whether context spans boundaries, and how often the same content appears in search results in your vector database. Both strategies are common in RAG and semantic search pipelines; the right choice depends on your documents and quality vs. cost trade-offs.

Summary

  • Fixed-size: constant length, no overlap; simple, predictable; risk of cutting context at boundaries.
  • Overlapping: sliding window (e.g. 100 tokens, 20-token overlap); better chance that an idea sits fully in one chunk; more chunks and possible duplicate/near-duplicate hits.
  • Overlap often used for RAG and semantic search; manage with re-ranking, dedup by doc ID, or limit per document; see chunking and vector quality.
  • Trade-off: overlap improves recall at boundary issues but increases index size and duplicate results; fixed-size is cheaper and simpler but can miss context at splits.
  • Practical tip: 10–20% overlap is common; combine with semantic boundaries (e.g. paragraph then overlap within) when structure allows.

Fixed-size chunking

Fixed-size chunks are simple and predictable: same token count (or character count) per chunk, easy to reason about index size and batch embedding. The downside is that important context can be cut at a boundary—e.g. a key sentence split across two chunks—so the embedding may not match queries that refer to that full idea.

No overlap also means fewer total chunks and thus lower storage and fewer duplicate results, but boundary effects can hurt recall when the split is unlucky. When to use fixed-size: when you need predictable, simple behavior, when document structure is messy, or when storage and latency are tight. Pipeline tip: use the same tokenizer as your embedding model so chunk size in tokens is exact; see batching embeddings for ingestion for scaling upserts.

Overlapping chunking

Overlapping chunks (e.g. 100 tokens with 20-token overlap) give each “idea” a chance to sit fully inside at least one chunk. The sliding window ensures that content near a boundary appears in two chunks, so at least one of them may embed the full idea and match the query. That can improve recall, but you get more chunks and thus more vectors and possible duplicate or near-duplicate hits.

You then manage duplicates with re-ranking, deduplication by document ID, or limiting results per document. Trade-off: overlap often used when boundary effects hurt quality; the extra vectors are a trade-off for better retrieval. How much overlap: common is 10–20% of chunk size (e.g. 50 tokens overlap for 256-token chunks). Too much overlap bloats the index and duplicates; too little may not fix boundary issues. Tune on your corpus and measure recall and user-facing relevance.

Choosing and tuning

In practice, overlap is often used for RAG and semantic search when boundary effects hurt quality; the extra vectors are a trade-off for better retrieval. There’s a direct link to how chunking affects vector quality: the right balance depends on your documents, tokenization, and retrieval goals. Try both strategies on a sample and measure recall and relevance.

You can combine semantic boundaries and overlap: for example, split by paragraph or section first, then apply a fixed size with overlap within each segment so you respect structure and still get overlap at sub-paragraph boundaries where needed. Keep metadata (e.g. doc_id, chunk_id) so you can collapse or rank by document after retrieval; see the importance of IDs and metadata and re-ranking for workflows.

Frequently Asked Questions

How much overlap should I use?

Common: 10–20% of chunk size (e.g. 50 tokens overlap for 256-token chunks). Too much overlap bloats the index and duplicates; too little may not fix boundary issues. Tune on your corpus.

Can I use semantic boundaries and overlap together?

Yes. For example: split by paragraph or section first, then apply a fixed size with overlap within each segment so you respect structure and still get overlap at sub-paragraph boundaries where needed.

Do overlapping chunks hurt query latency?

More chunks mean more points in the VDB, so index size and potentially latency can increase. ANN search is still sublinear in n, so the effect is usually modest; measure with your data. See measuring latency for metrics.

How do I deduplicate overlapping chunk results?

Keep metadata (e.g. doc_id, chunk_id); after retrieval, collapse or rank by document and return one or a few chunks per doc, or run re-ranking and then dedupe by doc.