Why RAG fails in production (And how to fix it)


Let me share one thing which may shock you: up to 70% of Retrieval-Augmented Generation (RAG) programs fail in production. Yes, you learn that proper. While RAG seems to be magical in demos and proof-of-concepts, the truth of production deployment tells a really completely different story.
I’m Shubham Maurya, Senior Data Scientist at Mastercard with eight years of expertise constructing AI options. Throughout my journey growing every thing from shopper credit score options to multi-agent programs, I’ve seen firsthand how RAG can go from hero to zero when it hits the actual world. Today, I would like to stroll you thru the challenges we have confronted and, extra importantly, how we have solved them.
What precisely is RAG (And why must you care)?
Before diving into the issues, let’s get clear on what RAG truly means. RAG stands for Retrieval-Augmented Generation – three easy phrases that pack a robust punch:
- Retrieve data out of your knowledge sources
- Augment that data into your prompts
- Generate responses utilizing Large Language Models (LLMs)
Think of it this fashion: when somebody asks your system “What’s the authorization charge for nation XYZ?”, RAG finds the related data out of your databases, provides it to the immediate, after which lets the LLM generate an correct, grounded response.
But why not simply use highly effective LLMs?
You may be questioning – with fashions like GPT-5 and Claude obtainable, why trouble with RAG? Here’s the factor:
Your knowledge adjustments always. We have shoppers whose knowledge refreshes weekly. Pre-trained fashions merely cannot sustain with that tempo of change.
Domain-specific data issues. Ask ChatGPT about Mastercard’s particular transaction decline codes, and you will get a clean stare. It would not have entry to our inside data.
Retraining is dear and impractical. You cannot repeatedly fine-tune LLMs each time your knowledge adjustments. It’s pricey, time-consuming, and requires vital experience.
Explainability is essential. With RAG, you’ll be able to see precisely what data was retrieved and why sure solutions have been generated. Try explaining a pure LLM’s output – good luck with that!

The 4 horsemen of RAG failure
Let me stroll you thru the 4 major challenges that trigger RAG programs to fail in production:
1. Knowledge drift: When yesterday’s fact turns into at this time’s lie
Here’s an actual instance: You construct a RAG system when rates of interest are 4%. Six months later, they’ve jumped to 5.5%. But your system? It’s nonetheless confidently telling customers the speed is 4%.
Or take into account what occurred to us at Mastercard. We had a large transaction desk that we determined to cut up into home and worldwide transactions. Our text-to-SQL resolution stored attempting to question the outdated desk that not existed. Result? Errors in all places.
2. Retrieval decay: Death by knowledge development
In your POC with a small dataset, retrieval works fantastically. Fast ahead six months, and you have got tens of millions of paperwork. Suddenly, your system cannot discover the needle in the haystack anymore.
We skilled this firsthand when attempting to discover high retailers and service provider codes. The system would retrieve the identical redundant data a number of instances, lacking essential particulars due to our context dimension limits.
3. Irrelevant chunks: The data overload drawback
Imagine asking for a easy definition and getting a 10-page dissertation in response. That’s what occurs when your retrieval brings again an excessive amount of irrelevant data. LLMs, identical to people, get confused and begin hallucinating when overwhelmed with knowledge.
4. The analysis hole: Flying blind
This may be probably the most painful problem. Have you ever given suggestions utilizing these thumbs up/down buttons in ChatGPT? Exactly – no one does. So how are you aware in case your production RAG system is deteriorating? By the time customers lose belief and cease utilizing it, it is already too late.
How we fastened these issues (And how you’ll be able to too)
Smarter retrieval methods
Hybrid search: We do not simply depend on semantic search or lexical search – we use each. When somebody asks about “ISO 8583 area 55 definition,” lexical search finds the precise match. For broader questions, semantic search understands context. The magic occurs once you mix them.
Graph-based RAG: For our text-to-SQL options with a number of interconnected tables, conventional RAG would miss essential becoming a member of situations. Graph-based retrieval understands relationships between tables, dramatically decreasing errors and hallucinations.
Making RAG conscious of adjustments
We developed a schema evolution monitoring system. When our transaction desk cut up into home and worldwide tables, our RAG system mechanically detected this modification. Now, when customers question transactions, the system is aware of in regards to the new construction and generates right SQL queries.
This strategy works for any evolving data – from altering rates of interest to up to date privateness definitions post-COVID.
Performance optimization
With 10 million data in our vector database, retrieval was painfully gradual. Our resolution? Intelligent segmentation. When somebody asks about column definitions, we solely search the schema section. Analytics questions? We search the analytics section. Response instances dropped dramatically.
Adaptive context sizing
Not all questions want the identical quantity of context. Asking for “high 5 science fiction books”? We retrieve possibly 10-15 paperwork. Asking for “all obtainable science fiction books”? We adapt and retrieve far more.
We use LLMs to detect person intent and alter retrieval accordingly. It’s not one-size-fits-all anymore.
Smart summarization
Before feeding retrieved data to the LLM, we summarize it. Think about it – would you like a three-page doc or a concise paragraph answering your query? LLMs are the identical. This not solely improves accuracy but additionally reduces prices through the use of much less of the LLM’s context window.
Continuous suggestions loop
Instead of counting on person suggestions (which hardly ever comes), we:
- Log all person queries
- Use libraries like RAGAS to consider retrieval high quality
- Check for groundedness, relevancy, and hallucinations
- Generate artificial check knowledge based mostly on actual queries
- Re-evaluate and fine-tune month-to-month or weekly

Real-world functions that really work
These aren’t theoretical options. We’ve efficiently applied them in:
- AI governance: Automating documentation for EU compliance utilizing policy-based RAG
- Diagnostic analytics: Multi-agent programs serving to clients enhance authorization charges
- Text-to-SQL: Natural language interfaces that appropriately question complicated databases
- Automated testing: Tools that write unit exams and run pipeline checks
The way forward for RAG
Looking forward, I see three thrilling developments:
- Self-retrieving LLMs: Where retrieval turns into simply one other software the LLM can use autonomously
- Graph + RAG integration: Deeper integration for dealing with complicated, interconnected knowledge
- Multi-agent orchestration: Systems that know after they want extra data and mechanically retrieve it
The backside line
RAG in production is difficult, nevertheless it’s not unimaginable. The secret’s understanding that what works in a demo hardly ever scales to production with out vital adaptation. By implementing smarter retrieval methods, making your system conscious of adjustments, optimizing efficiency, and creating steady suggestions loops, you’ll be able to construct RAG programs that really ship on their promise.
Remember: each failed RAG system is a chance to study and enhance. The challenges are actual, however so are the options. Start with understanding your particular use case, implement these methods incrementally, and at all times preserve measuring and adapting.
Because on the finish of the day, a RAG system that works 70% of the time in production is infinitely extra worthwhile than one which works 100% of the time in a demo.