RAG (Retrieval Augmented Generation)

๐๐๐ญ๐ซ๐ข๐๐ฏ๐๐ฅ-๐๐ฎ๐ ๐ฆ๐๐ง๐ญ๐๐ ๐๐๐ง๐๐ซ๐๐ญ๐ข๐จ๐ง (๐๐๐)
RAG is an AI technique where a Large Language Model (LLM) fetches relevant, up-to-date information from external sources (like a database or web search) and then uses that data to generate more ๐๐๐๐ฎ๐ซ๐๐ญ๐ ๐๐ง๐ ๐๐จ๐ง๐ญ๐๐ฑ๐ญ-๐๐ฐ๐๐ซ๐ ๐๐ง๐ฌ๐ฐ๐๐ซ๐ฌ.
Whenever we have any LLM model, letโs consider this is out basic LLM model and its trained on data till July 2024, now with respect to this perticular model you will be seeing that whenever we give an input to this model, Since it has been trained on the data before July 2024 it will be abl to give you some kind of output.
and waht if, if ask a question what is the current AI News? This LLM will not be able to Answer because obviously its trained on this some specific data. So what LLM does is that if we provide LLM Model Integration with some third party tools letโs say one of the tool is web search tool.
now with this web search what it will do whenever we give question what is the current AI News the LLM will be able to make a call to this web search tool and it will be able to get the response, the LLM Model will be able to provide you the output saying that hey todayโs News is this and all.
Now in this perticular usecase you will be able to see that we have deependency on external tools
Now letโs say if i go ahead and ask this is my company XYZ,i am an employee in the company for this particular company i say, hey what is the leave policy or what is the recent leave policy of XYZ.
So i asked this perticular question letโs say there is a chatbot that has got created for this work only, where i ask anything company related information and this chatbot will be important because this chatbot will be able to provide you some kind of information.
Now in this perticular question the LLM will be dependent on some kind of retriever so letโs say this company information whatever information is there, the current information everything it will be stored in some kind of database and this database we say it vector database now inside this vector database usually stores text data in the form of vectors, Now whenever i ask this question what is the leave policy of XYZ, so what this LLM will do, it will try to interact with this vector database because these all data information stored already in this vector database and based on this will be able to get a specific response.
Now this kind of communication whenever we are trying to communicate with some kind of vector database and then we take this data from vector database as a context and the LLM will be able to give you the summarised output.
So here there are three important thing basically happening and that is RAG all about.
RAG Means Retrieval Augmented Generation
Note: R means Retrieval
Retrieval basically means what, since i am communicating with the database so this is my vector database so we are retrieving some content from this particular database.
A means Augmented: when we retrieve any content from vector database
Augmented basically means that we will try to enrich it. We enrich of retrieval content what does enrich basically mean
letโs say from this perticular retreival i got something like this [Revenue inreased by 10%] So when we say augmentation how we are enrich this content you will be able to get text that iโm getting from the vector database we will try to add more metadata.
Augmented={โTextโ:Revenue increase by 10%, โSourceโ: Tesla annual Reports, โDataโ}
so there are all the metadata right now with the help of this metadata, at the end of the day your generation the summeraised output will be really good so this way we will able to vary Accurated provide on output.
G means Generations: So LLM Model taking this context and it is generating some kind of output,So it can be a summarised output or any kind of output so some output is basically comming up that basically means this LLM Model along with the contaxt that it got from the retriever is generating something.
so this is what all about RAG what exactly retrieval augmented generation basically means.
Follow For More๐
Happy Coding โค