New Tool Radar

AI Concepts

How to Chunk Documents Into Fixed-Size Pieces With Overlap for RAG

Split documents into fixed-size chunks with overlap so no sentence is lost at a boundary.

Schematic with three steps: Pick a size and an overlap; Split the text and check the boundaries; Attach metadata to every chunk.

Raw document text should not be embedded as one massive block. Split it into chunks: self-contained text segments that still represent a coherent thought. Fixed-size chunking with overlap is the simplest approach: a starting point is to split about every 512 tokens with a 10 percent (around 50-token) overlap, so a sentence that sits on a boundary is not cut in half and lost to both sides.

What you need

  • Clean plain text extracted from your documents
  • A token counter or an agreed chunk size in tokens
  • A note of the chunk size and overlap you chose

Step 1: Pick a size and an overlap

A range of roughly 250 to 500 tokens with a 10 percent sliding overlap is a reasonable place to start for technical documentation. Very small chunks often lack enough context, and very large chunks dilute the similarity signal.

Step 2: Split the text and check the boundaries

Split the text at the chosen size, keeping the overlap between neighbours. Read the first and last sentence of a few chunks and confirm no sentence is cut in half.

Step 3: Attach metadata to every chunk

Record document_id, source_url, section_heading and chunk_index on each chunk. Those fields let a later query restrict results to one document or section.

Worked example: synthetic chunk plan for a 2,000-token manual

The table below is a synthetic example. It shows the expected result of chunking a manual; no document was chunked.

Setting Value Result
Chunk size 500 tokens 4 chunks
Overlap 50 tokens No sentence cut at a boundary
Smallest chunk risk 50 words Too little context – avoided
Largest chunk risk 2,000 words Signal diluted – avoided

Expected result (UNTESTED). the manual splits into 4 chunks of about 500 tokens with 50-token overlap, and no sentence is cut at a boundary. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Fixed-size chunking can still split a paragraph mid-thought; structure-aware chunking keeps headings with their text.
  • Chunk size barely mattered in one published 156-query benchmark, so adjust from your own evaluation, not from a fixed rule.
  • Overlap costs storage and embedding calls; 10 percent is a starting point, not a rule.
  • Chunking applies to text the pipeline can already extract cleanly; scanned images need layout-aware parsing first.

Sources

See all