How does RAG work?
The name comes from a 2020 paper by Patrick Lewis and colleagues. They note that large pre-trained language models store factual knowledge in their parameters, and they add a second, non-parametric memory: a dense vector index of Wikipedia, accessed through a pre-trained neural retriever [1].
Most current systems follow a similar pipeline. Documents are converted into numerical representations by an embedding model and stored in a vector database. When a user asks a question, the most relevant passages are retrieved and added to the prompt, and the model writes its answer from that material [2]. A support assistant, for example, might store product manuals this way. When a customer asks how to reset a device, the matching section of the manual is pulled in and the answer is grounded in it.
Why use RAG?
AWS gives three reasons. The model can draw on current or internal information without being retrained. Answers can include references to their sources, which makes them easier to check. And feeding new data in this way costs less than retraining a foundation model [2]. In the original paper, RAG set the state of the art on three open-domain question answering tasks and produced more specific, diverse and factual text than parametric-only models [1].
How is RAG different from fine-tuning?
Fine-tuning changes the model itself through extra training. RAG leaves the model as it is and fetches the knowledge it needs at request time, so new information does not require retraining [2].