I was going to download this model, and then I was going to save it later to be used with bert-serving. Since bert-serving only supports tensorflow model, I need to download the tensorflow one and not the PyTorch. The PyTorch model downloads just fine, but the I cannot download the tensorflow model. I used this code to download:
from transformers import BertTokenizer, TFBertModel
model_name='cahya/bert-base-indonesian-522M'
model = TFBertModel.from_pretrained(model_name)
Here’s what I got when running the code on Ubuntu 16.04, python3.5, transformers==2.5.1,
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/username/.local/lib/python3.5/site-packages/transformers/modeling_tf_utils.py", line 346, in from_pretrained
assert os.path.isfile(resolved_archive_file), "Error retrieving file {}".format(resolved_archive_file)
File "/usr/lib/python3.5/genericpath.py", line 30, in isfile
st = os.stat(path)
TypeError: stat: can't specify None for path argument
And here’s what I got when running it on Windows 10, python 3.6.5, transformers 3.1.0:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\transformers\modeling_tf_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
579 if resolved_archive_file is None:
--> 580 raise EnvironmentError
581 except EnvironmentError:
OSError:
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
<ipython-input-3-c2f14f761f05> in <module>()
3 model_name='cahya/bert-base-indonesian-522M'
4 tokenizer = BertTokenizer.from_pretrained(model_name)
----> 5 model = TFBertModel.from_pretrained(model_name)
C:\ProgramData\Anaconda3\lib\site-packages\transformers\modeling_tf_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
585 f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a file named one of {TF2_WEIGHTS_NAME}, {WEIGHTS_NAME}.\n\n"
586 )
--> 587 raise EnvironmentError(msg)
588 if resolved_archive_file == archive_file:
589 logger.info("loading weights file {}".format(archive_file))
OSError: Can't load weights for 'cahya/bert-base-indonesian-522M'. Make sure that:
- 'cahya/bert-base-indonesian-522M' is a correct model identifier listed on 'https://huggingface.co/models'
- or 'cahya/bert-base-indonesian-522M' is the correct path to a directory containing a file named one of tf_model.h5, pytorch_model.bin.
This also happens with other cahya/ models. This page says that you can use the tensorflow model. However, based on the error, it seems like the file does not exist over there?
I tried downloading other pretrained model like bert-base-uncased
etc. and they download just fine. This issue only happens with cahya/ models.
Am I missing something? or should I report this issue to a github issue?