Hello guys.
So we are going to continue the fine tuning series.
And in this video I'm going to talk about an amazing platform which is called as laminae.
And this laminae platform has almost each and every thing from using basic LM models to probably create
chat bots till fine tuning different, different LM models with your own custom data.
And trust me, uh, if you have seen the Google gamma model, uh, fine tuning right over there, you
found lot of many difficulties.
Lot, many tasks needed to be done.
But this as a platform simplifies the entire fine tuning process.
So let me just go ahead and show you an example how you can perform fine tuning in this.
And obviously in this you will also be getting some amount of free things like with respect to if I
just go ahead and see the pricing.
Right.
So here in the pricing, uh, in the free you can see, see what we can do.
It can see the full model life cycle.
Choose a model run rack.
Try running.
See values used for inferencing compared to a top open source models like llama three, Mistral 2553.
All these models are specifically available 5000 inferences request per month and then limited turning
request.
And you can also run on Llamas Optimized Compute platform using Lora Beft.
Uh, so already we have learned about Lora Beft quantization.
Lora.
Right.
So we'll try to see how we can probably, uh, do the entire fine tuning process.
Okay.
Um, first of all, let's go ahead and log in over here.
So once you probably log in, you'll be able to see that you'll get redirected to app dot a dot AI.
Uh, once you go over here, you can see that out of 5000 total inferences, I have somewhere around
this many number remaining.
So obviously when you can try this much, definitely you'll be able to understand how does the entire
fine tuning process continue?
Right.
And currently this is the API token that they actually provide.
Okay.
Along with this you can go ahead and train your model.
So let's say that this is the model that I have actually trained you know, and here you can see this
model with respect to the custom data set how it is and how was the base model before.
Right.
So all those results also you'll be able to compare, you'll be able to go through the playground and
ask any kind of questions.
Uh, you can probably go ahead and check out the loss, uh, logs with respect to the entire fine tuning
process that also you can probably do, right?
Not only that, here is the entire documentation, which you can also go ahead and follow.
What are the documentation how to use this entire, uh, laminae, uh, using this particular library,
how you can basically start okay.
Okay.
So, uh, this is really, uh, you know, amazing because, uh, completely for free, you should you
you will be definitely able to access all these things.
Okay, so let's start and let me just show you a basic example with respect to fine tuning.
And in this particular example I will go ahead and um, you know, take llama three model.
Uh, and then we'll try to see that how things works over here okay.
So first of all, I will go back to my the same graph line chain.
I'll be using the same requirement.
Uh dot txt over here because I may require all these libraries.
I may not require neo for J.
Uh, but I will just try to show you with respect to that over here.
To start with, we require one model.
Okay.
Which model is that we definitely require.
For that it is nothing but lemon.
So let's go ahead.
And first of all start with the laminate API.
Sorry laminate model itself.
So we can go ahead and probably start doing it okay.
So first of all I will just go ahead and write over here okay.
And I'll show you the step by step how you can basically do.
Okay.
So the first thing that I will be writing is my library which I'm actually going to use okay laminate.
So I will just go over here.
Just go ahead and write pip install minus r requirement dot txt.
Okay.
Okay I'm in different folder okay.
CD dot dot.
And here also I will write CD.
Uh I'm inside my graph lamp chain okay fine.
Uh pip install minus pip install minus r requirement dot txt.
So once you do that, the installation will take place.
I've already done the installation so that it does not take much more time.
Now here I've created one folder called as fine tuning, and here is one fire file that is called as
a fine tuning.py.
I'll be writing my entire code over here itself as we go ahead.
Now, the best thing about using laminae with respect to any kind of models that you go, first of all,
you need to prepare your data.
Okay, one example of preparing a data over here.
I have actually created this.
Okay.
And, uh, I have also checked the documentation.
It was very simple.
So over here you can see I will just try to create a Q and a fine tuning LM model.
I'll use llama three.
But with respect to this particular data okay.
So here you can see in every data you have this in the form of list of key value pairs okay.
So here you have input.
Then you have output okay.
So for this input this is the output for this input.
This is the output.
And if you probably see this it is everything is about laminae itself is the laminae type system similar
to a Python type system.
This is just like f x.
Uh some kind of questions that you have related to laminae.
Right.
So here you have just laminae have a limit on the number of API requests I can make.
Laminae provides each and every user with free tokens up front, right?
So this is the answer.
If I ask this question, this should be the answer.
Like this.
We have created a set of questions and inputs and outputs okay.
So here it actually becomes this particular function.
This function is get data.
And we are creating a variable over here okay.
Now let's go ahead and start this okay.
So this is my data which I have.
And obviously for creating this particular data I don't think so.
You'll require much time.
So first of all I will go ahead and write import laminae okay.
Along with this I'll say hey from laminae import laminae okay.
So there will be this laminae class which I'm going to specifically use.
Okay.
Now I've already told you first to start with we need an API key.
So if you go over here if you go to the eval results or let me just see this okay.
Um.
Mhm.
So here if I go to the account okay.
So this is the API key that I have.
So I'm just going to copy this particular API key.
And I am going to just assign this API key to this particular variable.
Right.
So first of all what I'll write I'll write laminae dot API underscore key is equal to this particular
API key okay.
Okay.
So this is the API key that I'm setting.
You can also store this in your environment variable and call it over here by using AWS dot get env
right that I've already shown you.
Now I will just go ahead and use my LM models.
Now in order to call my LM model, I'll just use this laminae class.
Inside this I will give my model dash name.
Now model underscore name will be in the same way like how you define your model for hugging face.
Right?
So let's say I will go ahead and use this meta llama model.
So it is meta llama slash meta llama okay.
And this we are going to use three.
It is nothing but 8 billion parameter.
And this is nothing but instruct model I'm going to use.
Like this is how the model is available in your hugging face also.
Right?
If you go and see for this particular model, you'll get the entire path Because the best thing is that
this entire thing will be running in the cloud, and it'll be taking care of all the quantization process,
even Laura and Laura.
Every fine tuning will basically happen over there.
Okay.
So this basically becomes my LM model.
Now what I will do I will just go ahead and write data is equal to get underscore data.
Here I get my entire data itself.
Now I'm going to fine tune my entire LM model.
I'll just write LM dot fine tune.
Sorry, LM dot.
There's a function called as tune.
And inside this we will just go ahead and write data or so there is a parameter which is called as data
or data set which is nothing.
But it is assigned to this particular value called as data okay.
Now this is the most simplistic way of fine tuning.
Write this much code will actually help you to get started.
Okay, but we'll not stop here, right?
We will do some more things.
Let's go ahead and add some of the hyper parameters.
Now with respect to the hyper parameters, what all hyper parameters that you have over here okay.
So I'll write down some of the comments so that you will be able to see this common hyper parameters
to tune includes learning rate early stopping max steps and optimizer.
Okay, which are optimizers you can specifically use.
So guys, here are all the common hyper parameters you can probably include for tuning this particular
model.
Let's say learning rate early stopping max steps and optimizer.
So learning rate obviously you can set up some values.
Let me do one thing.
Let me just show you one example how you can go ahead and probably set it up.
So here I'm just going to create my second parameter which is called as fine tune underscore args.
This is what the documentation says.
You need to provide your additional hyper parameter in this particular way in the form of key value
pairs inside this.
So here I'm going to basically go ahead and write learning underscore rate okay.
While we are fine tuning it should be equal to let's say I will go ahead and write 1.4 e to the power
of minus four okay.
Okay, so this will basically be my learning rate.
And uh, I will just use this learning rate and try to probably fine tuning it.
You can still add max steps and optimizer, but I just want to keep it as default values itself.
Okay.
Now let's go ahead and run this so quickly I will go to my fine tuning folder.
I'll say Python fine tune.py.
Okay.
So once I execute this you will be able to see that now this entire thing will be running and it will
first of all load the data set.
See it is uploading the data.
Set data set pairs uploaded the data set.
Is this considering using this feature to train using the same data.
And this is the URL where we will be able to track.
So if I click this URL, it will go ahead and open my landing page okay.
So let's open this.
So oops.
I think it is this page or what.
So 8134.
Right.
So I will open this.
So let's see in this train.
So here you can see 8134 is running.
And before I had tried some more and it got failed.
I stopped it in middle.
Right.
Uh so here you'll also be able to see the logs.
And I've tried multiple things here.
It has been also successful, but I was just exploring multiple things over here.
So here you can see all the logs is basically getting generated.
And if you closely observe the logs here Laura underscore a is there Laura underscore B is there wait
wait.
Related to wait parameters are specifically the all the information is visible over here.
Right.
And this entire training is basically happening and how simple it was.
You just need to put your data in the input and output format.
And just by writing this particular code, you could actually see it, right?
Now let me do one thing.
Let me go back to the completed.
And obviously this process is going to take some amount of time right around five minutes, ten minutes
based on your data set size.
But I have trained with the similar data set over here, and you can see I'm able to get the trained
model.
Okay, but let me talk about some of the important metrics that you'll be seeing after the model is
basically trained.
So the first thing is that it is something related to eval results.
Now what this eval results basically talk about here you can see the model that you have used right.
This model that you see over here.
This is after fine tuning.
And before you had this base model.
This was before fine tuning okay.
Now before fine tuning when When we asked the question, can laminae be used on a regular computer or
do I need specialized hardware or software?
Right.
So here you could probably see if I just go ahead and click this.
This was the answer before.
Right.
But now your answer has much more details when compared to the previous one.
Right.
Similarly, if you go ahead and see the second question, are there any step by step tutorial walkthrough
available in the documentation?
So here if you go ahead and see before the answer used to come like this.
But now you have this entire detailed question.
Detailed answer right.
This is all because of fine tuning, right?
And here similarly you will be able to see what does this cancel underscore job function mean.
Before it was something like this right.
With respect to the base model.
But with the fine tuning model you will be able to see this.
Okay.
So here you will be able to see every kind of new responses with respect to the answers that you are
able to get.
Okay.
The second thing is playground.
If you really want to go ahead and play with this entire models, you can also go ahead and play it
right.
So here only you'll be able to chat and you'll be able to answer ask any kind of questions.
So with respect to this particular playground, you can probably go ahead and ask any questions and
you will be able to test it over here itself.
You'll also be able to get one link, you know, uh, over here with respect to the model.
Now see, this entire thing has got trained right now, if you really want to go ahead and change C
with respect to this argument, the argument that we have used learning rate right here, you are able
to see the eval results right.
This model and your base model response.
And it is like quite a difference over here right.
Which is amazing.
So with respect to this again you can go ahead and ask any question in this playground.
And you can probably ask them okay.
You want to test your model, how the result is.
You can go ahead and test it over here.
Similarly there will be something like you can also create the public link for this model.
So all you have to do is that click on yes confirm.
And uh once this is done, you will be able to share your entire LM model links with anyone so that
they will be able to use it in the chatbot.
Okay, so this will probably take some time.
I've already clicked on.
Yes okay, so let this go.
But overall you'll be able to see that.
Hey how easy, how simple.
It was probably to train this entire model, right?
And uh, here you can see right now I have this public link.
I will copy this over here.
I'll paste it over here.
Now you can go ahead and ask any question and you can go ahead and try it out.
And again it depends on how much quantity of data you are basically being able to train.
But I hope, uh, this gives you a clear idea about the entire fine tuning process and obviously how
simple and easy it was, right?
So yes, go ahead and explore it from your end.
Uh, as, uh, we will be seeing, uh, uh, that this probably I felt is the most easiest way and it
was my duty to probably go ahead with this specific platform and make your work very much easier.
Okay, so yes, this was it for my side.
Uh, I will see you all in the next video.
Thank you.