Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Fix: deprecated argument when calling transformers>4.0.0 #3393

Merged
merged 1 commit into from
Jan 19, 2021

Conversation

AlvaroMolano
Copy link
Contributor

@AlvaroMolano AlvaroMolano commented Jan 18, 2021

Patch description
Fixes #3353

It is a simple fix to the following errors:

TypeError: forward() got an unexpected keyword argument 'past'

When using the transformers>4.0.0
And:

/opt/conda/lib/python3.8/site-packages/transformers/modeling_gpt2.py:534: FutureWarning: The `past` argument is deprecated and will be removed in a future version, use `past_key_values` instead.

When using the transformers==3.5.1

As described in the issue 3353
past_key_values=incr_state,
solves the issue

Testing steps

parlai interactive -m hugging_face/gpt2 --add-special-tokens False --gpt2-size medium --inference beam --beam-size 10 --beam-context-block-ngram 3 --beam-block-ngram 3 --beam-min-length 25

Other information

Tested in transformers 3.5.1 and 4.2.1, no error or deprecation warning appears, code works.

@facebook-github-bot
Copy link

Hi @AlvaroMolano!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Copy link
Contributor

@stephenroller stephenroller left a comment

Choose a reason for hiding this comment

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

lgtm, rerunning our flaky CI and if it passes, I'll merge. Thanks for your contribution!

@stephenroller stephenroller merged commit 7812ce4 into facebookresearch:master Jan 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HuggingFace model only works with transformers <4.0.0
3 participants