Sentence-Aligned Chunks Beat 20% Overlap: 100,453 Tokens

🔧 AI Tools 2026-11-26 7 min read
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

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.

corpussentencesmean tokensp90p99longest
RFC 91101,41631.258117452
Python docs, asyncio tasks48022.24090193
Pride and Prejudice, ch. 1-61,65527.557111220

Fixed windows at 512 tokens

overlapchunkstokens embeddedvs no overlapsentences never wholeshare of tokens
0%8744,2470%84 (5.9%)11.7%
10%9649,092+10.9%16 (1.1%)5.4%
20%10855,161+24.7%2 (0.1%)1.9%
sentences packed, no overlap9244,2470%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.

corpus0% overlap10%20%packed
RFC 911084 (5.9%)16 (1.1%)2 (0.1%)0
Python docs18 (3.8%)000
Pride and Prejudice83 (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 sizeoverlap at 20%chunksextra tokenssentences never whole, RFC 9110
25651 tokens216+24.8%25 (1.8%)
512102 tokens108+24.7%2 (0.1%)
1,024204 tokens54+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.

corpuschunkstokens embeddedextrabrokenaverage chunklargest chunk
RFC 91109244,2470%0480.9512
Python docs2210,6750%0485.2512
Pride and Prejudice9445,5310%0484.4512

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

What to change in the pipeline

  1. Measure p99 sentence length in tokens on a hundred documents of your own corpus. For English prose it lands near 100 to 120 tokens.
  2. 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.
  3. 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.
  4. 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

Related Articles
2026-08-24
Best AI Content Writer in Cardiff 2026: 6 Tools for Welsh Marketing Teams
2026-08-03
AI Language Learning 2026: LibreLingo (2.6k Stars) + LLM Tutors - Free Alternatives to Duolingo
2026-07-29
Win11 KB5095093: Point-in-Time Restore, Pause Updates by Date, Screen Tint, and More
2026-08-23
Best AI Presentation Maker in Kigali 2026: 6 Tools for NGOs and Conference Speakers
2026-08-20
Best AI Detectors in 2026: 7 Tools That Catch AI-Generated Text
2026-07-25
Best Ai Research Paper Summarizer in 2026: Top 10 Tools Compared

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.

💬 Comments (0)

No comments yet. Be the first!

Login to comment