Skip to content
Ahmad Raza
Menu
All posts

6 min read

Why Your RAG Assistant Gives Wrong Answers (and How to Fix It in the Right Order)

A practical, step-by-step way to debug a RAG assistant that answers wrong: check retrieval first, fix chunking and metadata, then tighten the prompt, and know when RAG is the wrong tool.

Why Your RAG Assistant Gives Wrong Answers (and How to Fix It in the Right Order)
On this page

Why Your RAG Assistant Gives Wrong Answers (and How to Fix It in the Right Order)

A founder shows me their new AI assistant. It answers questions from their help docs, product catalog, or internal policies. In the demo it looks great. Then a real customer asks about the return window, and the assistant confidently quotes last year's policy.

The usual reaction is to rewrite the prompt. Add "be accurate." Add "only use the context." Try a bigger model.

That rarely fixes it. Most wrong answers from a RAG system are not a model problem. They are a retrieval problem. This post walks through how I debug them, in the order that actually saves time.

A quick refresher: what RAG does

RAG stands for retrieval-augmented generation. When a question comes in, the system:

  1. Searches your documents for the pieces most likely to contain the answer.
  2. Passes those pieces to the language model as context.
  3. Asks the model to answer using that context.

So there are two places it can go wrong. Either the search brought back the wrong pieces, or the model did something odd with the right pieces. You need to know which one before you change anything.

Step 1: Look at what was retrieved, not what was answered

This is the single most useful habit. For every wrong answer, log and read the exact chunks that were sent to the model.

Ask one question: was the correct answer inside those chunks?

  • If no, the model never had a chance. Fixing the prompt will not help. Go to step 2.
  • If yes, the retrieval did its job and the problem is in how the model used it. Skip to step 5.

In my experience the answer is "no" far more often than teams expect. Build a simple debug view that shows the question, the retrieved chunks with their source and score, and the final answer side by side. It pays for itself on day one.

Step 2: Fix how documents are split into chunks

Chunking is how you cut documents into pieces before indexing them. Bad chunking is the most common root cause I see.

Typical problems:

  • Chunks too small. A sentence like "Returns are accepted within this period" gets separated from the line that says what the period is.
  • Chunks too large. One chunk covers five topics, so it matches everything weakly and nothing strongly.
  • Splitting through structure. Tables, FAQ pairs, and step lists get cut in the middle.

What usually works better:

  • Split along the document's own structure: headings, sections, FAQ question-and-answer pairs, one product per chunk.
  • Keep the heading path with each chunk, for example "Shipping Policy > International > Customs fees". That gives the search engine and the model context about where the text came from.
  • Use a small overlap between neighboring chunks so a key sentence is not orphaned.

There is no universal perfect chunk size. Test a few options against real questions (step 7) and keep what wins.

Many wrong answers come from retrieving a chunk that is technically relevant but from the wrong context. Old versions of a policy. A different country's shipping rules. A discontinued product.

Store metadata on every chunk, such as:

  • Source document and URL
  • Last updated date and version
  • Region, language, or store
  • Product ID or category
  • Status (active, archived, draft)

Then filter on it before or during retrieval. If the user is on your Pakistan storefront, do not let the UK shipping page compete. If a policy was replaced, archive the old one instead of leaving both in the index.

Stale content is a data hygiene problem, not an AI problem. Delete or archive what should no longer be said.

Step 4: Make the search itself better

If the right chunk exists and is not being filtered out, but still does not show up near the top, look at the search.

Practical upgrades, roughly in order of effort:

  • Hybrid search. Combine vector (meaning-based) search with plain keyword search. Vectors are great for paraphrases. Keywords are better for SKUs, order numbers, error codes, and brand names. Many misses disappear once both are used.
  • Retrieve more, then rerank. Pull a wider set of candidates, then use a reranking model to sort them by how well they actually answer the question. Send only the top few to the language model.
  • Rewrite the query. Short follow-up questions like "what about for sale items?" do not search well on their own. Rewrite them into a full question using the conversation before searching.

Change one thing at a time and re-run your test set. Otherwise you will not know what helped.

Step 5: When the right context was there, tighten the generation

Now, and only now, work on the prompt and the model.

If the correct chunk was retrieved but the answer is still wrong, common causes are:

  • Too much context. Ten loosely related chunks bury the one that matters. Send fewer, better chunks.
  • Conflicting chunks. Two sources disagree. Fix the data, or tell the model which source wins (for example, the newest dated policy).
  • The model fills gaps. It blends its general knowledge with your docs. Instruct it to answer only from the provided context and to say clearly when the context does not contain the answer.
  • No citations. Ask the model to cite which chunk each claim came from. This makes wrong answers easy to trace, and makes users trust right answers more.

A plain "I don't have that information, here is how to contact support" is a much better outcome than a confident wrong answer. Design for it on purpose.

Step 6: Know when RAG is the wrong tool

Some questions should never go through document search at all.

  • Live data. Order status, stock levels, prices, and delivery dates change constantly. Fetch them from your database or API with a tool call, for example through an MCP server, instead of indexing snapshots of them.
  • Calculations. Totals, discounts, and shipping costs should come from your actual business logic, not from a model reading a pricing page.
  • Actions. Cancelling an order or issuing a refund is a tool with permissions and confirmation, not a retrieval problem.

A good assistant usually mixes both: RAG for policies, guides, and product descriptions, and direct tools for anything live or transactional.

Step 7: Build a small test set before you tune anything

You cannot improve what you do not measure, and you do not need a fancy platform to start.

  • Collect 30 to 50 real questions from support tickets, chat logs, or your sales team.
  • For each, write down the correct answer and which document should contain it.
  • After any change, run all of them and check two things: did the right document get retrieved, and was the final answer correct.

Keep the questions that failed in production and add them to the set. Over time this becomes your safety net, so a fix for one question does not quietly break three others.

A short checklist

When your RAG assistant gives a wrong answer:

  1. Read the retrieved chunks. Was the answer in them?
  2. If not, check chunking: structure-aware splits, heading paths, small overlap.
  3. Add metadata and filter out stale, wrong-region, or archived content.
  4. Improve search with hybrid keyword plus vector, reranking, and query rewriting.
  5. If the context was right, send fewer chunks, resolve conflicts, require citations, and allow "I don't know."
  6. Route live data, calculations, and actions to real tools instead of documents.
  7. Keep a test set of real questions and re-run it after every change.

Closing thought

RAG is not magic, and it is not broken either. It is a search system with a language model on the end. When the answers are wrong, treat it like any other search problem first, and most of the fixes become obvious.

If you are building an AI assistant on top of your docs, catalog, or store data and the answers are not trustworthy yet, I help teams design and fix RAG pipelines, agents, and MCP servers that connect AI to real systems safely. You can reach me through my portfolio.

  • 5 min read

    A 30-Day Agentic Commerce Rollout for a Next.js Store

    A practical, week by week plan to make a Next.js store ready for AI shopping agents: clean the data, ship a read only catalog MCP server, add carts, hand off to confirmed checkout, then log and cap everything.

  • 5 min read

    Fraud and Abuse When Agents Shop Your Checkout

    AI shopping agents look a lot like bots, and bots look a lot like agents. Here is how to tell them apart, where to put bot challenges, and why hosted checkout like Shop Pay is your best trust boundary.

  • 4 min read

    Hydrogen SDK vs Calling Storefront API Yourself in 2026

    Shopify's Hydrogen SDK now reaches beyond Remix and React Router into other frameworks. Here is what it gives you for agent ready storefronts, what a thin Next.js client gives you, and when each one pays off.