What is RAG (retrieval-augmented generation)
RAG makes AI look up passages from documents before it answers. How it works, why it can cite sources, and why the knowledge base matters more than the model.
RAG (retrieval-augmented generation) is the technique in which an AI assistant looks up relevant passages in a set of documents before answering, and builds its answer on those passages. Instead of relying only on what the model learned in training, the answer rests on the company's own content, which can be cited and checked.
It is the most common way to get an AI to answer questions about internal policies, contracts, products or processes that were never on the internet.
How RAG works, step by step
The process has two phases: preparing the knowledge base and answering each question.
Preparing the base (done ahead of time):
- Collect the documents. Files from shared drives, wiki articles, manuals, transcripts.
- Split them into chunks. Each document is broken into smaller pieces of a few paragraphs, because the model does not need to read the whole manual to answer a question about one item.
- Index them. Each chunk is turned into a numerical representation of its meaning (called an embedding) and stored in an index that can be searched by meaning, not just by exact words.
Answering (done for every question):
- Search. The question is converted the same way and compared against the index. The chunks closest in meaning are selected.
- Build the context. The selected chunks are placed alongside the question, with an instruction such as "answer based on these documents".
- Generate the answer. The model writes the answer from those chunks and points to where each piece of information came from.
Why answers can cite sources
Because the system knows exactly which chunks it handed to the model, it can show where each answer came from: the document, the section, sometimes the paragraph. That changes how people trust AI. Nobody has to take the answer on faith; they can open the source and check.
Citations are also a maintenance tool. When an answer is wrong and the source is visible, it is clear whether the problem is the model (it misread) or the document (it is wrong or out of date).
Where RAG fails
RAG is only as good as the base it searches. The most common problems are not in the model but in the content:
| Problem in the base | What happens in the answer |
|---|---|
| Outdated document | The AI gives the old rule, confidently and with a citation |
| Document with no owner | Nobody notices the error or fixes it |
| Duplicate documents | Two versions of the same policy land in the context and the answer mixes them |
| Ambiguous document | Search finds the right passage, but the model draws the wrong conclusion |
| Information nobody wrote down | Search finds nothing and the model answers from general knowledge, or admits it does not know |
That is why switching models rarely fixes a bad RAG setup. A more capable model reading an expired policy will deliver an expired answer, just better written. The quality of the base matters more than the choice of model.
What tends to work:
- every document has an owner, someone accountable for it;
- every document has a review deadline, so stale content surfaces before it causes trouble;
- duplicates are removed instead of leaving the AI to pick between versions;
- there is a record of who verified the content and when, so the reader knows how much to trust the answer.
Frequently asked questions
What is the difference between RAG and fine-tuning?
Fine-tuning retrains the model on company data, changing the model itself. RAG leaves the model alone and supplies the content at question time. For knowledge that changes (prices, policies, processes), RAG is easier to maintain, because updating the document is enough. Fine-tuning makes more sense for teaching a style or an answer format, not for keeping facts current.
Does RAG eliminate hallucinations?
It reduces them, but does not eliminate them. The model can still misread a passage or fill a gap with general knowledge. Citing sources is what lets you catch those cases. A good system also says when an answer did not come from the base.
Do I need a lot of documents to use RAG?
No. A small, accurate base works better than a huge, messy one. Starting with the questions the team asks most often is usually the fastest route.
Does RAG work with any model?
Yes. The technique sits outside the model: any language model can receive the passages and answer from them. That is one reason to keep the knowledge base independent of the model provider.
Where Kluco fits
Kluco's Brain takes care of the part of RAG that matters most: the base. It connects sources such as Google Drive, OneDrive and SharePoint, API, webhook and meeting recorders such as Fathom, Zoom and Fireflies, and can turn that content into articles. Each article shows whether it was written by AI or by a person, and who verified it and when. The company can set an owner and a review deadline for each article, and choose who can read it: all agents or internal assistants only. See how in Brain, or read about what company memory is.