Skip to content
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

Ignore keys for modules to save #1709

Open
zankner opened this issue May 4, 2024 · 1 comment
Open

Ignore keys for modules to save #1709

zankner opened this issue May 4, 2024 · 1 comment

Comments

@zankner
Copy link

zankner commented May 4, 2024

Feature request

It would be nice if you could specify a regex pattern for layer names to ignore from target modules.

Motivation

I have a base model that I apply lora to, but then I also add a few extra attention layers at the end of the model. I don't want lora to target these new decoder layers.

Your contribution

I could work on a PR if there is interest.

@BenjaminBossan
Copy link
Member

I'm not quite sure what you mean. On the one hand, you mention targeting LoRA layers, which implies you want to exclude certain layers from target_modules. This is already possible as target_modules accepts a regex, which is flexible enough to cover most use cases. As an example, for the OPT model, if I pass LoraConfig(target_modules=r".*\.(?!5\b)\d+\.self_attn\.k_proj"), I'll match all k_proj layers except for layer 5.

On the other hand, you mention modules_to_save in the title. Note that this is not related to applying LoRA, the modules listed there are fully fine-tuned and saved in the checkpoint file. This should not automatically include your extra attention layers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants