A one shot read to understand and get started with RAG!
Lets break the abbreviation: Assume that there is a task of answering a query “Who was the King Raja Raja Cholan and how did Chola dynasty reach its zenith during his rule?” Suppose this is the query raised to find the answer inside the text book of “History of Tamils”.
R(Retrieval) — Retrieving the relevant passages from the text book all that is related to Cholas.
A(Augmented) — Using the relevant retrieved information to modify an input to a generative model. From the retrieved text of Cholas seeking for Raja Raja Chola information as it is raised in the query.(e.g. an LLM).
G(Generation) — Generating an output as asked in the query. In the case of an LLM, generating a passage of text given an input prompt.
Goal of RAG: The main goal of RAG is to improve the generation output of LLMs.
Two primary improvements in LLM generation due to RAG are,
1.Preventing Hallucinations:
LLM’s often hallucinate by giving wrong information that seems to be correct while in reality it would be false. RAG pipelines can help LLMs generate more factual outputs by providing them with factual (retrieved) inputs.
2.Work with custom data:
LLMs are trained with huge amount of internet-based data while they often suffer from lack of specific domain knowledge. RAG systems can provide LLMs with domain-specific data such as medical information or company documentation.
Problems that can be solved with the help of RAG pipeline:
Textbook Q&A: As in our example in the beginning, answers can be retrieved from large text books to learn further.
Customer Support Chatbot: A chatbot to answer the queries of customer related to the company’s products and services by retrieving information from the company’s documentation.
Email chain analysis: Instead of searching through individual emails finding the relevant email that we want by giving the keyword to the LLM to retrieve information and find that particular customer’s email easily.
It was introduced in the paper Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks.
To get a deeper understanding on RAG do a guided project in RAG step by step to understand the work flow of it.
I would recommend : https://youtu.be/qN_2fnOPY-M?si=xeKsfnWncJpNc_k0
Cheers to more learning and growing!
Thank you,
SHARMILA L