I am trying to test this model called BETO (the model is an implementation of Bert in Spanish):
!pip install transformers
!wget https://users.dcc.uchile.cl/~jperez/beto/cased_2M/pytorch_weights.tar.gz
!wget https://users.dcc.uchile.cl/~jperez/beto/cased_2M/vocab.txt
!wget https://users.dcc.uchile.cl/~jperez/beto/cased_2M/config.json
!tar -xzvf pytorch_weights.tar.gz
!mv config.json pytorch/.
!mv vocab.txt pytorch/.
import torch
from transformers import BertForMaskedLM, BertTokenizer
tokenizer = BertTokenizer.from_pretrained("pytorch/", do_lower_case=False)
model = BertForMaskedLM.from_pretrained("pytorch/")
model.eval()
the enviroment is as follows:
platform debian 10
transformers 3.4.0
python 3.7.3
torch 1.7.0
tensorflow 2.3.1
but in the following line:
model = BertForMaskedLM.from_pretrained("pytorch/")
I get this error:
Exception has occurred: OSError
Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
Thanks in advance
2
Answers
I’ve tried the exact same code in Ubuntu with no problems.
OSError is a built-in exception in Python and serves as the error class for the os module, which is raised when an os specific system function returns a system-related error, including I/O failures such as “file not found” or “disk full”.
Maybe you can dig deeper into your OSError?
try with this: