RAG in production: what actually breaks
Most of the distance between a RAG demo and an assistant you can rely on is dull engineering. Retrieval quality and an evaluation harness come first.
part 2 of 2 · Data and AI that hold up in productionthe ideaWhat makes a RAG assistant dependable is everything around the model.
after reading, you can- Trace a wrong answer to retrieval or generation first. Leave the prompt alone until you know which.
- Stand up a golden-set eval that scores retrieval and answers separately. If either one drops, the build fails.
- Make the index honor document permissions. Have it cite its chunks, and refuse if nothing relevant is returned.
You can build a RAGdefinitionRetrieval-augmented generation, or RAG. A search first pulls relevant passages from your documents, and a language model writes the answer from those passages. demo in an afternoon. A RAG system takes an engineering program. The demo never has to answer one question. When the retriever hands back the wrong context, does anyone notice before the user does? Everything that separates a dependable assistant from a liability lives in that gap.
We've watched the same three failure modes take down systems that were otherwise well built. In none of them was the model short on cleverness. Each time, somebody was making a claim that nobody measured.
Retrieval fails silently, and the model papers over it
Hallucination gets the attention. In production we more often see a confident answer built on the wrong passages. Bad chunkingdefinitionCutting documents into pieces before indexing. Cut by a fixed token count and a policy clause can end up in one chunk while its exceptions sit in the next one. splits a policy clause from its exceptions. Pure dense retrieval misses the exact identifiers, part numbers and acronyms keyword search would have caught. A stale index serves last quarter's pricing with this quarter's confidence. The model then writes fluently over the wrong evidence, and the answer looks perfectly plausible.
The fixes are unglamorous and well understood. Use hybrid retrieval that combines BM25definitionA classic keyword-ranking method. It reliably finds exact part numbers and acronyms that embedding search can miss. with dense embeddings, and put a rerankerdefinitionA second model that re-scores whatever the search returned, so the passages that matter most reach the language model first. over the candidate set. Chunk along the document's structure instead of a fixed token count. Treat index freshness as an SLO with an owner. Watch for embedding driftdefinitionSwitch embedding models without re-indexing and this is what you get. The stored vectors and the new queries no longer share a coordinate system. as well. Swap the embedding model without re-indexing the corpus and every stored vector now sits in a foreign coordinate system. None of this is research. It's what turns recall you assume into recall you can state.
Build the evaluation harness before the second feature
Without an eval harness, every change to a RAG system is a guess ratified by a demo. The harness is a golden setdefinitionA fixed collection of real questions from users, with known source passages and reference answers. It's what every system change is scored on.: a few hundred real questions with known source passages and reference answers, drawn from actual user queries rather than what the team imagines users ask. Each one is scored on two independent axes: retrieval quality (recall@k, precision of the retrieved context) and generation quality (faithfulness to the retrieved passages, answer relevance). Score them separately, or you'll spend a week tuning prompts to fix what is actually a chunking bug.
Then wire the harness into CI. A new embedding model runs the golden set, and so does a chunking change, a prompt edit or a reranker swap, and each one blocks on regression the way a failing test would. LLM-as-judge scoring keeps this affordable, with the usual caveats. Calibrate the judge against a human-labeled sample, pin its version and audit where it disagrees. The harness won't tell you the system is good. It will tell you it just got worse, and it'll tell you before your users do.
A RAG system with no evaluation harness is an anecdote generator.
# golden set runs on every change, like tests, because it is one $ rag-eval run --golden-set v9 --diff main retrieval recall@5: 0.87 context precision: 0.74 generation faithfulness: 0.91 vs main: −0.04 regression: 12 questions worse · chunking suspected ✗ merge blocked · evidence attached to PR
The plumbing is the product
What makes a RAG assistant dependable is everything around the model. Start with permission-aware retrieval. The index has to respect document ACLs at query time, or the assistant becomes the most efficient data-leak mechanism in the company, and syncing those ACLs from the source systems is its own pipeline with its own freshness SLO. Then ingestion. Documents change, so the pipeline re-embeds on update and writes tombstones for deletions, which means a retracted policy stops being retrievable the day it's retracted. Without that, what you have is an archive.
Third, the system should be easy to check. Each answer cites the chunks it used, so when an answer is wrong someone can see why within minutes. If retrieval confidence is low, the system replies "I don't have a good source for that" and leaves it there. In every deployment we've reviewed, that scripted refusal has beaten a fluent guess. We also log each query, the chunks retrieved and the citation clicks, and the failures go back into the golden set. That feedback is what improves the system month after month, more than the choice of model.
What to take from this
- 01
Assume retrieval fails silently. Hybrid search, reranking, structure-aware chunking and an index freshness SLO are where you start, before any polish.
- 02
Build a golden-set eval harness before the second feature, score retrieval and generation separately, and gate merges on regression.
- 03
Ship the plumbing. Make retrieval ACL-aware and cite at chunk level. When confidence is low, refuse honestly. Feed failures back into the golden set with telemetry.
Three questions, about a minute
Pick an answer and we'll tell you if it's right, and why it is or isn't. The score stays in this browser.
-
Q1Prompt tweaks aren't fixing wrong answers, and nobody scores retrieval on its own. What should the team do first?
show the answer
A. Score retrieval and generation separately against a golden set Without separate scores you can spend a week tuning prompts to fix what is really a chunking bug. Score retrieval and generation apart and the failure shows itself.
-
Q2Questions about part numbers keep getting answers that cite the wrong passages. What fix does the post point to?
show the answer
D. Add BM25 keyword search alongside dense retrieval Embedding search struggles with exact strings like part numbers and acronyms. Keyword search handles them well. Run BM25 next to the embeddings and the right passages start coming back.
-
Q3A policy was retracted last week. The assistant is still quoting it. Where did the system break?
show the answer
C. The ingestion pipeline, which should tombstone deleted documents Ingestion should re-embed a document when it changes and tombstone it when it's withdrawn. Do that, and a retracted policy stops showing up the day it's retracted.