RAG Chunking Strategies That Improve Retrieval Quality

RAG Chunking Strategies That Improve Retrieval Quality

What happens when you feed a retrieval system a 40-page PDF and ask it a simple question? Often, nothing useful. The right answer may be sitting in the document, but the system can’t find it because the text was chopped into pieces at the wrong places. That’s the quiet problem in most RAG pipelines: before a model can retrieve anything, someone has to decide how to cut the source material into chunks. Get that decision wrong, and no amount of prompt engineering will save you.

Retrieval-augmented generation (RAG) pairs a search step with a language model, so the model answers from retrieved passages instead of memory alone. The approach was named and popularized in the 2020 paper Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, which combined a dense retriever with a generator over Wikipedia. Notably, that paper said almost nothing about how to split documents. Chunking practice grew up later, mostly in engineering blogs and tooling, which is why so much of the advice floating around is rule of thumb rather than measured fact.

Why chunking decides whether RAG works at all

A chunk is the unit that gets embedded, indexed, and later handed to the model. That single fact creates a tension. The embedding of a chunk is a compressed summary of everything inside it, so a chunk covering five different topics produces a muddy vector that matches nothing well. But a chunk that’s too small loses the context a reader needs to make sense of it.

The practical consequence: chunking sits upstream of everything else. A 2024 case-study paper, Seven Failure Points When Engineering a Retrieval Augmented Generation System, lists chunking among the recurring failure modes teams hit in real deployments. It is a case-study paper rather than a controlled benchmark, but the pattern it describes matches what practitioners report: retrieval misses caused by badly bounded passages are hard to diagnose because the system looks like it’s working. (Retrieval-augmented generation (Wikipedia))

Fixed-size chunking with overlap: the reliable baseline

Fixed-size chunking with overlap: the reliable baseline

The simplest approach splits text into windows of a fixed number of tokens or characters, with consecutive windows sharing an overlap so that a sentence cut at a boundary still appears whole somewhere.

Setting Typical starting point What it controls
Chunk size 256–512 tokens Precision versus context
Overlap 10–20% of chunk size Continuity across boundaries
Split unit Tokens or characters Predictability of index size

Those numbers are widely repeated heuristics, not measured optima. Nobody has published a controlled study showing 512 tokens beats 384 across domains. Still, fixed-size chunking has real virtues: it’s fast, deterministic, cheap, and easy to reason about when you’re debugging. It’s the right first thing to build, precisely because it gives you a baseline to beat.

The common mistake here is skipping the overlap because it inflates index size. Without overlap, a definition that straddles two chunks becomes two half-definitions, and neither one retrieves well.

Recursive character splitting: the default most teams should start with

Recursive character splitting tries a hierarchy of separators in order. It splits on paragraph breaks first, then line breaks, then sentence endings, then spaces, and only falls back to a hard character cut when nothing else works. The goal is to keep natural units intact while still hitting the target size.

This is the default behavior of LangChain’s `RecursiveCharacterTextSplitter`, and the framework’s documentation treats it as the recommended starting point for generic text. In practice it outperforms naive fixed-size splitting on prose because it respects paragraph structure without needing any parsing machinery.

Two practical notes from working with it. First, the separator list matters more than people expect: add domain-specific separators (a transcript’s speaker turns, a legal document’s numbered clauses) and quality jumps immediately. Second, recursive splitting does nothing for tables or code. A markdown table split down the middle becomes garbage in both halves.

Structure-aware chunking: let the document tell you where to cut

Structure-aware chunking uses the document’s own markup instead of raw length: headings, sections, list boundaries, tables, code blocks. For HTML and Markdown, this keeps a heading attached to the body text it introduces, which matters because a section heading is often the strongest signal of what the passage is about.

For PDFs, structure-aware splitting depends on layout-aware parsing that recovers reading order and table structure. Without that prerequisite, you’re splitting on extracted text whose line breaks mean nothing, and the results are worse than plain fixed-size splitting. If your corpus is PDF-heavy, invest in parsing before you invest in chunking cleverness.

The trade-off is uneven chunk sizes. A section might be 80 tokens or 2,000. That’s usually acceptable, but it means you can’t assume a fixed index footprint.

Small-to-big retrieval: index small, return large

This is one of the most useful ideas in the field, and it resolves the precision-versus-context tension directly. Small-to-big (also called parent-document retrieval) decouples the unit that gets embedded from the unit that gets returned.

The mechanics are simple:

  • Split the document into large parent sections.

  • Split each parent into small child chunks.

  • Embed and index the children, storing a pointer to the parent.

  • At query time, match against children for precision, then pass the full parent to the generator.

The small child gives a sharp embedding that matches specific queries. The large parent gives the model enough surrounding text to answer correctly. LangChain documents this pattern as the Parent Document Retriever, and LlamaIndex offers equivalent small-to-big and auto-merging retrievers.

Sentence-window retrieval is a close cousin. Each sentence is embedded on its own, and retrieval returns that sentence plus a window of neighboring sentences. It’s excellent for factoid questions in dense prose and awkward for anything where the answer spans a long argument.

Semantic chunking: promising, oversold

Semantic chunking splits where the embedding similarity between consecutive sentences drops sharply. The intuition is appealing: topic shifts become boundaries. Implementations exist in both major frameworks, as LangChain’s `SemanticChunker` and LlamaIndex’s `SemanticSplitterNodeParser`.

Here’s the honest caveat. There is no peer-reviewed benchmark showing semantic chunking beats well-tuned fixed-size chunking in general. Claims that it does tend to come from vendor posts and blog experiments with small, friendly datasets. Semantic chunking also costs an embedding call per sentence at index time, which is a real budget line at scale.

A balanced position: try it on a sample of your own corpus, measure it, and keep it only if it wins. Don’t adopt it because a chart on the internet looked good.

Metadata and contextual prefixes: cheap wins people skip

One of the highest-leverage improvements costs almost nothing: prepend context to each chunk before embedding. Instead of embedding a bare paragraph, embed something like “Annual report 2025, section 4: supply chain risk” followed by the paragraph.

Anthropic’s contextual retrieval write-up reports meaningful reductions in retrieval failure when contextual prefixes were added. Those numbers come from the company’s own evaluation and haven’t been independently replicated, so treat them as directional rather than definitive. The underlying logic is sound regardless: a chunk that knows where it came from is easier to match and easier to filter.

Store metadata alongside every chunk, too. Source document, section path, date, author, access level. Metadata enables filtered search (“only documents from 2024”) and gives you a debugging trail when retrieval goes wrong. Teams that skip this step usually regret it around month three.

Choosing a strategy: a decision table

Situation Start with Why
Generic prose, first build Recursive character splitting Respects paragraphs, no parsing needed
Long reports needing precise answers Small-to-big Sharp matching, full context returned
Heavily structured docs (HTML, Markdown) Structure-aware Headings stay with their content
Dense factual text, short queries Sentence-window Tight matching, local context restored
Mixed-topic transcripts Semantic chunking (tested) Boundaries follow topic shifts
Tables and code Structure-aware, never split mid-block Split blocks become unusable

How to evaluate before you commit

Pick your chunking strategy with measurement, not intuition. Build a small evaluation set of 30 to 50 real questions with known correct passages. Then compare configurations on recall@k (did the right passage appear in the top k results?) and nDCG (were the good results ranked highly?). The BEIR benchmark paper, BEIR: A Heterogeneous Benchmark for Zero-shot Evaluation of Information Retrieval Models, is a useful reference for how retrieval evaluation is structured, though it evaluates retrieval models on fixed corpora rather than chunking policies, so treat it as background rather than a direct test.

For broader context on how these pipelines get deployed and maintained, the news and cloud sections of 9481.org cover infrastructure trends, and the blog has related engineering write-ups worth skimming. (Cloud)

Practical advice that saves time: change one variable at a time. Teams routinely change chunk size, overlap, embedding model, and reranker simultaneously, then can’t tell which change helped. Run a grid of chunk sizes (256, 512, 1024) with fixed overlap first, lock the winner, then tune overlap.

Common mistakes that quietly break retrieval

Splitting tables and code blocks mid-structure is the single most damaging error. A half-table is not a smaller table; it’s noise.

Ignoring the embedding model’s token limit is another. Chunks longer than the model’s maximum get silently truncated, so the tail of every chunk is invisible to search. Check the limit before you pick a size.

Chunking before cleaning is a third. Navigation menus, footers, and boilerplate end up embedded as content and pollute results. Clean first, chunk second.

Finally, treating chunking as a one-time decision. Corpora drift. A strategy tuned on product documentation may fail on support tickets added six months later. Schedule a re-evaluation.

Conclusion

There is no universally best chunking strategy, and anyone who claims otherwise is selling something. What works is a sequence: start with recursive character splitting to get a baseline, add contextual prefixes and metadata because they’re cheap and effective, move to small-to-big retrieval when precision and context start fighting each other, and reach for semantic chunking only after you’ve measured it on your own data. The overlap percentages and token counts circulating online are starting points, not answers. Your corpus, your queries, and your evaluation set are the only authorities that matter. Build the measurement loop early, and chunking stops being guesswork.

Frequently Asked Questions

What is the best chunk size for RAG?

There is no single best size, but 256 to 512 tokens is a reasonable starting range for most prose. Smaller chunks match queries more precisely but lose surrounding context; larger chunks preserve context but dilute the embedding and consume more of the model’s context window. Test a few sizes against your own evaluation questions before settling.

Should chunks overlap, and by how much?

Overlap helps because it keeps sentences that straddle a boundary intact in at least one chunk. A 10 to 20 percent overlap is a common rule of thumb, though it’s a heuristic rather than a measured optimum. Overlap increases index size and cost, so it’s worth testing whether it actually improves your recall numbers.

Is semantic chunking better than fixed-size chunking?

Not proven. Semantic chunking splits where embedding similarity between sentences drops, which sounds smarter, but no peer-reviewed benchmark shows it reliably beats well-tuned fixed-size or recursive splitting. It also adds an embedding call per sentence at index time. Test it on your corpus and keep it only if it wins.

What is small-to-big retrieval in RAG?

Small-to-big retrieval indexes small child chunks for precise matching but returns the larger parent section to the generator. This separates the unit used for search from the unit used for answering, so you get sharp retrieval and enough context for a correct answer at the same time.

How do I evaluate a chunking strategy?

Build a set of 30 to 50 real questions paired with the passages that answer them. Then compare configurations using recall@k, which checks whether the right passage appeared in the top results, and nDCG, which checks ranking quality. Change one variable at a time so you know which change caused the difference.

Do I need to re-chunk my documents later?

Usually yes. Corpora change, and a strategy tuned on one document type can degrade when new content arrives. Metadata and a stored evaluation set make re-tuning fast. Treat chunking as a configuration you maintain, not a decision you make once.

Latest articles

Scroll to Top