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

Support for training lm_head in freeze finetuning_type #5032

Closed
wants to merge 1 commit into from

Conversation

upskyy
Copy link

@upskyy upskyy commented Jul 31, 2024

What does this PR do?

Fixes #3694

Before submitting

A ValueError occurs because lm_head is not included in model.named_parameters().
https://github.com/hiyouga/LLaMA-Factory/blob/main/src/llamafactory/model/adapter.py#L124-L131

[rank6]:   File "/llama-factory/src/llamafactory/model/adapter.py", line 135, in _setup_freeze_tuning
[rank6]:     raise ValueError(
[rank6]: ValueError: Module lm_head is not found, please choose from norm, embed_tokens

@upskyy
Copy link
Author

upskyy commented Aug 2, 2024

If embed_token and lm_head are tied together like gemma2, a KeyError occurs in model.named_parameters() where lm_head cannot be found.

@hiyouga
Copy link
Owner

hiyouga commented Aug 9, 2024

We do not need to specify lm_head to trainable if the model ties word embeddings, since the input/output embeddings share the same weights. Just use freeze_extra_modules: embed_tokens

@hiyouga hiyouga added the solved This problem has been already solved label Aug 9, 2024
@hiyouga hiyouga closed this Aug 9, 2024
@hiyouga hiyouga added wontfix This will not be worked on and removed solved This problem has been already solved labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

freeze类型如何指定lm_head可训练?
2 participants