All posts

"Your retrieval is the problem, not your model"

When a RAG system gives a bad answer, the instinct is to blame the model and reach for a bigger one. Most of the time the model was never shown the right material. One debugging habit, read what was retrieved before judging what was generated, resolves the majority of cases.

RAG4 min read15 September 2026by Ahmed
"Your retrieval is the problem, not your model"

A bad answer comes out of your RAG system and the team's first instinct is to blame the model. Swap it for the bigger one, rewrite the prompt, add "you must answer only from the provided context" in increasingly stern language. I understand the instinct, the model produced the words, so the model gets the blame, but in my experience the majority of bad RAG answers have nothing to do with generation. The model was never shown the right material, and no model answers well from the wrong page.

There is one debugging habit that settles this in minutes, and it is the first thing I teach anyone who joins a retrieval project: before you judge the answer, read what was retrieved. Pull the exact chunks that went into the context window for that specific question and look at them. Not the corpus, not the source document you know contains the answer, the actual retrieved set. Teams that have never done this are routinely shocked by what they find. The answer is not there. Or a fragment of it is there, sandwiched between five chunks of irrelevant boilerplate that happened to share vocabulary with the question.

Once you look, the diagnosis splits cleanly. If the answer is absent from the retrieved chunks, you have a retrieval problem, and prompt-tuning is a waste of a week. If the answer is present and the model still botched it, you have a generation problem, real, but far rarer than assumed. I would put the split at something like four to one in favour of retrieval across the systems I have debugged, and the ratio gets more lopsided as the corpus gets larger and messier.

"Your retrieval is the problem, not your model"

Retrieval failures themselves come in a few recognisable shapes. Vocabulary mismatch: the user says "holiday allowance", the policy says "annual leave entitlement", and the embedding distance is wider than you would hope. Ranking failure: the right chunk exists and lands at position twelve while your top-k is five, near misses like this are invisible unless you log scores. Chunking failure: the answer straddles a boundary, so no single chunk contains it and none ranks well. And corpus failure, the humbling one: the answer is simply not in the indexed documents, because the document everyone assumed was ingested never was, or the version that was ingested predates the answer.

That last shape deserves emphasis, because the model masks it. When retrieval returns nothing useful, a well-behaved model says it cannot find the answer, and users report "the AI is dumb". A less well-behaved one improvises from training data, and users report nothing at all until the improvised answer causes damage. Either way, the failure gets filed under "model quality" when the actual bug is a gap in ingestion. I have seen a team benchmark three different models against each other, at real expense, trying to fix answers whose source document was never in the index.

The fix for all of this starts with plumbing, not intelligence. Log the retrieved chunk IDs, their scores, and the final context for every single query, in whatever tracing tool you like, but log it. This is cheap, and it converts every user complaint from a mystery into a two-minute lookup. Then build a small retrieval eval: thirty to fifty real questions, each labelled with the passage that answers it, and a script that measures how often that passage appears in the top-k, recall at k, if you want the formal name. No model in the loop, no LLM judge, just hit-rate. It runs in seconds and it tells you whether retrieval changes help or hurt before your users do.

With that measurement in place, the levers rank themselves. Sometimes the win is hybrid search, because your users query with exact codes and names that pure vectors fumble. Sometimes it is re-chunking, because the eval shows answers being split at boundaries. Sometimes it is query rewriting, because users write terse fragments and documents are formal prose. Occasionally it genuinely is the model, but now you can prove it, because retrieval hit-rate is high while answers are still wrong.

The pattern underneath is old: measure before optimising. Generation is the visible part of a RAG system, so it absorbs the blame, the budget, and the upgrade cycles, while retrieval, the part that decides what the model even sees, goes uninstrumented. Flip that attention around and most "the AI keeps getting it wrong" tickets become ordinary, fixable engineering.

If your system is producing answers you cannot explain and you would like the two-minute lookup instead of the mystery, this is exactly the work I do. Get in touch via the contact form.

Senior engineering roles — or production AI consulting?

I'm open to senior AI and software engineering roles and to selective consulting on agents, RAG, and LLM automation in production. If this post resonates — as a hiring manager or as someone shipping similar work — get in touch.

Get in touch

© 2026 Ahmed Fareed. All rights reserved.

LOADING