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

Fix generation docstring #14216

Merged
merged 2 commits into from
Nov 2, 2021
Merged

Conversation

qqaatw
Copy link
Contributor

@qqaatw qqaatw commented Oct 31, 2021

What does this PR do?

As mentioned in this comment, the add_prefix_space argument is not available in GPT2TokenizerFast.__call__ but GPT2Tokenizer.__call__.

Therefore, this PR fixes this error by switching the fast tokenizer to the slow one.

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@patrickvonplaten, @LysandreJik

>>> model = AutoModelForCausalLM.from_pretrained("gpt2")
>>> input_context = "My cute dog"
>>> # get tokens of words that should not be generated
>>> bad_words_ids = [tokenizer(bad_word, add_prefix_space=True).input_ids for bad_word in ["idiot", "stupid", "shut up"]]
>>> bad_words_ids = tokenizer(["idiot", "stupid", "shut up"], add_prefix_space=True).input_ids
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored this line to follow the common usage of tokenizers.

@patrickvonplaten patrickvonplaten merged commit a767276 into huggingface:master Nov 2, 2021
@patrickvonplaten
Copy link
Contributor

Thank you!

@qqaatw qqaatw deleted the fix_gen_docstring branch November 2, 2021 10:30
Albertobegue pushed a commit to Albertobegue/transformers that referenced this pull request Jan 27, 2022
* Fix generation docstring

* Style
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.

None yet

2 participants