Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError for 'ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST' from 'transformers' #39

Open
esther1262 opened this issue May 22, 2024 · 3 comments

Comments

@esther1262
Copy link

Hi, I followed this tutorial with the sample data.
https://github.com/uf-hobi-informatics-lab/ClinicalTransformerNER/blob/master/tutorial/pipeline_preprocessing_model_training_prediction.ipynb

Everything worked well until I ran the command python ../src/run_transformer_ner.py.
I use anaconda and I installed transformer v4.41 using conda forge.
Pytorch was installed using conda too for linux and cuda 12.1.
The ClinicalTransformerNER folder is stored in /home/user .
I stored the training data in /home/user/language model/sample data/ddi_bio/merge.

This is the command I used:

python ClinicalTransformerNER/src/run_transformer_ner.py 
--model_type bert --pretrained_model bert-base-uncased 
--data_dir language model/sample data/ddi_bio/merge
 --new_model_dir language model/new_bert_ner_model --overwrite_model_dir 
--save_model_core --do_train --do_lower_case 
--log_file language model/log.txt --progress_bar --early_stop 3

Here is the error I got:

Traceback (most recent call last):
  File "/home/user/ClinicalTransformerNER/src/run_transformer_ner.py", line 12, in <module>
    from transformer_ner.task import run_task
  File "/home/user/ClinicalTransformerNER/src/transformer_ner/task.py", line 43, in <module>
    from transformer_ner.model import (AlbertNerModel, BartNerModel,
  File "/home/user/ClinicalTransformerNER/src/transformer_ner/model.py", line 11, in <module>
    from transformers import (ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
ImportError: cannot import name 'ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST' from 'transformers' (/home/user/anaconda3/lib/python3.11/site-packages/transformers/__init__.py)

Can someone please help how to fix the error? I restarted the computer already. In python, I can run commands like from transformers import TFBertModel, BertModel but there's nothing named ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST or any PRETRAINED_MODEL_ARCHIVE_LIST in transformers/__init__.py .

Thanks

@bugface
Copy link
Contributor

bugface commented May 23, 2024

@esther1262 I think the version of transformers we used is transformers==4.12.5, if you can create a virtual env and use this version, it should work.

Meanwhile, @chenaokun @cpenguf any of u can check the transformers package compatibility issue and we might need to update this repo for any break updates.

@esther1262
Copy link
Author

esther1262 commented May 23, 2024

Hi, I couldn't install transformers earlier than version 4.34.0. It gave me the following errors:

ERROR: Failed building wheel for tokenizers
Failed to build tokenizers
ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects

So I installed ver 4.34.0 which also contains ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST. It's just there were some warnings:

/home/user/anaconda3/envs/nlp/lib/python3.12/site-packages/transformers/utils/generic.py:311: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  torch.utils._pytree._register_pytree_node(
/home/user/anaconda3/envs/nlp/lib/python3.12/site-packages/transformers/utils/generic.py:311: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.

Otherwise, the code is working. Thanks.

@bugface
Copy link
Contributor

bugface commented May 24, 2024

Hi, I couldn't install transformers earlier than version 4.34.0. It gave me the following errors:

ERROR: Failed building wheel for tokenizers
Failed to build tokenizers
ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects

So I installed ver 4.34.0 which also contains ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST. It's just there were some warnings:

/home/user/anaconda3/envs/nlp/lib/python3.12/site-packages/transformers/utils/generic.py:311: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  torch.utils._pytree._register_pytree_node(
/home/user/anaconda3/envs/nlp/lib/python3.12/site-packages/transformers/utils/generic.py:311: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.

Otherwise, the code is working. Thanks.

Great to know. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants