Fine Tuning a Model in Gemini and Vertex AI | Steps to make a LLM

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right so we're going to be doing some fine-tuning of a base large language model in vertex AI we're going to be using our own Json L file that we're going to create and I'll walk you through the steps of how to get going in vertex AI how to load up your Json L file what to look for and um ultimately deploy that new model to an endpoint in vertex Ai and so that you can start using it so let's go all right so what we're going to be doing today is fine-tuning and training our own model and we wanted to sound and respond like I do so really um what we're going to be doing is starting up in vertex Ai and um if you haven't already create a bucket for your information so really simply click on your hamburger icon go to cloud storage and create a bucket um for you to put your um data all right so what we're going to do next is click on language and you'll see over here called tune a model all right so click new tuned model model and um what this is going to be doing is it's going to be using a Json L file all right so what we want to do is let's just walk through here and then I'll show you exactly what it's looking for cuz the um instructions are on the next page so let's just call this my tuned model uncore new and we can base off the text bison um and the output directory just put it into the bucket that you've already created and go down to the advanced options now this is super important if you don't put in the service account it's not going to work all right so if you haven't already created your service account I suggest you do so click on SVC chat this one that I'm going to be using and hit select all right the other steps over here you can play around with it but uh for this uh demo it's just going to be these defaults all right um and now what it's going to say here is tuning data set the data set is a Json file where each line contains a single example right number of recommended examples and view the data set documentation to learn how to prepare right so let's go and have a look at the data set documentation okay so here's a um guideline on what it's looking for and how to actually create it all right so tuning uh Foundation models needs to include examples that align with the task you want the model to perform all right that's text to text and each row record contains input and is paired with an expected output model all right it also shows you here how many um examples are required and uh they want at least 100 to 500 examples for good results okay so if you've got um um a lot of questions and a lot of answers and a lot of styling that you want to pop in um it's well worth the effort to get this model fine tuned so if you want to do something that's very sort of um inaccurate or Loosely based on your style do do do the lower number but if you want it to be more accurate obviously the higher number of examples the better all right so here's a data set sample and the data set format and um here's what it's saying that the um output could look like all right so what we're going to do is let's just um go into ai. gooogle dodev and click on the get API key and you'll taken into Google AI studio now the reason we're going to use Google AI Studio it's got a lot of free credits and um what we want to do is just generate a Json for us uh so let's copy the style of Json that we want and we can just pop in a a prompt here just saying create a Json L um output of 25 lines uh for questions about AI make the output look like this and then we can hit enter and what it's going to do now is it's going to create um 25 lines that we can then copy and paste into our uh Json L file that we want to train on all right so what you would be doing is ultimately taking this information and um looking to write your own answers for it okay so here's the information and all right so as you can see here it's basically um popping it into a um format that we can use all right and what we can do now is just go into our um into our space where we've created a Json L file so really simply all you do is create a new file and create a text document and then you can just rename it to Json L I'm using text pad and I find it works really well all right so let's just open up my text uh my Json L and let me show you what I've done to get it to work all right so what it's done is it's created the questions for me what I found is super important is to add context or I set um the model throws out and what you need to do is just make sure that your output text is over here and you can then start to just fine-tune it a little bit more um so I've added happy days to the end of all of my um outputs over here just to give it a bit of a more friendly happier turn um I've only got 10 records in here um you would need a lot more to train uh but this is just to get you going and to show you how it works and how to um get your models um buil bu up in vertex right so what we've got is our training data set uh like I said you're going to have to update your output text to whatever you feel is more um congruent with your style uh so you can close that off and let's jump back into um into vertex AI all right so now we've got our uh Json L file so what we want to do is just select it and we can just choose that one there and where do we want to pop the output so you can just choose one of your buckets that you've already created um so I'll just pop it into that bucket for now and um if you wanted to enable the model evaluation you can um it does increase the time it takes to do the um uh training uh so yeah use with caution it does take about so for a record of about 10 to 15 um line items it takes about 30 35 minutes obviously the more um line items you have in your Json L file the longer it's going to take so bear that in mind when you're training your data all right and what we can do now is click on start tuning and um hit the start tuning button and what you'll see now is it will start running in the background okay so what I'm going to do is uh because it takes a little while to run um I've already done it um in the background um and let it run and basically what you can see here is if you wanted to see how it's performing click on it and it'll open up your pipelines all right and it'll basically show you what steps it's going through the number of steps it's completed and um you can see if there's any errors or any problems um word of warning if your Json L file is not formatted 100% correct it will fail um so always check that the other thing to check is make sure you're using your ser service account um or I it will fail so these are things that I've learned um and hopefully it saves you a huge amount of time um and that's top tip there all right so let me jump back to a model that I've already um fine tuned so as you can see over here it succeeded and if we had to look at the time it took around 32 minutes to complete all right so once you've created your model it automatically deploys it to an end point so what we can do now is just go into language and now how do we interface with that new fine-tuned model all right so we're going to go into our text prompt over here and in your model on the far right You' be able to now see your new model all right so there is my new tuned model all right and you can set all your sequences or your um temperatures and all that kind of stuff and now you can interact with this model as um a fine-tuned version of the text bison um large language model and the Tex bison is absolutely perfect for this type of scenario it's uh it's eventually going to be merged with German so don't don't don't stress about the accuracy of it um so what you can do now is you can just type in a question it's like what is tyron's view on AI all right um it doesn't know who Tyron is but because we've trained it um we should get an answer um from this model so make sure you've selected your tuned model and let's hit submit all right uh so there we go so it's a powerful tool that can be used for good or evil it's important to be aware of the potential risks and to use AI responsibly uh so yeah that's um pretty much what uh kind of tone and the style that I would be using um I got a bit of a dark sense of humor sometimes but it's really for good um and uh yeah so that's what you would do over there all right you can obviously test it fine-tune it a little bit more um and then what you would do from here is if you U wanted to use it in production grab the code and um start uh fine-tuning the model that you're actually looking for okay um so you're going to be from the pre-train text bison get the tuned model and um yeah so you basically select the tuned model that you wanted um and that's how you would select it over there so don't use the standard um model select the model that you've um actually typed in and there's the model name um that's going to be used in your application all right let's click close And um yeah and that's it for today's uh session so hopefully you found this useful hopefully you got some um some good use cases and fine-tuning of your data style and your outputs and um if you enjoyed this video like subscribe let's um yeah hopefully you had fun
Info
Channel: LevelUp_Plus
Views: 11,908
Rating: undefined out of 5
Keywords: vertex ai fine tuning, tune a model gemini, fine tune gemini ai, how to use model tuning in vertex ai, gemini ai google, large language models
Id: ej_ZUcyKpoc
Channel Id: undefined
Length: 10min 58sec (658 seconds)
Published: Fri Feb 16 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.