We ended the last lecture on this picture
of what RAG actually is, and it's about
getting all our data into some kind of
search index so we can search.
Let's turn this into a more abstract picture
and show the flow of what's going on
with the various components.
So the moving parts are that we of
course have some source data.
We know of course that not all the
data can be put in and also that
not all the data we want to put
in.
So we need to take this data and
we need to clean it and select it.
So that could be taking a PDF, getting
the raw data out of it, getting the
data out of images, or just taking the
data we have and preparing it so it
is in the right format of the vector
search.
After that, we need to embed the data,
and the embedding of the data is actually
to call a limb with the data in
the structure we wanted and returning it back
as what is called a vector.
So vector is 1536 dimensions of that piece
of data, so it can be searched across
various things.
So if we search for cat, the word
kitten can also be a similar type of
data and so on.
We'll go more into embeddings in a separate
lecture.
And then we ingest it into a vector
store.
There's various different vector stores to choose from,
like for example, Azure AI Search, SQL Server
that can be it, SQLite can be it,
you can even do in-memory, Cosmos DB,
and there's some open source versions as well
like Quadrant and Veviate, and other players like
Progress and Redis is in the game as
well.
So we're going to use SQL Server and
SQLite and in-memory primarily, but all of
them work the same because they're working with
a NuGet package called MicrosoftExtensions.VectorData. Then our
user comes into play and asks that question.
And from that side, we again embed, and
what we are embedding is actually the search
query, because when we need to search for
something, we need to similarity search against these
vectors we put in on which of them
are most like our question.
So we get our search query, turn it
into a vector, and then we do a
vector similarity search.
When we have done that search, we get
some results back, we choose how many, and
for each search result, we get some kind
of score, often it's one being it's an
exact match, and zero being nothing in the
manner.
So like, for example, if we get a
score of 0.7, that means it's 0
% the same, our search query compared to
what it actually found.
And once that happens, our AI, of course,
can use those search results, get them into
the context together with the question we have,
and answer the question.
So this is all the parts that are,
and we will have separate lectures on embeddings
and ingestion and so on, and putting it
all together in the next few lectures.