Fine-tuning ChatGPT with OpenAI Tutorial - [Customize a model for your application in 12 Minutes]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
when leveraging the different models found within open ai's API there is a special use case called fine-tuning when we fine-tune models this allows us to take a base model like 3.5 or four and laser in the model even further so we get more consistent outputs that are more quality at scale currently a lot of videos on this topic on YouTube is like 6 to 8 months old therefore let me give you the updated version with the new user interface how we're going to do this so in today's video I plan on one creating a file for this for a very specific use case downloading it uploading it and showing how to use it in the context of opening eyes API welcome back y'all this is one of my more complex videos found on the channel this is going to involve a little bit of code so if you don't like that you can click off but if you do like that and you actually want to see how to f- tune open AI API models this is the video for you I'm going to show you one how to create the file which may be a little confusing I'm also going to show you how to upload the file and start actually calling that endpoint in the context of code this is my Twitter check it down below I'll see you in the video first things first I'm going to go ahead and leave the fine-tuning documentation in the description down below so you can go and click it and you can reference everything that I'm showing you in today's video from these steps outlined here though all we need to do is prepare a training model we need to upload it then it's going to train on their backend we're going to evalue evaluate the results in the playground and then we can go ahead and start leveraging this new endpoint basically when you call an endpoint in code as you may or may not know we will typically Call It by using the model name therefore for example if I was doing an API call in vs code I would use gbt 3.5 Turbo d01 125 and now I'm using that model first question might be is what is 0125 January 25th of 2024 you want to use the most update upto-date models because past models they deprecate let's go ahead in this video though discover I can jump over to here how to create a file and find tuna file so if we scroll down here it goes over common use cases why you would do this this obviously improves reliability at producing a desired output if the very specific reason you're calling that API you're expecting a very specific type of output EG it's not that creative it's not that diverse in the outputs You're Expecting rather it's more structured in its outputs using fine tuning may be the option for you as you want more consistency rather than holy smokes it just made like a really cool paragraph about unicorns and butterflies and it's super creative we don't want it creative we don't want this creative we want you to do a very specific task for us so therefore we're going to laser you in by fine-tuning you so if I scroll down here let's go ahead and create a data set together with this example data set here we have the context that we are going to fine-tune a model to make it sarcastic so be honest with you I'm going to use the same data here but we're going to add more points I'm going to go ahead and leave this in the description down below this is an example Json file I'm not going to use this one but this is an example one you can upload just to see if it even works although I will point out this one actually isn't perfect as it doesn't give you 10 example inputs and outputs that's the name of the game when it comes to fine tuning you want to give an example input and the expected output so the model understands how to basically communicate in the context of multiple prompts coming in past the initial training stage make this a little bit more clear what's the capital of France sarcastic right Paris as if everyone doesn't know that already that's the idea here let's go and create our training file I'm in vs code here you can go and install this application as well it's completely free we're going to go ahead and create a new file for the training data here so I'm going to come up here to file new file I'm going to Simply name this file test for video I'm going to do Json L this is the type of format that they're looking for when uploading it I'm going hit enter here I'm going to save it once I have saved it I'm going to go and delete this other one because we don't need it soone don't save this and now we have the formatted file of how we want to proceed I'm going to go and grab their example code example format I'm going to copy this I'm going paste it so let me explain this a little bit more so this makes sense to y'all first thing I want to point out is that right now there is three data points that it can reference in the context of when it's training the system as you'll see later in this video video in order for you to have a file that works within this you know realm of fine tuning we need to actually have 10 different data points or alternatively basically 10 different examples of how you want outputs to come out comparative to the input we put in explain this a little bit more system what are we typically if you're familiar with API this is where you would put the uh default in here is like I am a helpful assistant let's laser in a little bit more we're going to say the system itself is Marv a actual factual chatbot that is also sarcastic come over here user content this is when you yourself is like talking to chat gbt you put in like a text input such as what's the capital France that's your message this is the expected message coming in from the user and then the assistant and this output is the output from the actual model itself everything makes sense so far from here I need to Simply add seven more examples so I'm going to do just to show you you can do command C enter command V command V and proceed in that manner so I'm going to do is I'm just going to cook this up real quick we can actually do one together let's do one together so number four how far is the Moon from Earth I have no clue so we'll try and say we are going to go ahead and I'm going to leave the system as the same I'm going to go ahead and change this though I'm going to say what is the capital or this add apostrophe what is the capital of Texas and then this is basically where we give our s castic answer so let's mess around a little bit we'll say Austin have you never read read a textbook I guess that is a little sarcastic and that should be good okay so I'm going to go ahead and add six more data points and proceed because I'm lazy I'm going to go ahead and make this simple myself I went ahead and just gave an example data point that I provided earlier talking to Chad gbt I'm just like you know based off this can we get six more examples it wanted to Output one by one I'm like no no no no that's too much so I'm like can you output this all in one block I can copy output it all as 10 but notice how it is structured a little bit differently than what we had originally in this code where there doing different syntax we want to make sure it's the same syntax so what I'm going to do is say okay make sure each one is one line and is like this enter again I don't want the commas I don't want the square brackets at the end there we go so we want to make sure we do same syntax here that's actually pretty important in this context also on top of that ensure that there's no spacing so for example if I hit space space here and then I pasted the code that's no good either make sure there's no spacing as compressed as possible and we should get our six examples here I'm going hit copy come back over here hit paste now we got 10 example data points this is the minimum that's required to train a model for open AI up to this point let's look at some of the examples what's the tallest mountain in the world Mount Everest standing at tall as 8,848 M but don't worry your backyard Hill is still impressive okay when was the internet invented the concept came about in the 1960s but it's clear you've been mastering it since birth okay now it's being a little bit nicer than expected we got our data points now how do we take this file and upload it so I'm going to make sure I delete everything so there's no empty space space here below 10 points I'm going to right click this for me I'm going to Simply put reveal and finder all you're going to do though is once it's revealed in your finder you're going to Simply command C or control C and paste it to your desktop is there a more effective way to do this probably this is how I'm doing it once you have the file though let's jump over back to open AI we are in open AI we are in our fine-tuning dashboard and from here we are going to make me jump over here and I'm going to say create base model this is what this is the one you're going to choose in most contexts you're probably going to choose 35125 right now gbt 4 is not available for a lot of people it's available for a select few of people and I'm not one of those people hit 3.5 here 0125 the most update model I'm going to go ahead and upload the file we just created together once I have it selected make sure you're using that Json L very important say upload selected we don't have any of this and then suffix we can add to our model name this might actually be useful we're going to say uh funny funny bot I'm going to say upload selected perfect and we're going to go go ahead and create now this is where it's validating the files we'll get a little bit of a message board here this is what it looks like when it's successful you know new finetune model created job has successfully completed notice I actually did get an error it's good that I got this err so I can actually explain it to you it said that example 11 is not a valid Json format but there's no example 11 well what happened was I did this I showed you to delete it basically but I didn't hit command save or I didn't save the file and then I exported it so what I need to do is I need to make sure it's save here I need to make sure that there is no little blue ticker there now this is the fresh file I'm going to go ahead and do this process again and reupload it funny bot two upload hit create also want to point out for that kind of error message it's going to specify the exact line that isn't in the correct format so that's helpful for your reference these are the lines nine 8 9 10 line eight line six line four now the actual validating process really depends I've had one take me like 30 minutes 40 minutes this data is pretty small this data is pretty short therefore we should get a pretty fast success here there we go the fine-tuning job has started it is confirmed that the actual structure and formatting of the file is correct now the actual training that's happening right now does cost money so for this one random example I did it was around 87,000 training tokens and 10 epochs I come over to their documentation this is where you estimate your cost I gave an example of if there was 100,000 tokens trained and three Epoch it's around 240 USD so keep that in mind to actually train a model with a data data set it does cost money once the data set has been trained though now if the data looks good and the outputs are consistent you have a better model at scale when you access this new endpoint now the final objective here is once this is done training and I get the green light succeeded we're going to come over to the playground here and we're going to be able to actually play around with it and see if it does work so I'm going ask a question that's General and see if the answer is sarcastic also while this is loading let me know in the comments down below if you find tun mod models in the past and how you've used it and like why you've used it I think this will be very helpful to give more perspective for people that are interested in fine tuning but more likely like give me good examples of it right I can think of a couple although those might be a little bit confidential but the point being is that there is power here in the sense that you don't have to maybe prompted as much for your initial input data when you call these endpoints comparative to calling it at a more General level if I were to call just gbt 3.5 turbo 0125 that sounded like a robot that sounded like something from a movie but that's what they call them once a model is completely done with training you can actually reference it exactly like this traditionally we would have referenced it like you know gbt 35125 here but now we can actually reference our fine two model in our code super powerful that was the point of the suffix so we can identify more specifically what is incurring and what like fine tune happened so for example if I were to take this model and use it in code I would copy this entire string and then simply put it into my call on open a API there we go once we completed the training we say the job has successfully completed we'll get succeeded and we can start messing with it in playground hit playground here we're going to come to playground here we're going to go ahead and be able to choose our model scroll down here we should see yeah find two models the suffix of funny bot what I've realized though through training and through processing of this is that it will default to your a helpful assistant in the context of playground not in the context of API calling therefore I'm going to add the system that we already added throughout the code which is Marv your a factual chat B that is also sarcastic let's say what is the capital of Hawaii there we go y'all this is how we start leveraging fine two models in the context of open AI now I would suggest only to use this if you really need to make sure basically try the traditional way of prompting which I go over in this video right here if that doesn't work and you are still facing issues try Json or JavaScript try that you know format the outputs and if that doesn't work use fine-tuning I'm going to leave a playlist at the end here going over building a software from start to finish everything you should know I'll see see you in the next video there we go we learned how to fine tune in the new UI open AI has provided leave a like is complet free that's the playlist I was referring to that's a random video that's my face we do a ton of stuff on this channel check me out I'll see you in the next video
Info
Channel: Corbin Brown
Views: 4,304
Rating: undefined out of 5
Keywords: chatgpt, zapier, openai, ai automation, gpt tutorials, chatgpt education, ai for business, ai service, zapier tutorials, software business, entrepreneur, start a business, passive income
Id: VVKcSf6r3CM
Channel Id: undefined
Length: 12min 12sec (732 seconds)
Published: Tue Mar 05 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.