Last updated: Aug 21, 2026

Chunking Strategies for Production RAG

Dan Lee, JoinAI Founder · AI Tech Lead

JoinAI Founder · AI Tech Lead

Aug 21, 20264 min read
Chunking Strategies for Production RAG

There is no best chunk size for RAG. A 400-token chunk can preserve a support article and destroy a table, a contract clause, or a function definition.

Choose boundaries from the structure of the source and the questions users ask. Then measure whether the retrieved unit contains enough evidence to answer without dragging unrelated text into the prompt.

Define the job of a chunk

A chunk serves two different systems:

  1. The retriever needs a focused representation that matches a query.
  2. The generator needs enough context to interpret the matched passage.

One unit rarely optimizes both. That is why parent-child retrieval is useful: embed and match a small child passage, then return its larger parent section to the model.

Before tuning chunk size, establish the retrieval metrics in RAG Evaluation: Metrics for Retrieval and Answer Quality. Otherwise “the answers feel better” becomes the experiment.

Start with document structure

SourceFirst boundary to tryPreserve with every chunk
Product docsheading sectionpage title, heading path, version
Contractsclause or numbered subsectionagreement, parties, effective date
Support ticketsmessage or short exchangeticket ID, author role, timestamp
Source codefunction, class, or symbolfile path, language, symbol name
Tablescomplete table or row group with headerstitle, headers, units
Transcriptsspeaker turn windowspeakers and time range

Do not flatten the document to plain text and hope a recursive character splitter reconstructs its meaning. Parse headings, lists, tables, code fences, and page metadata before splitting.

Use size as a constraint, not the strategy

Token limits still matter. Embedding models accept bounded inputs, and huge chunks produce diluted representations. But a token target should decide when a structural unit must be subdivided—not where every document is cut.

A workable starting experiment is:

Text
A: structural sections, capped at 300 tokens
B: structural sections, capped at 600 tokens
C: 250-token children retrieving 800-token parents

Run the same query set against all three. Compare recall@K, context precision, and answer correctness. Segment results by question type; definitions and multi-step procedures often prefer different units.

Overlap fixes one problem and creates another

Overlap helps when a fact crosses an arbitrary boundary. It also duplicates evidence, inflates the index, and can fill the top results with near-identical passages.

Prefer semantic continuity first:

  • repeat the heading path in metadata or chunk text;
  • keep list introductions with their items;
  • keep table headers with every row group;
  • attach definitions to the section that uses them;
  • use adjacent-chunk expansion after retrieval.

Add fixed overlap only where boundary tests show missed evidence. Measure duplicate-result rate alongside recall.

Store provenance that survives retrieval

Every chunk should carry enough metadata to explain and filter it:

JSON
{
"chunk_id": "policy-v7:4.2:01",
"document_id": "access-policy",
"document_version": 7,
"heading_path": ["Contractors", "Production access"],
"tenant_id": "acme",
"effective_at": "2026-07-01",
"source_uri": "/policies/access#contractors"
}

Versioning matters. If old and new policy chunks coexist without freshness rules, excellent semantic retrieval can return the wrong policy confidently.

Build a boundary test set

Include questions whose answers sit:

  • at the start and end of sections;
  • across two adjacent sections;
  • inside a table with units in the header;
  • in a list whose meaning depends on its introduction;
  • under duplicate headings on different pages;
  • in a newer version that contradicts an older one.

Also include no-answer questions. Large chunks sometimes make an unrelated passage look plausible enough for the generator to answer anyway.

Diagnose chunking failures

SymptomLikely causeFirst experiment
Right page, missing factchunk too narrowparent expansion
Many vaguely relevant resultschunk too broadsmaller structural children
Repeated near-duplicatesexcessive overlapreduce overlap, diversify results
Table answers lose unitsparser destroyed structuretable-aware representation
Exact IDs never matchretrieval mode, not chunkingadd keyword or hybrid search
Old answer winsmissing version metadatafilter or freshness boost

The exact-ID failure belongs to retrieval. Hybrid Search vs Vector Search for RAG explains why changing chunk size will not fix every miss.

Chunking experiment checklist

  • Split on source structure before applying token caps.
  • Preserve heading, version, tenant, and source metadata.
  • Compare at least three chunking configurations on one fixed dataset.
  • Measure retrieval and answer quality separately.
  • Track duplicate-result rate when using overlap.
  • Test tables, lists, code, version conflicts, and boundary-spanning answers.
  • Re-index into a versioned index so rollback is possible.

Sources

Build better AI systems

One practical engineering lesson in your inbox each week.

JoinAI Premium

Go from reading to shipping

Get guided learning, hands-on AI engineering projects, and premium practice.

Explore Premium
Dan Lee, JoinAI Founder · AI Tech Lead

About the author

JoinAI Founder · AI Tech Lead

Dan Lee is the founder of JoinAI and an AI tech lead with more than 10 years of industry experience across data engineering, machine learning, and applied AI. He previously worked as an engineer at Google.