Özer Cem KELAHMETKELAHMET
Articles · Chunking

Chunking for RAG explained: fixed, recursive, semantic and late chunking with worked numbers

Chunking decides what a RAG system can find. This guide works through fixed-size, recursive, semantic and late chunking with formulas, a simulation of overlap and fact survival, and runnable Python, then turns the results into defaults you can test.

Download Markdown
At a glance
Reading time
15 min
Sections
7
Code examples
4
Tables
2
Sources
8
Published
24 Nov 2026
In 30 seconds
What changed
LangChain text splitters 1.2.0 released
Why it matters
Chunking is a recall decision dressed as a formatting one.
What to do
Build a recall test before tuning chunks

Every retrieval-augmented generation (RAG) system cuts documents into pieces before it indexes them. Those pieces, called chunks, are the unit the retriever finds and the unit the model reads. If an answer is split across two chunks, or buried in a chunk full of unrelated text, the best embedding model in the world will not rescue it.

Chunking looks like a preprocessing detail, yet it sets a hard limit on recall. This month two widely used libraries shipped new releases that touch this stage, which makes it a good time to go through the methods properly. This article explains fixed-size, recursive, semantic and late chunking, derives the overlap arithmetic, measures how often a fact survives a cut, and ends with defaults you can test on your own data.

A useful analogy: chunking is like cutting a long film into clips for a search engine. Cut too short and a scene loses its meaning. Cut too long and every search returns ten minutes of footage to find one line.

What happened

LangChain text splitters 1.2.0 released (23 November 2026)

The langchain-text-splitters package, home of RecursiveCharacterTextSplitter, published version 1.2.0 on PyPI on 23 November 2026, after 1.1.3 on 2 October. Installed, 1.2.0 still exposes the familiar splitters, including character, token, Markdown header, HTML section, LaTeX, Python code and recursive JSON splitters. The default separator list of the recursive splitter is unchanged: paragraph break, line break, space, then single characters.

LightRAG 1.5.8 ships with selectable chunking strategies (23 November 2026)

LightRAG, an open-source framework that combines a knowledge graph with vector retrieval, released 1.5.8 on PyPI on 23 November 2026. Its README notes that the project added selectable text chunking strategies in May 2026, named Fix, Recursive, Vector, Paragraph and custom. That a framework built around a knowledge graph exposes chunking as a first-class option shows how much it matters even for graph extraction.

Chonkie 1.7.0 lists late, semantic and LLM-guided chunkers (7 July 2026)

Chonkie, a chunking-only Python library, released 1.7.0 on 7 July 2026. Its README lists a token chunker, a SIMD-accelerated fast chunker, sentence, recursive, semantic, late, code, neural and table chunkers, and an LLM-driven "Slumber" chunker. The range is a useful map of the methods this article covers.

The four main methods

Fixed-size chunking

The simplest rule: cut every S tokens, optionally repeating the last O tokens of one chunk at the start of the next. It is fast, predictable and ignores meaning. Sentences and tables are cut wherever the counter lands.

The number of chunks for a document of L tokens is:

n = ceil((L − O) / (S − O)) when L is greater than S, else 1.

The step between chunk starts is S − O, so the storage overhead is about S / (S − O). With S = 512 and O = 64, overhead is 512 / 448 ≈ 1.14 in the limit; for a 10,000-token document it is 23 chunks, 11,776 stored tokens, or 1.18 times the original.

Recursive chunking

Recursive splitting tries the largest natural boundary first and only falls back to smaller ones when a piece is still too big. LangChain's RecursiveCharacterTextSplitter uses the separator list paragraph break, line break, space, empty string. A section that fits stays whole; a long paragraph is split at line breaks, then at spaces. The result respects document structure most of the time at almost no cost, which is why it is the common default.

Structure-aware variants go further: Markdown and HTML header splitters cut at headings and attach the heading path as metadata, and code splitters cut at function and class boundaries.

Semantic chunking

Semantic chunking places boundaries where the topic changes. The usual recipe embeds each sentence, computes the similarity between neighbouring sentences, and splits where similarity drops below a threshold, often a percentile of all the gaps. It produces chunks of uneven size that follow topics, at the cost of one embedding per sentence at index time.

Late chunking

Late chunking, introduced by Günther and colleagues at Jina AI (arXiv 2409.04701), changes the order of operations. Normal pipelines chunk first, then embed each chunk on its own. Late chunking runs the embedding model's transformer over the whole document (or as much as fits, 8,192 tokens for the model used in the original work), then mean-pools the token vectors inside each chunk's span. Each chunk's vector therefore carries context from the rest of the document.

The project README gives a clear example from a Wikipedia article on Berlin. The sentence "Its more than 3.85 million inhabitants make it the European Union's most populous city" scored 0.708 similarity to the query "Berlin" with normal chunking and 0.825 with late chunking, because the pronoun "its" now carries information from the earlier mention of Berlin.

Table 1. Late chunking
Method Boundary rule Index cost Strength Weakness
Fixed-size Every S tokens Lowest Simple, uniform sizes Cuts sentences and tables
Recursive Largest separator that fits Low Respects paragraphs and headings Still blind to topic changes
Semantic Similarity drop between sentences One embedding per sentence Follows topics Uneven sizes, threshold tuning
Late Any boundary, pooled after a full-document pass One long-context pass per document Chunks keep document context Needs a long-context embedding model with token outputs
Contextual (LLM-written prefix) Any boundary plus a generated summary line One LLM call per chunk Strong for ambiguous chunks Highest index cost

The last row is the contextual retrieval approach: an LLM writes a short sentence situating each chunk in its document, and that sentence is prepended before embedding and keyword indexing. Anthropic's contextual embeddings cookbook reports that, averaged across the data sources it tested, contextual embeddings reduced the top-20 retrieval failure rate by 35 percent. The site's contextual RAG simulation and contextual retrieval page walk through it.

How often does a fact survive the cut?

Overlap exists for one reason: so that a fact near a boundary appears whole in at least one chunk. We can compute exactly how much it helps.

Model a fact as a span of f consecutive tokens at a random position. With fixed chunks of S tokens and no overlap, the fact is intact only if it starts at one of the first S − f + 1 positions of a chunk. So:

P(intact, no overlap) = (S − f + 1) / S

With overlap O of at least f tokens, every span of length f fits inside some chunk, so P(intact) = 1.

The script below counts chunks, storage overhead and the survival rate by simulation, for a 10,000-token document and a 60-token fact (about two sentences).

import math, random

def n_chunks(L, S, O):
    return 1 if L <= S else math.ceil((L - O) / (S - O))

def p_span_intact(S, O, f, trials=200_000, seed=0):
    rng, step, hit = random.Random(seed), S - O, 0
    for _ in range(trials):
        start = rng.randrange(0, 100_000)
        end = start + f
        k = start // step
        hit += any(c * step <= start and end <= c * step + S for c in (k - 1, k))
    return hit / trials

L = 10_000
for S, O in [(256, 0), (512, 0), (512, 64), (512, 128), (1024, 128)]:
    n = n_chunks(L, S, O)
    print(f"S={S} O={O} chunks={n} stored={n*S} overhead={n*S/L:.2f}x "
          f"p_intact(f=60)={p_span_intact(S, O, 60):.3f}")
Table 2. How often does a fact survive the cut?
Chunk size S Overlap O Chunks Stored tokens Overhead P(60-token fact intact)
256 0 40 10,240 1.02x 0.769
512 0 20 10,240 1.02x 0.884
512 64 23 11,776 1.18x 1.000
512 128 26 13,312 1.33x 1.000
1,024 128 12 12,288 1.23x 1.000

The simulated values match the formula: (256 − 60 + 1) / 256 = 0.770 and (512 − 60 + 1) / 512 = 0.885. Three lessons follow.

  1. Without overlap, small chunks lose many facts. At 256 tokens, almost one two-sentence fact in four is cut.
  2. Overlap only needs to cover your longest typical fact. Going from 64 to 128 tokens of overlap buys nothing for 60-token facts and costs 15 percent more storage and embedding.
  3. Bigger chunks lose fewer facts but dilute them. A 1,024-token chunk holding one relevant sentence produces an embedding that mostly describes the other 990 tokens, and it costs twice as many prompt tokens when retrieved.

That last point is the core trade-off. Recall at a fixed number of retrieved chunks depends both on whether the fact is intact and on whether the chunk's vector is close enough to the query to rank high. Small chunks give sharp vectors; large chunks give intact facts. Overlap and structure-aware splitting let you have smaller chunks without losing facts. The chunking strategies simulation lets you move these sliders and watch retrieval change.

Semantic and late chunking in code

Semantic chunking can be tested with nothing more than scikit-learn. The example uses TF-IDF vectors as a cheap stand-in for sentence embeddings, then splits at the lowest 20 percent of neighbour similarities.

import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer

sents = [
    "The heat pump moves heat from outside air into the house.",
    "In winter the heat pump still extracts heat from cold outside air.",
    "Its efficiency is measured as the coefficient of performance.",
    "Invoices are sent on the first working day of each month.",
    "Unpaid invoices trigger a reminder after 14 days.",
    "A second reminder adds a late fee to the invoices.",
]
X = TfidfVectorizer(stop_words="english").fit_transform(sents).toarray()
X = X / np.linalg.norm(X, axis=1, keepdims=True)
sim = (X[:-1] * X[1:]).sum(axis=1)
threshold = np.percentile(sim, 20)
chunks, cur = [], [sents[0]]
for s, nxt in zip(sim, sents[1:]):
    if s <= threshold:
        chunks.append(" ".join(cur)); cur = []
    cur.append(nxt)
chunks.append(" ".join(cur))
print(np.round(sim, 3)); print(*chunks, sep="\n")

The neighbour similarities are 0.655, 0.0, 0.0, 0.1 and 0.224. The method correctly separates the heat-pump topic from the invoices topic. But it also cuts off "Its efficiency is measured as the coefficient of performance" into a chunk of its own, because the sentence shares no keywords with its neighbours. A real embedding model would do better than TF-IDF, but the failure is the same in kind: the pronoun "its" has no meaning without the previous sentence. That is exactly the problem late chunking and contextual prefixes were designed to solve.

Late chunking needs a model that returns token-level vectors. The pooling step itself is short:

import numpy as np

def late_chunk(token_vecs, spans):
    """token_vecs: (n_tokens, d) from one pass over the whole document.
    spans: (start, end) token offsets of each chunk."""
    out = np.stack([token_vecs[a:b].mean(axis=0) for a, b in spans])
    return out / np.linalg.norm(out, axis=1, keepdims=True)

You choose the spans with any method above (fixed, recursive or semantic); late chunking only changes how each span's vector is computed. With Sentence Transformers you can get token embeddings by calling model.encode(text, output_value="token_embeddings") on a model whose context window covers the document.

What it means in practice

Chunking is a recall decision dressed as a formatting one. The simulation shows that a careless choice, such as 256-token chunks with no overlap, silently loses close to a quarter of two-sentence facts before retrieval even starts. Modest overlap removes that loss for a 15 to 20 percent storage cost.

Structure beats cleverness for most documents. Manuals, policies, wikis and contracts have headings and paragraphs written by people who already grouped related ideas. Recursive or header-aware splitting captures that grouping almost for free, and the heading path makes an excellent piece of metadata to prepend to each chunk.

Semantic, late and contextual chunking earn their cost where chunks lose meaning out of context: pronoun-heavy prose, transcripts, and documents where key entities appear once at the top. In those cases, prefer late chunking if your embedding model supports long inputs and token outputs, and contextual prefixes if you can afford one cheap LLM call per chunk with prompt caching of the document.

For how chunking fits with the other RAG variants, see the site's guide to RAG types from naive to GraphRAG and the RAG and grounding topic.

The library releases this month do not change the defaults, but they make experiments cheaper: LangChain, LightRAG and Chonkie all expose several strategies behind one switch, so you can test them on your own evaluation set in an afternoon.

What to do now

  1. Build a recall test before tuning chunks. Take 50 to 100 questions with known answer passages and measure recall@5 and recall@10 for each chunking setting; Ragas can score context recall automatically.
  2. Start with recursive splitting at 400 to 600 tokens. It respects paragraphs, and it is the baseline every other method must beat.
  3. Set overlap to cover your longest typical fact. For two-sentence facts, about 60 to 100 tokens is enough; more mostly adds cost.
  4. Split on headings for structured documents. Use Markdown or HTML header splitters and store the heading path with each chunk.
  5. Prepend titles and headings to the text you embed. A chunk that begins "Returns policy > Fees:" is easier to match than the bare paragraph.
  6. Keep tables and code whole. Use a table chunker or code splitter rather than cutting rows and functions at arbitrary token counts.
  7. Try late chunking for pronoun-heavy text. It costs one long pass per document, not one LLM call per chunk.
  8. Use contextual prefixes for the hardest corpora. Cache the full document in the prompt so each per-chunk call pays mostly for cached input.
  9. Re-run your test after every chunking change. Chunk size, overlap and retrieval k interact; tune them together.

Risks and open questions

Benchmarks disagree. Published comparisons of chunking strategies use different corpora, embedding models and metrics, and results do not transfer reliably. Your own evaluation set is the only trustworthy guide.

Semantic chunking can make things worse. Similarity thresholds are sensitive. On text with frequent pronouns or short sentences, the method can isolate sentences that need their neighbours, as the example showed.

Late chunking depends on the model. It needs a long-context embedding model that exposes token vectors and was trained in a way that makes mean pooling meaningful. Not every hosted embedding API returns token vectors.

Contextual prefixes cost money and can drift. One LLM call per chunk is cheap with caching but not free, and generated context can introduce errors that then get embedded.

Re-chunking means re-embedding. Any change to chunk boundaries invalidates every vector in the index. Budget the full re-embedding cost before experimenting in production.

Watch next: whether library defaults move from recursive to structure-plus-context strategies, and whether embedding providers expose token-level outputs widely enough to make late chunking a standard option.

Frequently asked questions

What is a good default chunk size for RAG?

A recursive split at roughly 400 to 600 tokens with 10 to 20 percent overlap is a sound starting point for prose. Treat it as a baseline, not an answer, and measure recall on your own questions before and after any change.

Does chunk overlap really help?

Yes, up to a point. The simulation in this article shows that 64 tokens of overlap raised the chance a 60-token fact stays intact from 0.884 to 1.0 for 512-token chunks. Overlap beyond your longest typical fact adds storage and cost without more benefit.

Is semantic chunking better than recursive chunking?

Not reliably. Semantic chunking follows topic changes, but it adds embedding cost at index time and can split sentences that depend on their neighbours. On well-structured documents, recursive or header-based splitting often performs as well.

What is late chunking in one sentence?

Late chunking embeds the whole document first and then averages the token vectors inside each chunk, so every chunk's vector carries context from the rest of the document. It was introduced by Jina AI researchers in 2024.

Do I need to re-embed everything if I change my chunking?

Yes. New boundaries mean new chunks, and every chunk needs a new vector. Plan chunking experiments on a sample and an evaluation set before re-indexing a full production corpus.

Summary

Chunking sets the ceiling on what a RAG system can retrieve. Fixed-size chunking is simple but cuts facts; the formula P = (S − f + 1) / S shows that 256-token chunks without overlap lose almost a quarter of two-sentence facts, and modest overlap removes that loss for about 18 percent more storage. Recursive and header-aware splitting follow the structure authors already wrote and are the right default. Semantic chunking follows topics but is threshold-sensitive, while late chunking and contextual prefixes give each chunk context from its whole document, at the cost of a long-context pass or an LLM call. This month's releases of LangChain text splitters and LightRAG, and Chonkie's broad set of chunkers, make these strategies easy to switch between, which means the real work is measuring them on your own questions.

Sources

Cite this article

Kelahmet, Ö. C. (2026, November 24). Chunking for RAG explained: fixed, recursive, semantic and late chunking with worked numbers. Özer Cem KELAHMET. https://www.ozercemkelahmet.com/articles/chunking-for-rag-fixed-recursive-semantic-late

BibTeX
@online{kelahmet2026chunking,
  author = {Kelahmet, {\"O}zer Cem},
  title  = {{Chunking for RAG explained: fixed, recursive, semantic and late chunking with worked numbers}},
  year   = {2026},
  month  = {nov},
  url    = {https://www.ozercemkelahmet.com/articles/chunking-for-rag-fixed-recursive-semantic-late}
}
Version historyfirst version
  1. Published

Factual corrections are listed here with what changed. Wording and formatting edits are not listed.

Last updated Nov 24, 2026
Type to search.
    ↑↓ navigate↵ open