"okay, but I want GPT to perform 10x for my specific use case" - Here is how

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so a lot of people are saying that I want GPT for a specific use case like medical or legal but there are two methods you should consider to achieve the outcome one method is fine tuning which means you retrieve the large layout model with a lot of private data you're holding and another is knowledge base which means you are not actually retraining the model instead you are creating an embedding or vector database of all your knowledge and try to find the relevant data to feed into large language model as part of prop and these two methods are feet for different purpose so what fine tuning is good at is making sure the large knowledge model behave in certain way for example if you want to digitize someone like the other AI talks like Trump that's where you will use fine too because you can feed all those chat history or broadcast interview transcript into large language model so it can have certain type of behavior but if your use case is that I have a bunch of domain knowledge like a legal case or financial Market stats fine tune is actually not going to work because it's not good at providing very accurate data instead you should use embedding to create a knowledge base so so that where someone asking which stock has the highest price movement yes it will get real data and feed it as part of pop so those two methods are three different use case a lot of times you can just create it in betting but find here is still super valuable for you to create a larger knowledge model that have certain Behavior it's a pretty way to decrease cost because instead of adding a big chunk of prompt to making sure large language model can behave in a certain way you can just teach large language models so you cut the cost so there's still a lot of legit use case where you should fine tune the legendary model unless I want to show you a step-by-step case study how can you fine-tune large language model for creating military power and this is a great use case because it is not a task that base model like GPT are good at what I want is a large energy model can take a simple instruction like this and turn it into a Miss Journey prompt so let's get started firstly we need to choose which model to use for fine tuning hacking face has this leaderboard for all the open larger launcher model and you can take a look to choose is the one that suits you most the one I'm going to use is the Falcon it is one of the most powerful large Lounge model there has been a number one place on the leaderboard in a very very short time it's also a few ones that are available for the commercial use so you can actually use this for production level products for your own company and it's actually not just our English a large set of different type of languages like German Spanish French and it has couple versions 40b version which is most powerful but also a bit slower think about more like gpd4 but it also a 7B version which is much faster and cheaper to train as well the next which is most important step is getting your data sets ready the quality of your data set decides the quality of your fine tune model there are two type of data sets you might use one is public data sets that you can get from internet and their model place you can get it like Kegel which is data set library that has a wide range of data across different topics like sports Health software you can just click on any of them preview the details of the data and if it's good you can download to use on the outside hugging is also have very big data set library and to find the ones that you will use for training large Lounge model you can click on data sets move down here try to find the text generation and you can try to find the relevant data sets that you want for example this is one public data set for medical related QA data sets you can preview what data actually inside but on the other side I think the most of the use case for fine tuning is actually use your own private data sets that is not available anywhere else it actually didn't require too big a data sets you can even start as little as 100 rows of data so it should be still manageable so this is one tip I want to share is that you can actually use GPT to create a huge amount of training data for example I have collected list of really high quality mid-journey prompts and I want chat GPD to reverse engineer generate a simple user instruct that might generate this mid-journing prompt and what I will do is give charity GPD a prompt like this you will help me create training data sets for generating text to image prompts and then I'll give it a few examples like this is from and this is user input and in the end it will start generating a user input that pair with this prompt which I can use them as a training data for fine-tuning Falcon model and all we need to do just repeat this process for hundreds or thousands of rows but luckily there are platforms like Randomness AI where you can run the GPT prompt f scale in bulk for example I can create an AI chain with this input variable called mediterating pump and then I will copy paste The Prompt that I was using in charge GPT the point the last prompt to the variable that we created here and let's run this so you can see it is working properly as it generates a user input and all we need to do next is go to the use tab this running block option allow me to upload the whole CSV file of the military prompt and then it will import the whole CSV file and run the GPD prompt for every single row hundreds of time automatically in the end I can have the training data like this so there's a pair of the user inputs as well as a corresponding mid Journey prompt so now let's fine tune the Falcon model I'm using Google collab as a platform to fine tune the model and I decided to use a 7B version which is much faster but if you want to use the 40p version it's basically the same code you just need to find more powerful computer before you run this making sure you check the runtime type and choose the GPU and at default I think you will be on T4 version which still works but I have upgraded so I can choose 800 model which will be faster so firstly let's install a few libraries once it's finished you will see a little check mark here then the next step is we will import all those libraries okay great and you will run this notebook login which will ask for your hacking face API key if you don't have hacking face account just create account and then copy the link here and paste here we will need to use hugging face as a way to upload and share our model the next thing we will do is we will try to load the Falcon model and tokenize it first and here the model I choose is 7B instruct shared so instruct is a fine-tuned 7B model specifically for conversation so think about as chat GPT versus gpt3 and share it just a version of samd model and shared shared is this version of 7B model that would be faster and easier to run and it will take a while for you and it is downloading the whole bottles it will take a while okay so the model is downloaded and then let's load the model Q Laura is a specific type of method called Low ranks adapters which is one way to fine-tune the large language model much more efficient and fast before we fine-tune 7B let's try this prompt with the base model to see what kind of results we get so I will create a prompt and then start loading a bunch of configuration for the model and click around so this is the results we get it's not even close to generating a good Mediterranean prop as they didn't really understand the context and as I mentioned before even check GPT is not doing a good job for this task so I'm pretty curious to see the results and let's first try to prepare the data sets so what I'll do is I will drag and drop the training data says here and once it's finished I should see this file showing up on the left side you can click on this file button to open this side panel by the way and then the first is we will load this data set that we store locally and we can preview of this data so it has two column user and prompt it has 289 rows so this is actually another point I would mention you actually don't need a huge data set even 100 or 200 rows can already generate a really good results for fine tuning and if we pick up the first row I can see the data that is properly loaded and then what we want to do is to map the whole data sets in this format human and assistant and then tokenize the prompt into our data set so once it's finished you can see the data set is fully prepared with input IDs token type IDs and attention masks and firstly we will need to create the list of training arguments and you can use this one I have here as default and then we'll just run trainer.train to start the training process and this will take a while for the higher end GPU I choose it take me two minutes I think if you're using T4 version it will probably take you around 10 minutes okay great so we just finished fine-tuning the model next we will need to save the model that we've just trained you can either save locally by doing modal.save pre-trained and once it is finished you will see on the left side there's a folder called train model and inside this is model that we just created but you can also upload this model to hugging face so you will come to hugging phase click on this new model under your profile give a name and choose a license then click create model once you finish that you can copy this and then coming back to paste on here this will upload the model to your hanging face repo okay we successfully load the model and let's run this again I will create a list of configuration for the model then I will create this prop mid Journey prompt for a boy running in the snow and let's run this okay great so we got this result as you can see it produced a really great prompt that I just tell you that why running in the snow and it is able to generate prompt if by running the snow with backpack a red scarf by the famous artist The Simpsons style the red is a bit messed up and I think if I provide him more data it probably will produce better results but it's already much better result than the base model and chatty GPT so this is how you can fine tune a large language model I'm really Keen to see the results you are getting here I'm training the 7B model because 40b takes a lot more computer power but luckily tii which is maker of Falcon model they are running a contest where the winner will be awarded with huge amount of training computer power so I think this is a brilliant opportunity if you really want to get into the fine tune space and there are a few use case you can try either customer support legal document medical diagnose or financial advisories I'm very keen to see what kind of models you guys got to train I hope you enjoyed this video if you're interested I will also produce another video talking about how can you create embedded knowledge base so if you like this video please like And subscribe and I see you next time
Info
Channel: AI Jason
Views: 706,026
Rating: undefined out of 5
Keywords: ai, gpt, large language model, large language models, finetune an llm, finetune your own llm, finetune llm model, artificial intelligence, falcon 7b instruct, falcon 7b llm, how to use falcon 7b, how to install falcon 40b, qlora falcon 40b, falcon 40b on macbook, falcon 40b llm, falcon 40b model, falcon 40b king, train gpt on your own data, train custom gpt, how to train gpt like model, chatgpt, how to train chat gpt 4 on your dataset, how to train chat gpt to write like you
Id: Q9zv369Ggfk
Channel Id: undefined
Length: 9min 53sec (593 seconds)
Published: Sun Jul 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.