A language model knows a great deal, but nothing about your organisation: your products, your policies, last week’s decision. Retrieval-augmented generation, or RAG, is the common way to close that gap. The simplest way to understand it is as an open-book exam.
- AI
- RAG
- Explainer
In this article4 sections
Closed book versus open book#
Ask a model a question without RAG and it answers from memory, like a student in a closed-book exam. The answer can be fluent and still wrong, because the model fills gaps with what sounds plausible.
With RAG, the model is first handed the relevant pages from your own material and then asked to answer. It is an open-book exam: the student still needs to understand the question, but now has the facts in front of them.
How it works, in three steps#
Behind the scenes, a RAG system does roughly this:
- Search. Your question is used to find the most relevant passages in your documents, wiki, tickets or database.
- Hand over. Those passages are added to the prompt, together with the question.
- Answer with sources. The model writes its answer from the passages and points to where each part came from.
When it helps#
RAG is a good fit when answers must be based on your own, current information:
- Internal support: “How do we handle refunds for business customers?”
- Developer onboarding: “Where is authentication handled, and why was it built that way?”
- Policies and regulations, where an answer without a source is worth very little.
Where it falls short#
RAG is only as good as what it can find. Outdated, duplicated or badly structured documents lead to confident answers based on the wrong page. Access rights matter too: the system must never retrieve something the person asking is not allowed to see.
The practical advice is the same as for people: keep the important documents current, make the sources visible in every answer, and let a person check anything that matters.