audio
audioduration (s)
16.6
53.7
text
stringlengths
157
567
start_time
stringlengths
12
12
end_time
stringlengths
12
12
I'm going to walk you through 10 quick tips for fine tuning. For each of those, I'll point you to one or two trellis videos on YouTube and also point you to the right branch if you're working out of the trellis advanced fine tuning repository. Tip number one is to start with a small model. I recommend starting with something like Lama 3 8B or Phi 3 Mini. And the reason is because fine tuning is about experimentation and you want to be able to try many things quickly.
00:00:00.029
00:00:27.242
If you start off with Lama 3 8 or 70B, it's going to take you much more time in order to test out what's working and what's not. You can always start small and scale up later. The video I recommend here is memorization. This one, I use a relatively small model as I do in many of my fine tuning tutorials, just because it's quicker to learn fast. Tip number two is to use LoRa or QLoRa. I don't recommend starting off with full fine-tuning for a few reasons.
00:00:27.582
00:00:55.878
First of all, LoRa and QLoRa allow you to start with fewer GPUs or a smaller GPU. That's going to make iteration faster. But for small datasets, the performance might even be better than full fine-tuning because full fine-tuning can tend to overfit. So I'd recommend even if you eventually want to do full fine-tuning, start off with LoRa or QLoRa and try to get it working before you want to spend more on GPU rental and more of your time. The video here if you want to pick out the right LoRa parameters is a live stream on how to pick LoRa parameters.
00:00:56.358
00:01:29.374
And if you're working out of the Trellis repo, you can check out the Unsloth branch for the fastest fine-tuning on a single GPU using LoRa or QLoRa. Tip number three is to create 10 manual test questions. So you want to create 10 question answer pairs and use those to choose which base model is going to perform best. So just by running those on different base models, you can see which one is going to give you the best baseline for starting off your fine tuning. Then after you do any training run, you want to run that manual test.
00:01:29.954
00:02:01.222
and just evaluate whether the model is doing well. This gives you probably a better sense than solely looking at the eval and training loss during the fine-tuning process. This is what I do in this memorization video as well, which you can check out on YouTube, and you'll see in the memorization scripts how I allow you to set up this manual dataset. That's also possible in the unsloth branch and the multi-GPU branch, which I'll get to later. Tip number four is to create data sets manually.
00:02:01.662
00:02:31.010
Yes, I know this is a bit of work, but I think it's underrated. When you manually curate a data set like I did for the trellis function calling data set, it lets you appreciate exactly which rows of data are needed to get the performance that you need. You can, of course, use Python and chat GPT to help automate some of this and generate rows. But I think the manual touch does allow you a better understanding, which will allow you to get performance faster.
00:02:31.110
00:02:56.022
Here, you can check out the function calling v3 branch and also the unslot and multi-GPU branches of the advanced fine-tuning repo. Tip number five is to start off training with a small number of rows. In fact, I always run training first with just one row of data to check that my training pipeline is working correctly and I don't run out of memory. Then I'll move to training on 100 rows, then 1,000. And I'm checking all the time whether my performance is actually improving or whether just my dataset design is completely off.
00:02:57.185
00:03:28.098
If you do want to automate a little more how you generate synthetic data sets, you can check out this video here on data set preparation with LLMs. Tip number six is always use a validation data set. If you don't have one, you can just split off 10 to 20% of your training data set. You want to be checking your training loss as you progress along the process. Make sure it's not too bumpy and your learning rate is not too high or your batch size or virtual batch size is too small.
00:03:29.079
00:03:56.433
You also want to check your validation loss, and this should be monotonically decreasing in a smooth way. If it's ever upticking, that means you might be overfitting and you're training for too many epochs, or you may not have enough data. Here, I recommend the Trellis repo branches of Unsloth or MultiGPU. They each allow you to split off validation, split from your base training set. This is something you can also do easily using Hugging Face datasets if you check out their documentation.
00:03:57.153
00:04:26.050
Tip number seven is to try to start training on just one GPU. Again, this allows you to iterate faster. If you really need to increase VRAM, say from what is on a T4 with Colab, then consider paying maybe 70 cents an hour for a 48 GB GPU like an A6000 or an A100 for 80 GB of VRAM.
00:04:27.182
00:04:46.009
I think you're better off to just fit it on one GPU, because when you move to multi GPU, you have data that's moving between them, the training becomes more complicated, it's easier to make mistakes, and it can be slower in some ways. Also, on one GPU, you can use unsloth, which gives you a 2x speed up. So that's quite beneficial if you can just focus on keeping things simple, until you've at least got a training approach that's working well, and you're happy to then spend the time and money to scale up.
00:04:48.650
00:05:16.566
Something I should mention as well is that you can waste a lot of time with installations and getting stuck in getting set up for fine tuning. One way around that is to use an image or a template that sets up your CUDA and PyTorch to a specific version. I've got a one-click template here for RunPod, and you can use that to consistently have the same environment on which to install the final packages you need for fine tuning. Tip number eight is to use weights and biases.
00:05:17.802
00:05:47.073
This is a tool that allows you to track the losses and the rewards as you move through your training run. You can include this in a script with pip install wandb, then set the environment variable for wandb project to a project name. And this will create a folder basically within which you can have multiple runs of run name. And the way you set the run name is in the training arguments by passing in the run name. Here you would set the run name like one epoch and constant scheduler or whatever you want to call it.
00:05:47.393
00:06:16.669
And you also need to set up report to wand b weights and biases. This is supported in the Onslaught and the multi-GPU branches and also in many of the Jupyter notebooks that are throughout all the branches of the advanced fine-tuning repo. Before I move to tips 8 and 9, I want to comment on scaling up. So I've talked about starting with a low number of rows, starting with LoRa or QLoRa, and starting with a small model. Well, here's the order you want to scale up in. Start by increasing the rows of data on a small model, then move QLoRa to LoRa.
00:06:17.089
00:06:48.218
If you really want to try full fine-tuning, test it out on a small model and see if it really improves performance. Then, as a very last step, you can think about moving to a larger model where it's going to take more time and money to get in that final result. There are two videos of relevance here. If you want to understand the pros and cons of full fine-tuning versus QLORA or LoRa, take a look at this video. And if you want to understand the complexities of doing multi-GPU training, check out multi-GPU fine-tuning. Moving to two last tips.
00:06:48.438
00:07:20.753
Tip number nine is to use unsupervised fine-tuning. This can be useful if you have a large data set. I'm going to say larger than 10,000 rows of data. Here, you'll need to use Python scripts in order to clean up, say, repeated characters or too much new lines. You can also use language models in order to clean up the data set chunk by chunk. The video of relevance here is the Wikipedia video I made, where I first extract data from Wikipedia, clean it, and then use it for fine-tuning.
00:07:20.873
00:07:48.832
Last of all, my tip number 10 is to do preference fine-tuning. This is where you have a data set with chosen, which are better or preferred responses, and rejected, which are the responses to the same prompts but are of lower quality. You might have a set of data like this if you have production data from customers or from a chatbot. You may have some conversational data that you consider of good quality. You may even have corrected or annotated versions of those conversations where you've improved the assistance responses.
00:07:49.912
00:08:20.972
That's going to be ideal as your chosen dataset. And you can always generate a rejected or lower quality dataset just by putting the same prompts into a language model and seeing what generic response it comes back with. So this approach here, called ORPO, or Odds Ratio Preference Optimization, it allows you to do both SFT, supervised fine-tuning, and preference fine-tuning at once.
00:08:21.593
00:08:43.308
The preference fine-tuning will move your model to give responses more like your chosen answers and less like your rejected answers, which is useful if you want to do some fine-tuning for tone or style, or if you want to make some corrections where the model's giving a response you don't quite like. Here I recommend the Orpo YouTube video, and there's also a branch by that name in Advanced Fine Tuning. Orpo is also supported in the Unslot branch, where there's a Python Jupyter notebook and also just a Python.py script you can run.
00:08:43.728
00:09:13.992
And Orpo is supported as an option in the Multi-GPU branch too. So to recap these 10 tips, start with a small model, use LoRa or QLoRa, not full fine-tuning. Always create 10 manual test questions or maybe a few more. Remember that manual data sets are probably underrated. You can always get a little bit of help from Python or from chat GPT. Start training on a small number of rows, even just one row to test the pipeline, but then 100, and make sure it's having a good effect before you decide to scale up.
00:09:14.433
00:09:47.199
Make sure you know that the data type and the data set that you've set up is actually the right one. Number six, always use a validation set. Just split one off from a training set if you don't have one. Number seven, try to just start training on one GPU. Number eight, use weights and biases for tracking. And when you're scaling from small to large, increase first the rows, then move to using more VRAM with LoRa instead of QLoRa or full fine tuning instead of LoRa. By the way, there's a factor of four roughly in VRAM difference between each of those.
00:09:47.559
00:10:18.710
So LoRa is about four times QLoRa and full fine tuning is about four times. LoRa, or even more in some cases. And last of all, increase to a larger model size only at the very end of your training process when you think you have a pipeline that's working well. Then for advanced tips, consider doing unsupervised fine-tuning if you have a large amount of data, only if you have a large amount of data, I'd say.
00:10:18.770
00:10:41.877
And last of all, you can consider preference fine-tuning, in which case I'd recommend using ORPL, which will do supervised fine-tuning and odds ratio preference optimization. at the same time. Now, this approach here I've talked about for language models, but it also works for video and speech or images, multimodal models. So you can check out this video here on multimodal text plus image, where I prepare a data set and bring it through fine tuning.
00:10:42.477
00:11:09.077
And likewise, for this speech to text model, where I prepare a data set and bring it through fine tuning. There are specific repos for multimodal. That's the vision repository here. And there's a repo for transcription. And this LLMs repo is the advanced fine-tuning repo I've been talking to date in or up until now in this presentation. I've laid out here all of the playlists that are relevant depending on what you need. So there are four different sections, four playlists and four repositories that go with them.
00:11:09.157
00:11:40.804
There's the LLM fine tuning playlist, which is all about fine tuning language models. Then there's a repo for that advanced fine tuning. There's the vision playlist, which is for multimodal models and repo link. There's a video on transcription and a repo link. And then there are many videos on server setup.
00:11:41.205
00:11:59.581
That's if you want to deploy your own custom model, either on a server that will sleep or start up when you need it to run, that's called serverless, or a server that's always on if you're using something like TGI or VLLM through a service like RunPod or Vast AI. And so here is the link for this.
00:11:59.921
00:12:16.565
I'll note as well that within this repo, there's some scripts that allow you to redact information, personally identifiable information like names, emails, or credit card numbers before you send the data to a third-party LLM. And there are also scripts on function calling inference and speed test too. I'll talk a little more about those just at the end of this video.
00:12:17.105
00:12:40.056
Last of all, these repos, of which there are four, they're available for purchase individually, but you can also now buy a repo bundle, which will give you lifetime access to all four of these repositories, which includes any future updates made to those repos. You can purchase that all together now as a bundle.
00:12:41.177
00:12:58.819
This very last section of the video is for those who have purchased lifetime access to one of the Trellis repositories, but I'll just put it part of this public video because it will give a sense of what's in these repositories for those of you who might be interested to purchase lifetime membership later. The first repo is the advanced fine-tuning repo, and this is split into branches according to function. They are all listed here roughly in the order that they have been released.
00:12:59.943
00:13:27.216
Now, a few of the branches that I'll highlight are, first of all, the Wikipedia branch, which is for unsupervised fine-tuning and data cleaning. If you do want to do ORPO, you have the ORPO branch here. And if you want to prepare data, you can do so with the help of a language model. This is done in the memorization branch, where you can set up some data generation based on PDF content.
00:13:27.756
00:13:50.269
And likewise, if you go to the supervised fine tuning branch, there is also a script or multiple scripts for generating Q&A data from a base data set right there. Then there are two important branches here, unsloth and multi-GPU. The unsloth branch allows you to run fine tuning in either a notebook or as a Python script. Whereas the multi-GPU branch allows you to run Python scripts that will deploy multi-GPU training that's fully shared data parallel or distributed data parallel.
00:13:50.870
00:14:21.609
Now I'll briefly show you each of those two main branches. So here we'll go into the unsloth branch. The way that you run training in this Unslot branch is by setting up the configuration in a config file. I've also got a config file that you can use here if you want to do some function calling fine tuning. And once you have your configuration set up, you can run the test.py in order to run a set of test questions that you've manually generated, or you can run questions from validation or test split of a data set.
00:14:22.370
00:14:52.930
Then when you want to train your model, you simply run train.py, or you can run it step by step in a Python Jupyter notebook. Now, the notebook is recommended if you want to go through the training the first time, you can see step by step what's happening and easily print out things at intermediate points. But when you've got your script honed, it can be a lot faster to run a Python script. And that's why I have made this script available, which you just run from the command line and it will go through everything within the training.
00:14:53.590
00:15:21.205
Just to give you a sense of how you configure the training and test setup, you'll set a model slug. You will then set some parameters, like whether you want to fine tune in 4-bit, what data type you want to use, depending on your GPU. You can then choose a data set, say for function calling, or if you want to memorize some data, like on the rules of TouchRugby. Here, you can set up your testing.
00:15:22.301
00:15:45.187
You can decide to test either from a set of messages that you have prepared manually, or you can use the training, or you can use the validation split of a test set that's on Hugging Face by setting use data set to test equal to true right here. Next, you set up your training and validation splits. Here I've selected a main branch for training, and I've selected the training split. You can fix a max number of rows here. This will save you time if you just want to download and run on, say, 100 rows instead of on a massive dataset.
00:15:45.328
00:16:17.832
Now, I spoke earlier about generating a validation set. You can either download from a split that's on Hugging Face called test or validation, but you can also generate a validation split from the train split. If you just set this to true, it will sequester 20% of the training data to use as validation. Next up is the LoRa configuration. You have all the regular LoRa parameters you'll see here. Check out the live stream video on choosing LoRa parameters if you want to know more.
00:16:19.229
00:16:47.113
You can set LoRa or LoRa alpha and also rank stabilize LoRa, set that to true or false. Here you've got some Weights and Biases project configurations. You set the project name, and then for each run, you can use a different name here for running in Weights and Biases. You can set up your HuggingFace username. This will be used when pushing models to Hub. Now there's a more advanced technique here where you can decide to train on completions only. This means that you will only be considering the loss on the answer portion, not on the prompt or question portion.
00:16:47.454
00:17:19.287
And this can be useful if your answers are quite short and you don't want the loss on all of the prompts to kind of crowd out or cloud out the information or the signal that's coming from training on the response or the answer. So you set the completions to true here. Sometimes I use this for function calling, fine tuning. And then you need to let the model know where your answer is starting. So in a Lama 3 model, the answer will start after assistant and header ID. In a Lama 2 model, it will start after inst.
00:17:19.647
00:17:52.328
And then I think this is maybe a chat ML format. the answer will start after I am start assistant. So this allows the training loop to check within your prompt. It will check for where this start of the assistance answer is, and then it will only look at the loss after that point. After this, there are some standard parameters like setting the training batch size, the validation batch size, the gradient accumulation, whether you want to run a validation set or not.
00:17:52.668
00:18:20.808
the number of epochs, the learning rate, an output directory for your training model and results, whether you want to train with BrainFloat 16 or not. You can set your scheduler. You can decide whether to save the model at a certain number of steps of training. set your max sequence length, gradient checkpointing, and whether to use re-entrancy, which allows you to speed up the training. Next, you can decide whether you want to use ORPO or not. By default, I've got that set to false.
00:18:21.787
00:18:51.901
If you're using ORPO, you need a column that's called chosen and one called rejected. and you can set your max prompt length. And then the beta, the beta basically weighs how much of the preference fine-tuning, what's the importance of that loss relative to the standard SFT loss. Remember, ORPL does two things in one. It does SFT and it does preference fine-tuning in one. So if you have this at 0.2, it's kind of the importance of the odds ratio is about 0.2 relative to the SFT loss.
00:18:52.422
00:19:19.667
Last of all, you can push to hub, so you can set a target model name if you want to push to hub. So very quickly, if we take a look at the test script, this will simply load the model. So it will load all of your configurations. It will load the model here, a fast language model using unsloth.
00:19:20.867
00:19:39.559
It will set up the tokenizer, set up the chat template, load the dataset, either from your manual data that's in the repo or from Hugging Face, and then it will run inference through all of those samples and print the results out to file. Just as an example, I can show you within test output, you'll see here a large number of tests that I have run. I'll try to find a recent one.
00:19:40.137
00:20:05.762
So here is some fine-tuning on TouchRugby, and you'll see there is a prompt, a question, and it'll print out the correct response, and it'll also print out the generated response. And then you can just manually compare whether these answers are good or not. Now, just one other script I'll point out here, which is viewModules. You can just run Python viewModules if you want to see what modules are within the given model. This allows you to pick out which modules you might want to fine tune using LoRa.
00:20:06.763
00:20:35.591
And that's pretty much it for the unsloth branch, which is recommended if you're going to fine tune on one GPU. It does not work if you're fine tuning on multi GPU, which is why I have the multi GPU branch and the multi GPU branch is configured much in a similar way to unsloth, except that it allows you to run in fully sharded data parallel or in distributed data parallel. It has a config file that you can set up. It has the test.py and the train.py file that will allow you to run testing and training.
00:20:36.758
00:21:07.812
And I'll just briefly show you the config file. So at the start here, you'll see this parameter that's not in the unsloth branch. If you set it to auto, it will just do standard training. You can train on multiple GPUs, but it will be pipeline parallel, so not quite as efficient. However, you can set this to DDP for distributed data parallel, or you can set it to FSDP for fully sharded data parallel. Now, when you're doing that, you'll need to configure the multi-GPU setup.
00:21:09.133
00:21:37.410
That can be done by running config, accelerate config, and you'll see the instructions if you head over to the multi-GPU branch for doing that. So this is the Advanced Fine Tuning repo, and you can find out more at trials.com forward slash advanced dash fine dash tuning. The next repo I'll briefly go through is the Advanced Vision repo. This does much of the same, but for multimodal text plus image models. It allows you to prepare your data and push it up to create a Hugging Face dataset.
00:21:37.790
00:22:08.539
Then you can fine-tune Lava, IdaFix, and Moondream models. You can do multimodal server setup with text generation inference. There's a one-click template for running an IdaFix server, including on a custom model. And last of all, there is a script for fine-tuning multimodal text plus video models. This is basically a variation on text plus image models where you split the video into multiple images. The next repo is the Advanced Inference repo.
00:22:08.920
00:22:38.829
This allows you to set up a server so that you can hit an endpoint for a custom model. You can do so on RunPod, Vast AI, or using a Llama CPP type server. There's also the option to deploy serverlessly using RunPod. This means that you can put a server that will only turn on when it's being queried and will turn off after it's being queried.
00:22:39.250
00:23:01.108
It's quite useful for batch jobs that are less time sensitive, because it means you're not paying for the server when it's not being used, and it will just turn on when you need it, which is going to save you cost. There are also a number of scripts for making API calls, simple API calls, OpenAI style or TGI style, function calling API calls if you want to test out function calling performance of a model. Then there are speed tests for single queries and multiple queries.
00:23:01.528
00:23:29.591
Data extraction, if you want to extract JSON or YAML data from files, so you can input some text and have a language model extracted for you into JSON or YAML format. And there's also a more advanced technique called LLM-RAG, which is a version of RAG, but you retrieve the relevant snippets from a data set by using a language model as a classifier to tell you whether that snippet is going to be relevant or not.
00:23:30.112
00:23:54.874
So the idea is to use a very fast and relatively small language model to pick out the right snippets and then include those snippets in the context of a more powerful model like, say, GPT-4. There's also a folder now on privacy, which allows you to basically hide information, like personal information on credit cards, names, email addresses, before you send it to a third-party API so that you can reduce any data privacy risks. Last of all, there's the advanced transcription repository.
00:23:55.274
00:24:24.271
This one here allows you to generate data if you want to fine tune a whisper model and then do the fine tuning. And again, much of the 10 tips that I provided earlier are going to apply here for transcription. And that is it for my 10 tips on fine-tuning. If I've left anything out, please let me know below in the comments and I'll get back to you. In the meantime, if you want more information on Trellis resources, including free and paid, try out trellis.com. That's T-R-E-L-L-I-S.com forward slash about. Cheers.
00:24:24.652
00:24:56.711
バ レ ー 好 き ? 別 に 、 な ん と な く や っ て る じ ゃ あ さ 、 お 前 の 学 校 強 い ? 最 近 は 、 強 い と 思 う よ 次 は 、 悔 し か っ た と か 楽 し か っ た と か 別 に 以 外 の こ と 言 わ せ る か ら な ! じ ゃ あ 、 期 待 し と く 昭 陽 は い つ も 新 し い ね
00:00:03.120
00:00:28.995
昇 陽 と 練 習 じ ゃ な い 試 合 や っ て み た い か も っ て 負 け た ら 即 ゲ ー ム オ ー バ ー の 試 合 や ろ う も う 一 回 が な い 試 合 も う 一 回 が な い 試 合 だ ! ケ ン マ ! 劇 場 版 ハ イ キ ュ ー ゴ ミ 捨 て 場 の 決 戦
00:00:30.945
00:01:24.626
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
40
Edit dataset card