Example of an RAG workflow
Let’s walk through as an example step by step, as shown in the image. Imagine a platform where users can ask about ongoing cricket matches, including recent performances, statistics, and trivia:
- Suppose the user asks, “How did Virat Kohli perform in the last match, and what’s an interesting fact from that game?” Since the LLM was trained until April 2023, the LLM may not have this answer.
- The retrieval model will embed the query and send it to a vector DB.
- All the latest cricket news is stored in a vector DB in a properly indexed format using ANN strategies such as HNSW. The vector DB performs a cosine similarity with the indexed information and provides a few relevant results or contexts.
- The retrieved context is then sent to the LLM along with the query to synthesize the information and provide a relevant answer.
- The LLM provides the relevant answer: “Virat Kohli scored 85 runs off 70 balls in the last match. An intriguing detail from that game is that it was the first time in three years that he hit more than seven boundaries in an ODI inning.”
The following image illustrates the preceding points:

Figure 4.11 – Representation of RAG workflow with vector database
Business applications of RAG
In the following list, we have mentioned a few popular business applications of RAG based on what we’ve seen in the industry:
- Enterprise search engines: One of the most prominent applications of RAG is in the realm of enterprise learning and development, serving as a search engine for employee upskilling. Employees can pose questions about the company, its culture, or specific tools, and RAG swiftly delivers accurate and relevant answers.
- Legal and compliance: RAG fetches relevant case laws or checks business practices against regulations.
- Ecommerce: RAG suggests products or summarizes reviews based on user behavior and queries.
- Customer support: RAG provides precise answers to customer queries by pulling information from the company’s knowledge base and providing solutions in real time.
- Medical and healthcare: RAG retrieves pertinent medical research or provides preliminary symptom-based suggestions.