Fig. 1: A typical retrieval-augmented generation framework.
From: Retrieval-augmented generation for generative artificial intelligence in health care

External data is first encoded into vectors and stored in the vector database (where vectors are mathematical representations of various types of data in a high-dimensional space). In the retrieval stage, when receiving a user query, the retriever searches for the most relevant information from the vector database. In the generation stage, both the user’s query and the retrieved information are used to prompt the model to generate content.