-
Notifications
You must be signed in to change notification settings - Fork 20
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
Doesn't support the latest version of transformers. IndexError: tuple index out of range #14
Comments
I have met the same problems. Could there is a solution? |
Unfortunately, the installation on Mac with ARM architecture failed, however, I managed to install and run it on a Linux machine with the required dependencies. The only thing I could recommend is using Python<3.9 on Linux with the rest of the installation instructions. |
Hi @LingjieBao1998, I have found the solution for Mac users with Apple silicon. You can follow next instruction to install ChemRxnExtractor: 1. Install compatible conda with either Miniforge or Anaconda(Miniconda). We recommend using Miniforge.
if you have installed Anaconda(Miniconda) update it to the latest version: 2. Create environment and install essential libraries.
It’s important to use channel conda-forge for installation next version of tokenizers and transformed.
Install tokenizers then transformers: 3. Install ChemRxnExtractor
4. If the error occurs:line XXX, in init Please, go to the file: /Users/USER_NAME/miniforge3/envs/ENV_NAME/lib/python3.YY/site-packages/transformers/tokenization_bert.py and in line XXX change 'vocab_file' to 'vocab' |
Hi! I tried to install the program on Mac M2 and found the error while using fresh python3.11 and transformers 4.34.0 as well as tokenizers 0.14.1. When I ran pipeline.py I got the next error, I also printed outputs variable and its type from model.py file:
python pipeline.py --model models --input tests/data/raw.txt --output out.json
Loading product extractor from models/prod...Some weights of the model checkpoint at models/prod were not used when initializing BertCRFForTagging: ['bert.pooler.dense.weight', 'bert.pooler.dense.bias']
This IS expected if you are initializing BertCRFForTagging from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
This IS NOT expected if you are initializing BertCRFForTagging from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
done
Loading role extractor from models/role...Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Some weights of the model checkpoint at models/role were not used when initializing BertCRFForRoleLabeling: ['bert.pooler.dense.weight', 'bert.pooler.dense.bias']
This IS expected if you are initializing BertCRFForRoleLabeling from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
This IS NOT expected if you are initializing BertCRFForRoleLabeling from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
done
BaseModelOutputWithPoolingAndCrossAttentions(last_hidden_state=tensor([[[-7.2273e-01, -1.3122e-01, -1.1214e+00, ..., 1.3058e+00,
-7.9485e-01, 1.7867e+00],
[-7.0862e-01, 8.6485e-01, -8.8587e-01, ..., -9.6626e-01,
1.1189e+00, 8.2820e-01],
[ 4.5367e-01, -1.0321e+00, -4.2794e-02, ..., -1.1382e-01,
-6.6842e-01, -2.5176e-01],
...,
[ 4.6953e-01, -4.4274e-01, -2.4798e-01, ..., -7.2705e-02,
1.0744e-01, -6.4336e-01],
[ 2.9490e-01, -6.9888e-01, 4.3615e-01, ..., 2.6774e-01,
-2.0582e-01, -5.2261e-01],
[ 3.9034e-01, -4.5327e-01, 7.8649e-02, ..., 9.6617e-02,
1.2183e-01, -6.4031e-01]],
<class 'transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions'>
Traceback (most recent call last):
File "/Users/alekseikrasov/Desktop/OntoChem/work/ChemRxnExtractor/ChemRxnExtractor/pipeline.py", line 22, in
rxns = rxn_extractor.get_reactions(sents[:10])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/alekseikrasov/Desktop/OntoChem/work/ChemRxnExtractor/ChemRxnExtractor/chemrxnextractor/cre.py", line 224, in get_reactions
outputs = self.role_extractor(
^^^^^^^^^^^^^^^^^^^^
File "/Users/alekseikrasov/miniforge3/envs/ontochem/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/alekseikrasov/miniforge3/envs/ontochem/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/alekseikrasov/Desktop/OntoChem/work/ChemRxnExtractor/ChemRxnExtractor/chemrxnextractor/models/model.py", line 321, in forward
extended_cls_h = outputs[1].unsqueeze(1).expand(batch_size, seq_length, hidden_dim) # FIXME: here is the errer causing IndexError: tuple index out of range in
~~~~~~~^^^
File "/Users/alekseikrasov/miniforge3/envs/ontochem/lib/python3.11/site-packages/transformers/utils/generic.py", line 405, in getitem
return self.to_tuple()[k]
~~~~~~~~~~~~~~~^^^
IndexError: tuple index out of range
I tried to use the old version of transformers v.3.0.2, however, I cannot compile tokenizers==0.8.1.rc1 (from transformers==3.0.2) with existing Rust compiler. The same problem was on Linux Opensuse machine.
Could you please help to solve this problem and maybe update the code and requirements so that one could use the latest version of Python, transformers, and tokenizers?
The text was updated successfully, but these errors were encountered: