5 Painful Lessons from Building an Enterprise RAG System (And How to Fix Them)

Running RAG (Retrieval-Augmented Generation) in production is not "dump your docs into a vector DB and connect an LLM." Enterprise RAG systems tend to break in five places (document parsing, chunking, data freshness, hallucination and context cost), and each has a practical fix rooted in data engineering and search quality rather than a fancier AI framework.
Do you even need RAG?
Not always. If your whole knowledge base is small, Anthropic's guidance is to skip retrieval: for a knowledge base under about 200,000 tokens, you can put all of it in the prompt and use prompt caching to keep it fast and affordable. RAG earns its complexity when the document set is too large or changes too often for that.
1. Why does RAG ignore tables and images?
Because standard text extraction can't read them properly. Internal documents are full of multi-column tables, diagrams and scanned pages. A plain PDF text extractor can pull table cells out of order, so the vector DB ends up storing text that no longer lines up with its headers. Ask "What was Q3 revenue?" and the model can't match the number to the right row.
How to fix it: Route complex pages through OCR or a multimodal (vision) model. Render the page as an image, ask the model to convert it into a Markdown table, and embed that output. It costs more time and compute at ingestion, but the stored text actually reflects the table.
2. How should you chunk documents?
By meaning, not by a fixed size. Cutting every 1,000 tokens can split a sentence like "The exceptions to this policy are..." from the list that follows, and neither chunk makes sense alone.
How to fix it: Combine semantic chunking with a parent-child structure.
- Split documents along real boundaries such as sections and paragraphs.
- Index small "child" chunks so search can match precisely.
- When a child matches, pass its full "parent" section to the LLM so it sees the surrounding context.
Anthropic's "contextual retrieval" is another route to the same goal: it prepends a short, generated description of where each chunk sits in its document before embedding. In its tests, that alone cut the retrieval failure rate by 35%.
3. Why does RAG cite outdated documents?
Because the vector DB doesn't update itself when the source changes. Policies, manuals and team pages change constantly, but the index still holds whatever was loaded at the last sync, so the assistant can confidently quote a rule that no longer applies.
How to fix it: Store metadata (document ID, last-modified date, version, access permissions) with every chunk. Run a scheduled job that compares source modification dates with the index, deletes chunks from removed documents and re-embeds only the ones that changed. The permission field also lets you filter results so users never retrieve documents they couldn't open directly.
4. Does RAG still hallucinate?
Yes. RAG reduces hallucination but doesn't eliminate it. When the retrieved context doesn't contain the answer, the model may fill the gap from its training data, especially for internal acronyms or product names it has never seen.
How to fix it:
- Constrain the prompt: Tell the model to answer only from the provided context and to say it can't find the answer otherwise.
- Use hybrid search: Embeddings are weak at exact matches like product codes or department names. Combine vector search with keyword search (BM25) and merge the lists, for example with Reciprocal Rank Fusion, which Elasticsearch documents as a method for combining result sets with different relevance indicators. Anthropic reports that adding BM25 to its contextual embeddings raised the failure-rate reduction from 35% to 49%.
5. Why do RAG costs explode?
Because every extra retrieved document is extra input tokens on every question. Cost rises with the amount of context you send, and longer prompts are also slower.
Long context can hurt answers too. The "Lost in the Middle" study by Liu et al. found that language models are most accurate when relevant information is near the start or end of the input, and less accurate when it sits in the middle of a long context.
How to fix it: add a reranker.
- Retrieve a generous candidate set in the first pass.
- Rescore the candidates with a reranking model (typically a cross-encoder) against the actual question.
- Send only the best-scoring chunks to the LLM.
In Anthropic's experiments, reranking on top of contextual embeddings and BM25 cut retrieval failures by 67%. How many chunks to keep is worth testing on your own data: Anthropic found passing 20 chunks worked better than 5 or 10 in its setup, so "fewer" isn't automatically better.
What is RAG really?
RAG is a search engineering project with an LLM at the end. Before blaming the model, check how clean, current and relevant the context you are giving it actually is. Most of the work, and most of the gains, sit in parsing, indexing and retrieval quality rather than in the choice of AI framework.


