What Is RAG in AI? Retrieval-Augmented Generation Explained
RAG stands for retrieval-augmented generation. Before a language model answers, the system searches your own documents, takes the passages that match the question, and puts them into the prompt. The model then writes its answer from those passages instead of from memory.
It is the standard way to make an AI system answer with your product facts, your policies and your procedures, and to keep those answers current when the documents change.
Why RAG exists
A large language model only knows the text it was trained on. Your return policy, this year's product versions and last week's troubleshooting fix were never in that text. Retraining a model every time a document changes is slow and expensive. RAG solves it at answer time: the model stays the same, and the facts arrive with each question.
It also makes answers checkable. When the system knows which passages it gave the model, you can see where each answer came from. If you are new to the models themselves, start with what is an LLM.
How RAG works
- Prepare the documents. Documents are split into chunks, ideally one topic per chunk, following the headings. Each chunk is converted into a list of numbers that captures its meaning, called an embedding, and stored in a vector database.
- Retrieve. The question is turned into a search query and compared with the stored chunks. The closest matches come back, ranked. Many systems combine this meaning-based search with ordinary keyword search, so exact terms like model names are not missed.
- Generate. The top passages, the question and the rules for answering go to the model together. The model writes the answer from those passages.
A RAG database is the store behind step two: usually a vector database, sometimes alongside a keyword index.
RAG means something else in project management
If you arrived from a status report: a RAG status is red, amber, green, a traffic-light rating for projects. It has nothing to do with AI. The rest of this page is about the AI meaning.
RAG vs fine-tuning
- RAG changes what the model knows at the moment it answers. Update a document and the next answer uses it. Use it for facts that change: products, prices, policies, procedures.
- Fine-tuning changes how the model behaves. It trains the model further on your examples, so it picks up a format, a tone or a narrow skill. Updating a fact means training again.
For business knowledge, RAG comes first. Fine-tuning is worth considering only once retrieval works and the remaining problem is style or format.
RAG vs sending the whole document
Models now accept long inputs, so it is tempting to skip retrieval and paste everything. It does not work well. In long material a model loses the one fact that matters. In our own system, sending only the order lines an email concerned cut one case from 37,604 input tokens to 4,722, and all four parts in the reply were then correct. Retrieval is how the model gets the right paragraph and only that.
RAG in production: what we learned
We run customer service for an online brand. Before every email draft, the system searches a knowledge base of product facts, published policies, troubleshooting steps and video guides. In the 30 days to 19 November 2026 that meant 36,789 customer emails received, in eight languages, from one knowledge base. Four lessons decided the quality:
- Search every time, in code. Do not let the model decide whether to look something up. The system searches before every draft and gives the model the results.
- One question, one short query. An email with three questions becomes three short searches, each phrased the way the knowledge base is phrased. One long mixed query buried the right entry.
- Keep one version of each fact. When an old and a new policy both sit in the store, retrieval returns both and the model follows either one.
- Never cut content on the way to the model. A filter we added to strip video links cut at sentence boundaries and deleted whole troubleshooting steps. A filter removes only its target, and every change is checked against a real entry before and after.
What goes into the store is covered in AI customer service knowledge base. When retrieval returns nothing useful, the five usual causes are in RAG not finding answers.
Where RAG is not the answer
- Live data. Where a parcel is now, whether an item is in stock, what an order contains. These come from a direct lookup in the order or shipping system, not from searching documents.
- Actions. Creating a ticket, changing an address or issuing a refund needs tools and approval rules. That is an AI agent with RAG as one of its tools. See what is an AI agent.
- Knowledge nobody wrote down. RAG retrieves documents. If the answer lives only in an experienced person's head, write it down first.
How to check a RAG system works
- Ask real questions the way customers ask them, inside the live app, and confirm the right passage was retrieved.
- Print the retrieved text and read it. Confirm it is the complete passage, not half of it.
- After every knowledge update, re-run questions that were already answered correctly and confirm they still are.
We build AI agents with retrieval on your own documents and systems, and charge per completed task. Send us the questions your team answers most and the free plan shows how a RAG setup would handle them, within two working days.