RAG (retrieval-augmented generation)
In brief
RAG means retrieving relevant documents from a knowledge base, then giving them to a language model so that it bases its answer on them.
Sources[1]
Definition
RAG (Retrieval-Augmented Generation) is a technique that combines a search engine with a language model. Before answering, the system retrieves relevant passages from a document base, then inserts them into the prompt given to the model, which generates its answer based on them.
The steps
- Preparation: documents are split into passages, turned into embeddings and stored in an index (often a vector database).
- Retrieval: the user’s question is converted the same way, and the closest passages are found.
- Generation: the selected passages are added to the model’s prompt, which writes the answer, ideally citing its sources.
Benefits
- Access recent or private information the model has not learned.
- Reduce (without eliminating) hallucinations by anchoring the answer in documents.
- Cite sources, which makes checking easier.
- Update knowledge without retraining the model.
Limits
The quality of the answer depends on the quality of retrieval: poor splitting or irrelevant passages degrade the result. The model may also ignore or misread the documents it is given.
Spotted a mistake or have an idea about this entry? Let us know