DEV Community

Hasindu Nagolla
Hasindu Nagolla

Posted on

What is the RAG (Retrieval-Augmented Generation) ๐Ÿ”ฅ๐Ÿ˜ณ

Think, you are writing an exam. We usually write exams based on what we have memorized. But RAG is like an open book exam. It means we will write the exam using the resources on time, not based on our memory. just like writing answers to the question using a book.

AI models like ChatGPT (actually LLMs) can answer based on their training data set. They cannot provide answers beyond their training data. After integrating the RAG technology, AI models can provide answers by accessing the new outside databases or documents. It will be more accurate than the common answers that return from the LLMs.

Why RAG? ๐Ÿค”๐Ÿค”

AI models (LLMs) like ChatGPT and Gemini are brilliant, but they have some limitations,

  1. Outdated Data - they trained on past data, because they have no idea about on time information. So they do predict. (Knowledge Cutoff)
  2. Hallucinations - sometimes they provide random answers instead of the correct answer.
  3. Personal Data - general AI models have no idea about your personal information, like private details or company information.

We can completely mitigate these issues using RAG.

How does it work?

This entire process is done through 4 steps,

  1. Asking a question - think you are asking "can i get a leave?"
  2. Retrieve (search) - The AI model (RAG integrated) does not provide the answer directly; it will search your company's HR policies and regulations.
  3. Augmented - then the system will collect your problem and the company information and send it to the AL model.
  4. Generation - now, the AI model is providing an accurate answer after analysing your question with your company details.

Advantages of RAG, ๐Ÿ˜ฎ๐Ÿ˜ฎ

  1. ๐Ÿ‘‰Low cost - no need to train an AI model from scratch
  2. ๐Ÿ‘‰Real-time information - if you ask for real time news, you can get answers if they exist in the databases
  3. ๐Ÿ‘‰Stopping hallucinations - because the AI model will generate answers based on provided real information.
  4. ๐Ÿ‘‰Sources - The AI model can highlight references based on the provided documents or databases.

As a summary, RAG(Retrieval-Augmented Generation) is like a bridge between your data and a separate AI model like ChatGPT. We can get highly accurate answers from AI models by providing our information as an outside data source. ๐Ÿ‘๐Ÿ‘

Top comments (0)