RAG BASiCS

DEEPAK KumarDEEPAK Kumar
3 min read

hello friends welcome you all.
today we are going to discuss some basic topic related to rag.
RAG - Rag stands for retrival agumented generation.
let’s first understand the problem why we need to use RAG.
let assume that you have to understand or learn about the dark particles, but there are multiple books in the market and they are saying that they have best content. so you decided to study one topic that is dark matter from all the books. for studying just one topic you have to search the topic in the books. for just searching you need many weeks. If you can spent months for just searching the topic then this article is not for you. For tackling the problem we retrival agumented generatin.

now lets understand how rag solve can solve this problem. it will save your weaks even months for searching.
solution of the problem is RAG-chat app.
we will give all the books to AI as a data. Ai will store all the data. then you can ask any question from Ai related to the books. it will give very precise response.

now les’s understand that how a RAG-application works in the backend.
1. first we have to store data. for storing that we have to use a database. we will use Qdrant(pronounce ‘quadrant‘) db. in qdrant db we can store vector data. lets understand how a vector database store data.
let understand with an example , day 01- i was preparing for the jee exam. in my there are many student. some student came from north, some came from south, some came from east , some came from the west. in the begginnig of classes any student can select a for him/her. after few months some student are saying that these bench are reserved for south people and these bench are reserved for each people. same for others.
moral of the story, do not go for jee. this is joke.
in this exaple we understand that some type of people make their group. similarly in the qdrant db we keep same type of data at region. and this region is a n dimensional space.
what is n-dimentional space. it is nothing but it is n-dimention vector.
initially we have row data. and it is a large data. first we have convert the data into chunk.
at this time we have to perform chunk overlapping as well lets understand it with the exaples.
my name is deepak. if give chunk size is 3. it will be store like this [“dee“,”pak”];
if ask the Ai to tell my name then what it will return. i don’t know. for overcome this problem we have to chunk overlap. chunk overlap prevent from breaking the words as well as breaking the sentence.

flow chart

part 01

large data
|
small chunks + chunk overlap
|
convert chunks into vector embedding
|
store vector embedding into vector database(qdrant db).

part 02

Take query from the user
|
convert data into vector embedding.
|
retrive similar data from the qdrant db (using above vector embedding)
|
pass the retrived info + user query to LLM
|
LLM will give the response.

thanks for reading the article.

0
Subscribe to my newsletter

Read articles from DEEPAK Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

DEEPAK Kumar
DEEPAK Kumar