pytorch / torchtune

PyTorch native finetuning library
https://pytorch.org/torchtune/main/
BSD 3-Clause "New" or "Revised" License
4.26k stars 419 forks source link

How to finetune custom models? #1925

Open nam1410 opened 5 days ago

nam1410 commented 5 days ago

Thank you for your work on finetuning LLMs using lora, dora etc. I'm wondering how I can get started to finetune my custom model with torchtune lora. Do you have any suggestions?

calvinpelletier commented 5 days ago

Here's my suggestion for the steps you should take:

  1. Follow the installation/"Get Started" guide in the README to get torchtune setup and run one of our LoRA finetune configs
  2. Modify the model section of the LoRA config such that model._component_ points to a function that returns your custom model
  3. Modify the checkpointer section so that it can read/write your weights in the right format. You can use our torchtune checkpointer or write a custom one using this interface.
  4. Experiment with different hyperparameters to see what works best for your model

Let me know if you run into any problems

SalmanMohammadi commented 5 days ago

We've also just added a small tutorial on adding custom components to torchtune - check it out!

https://pytorch.org/torchtune/main/basics/custom_components.html#launching-with-custom-components

If you happen to find it useful/don't useful all feedback is welcome.