LOAD-BEARINGfree
High-level designTier 11 · unit 2 of 5 · 15 min read

The RAG shape, and where it fails

Models have a training cutoff, no access to your private data, and a context window that is large but finite and priced per token. Retrieval-augmented generation is the standard response: find the relevant material, put it in the prompt, and let the model answer from it.

query ─▶ retrieve ─▶ rank ─▶ assemble context ─▶ generate ─▶ answer

Simple enough to draw in one line, which is exactly why it gets built badly. The framing that fixes most of it:

RAG is a search problem wearing a generation problem's clothes. The overwhelming majority of bad RAG answers are retrieval failures — the right passage was never in the prompt — and the overwhelming majority of teams respond by editing the prompt.

Four stages, four distinct failures

1. Chunking. Documents are split into retrievable units, and this unglamorous step decides more of your quality than anything downstream. Too small and you retrieve a fragment whose meaning lived in the surrounding paragraph. Too large and every retrieval spends context on mostly-irrelevant text. Worse, chunking that ignores document structure — splitting a table across two chunks, severing a heading from the section it governs, cutting mid-sentence — destroys meaning before retrieval starts, and no later stage can recover it. Chunk along the document's own boundaries, and keep the heading path with the chunk.

2. Retrieval. The trap here is a category error: semantic similarity is not relevance. Embeddings match topic. "How do I cancel my subscription" and "Cancellation policy amendments, 2019" are neighbours in embedding space and only one of them answers the question. Worse, embeddings are consistently poor at exactly the things enterprise queries hinge on — product codes, error identifiers, version numbers, proper nouns — because those carry meaning by identity rather than by context.

Which is why hybrid retrieval is the single highest-value default: run dense vector search and keyword search together and fuse the results. Keyword search is excellent at exact terms and terrible at paraphrase; embeddings are the reverse. They fail on different queries, which is the entire point.

3. Ranking and assembly. You retrieved fifty candidates and can afford ten. A reranker — a model that scores each candidate against the query directly rather than comparing precomputed vectors — is usually the largest single quality improvement available to an existing RAG system, because it is far more accurate than similarity and only has to run on the shortlist. And order matters: attention across a long context is uneven, so where a passage sits in the prompt affects whether it gets used. Putting the strongest evidence at the edges rather than buried in the middle is a real design choice.

4. Generation. Even with the right passage in front of it, the model can blend retrieved content with what it absorbed in training, or answer confidently from neither. Requiring citations to specific retrieved spans is the practical defence — not because citations are a feature, but because an answer that cannot point at its source becomes detectable rather than merely wrong.

The failure with legal consequences

Worth its own heading because it is the one that gets shipped: retrieval must be authorisation-aware, and the filter has to be inside the query.

An index built over every document will cheerfully return one this user may not see, and the model will summarise it into the answer. Filtering the results after retrieval is not equivalent — you have already ranked over documents the user cannot access, so you return too few results, and the shape of what is missing leaks information about what exists. Lesson 12.02's authorisation rules apply unchanged; what changes is that the enforcement point moved into a search index that was probably built by someone thinking about recall.

The index is a derived copy

Everything in Tier 7 applies. The index is a projection of your documents: it needs a pipeline, it has lag, it can be rebuilt, and — the part that catches people — a deleted document must leave it. Lesson 12.07's erasure fan-out includes the vector index, and an index nobody listed as a copy is exactly the copy that survives a deletion request.

What RAG does not fix

It does not make the model reason better; it changes what the model can see. And it is the wrong shape entirely for questions that require aggregating across the whole corpus — "how many customers churned last quarter" is a query against the analytical store from Tier 7, not a retrieval over ten documents. Retrieval finds passages. It does not count.

The trap

Measuring only end to end. When an answer is wrong you cannot tell whether retrieval missed the document, the reranker buried it, context assembly truncated it, or the model had it and ignored it — four different bugs with four different fixes, and one number covering all of them. Instrument every stage, and above all build a labelled set and measure retrieval recall: for these queries, did the passage that contains the answer make it into the prompt at all? It is the most useful number in a RAG system and almost nobody has it, which is why so much RAG debugging consists of rewording the prompt.

The tradeoff sheet

Problem solved
A model answering from training data it may not have, on a corpus that changes faster than any model can be retrained.
Rejected, and why
A longer context window with the documents pasted in is simpler and works until the corpus exceeds it. Keyword search with a summarisation step is cheaper and often good enough.
The trade
A retrieval pipeline whose quality ceiling is set at chunking time, an index that is a derived copy with its own permissions problem, and answers whose failures are plausible rather than obvious.
First to break at 10x
Retrieval, not generation. At 10x the corpus, the right passage stops appearing in the top results, and the model answers confidently from the wrong ones.
What it does to the bill
Embedding compute at ingest, index memory in proportion to the corpus, and a per-query cost that includes retrieval and a much larger prompt.
Day-2 operations
Evaluate retrieval separately from generation, on a fixed set, on every change. Without that split, a regression in chunking looks exactly like a worse model.