TypeError: __init__() got an unexpected keyword argument 'force_bos_token_to_be_generated'
See original GitHub issueEnvironment info
transformers
version: 4.6.1- Platform: Linux-3.10.0-1160.15.2.el7.x86_64-x86_64-with-glibc2.10
- Python version: 3.8.8
- PyTorch version (GPU?): 1.7.1 (False)
- Tensorflow version (GPU?): 2.4.1 (False)
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no
Who can help
@patrickvonplaten, @patil-suraj
Information
The model I am using is BART
The problem arises when using:
- the official example scripts: (https://huggingface.co/transformers/model_doc/bart.html)
To reproduce
Steps to reproduce the behavior:
- Install transformers library
- run the following code-snipped as presented in the official example:
from transformers import BartForConditionalGeneration, BartTokenizer
model = BartForConditionalGeneration.from_pretrained("facebook/bart-large", force_bos_token_to_be_generated=True)
- Receive error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-21-216ff3421f95> in <module>
1 from transformers import BartForConditionalGeneration, BartTokenizer
----> 2 model = BartForConditionalGeneration.from_pretrained("facebook/bart-large", force_bos_token_to_be_generated=True)
3 tok = BartTokenizer.from_pretrained("facebook/bart-large")
4 example_english_phrase = "UN Chief Says There Is No <mask> in Syria"
5 batch = tok(example_english_phrase, return_tensors='pt')
~/.conda/envs/groundwork/lib/python3.8/site-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
1171 else:
1172 with no_init_weights(_enable=_fast_init):
-> 1173 model = cls(config, *model_args, **model_kwargs)
1174
1175 if from_tf:
TypeError: __init__() got an unexpected keyword argument 'force_bos_token_to_be_generated'
Expected behavior
I expect the code to not raise an exception and that the final assertion is true.
If there are more information needed, please let me know.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
TypeError: __init__() got an unexpected keyword argument ...
I got this error ---> TypeError: init() got an unexpected keyword argument 'parent'. This is my code : class Manager(Tk): def __init__(self, ...
Read more >gcloud error while updating google-cloud-sdk on centos 7
ERROR: gcloud crashed (TypeError): __init__() got an unexpected keyword argument 'completer'. Here's more from the update ouptut:.
Read more >init() got an unexpected keyword argument 'seed' · Issue ...
I got this error message when running fm = pywFM.FM(task='regression', k2=2, seed=seed). TypeError Traceback (most recent call last)
Read more >TypeError: __init__() got an unexpected keyword argument ...
Hi, I have followed the steps given in the chapter to set up mflix app. ... TypeError: init() got an unexpected keyword argument...
Read more >init__() got an unexpected keyword argument 'max_iter'?
TypeError : init() got an unexpected keyword argument 'max_iter'. I m running the linear regression code in Community edition. Google says reinstall --....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @patil-suraj,
I’m not sure to understand your answer.
facebook/bart-large
withforced_bos_token_id
, you get a clear output:UN Chief Says There Is No Plan to Stop Chemical Weapons in Syria
generated_ids = model.generate(batch['input_ids']
), you get this:UNALSO SEE
forced_bos_token_id
has an impact withfacebook/bart-large
, no?https://huggingface.co/ainize/bart-base-cnn
). How do you useforced_bos_token_id
with them?Note: just to give an overview of this discussion, I’m researching the right code to get the BART, mBART, and MBART-50 language models making multiple token masks (ie writing zero or more tokens in the output sentence when there is a
<mask>
token in the input one) with the objective to get the full output sentence.Hi there,
force_bos_token_to_be_generated
is now depricated, instead you could useforced_bos_token_id
argument, which should be set to the token id that needs to be forced as first token.