Test RAG Chunking with Questions the Product Must Answer
A chunk-size debate means little until you know whether the facts a question needs survive intact and reach the prompt. This lab labels gold evidence as verbatim fact spans instead of chunk IDs, then compares seventeen chunking strategies on 44 questions for a fictional policy with exceptions in other sections, tables and cross-references. It measures fact survival with no retriever, complete-evidence recall at equal word budgets on BM25 and a local MiniLM embedding model, top-chunk citation support, index size and latency. Fixed chunks lost facts, 25% overlap closed most of the gap, parent-child and chapter-sized parents lost, and most gaps need more questions than 44 before anyone acts on them.

A support assistant answers a refund question from a policy document. The rule, a 14-day window for new annual plans, sits in section 4.2. The exception, that the window no longer applies once the customer has exported their data, sits in section 13.1. The team halves the chunk size from 512 to 256 tokens, reruns twenty questions, and the pass rate moves two points. Nobody can say whether that is the chunker or noise, because nobody checked whether the exception sentence was whole in any chunk, or whether the rule and its exception ever reached the prompt together.
This part compares chunking strategies with the corpus, questions, gold evidence and retrievers held constant. Part 1 covers where questions come from and how splits stay honest, Part 2 trusting a grader, and Part 3 localising a wrong answer with a trace. Part 3 starts by asking whether the gold chunk is in the index at all. This part measures the case that check cannot see: the chunk exists, and the fact inside it has been cut in half.
What should gold evidence point at when the chunker is the variable?
At the evidence itself. Ragas ships an ID-based context recall that divides the reference context IDs found among the retrieved IDs by the number of reference IDs. That works while IDs are stable. A chunker change renumbers every chunk, so a label set made of chunk IDs describes one chunker and no other. Label the sentences and table rows the answer needs, verbatim, as they appear in the source document, and test them against whatever chunks a strategy produces.
Here is one record from the lab's question file. Each inner list is one required fact, and its members are acceptable wordings, because a policy sometimes states a fact in two places. A question is supported only when every inner list has a member that appears whole in the context:
{"id": "q22", "type": "exception",
"q": "We exported all our boards last month and now want to cancel and get the annual fee back. Can we?",
"facts": [
["A new annual subscription is refundable in full if the Account owner gives Notice within 14 days of the first payment."],
["The first is a subscription for which a Data Export was completed, as defined in Section 10.1, before Notice was given."],
["An export counts as completed when the download link is generated, even if it is never downloaded."]]}
The three facts live in sections 4.2, 13.1 and 10.1. Two small functions turn the file into measurements. covered returns one boolean per required fact. survival uses it with no retriever at all, which separates a chunker problem from a retrieval problem before any ranking runs:
def norm(s):
return " ".join(s.split())
def covered(groups, texts):
"""One boolean per required fact: is any acceptable wording whole inside one context?"""
flat = [norm(t) for t in texts]
return [any(norm(alt) in t for alt in g for t in flat) for g in groups]
def survival(texts, questions):
"""No retriever: can the chunks hold the evidence at all?"""
whole = colocated = 0
for q in questions:
whole += all(covered(q["facts"], texts)) # every fact whole somewhere
colocated += any(all(covered(q["facts"], [t])) for t in texts) # all facts in one chunk
return whole, colocated
The lab corpus is an invented subscription policy for a fictional product, Halyard Boards. It has 41 retrievable units (39 leaf sections plus two short introductions), a median of 85 words per unit and a longest of 142, five tables, 35 "Section N" cross-references, terms defined in section 1, an exceptions chapter at section 13, and an Enterprise override at 14.1. The 44 questions break down as 15 lookups, 5 that depend on a defined term, 10 where an exception sits away from its rule, 6 table rows, 2 overrides and 6 that need three or more places. Thirteen of the 44 cannot be answered from any single section. The questions use a customer's words, such as "money back" for a section that says "refund". In a real project they come from logs and tickets, labelled and split as in Part 1.
Which chunkers ran, and what do their defaults assume?
Defaults differ in unit as well as size, which is the first reason a chunk-size debate between two stacks compares nothing. Each row below was read from the source or API reference at the version named:
| Component | Default that matters | Counted in |
|---|---|---|
| Haystack 3.4.1, DocumentSplitter | split_by "word", split_length 200, split_overlap 0 | units separated by a single space |
| LangChain text splitters 1.1.3, RecursiveCharacterTextSplitter | chunk_size 4000, chunk_overlap 200, separators paragraph, line, space, empty string | characters, unless you pass a length function |
| LangChain text splitters 1.1.3, MarkdownHeaderTextSplitter | strip_headers True | headings move to metadata and leave the chunk text |
| LlamaIndex 0.14.25, SentenceSplitter | chunk_size 1024, chunk_overlap 200 | tokens |
| LlamaIndex 0.14.25, HierarchicalNodeParser | chunk_sizes 2048, 512, 128; AutoMergingRetriever merges when more than half of a parent's children are retrieved | tokens |
| OpenAI vector stores, auto chunking | 800 tokens with 400 overlap; overlap may not exceed half the chunk size | tokens |
| Google Vertex AI RAG Engine | chunk_size 1,024, chunk_overlap 256 | tokens |
Two entries are easy to miss. LangChain's recursive splitter counts characters by default, so a chunk_size of 1000 there is not the 1000 tokens or words that other stacks mean. And the Markdown header splitter drops the heading from the text it returns, which matters to any retriever that indexes only text.
The lab built the first four rows with the libraries themselves, passing a whitespace word count where a length function or tokenizer is accepted, and added its own section-based chunkers:
from haystack import Document
from haystack.components.preprocessors import DocumentSplitter
from langchain_text_splitters import MarkdownHeaderTextSplitter, RecursiveCharacterTextSplitter
from llama_index.core.node_parser import SentenceSplitter
words = lambda s: len(s.split())
text = open("policy.md").read()
def fixed(size, overlap):
ds = DocumentSplitter(split_by="word", split_length=size, split_overlap=overlap)
return [d.content for d in ds.run(documents=[Document(content=text)])["documents"]]
recursive = RecursiveCharacterTextSplitter(chunk_size=200, chunk_overlap=0, length_function=words).split_text(text)
sentence = SentenceSplitter(chunk_size=100, chunk_overlap=0, tokenizer=lambda s: s.split()).split_text(text)
by_header = [d.page_content for d in MarkdownHeaderTextSplitter(
[("#", "h1"), ("##", "h2"), ("###", "h3")]).split_text(text)] # strip_headers=True is the default
The own-code strategies are small. One chunk per section, with the chapter and section titles on the first line so the indexed text carries those words. Then a post-retrieval step that appends any section a retrieved chunk points to with "Section N.M":
XREF = re.compile(r"Section (\d+(?:\.\d+)?)")
def heading_path_chunks(sections):
"""One chunk per section; the indexed text starts with the chapter and section titles."""
return [(s["h2"] + " > " if s["level"] == 3 and s["h2"] else "") + s["heading"].lstrip("# ")
+ "\n" + s["body"] for s in sections]
def expand_xrefs(picked, text_by_id, max_extra=3):
"""Append sections named by 'Section N.M' in what was retrieved, nearest rank first."""
have, extra = set(picked), []
for sid in picked:
for ref in XREF.findall(text_by_id[sid]):
if ref in text_by_id and ref not in have and len(extra) < max_extra:
have.add(ref)
extra.append(ref)
return list(picked) + extra
Also run were parent-child (40-word children indexed, the whole section handed to the generator), the same idea with a chapter as the parent, whole chapters as chunks, and the Markdown splitter with headers kept. Sizes are whitespace words. Haystack splits on single spaces only, so a newline between two words does not separate them and its "200-word" chunks measure 200 to 213 by whitespace count. Word counts are not token counts; the tokenizer note in the FAQ gives the conversion for the embedding model used here.
How much do boundaries break before any retriever runs?
More than the average chunk length suggests. The table counts questions, out of 44, whose evidence survives. "Facts intact" means every required fact is whole inside some chunk. "One chunk" means every required fact is inside the same chunk. The last column is for the dense retriever and is explained after the table.
| Strategy | Chunks | Indexed words | Facts intact (of 44) | All in one chunk | Chunks over the 256-piece embed limit |
|---|---|---|---|---|---|
| Fixed, 50 words | 70 | 3,598 | 26 | 21 | 0 of 70 |
| Fixed, 100 words | 35 | 3,598 | 33 | 26 | 0 of 35 |
| Fixed, 200 words | 18 | 3,598 | 38 | 28 | 16 of 18 |
| Fixed, 400 words | 9 | 3,598 | 39 | 28 | 9 of 9 |
| Fixed, 200 words, 50 overlap | 23 | 4,732 | 44 | 31 | 20 of 23 |
| Fixed, 200 words, 100 overlap | 34 | 7,023 | 44 | 32 | 31 of 34 |
| Paragraph-first recursive, 200 | 21 | 3,598 | 44 | 32 | 5 of 21 |
| Sentence-packed, 100 | 41 | 3,598 | 43 | 28 | 0 of 41 |
| Markdown headers, default | 41 | 3,320 | 44 | 31 | 0 of 41 |
| Section chunk + heading path | 41 | 3,667 | 44 | 31 | 0 of 41 |
| Parent-child, 40-word children | 112 (41 parents) | 3,322 | 44 | 31 | 0 of 112 |
| Section children, chapter parent | 41 (17 parents) | 3,667 | 44 | 33 | 0 of 41 |
Fixed chunks without overlap lose facts in proportion to how small they are: 26, 33, 38 and 39 of 44 at 50, 100, 200 and 400 words. At 400 words the loss is smaller, but each chunk is 11% of the whole document. A 25% overlap restored all 44, at 4,732 indexed words against 3,598, which is 31.5% more text to embed, store and rank. A 50% overlap, the proportion OpenAI's auto strategy uses, also restored 44 and cost 95% more (7,023 words). The overlap bought nothing past the first quarter.
The "all in one chunk" column has a ceiling. Thirteen questions have evidence in two or more sections, so no section-sized chunk can hold them together, and the best any strategy reaches is 33. Those questions are won by retrieving two chunks, not by a cleverer boundary.
The boundary report is a few lines. It looks for a required fact that no chunk holds whole but two neighbours hold between them, and prints the cut:
def split_facts(chunks, fact):
"""Find a required fact that no chunk holds whole but two neighbours hold between them."""
f = norm(fact)
for i in range(len(chunks) - 1):
a, b = norm(chunks[i]), norm(chunks[i + 1])
if f in a + " " + b and f not in a and f not in b:
return i, a[-60:], b[:60]
cut between chunk 9 and 10
ends : ...Only P1 and P2 tickets can be escalated, and each ticket can
starts: be escalated once. Tickets about billing are handled by the ...
cut between chunk 2 and 3
ends : ...riod is the number of Active Seats counted at the end of the
starts: period, at the monthly price. On annual plans, the charge is...
Output from Python 3.14.5 on the 200-word fixed chunks. The first cut separates "each ticket can" from "be escalated once", so a question about escalation limits finds half a rule. The second cuts the monthly billing formula in two, and the question about billed seats lost a required fact to that cut at 50, 100 and 200 words.
Three library behaviours showed up in the same table. The sentence splitter lost one fact, 43 of 44, by ending a chunk in the middle of a table row; a sentence boundary is the wrong boundary for a pipe table. The Markdown splitter's default removed the 278 words of headings, 3,320 indexed words against 3,598. And the right-hand column: all-MiniLM-L6-v2 truncates input at 256 word pieces, a limit stated on its model card, and this corpus runs about 1.3 word pieces per word. A full 200-word chunk is about 270 pieces, so 16 of 18 fixed chunks lose between 2 and 36 pieces from the vector's view. At 400 words a full chunk is about 540 pieces and the model sees 47% of it; only 21 of 44 questions have all their facts inside the first 256 pieces of any chunk. BM25 reads the whole chunk; the dense vector does not. Keep that in mind when the results below separate the two retrievers.
Which chunker wins once a retriever is in the loop?
The retrievers are an in-memory BM25 written for the lab (k1 1.5, b 0.75, a small stopword list and a light suffix stripper) and the dense model above, with cosine similarity over normalised vectors. The BEIR benchmark paper found BM25 held up as a baseline across 18 datasets, which makes it a sensible lexical choice. The measurement is complete@k: every required fact is whole inside the retrieved context. The loop stops at k chunks or at a word budget. A budget is the fairer comparison, because chunks of 50 and 400 words fill a prompt differently:
def pick(texts, ranked, k=None, budget=None):
"""Walk the ranking; stop at k chunks, or when the next chunk would bust the word budget."""
picked, used = [], 0
for i in ranked:
w = len(texts[i].split())
if budget is not None and used + w > budget:
break
picked.append(i)
used += w
if k is not None and len(picked) >= k:
break
return picked
def complete_at(texts, rank_fn, questions, **limit):
hits = 0
for q in questions:
picked = pick(texts, rank_fn(q["q"]), **limit)
hits += all(covered(q["facts"], [texts[i] for i in picked]))
return hits
Counts are out of 44. The last column is how many questions had a required fact inside the single top-ranked chunk, a rough stand-in for whether a one-chunk citation would point at real support (BM25 / dense).
| Strategy | BM25, top 3 | BM25, 500 words | Dense, top 3 | Dense, 500 words | Words in top 3 (BM25) | Top chunk holds a fact |
|---|---|---|---|---|---|---|
| Fixed, 100 words | 26 | 26 | 23 | 28 | 312 | 20 / 22 |
| Fixed, 200 words | 27 | 22 | 28 | 24 | 621 | 24 / 22 |
| Fixed, 400 words | 29 | 16 | 27 | 14 | 1,223 | 26 / 23 |
| Fixed, 200 words, 50 overlap | 30 | 25 | 34 | 31 | 620 | 29 / 27 |
| Paragraph-first recursive, 200 | 29 | 27 | 34 | 33 | 525 | 25 / 31 |
| Sentence-packed, 100 | 28 | 34 | 31 | 36 | 267 | 24 / 27 |
| Markdown headers, default | 32 | 34 | 37 | 40 | 258 | 26 / 33 |
| Section chunk + heading path | 33 | 36 | 37 | 38 | 285 | 26 / 33 |
| Section chunk + heading path + cross-references | 37 | 37 | 38 | 39 | 457 | 26 / 33 |
| Parent-child, 40-word children | 28 | 33 | 32 | 36 | 283 | 26 / 28 |
| Section children, chapter parent | 34 | 27 | 37 | 32 | 743 | 29 / 37 |
| Whole chapters | 35 | 29 | 34 | 31 | 718 | 32 / 35 |
Four readings, in order of how much they should change a decision. Section chunks also lead 200-word chunks with 50 overlap, by 3 questions on both retrievers, but that gap is within noise, as the last section shows.
- Chunk size is a budget decision. At the top-3 cutoff the 400-word chunks look fine on BM25 (29 of 44), but they cost 1,223 words of prompt. Give every strategy the same 500 words and they fall to 16 and 14, because a prompt holds one chunk. The section chunks and the 100-word sentence-packed chunks hold the most evidence per word.
- Changing the retriever reorders the chunkers. At top 3, 400-word fixed chunks beat 200-word chunks with 100 overlap on BM25 (29 to 28) and lose to them by seven on dense (27 to 34). Part of that is the truncation above: the dense vector of a 400-word chunk describes about half of it. A team that swaps the embedding model and the chunker in one release cannot attribute the change to either.
- Section-level recall flatters the fixed chunkers. Counting a hit when any retrieved chunk touches a gold section, BM25 at top 3 scores the 200-word fixed chunks 33 of 44, against 27 for complete evidence. For the section chunks the two numbers are equal, 33 and 33. A document-level or section-level recall metric would have hidden the gap.
- Bigger chunks are likelier to hold some supporting fact. In the last column, 200-word chunks with 50 overlap beat the section chunks on BM25 (29 to 26), because a 206-word chunk covers more ground than an 89-word one. They also spend 620 words to get there, against 285.
Where did the fancier strategies lose?
Parent-child lost to plain section chunks. Indexing 40-word children and returning the parent section scored 28 against 33 on BM25 and 32 against 37 on dense at top 3, and stayed behind at the 500-word budget (33 against 36, 36 against 38). Sections here are small, a median of 85 words, so the parent is nearly the child, and a 40-word child carries fewer matching terms than an 89-word section; the lab did not isolate the cause. The pattern is built for long parents: LlamaIndex's hierarchical parser defaults to 2048, 512 and 128 token levels, and its AutoMergingRetriever and Haystack's both swap in the parent when more than half of its children match. This corpus has no long parents, so it says nothing about that case.
A larger parent bought little and cost a lot. Indexing sections but handing the generator the whole chapter scored 34 on BM25 against 33, at 743 words of context against 285. At the 500-word budget it fell to 27 against 36. Whole chapters as chunks behaved the same way.
A cheap stand-in for contextual chunks did nothing. Anthropic's Contextual Retrieval prepends 50 to 100 tokens of model-written context to each chunk before embedding and BM25 indexing, and reports top-20 retrieval failures falling from 5.7% to 2.9% with contextual embeddings and contextual BM25 combined. The lab did not run that. It prepended the heading path of the section where each fixed chunk starts, with no model. That scored 27 against 27 on BM25 and 29 against 28 on dense at top 3, which is unsurprising: a chunk spanning three sections gets the label of one. The published method pays for a model call per chunk, which Anthropic estimates at $1.02 per million document tokens with prompt caching, assuming 800-token chunks and 8,000-token documents.
Cross-reference expansion helped, with a price. Following "Section N.M" pointers from the retrieved chunks raised BM25 from 33 to 37 and dense from 37 to 38. In the refund example the exception section names section 4.2, so the rule arrives with the exception. The expansion added 172 words per question on average, 285 to 457, and diluted the top-three citation precision on BM25 from 0.34 to 0.25. It also depends on the document naming its own sections. This corpus has 35 such pointers because it was written that way; a document without them gets nothing.
Three approaches were not run. Late chunking embeds the whole text with a long-context model and pools per chunk afterwards, so it needs a long embedding window that the 256-piece model here lacks. RAPTOR recursively embeds, clusters and summarises chunks into a tree, and its method includes a model-based summarisation step in the indexing path. For semantic chunking, one 2024 study found its extra compute was not justified by consistent gains over fixed-size chunks on the tasks it tried; that is a reason to test it on your questions, not a result for this corpus.
Which question types justify which chunker, and what does each cost?
The pass count hides the type of question that fails. Each cell is BM25 / dense at top 3, out of the number in the header:
| Strategy | Lookup (15) | Defined term (5) | Exception elsewhere (10) | Table row (6) | Override (2) | Three or more places (6) |
|---|---|---|---|---|---|---|
| Fixed, 200 words | 14 / 14 | 0 / 1 | 5 / 5 | 3 / 5 | 2 / 2 | 3 / 1 |
| Fixed, 200 words, 50 overlap | 14 / 13 | 2 / 2 | 4 / 7 | 4 / 5 | 2 / 2 | 4 / 5 |
| Paragraph-first recursive, 200 | 12 / 14 | 2 / 1 | 5 / 6 | 4 / 6 | 2 / 2 | 4 / 5 |
| Section chunk + heading path | 14 / 15 | 1 / 2 | 7 / 7 | 4 / 6 | 2 / 2 | 5 / 5 |
| Section chunk + heading path + cross-references | 14 / 15 | 2 / 2 | 8 / 8 | 6 / 6 | 2 / 2 | 5 / 5 |
| Section children, chapter parent | 14 / 15 | 1 / 2 | 7 / 7 | 5 / 6 | 2 / 2 | 5 / 5 |
| Whole chapters | 14 / 13 | 4 / 2 | 6 / 6 | 4 / 6 | 2 / 2 | 5 / 5 |
Lookups barely care: 12 to 14 of 15 on BM25 for every strategy of 100 words or more, and 13 to 15 on dense apart from the 400-word chunks. The separation comes from exceptions and requests spanning several places, where the section chunks scored 7 of 10 and 5 of 6 on BM25 against 5 and 3 for the plain 200-word chunks. The weak column is the defined term, 0 to 2 of 5 for most strategies, and it is a retrieval problem a boundary cannot fix: a question about billed seats shares little beyond the word "seat" with the sentence that defines an active seat. Only whole chapters, which glue three definitions together, reached 4 of 5 on BM25, at 718 words of context.
Turned into a choice, with the measured price of each option:
| If the failing questions look like | Check first | Try | What it cost here |
|---|---|---|---|
| A rule or a table row cut in two | Survival below 44 of 44 with no retriever | Paragraph or section boundaries, or 25% overlap | Overlap: +31.5% indexed words. Section chunks: +69 words, 1.9% |
| A rule here, its exception elsewhere | Whether the exception names the rule's section | Follow explicit pointers after retrieval | +172 words per question; needs pointers in the source |
| A term defined in another section | Whether the defining section is retrieved at all | Pin the glossary, expand the query, or widen the parent | Chapter-sized context: 718 words against 285 |
| A table row without its header | Whether header and row sit in one chunk | Keep the table inside its section chunk; do not pack by sentence | Sentence packing broke one row (43 of 44) |
| Answers that live in one sentence | Nothing; the chunker is not the problem | Keep what you have | None |
| A whole corpus smaller than your prompt budget | Total words against the model's window | Skip retrieval | 3,598 words per question against about 285 |
The last row is Anthropic's own advice: a knowledge base under 200,000 tokens, about 500 pages, can go in the prompt whole, with prompt caching making that cheaper. A 3,598-word policy is far below that, so retrieval has to earn its recall loss. Section chunking also needs structure. The lab corpus has clean Markdown headings, and a PDF whose headings were flattened into body text is a different, earlier problem that these numbers do not cover.
What do latency, index size and citations cost?
Query latency did not separate the strategies. BM25 took 0.03 to 0.07 ms per query and the dense retriever 10.3 to 11.2 ms, with the single query embedding dominating the second. The index here has 9 to 112 chunks, far too few for scan time to matter, so the lab says nothing about latency at a million chunks. The costs that moved are paid at index and prompt time:
- Embedded word pieces ranged from 2,304 (400-word fixed, mostly truncated) to 8,664 (200 words with 100 overlap), which is the number an embedding API would bill.
- Vector storage ranged from 27 KB to 336 KB for 9 and 112 chunks of 384 float32 values.
- Building the dense index took 0.6 to 2.2 seconds on one run; the slowest was the 100-word overlap. Timings are single-run and will vary.
- The top-3 prompt held 156 words for 50-word chunks and 1,223 for 400-word chunks. That is the recurring cost, paid on every question.
A bigger prompt has a quality cost this lab did not measure, because no generator ran: the Lost in the Middle study found accuracy often highest for evidence at the start or end of a long input and lower in the middle.
Citation support pulls the other way. Top-3 citation precision, the share of retrieved chunks that contain a required fact, ran from 0.20 (50-word fixed chunks) to 0.47 on BM25 and was highest for the overlapping 200-word chunks (0.40 and 0.47), partly because overlap puts the same fact in two chunks. A section chunk also carries a clean citation target, its section number. Whether a generator cites the chunk that supports each claim is a separate measurement, covered in Part 5 of this series.
How do you keep the question set from flattering the chunker?
Start with how the questions were made. Take each hand-written question's first required sentence and use it verbatim as the query instead, which is roughly what a generator does when it writes a question from one chunk:
strategy copied-sentence hand-written (all 44)
fixed-100 33/38 26/44
fixed-200 35/38 27/44
fixed-200/50 38/38 30/44
recursive-200 38/38 29/44
heading-path 38/38 33/44
parent-child (40w) 38/38 28/44
Output from the lab on BM25 at top 3. On the copied set the strategies span 33 to 38 of 38 and four of the six score a perfect 38, so a chunker comparison would conclude that it barely matters. On questions in a customer's words, the same strategies spread from 26 to 33 of 44. Questions copied from a chunk reward a retriever for matching the sentence it was copied from.
The second issue is noise. With 44 questions one question is 2.3 points, so compare in pairs: count the questions only A answered and the questions only B answered, then run an exact two-sided sign test on those. At top 3 on BM25, section chunks beat 200-word fixed chunks 8 to 2 (p about 0.11), beat 200-word chunks with 50 overlap 5 to 2 (p about 0.45) and beat parent-child 6 to 1 (p about 0.13). On dense they beat 200-word fixed chunks 9 to 0 (p about 0.004) and 100-word fixed chunks 14 to 0, and beat the overlap strategy 3 to 0 (p about 0.25). Cross-reference expansion won 4 to 0 on BM25 (p about 0.13). The defensible conclusion is narrow: fixed chunks without overlap lose to section chunks on dense retrieval. Overlap against sections, and the value of cross-references, need more questions before anyone acts on them.
The third issue is who writes the questions. A model can draft candidates quickly, but a person has to confirm that each question looks like something a user would ask and that the gold facts are right, and the holdout that decides a chunker should be human-written. Hold it out as in Part 1 and change one variable per run. The retriever swap above is the reason: strategies that tie on one embedding model can separate on another.
Apply this now
- Pull 20 real questions from tickets or logs, and make five of them ones whose answer spans two sections. For each, copy the required sentences and table rows verbatim into inner lists of acceptable wordings.
- Run
survivalon your current chunker with no retriever. Any question below full survival is a boundary problem; read the cut with the boundary report before touching the retriever. - Fix a word or token budget that matches your prompt. Report complete@budget with your production retriever, and the words used, so a larger chunk cannot win by spending more.
- Label the ten worst failures: fact cut, fact never retrieved, or defined term missing. Part 3's ordered checks give the labels for the middle one.
- Change one thing, then re-run. If a swap of chunker and embedding model happens in the same release, run the two changes separately first.
Keep the results file from before and after, with the paired counts (questions only the old strategy answered, questions only the new one did). Saving results as JSON lets the JSON Diff tool show which questions moved. Part 7 of this series applies the same discipline to whole model upgrades.
FAQ
What chunk size should I use?
The documented defaults span 200 words (Haystack), 800 tokens (OpenAI), 1,024 tokens (LlamaIndex and Google) and 4,000 characters (LangChain), so a size carried between stacks does not mean the same thing. Measure complete@budget on your own questions, in the unit your embedding model and prompt count.
Why words instead of tokens?
Whitespace words are the same on every machine and need no tokenizer. Token limits are what models enforce: this corpus ran about 1.3 word pieces per word on all-MiniLM-L6-v2, and a 200-word chunk crossed its 256-piece limit. Convert your budget to the unit the model counts before comparing it with these numbers.
Is overlap worth it?
It restored every fact in the lab at 25% overlap (44 of 44 survival from 38) and cost 31.5% more indexed words. At 50% it cost 95% more and survival did not improve. If your documents have no headings or paragraphs to cut on, 25% is a reasonable first trial. If they do, section boundaries reached 44 of 44 for 1.9% more text.
Should I use semantic chunking, late chunking or RAPTOR?
None of the three was run here, so there is no result to quote. Each has a cost the lab strategies lack: an extra embedding pass, a long-context embedding model, or a model in the indexing path. Put them through the same survival and budgeted-recall test and compare that cost with the 31.5% that 25% overlap added.
Can I run this without a generator?
Yes, and the lab did. Survival and recall at a budget need only the corpus, the questions and a retriever. They show whether the evidence reached the context, not whether the model used it; Part 3 covers that side, and Part 5 covers abstention, hallucination and citation faithfulness.
Primary references
- Ragas metrics reference: ID-based and LLM-based context recall. The ID-based recall formula (reference context IDs found among retrieved IDs, over all reference IDs), which is the reason chunk-ID labels do not carry across chunkers, and the LLM-based and non-LLM variants that estimate recall from a reference answer or reference contexts.
- Haystack 3.4.1 source for DocumentSplitter. Defaults of split_by "word", split_length 200 and split_overlap 0, and that splitting by word divides on a single space.
- Haystack 3.4.1 source for AutoMergingRetriever. Returns the parent when the matched leaf share exceeds a threshold, default 0.5.
- LangChain text splitters 1.1.3 source for RecursiveCharacterTextSplitter. Default separators of paragraph, line, space and empty string, with the base class defaults of chunk_size 4000, chunk_overlap 200 and a character-count length function in base.py.
- LangChain text splitters 1.1.3 source for MarkdownHeaderTextSplitter. The strip_headers default of True.
- LlamaIndex 0.14.25 source for SentenceSplitter. Defaults of 1,024 chunk size and 200 overlap, and the tokenizer parameter used to count words.
- LlamaIndex 0.14.25 source for AutoMergingRetriever. Merging into the parent when the retrieved share of its children is above a 0.5 threshold, with hierarchical chunk sizes of 2048, 512 and 128 in the HierarchicalNodeParser source beside it.
- OpenAI API reference for creating a vector store. The auto chunking strategy of 800 tokens with 400 overlap, and the rule that overlap may not exceed half the chunk size.
- Google Cloud guide to fine-tuning RAG Engine transformations. Default chunk_size of 1,024 tokens and chunk_overlap of 256, and the note that a larger chunk can miss specific details.
- Anthropic on contextual retrieval. Prepending 50 to 100 tokens of chunk context before embedding and BM25 indexing, the 5.7% to 2.9% top-20 failure result, the $1.02 per million document tokens estimate and its assumptions, and the advice to put a knowledge base under 200,000 tokens in the prompt.
- Hugging Face model card for all-MiniLM-L6-v2. Input beyond 256 word pieces is truncated by default.
- Sentence Transformers 3.4.1 README. The published similarity matrix for three example sentences, which the numpy reimplementation reproduced to four decimals.
- BEIR, a benchmark for zero-shot retrieval evaluation (arXiv 2104.08663). BM25 holding up as a baseline across 18 datasets, with dense models efficient but often weaker out of domain.
- Late chunking with long-context embedding models (arXiv 2409.04701). Chunking applied after the transformer and before mean pooling, for long-context embedding models.
- RAPTOR, tree-organised retrieval (arXiv 2401.18059). Recursively embedding, clustering and summarising chunks into a tree that is retrieved from at several levels.
- Is semantic chunking worth the computational cost (arXiv 2410.13070). The finding that semantic chunking's extra cost is not justified by consistent gains over fixed-size chunking on the tasks tested.
- Lost in the Middle, long-context use (arXiv 2307.03172). Accuracy is often highest for evidence at the start or end of a long input and falls for the middle, one reason a budget matters when you raise k.
LLM and RAG Evaluation
LLM and RAG Evaluation
Get part 5: Test LLM Hallucination, Abstention and Citation Faithfulness
It is live now: read part 5. The form below subscribes you to The Automation Brief, the site newsletter.
No spam, no sending cadence promised. Unsubscribe any time.