question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Official example not working, are you serious?

See original GitHub issue

Environment info

  • transformers version: 4.10.0
  • Platform: Ubuntu 18.04
  • Python version:
  • PyTorch version (GPU?): 1.9 GPU
  • Tensorflow version (GPU?): 2.4.0 GPU
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?:

Who can help

Information

@LysandreJik

Model I am using Bert, official code not working 😦

from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-cased')
model = BertModel.from_pretrained("bert-base-cased")
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='tf')
output = model(encoded_input)

https://huggingface.co/bert-base-cased to above code. https://huggingface.co/bert-base-cased

Exception:

Traceback (most recent call last):
  File "/home/zhangguanqun/venv_tf_2.4/lib/python3.6/site-packages/transformers/tokenization_utils_base.py", line 248, in __getattr__
    return self.data[item]
KeyError: 'size'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zhangguanqun/projects/huggingface/bert.py", line 15, in <module>
    output = model(encoded_input)
  File "/home/zhangguanqun/venv_tf_2.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/zhangguanqun/venv_tf_2.4/lib/python3.6/site-packages/transformers/models/bert/modeling_bert.py", line 938, in forward
    input_shape = input_ids.size()
  File "/home/zhangguanqun/venv_tf_2.4/lib/python3.6/site-packages/transformers/tokenization_utils_base.py", line 250, in __getattr__
    raise AttributeError
AttributeError

Process finished with exit code 1

What’s wrong with that?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
thomwolfcommented, Sep 6, 2021

a lot more serious now indeed!

1reaction
Doragdcommented, Sep 6, 2021

Similar issue on examples https://huggingface.co/microsoft/xprophetnet-large-wiki100-cased-xglue-ntg: @thomwolf @patrickvonplaten

from transformers import XLMProphetNetTokenizer, XLMProphetNetForConditionalGeneration, ProphetNetConfig

# should be just XLMProphetNetForConditionalGeneration & XLMProphetNetTokenizer
model = ProphetNetForConditionalGeneration.from_pretrained('microsoft/xprophetnet-large-wiki100-cased-xglue-ntg')
tokenizer = ProphetNetTokenizer.from_pretrained('microsoft/xprophetnet-large-wiki100-cased-xglue-ntg')
...
Read more comments on GitHub >

github_iconTop Results From Across the Web

Workers' Right to Refuse Dangerous Work
You refused to work in "good faith." This means that you must genuinely believe that an imminent danger exists; and; A reasonable person...
Read more >
Harassment - FAQs | U.S. Equal Employment Opportunity ...
One instance of harassing conduct is generally not sufficient, unless the conduct is very serious, such as a physical assault. If you believe...
Read more >
Fact Sheet #28P: Taking Leave from Work When You or Your ...
This fact sheet explains when a mental or physical illness, injury, or other condition meets the FMLA's requirements as a serious health condition....
Read more >
Sick Leave to Care for a Family Member with a Serious Health ...
The common cold, influenza, earaches, upset stomach, headaches (other than migraines), routine dental or orthodontia problems, etc., are not serious health ...
Read more >
How We Decide If You Are Disabled (Step 4 and Step 5)
Remember that you are not disabled according to our rules unless your illnesses, injuries or conditions prevent you from doing your past work...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found