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

[GPT2] Add correct keys on _keys_to_ignore_on_load_unexpected on all child classes of GPT2PreTrainedModel #24113

Merged
merged 2 commits into from
Jun 8, 2023

Conversation

younesbelkada
Copy link
Contributor

@younesbelkada younesbelkada commented Jun 8, 2023

What does this PR do?

as per title

forgot to add them in #23256

Currently this snippet:

from transformers import GPT2Model

model = GPT2Model.from_pretrained("gpt2")

Gives a big warning:

Some weights of the model checkpoint at gpt2 were not used when initializing GPT2Model: ['h.10.attn.bias', 'h.5.attn.bias', 'h.7.attn.bias', 'h.0.attn.bias', 'h.11.attn.bias', 'h.8.attn.bias', 'h.1.attn.bias', 'h.9.attn.bias', 'h.2.attn.bias', 'h.4.attn.bias', 'h.6.attn.bias', 'h.3.attn.bias']
- This IS expected if you are initializing GPT2Model from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing GPT2Model from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).

This PR fixes it by adding the correct regex expressions on _keys_to_ignore_on_load_unexpected for all child classes that inherit from GPT2PreTrainedModel

cc @sgugger @patrickvonplaten

@younesbelkada younesbelkada changed the title [GPT2Add correct keys on _keys_to_ignore_on_load_unexpected [GPT2] Add correct keys on _keys_to_ignore_on_load_unexpected Jun 8, 2023
@younesbelkada younesbelkada changed the title [GPT2] Add correct keys on _keys_to_ignore_on_load_unexpected [GPT2] Add correct keys on _keys_to_ignore_on_load_unexpected on all child modules of GPT2PreTrainedModel Jun 8, 2023
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks!

@younesbelkada younesbelkada changed the title [GPT2] Add correct keys on _keys_to_ignore_on_load_unexpected on all child modules of GPT2PreTrainedModel [GPT2] Add correct keys on _keys_to_ignore_on_load_unexpected on all child classes of GPT2PreTrainedModel Jun 8, 2023
@sgugger sgugger merged commit 8b16914 into huggingface:main Jun 8, 2023
sgugger pushed a commit that referenced this pull request Jun 8, 2023
…all child classes of `GPT2PreTrainedModel` (#24113)

* add correct keys on `_keys_to_ignore_on_load_unexpected`

* oops
@younesbelkada younesbelkada deleted the fix-gpt2 branch June 8, 2023 14:22
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

novice03 pushed a commit to novice03/transformers that referenced this pull request Jun 23, 2023
…all child classes of `GPT2PreTrainedModel` (huggingface#24113)

* add correct keys on `_keys_to_ignore_on_load_unexpected`

* oops
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

Successfully merging this pull request may close these issues.

3 participants