Retrieval Augmented Generation (RAG)
This section provides background on Retrieval Augmented Generation (RAG) (opens in a new tab) using the MuleSoft AI Chain (MAC) Project.
RAG using the MAC Project
The MAC Project provides all the low level capabilities to perform RAG, from basic to advanced, including agentic RAG. Through the suite of connectors, we are supporting all phases of RAG,
- Ingestion: This phase takes unstructered data from file storages and embedd it into the supported Vector Databases.
- Query Intake: This phases takes in the users query and prepares it for the next step.
- Retrieval: This is the retrieval phase, which queries the vector database and re-assesses the relevant data based on a defined prompt template. If needed, the retrieval process will be repeated with a refined query.
- Augmentation: This phase takes the relevant context and augment an answer for the users query.
- Reasoning: This phase assess users query and refines it based on a defined prompt template.
- Refinement: This phase refines the query of the user to retrieve more contextual results.
- Repetitions: This implementation of agentic RAG allows the incoming request to control the repetition and refinement based on an input parameter with a overall default max of 3.
- Grounded Responses: Answering questions / queries only on available context. If no context is retrieved, the augmentation should not generate an answer.
Standard RAG
The Standard RAG process is simple, cheap and consist of a single query retrieval. Based on the results of the retrieval the augmentation will happen. The process is not ensuring qualitative assessment of the query and retrieval for additional refinement.
Advanced RAG
There are various other ways to perform Advanced RAG, in this diagram, we are using the LLM to refine the original query with 3 alternative queries and retrieve through similarity search relevant data, which is prepared and sent to the LLM.
This is just one example of Advanced RAG, there are many other examples of Advanced RAG.
Standard RAG vs Advanced RAG
In this short demo video, we are demonstrating the benefits of an Advanced RAG technique, compared to the Standard RAG process.
Agentic RAG
Agentic RAG implements a repetitive refinement of the query and contextual assessment of the retrieval to ensure the augmentation is relevant to the users query.
Agentic RAG Implementation in MuleSoft
Here is an example implementation of an agentic RAG workflow in Mulesoft Anypoint Studio.
MAC Connectors for RAG
All provided connectors of the MAC Project play a role within RAG.
Required Connectors for RAG
-
MAC Vectors: MAC Vectors provides access to a broad number of external Vector Stores and Databases. It is built to be leveraged by the MAC Projects AI Connector (Amazon Bedrock, MuleSoft AI Chain, MAC Inference & Einstein AI) The MAC Vectors connector is the backbone for any RAG implementation in MuleSoft. It helps you to ingest and embed your unstructered data into the vector database of your choice. MAC Vectors provides the low level operations to perform most advanced retrieval implementations.
-
MuleSoft AI Chain, MAC Inference, Einstein AI & Amazon Bedrock: The AI Connectors will support the augmentation of the retrieval via the Agent define prompt template (1,2,3 or 4) operation by combining it to MAC Vectors Query operations.
RAG Demos Playlist
The MuleSoft community has created some amazing content around Retrieval Augmented Generation using the MAC Project. Check it out on our YouTube Channel.