Retrieval-Augmented Generation
Benefits of RAG in designing an agent:
reduce its hallucinations
provide it with recent data at lower cost
be able to modify / delete its information easily
Principle of RAG:
retrieve passages from documents
that are close to the semantic context of a prompt
and send them with the prompt to an LLM for generation.
Preparation of the documents :
we split them into passages , according to a controlled strategy
we convert each passage into a vector
we store :
the text
the vectors and the information needed to retrieve the passages
Relevant passages retrieval mechanism:
vector search (also called semantic search):
their vectors are close to the vector of the prompt to be completed.
Mechanism for sending to the LLM :
the text of the passages is added to the initial prompt
everything is sent to the LLM as a standard prompt .