Sentence-Aligned Chunks Beat 20% Overlap: 100,453 Tokens
Overlap is set as a percentage of chunk size, so its real reach is 51 or 102 tokens, and the sentences it fails on are the longest ones.
📜 Table of Contents
📖 Keep reading
Cut a document into 512-token chunks with no overlap and 84 of RFC 9110's 1,416 sentences never appear whole in any chunk. That is 5.9% of the sentences and 11.7% of the document's tokens sitting across a boundary. Turn on 20% overlap and the count falls to 2 sentences, at the price of re-embedding 24.7% more text. Pack whole sentences into chunks instead and the count is 0, for 0% extra tokens.
Same three documents, same tokenizer, same day, three configurations. The part worth reading is why the overlap fix behaves the way it does: it is a length problem wearing a percentage costume.
What was measured
- RFC 9110, HTTP Semantics, plain text from rfc-editor.org: 502,902 characters, 44,247 tokens, 1,416 sentences.
- The Python 3 documentation page for asyncio tasks, HTML stripped to text: 47,952 characters, 10,675 tokens, 480 sentences.
- Pride and Prejudice, chapters 1 to 6, from Standard Ebooks: 692,611 characters, 45,531 tokens, 1,655 sentences.
All three fetched on 2026-11-25, 100,453 tokens in total. Tokens counted with tiktoken's cl100k_base. Sentences split on a period, exclamation mark or question mark followed by whitespace, which is crude, and the cost section below puts a number on how crude.
Every sentence is tokenized on its own, then the sentences are laid end to end so each one owns a token range. A chunk is a window over that range. A sentence is broken when no single chunk contains all of it, which is the failure a retriever cannot fix later: half a clause embeds badly and the other half is never retrieved with it.
| corpus | sentences | mean tokens | p90 | p99 | longest |
|---|---|---|---|---|---|
| RFC 9110 | 1,416 | 31.2 | 58 | 117 | 452 |
| Python docs, asyncio tasks | 480 | 22.2 | 40 | 90 | 193 |
| Pride and Prejudice, ch. 1-6 | 1,655 | 27.5 | 57 | 111 | 220 |
Fixed windows at 512 tokens
| overlap | chunks | tokens embedded | vs no overlap | sentences never whole | share of tokens |
|---|---|---|---|---|---|
| 0% | 87 | 44,247 | 0% | 84 (5.9%) | 11.7% |
| 10% | 96 | 49,092 | +10.9% | 16 (1.1%) | 5.4% |
| 20% | 108 | 55,161 | +24.7% | 2 (0.1%) | 1.9% |
| sentences packed, no overlap | 92 | 44,247 | 0% | 0 (0.0%) | 0.0% |
RFC 9110 is the hardest of the three for a splitter: long normative sentences, tables, lists of HTTP field names. The other two behave the same way at smaller scale.
| corpus | 0% overlap | 10% | 20% | packed |
|---|---|---|---|---|
| RFC 9110 | 84 (5.9%) | 16 (1.1%) | 2 (0.1%) | 0 |
| Python docs | 18 (3.8%) | 0 | 0 | 0 |
| Pride and Prejudice | 83 (5.0%) | 7 (0.4%) | 3 (0.2%) | 0 |
Overlap is a length, not a percentage
20% of 512 tokens is 102 tokens of overlap. RFC 9110's 99th percentile sentence is 117 tokens, so the longest sentences are longer than the overlap itself and can never be captured by stitching two chunks together. Two sentences are still broken at 20%, and both sit past that line.
Raise the chunk size to 1,024 and 20% becomes 204 tokens of overlap, which clears the 117-token p99, and the count goes to zero. Nothing about the percentage changed. The overlap crossed the sentence length distribution.
The same arithmetic explains the other two corpora. Pride and Prejudice has a p99 of 111 tokens, just above 102, and leaves 3 sentences broken at 512/20%. Python's documentation has a p99 of 90 tokens, below 102, and is fully clean at 512/10%.
So the number to set is not 20%. It is your corpus's p99 sentence length, in tokens, and it stays put when you change chunk size.
Same bill, different result
| chunk size | overlap at 20% | chunks | extra tokens | sentences never whole, RFC 9110 |
|---|---|---|---|---|
| 256 | 51 tokens | 216 | +24.8% | 25 (1.8%) |
| 512 | 102 tokens | 108 | +24.7% | 2 (0.1%) |
| 1,024 | 204 tokens | 54 | +24.6% | 0 |
Three settings, the same 24.7% surcharge on the embedding bill, and 25 broken sentences against zero. The 256-token row is the trap: 20% sounds like a bigger relative safety margin on small chunks, and it is 51 absolute tokens, which does not clear a 117-token sentence.
Packing sentences: zero broken, zero extra tokens
The alternative is to stop cutting inside sentences at all. Accumulate whole sentences until the next one would overflow the target, start a new chunk, repeat. Chunk sizes stay at or under the target, nothing is duplicated, and every sentence lives in exactly one chunk.
| corpus | chunks | tokens embedded | extra | broken | average chunk | largest chunk |
|---|---|---|---|---|---|---|
| RFC 9110 | 92 | 44,247 | 0% | 0 | 480.9 | 512 |
| Python docs | 22 | 10,675 | 0% | 0 | 485.2 | 512 |
| Pride and Prejudice | 94 | 45,531 | 0% | 0 | 484.4 | 512 |
Against 512 tokens with 20% overlap: RFC 9110 drops from 108 chunks and 55,161 tokens to 92 chunks and 44,247 tokens. That is 10,914 tokens, 19.8% of the embedding job, for a better result on the metric the overlap was supposed to fix. Pride and Prejudice saves 11,220 tokens, Python 2,550.
The chunk count moves the other way: 92 rows against 87 at zero overlap, 5.7% more, because the sentence that would have overflowed starts the next chunk and leaves slack at the end.
What packing costs
- Uneven chunks. At a 512 target the average is 481 and the largest 512, which is fine. At a 256 target RFC 9110's longest sentence is 452 tokens, so one chunk is 452, 77% over target. If your model caps at 256 tokens, that chunk is truncated by the model rather than by your splitter, and the sentence is broken again with no overlap to rescue it.
- More rows in the index: +5.7% on RFC 9110, +4.8% on the Python page, +5.6% on the novel.
- Splitter quality becomes the whole game. The regex used here produced 471 sentence boundaries ending in an abbreviation in Pride and Prejudice, mostly Mr and Mrs, and 20.1% of RFC 9110's supposed sentences are three words or fewer. A real splitter handles abbreviations and decimals; a naive one turns 28.5% of the novel into fragments and then packs them into chunks that end mid-clause anyway.
What to change in the pipeline
- Measure p99 sentence length in tokens on a hundred documents of your own corpus. For English prose it lands near 100 to 120 tokens.
- If you keep fixed windows, set overlap to that number in tokens and stop thinking in percentages. Expect a 20 to 25% markup on embedding cost either way.
- If you own the splitter, pack sentences, cap at the model's real max sequence length, and split the rare sentence longer than the cap at clause punctuation. That is one truncation per oversized sentence instead of one per chunk boundary.
- Keep sentences-never-whole as a regression metric next to retrieval score. It moves before recall does.
Run it on your own corpus
import re, tiktoken
enc = tiktoken.get_encoding("cl100k_base")
def spans(text):
sp, pos = [], 0
for s in [x.strip() for x in re.split(r'(?<=[.!?])\s+', text) if x.strip()]:
n = len(enc.encode(s, disallowed_special=()))
if n:
sp.append((pos, pos + n))
pos += n
return sp, pos
def run(text, size, overlap_pct):
sp, total = spans(text)
step = max(1, round(size * (1 - overlap_pct / 100)))
windows, i = [], 0
while i < total:
j = min(i + size, total)
windows.append((i, j))
if j >= total:
break
i += step
broken = [k for k, (a, b) in enumerate(sp)
if not any(s <= a and b <= e for s, e in windows)]
return len(windows), sum(e - s for s, e in windows), len(broken), len(sp)
def pack(text, size):
sp, total = spans(text)
chunks, cur = [], 0
for a, b in sp:
n = b - a
if cur and cur + n > size:
chunks.append(cur)
cur = 0
cur += n
if cur:
chunks.append(cur)
return len(chunks), sum(chunks), 0, len(sp)
Two functions, one dependency. Run them on your corpus and you get the tables above; the numbers move with genre, the conclusion about overlap does not.
What this does not measure
Retrieval quality. A sentence that survives intact can still be retrieved badly, and a broken sentence can still be found if the query matches its first half. What was counted here is the mechanical precondition: whether the retrieved unit contains a complete thought. Fixing that is cheap, and it removes one excuse from the pile when recall disappoints.
Related
- RAG chunking strategies compared - the menu of splitters this post puts numbers under.
- One million chunks: 1.4 GiB or 15.4 GiB - what the extra rows cost in index memory.
- The tokenizer tax - the same text costs different tokens under different encoders, which moves every threshold here.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.