transformers icon indicating copy to clipboard operation
transformers copied to clipboard

Error while loading albert for token classification

Open nirajkale opened this issue 6 years ago • 4 comments

Environment info

  • transformers version: 3.0.2
  • Platform: Windows-10-10.0.18362-SP0
  • Python version: 3.6.10
  • PyTorch version (GPU?): not installed (NA)
  • Tensorflow version (GPU?): 2.2.0 (False)
  • Using GPU in script?: No
  • Using distributed or parallel set-up in script?: No

Who can help

@LysandreJik @jplu

Information

Model I am using albert-base-v2 or albert-base-v1:

The tasks I am working on is: token classification using albert-base-v2 or v1

To reproduce


>>> from transformers import AlbertTokenizer, TFAlbertForTokenClassification
>>> import tensorflow as tf

>>> tokenizer = AlbertTokenizer.from_pretrained('albert-base-v2', cache_dir = 'cache')
>>> model = TFAlbertForTokenClassification.from_pretrained('albert-base-v2', cache_dir = 'cache')

When I run above script I get error:


Traceback (most recent call last):
  File "C:\Users\703235761\AppData\Local\Continuum\anaconda3\envs\slot\lib\site-packages\transformers\modeling_tf_utils.py", line 581, in from_pretrained
    raise EnvironmentError
OSError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "model_utils.py", line 7, in <module>
    model = TFAlbertForTokenClassification.from_pretrained('albert-base-v1', cache_dir = 'cache')
  File "C:\Users\703235761\AppData\Local\Continuum\anaconda3\envs\slot\lib\site-packages\transformers\modeling_tf_utils.py", line 588, in from_pretrained
    raise EnvironmentError(msg)
OSError: Can't load weights for 'albert-base-v1'. Make sure that:

- 'albert-base-v1' is a correct model identifier listed on 'https://huggingface.co/models'

- or 'albert-base-v1' is the correct path to a directory containing a file named one of tf_model.h5, pytorch_model.bin.

Expected behavior

I think this model was supposed to work with TFAlbertModel as well. Thanks in advance! :-)

nirajkale avatar Aug 10 '20 16:08 nirajkale

Quick update: Above code works just fine in Ubuntu environment with below specs:

  • transformers version: 3.0.2
  • Platform: Linux-5.3.0-1034-azure-x86_64-with-debian-buster-sid
  • Python version: 3.6.10
  • PyTorch version (GPU?): 1.5.1 (True)
  • Tensorflow version (GPU?): 2.0.0 (True)
  • Using GPU in script?: yes (Tesla P40)
  • Using distributed or parallel set-up in script?: No

I think this issue only occurs in Windows.

nirajkale avatar Aug 10 '20 16:08 nirajkale

Hi! This may be related to a network error, can you download other models on your Windows machine?

LysandreJik avatar Aug 11 '20 09:08 LysandreJik

set REQUESTS_CA_BUNDLE env var to ca-certificates.crt

In my case I am using Ubuntu, so running the following command on terminal solves the issue:

export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

UmarSpa avatar Sep 29 '20 08:09 UmarSpa

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 29 '20 00:11 stale[bot]