microsoft / LoRA

Code for loralib, an implementation of "LoRA: Low-Rank Adaptation of Large Language Models"
https://arxiv.org/abs/2106.09685
MIT License
10.78k stars 688 forks source link

improve mark_only_lora_as_trainable #133

Closed Edenzzzz closed 1 year ago

Edenzzzz commented 1 year ago

It doesn't follow OOP principle to check layers by name instead of type by inheritence. Also naming is in quite convenient, e.g. when I just want to name the module self.query instead of self.lora_query so that I can load the original weights. Also changed it to set lora layers requires_grad=True, as the function name suggests (requires_grad can default to false).