Skip to main content

Command Palette

Search for a command to run...

RAG (Retrieval Augmented Generation)

Published
โ€ข4 min read
S
Passionate about coding and the limitless possibilities of cloud technology. I thrive on turning ideas into scalable, efficient solutions. Let's connect and explore the exciting synergy between code and the cloud! ๐Ÿค– AI / ML๐Ÿง | ๐Ÿ“Š - Data Science | Azureโ˜๏ธAWS | Linux๐Ÿง| Windows๐Ÿ–ฅ๏ธ| Python | JAVA | ๐Ÿณ Docker | Git | Gitlab | โš“๏ธKubernetes | ๐Ÿš€ Jenkins CI/CD | ๐Ÿ—๏ธ terraform | SQL.

๐‘๐ž๐ญ๐ซ๐ข๐ž๐ฏ๐š๐ฅ-๐€๐ฎ๐ ๐ฆ๐ž๐ง๐ญ๐ž๐ ๐†๐ž๐ง๐ž๐ซ๐š๐ญ๐ข๐จ๐ง (๐‘๐€๐†)
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 โค

More from this blog

Untitled Publication

26 posts