Skip to content
← Blog
Article

Why RAG works in the demo and fails in production

Your RAG pilot answered five questions perfectly and then fell apart on real traffic. Here is why that happens, how to diagnose it, and what actually fixes retrieval quality in production.

7 min readStallwart

The demo tested the wrong thing

RAG fails in production because the demo measured whether the system could answer questions you already knew the answers to, on documents you already knew contained them. Production asks questions nobody curated, over data nobody cleaned, and the gap between those two is where the pilot dies. The model is almost never the problem. Retrieval is.

A retrieval-augmented generation system has two halves: find the right context, then write an answer from it. Demos stress the second half, which large models already do well. Production stresses the first half, which is an information-retrieval problem your team probably has not built for. When a RAG pilot underperforms, the answer is usually confident and fluent and wrong, and it is wrong because the model was handed the wrong passages, not because it reasoned badly over the right ones.

So the diagnosis almost always starts in the same place: not the prompt, not the model, but what got retrieved. Before changing anything else, log the exact chunks passed into the context for a batch of failing queries and read them. In most stalled pilots the failure is visible in that log within ten examples.

The seven failures behind a stalled RAG pilot

Underperforming RAG systems fail for a small number of recurring reasons. Most pilots have three or four of these at once, which is why swapping the model changes nothing.

  1. Retrieval quality: the top-k passages do not contain the answer. Embedding similarity found text that looks related but is not, and no answer can be written from context that lacks the fact.
  2. Chunking mistakes: documents were split by a fixed token count that cut tables in half, separated a heading from its content, or isolated a clause from the sentence that qualified it. The chunk retrieves, but it is missing the part that mattered.
  3. Stale and dirty data: the index was built once and never refreshed, so it answers from last quarter's policy. Or it ingested duplicates, boilerplate headers, and navigation text that now outrank the real content.
  4. No evaluation harness: nobody can say whether a change helped, because there is no labeled set of questions with known-good sources. Every fix is a guess, and regressions ship silently.
  5. Context window misuse: the system stuffs twenty passages into the prompt assuming more context is safer. Relevant passages get buried, the model attends to the wrong ones, and cost per query climbs for a worse answer.
  6. Hallucination despite retrieval: the correct passage was retrieved but the model ignored it, blended it with its own priors, or filled a gap the context did not cover. Retrieval is necessary, not sufficient.
  7. Latency and cost: reranking, large context, and multiple model calls per query looked fine at ten requests and fall over at ten thousand, so the system is technically correct and operationally unusable.

How to diagnose which failure you have

You cannot fix retrieval by staring at final answers, because a wrong answer looks the same whether retrieval missed or the model ignored good context. Separate the two halves and measure each. This is the single most useful thing a stalled team can do.

First, evaluate retrieval in isolation. Take a set of real questions, label the passages that genuinely contain each answer, and measure whether retrieval returns them. If the right passage is not in the top-k, no prompt change will help, and you are looking at a chunking, embedding, or indexing problem. If the right passage is present but the answer is still wrong, the failure moved downstream to generation.

Second, read the retrieved chunks by hand for the failures. Cut tables, orphaned headings, and boilerplate are obvious on sight and invisible in an aggregate score. Third, check freshness: when was the index last built, and does the source of truth change faster than that. A large share of production RAG complaints are simply stale answers from a never-refreshed index.

What actually fixes it

The fixes are unglamorous and they compound. In rough order of how often they matter: fix chunking, then retrieval, then evaluation, then generation, then cost. Most teams reach for the model swap, which is last on the list.

Chunk on structure, not on a fixed token count. Split on headings, sections, and logical units, keep tables and their captions together, and attach metadata such as title, section, and date so retrieval and filtering have something to work with. Then improve retrieval: hybrid search that combines keyword and vector matching recovers exact terms, product codes, and names that pure embeddings miss, and a reranking pass over a larger candidate set lifts the genuinely relevant passage to the top before it reaches the model.

Build the evaluation harness before you tune anything else, because without it every other change is a guess. A modest set of real questions with labeled correct sources lets you measure retrieval recall and answer correctness on every change and catch regressions before they ship. For generation, ground the model explicitly: instruct it to answer only from the provided context and to say when the context does not contain the answer, which turns a confident hallucination into an honest gap you can then close at the retrieval layer. For cost and latency, retrieve fewer and better passages rather than more, cache what repeats, and measure at production traffic, not at demo scale.

Naive RAG versus a production retrieval system

The difference between a pilot that demos well and a system that survives production is not the presence of RAG, it is what surrounds it. The contrast is concrete.

A naive pipeline chunks by fixed size, retrieves by vector similarity alone, passes the top-k straight to the model, has no evaluation, and refreshes the index by hand when someone remembers. A production system chunks on document structure with metadata, retrieves with hybrid search and reranking, grounds generation against the context, runs a labeled evaluation set on every change, refreshes the index on a schedule tied to how fast the source changes, and is instrumented so you can see retrieval quality, latency, and cost per query in real traffic. Same three letters, different engineering problem.

That surrounding system is the work, and it is the work Stallwart does: retrieval built around your data, your documents, and your freshness requirements, with evaluation and observability treated as part of the build rather than a later phase. If a RAG pilot underperformed, the fix is almost never a better model. It is the retrieval system the pilot was allowed to skip.

The short version

  • RAG fails in production because retrieval hands the model the wrong passages, not because the model reasons badly over the right ones.
  • Diagnose by measuring retrieval in isolation: label the passages that contain each answer and check whether the top-k returns them.
  • Fix chunking first (split on structure, keep tables whole, add metadata), then retrieval (hybrid search plus reranking), then evaluation.
  • Retrieving the right passage is necessary but not sufficient; ground the model to answer only from context and admit gaps.
  • A labeled evaluation set is the prerequisite for every other fix, because without it every change is an unmeasured guess.
The short answers

Questions this raises

Why does my RAG system work in testing but fail on real questions?
Testing usually uses curated questions over clean documents you already know contain the answers, which stresses generation, the part large models handle well. Real traffic stresses retrieval over uncurated data, which is where most failures live. Log the exact chunks retrieved for failing queries and you will usually see the problem within ten examples.
How do I know if the problem is retrieval or the model?
Separate the two halves and measure each. Label the passages that genuinely contain each answer and check whether retrieval returns them; if the right passage is missing from the top-k, no prompt or model change will help. If the right passage is present but the answer is still wrong, the failure is in generation, not retrieval.
What is the most common cause of bad RAG answers?
Retrieval quality: the passages passed to the model do not actually contain the answer, usually because of poor chunking or embedding-only search that matches text that looks related but is not. Chunking that cuts tables or separates headings from content is the single most common culprit, and it is visible the moment you read the retrieved chunks by hand.
Does a bigger context window fix RAG problems?
Rarely, and it often makes them worse. Stuffing more passages into the prompt buries the relevant ones, invites the model to attend to the wrong context, and raises cost and latency per query. Retrieving fewer and better passages, with a reranking pass, beats retrieving more.
How do you improve retrieval quality in a RAG system?
Chunk on document structure rather than a fixed token count, keep tables and their captions together, and attach metadata like section and date. Then use hybrid search that combines keyword and vector matching to recover exact terms and names, add a reranking pass over a larger candidate set, and build a labeled evaluation set so you can measure whether each change actually helped.

Recognize this in your own operation?

Bring us the version of it happening in your business and we will tell you which part a system can take over.