-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Lora-like guides #1371
[docs] Lora-like guides #1371
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @stevhliu for consolidating all the LoRA like guides into a single guide while focusing on usage of different LoRA variants. Thank you for the HF Space collection of notebook examples.
Left a few suggestions and comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 🤗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stevhliu !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this excellent guide and consolidating the different methods. Overall, this looks really good, I just have a concern regarding the use of AdaLora. Please check the comment and the solutions I suggested.
</hfoption> | ||
<hfoption id="AdaLoRA"> | ||
|
||
[AdaLoRA](../conceptual_guides/adapter#adaptive-low-rank-adaptation-adalora) efficiently manages the LoRA parameter budget by assigning important weight matrices more parameters and pruning less important ones. In contrast, LoRA evenly distributes parameters across all modules. You can control the average desired *rank* or `r` of the matrices, and which modules to apply AdaLoRA to with `target_modules`. Other important parameters to set are `lora_alpha` (scaling factor), and `modules_to_save` (the modules apart from the AdaLoRA layers to be trained and saved). All of these parameters - and more - are found in the [`AdaLoraConfig`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bit of an issue with the AdaLora example. For AdaLora, we need to call the method update_and_allocate
during each training step, otherwise, the adaptation step is not performed. This requires to either write a custom training loop or to subclass the Trainer
to add this step. An example of a custom training loop that calls this method is here:
model.base_model.update_and_allocate(global_step) |
Given this guide, as is, the reader may not be aware that this is required and thus use AdaLora incorrectly. These solutions come to mind:
- Don't provide the AdaLora example. Instead, refer to the existing examples with custom training loops.
- Don't use
Trainer
, instead use a custom training loop that calls this method when AdaLora is being used. - Subclass
Trainer
to perform this step if AdaLora is being used. I don't know enough aboutTrainer
to be really sure how to do that correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! I mention update_and_allocate
+ link to a custom training loop in a Warning
in the training section for more visibility. I think we should still keep the example of showing the AdaLoraConfig
though so users still know how to set it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy with the added warning, thanks for adding it.
* loras * review * fix * feedback * feedback
As discussed in #1332, this PR condenses the LoRA guides by showcasing one specific task type (image classification) and redirecting to other use cases/tasks stored on the PEFT Hub org. Instead, this guide expands on the other LoRA methods such as LoHa, LoKr, and AdaLoRA. The configs of these methods aren't optimized for the best performance, so any feedback you have on that would be super useful!