13 Oct Example of Retrieval Augmented Generation (RAG)
Let us now see an example of the RAG process. This is an example flow that shows what happens when you ask a query or type a prompt.
Here is the flow:
- Input Query: Let’s say our prompt is “Tell me about the history of the Taj Mahal.”
- Document Retrieval:
Initial Search: The system searches through a large dataset (like a collection of articles) to find relevant
documents about the Taj Mahal.
Chunking: These documents are divided into smaller chunks, each containing a few paragraphs or sentences. - Vector Embeddings:
Encoding: The query “Tell me about the history of the Taj Mahal” is encoded into a vector. Each chunk of the retrieved documents is also encoded into vector embeddings. - Similarity Calculation:
Similarity: The system calculates the cosine similarity between the query vector and each chunk’s vector.
Selection: The top-k most relevant chunks are selected based on their similarity scores. - Relevance Ranking:
The retrieved and encoded document chunks are ranked according to their relevance to the query using
ranking algorithms. - Context Encoding: Encode the query and selected documents together.
- Attention Mechanism: Focus on the most relevant parts of the context.
- Response Generation: Using an LLM like GPT, generate a detailed response
- Output: “The Taj Mahal is a breathtaking white-marble mausoleum located in Agra, India, along the
southern bank of the Yamuna River”
Example – Uploading Documents
Q. Let’s say you uploaded your document on an AI chatbot like ChatBot and got the result. Is it RAG?
Yes, uploading your document to an AI chatbot and getting results based on its content is a prime example of Retrieval-Augmented Generation (RAG). Let us see why:
-
Document Upload: The document you upload acts as an external data source.
-
Retrieval: The chatbot retrieves relevant information from this document.
-
Generation: It uses this information to generate responses based on your query.
RAG combines retrieval capabilities (fetching information from your document) with generation (providing a coherent and contextually relevant response), making the interaction more informative and tailored.
If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
- What is Machine Learning
- What is a Machine Learning Model
- Types of Machine Learning
- Supervised vs Unsupervised vs Reinforcement Machine Learning
- What is Deep Learning
- Feedforward Neural Networks (FNN)
- Convolutional Neural Network (CNN)
- Recurrent Neural Networks (RNN)
- Long short-term memory (LSTM)
- Generative Adversarial Networks (GANs)
No Comments