Blog · AI Product Management

What Is RAG? Retrieval-Augmented Generation Explained for Product Managers

How RAG works, when to choose it over fine-tuning or a long prompt, where it goes wrong, and how to tell whether your RAG feature gives good answers.

Short answer: RAG (retrieval-augmented generation) is a way to make an AI answer from your own information. Before the model writes a reply, the system searches a knowledge source, such as help articles, policies or product docs, and adds the most relevant passages to the prompt. The model then answers from those passages instead of relying only on what it learned in training.

What is RAG?

RAG stands for retrieval-augmented generation: retrieval (finding relevant information), augmented (added to the prompt) and generation (the model writing the answer). Anthropic describes it as "a method that retrieves relevant information from a knowledge base and appends it to the user's prompt".6

A simple example: a customer asks your support assistant, "Can I get a refund after 30 days?" A model on its own only knows what it saw in training, which doesn't include your refund policy. With RAG, the system first searches your help centre, finds the refund policy section, and gives it to the model with the question. The model answers from your policy and can link to it.

The name comes from a 2020 paper by Patrick Lewis and colleagues, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (NeurIPS 2020). It combined a model's built-in knowledge with "a dense vector index of Wikipedia, accessed with a pre-trained neural retriever", and found that RAG models "generate more specific, diverse and factual language" than the same kind of model without retrieval.1

How does RAG work, step by step?

A RAG system has two parts: a preparation step that runs ahead of time, and a step that runs every time a user asks something.

Ahead of time, prepare the knowledge:

  1. Split the documents into chunks. Long documents are cut into smaller passages that can be searched on their own.
  2. Turn each chunk into an embedding. An embedding model converts text into a list of numbers that captures its meaning, so passages about the same thing end up close together.
  3. Store them in a vector database, which can search "by semantic similarity", that is, by meaning rather than exact words.6

Every time a user asks a question:

  1. Retrieve. The question is turned into an embedding too, and the system fetches the chunks closest in meaning. Many systems also run a keyword search, which is better at exact terms such as product names or error codes.
  2. Augment. The best chunks are added to the prompt, with an instruction such as "Answer only from the sources below, and cite them."
  3. Generate. The model writes the answer from those passages, ideally with links to the sources it used.

Why do teams use RAG?

A language model only knows what was in its training data, and that stops at a cut-off date. It has never seen your internal documents, your latest pricing or yesterday's policy change. RAG fixes that without retraining the model. AWS lists the main benefits:7

  • Cheaper than retraining. "RAG is a more cost-effective approach to introducing new data to the LLM."
  • Current information. Update the documents and the answers change, with no new model.
  • Sources users can check. RAG lets the model "present accurate information with source attribution", which builds trust.
  • More control. The team decides which documents the AI can draw from, and can test and improve them.

RAG also reduces made-up answers. A 2021 study found that retrieval can "substantially reduce the well-known problem of knowledge hallucination" in chatbots.4 It reduces the problem; it does not remove it. The model can still misread a passage or answer when nothing relevant was found.

Numbers worth knowing

2020Year of the NeurIPS paper that named retrieval-augmented generationLewis et al., 2020
49%Fewer failed retrievals with contextual retrieval: context added to each chunk, plus keyword searchAnthropic, 2024
67%Fewer failed retrievals when contextual retrieval is combined with rerankingAnthropic, 2024
~500Pages of material (200,000 tokens). Below this, you can put everything in the promptAnthropic, 2024

RAG vs fine-tuning vs a long prompt: which should you use?

They solve different problems. OpenAI's accuracy guide separates them clearly: you optimise the context (RAG) when "the model lacks contextual knowledge because it wasn't in its training set", and you optimise the model (fine-tuning) when it "is producing inconsistent results with incorrect formatting". The two "are additive, not exclusive", and OpenAI says prompt engineering "is typically the best place to start".8

RAG compared with fine-tuning and a long prompt
ApproachWhat it changesUse it when
Put it all in the promptThe whole knowledge base goes into every requestThe material is small. Anthropic suggests this below about 200,000 tokens, roughly 500 pages6
RAGWhat the model knows for this question, by adding retrieved passagesThe knowledge is large, changes often, is private, or answers need sources
Fine-tuningHow the model behaves, by training it on example prompts and answersYou need a consistent format, tone or behaviour that prompting can't get reliably

For adding facts, retrieval tends to win. A 2023 study comparing the two found that while fine-tuning "offers some improvement, RAG consistently outperforms it", and that models "struggle to learn new factual information through unsupervised fine-tuning".3

Where does RAG go wrong?

Common RAG failures and fixes
ProblemWhat happensHow to fix
Chunks lose their contextA chunk like "revenue grew 3%" no longer says which company or quarter, so search can't match it. Traditional RAG can "remove context when encoding information"6Add a short description of the document to each chunk before indexing it. Anthropic's contextual retrieval, which does this and adds keyword search, cut failed retrievals by 49%, and by 67% with reranking6
Exact terms are missedMeaning-based search can miss product codes, names and error numbersCombine it with keyword search (BM25), which is "particularly effective for queries that include unique identifiers or technical terms"6
Important passages get ignoredModels use information best at the start or end of a long prompt; performance "significantly degrades" when it sits in the middle2Send fewer, better-ranked passages, with the most relevant first
The sources are wrong or out of dateThe model faithfully repeats an old policy or a draft documentGive the knowledge base an owner, remove old versions and re-index when documents change
The answer goes beyond the sourcesThe model adds details that aren't in the passages, or answers when nothing relevant was foundTell it to answer only from the sources and to say when it doesn't know, then test for it

How do you evaluate a RAG feature?

Test the search and the answer separately, because a bad answer can come from either. OpenAI notes that RAG applications "introduce a new axis we need to optimize against, which is retrieval".8 The Ragas evaluation framework splits it into three questions:5

  1. Retrieval: did the system find relevant, focused passages for the question?
  2. Faithfulness: did the answer use those passages "in a faithful way", without adding claims they don't support?
  3. Answer quality: did the answer actually address what the user asked?

Build a test set of real questions with the source passage each one needs, measure how often the right passage is retrieved, and grade the answers, by people at first and then with a calibrated LLM-as-a-judge. Our guide to AI evals covers building the test set and setting a release gate.

What should a product manager ask about a RAG feature?

  • Which sources can it use, who owns them, and how quickly do changes reach the AI?
  • Who may see what? If documents have access rights, retrieval must respect them, so users never get answers from files they can't open.
  • Does it show its sources, so users and support staff can check an answer?
  • What happens when nothing relevant is found? The right behaviour is usually "I don't know" or a hand-off to a person.
  • How will we measure it? Agree retrieval and answer-quality targets before launch, and keep testing after it. Our free AI PRD Template has a section for this.

Where can I learn to build RAG products?

Product Faculty's AI Product Management certification is six weeks. Week 2, The AI Product Stack, covers "RAG, fine-tuning, tools, memory, and agents", so you learn to choose between prompting, RAG, tools and fine-tuning for a real product, then write your first AI PRD. To make sure a RAG feature gives good answers, AI Evals teaches you to build and calibrate the tests.

FAQ

What does RAG stand for?

RAG stands for retrieval-augmented generation. The system retrieves relevant information, adds it to the prompt, and the model generates an answer from it.

What is RAG in simple terms?

RAG is an open-book exam for AI. Before answering, the system looks up the most relevant passages in your documents and gives them to the model, so it answers from your information instead of only from what it learned in training.

Is RAG better than fine-tuning?

For adding knowledge, usually yes: a 2023 study found RAG consistently outperformed unsupervised fine-tuning. Fine-tuning is better for shaping behaviour, format and tone. The two can be combined.

Does RAG stop hallucinations?

It reduces them but doesn't stop them. Research shows retrieval substantially reduces made-up facts, but a model can still misread a passage or answer when nothing relevant was found, so you still need evals.

Do I need a vector database for RAG?

Most RAG systems use one to search by meaning, often combined with keyword search. For a small knowledge base, under about 500 pages, you may not need RAG at all: you can include all of it in the prompt.

How do you measure RAG quality?

Measure retrieval (did it find the right passages?) and the answer (is it faithful to those passages and does it address the question?) separately, on a fixed test set of real questions.

Where can I learn RAG as a product manager?

Product Faculty's AI Product Management certification covers RAG, fine-tuning, tools, memory and agents in week 2 of six, and how to choose between them for a real product.

Sources

  1. Lewis, P. et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. NeurIPS 2020.
  2. Liu, N. F. et al. (2023). Lost in the Middle: How Language Models Use Long Contexts. Transactions of the ACL.
  3. Ovadia, O. et al. (2023). Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs.
  4. Shuster, K. et al. (2021). Retrieval Augmentation Reduces Hallucination in Conversation.
  5. Es, S. et al. (2023). Ragas: Automated Evaluation of Retrieval Augmented Generation.
  6. Anthropic (2024). Introducing Contextual Retrieval.
  7. AWS. What is RAG (Retrieval-Augmented Generation)?
  8. OpenAI. Optimizing LLM accuracy.

Build AI products that know your business

Learn when to use RAG, fine-tuning or tools, and ship an AI feature end to end, in AI Product Management, part of the AI Builder Fellowship.