RAG addresses the main weakness of a language model: its knowledge stops at its training date, and on narrow or fresh topics the model makes things up. Instead of retraining it, the model is supplied with text retrieved from a database — corporate documents, handbooks, instructions — and answers on the basis of that text.
How the pipeline works
The knowledge base is prepared in advance: documents are cut into chunks of a few hundred tokens each, embeddings are computed for them, and the chunks are stored in a vector database. Then, for each question:
- the question is turned into an embedding and the nearest chunks are retrieved — by meaning, not by word matches;
- the retrieved chunks are inserted into the prompt together with the question: the context grows by hundreds and thousands of tokens;
- the model generates an answer from the supplied text — in more advanced schemes it also marks which chunks it relied on.
What it provides
| A model’s problem without retrieval | What RAG changes |
|---|---|
| Knowledge stops at the training date | The documents in the database can be updated at any time; the model is not retrained |
| Hallucinations on narrow questions | The answer rests on retrieved text rather than the model’s “memory” |
| The answer has nothing to show in support | It is visible which documents the answer was assembled from — the answer can be verified |
| A separate model for each topic | One model plus a replaceable knowledge base: swap the documents and the expertise changes |
This is how corporate assistants, support bots, documentation search and answers on fresh data that was not in the model’s training are built.
Where the term comes from
The term was proposed by Patrick Lewis and colleagues in the 2020 paper “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks”: a generator was combined with a dense vector index of Wikipedia articles, and on question-answering tasks such models outperformed the same models without retrieval.
Sources
the term is written from these pagesVerified 9 Nov