Guides
What Is Retrieval-Augmented Generation (RAG)? Explained Simply
RAG explained in plain English: how AI chatbots look up your documents before answering, and why that cuts hallucinations.

Ask a chatbot a question about your own documents — your company handbook, a 200-page report, last quarter's sales figures — and it answers confidently. But the chatbot was never trained on your documents. So how does it know?
The answer is a technique called retrieval-augmented generation, or RAG. Before the chatbot replies, it searches your documents, finds the passages that matter, and reads them. Then it writes its answer from what it just read, not from what it memorized during training.
Think of it as the difference between a closed-book exam and an open-book exam. A chatbot answering from memory alone is taking the closed-book exam: it has to recall everything, and when it cannot remember, it guesses — that is where hallucinations come from. RAG turns the test into an open-book exam. The model does not need to remember your returns policy. It just needs to read it.
What the three words actually mean
The name sounds technical, but each word does one job:
- Retrieval — find the relevant passages. The system searches your documents for the bits that match your question.
- Augmented — add those passages to the prompt. The retrieved text is pasted in alongside your question, so the model can see it.
- Generation — write the answer. The model produces its reply using the retrieved passages as its source material.
Nothing about the model itself changes. It is not retrained, and it does not learn your documents permanently. It is handed the page and asked to read.
Why chatbots need RAG in the first place
Large language models have three built-in limits, and RAG addresses all three with the same trick.
1. Their knowledge has a cutoff date
A model only knows what was in its training data, which was collected months before the model was released. Ask about something that happened last week and it is guessing from outdated information. RAG fixes this by fetching current information at the moment you ask.
2. They never saw your private data
Your company's internal wiki, your medical records, your unpublished manuscript — none of that was in the training data, and it never should be. RAG lets a model answer questions about private material without ever training on it: the documents stay in your own searchable store, and only the relevant passages are shown to the model for that one question.
3. They hallucinate when they have to recall
When a model answers purely from memory, it can invent plausible-sounding facts, quotes, and citations. Grounding the answer in retrieved passages does not eliminate this completely — the model can still misread what it was given — but it cuts the problem down sharply, because the correct facts are sitting right there in the prompt. It also gives the answer something a memory-only reply cannot have: a source you can check.
How RAG works, step by step
A RAG system is really two pipelines that run at different times.
The indexing pipeline: prepare your documents (happens once)
Before anyone asks a question, your documents are prepared for searching:
- Load — gather the documents: PDFs, web pages, spreadsheets, help-center articles, whatever the system should know about.
- Chunk — split each document into short passages, usually a few hundred words each. A whole 200-page manual is useless as one search result; a single paragraph about returns is exactly right. How documents are split matters more than most people expect: chunks that break mid-sentence or mix two topics together retrieve badly.
- Embed — convert each chunk into an embedding, a long list of numbers that captures the chunk's meaning. Passages with similar meanings get similar numbers, which is what makes searching by meaning possible instead of searching by exact words.
- Store — save the chunks and their embeddings in a vector database, a database built to find the closest matches to a given set of numbers quickly.
This runs when documents are added or changed, not when a user asks a question.
The query pipeline: answer one question (happens every time)
When you ask a question, the system runs a short sequence:
- Embed the question — turn your question into an embedding, the same kind of number list used for the chunks.
- Retrieve — search the vector database for the chunks whose embeddings are closest to the question's. Usually the top three to ten chunks are kept.
- Augment — build a new prompt: your question plus the retrieved passages, with an instruction like "answer using only this material."
- Generate — the model writes its answer from the passages, often with citations pointing back to the source documents.
The whole thing takes seconds. You asked one question; behind the scenes the system searched, read, and then answered.
Where you already use RAG every day
RAG sounds like enterprise infrastructure, but you have probably used it this week without knowing the name:
- Uploading a file to a chatbot. When you attach a PDF to ChatGPT or add documents to a Claude Project and ask questions about them, a RAG pipeline is searching your files behind the scenes.
- Google's Gemini Notebook (formerly NotebookLM, renamed in July 2026) is built entirely around this idea: you add sources — PDFs, websites, YouTube videos, Google Docs — and it answers only from that material, with inline citations.
- Perplexity searches the live web before answering, which is RAG with the whole internet as the document collection. That is why its answers come with sources.
- Customer-support chatbots that actually quote the right help article are almost always RAG systems searching the company's support docs.
- Coding assistants that answer questions about your codebase search your repository first, then explain what they found.
If an AI tool answers from your material and shows its sources, RAG is almost certainly doing the work.
RAG vs fine-tuning vs long context
RAG is one of three ways to adapt a chatbot to your own information. The other two are fine-tuning (retraining the model on your data) and long context (pasting everything into the prompt). Picking the wrong one is the most common expensive mistake in this space.
| RAG | Fine-tuning | Long context | |
|---|---|---|---|
| What it changes | What the model sees at query time | How the model behaves (its weights) | What the model sees, one call at a time |
| Best for | Facts that change, large collections, answers that need citations | Stable behavior: format, tone, classification, domain style | One document or a small set of files |
| Updating information | Edit the document — the next answer uses it | Retrain the model | Send the updated file |
| Citations | Built in | Not possible | Possible, if prompted |
| Effort to start | Days to weeks of setup | Needs labeled examples, then training | An afternoon |
The rule of thumb: if the problem is wrong facts, you need RAG or long context. If the problem is the right facts in the wrong shape — the format, tone, or labels keep drifting — that is a fine-tuning problem. And if everything the model needs fits in a single prompt, try long context first: it takes an afternoon and tells you whether the model can do the job at all when it has the right information. Most production systems end up as hybrids — RAG for knowledge, light fine-tuning or careful prompting for behavior.
Where RAG falls short
RAG is not magic, and honest guides say so. Its weak points are worth knowing before you build or buy one:
- Bad retrieval means bad answers. If the search step fetches the wrong passage, the model will confidently answer from the wrong passage. Most RAG failures trace back to retrieval, not to the model itself — which is why chunking and search quality matter so much.
- It cannot reason across what it was not shown. RAG answers from the chunks it retrieved. A question that needs ten scattered facts synthesized together may fail if only three of them were retrieved.
- The index goes stale. If a document changes and the index is not rebuilt, the system keeps answering from the old version. Freshness is only as good as the re-indexing habit.
- Private data still leaves the building. Retrieved passages are sent to the model, which often means sending them to a cloud provider. If the documents are sensitive, that needs a privacy decision, not just a technical one.
- It adds cost and latency. Every question now pays for a search step plus a longer prompt. For simple questions a plain chatbot call is cheaper and faster.
Try it yourself in five minutes
You do not need to build anything to see RAG work. Pick a document you know well — a contract, a long report, a manual — and upload it to ChatGPT, a Claude Project, or Gemini Notebook. Then ask three questions:
- One whose answer is a single fact buried in the middle of the document.
- One that requires combining two sections.
- One the document does not answer at all.
The first should come back fast and cited. The second may work or may miss a piece — that is retrieval quality showing. The third is the most revealing: a good RAG setup says the document does not cover it; a bad one invents an answer anyway.
Frequently asked questions
Is RAG the same as fine-tuning?
No. RAG changes what the model reads at question time; fine-tuning changes the model itself by retraining it. RAG is for facts that change. Fine-tuning is for behavior that should stay the same.
Does RAG stop hallucinations?
It reduces them a lot, but it does not stop them. A model can still misread a passage, combine two passages wrongly, or answer from a stale or irrelevant chunk. Citations help because you can check the answer against the source.
Do I need a vector database to use RAG?
Not as a user — ChatGPT Projects, Claude Projects, and Gemini Notebook all run the pipeline for you. You only need to think about vector databases if you are building a RAG system yourself.
Where did the term come from?
From a 2020 research paper, "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks," by Patrick Lewis and colleagues. They paired a language model with a searchable index of Wikipedia and showed its answers became more specific and more factual. The technique has been standard practice ever since.
The bottom line
Retrieval-augmented generation is a simple idea with an intimidating name: before the chatbot answers, let it look things up. It is how AI tools answer questions about your documents, your company's knowledge, and today's news — things no model could have memorized in training. The model does not get smarter. It gets the book open in front of it, and that turns out to be most of the difference.