Tune chunk size and overlap by building a 30-50 query eval set from real user questions, sweeping 3-4 chunk sizes (e.g., 256, 512, 1024 tokens) against 2-3 overlap ratios, and plotting recall@k for each combination. Stop when recall gains flatten — that's your production configuration, not the tutorial default.
Quick Answer: Don't guess chunk size — measure it. Build a representative eval set of real queries with known-correct source passages, sweep chunk size and overlap combinations, and pick the configuration where recall@k plateaus rather than the one that feels intuitively "right."
Why the 512-Token Default Is a Guess, Not a Decision
The 512-token chunk with 50-token overlap you copied from a tutorial was tuned for someone else's documents and someone else's queries, not yours. It's a reasonable starting prior, not a validated choice. Treating it as final skips the one step that actually matters: measurement.
Chunk size and overlap control a trade-off in how your retriever represents documents, and that trade-off shifts depending on document structure, query style, and embedding model. A knowledge base of short support tickets behaves nothing like one built from long technical specs. A retriever tuned on FAQ-style queries behaves nothing like one tuned on multi-clause troubleshooting questions.
Our complete guide to RAG knowledge systems frames chunking as one of four product decisions RAG forces on a team building retrieval — alongside chunking strategy (semantic vs. fixed-window), embedding choice, and retrieval architecture. Size and overlap are the tuning knobs within whatever strategy you've already picked; if you haven't picked one yet, read our chunking strategy and retrieval quality piece first.
This article assumes you've made the strategy decision and need to tune the parameters empirically. That's a measurement problem, and measurement problems have a standard shape: build a test set, sweep a parameter, plot the result, pick the value where the curve stops improving.
The Core Tension: Precision vs. Completeness
Small chunks retrieve precisely but fragment context; large chunks preserve completeness but dilute relevance with noise. Neither extreme wins across all query types — the right size depends on how much context a typical answer in your corpus actually requires, which only your own eval data can tell you.
Small chunks (128-256 tokens) embed a narrow, focused idea. When a query matches that idea, the retrieved chunk is highly relevant — cosine similarity is sharp because there's little competing content diluting the vector. But answers spanning two sentences that got split across a chunk boundary become unretrievable as a single unit, forcing the generator to reason across fragments it may never see together.
Large chunks (1024+ tokens) preserve narrative flow and rarely split an answer mid-thought. But they also drag in adjacent, irrelevant sentences that dilute the embedding's semantic focus. A large chunk about "onboarding" might also contain a paragraph about billing, and now a billing query retrieves it too — false-positive noise that a reranker or the generator has to filter out downstream.
| Chunk size | Precision | Context completeness | Typical failure mode |
|---|---|---|---|
| 128-256 tokens | High | Low | Answer split across chunks; partial context |
| 512 tokens | Moderate | Moderate | Balanced default; still corpus-dependent |
| 1024+ tokens | Low | High | Irrelevant content dilutes embedding; noisy retrieval |
Overlap is the partial fix for boundary-splitting: repeating the last N tokens of chunk i at the start of chunk i+1 so a sentence straddling a boundary appears whole in at least one chunk. More overlap reduces split-answer failures but increases index size and redundant retrieval — every extra overlap token is stored, embedded, and searched again.
Build a Representative Eval Set First
A chunk-tuning sweep is only as trustworthy as the query set you run it against, so build 30-50 real queries with known-correct source passages before you touch a single parameter. Skip this step and you're optimizing against vibes, not evidence.
What Goes Into the Eval Set
- Pull real queries, not invented ones — from support logs, search analytics, or a stakeholder interview transcript. Invented queries reflect how you think users ask questions, not how they actually do.
- Cover query diversity: short keyword lookups, multi-clause questions, and queries requiring synthesis across two or more source passages.
- Label ground truth: for each query, identify the specific passage(s) in your source documents that contain the answer — not just the document, the passage.
- Include edge cases deliberately: queries whose answer spans an awkward paragraph break, and queries with no good answer in the corpus (to catch false-positive retrieval).
- Hold out a slice you never look at during tuning, so your final config isn't overfit to the same 30 queries you iterated against.
This mirrors the discipline behind customer journey mapping: you don't map a journey off one power user's story, and you don't tune retrieval off one query you happen to love.
The Single Biggest Mistake: Tuning to One Beloved Query
Warning: teams repeatedly converge on a chunk size because it makes their one favorite demo query return a perfect answer — then ship it, and recall on everything else quietly degrades. A single query has no statistical power; it tells you about one point in your query distribution, not the distribution itself.
The fix is procedural, not willpower: never look at per-query results while deciding on a final configuration. Look only at the aggregate metric across the full eval set. If a stakeholder's favorite query performs worse under the winning configuration, that's a signal to add more queries like it to the set — not to abandon the aggregate result.
Running the Sweep: Chunk Size × Overlap
Sweep chunk size (e.g., 128, 256, 512, 1024 tokens) crossed with overlap ratio (e.g., 0%, 10%, 20% of chunk size) — typically 9-12 combinations — and measure recall@k for each against your held-out eval set. Plot the results; the configuration you want is where the recall curve flattens, not necessarily the highest single point.
Metrics Worth Tracking
recall@k: of the ground-truth passages, what fraction appear somewhere in the top-kretrieved chunks. This is your primary signal — it directly measures whether the right information reached the generator at all.precision@k: of the top-kretrieved chunks, what fraction are actually relevant. Matters most when your generator has a limited context window and irrelevant chunks crowd out useful ones.MRR(mean reciprocal rank): rewards configurations that surface the correct chunk earlier in the ranked list, not just somewhere in the top-k.- Answer-level accuracy: run the full pipeline end to end and grade whether the generated answer is correct — the metric that ultimately matters, though noisier and more expensive per data point.
Reading the Sweep Results
| Chunk size | Overlap | recall@5 | precision@5 | Notes |
|---|---|---|---|---|
| 256 | 0% | 0.61 | 0.71 | Boundary splits hurt multi-clause queries |
| 256 | 20% | 0.68 | 0.69 | Overlap recovers some split-answer loss |
| 512 | 10% | 0.79 | 0.66 | Best balance in this illustrative sweep |
| 512 | 25% | 0.80 | 0.62 | Marginal recall gain, precision cost rises |
| 1024 | 10% | 0.77 | 0.54 | Noise starts dragging precision down |
(Illustrative structure only — run this exact sweep against your own corpus; these numbers are not a benchmark to copy.)
The pattern to look for: recall rises with chunk size up to a point, then flattens or reverses as noise offsets the completeness gain. Overlap typically shows diminishing returns past 15-20% — each additional overlap percentage recovers fewer split-answer failures while linearly growing index size and query latency.
Pick the smallest chunk size and lowest overlap that sit on the flat part of the recall curve, not the single highest data point — that point is often a statistical artifact of your particular eval set, and the flat region is more robust to queries you haven't seen yet.
Plotting and Interpreting the Trade-off Curve
Plot recall@k on the y-axis against chunk size on the x-axis, with one line per overlap ratio, and look for the elbow where the curve bends from steep to flat — that elbow, not the peak, is usually the more defensible production choice. A peak one data point past the elbow rarely justifies the added noise and index cost.
Signs Your Sweep Needs a Second Pass
- The curve never flattens across your tested range — extend the sweep to larger chunk sizes before concluding.
- Precision craters at the chunk size where recall peaks — that configuration is fragile; small corpus changes could tip it the wrong way.
- Different query types want different chunk sizes — this often means your corpus needs a hybrid strategy (e.g., smaller chunks for FAQ-style content, larger for narrative documentation) rather than one global setting.
- Recall is flat everywhere — the bottleneck likely isn't chunking at all; check embedding model quality or query preprocessing first.
This is the same empirical instinct that underlies deciding RAG versus fine-tuning: don't reason from first principles about which approach "should" work better — build the smallest test that lets the data answer the question, then act on what it actually shows.
Where Prodinja Fits in This Loop
Comparing several chunking configurations side by side is exactly the kind of before-you-commit check Prodinja's Evals critique layer is designed to support. Rather than eyeballing outputs from one configuration at a time, it's built around walking through retrieval outcomes across configurations before you lock one in for production — the same sweep-and-compare discipline this article describes, framed as a structured review step rather than a one-off spreadsheet.
It's worth being precise about what this is: a structured prototype workflow for organizing and comparing retrieval-eval results, not an autonomous system that runs your sweep or picks a winner for you. You still need the eval set, the sweep, and the judgment call above — Evals is designed to make comparing the outputs of that work more legible once you've done it. If you're mapping out the broader set of decisions a retrieval-heavy product surfaces — chunking, prioritization tradeoffs, stakeholder sign-off — that's the same territory Jobs to Be Done framing helps structure at the product-decision level, one layer up from the retrieval mechanics here.
Key Takeaways
- A copied default (512 tokens, 50-token overlap) is a starting prior, not a validated setting — treat it as the first point in a sweep, not the final answer.
- Small chunks trade completeness for precision; large chunks trade precision for completeness — the right balance depends on your corpus and query style, not a universal rule.
- Build a 30-50 query eval set from real user queries with labeled ground-truth passages before running any sweep — tuning without this is tuning against vibes.
- Never tune to a single beloved query — a demo query that looks perfect after a change tells you nothing about aggregate recall; only the full eval set does.
- Sweep chunk size and overlap together, not independently, since their effects interact — overlap's value depends on how often your chosen chunk size splits answers.
- Pick the elbow of the recall curve, not the peak — the flattening point is typically more robust to queries outside your eval set than the single highest recall score.
- Track recall@k, precision@k, and MRR together, not recall alone, since chunk size trades one against the others in predictable ways.
Frequently Asked Questions
What is the best chunk size for RAG retrieval?
There is no universally best chunk size — it depends on your document structure and query patterns. Most corpora land somewhere between 256 and 512 tokens, but the only reliable way to find your number is sweeping sizes against a real eval set and reading where recall flattens.
How much chunk overlap should I use?
Start around 10-20% of your chunk size and measure the recall gain against the added index size. Overlap typically shows diminishing returns past 20%: each additional percentage recovers fewer split-answer failures while linearly increasing storage and query cost.
How many queries do I need in an eval set to tune chunking reliably?
Thirty to fifty labeled queries is a reasonable working minimum, covering short lookups, multi-clause questions, and synthesis-across-passages cases. Fewer than that and single-query noise can dominate your aggregate recall metric, leading you back to the beloved-query trap this article warns against.
Does a bigger chunk size always hurt precision?
Not always, but it usually does past some corpus-specific threshold, because larger chunks pull in more surrounding, potentially irrelevant content. The safest approach is measuring precision@k alongside recall@k in your sweep rather than assuming the relationship in advance.
Should different document types in the same corpus use different chunk sizes?
Often yes — a corpus mixing short FAQ entries with long technical specs frequently performs best with a hybrid chunking strategy rather than one global size. If your sweep shows different query types wanting different chunk sizes, that's the signal to segment your chunking strategy by document type instead of forcing one setting.