Zenaique
Compare

Chunking strategies: fixed vs semantic vs recursive

Three ways to slice documents before they hit the vector store

The verdict

Fixed-size chunking is simple; semantic chunks at meaning boundaries; recursive respects the document's own structure. Recursive is the modern default for anything hierarchical (headings, code).

Fixed-size

Glossary

Cut every N tokens (often 256 to 1024) with a small overlap. Fast to implement, format-agnostic, and predictable. Ignores meaning and structure.

Best for: Prototyping and format-agnostic pipelines.

Semantic

Glossary

Split at topic or sentence-similarity boundaries. Adjacent sentences with a big embedding drop become a chunk break. Chunks stay topically coherent; length varies.

Best for: Long-form prose where topics drift naturally.

Recursive

Glossary

Split by the document's own hierarchy: sections, then paragraphs, then sentences, only descending when a chunk is too large. Preserves headings, code fences, and markdown structure.

Best for: Structured docs, markdown, code, technical writing.

At a glance

Chunking strategies: fixed vs semantic vs recursive: dimension-by-dimension comparison
DimensionFixed-sizeSemanticRecursive
How chunks formEvery N tokensEmbedding-similarity gapsBy hierarchy, then N tokens
Boundary respectNoneTopic changesSection / paragraph / sentence
Embedding qualityMedium (mid-topic chunks hurt)High (coherent chunks)High (structure preserved)
Compute cost to chunkCheapestExtra embedding passDocument parse plus split
Common size512 tokens with 50-token overlapVariable (150 to 900)Bounded (256 to 1024)
Best forPrototyping, mixed formatsLong-form proseMarkdown, code, structured docs

Key differences

  • 1Fixed-size ignores structure; semantic follows meaning; recursive follows the document's own layout
  • 2Fixed-size is trivial to run at scale; semantic needs an extra embedding pass; recursive needs a document parser
  • 3Recursive keeps headings with their body text; fixed-size cuts through them; semantic is somewhere in between
  • 4Semantic chunks vary in length; fixed and recursive can be bounded
  • 5Recursive is the modern default in LangChain / LlamaIndex for markdown, code, and structured docs

In the interview

What they're really testing
Whether you know chunking design dominates RAG quality and can pick the strategy from the document shape.
Say this
Fixed-size is the baseline: cheap, format-agnostic, but it cuts through headings and mid-topic. Semantic chunks at topic boundaries by finding embedding-similarity drops, so chunks stay coherent but their length varies. Recursive splits by the document's own hierarchy (sections, paragraphs, sentences), descending only when a chunk is still too large. On markdown, code, and any structured content I default to recursive because it keeps headings attached to their body text and preserves code fences. Semantic is my pick for long-form prose without visible structure.
Traps to sidestep
  • Claiming bigger chunks always help recall
  • Ignoring that mid-topic breaks hurt embedding quality
  • Recommending fixed-size for markdown or code
  • Missing that semantic chunk lengths vary and must be bounded

How to choose

If prototyping or mixed document formatsFixed-size
If long-form prose without strong structureSemantic
If markdown, code, or hierarchical docsRecursive
If you need bounded chunk lengths for downstream costRecursive

Prototype → fixed-size. Long prose → semantic. Structured docs → recursive.

Common misconceptions

Myth: Bigger chunks improve recall.

Reality: Embedding quality degrades past around 512 tokens because the vector averages multiple topics. Recall recovers when chunks stay coherent, not when they grow.

Myth: Recursive is just fixed-size with a fancier splitter.

Reality: It respects the document's headings, code fences, and paragraph boundaries, so chunks correspond to real semantic units instead of arbitrary spans.

Memory aid

Fixed = cut every N pages. Semantic = cut when the topic changes. Recursive = cut respecting the book's chapters and sections.

Can you combine them?

In production stacks these are pipeline stages, not either-or. You can recursively split by structure and then apply a fixed-size cap to bound cost, or run semantic splitting inside a recursive step for very long sections.

Related topics

Related comparisons