RAG — RAG Development Services

Common RAG Project Failures and Fixes

Direct answer

Most RAG failures are retrieval failures, not model failures: the right passage was never parsed correctly, never chunked sensibly, or never ranked high enough to reach the model. Fix them in pipeline order — parsing, chunking, hybrid retrieval with re-ranking, then prompting for grounded answers with citations — and measure each change against a fixed set of real questions so you know what actually helped.

A RAG demo works on the five questions it was built for. Production brings thousands of questions nobody planned for, documents that were never meant to be machine-read, and users who notice a single confident wrong answer. The good news is that failures cluster into a small number of patterns with known fixes. This guide walks through them in the order data flows through the pipeline, so you can find which stage is actually broken before changing anything.

Parsetables lost Chunkcontext split Retrieveright chunk ranked low Assemblelost in the middle Generateungrounded answer Debug left to right: a generation bug is often a retrieval bug in disguise

Key facts, with sources

  • A study of three production RAG systems (research, education, biomedical) catalogued seven failure points, from missing content and missed top-ranked documents to wrong format and incomplete answers. (Barnett et al., arXiv 2024)
  • Language models answer best when relevant information sits at the start or end of the context, and accuracy drops when it sits in the middle — even for long-context models. (Liu et al., 'Lost in the Middle')
  • Adding contextual embeddings, BM25 and re-ranking reduced top-20 retrieval failures from 5.7% to 1.9% (a 67% reduction) in Anthropic's tests. (Anthropic)

Diagnose before you fix

Every RAG complaint sounds the same — 'it gave a wrong answer' — but the cause can sit in any stage. The fastest diagnosis is to log, for each bad answer, the chunks that were retrieved. Then ask three questions in order. Is the correct information in the corpus at all? Was it in the retrieved chunks? Was it used correctly in the answer? The first 'no' tells you which stage to fix.

That is also the case for building a question set early: 50–200 real questions with known answers turns 'it feels worse' into 'retrieval hit rate dropped from 82% to 74% after the chunking change'.

SymptomLikely stageFirst thing to check
'I don't know' when the answer existsRetrievalIs the right chunk in the top 20? Try keyword search for the exact term
Confident answer, wrong numbersParsingOpen the stored chunk — is the table intact or scrambled?
Answer misses half the policyChunkingIs the rule split across chunks with no shared heading?
Right chunks retrieved, still wrongContext assembly / promptWhere in the context was the key chunk? Too many chunks?
Answers cite an outdated policyFreshnessAre old versions still indexed? When did sync last run?
User sees content they shouldn'tAccess controlIs filtering done at query time, before generation?
Work down the pipeline: fixing the prompt won't help if the right chunk never arrives.

Failures 1–2: parsing and chunking

Parsing failures are the most common and the least visible. PDF text extraction can merge two columns into nonsense, drop table structure so numbers lose their row labels, or repeat a page header inside every chunk. The model then answers fluently from garbage. Fix it by inspecting stored chunks by hand for your ten most important documents, and by using a layout-aware parser for anything with tables or columns.

Chunking failures happen when a rule and its exception land in different chunks, or when a chunk loses the heading that explains what it is about. Fixed-size character splits are the usual culprit. Split on document structure (headings, list items, table rows), keep chunks a few hundred tokens with a small overlap, and prepend the document title and section path to every chunk so 'Refunds are allowed within 30 days' still says which product it is about.

Prepend context to each chunk before embedding
def contextualize(doc_title: str, section_path: list[str], text: str) -> str:
    # A chunk that knows where it came from retrieves far better
    header = " > ".join([doc_title, *section_path])
    return f"{header}\n\n{text}"


chunk = contextualize(
    "Returns Policy 2026",
    ["EU customers", "Electronics"],
    "Refunds are allowed within 30 days if the seal is unbroken.",
)

Failure 3: the right chunk is never retrieved

Pure vector search is good at meaning and bad at exact strings — product codes, error messages, names, policy numbers. A user who types 'error E-4012' needs keyword matching. The standard fix is hybrid search: run vector and keyword (BM25) search in parallel and merge the lists, commonly with reciprocal rank fusion. Then add a re-ranker that scores the top 50–150 candidates against the question and keeps the best handful.

Also check metadata filters. A filter on product, region or document type both improves precision and cuts cost, but a wrong filter silently removes the right answer. Log filter values alongside every query.

Failure 4: the context is assembled badly

50–150 candidatesvector + keyword, fused Re-rank + dedupescore each vs the question 5–20 ordered chunksbest first, with sources Less context, better placed, beats more context

Retrieving more chunks feels safer, but stuffing the context window has a cost: research shows models use information at the start and end of a long context better than information buried in the middle. Twenty mediocre chunks can bury the one good one.

Send fewer, better chunks — re-ranked, de-duplicated, and ordered with the most relevant first. Group chunks from the same document together so the model sees a coherent passage instead of fragments, and include the source title with each so citations are possible.

Failure 5: answers that aren't grounded

Even with perfect retrieval, a model will sometimes fill gaps from its own training data. Three habits contain this. Tell the model to answer only from the provided sources and to say plainly when they don't contain the answer. Require citations — a source ID per claim — and check in code that cited IDs exist in the retrieved set. And treat 'I don't know' as a success state in your UI, with a route to a human or a search results page, rather than an error.

For high-stakes domains, add a verification pass: a second, cheaper model call that checks whether each sentence is supported by the cited chunk, and drops or flags the ones that aren't.

Failures 6–8: freshness, permissions, and drift

Stale answers come from indexes that are rebuilt by hand or never delete old versions. Sync incrementally from the source of truth, store a version or updated-at field on every chunk, and delete chunks when their document is removed or replaced.

Permission leaks are the failure that ends projects. Filter by the asking user's access at retrieval time — store an ACL or group list on each chunk and include it in the query filter — never by asking the model to withhold things. Anything in the context window can end up in the answer.

Drift is slower: new document types, new product names and new question styles gradually lower quality. Re-run the question set on a schedule and after every pipeline change, sample real low-rated answers weekly, and add the failures to the question set so they can't quietly return.

FailureFixHow to verify
Stale contentIncremental sync + delete on removal + version fieldChange a test doc; answer updates within the sync window
Permission leakACL filter in the retrieval querySame question, two users, different allowed answers
Quality driftScheduled eval runs + weekly failure reviewEval score trend per release

When to hire senior help

Bring in senior help when a prototype works in demos but retrieval quality, hallucination rates, or latency block a production launch, since diagnosing those issues requires experience across chunking, embeddings, and evaluation rather than general web engineering. A short engagement with someone who has shipped RAG systems is usually cheaper than months of trial-and-error tuning by a team learning on the job. If your stack includes React Native + Python + AI, a senior engineer who owns the full product beats coordinating multiple juniors.

Bottom line

Dhairya Senjaliya ships RAG — RAG Development Services projects worldwide — book a scoping call to discuss your specific situation.

Common pitfalls to avoid

  • ✕Budgeting only for the initial build and not for evaluation, monitoring, and index maintenance, which is where most RAG spend actually lands after launch.
  • ✕Hiring for prompt-writing skills when the hard work in RAG projects is data pipeline engineering, chunking, and retrieval tuning.
  • ✕Shipping a demo validated on 20 hand-picked documents and assuming it will hold up against the full corpus of thousands of messy PDFs.
  • ✕Building custom retrieval infrastructure from scratch for a standard use case when most enterprises now buy rather than build, often at lower total cost.

Frequently asked questions

Why does my RAG chatbot give wrong answers?

Usually because the right passage never reached the model — it was parsed badly, split across chunks, or ranked too low. Log the retrieved chunks for each bad answer and check whether the correct information was there before changing prompts or models.

Will a bigger or newer model fix RAG accuracy?

Rarely on its own. A stronger model uses good context better, but cannot answer from a chunk it never received. Retrieval fixes — hybrid search, re-ranking, better chunking — typically improve accuracy more per dollar.

How many chunks should I send to the LLM?

Enough to contain the answer, ordered best-first. Many systems retrieve 50–150 candidates, re-rank them, and send 5–20. Measure on your own question set; more context is not automatically better because models use the middle of long contexts less reliably.

How do I stop a RAG system from hallucinating?

Ground answers in retrieved sources, require citations and validate them in code, allow and design for 'I don't know', and add a verification pass for high-stakes answers. Most hallucinations disappear once retrieval reliably returns the right passage.

How do I enforce document permissions in RAG?

Store access metadata (user or group IDs) on every chunk and filter on it in the retrieval query, so restricted text never enters the model's context. Never rely on the prompt to keep restricted content secret.

How much does it cost to build a production RAG system?

A prototype on managed APIs and pgvector or a hosted vector database can be built in days, and embedding a million document chunks costs only a few dollars at current pricing. The real cost is engineering time: production hardening with ingestion pipelines, evaluation, and monitoring typically takes weeks to months of senior engineering effort.

Should we build RAG in-house or buy an off-the-shelf product?

Menlo Ventures data shows 76% of enterprise AI solutions were bought rather than built in 2025. Buying makes sense for standard use cases like support chatbots, while building pays off when your data, domain, or permission model is unusual enough that generic products retrieve poorly.

How long does a RAG project take to reach production?

Working prototypes commonly take one to four weeks, while hardening for production, including evaluation datasets, hallucination guardrails, and access controls, typically takes another one to three months. Gartner's finding that at least half of generative AI projects die after proof of concept largely reflects teams underestimating that second phase.

Bottom line: Dhairya Senjaliya ships RAG — RAG Development Services projects worldwide. Book a scoping call at https://dhairyasenjaliya.com/#book-call.

Sources

Related guides

Keep up with new guides

New deep-dive guides on React Native, Python, and AI ship regularly. Subscribe via RSS or follow on LinkedIn.

Want help implementing this?

30-minute scoping call · Clear milestones · Senior engineer ownership