Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Don't use PretrainedModelInitializer when loading a model #4711

Merged
merged 11 commits into from
Oct 16, 2020

Conversation

eladsegal
Copy link
Contributor

@eladsegal eladsegal commented Oct 6, 2020

When loading a model, pretrained embeddings are not loaded as it is not needed.
This change make the same thing happen with pretrained weights from PretrainedModelInitializer.

Goes with allenai/allennlp-models#141

Copy link
Member

@dirkgr dirkgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine, but wouldn't it be easier to just not run initializers at all when loading the model?

@dirkgr dirkgr self-assigned this Oct 8, 2020
@eladsegal
Copy link
Contributor Author

This seems fine, but wouldn't it be easier to just not run initializers at all when loading the model?

If we make the assumption that for every module the initializer is under "initializer" in the config, then yes.
Should I make the change?

@dirkgr
Copy link
Member

dirkgr commented Oct 9, 2020

I went hunting for a more elegant way of doing this than grepping for the word "initializer" in a Params object. But then I found the remove_pretrained_embedding_params() function that already does a similar thing exactly that way. Can you just adapt that function, or write something like it for initializers?

Copy link
Member

@dirkgr dirkgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic, thank you!

@dirkgr dirkgr merged commit 006bab4 into allenai:master Oct 16, 2020
@eladsegal eladsegal deleted the pretrained-loading branch October 16, 2020 03:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants