EmilyAlsentzer / clinicalBERT

repository for Publicly Available Clinical BERT Embeddings
MIT License
658 stars 134 forks source link

Getting Started using transformers #23

Closed lukasfolle closed 4 years ago

lukasfolle commented 4 years ago

When I am trying to get started with the model "emilyalsentzer/Bio_ClinicalBERT" using the model card at huggingface and this code

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("emilyalsentzer/Bio_ClinicalBERT")
model = AutoModel.from_pretrained("emilyalsentzer/Bio_ClinicalBERT")

I get the following error:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    tokenizer = AutoTokenizer.from_pretrained("emilyalsentzer/Bio_ClinicalBERT")
  File "/Users/Lukas/miniconda3/envs/nlp/lib/python3.7/site-packages/transformers/tokenization_auto.py", line 124, in from_pretrained
    "'xlm', 'roberta', 'ctrl'".format(pretrained_model_name_or_path))
ValueError: Unrecognized model identifier in emilyalsentzer/Bio_ClinicalBERT. Should contains one of 'bert', 'openai-gpt', 'gpt2', 'transfo-xl', 'xlnet', 'xlm', 'roberta', 'ctrl'

I would appreciate any help regarding this.

YojanaGadiya commented 4 years ago

@lukasfolle It is surprising because when I use the same code, it works for me. Maybe you can try updating pytorch-tranformer with pip install pytorch-transformer --upgrade

EmilyAlsentzer commented 4 years ago

@lukasfolle, has this issue been resolved? If not, can you provide more information about your library version? I haven't had any issues loading the model using the most recent transformers repo.

lukasfolle commented 4 years ago

@EmilyAlsentzer @YojanaGadiya Sorry for the late reply. Yes, installing with pip resolves the issue. Somehow conda seems to lag behind the pip version.