Fixed resize_token_embedding issue #21053#21065
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
|
cc @gante and @Rocketknight1 |
gante
left a comment
There was a problem hiding this comment.
This is absolutely correct. self.vocab_size can easily get stale when the vocabulary gets updated, and the check should be done against the config.
(there are other models with this issue, where the fix needs to be slightly different, so I'll have a look very soon)
|
@sgugger feel free to merge if you approve. As I wrote above, other models have a similar problem (which require a more elaborate fix) |
|
@susnato can you remove the |
Hi, @gante if you want, I would be happy to look into this and fix if I can. |
|
@susnato sounds good! My plan consists in removing all references to If you search for "tf.cast(self.vocab_size", you will find all matches that will likely have to be touched. |
Hi @gante I am going to check for all models in |
|
@susnato yes. If we look at the corresponding PT implementation e.g. for Albert, the layer classes store |
What does this PR do?
There was a typo in Line 449 in huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_tf_gpt2.py where the code was doing a check between input_ids and self.vocab_size but resize_token_embeddings change self.config.vocab_size so we were getting the error described in the issue, to overcome this I replaced it with self.config.vocab_size and it worked.
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed.
@sgugger