Dev tools

RAG Chunking: Strategies, Chunk Size and Overlap

RAG chunking guide: fixed, recursive, semantic, structure-aware and contextual chunking, what chunk size and overlap to start with, and how to test them.

By OmniAI Editorial · Nov 20, 2026 · 11 min read

RAG chunking is the step in retrieval-augmented generation where you split documents into smaller pieces, called chunks, before embedding and indexing them, so the system can retrieve only the passages that answer a question. A good default is to split on the document's structure (headings, paragraphs, sentences) into chunks of roughly 200 to 500 tokens with little or no overlap, then test. Smaller chunks help precise fact lookups; larger chunks or whole pages help questions that need more context. Chunking often affects answer quality as much as the choice of embedding model.

This guide explains why chunking matters, the main chunking strategies for RAG, the recommended chunk size for RAG and how much overlap to use, what research says, and how to test your choice.

Why RAG Chunking Matters

In a RAG system, documents are split into chunks, each chunk is turned into a vector by an embedding model, and the vectors go into a search index. When a user asks a question, the system finds the most similar chunks and passes them to the language model as context. Our guide to what RAG is covers the full pipeline.

Chunking decides what the retriever can find:

  • Too large: a chunk covers several topics, its embedding becomes a blurry average, and it ranks lower for specific questions. It also fills the model's context with irrelevant text and costs more tokens.
  • Too small: a chunk loses the context needed to understand it ("It increased by 12%" without saying what "it" is). Answers then need many chunks, and some get missed.
  • Badly placed boundaries: a split in the middle of a table, list or code block separates facts that only make sense together.

Embedding models also have input limits, often 512 to 8,192 tokens, and anything longer is cut off. Even models with long limits tend to produce better retrieval on focused passages.

The Main Chunking Strategies for RAG

StrategyHow it splitsStrengthsWeaknesses
Fixed-sizeEvery N tokens or charactersSimple, fast, predictableCuts sentences and sections mid-way
RecursiveTries paragraphs, then lines, then sentences, then words, until under NRespects natural breaks; a strong defaultIgnores meaning; needs tuning
Structure-awareBy headings, sections, pages, functions, table rowsKeeps logical units togetherNeeds parsing per format
SemanticStarts a new chunk when meaning shifts (embedding similarity drops)Topic-coherent chunksSlower, costs embeddings, uneven sizes
LLM-basedAsks a model to split or summarise the textCan be very coherentExpensive and slow at scale
Contextual / late chunkingAdds document-level context to each chunk before embeddingFixes "orphan" chunksExtra processing cost
Parent–child (small-to-big)Retrieves small chunks, returns their larger parent sectionPrecise search, full contextMore storage and logic

Fixed-size chunking

Fixed-size chunking cuts the text every N tokens (for example, every 512), usually with some overlap. It's the easiest method and works acceptably on uniform prose, but it ignores sentences, paragraphs and tables. Use it as a baseline to compare other methods against.

Recursive chunking

Recursive chunking, popularised by LangChain's RecursiveCharacterTextSplitter, tries to split on the largest natural separator first (blank lines between paragraphs), and only falls back to smaller ones (line breaks, sentences, spaces) when a piece is still too big. Chunks end up close to the target size while mostly respecting paragraph and sentence boundaries. For many teams it's the best starting point.

from langchain_text_splitters import RecursiveCharacterTextSplitter

splitter = RecursiveCharacterTextSplitter.from_tiktoken_encoder(
    chunk_size=400,   # tokens
    chunk_overlap=0,
)
chunks = splitter.split_text(document_text)

Structure-aware chunking

Structure-aware chunking uses the document's own layout:

  • Markdown and HTML: split on headings, and keep the heading path ("Pricing > Enterprise > Discounts") with each chunk.
  • PDFs: split by page or section, after a good parser has extracted headings, lists and tables.
  • Code: split by function or class, using a syntax-aware splitter.
  • Tables and spreadsheets: keep header rows with every group of rows, or turn each row into a short sentence.
  • Chats, tickets and emails: one message, thread or ticket per chunk, with metadata such as date and author.

For well-structured documents this often beats any token-based method, because a section written by a human is already a coherent unit.

On the left, a light page of ink lines cut into four equal parts by dashed ink lines; a dotted divider; on the right, a light page divided into three uneven grey blocks, the middle one larger and orange.
Fixed-size chunking cuts at equal intervals; semantic and structure-aware chunking cut where the topic changes.

Semantic chunking

Semantic chunking embeds each sentence (or small group of sentences), compares neighbours, and starts a new chunk where the similarity drops, meaning the topic has changed. The result is chunks that each cover one idea, but in uneven sizes.

Is semantic chunking worth it? It costs an embedding call per sentence at indexing time and adds a threshold to tune. On clean, well-structured documents, recursive or structure-aware splitting often performs about as well. Semantic chunking helps most on long, unstructured text such as transcripts, where there are no headings to split on.

Contextual chunking

A chunk taken out of its document can be ambiguous. Contextual approaches fix that:

  • Contextual retrieval: Anthropic's method uses a language model to write a short note explaining where each chunk sits in its document ("This chunk is from ACME's Q2 report; revenue figures are for the EMEA region") and prepends it before embedding and keyword indexing. In Anthropic's tests, contextual embeddings cut the top-20 retrieval failure rate by 35%; combined with contextual BM25 keyword search, by 49%; and with reranking added, by 67%.
  • Late chunking: embed the whole document with a long-context embedding model first, then split the token embeddings into chunks, so each chunk's vector carries information from its surroundings.
  • Metadata: simply attaching the document title, section heading and date to each chunk often recovers much of the lost context at no cost.

Parent–child retrieval

Index small chunks (say 100–200 tokens) for precise matching, but when one matches, send the model its parent section (1,000–2,000 tokens) or neighbouring chunks. You get the precision of small chunks and the context of large ones. Most RAG frameworks support this as "parent document" or "small-to-big" retrieval.

There's no universal best size; it depends on your documents, your questions and your embedding model. Two published evaluations give useful starting points:

  • Chroma's chunking evaluation found that the simple recursive splitter with chunks of about 200 tokens and no overlap performed consistently well across its metrics, even if not best on every one. It also found that the default OpenAI used for file search at the time of the study, 800-token chunks with 400 tokens of overlap, scored poorly on most of its metrics.
  • NVIDIA's tests on several document sets found that page-level chunking had the highest average accuracy and the most consistent results. Among token sizes, medium chunks (512 to 1,024 tokens) beat both very small (128) and very large (2,048) ones, and factoid questions favoured 256 to 512 tokens, while analytical questions favoured larger chunks or whole pages.

A practical recommended chunk size for RAG, then:

Content and questionsStarting chunk size
FAQs, short facts, support articles128–256 tokens, or one Q&A per chunk
General documentation and web pages256–512 tokens, split by section
Reports, contracts, research papers512–1,024 tokens, or by page/section
Analytical questions across long documentsPage-level or parent–child
CodeOne function or class per chunk

RAG Chunk Size and Overlap

Overlap repeats the end of one chunk at the start of the next, so a sentence near a boundary appears in both. It helps when splits fall mid-thought, mainly with fixed-size chunking.

For RAG chunk size and overlap together:

  • With fixed-size chunks, 10–20% overlap is common. NVIDIA tested 10%, 15% and 20% on 1,024-token chunks and found 15% worked best for its dataset.
  • With recursive or structure-aware chunks, start with no overlap; boundaries already fall at natural breaks. Chroma found that reducing overlap improved its efficiency measure, because overlap adds duplicated text.
  • Overlap has costs: more chunks to embed and store, and duplicate passages in the retrieved results that waste context. If you use it, deduplicate results before sending them to the model.
Three grey and light chunk blocks in a row, each overlapping the next; the overlap between the first two is orange, with ink lines running across the shared section.
Overlap repeats the edge of each chunk in the next one, so text near a boundary isn't lost.

How to Choose a Chunking Strategy

  1. Parse well first. Bad PDF extraction (merged columns, broken tables, headers in the middle of text) ruins any chunking method. Use a parser that keeps headings, lists and tables.
  2. Start with structure-aware or recursive chunking at 256–512 tokens, no overlap, with title and heading metadata on every chunk.
  3. Build a small test set: 50–100 real questions with the passages that answer them.
  4. Measure retrieval, not just answers: does the right passage appear in the top 5 or top 10 results (recall)? How much of what's retrieved is relevant (precision)?
  5. Try one change at a time: a smaller and larger size, semantic chunking, contextual headers, parent–child retrieval.
  6. Add hybrid search and reranking before over-tuning chunks. Keyword search catches exact terms, and a reranking model reorders the top results; together they often fix more than chunk tuning.
  7. Re-test when documents or models change. A new embedding model can shift the best size.

Chunking by Document Type

  • PDF reports: split by section or page; keep tables whole and repeat the table caption; include page numbers in metadata for citations.
  • Legal documents and contracts: split by clause or section number; keep definitions in their own chunks and consider adding referenced definitions as context.
  • Product docs and knowledge bases: split by heading; keep the breadcrumb path; one procedure per chunk where possible.
  • Transcripts and meeting notes: semantic chunking or fixed time windows with speaker names and timestamps.
  • Code repositories: syntax-aware splitting by function or class, with file path and imports as metadata.
  • Spreadsheets: turn rows into sentences or keep header rows with each group; for numeric questions, consider querying the data directly instead of embedding it.
  • Multimodal documents: describe images and charts in text (with a vision model) and chunk the description with the surrounding section.

Common RAG Chunking Mistakes

  • Using a framework's default without testing. Defaults are compromises, and Chroma's study found some popular defaults performed relatively poorly.
  • Splitting tables and lists across chunks, so neither half makes sense.
  • Dropping context: chunks without titles, headings or dates.
  • Very large overlap, which multiplies storage and fills results with duplicates.
  • Tuning chunk size to fix a parsing problem. Fix the parser first.
  • Ignoring the embedding model's limit, so long chunks are silently cut off.
  • Judging only by final answers. Measure whether the right chunks are retrieved; a strong model can hide poor retrieval until it can't.

Do Long Context Windows Make Chunking Obsolete?

Not for most systems. Models with million-token context windows can read whole documents, but sending everything on every question is slow and expensive, and models still answer more reliably when the relevant passages come first and irrelevant text is kept out. Long context does make chunking more forgiving: you can retrieve bigger chunks or whole pages and let the model find the answer. For a few documents, simply putting them in the prompt (with prompt caching) can beat RAG; for thousands, chunking and retrieval are still needed.

FAQ

What is chunking in RAG?

Chunking in RAG is splitting documents into smaller passages before embedding and indexing them. At query time, the system retrieves the most relevant chunks and gives them to the language model as context, so chunk size and boundaries decide what the model can see.

What is the best chunk size for RAG?

There's no single best size. A common starting point is 256 to 512 tokens split along the document's structure. Short factual questions tend to work best with smaller chunks; analytical questions across long documents work better with larger chunks or whole pages. Test on your own questions.

How much chunk overlap should I use?

With fixed-size chunks, 10–20% overlap is common. With recursive or structure-aware chunking, start with no overlap, because boundaries already fall at natural breaks and overlap adds duplicate text.

What is semantic chunking?

Semantic chunking splits text where the meaning changes, by embedding sentences and starting a new chunk when neighbouring sentences become less similar. It produces topic-focused chunks but costs more to compute, and often helps most on unstructured text such as transcripts.

Does chunking affect RAG accuracy?

Yes, often a lot. Poor chunking can split answers across chunks, blur embeddings with mixed topics, or strip away context. Changing the chunking strategy, adding context to chunks and adding reranking are among the most effective ways to improve RAG accuracy.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog