- [Instructor] In the world of NoSQL,
vector-databases are being increasingly used
in generative AI solutions.
What is a vector-database and how do you actually use it?
Well, you can see by the graphic here
that we take our content,
and rather than just querying directly using a query engine
like SQL or a query language associated,
there is an interim step, which is called embedding.
What this embedding does is it translates the source data
into a numerical representation,
a set of vectors.
The model that is embedded is then used
for querying in a more efficient manner.
The purpose of this is to take semi-structured data
and to represent it in a highly efficient manner
so that queries can be performed against thousands,
tens of thousands, or even millions of dimensions of data.
While there are many open source solutions,
such as ChromaDB, a new way to work
with vector-databases if you work on the cloud,
is to use vendor created solutions
because they're somewhat simpler to implement.
They're often created
as indexing solutions rather than databases.
But the underlying technology is the same.
It's embeddings and vectors.
Let's look at an example in the GCP ecosystem.
Using a Jupyter Notebook inside of Google Cloud
from Colab Enterprise.
If you don't have a Google Cloud account,
you can also run this sample,
which is part of Google sample set on public Colab.
We're going to take a look at
how this works in the Google ecosystem.
Other cloud vendors are similar.
So you can see on the right side, we have a look data set.
This is a public data set, has 30,000 rows
of synthetic product data for e-commerce.
We're first going to get the data,
so we're just downloading the data into a bucket.
And I've pre-run this sample
'cause it takes about 30 minutes to run.
And then we're going to use the associated APIs
to quickly build and deploy a vector search index.
There's a couple steps to do this.
First, we have to take the text information
and we have to change the representation
into the numeric vectors.
Using Google's AI platform,
we can easily do this by simply setting up some parameters.
And you can see in the sample here,
the parameters are listed.
We have the dimensions, in our case,
we're going to use 768 from the text embeddings API,
and the approximate neighbors count,
how many similar items we want to retrieve in typical cases.
And then we're going to allow for indexes
to be updated via streaming, which is very typical
for e-commerce type of applications where you have lots
of data updates coming rapidly.
Once we create the index,
then we're going to create an endpoint
and that will allow us to query
and work with the data that's represented
by these vector embeddings via this endpoint.
The endpoint is almost like an API.
And again, what the Google ecosystem has done is they have
exposed this functionality, which in an open source example
by comparison, you would have
to create a database such as ChromaDB.
You would have to set the database up,
you would have to set up the VMs, connect them, scale them.
You would have to select your method of embedding
or write your embedding code, create your embeddings,
load your database,
and then determine your query methodology
and write your query language.
It's really a lot more overhead
than using these integrated APIs.
So once we've created the index endpoint,
then we need to deploy it.
Once we deploy it inside of Vertex AI,
you can see that we have a vector search section,
and here is our index,
and here is our endpoint.
You can have multiple endpoints for scaling.
Inside of our index,
we can then use our associated API to query it.
And you can see that we have done some querying.
If we look on the monitoring, we ran a couple queries there.
What does that look like?
If we scroll down, there we've deployed the index
and then we need to stream the created index
with our embedded data,
which we've done here, and insert it.
It's just a for loop.
And then for our query,
this is the syntax of the query language.
So what we're doing here is we're getting the embedding
from the product embeds JSON.
And then once we get that,
we can specify a product ID to get the embedding for it,
and we can run a query with our particular embedding to,
in this case, find our neighbors
because that's how we generated our embedding.
So this is a shopping basket example.
We can see, you know, what type of products people bought,
when they bought, in this case, the excursion short,
and then what's the proximity in terms of frequency
of nearest neighbors.
And it's really just that simple.
It exposes itself kind of like a more traditional indexing.
The difference here is we are using embeddings for scale.
And when I started this movie, I talked about gen AI,
and this is the use case
that my customers are using this capability
because for gen AI, of course,
when you are either fine tuning a model
or you are not as often,
but trying to build your own custom of models,
you are working with really a crushing amount of data
and more typical approaches
in the NoSQL ecosystem are really unable to be able to scale
unless you have the resources of someone like a Google.
So this new capability of generating embeddings allows
for more efficient query ability of semi-structured data
and is very well integrated into Google
and other cloud vendor ecosystems as indexing capability.