Hello guys.
So we are going to continue the discussion with respect to the embedding techniques.
In our previous video, we have already seen how we can use OpenAI embeddings and uh, convert your
text or document into vectors.
Let's say you do not want to use OpenAI API.
Then you can also go ahead with open source models.
And one of the way of using this open source models, uh, and use the embedding technique, is through
this platform, which is called as Lama.
Now in this video I'll show you how you can probably go ahead and do the setup of this olama and how
you can run the code.
Okay, so what exactly is Olama?
Olama is something is a kind of platform where you will be able to use open source LLM models like llama
353, Mistral and Gamma.
These are various open source models that are available right now.
And you can probably run all these models in your local machine itself, in your local workstation.
Right.
So here you can see get up and start running with large language models.
I'll be showing you, uh, this particular platform.
You can download it in your local machine and then you can download any of this specific models.
And then you can use this LM models.
Okay.
Uh, now when we discuss about embedding techniques with respect to this llama 353 Mistral gamma.
There are also different different embedding techniques with respect to that, right.
If I go ahead and use llama embedding, then let's say that I have installed llama two or llama three.
Um, then I'll be able to use the embedding techniques that are available over here.
So let me just go ahead step by step.
First of all, we'll see how to download this particular llama platform.
Uh I will go ahead and click on this llama.
First of all you need to go to this particular website called as alumni.com.
And if I go to this GitHub of this, it is a complete open source.
Here you will be able to see that it supports all these open source model okay.
So here you can see all these open source models like llama three 8 billion parameters.
Llama 370 billion parameters.
Phi three mini 3.8 billion parameters.
Then you have gamma.
Google gamma 2,000,000,007 billion parameters.
Then you have Mistral moon dream.
neural chart, star link code llama.
So we will be using all these specific models as we go ahead.
We'll be creating end to end projects by using all these models okay.
So first of all I will go ahead and click on download.
As soon as I go ahead and click on download.
You have this particular platform in all the operating system like uh, Mac OS, then you have Linux,
then you have windows, right?
So uh, right now, uh, since I have a windows machine, I will go ahead and download this particular
windows exe file.
Okay.
For this windows we will have uh exe file that will get downloaded.
Uh, but one condition is that you really need to have Windows 10 or later.
Then only this will work okay.
So this is one of the criteria.
So in order to download it just go ahead and click on this.
So as soon as you click on this you'll be able to see that I will be getting an EXE file that gets installed.
Okay.
Uh, once this x file gets installed, the installation is pretty much simple and easy.
So here what I will do is that I'll just go ahead and double click that particular x file once this
gets downloaded.
And just keep on clicking next okay.
Once you finish the installation here in the bottom section you'll be seeing one icon.
So this kind of icon you'll be able to see it.
Uh, I'm not able to zoom in much more over here, but just here you can see this particular icon will
get enabled.
Now this icon is nothing, but it is the icon of Allama.
Okay, so, uh, first of all, you just download the exe file, double click on that and keep on just
pressing next, next next and do the installation.
As soon as you do, the installation icon will be running in the back end.
Okay, now let's go back.
And after the installation I've already done the installation.
So I will show you how you can go ahead and download this kind of models.
Okay.
So after you do the installation just go ahead and open your command prompt.
Now in this prompt command prompt, let's say I want to go ahead and use llama three or llama two or
gamma model okay.
So I will just go ahead and use this or run this command.
Right.
So let's say if I go ahead and write all of my run gamma 2 billion parameters, I will go over here,
press paste it.
So allow me to run run gamma 2 billion parameter as soon as I run this command.
If this particular model is not downloaded in my local right.
So first of all, what it will do, it will pull this entire gamma two B model, uh, and then it will
download it in my local machine.
First of all, let's say if it is already downloaded then this chatbot will automatically get started.
So let me go ahead and press enter.
So here you'll be able to see that I have already downloaded this model.
Okay.
Uh, so here you'll be seeing hey nothing has got downloaded because already in my local machine it
has got downloaded.
If you're doing it for the first time initially, this particular model needs to get downloaded.
So as soon as you write this command or run gamma to be so, it will keep on downloading and it will
take some amount of time because this particular file is 1.4 GB.
Okay.
So once you have this you can go ahead and chat it.
Hey.
Hi.
Who are you?
Okay.
I'm a large language model trained by Google.
I'm capable of engaging in a whole wide range of conversation on various topics.
Okay, so here you have all the information you can ask any question as such.
Similarly, you can go ahead and play with any model that you want, any model that you want to work
with like a llama three llama 370 billion 5353 is from Microsoft, right?
Any of the models that you really want to play now, once you do this installation and everything is
working fine from the command prompt, now it's time that we go ahead and start our coding okay.
So so first of all, let me just go ahead and open my, uh, Allama embedding.
So here, uh, what I will do is that I will just show, hide my face.
Okay.
So here you can see Allama supports embedding models, making it possible to build a retrieval augmented
generation.
So this is basically a Rag application.
The based on the architecture that I have actually discussed okay.
Now first of all one of the library that you require is lang chain underscore community.
Okay.
So I'll just go ahead and write lang chain dash community.
Let me, uh, use this particular thing.
And along with this, what I am also going to do is that, uh, I'll talk about one more library that
will be required.
But before this, let's go ahead and install this.
Okay.
So here I'm just going to go ahead and write pip install minus r requirements.txt.
And here you'll be able to see that if it is already installed.
Uh, I've already done the installation so you can see that it has got successfully installed.
Okay.
Now in order to use the embedding, what I am actually going to do is that I'll go ahead and write from
long chain.
From long chain.
Uh, before that let me just go ahead and select my kernel.
Okay.
Don't forget to do that from long chain underscore community I'm just going to import.
Sorry.
It should be Langston underscore community dot embeddings.
Okay.
Embeddings I'll be importing.
Oh.
Llama embeddings okay.
So this is the embedding technique that we are going to use.
So once this gets executed you can see that it has got successfully executed.
Now I'll go ahead and create my embeddings okay.
Like how we did it with OpenAI.
And here I'm going to give my llama my embedding.
Okay.
I'm initializing my all of my embedding.
Remember, once we execute this by default, uh, this all of my embeddings for which LM model it will
be probably taking up, uh, it will be taking up for the llama two model.
So here I will just go ahead and write a comment.
By default it uses llama two.
Now if you really want to use the llama two so what I will do, I'll just go ahead and open my command
prompt.
Let me just execute this okay.
Control Z you just do control Z and exit.
So if I want to use this by default if I'm giving llama two okay.
Um over here uh, or this is taking llama two.
So we need to first of all install llama two okay.
Without installing llama two, it will not work.
Okay.
So that basically means here in llama embedding I will just go ahead and write.
My model is equal to.
And here I will give my model name.
Right.
Let's say as I said by default it uses llama two.
Since you know that I have already downloaded which model I have downloaded this gamma two B right.
So I will just go ahead and copy this particular model and I will paste it over here okay.
So once I go ahead and execute it.
here, you can see that it has got executed successfully.
Now this embedding technique is basically uh see the base URL is running over here.
The model is to be and we are using the embedding technique of this specific model okay.
Now I will just go ahead and use some text okay.
Uh let's say one of my text will be something like this R one is equal to I will write, hey, Allama,
or let me just go ahead and write embeddings.
Dot I will go ahead and write embed underscore documents.
So this is one of the functionality that I'm actually going to use.
Embed underscore documents.
If you want to see the definition it says that hey list of text words to embed inside this I have to
give the list of texts that I really need to do the ending.
So here I will just go ahead and create my list.
Okay.
Now with respect to the list list, let's say that I have two two sentences which I will be copying
it over here.
I'll say, hey, Alpha is the first character of the Greek alphabet and I'll say, hey, beta is the
second character letter of the Greek alphabet.
Okay, now what I will do is that I will just go ahead and execute this.
Okay.
So I'm just trying to embed this specific documents.
And here I'm just going to see our one.
And this is what I'm actually able to get it right.
If I say hey our one of zero.
So here this is my first one.
So first over here you can see.
And if you go ahead and see the length of this that many number of dimensions you will be able to see.
So in short, over here, this gamma model actually creates a dimension of 2048 with respect to the
vectors.
Okay.
Now let me go ahead and try one more functionality.
So here I'm going to use the same embedding.
And I'm going to embed a query.
See initially I used embed documents.
Right inside this I can give a list of text uh that I have here.
I will be just giving one text.
Right.
What is one sentence?
So what is the second letter of Greek alphabet?
And here also you could see that second had asked beta is the second letter of Greek alphabet.
And when I probably go ahead and see ah one of one, I'm actually able to get this particular, uh,
vectors right.
Uh, now this question is also some something similar only.
Okay.
Then I think, uh, both these vectors should match a bit.
Right?
Because here I'm just asking what is the second letter of Greek alphabet there?
I've given the answer.
So here if you go ahead and see just go ahead and compare this two vectors.
So this is 2.18 here also you can see 2.35.
So it's almost matching a bit right.
That basically means you are talking more about these two sentences are almost similar because that
is just an answer saying that hey beta is the second letter of the Greek alphabet.
Here I've just asked the question as what is the second letter of the Greek alphabet?
Right?
So I hope you are able to understand about this whole Arma embeddings.
Uh, similarly, you can go ahead and try different different embedding models also.
Right.
So Omar has different different embedding models okay.
So for that in order to show you what all embedding models it has, I'm just going to open a new browser
over here.
And I'm going to probably hit this particular URL.
So here it shows a blog embedding models.
Right.
So um, what are embedding models?
Embedding models are models that are trained specifically to generate vector embeddings.
Here you can see all the information.
Now with respect to embedding models.
You also have different different embedding models.
Right.
Let's say you have this mix by and embed large right.
You want to go ahead and see this particular model.
You can go ahead and see it over here.
Right.
Like how many parameters are there if you want to pull this okay.
Let's go ahead and pull it.
Let's see okay.
So I'll paste it over here I'll press enter.
Now you see if I'm downloading it downloading it for the first time.
It may take some amount of time because this is 669 MB.
So this is getting downloaded.
Once it gets downloaded I can use this model.
Okay.
So uh, we will wait for some time since this is basically getting downloaded till then, we'll go ahead
and explore other models also.
So inside this you also have Nomic embed text.
You also have all mini LM.
So these are some very free models that are available.
Right.
And uh we can actually use this kind of models and perform our embeddings, uh, whatever things we
really want to do.
Okay.
So for this also I will try to show you how to actually do it.
And, uh, you know, uh, over here also you can see in alarm also you have this chroma DB if you want
to save it in the form of collections, you can actually do that and again retrieve it and generate
it.
It is up to you.
So we'll discuss more about this as we go ahead.
But in this video as I said uh, that we are just focusing on the embedding techniques.
Now let me just go back to my command prompt right now.
228 to 2 2037 MB has been loaded.
Now I will just go ahead and write my code.
Till then.
Okay, so now let's say that I want to use some other embedding models.
Other embedding models okay.
If you want to probably go ahead and explore the other embedding models, I'll keep the link over here
so that you can refer it.
Okay.
So this is the link uh.
Ah that is there for the other embedding models.
Now once this basically gets downloaded the embedding model, I will just go ahead and call this okay.
So here you can see I've created an embedding with all of my embedding.
And I'm using the model MKB I embed large.
Then I've said that this is the text.
And we try to just find out what will be the my vector right.
So this will basically be my query underscore result.
Now let's quickly see how much time is basically involved.
Another 200 MB.
And then once this download actually happens it's it is hardly taking 38 second.
So this is what right.
If that model is not downloaded in your local then you have to first of all go ahead and download it.
And here also you can see that another 120 MB is there.
Uh, similarly that is with respect to all the LM models.
If you do not have llama three, then again you have to go ahead and write llama pull llama three,
otherwise your code will not get executed.
Okay, but this.
In short, what is happening is that this model is basically getting downloaded in the local itself.
So another 3 to 4 seconds and then we are good to go to run this okay.
So now here you can see it has downloaded it 11 KB.
This is also downloaded.
So it's just like downloading a Docker's right.
Dockers also gets downloaded in a similar way.
Right.
So finally has got downloaded.
Let's go ahead and execute it.
Now I will be using this hole on my embedding with respect to MB, I embed large and here is your entire
length.
Now let's go ahead and see length of query result.
So it has nothing but 1024 dimensions right?
So I hope you are able to understand about the embedding technique using ulama.
Uh, you can again try different, different open source embedding techniques.
It is up to you.
But again, our main aim was to understand how we can use ulama and perform embedding.
But trust me, if you do not have APIs opening API, you can definitely use this.
And uh, up going ahead, right?
I'll also be creating an end to end project with the help of ulama.
So yes, this was it.
I will see you all in the next video.
Thank you.