-
Notifications
You must be signed in to change notification settings - Fork 28k
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
resizing token embeddings causes output embedding to be reinitialized in post_init
when tie_word_embedding
is False
#35141
Comments
@avishaiElmakies this might be a bug, but can you explain why you're calling |
I am using the model inside a more complex model which i add more modules to. I want thow to be initiated normally, which from what i understand should be done using post_init. |
@avishaiElmakies I understand! In that case, would setting |
@Rocketknight1 yes. I think |
@avishaiElmakies thank you! The PR isn't urgent, but we'd definitely appreciate the fix if you get a chance. |
Thank you for the response! |
PR is most welcome as I am not sure this is the intended API, but might be good to have! |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Hi @Rocketknight1 @ArthurZucker , |
System Info
transformers
version: 4.46.3Who can help?
@ArthurZucker
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
This code reproduces the problem:
the default value for
tie_word_embeddings
in pythia is False.I believe the problem arises from the fact the if
tie_word_embeddings
is False, Thenresize_token_embeddings
creates a newnn.Linear
object that doesn't have the flag_is_hf_initialized
(causing it to beFalse
when usinggetattr
), and thenpost_init
calls_init_weights
on the new module.transformers/src/transformers/modeling_utils.py
Line 2406 in c8c8dff
Expected behavior
post_init
should not change the weights of output_embeddings after a resize.The text was updated successfully, but these errors were encountered: