Data & Vector Databases

What Is RAG? Retrieval-Augmented Generation Explained Simply (2026)

Retrieval-augmented generation (RAG) lets an AI model answer from your own documents by finding the relevant passages first and adding them to the prompt. How it works, when you need it, how it differs from fine-tuning and how to get good answers from it.

By Published Updated

Retrieval-augmented generation (RAG) is a way to make an AI model answer from your own documents. When a question comes in, a search step finds the most relevant passages and adds them to the prompt, and the model writes its answer from them. It helps most with current or company-specific information and with answers that cite a source.

Retrieval-augmented generation (RAG) is a way to get an AI model to answer from your own material. When a question comes in, a search step finds the passages in your documents that relate to it and adds them to the prompt. The model then writes its answer from those passages, along with what it learned in training.

Anthropic's glossary describes the same sequence: relevant information is retrieved from a knowledge base when the query is sent, then passed to the model along with the original question. According to the glossary, this lets a model use information beyond its training data, and RAG is most useful for up-to-date information, domain-specific knowledge and answers that need to cite a source. For how the models themselves work, see What Are Large Language Models (LLMs)?

A business usually wants RAG for questions such as "what does our refund policy say about annual contracts" or "which procedure covers a change of vendor." A general model has never seen those documents. RAG gives it the right pages at the moment someone asks.

Where the idea comes from

The name comes from a 2020 paper, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, by Patrick Lewis and eleven co-authors, accepted at NeurIPS 2020. The authors named two open problems with language models: "providing provenance for their decisions and updating their world knowledge." Their approach paired what the model learned in training, which they called parametric memory, with a searchable index of Wikipedia passages, which they called non-parametric memory. They reported that the RAG models produced "more specific, diverse and factual language" than a comparable model working from its training alone.

Those two problems are why a business cares about RAG. You can show where an answer came from, and you can change what the model draws on by changing the documents.

How RAG works

Most RAG systems follow the same steps, set out in Anthropic's post on contextual retrieval and in OpenAI's retrieval guide.

  1. Split the documents into chunks. Anthropic describes chunks of usually no more than a few hundred tokens.
  2. Turn each chunk into an embedding, a list of numbers that represents the text so that similar meanings can be measured. Anthropic does not offer its own embedding model, and its embeddings page points to Voyage AI as one provider among several worth assessing.
  3. Store the embeddings in a vector index, often called a vector store or vector database.
  4. When a question arrives, turn it into an embedding the same way and find the chunks closest to it. OpenAI calls this semantic search and notes that it can surface relevant results that share few or no keywords with the question.
  5. Put the best chunks into the prompt with the question, and have the model answer from them.

Anthropic's glossary adds a detail worth knowing. The data is retrieved at runtime, but the model does not have to run the search itself. Usually the application searches and passes the results in, and a model can also run the search as a tool.

Keyword search still matters

Embeddings match meaning, and they can miss exact strings. Anthropic's example is a support search for "Error code TS-999," where an embedding model may return pages about error codes in general. A keyword ranking method called BM25 finds the exact string, and Anthropic's method combines the two. Microsoft's Foundry IQ (Azure AI Search) does the same in its classic RAG pattern, with hybrid queries that run keyword and vector search together. Product codes, part numbers, client IDs and statute numbers all need the keyword side.

When you do not need RAG

If your material is small, you can skip retrieval and put all of it in the prompt. Anthropic's September 2024 post drew the line at a knowledge base under 200,000 tokens, about 500 pages. Context windows on current models are larger, so check the limit for the model you use. RAG makes sense when the material outgrows the context window, changes often, or has to be filtered by who is asking.

RAG or fine-tuning

The two get confused. OpenAI's guide to optimizing accuracy compares RAG to sitting an exam with the textbook open, which it calls in-context memory. Fine-tuning is closer to attending the class for months, which it calls learned memory. Anthropic's glossary defines fine-tuning as further training of a pretrained model on additional data, and notes that the Claude API does not currently offer it.

RAGFine-tuning
What changesWhat the model is given for each questionThe model itself, through more training
Good forFacts from your documents, current information, citing sourcesDoing a task the same way every time, or with fewer tokens or a smaller model
UpdatingAdd, replace or remove documentsPrepare new training examples and train again

OpenAI notes that the two stack, and that many of its largest customer deployments used only prompt engineering and RAG.

Ways to set it up

The major vendors sell managed versions, so you do not have to build every piece.

  • OpenAI's vector stores power both its Retrieval API and its file search tool. A file added to a vector store is chunked, embedded and indexed automatically.
  • Google's Gemini API File Search imports, chunks and indexes your files. As listed on 2026-12-02, file storage and embeddings at query time are free, and you pay for embeddings when files are first indexed, plus the normal model tokens.
  • Microsoft's Foundry IQ offers agentic retrieval, which uses a model to break a question into smaller searches and runs them in parallel, alongside the classic pattern. Microsoft recommends agentic retrieval for new projects.

Teams that build their own usually pick an embedding model, a vector database and a model API, often with a framework such as LangChain or LlamaIndex, both named in OpenAI's accuracy guide.

How to get good answers from RAG

Test retrieval on its own

Anthropic's glossary says RAG is only as good as the knowledge base and the passages retrieved. OpenAI's guide splits failures into two kinds. Retrieval can supply the wrong context, or so much irrelevant context that the right information gets lost, or the model can mishandle good context. Run a set of real questions with known answers and look at which passages come back before you change the prompt or the model.

Ask for sources

Show the passage behind each answer so a person can check it. Anthropic's citations feature returns the exact passages that support each claim, and Gemini File Search returns file citations with its answers. Citations give you the provenance the 2020 paper's authors were after.

Match access to the person asking

Microsoft's overview states that users and agents must only retrieve content they are authorized to see. Foundry IQ can inherit SharePoint and Microsoft Entra ID permissions and trim results at the document level. Whatever you use, make sure a question from one employee cannot pull up a file that person could not open. What Is Safe to Put Into ChatGPT covers the data side of that decision.

Keep the documents current

RAG answers from what is in the index, so an old policy left there produces old answers. Give each source an owner, remove superseded versions and re-index when documents change. The NIST Generative AI Profile lists confabulation, "confidently stated but erroneous or false content," as a generative AI risk, and among its suggested actions is verifying that retrieval-augmented generation data is grounded. RAG gives the model your documents to work from, and a person should still check the answers that matter.

Sources

  1. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arXiv 2005.11401, NeurIPS 2020) (checked 2026-12-02)
  2. Glossary: RAG, fine-tuning, context window (Anthropic documentation) (checked 2026-12-02)
  3. Introducing Contextual Retrieval (Anthropic, September 19, 2024) (checked 2026-12-02)
  4. Embeddings (Anthropic documentation) (checked 2026-12-02)
  5. Citations (Anthropic documentation) (checked 2026-12-02)
  6. Retrieval: semantic search and vector stores (OpenAI API documentation) (checked 2026-12-02)
  7. Optimizing LLM accuracy: prompt engineering, RAG and fine-tuning (OpenAI API documentation) (checked 2026-12-02)
  8. File Search (Gemini API documentation, Google AI Studio) (checked 2026-12-02)
  9. Retrieval-augmented generation in Foundry IQ (Azure AI Search) (Microsoft Learn) (checked 2026-12-02)
  10. NIST AI 600-1, Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (July 2024) (checked 2026-12-02)
the list

Get the next one.

Field notes from real deployments, written the way this one was. No schedule promised and nothing sold to you. Unsubscribe whenever.

Frequently asked questions

What is RAG in AI?

Retrieval-augmented generation (RAG) finds the passages in your documents that relate to a question and adds them to the prompt, so the model answers from that material as well as its training. Anthropic's glossary describes it as most useful for up-to-date information, domain-specific knowledge and answers that cite a source.

How is RAG different from fine-tuning?

RAG changes what the model is given for each question, so you update it by changing the documents. Fine-tuning is further training of the model on additional data, used to make it do a task consistently or more efficiently. OpenAI describes the two as complementary and notes that they stack.

What is a vector database?

A vector database stores embeddings, the lists of numbers that represent each chunk of text, and finds the ones closest to a question's embedding. That is semantic search, which OpenAI notes can return relevant results that share few or no keywords with the question. Many systems also run keyword search for exact terms such as codes and names.

Does RAG stop AI hallucinations?

It reduces the model's reliance on memory by giving it source material, according to Anthropic's glossary, but the answer is only as good as the passages retrieved. Ask for citations, test retrieval with questions you know the answers to, keep the documents current, and have a person check answers that matter.

Need help implementing this?

Prometheus does AI consulting and implementation, remote, with onsite days available in Milwaukee. We set it up, train your team, and make sure it works.

let's talk