Language ModelsExplainer

What Is RAG? A 1,534-Question Test Where Retrieval Only Took Things Away

Retrieval-augmented generation finds the relevant material and puts it in the model's window before it answers. In my Text-to-SQL benchmark the retrieval step kept 96.5% of the needed tables on average and left accuracy unchanged. Here is why, and how to tell whether retrieval will help on your data.

By Vladimir Beskorovainyi

7 min read

Illustration: BESK TECH

RAG, retrieval-augmented generation, is a way of answering with a language model where the system first searches a store of documents for the parts relevant to the question and puts them into the model's context window, so the model answers mainly from that material. It helps when the material the model needs is not already in the window. When everything relevant already fits, retrieval can only remove things: in a benchmark of 1,534 Text-to-SQL questions, an embedding retriever kept 96.5% of the needed tables on average and left accuracy unchanged.

RAG, retrieval-augmented generation, is the step where a system looks things up before the model answers. In my own benchmark that step kept 96.5% of the material the model needed and did not change the score. Against simply giving the model everything, it got 33 questions right that the full version missed and 39 wrong that it had right. That result holds under one condition, and production usually breaks it. What carries over are two lessons about how to judge retrieval at all.

What RAG is

The system takes the question, searches a store of documents for the parts that look relevant, puts those parts into the model's context window, and only then asks the model to answer. The model answers mainly from the material in front of it rather than from what it absorbed in training.

A typical case is a support assistant over a 2,000-page product manual. The manual is cut into chunks, a few paragraphs each, and stored. When a customer asks how to reset a device, the system finds the three or four chunks closest to the question and hands only those to the model.

The search is usually done by embedding: the question and each chunk are turned into vectors, and the chunks nearest to the question are taken. It can also be plain keyword matching. Either way the job is the same: choose what goes into the window.

Why people use it

Two reasons. The model does not know your documents, because they were never in its training data. And what it does know goes stale. Retrieval fixes both by bringing current, private material to the model at the moment of the question. Given the source, the model is also less likely to make things up, though not immune to it.

That is the case for RAG. Here is a case where it did nothing.

What I measured

The task was Text-to-SQL: turn a question in plain English into a database query. I ran it on the BIRD development set, 1,534 questions over real databases, with open models deployed on my own infrastructure and through APIs.

Text-to-SQL has a retrieval step of its own, called schema linking. A database has many tables. Instead of giving the model the whole schema, you search for the tables the question is about and give it only those. It is RAG in miniature: retrieve, then generate. One difference matters from the start. A database schema is small next to a document store, small enough that the whole of it fits in the window. That is what made the comparison below possible.

I tested two retrievers, one matching words and one matching embeddings, against the obvious baseline of no retrieval at all, where the whole schema goes into the window.

Word-matching retrieverEmbedding retriever
Needed tables kept, on average93.95%96.53%
Questions where a needed table was dropped12.78%8.34%
Questions where the schema was cut down74.0%57.5%

After correcting for the number of comparisons, neither retriever improved accuracy significantly for any model it was tested on. The word-matching one made things worse for one model: it cost Llama-3.3-70B 4.2 points. The embedding retriever, tested on three models, did no better than giving the model everything. On Qwen2.5-Coder-32B through an API it scored 54.11% against 54.50% for the full schema, 33 questions won and 39 lost, p = 0.56.

Why it did nothing

Because retrieval here could only subtract.

The baseline already had the whole schema in the window. Its recall of the needed tables was 100%, by construction. No retriever can beat that. The best it can do is lose less: the embedding retriever at 96.5% lost less than the word-matching one at 94%, but neither found anything the model did not already have.

The retriever does change individual answers, 33 one way and 39 the other. In the mean they cancel.

And the model was wrong on about 45% of the questions regardless. With recall that high, the bottleneck was not which tables made it into the prompt. It was the joins between them and what the values in them mean. Most of the wrong answers ran without any error and simply returned the wrong result: about 83% for Qwen2.5-Coder-32B through the API. A query that runs and answers a different question looks exactly like a correct one.

The one technique in the same study that helped consistently was not retrieval. When a query failed to run, the error went back to the model for up to two repair rounds. That added 1.2 to 4.4 points, almost entirely by fixing queries that did not run: for the same model they dropped from 115 to 24. The queries that run and answer the wrong question, the real bottleneck here, it cannot see at all.

The condition, and where production breaks it

This result depends on one thing: the whole schema fit in the window. That made "give it everything" a real option, with perfect recall, and against perfect recall a retriever can only subtract.

Production usually breaks that condition. A warehouse with five hundred data marts does not fit in any window. There retrieval is not an option to compare against the full schema; it is the only way in, and a measurement like mine says nothing about how well it works.

What carries over are two lessons about judging retrieval at all.

What carries over: when it fits, retrieval does not add

When everything relevant fits, retrieval does not add accuracy, and on weaker models it takes some away. On CodeLlama-7B the embedding retriever did worse than the word-matching one by 2.80 points, 59 questions won and 102 lost, significant after correcting for the number of comparisons. The better retriever by recall was the worse one by accuracy.

What carries over: recall is the wrong yardstick

That last result is the second lesson. Recall on its own is a poor way to judge a retriever. 96.53% against 93.95% looks like a clear win, and on Qwen2.5-Coder-32B it produced a difference in accuracy indistinguishable from zero. On CodeLlama-7B the higher-recall retriever lost.

The measure that matters is how many queries a retriever breaks by dropping a table they needed, not how large a share of tables it finds. A retriever that finds 96% on average and drops a needed table on 8% of questions has put those 8% at risk, whatever its average looks like.

When it does help

A November 2026 preprint shows retrieval paying off. Its authors retrieved similar solved problems for competitive programming and found that retrieval substantially improved the models. Read the setup, though: they evaluated the test problems that have similar instances in the store. Retrieval helped because it brought something the window did not have.

The same logic now applies to tools. On November 19, 2026, Google released Tool Retrieval for the Gemini API in preview: the model sees each tool's name and description, and the full schema loads only when the model asks for it. Claude Code works in a similar way. In my test of it with 738 tools connected, the model asked for a tool by its exact name in 196 of 197 requests. Retrieval earns its place there for the same reason it does in a large warehouse: putting everything into every request is not an option.

How to tell on your own data

  1. Ask whether it fits. If the material for a typical question fits in the window comfortably, try without retrieval first. That is your baseline, and its recall is perfect.
  2. Judge a retriever by what it breaks, not by what it finds. Count the questions where it dropped something the answer needed. That number, not average recall, is what costs you accuracy.
  3. Count wins and losses per question, not just the mean. Thirty-three against thirty-nine averages to nothing and tells you the retriever is changing answers in both directions.
  4. Find the real bottleneck before you tune retrieval. If most wrong answers run cleanly and return the wrong thing, the problem is reasoning over the material, not finding it.

One task, one dataset, a handful of models, and a schema small enough to fit. Where it does not fit, retrieval is the only option, and these numbers do not tell you how good yours is. They tell you how to measure it.

Sources

  1. How far do on-premises open LLMs get on Text-to-SQL? arXiv:2606.29733
  2. nl2sql-onprem-bench, code and per-question results
  3. Assessing the Impact of Retrieval-Augmented Generation on Algorithmic Problem-Solving, arXiv:2611.09791
  4. Gemini API tool retrieval for efficient agent scaling, Google, November 19, 2026
  5. MCP Tool Search: Does the Model Pick the Right Tool Out of 738?, BESK TECH

Vladimir Beskorovainyi

Vladimir Beskorovainyi, Enterprise AI Architect & CTO, author of the Amazon bestseller "Enterprise AI: The KATA Way", founder of Besk Tech (besk.tech)

More in this section

AI AgentsExplainer

MCP Tool Search: Does the Model Pick the Right Tool Out of 738?

Readers asked whether 738 connected tools make the model pick the wrong one. I ran 71 tasks three times, twice with every server connected and once with 12 servers blocked. In 189 scored picks it never took a tool from the wrong server. It took the shell 19 times.

Language ModelsExplainer

What Is a Token in AI? I Ran the Same 71 Tasks on Three Models

A token is the unit a language model reads, writes and bills in. I gave the same 71 tasks to three Claude models. The mid-size one got 57 of 63 right for about half the price of the largest, which got 58. In this test the model choice moved the bill far more than trimming the context did.

Get new articles by email

One message when something new is published. No other mail, and you can stop at any time.

The address is used for this one letter and nothing else. Privacy

← All articles