transformers: TFBertModel.from_pretrained('neuralmind/bert-base-portuguese-cased') -> TypeError

I just installed the library on a TensorFlow environment (2.0.0-rc1) and there is no BertModel in transformers.

Is TFBertModel equivalent? If so, then I get the error TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType when loading the model with model = TFBertModel.from_pretrained('neuralmind/bert-base-portuguese-cased').

  • transformers version: 2.4.1
  • Platform: Windows 10
  • Python version: 3.7.6
  • Tensorflow version (GPU?): 2.0.0-rc1 (it automatically uses GPU now)
  • Using GPU in script?: No, just importing.
  • Using distributed or parallel set-up in script?: No.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

sometimes it works, sometimes it appears error

@daraksha-shirin you’re welcome! Glad that I could help!

Hi @Riccorl my problem somehow just disappear after restarting and upgrading tensorflow to 2.1.0. I’m not sure how it is solved. Initially, the error pops up randomly, meaning sometimes it works smoothly sometimes not. But I have no error now at all.

Maybe do a pip install -U transformers And then pip install -U tensorflow-gpu

Installing above packages solved this issue for me. Its working fine now. Thanks @nixon-nyx

This model is only available in PyTorch, Neuralmind has not provided a TensorFlow checkpoint for that model. You can see it on the page, as it has the tag PyTorch, but no TensorFlow tag.

You can still load it in TensorFlow, but you have to add the from_pt flag:

from transformers import TFBertModel

TFBertModel.from_pretrained('neuralmind/bert-base-portuguese-cased', from_pt=True)

This might require you to have PyTorch installed to do the conversion.