Retrieval and generation
In our RAG application code, we have combined the Retrieval and Generation stages. From a diagram standpoint, this looks like what’s shown in Figure 4.6:
Figure 4.6 – Vectors during the Indexing stage of the RAG process
While retrieval and generation are two separate stages serving two important functions of the RAG application, they are combined in our code. When we invoke rag_chain
as the last step, it is stepping through both of these stages, making them difficult to separate when talking about the code. But conceptually, we will separate them here, and then show how they pull them together to process the user query and provide an intelligent generative AI response. Let’s start with the retrieval step.
Retrieval focused steps
In the complete code (which can be found in Chapter 2), there are only two areas in this code where actual retrieval takes place or is processed. This is the first:
# Post...