Short answer: in my lab, nothing throws an error as a corpus grows. A keyword retriever found the right chunk in its top five for 100% of questions at 1,000 documents, 87% at 10,000 and 44% at 40,000. Stale versions, split chunks and permission filters fail the same quiet way, and each has a cheap fix.
Published 30 November 2026. I ran the lab on 30 November 2026 with Python 3.12.3 and NumPy 2.5.1. I fetched the practitioner, vendor and paper figures the same day, and each one carries its own publication date. Every number labelled "lab" is mine and comes from a synthetic corpus, so read it as a mechanism, not as a rate for your system.
1. A demo that passes at 100 documents
The most useful short account of production RAG that I found is a write-up dated 20 October 2025 on blog.abdellatif.io. Its author built retrieval for two products, one with 9 million pages and one with 4 million. They tested on a subset of 100 documents, saw results that "looked great", and ran the pipeline on the full dataset within a week. Then, in their words, "the results were subpar and only the end users could tell." Fixing it took "the following few months", one piece at a time.
That last detail is the one I care about. No alert fired. No query failed. The only people who noticed were the ones reading the answers. The post is a three-minute read and gives a ranked list of what helped, but no numbers for any of the fixes. I wanted numbers I could re-run, so I built a small lab and broke it on purpose.
This is an architecture question as much as a tuning one. If a failure is silent, the design has to include a way to see it: an evaluation set at production size, metadata that lets you filter, and a permission model that works inside the search and not after it. That is what the rest of this post is about. If you are weighing whether an agent should retrieve at all, or whether a plain workflow would do, my decision guide on agents versus workflows covers that first step.
2. What published teams report, and how much to trust it
Before running anything, I collected the claims I would otherwise be tempted to repeat. I label each by who measured it, because a vendor's number on its own datasets is not the same kind of evidence as a result you can re-run.
| Claim | Source and date | Evidence label |
|---|---|---|
| Reranking is "the highest value 5 lines of code you'll add"; the best setup they found was 50 chunks in, 15 out | blog.abdellatif.io, 20 Oct 2025 | Practitioner-reported, no measurement given |
| Passing metadata (title, author) to the model alongside the chunk "improves context and answers by a lot" | Same post | Practitioner-reported, no measurement given |
| Contextual embeddings cut top-20 retrieval failures by 35% (5.7% to 3.7%); adding contextual BM25 made it 49% (to 2.9%); adding a Cohere reranker made it 67% (to 1.9%) | Anthropic, 19 Sep 2024 | Vendor-reported, on the vendor's own datasets |
| Model accuracy often drops when the relevant passage sits in the middle of a long input | Liu et al., arXiv 2307.03172, revised 20 Nov 2023 | Published research |
| If the knowledge base is under about 200,000 tokens, put all of it in the prompt and skip retrieval | Anthropic, same post | Vendor guidance as of Sep 2024; limits and prices change, so recheck |
Two things stand out. First, the only retrieval-failure percentages in that list come from a vendor, on its own data, and they measure retrieval quality only. Second, none of these sources tests the problems that show up in a company and not in a benchmark: a policy that exists in three versions, and a user who may read some documents and not others. I tested those directly.
3. The lab
I generated a corpus of fake policy documents. Each document has 40 single-sentence facts, about 570 words. A fact looks like this: "For the amber anchor 014 programme, the refund window is 37 days." The entity name is an adjective, a noun and a three-digit code, drawn from 58 adjectives, 46 nouns and 1,000 codes. There are 30 attribute phrases such as "refund window" and "audit frequency". Distractor sentences reuse those words freely but never reuse the exact name of a probe fact.
Each run plants 300 probe facts in documents at random positions. Every question has one shape: "What is the refund window for the amber anchor 014 programme?" A hit means the full probe sentence appears in at least one of the top-k chunks. I used BM25 (k1 = 1.2, b = 0.75), written by hand, over chunks of up to 120 words. I ran three seeds. The three-seed ranges below are the spread I saw, not confidence intervals.
def scores(self, q, mask=None):
s = np.zeros(self.n)
for w in set(tok(q)):
ids, tf = self.post[w]
s[ids] += self.idf[w] * tf * (K1 + 1) / (tf + K1 * (1 - B + B * self.lens[ids] / self.avg))
if mask is not None:
s = np.where(mask, s, -1.0) # masked chunks can never rank
return s
def chunk_sentence(sents, size=120):
out, cur, n = [], [], 0
for s in sents:
w = len(s.split())
if cur and n + w > size:
out.append(" ".join(cur)); cur, n = [], 0
cur.append(s); n += w
if cur: out.append(" ".join(cur))
return out
Those two excerpts and the description above are enough to rebuild the lab. I have not published the repository. It has 11 unit tests, which pass, and the full three-seed run takes about two and a half minutes on one core.
What this lab is not: it has no embedding model, no reranker and no language model, so it cannot say how a dense or hybrid retriever behaves. Its facts are key-value lookups. In a real system a lookup like "refund window for programme X" belongs in a table behind a tool call, not in a vector index. I used key-value facts because the right answer is unambiguous, not because RAG is the right tool for them.
4. Failure one: the corpus grows and recall falls without an error
From 1,000 documents up, I kept the same 300 probes and the same question wording, and grew the number of distractor documents around them. The 100-document row has only 100 probes, because the corpus has only 100 documents. The corpus grows by a factor of 400 across the table, and every query returns five chunks at every size.
| Documents | Chunks (seed 1) | Right chunk in top 5 | Right chunk in top 20 |
|---|---|---|---|
| 100 | 540 | 100.0% | 100.0% |
| 1,000 | 5,413 | 100.0% | 100.0% |
| 5,000 | 27,064 | 97.6% (97.3 to 98.0) | 100.0% |
| 10,000 | 54,112 | 87.1% (86.0 to 88.0) | 100.0% |
| 20,000 | 108,299 | 64.1% (63.0 to 64.7) | 99.2% (99.0 to 99.3) |
| 40,000 | 216,608 | 43.9% (41.0 to 48.0) | 91.8% (91.3 to 92.7) |
A team that tests at 1,000 documents sees a perfect score. The same team at 40,000 documents is wrong more often than right at rank five, and the system still returns five confident-looking chunks. This is the 100-document trap from the practitioner post, reproduced in a setting where I can see the mechanism.
The mechanism, in this corpus, is look-alike chunks. At 20,000 documents, 106 of the 300 probes in seed 1 missed the top five. For those 106, I looked at the chunk ranked first. It contained the exact three-part entity name in none of the cases. It did contain the same three-digit code in all of them, the same attribute phrase in 96%, and the same adjective and noun in 92% and 93%. A bag-of-words score adds up partial matches from different sentences in the chunk, so a chunk with the right code, the right attribute and one more matching word can beat the chunk that has the real answer. I read this as the cause because it is what the failures look like. I did not run a separate test that isolates it.
The gap between the two columns is the useful signal. At 20,000 documents the answer is in the top 20 for 99.2% of questions and in the top five for 64.1%. The retriever fetched the right chunk and ranked it too low. That is the case the practitioner's "50 in, 15 out" reranker is built for. I did not test a reranker, so I cannot say how much of that 35-point gap one would recover here. At 40,000 documents the top 20 misses 8.2% of questions, and no reranker can rescue a chunk that the first stage never fetched.
The same crowding shows up in agent memory, where near-identical entries compete for the same slots. In my mem0 audit, a duplicate check that only looked at the 10 nearest neighbours let six word-for-word repeated sentences through 141 times across 30 sessions in a test run. Different system, same shape: a check that works on a small store and quietly stops working on a large one.
5. Failure two: chunk boundaries cut a fact away from its name
Most pipelines start with fixed-size windows. I compared three chunkers on 1,000 documents. A probe sentence is "split" when no single chunk of its document contains the whole sentence. I count a hit only when the whole sentence is inside one chunk, because a value without its entity name is not an answer.
| Chunker | Chunks (seed 1) | Probe sentences split | Right chunk in top 5 |
|---|---|---|---|
| Fixed 120-word windows, no overlap | 5,014 | 7.2% (5.0 to 9.0) | 92.8% (91.0 to 95.0) |
| Fixed 120-word windows, 30-word overlap | 6,492 | 0.0% | 100.0% |
| Whole sentences packed up to 120 words | 5,413 | 0.0% | 100.0% |
Plain windows split 7.2% of the facts, and recall fell by the same amount. That is partly by definition, since I score only whole sentences, but the practical point holds: the half of a sentence that carries the value has no subject, so it cannot match a question about the subject. Overlap fixed it here because 30 words is longer than my longest sentence (17 words). It cost 29% more chunks than plain windows. Packing whole sentences cost 8% more chunks (5,413 against 5,014) and needs no tuning.
Real documents are harder. Tables, numbered clauses and multi-paragraph exceptions are longer than a 17-word sentence, so the overlap has to scale with the unit that carries the meaning, not with a token count you picked once. The practitioner post gives the same advice in plain terms: check that chunks are not cut mid-sentence and that each is a logical unit that captures information on its own. I would add that you can measure it. Take 100 facts you know the answer to and count how many sit whole inside one chunk.
6. Failure three: three versions of the policy, one confident answer
Enterprise documents are revised. The old version is rarely deleted, and a revision often changes one number in a document that is otherwise identical. I built three versions of every document in a 1,000-document base, 3,000 documents in total. The versions differ only in the value of each probe fact. Version 3 is current. I shuffled the documents so that no version had a tie-break advantage.
| Measure | No version filter | Current version only |
|---|---|---|
| Top 5 contains a chunk that answers the question | 97.2% (96.7 to 98.0) | 100.0% |
| Top 5 contains two or more different values | 97.2% (96.7 to 98.0) | Not measured; one version is eligible by construction |
| First-ranked answering chunk is the current one | 32.8% (30.3 to 34.4) | 100.0% |
With nothing to tell the versions apart, the current one ranks first about a third of the time, which is chance for three candidates. In 97.2% of questions the top five held conflicting values for the same fact. What the model does with conflicting values depends on the model and the prompt. I did not run one, so I make no claim about it. I will say what the retrieval layer handed over: three perfect-looking matches and no signal about which to trust. Nothing in that response looks like an error.
This test is not a forecast for your system. Real revisions differ by more than one number, and a dense retriever may separate them, partly by accident. But an accident is not a design. The fix is cheap and has nothing to do with retrieval quality: store a version and a status (current or superseded) at ingest, and filter to current inside the search. In the lab that took the first-ranked answer from 32.8% current to 100%.
7. Failure four: permissions applied after the search
Every enterprise deployment needs to answer one question: who may read this chunk? There are two places to apply the answer. After the search, you drop chunks the user may not see. Before it, you restrict the search to chunks the user may see. I gave each document one of ten access groups and let the test user read three of them, which is about 30% of documents (30.3%, 30.1% and 29.6% in my three 5,000-document corpora). Probe facts sit only in documents the user may read, so a perfect system finds every one.
I compared four strategies at 5,000 and 20,000 documents. Each seed had 83 to 92 permitted probes, so each cell below rests on about 260 queries.
| Documents | Strategy | Right chunk in top 5 | Chunks returned (of 5) | Queries with no context | Queries that saw an unauthorised chunk |
|---|---|---|---|---|---|
| 5,000 | No filter | 98.1% | 5.00 | 0.0% | 98.9% |
| 5,000 | Filter after search | 98.1% | 2.21 | 0.8% | 0.0% |
| 5,000 | After, fetching 4x as many | 100.0% | 4.81 | 0.0% | 0.0% |
| 5,000 | Filter inside search | 100.0% | 5.00 | 0.0% | 0.0% |
| 20,000 | No filter | 59.6% | 5.00 | 0.0% | 99.6% |
| 20,000 | Filter after search | 59.6% | 1.99 | 5.8% | 0.0% |
| 20,000 | After, fetching 4x as many | 96.2% | 4.84 | 0.0% | 0.0% |
| 20,000 | Filter inside search | 96.2% | 5.00 | 0.0% | 0.0% |
I read four things from this.
- No filter leaks, almost always. In 99% of queries at least one of the five chunks came from a group the user cannot read. That is what a retriever with no permission check does, so it is a baseline and not a finding about any product.
- Filtering after the search is safe and starves the model. It removed every unauthorised chunk, but only about two of the five chunks survived. At 20,000 documents, 5.8% of questions got no context at all. A recall number would not show this, because the post-filter recall is identical to the unfiltered recall by construction.
- Fetching more before filtering works, until visibility drops. Fetching four times as many candidates recovered everything here because the user could see about 30% of the corpus. If a user can see 3%, the arithmetic says you need roughly 30 times as many candidates. That last figure is my estimate from the ratio, not a measurement.
- Filtering inside the search also raised recall at 20,000 documents, from 59.6% to 96.2%. The reason is a smaller haystack: the search ignores the 70% of chunks the user may not read, so fewer look-alikes compete. That is a side effect, not a security property. It is a good reason to keep the permission filter in the query.
A caution about the lab. I assigned one group to each document at random and fixed the groups at index time. In a company, permissions change, inherit from folders and differ by chunk. If the access list is copied into the index at ingest, it goes stale the day someone leaves a team. My recommendation is to store a group identifier at ingest and resolve what a user belongs to at query time, from the system that owns the permissions. I did not test this.
8. What each failure means for the architecture
I would not call any of this exotic. Each failure is silent, cheap to measure and cheap to design out, if you plan for it before the first production query. Here is the summary, with the evidence behind each fix labelled.
| Failure | What you see | Number to track | First fix | Evidence for the fix |
|---|---|---|---|---|
| Corpus growth | Right chunk exists but ranks 6th to 20th | Recall at 5 and at 20, measured at production size | Rerank a wider candidate set, such as 50 in and 15 out | Practitioner-reported; not tested in my lab |
| Chunk boundaries | A value with no entity name attached | Share of known answer sentences that fit whole in one chunk | Pack whole sentences, or overlap by more than your longest unit | Lab: 7.2% split to 0% |
| Stale versions | Confident answer from a superseded document | Share of queries whose top 5 hold conflicting values | Version and status at ingest; filter to current | Lab: current ranked first 32.8% to 100% |
| Permissions | A leak, or too little context | Chunks returned per query, empty-context rate, unauthorised chunks returned | Filter inside the search, not after it | Lab: leak 99% to 0%, context 2 of 5 to 5 of 5 |
| Chunks without context | A chunk that never says which document or entity it belongs to | Recall of top-20 chunks on your own questions | Add the document context to each chunk before embedding or indexing | Vendor-reported: top-20 failures 5.7% to 2.9% (Anthropic, Sep 2024) |
9. What I would budget before building
These are my recommendations. They follow from the lab and from the published reports above, and I have not tested them on a client system.
- Build the evaluation set first, and run it at production size. Use questions with known answer chunks, and report recall at 5, 20 and 50. A test on a subset hides failure one by design. For the arithmetic of sample size: about 385 questions gives a worst-case 95% interval of plus or minus 5 points, and about 100 gives plus or minus 10. I wrote more about building such sets in how to evaluate an AI agent before deployment.
- Decide the metadata schema on day one. Document ID, version, status, access group and source system. Adding these after 5 million chunks are indexed means re-indexing.
- Read chunks by eye. Sample 100 random chunks and check that each one stands on its own and names what it is about.
- Re-run the evaluation each time the corpus doubles. My curve is flat for the first thousand documents and steep after five thousand. Yours will be different, and the only way to find out where is to measure.
- Ask whether you need retrieval at all. Anthropic's September 2024 guidance puts the line at roughly 200,000 tokens, about 500 pages. Check current model limits and prices before relying on that figure. Facts that are really rows in a table belong behind a query, not in an index.
If you are scoping a RAG build and want a second pair of eyes on the architecture, the AI agents page describes how I work with teams, and the free AI readiness assessment is a quick first pass. To put numbers on the cost side of a build, the ROI calculator is a starting point.
10. What I did not test
- I did not run an embedding model, a hybrid retriever or a reranker. A dense retriever fails differently, and my curve is not a prediction for one.
- I did not run a language model, so I have nothing to say about what it does with conflicting or missing context.
- My corpus is synthetic and regular. Real documents have tables, scans, headers, footers and exceptions. I tested none of that.
- My facts are single sentences. Answers that span several paragraphs will chunk worse than anything above.
- My permission model is one group per document, fixed at index time.
- Three seeds is a small number. The ranges I report show the spread I saw, nothing more.
- I did not verify the vendor and practitioner figures beyond reading the pages. They are reported as theirs.
Frequently Asked Questions
Why does RAG get worse as the document set grows?
Look-alike chunks compete for the same top slots. In my lab, a keyword retriever put the right chunk in its top five for 100% of questions at 1,000 documents, 87.1% at 10,000 and 43.9% at 40,000, with no error at any size. The right chunk was still in the top 20 for 91.8% of questions at 40,000. The corpus is synthetic and the retriever is lexical, so read this as a mechanism, not a rate for your system.
How many test questions do I need to evaluate a RAG system?
Enough that the interval is narrower than the change you care about. About 385 questions give a worst-case 95% interval of plus or minus 5 points, and about 100 give plus or minus 10. Run them against a corpus at production size, because my lab scored 100% at 1,000 documents and 44% at 40,000 on identically shaped questions.
Should I filter by permission before or after retrieval?
Inside the search. In my lab, filtering after the search returned only about 2 of 5 chunks per query and left 5.8% of questions with no context at 20,000 documents. Filtering inside the search returned all 5 chunks, with 96.2% recall against 59.6% and no unauthorised chunks. Fetching four times as many candidates before filtering matched it there, but the multiplier has to grow as the share of the corpus a user can see shrinks.
Do I need a reranker for production RAG?
Check the gap between recall at 5 and recall at 20 first. If the right chunk is in the top 20 but not the top 5, as with 99.2% against 64.1% at 20,000 documents in my lab, a reranker has something to reorder. A practitioner report describes 50 chunks in and 15 out as the best setup it found, and Anthropic reports a 67% cut in top-20 failures with contextual retrieval plus a reranker on its own datasets. I did not test a reranker.
When can I skip RAG entirely?
When the knowledge base is small enough to fit in the prompt, or the facts are really rows in a table. Anthropic's guidance in September 2024 was that a knowledge base under about 200,000 tokens, roughly 500 pages, can go straight into the prompt. Check current model limits and prices before relying on that figure, and use a database query for key-value facts.
Ready to Get Started?
Book a free 30-minute discovery call. We'll identify your biggest opportunities and show you exactly what AI automation can do for your business.