Building

Retrieval-augmented generation (RAG): how AI looks things up before it answers, and where it still goes wrong

How retrieval-augmented generation works, what the evidence says about its reliability, and how to judge a tool that claims to answer from your documents.

Manelink Research29 November 2026 · 8 sources · 8 min read

In brief

RAG lets a model look up passages from your own documents and answer from them, which helps with private, current and checkable knowledge. It lowers errors but does not remove them, since leading legal RAG tools still got 17% to 33% of answers wrong or misgrounded in a Stanford study. Each step of the pipeline can fail, and retrieval quality is the main lever, with one vendor test cutting failed retrievals by 49% to 67%. For small collections a long-context model is a serious alternative, so test on your own questions before trusting either.

Imagine asking an AI assistant about your company's refund policy. A plain chatbot answers from what it absorbed during training, which may be out of date or simply wrong, and it cannot see your internal documents at all. Now imagine the same assistant first searching your policy files, pulling out the two relevant pages, and answering from them. That second setup is called retrieval-augmented generation, or RAG, and it sits behind many AI tools that "chat with your documents."

This article explains how RAG works in plain terms, what research shows about how well it works, and where it still fails. You will also get a short list of questions to ask before trusting a RAG-based product with something that matters.

What RAG is, in plain terms

A large language model (LLM) is the kind of AI behind chatbots such as ChatGPT or Claude. It stores what it learned in training inside its parameters, the billions of numbers that make up the model. Those parameters are frozen at training time. They cannot hold your private files, and they do not update when the world changes.

The 2020 paper that named the technique, by Patrick Lewis and eleven co-authors (accepted at NeurIPS 2020), described RAG as combining "parametric" memory (the pre-trained model) with "non-parametric" memory (in their case, a dense vector index of Wikipedia, searched by a neural retriever)1. In everyday terms: the model is the writer, and the index is a library it can consult. The authors reported state-of-the-art results on three open-domain question-answering tasks at the time. Their abstract also noted that giving provenance (showing where an answer came from) and updating a model's knowledge were still open research problems, which is exactly what RAG set out to improve1.

A later survey of the field, by Yunfan Gao and colleagues, summarizes the motivation the same way: LLMs face hallucination (stating false things fluently), outdated knowledge, and reasoning that is hard to trace, and RAG addresses these by pulling in knowledge from external sources2. The survey describes three generations of designs, Naive, Advanced and Modular RAG, built from three parts: retrieval, generation and augmentation2.

How a RAG system works, step by step

Most systems follow the same outline.

1. Prepare the library. Documents are split into chunks, short passages of a few paragraphs. Each chunk is converted into an embedding, a list of numbers that captures its meaning, so that passages about similar things sit close together. These are stored in a vector database.

2. Retrieve. When you ask a question, it is converted into an embedding too, and the system fetches the chunks closest in meaning. Many systems also run a keyword search (a method called BM25) and combine the two.

3. Rerank (optional). A second model re-sorts the candidates so the most relevant ones come first.

4. Generate. The top chunks are pasted into the model's prompt along with your question, and the model writes an answer, ideally citing which chunk each claim came from.

The analogy is an open-book exam. The model is the student, the retrieval step is the student's skill at finding the right pages, and the answer is only as good as both. A strong student with the wrong pages will still answer badly.

What the evidence says about where RAG breaks

The most useful finding from engineering research is that RAG is not one thing that either works or does not. It is a pipeline, and each stage can fail.

A 2024 paper from Deakin University researchers (Scott Barnett and colleagues, presented at the CAIN 2024 software-engineering conference) reports lessons from three real systems built for research, education and biomedical question answering. It lists seven failure points: missing content, missed top-ranked documents, answers not making it into the context, answers not extracted, wrong format, incorrect specificity, and incomplete answers3. Their central warning is that validating a RAG system is "only feasible during operation," and that its robustness evolves over time rather than being designed in at the start3. In other words, you cannot prove it works on the day you build it.

The first two failure points sit in retrieval: the answer is not in the library, or it is there but the search did not surface it. This is why retrieval quality gets so much attention from builders. Anthropic published tests in September 2024 of a technique it calls contextual retrieval, where each chunk gets a short explanatory note about where it came from before it is indexed. Measured as how often the right passage failed to appear in the top 20 results, the technique cut failures by 35%. Combined with keyword search it cut them by 49% (from 5.7% to 2.9%), and with reranking added by 67% (to 1.9%)4. These are the company's own tests across codebases, fiction and scientific papers, so treat them as a promising vendor result rather than an independent benchmark.

The third failure point, answers that were retrieved but not used well, connects to a well-known finding about how models read long inputs. In a study published in the Transactions of the Association for Computational Linguistics, Nelson Liu and colleagues placed the one relevant document at different positions among others. Performance was often highest when the relevant information was at the beginning or end and "significantly degrades" when it sat in the middle5. For GPT-3.5-Turbo, accuracy with the answer in the middle fell below its score with no documents at all (56.1%)5. Those were 2023-era models, and newer ones handle this better, but it explains why simply retrieving more chunks is not a fix. The same study found that using more than 20 retrieved documents improved results only marginally5.

Does RAG actually reduce hallucinations?

It helps, but it does not eliminate them. The clearest independent test comes from legal research, where a fabricated case citation can have serious consequences. A Stanford team (Varun Magesh, Faiz Surani, Matthew Dahl, Mirac Suzgun, Christopher Manning and Daniel Ho) evaluated commercial AI legal research tools from LexisNexis and Thomson Reuters, which are marketed as grounded in real legal sources. They used a benchmark of more than 200 legal queries and counted a response as hallucinated if it was either incorrect or misgrounded, meaning it cited a source that did not support the claim or was not applicable7. The published version in the Journal of Empirical Legal Studies reports that the tools each hallucinated between 17% and 33% of the time, which is lower than a general-purpose chatbot but far from "hallucination-free," the claim some vendors had made7.

Two cautions apply. The figure covers specific products tested at one time on one set of legal questions, so it should not be read as a rate for RAG in general. And the study's definition is strict, counting a wrong citation as a failure even when the headline answer is right, which is arguably the right standard for lawyers and a stricter one than most casual users apply.

RAG versus just pasting everything in

As models accept longer inputs, a reasonable question is whether you need retrieval at all. A 2024 study from Google researchers (Zhuowan Li and colleagues, accepted to EMNLP 2024's industry track) compared the two across public datasets and three recent LLMs. When resourced sufficiently, long-context models "consistently" outperformed RAG on average, but RAG's much lower cost remained a distinct advantage6. The authors proposed Self-Route, which lets the model decide whether a question can be handled by retrieval or needs the full text, and reported that it kept performance comparable to long-context while reducing computation6.

Anthropic's engineers give a practical rule of thumb: if your document collection is smaller than about 200,000 tokens (roughly 500 pages), you can put all of it in the prompt with no need for RAG, and prompt caching makes that faster and cheaper4. RAG earns its place when the collection is larger than that, changes often, needs per-user access controls, or must show which source supports each claim.

Limits and open questions

Security. If a system retrieves from a document pool that others can write to, an attacker can plant text in it. A 2024 preprint, PoisonedRAG (Wei Zou and colleagues), reports that injecting five malicious texts per target question into a knowledge database of millions of texts achieved a 90% attack success rate in their experiments8. This was a research demonstration under chosen conditions, not a measured rate in deployed products, but it shows that whatever the retriever fetches, the model tends to trust.

Evaluation is hard. There is no single accepted score for a RAG system. Retrieval can be scored (was the right passage found?), generation can be scored (was the answer faithful to the passage?), and the two can disagree. The failure-point research suggests ongoing monitoring on real questions matters more than a one-time benchmark3.

The evidence ages fast. Most figures here come from specific models and products from 2023 to 2025. The pattern, that each pipeline stage can fail and that retrieval quality is the main lever, is stable. The exact percentages are not.

What this means for you

  1. Ask what the tool searches. A RAG assistant can only be as complete as its library. Find out which documents are included, how often they are refreshed, and whether it says so when it cannot find an answer.
  2. Check the citations, not just the answer. The legal study shows citations can look authoritative and still not support the claim7. Click through on anything that matters.
  3. Build a small test set. Write 20 to 30 real questions with known answers, including a few the documents do not answer, and run them before rollout and again after any change3.
  4. Consider skipping RAG for small collections. If everything fits in one long prompt, that may be simpler and equally good46.
  5. Treat the document pool as a security boundary. Do not let untrusted people or web pages write into the library your assistant trusts8.

Key takeaways

  • RAG gives a language model an open book: it retrieves passages from your documents and answers from them, which helps with private, current and checkable knowledge12.
  • It is a pipeline with at least seven documented failure points, and it can only be fully validated in real use3.
  • Retrieval quality is the main lever. One vendor test cut failed retrievals by 49% to 67% with better indexing and reranking4.
  • Grounding reduces but does not remove hallucination: leading legal RAG tools still got 17% to 33% of answers wrong or misgrounded in a Stanford study7.
  • For small collections, long-context models are a serious alternative, and RAG's edge is cost and scale46.

Sources

  1. Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., et al. (2020). Retrieval-augmented generation for knowledge-intensive NLP tasks. NeurIPS 2020, arXiv:2005.11401. arxiv.org/abs/2005.11401
  2. Gao, Y., Xiong, Y., Gao, X., Jia, K., Pan, J., Bi, Y., et al. (2023, rev. 2024). Retrieval-augmented generation for large language models: A survey. arXiv:2312.10997. arxiv.org/abs/2312.10997
  3. Barnett, S., Kurniawan, S., Thudumu, S., Brannelly, Z., & Abdelrazek, M. (2024). Seven failure points when engineering a retrieval augmented generation system. Proceedings of CAIN 2024 (3rd International Conference on AI Engineering), arXiv:2401.05856. arxiv.org/abs/2401.05856
  4. Anthropic. (2024, September 19). Introducing contextual retrieval. anthropic.com/news/contextual-retrieval
  5. Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., & Liang, P. (2024). Lost in the middle: How language models use long contexts. Transactions of the Association for Computational Linguistics, 12, 157–173. doi.org/10.1162/tacl_a_00638
  6. Li, Z., Li, C., Zhang, M., Mei, Q., & Bendersky, M. (2024). Retrieval augmented generation or long-context LLMs? A comprehensive study and hybrid approach. EMNLP 2024 (industry track), arXiv:2407.16833. arxiv.org/abs/2407.16833
  7. Magesh, V., Surani, F., Dahl, M., Suzgun, M., Manning, C. D., & Ho, D. E. (2025). Hallucination-free? Assessing the reliability of leading AI legal research tools. Journal of Empirical Legal Studies, 22(2), 216–242. doi.org/10.1111/jels.12413
  8. Zou, W., Geng, R., Wang, B., & Jia, J. (2024). PoisonedRAG: Knowledge corruption attacks to retrieval-augmented generation of large language models. arXiv:2402.07867. arxiv.org/abs/2402.07867