What is the difference between retrieval and generation in RAG?
In RAG, retrieval finds relevant external information, while generation uses that information to produce the final response.
Retrieval
Retrieval happens before the model writes the answer.
Its job is to search the knowledge source and return the pieces of information most relevant to the user's query.
Example:
User asks:
How long is the warranty for Product A?
Retriever finds:
Product A includes a 2-year warranty.The retriever does not usually create the final answer. It selects useful context.
Generation
Generation happens after relevant information has been retrieved.
The language model receives the user's question together with the retrieved context and produces a natural-language response.
Question + retrieved context
↓
Language model
↓
Product A includes a 2-year warranty.Key difference
| Retrieval | Generation | | --- | --- | | Finds relevant information | Produces the final response | | Searches external knowledge | Uses the retrieved context plus the query | | Focuses on selecting useful evidence | Focuses on forming a coherent answer | | Poor retrieval can supply the wrong context | Poor generation can misinterpret or misuse good context |
The two stages are closely connected. Good generation cannot fully compensate for missing or irrelevant retrieved information, and good retrieval does not guarantee that the model will use the evidence correctly.
For the overall architecture connecting these stages, see “What are the main components of a RAG system?”.
In short, retrieval decides what external information should be given to the model, while generation decides how to turn that information into an answer.
Learning Sequence
Retrieval-Augmented Generation Curriculum
Explore Related Questions
Deepen your understanding across related Retrieval-Augmented Generation topics.