And I'm delighted to welcome you back to LM engineering on the day that we turn to vectors.
Finally, I've been talking about vectors for so long.
Today we actually get to play with them.
We are going to be going into Jupyter Lab soon and creating chunks of.
We're creating vectors from chunks of text using OpenAI embeddings, the encoding model that I talked
about before.
We're going to store those vectors in the very popular open source vector database called chroma.
And we're then going to visualize the vectors get a sense for what they represent.
And that will then be an exercise for you to keep playing with vectors.
Try putting your own things into vectors and get a better and better sense of what it what it means
to have a meaning by turning text into a bunch of numbers.
So let me talk for a moment about these different types of of model.
How how do you turn text into vectors.
So there's first of all, there's this very simplistic way that you could do it.
You could for example, say come up with a vocabulary.
So come up with a list of possible words.
Let's say the first word in your vocabulary is the word dog, and the second word in your vocabulary
is the word cat.
And what you could do is take a block of text and just count the number of times any particular word
is in that block of text.
And then if the word dog, for example, is in there twice, then you would put a two in the first location
in your vector and cat is in there once.
Then you would put one in that location and so on.
So it would really just be counting the number of words of a of a particular type and putting that in
a vector.
And that would be very simplistic.
It wouldn't reflect the order in which the words are laid out, and it wouldn't reflect the fact, for
example, that the same word Java could refer to a type of coffee bean or to a programming language.
It would just be the count of the number of words.
So that would be rather simplistic.
And luckily there are more advanced methods for doing this.
One of the ones that got a lot of attention was in 2013, the arrival of something called word two vec,
which was able to use use a deep neural network to start to convert words to vectors in a way that seemed
to reflect their meaning.
And it was really it was with word two vec that we started to talk about things like, uh, king minus
man plus woman equals queen.
Uh, Burt is the model that I talked about some time ago.
Now it was, uh, it's a transformer model for encoding that Google produced shortly after publishing
their paper, Inventing Transformers.
And the one that we're going to use, OpenAI embeddings, is one that is from OpenAI.
And the most recent version is with, uh, updates from 2024.
Um, and so that is going to be the latest and greatest model that we're going to use for converting
text into numbers vectors.
So with that, uh, let me just quickly talk about chroma and then we will get to it.
So chroma is an example of one of the, uh, vector data stores.
There are quite a few of them, and many of the of the main databases also now support taking vectors
and searching on vectors.
An example MongoDB that lots of people use as a NoSQL data store will also take vectors and can act
as a vector database.
But Cromer was sort of first and foremost a vector database.
And this is uh, its website.
Uh, and you can see it makes a, it's got better pictures than I had with an old school, uh, Mac
interface here.
Uh, but the idea that, that you could do a query in your I application and it can retrieve from a
bunch of vectors and that retrieve data gets put into the prompt and query.
So it's a fancier version of the diagram that I showed you last time.
Uh, so this is Cromer.
This is what we'll be using to store our vectors.
And I think quite enough chit chat.
It's time for us to get JupyterLab, and it's time for us to use vectors first hand.
See you there.