Simpletransformers: ImportError: cannot import name 'ElectraForMaskedLM'

Created on 9 Apr 2020  路  15Comments  路  Source: ThilinaRajapakse/simpletransformers

Describe the bug

ImportError                               Traceback (most recent call last)
<ipython-input-21-c3e03203b6fb> in <module>
----> 1 from simpletransformers.classification import MultiLabelClassificationModel

/opt/conda/lib/python3.6/site-packages/simpletransformers/classification/__init__.py in <module>
      1 from simpletransformers.classification.classification_model import ClassificationModel
----> 2 from simpletransformers.classification.multi_label_classification_model import MultiLabelClassificationModel
      3 from simpletransformers.classification.multi_modal_classification_model import MultiModalClassificationModel

/opt/conda/lib/python3.6/site-packages/simpletransformers/classification/multi_label_classification_model.py in <module>
      6 
      7 from simpletransformers.classification import ClassificationModel
----> 8 from simpletransformers.custom_models.models import (
      9     BertForMultiLabelSequenceClassification,
     10     RobertaForMultiLabelSequenceClassification,

/opt/conda/lib/python3.6/site-packages/simpletransformers/custom_models/models.py in <module>
     12 from transformers import FlaubertModel
     13 from transformers.configuration_xlm_roberta import XLMRobertaConfig
---> 14 from transformers import ElectraForMaskedLM, ElectraForPreTraining
     15 from torch.nn import BCEWithLogitsLoss
     16 

ImportError: cannot import name 'ElectraForMaskedLM'


To Reproduce
from simpletransformers.classification import MultiLabelClassificationModel

Expected behavior
Successful Import

Desktop (please complete the following information):

  • Ubuntu 16.04
  • simpletransformers-0.24.1
stale

Most helpful comment

pip install --upgrade transformers

All 15 comments

Is your transformers version up to date?

  • Current ~ simpletransformers-0.24.1
    But I see you have released a new version in 2hrs gap, will check and revert.

You need to update transformers as well, not just simpletransformers.

Updated transformers, everything is working fine !

i have the same error which command you use?

pip install --upgrade transformers

it's still the same error, I use:
pip install simpletransformers
and
pip install --upgrade transformers

Try
pip install --force transformers
and then
pip install --force simpletransformers

i tried it but it's not working

What are the versions you have installed right now?

Same error with:
Transformers - 2.8.0
Simple Transformers - 0.24.8
image

Updated transformers, everything is working fine !

Hi, could you mention the versions of simpletransformers and transformers, you are using?

You shouldn't be getting the error with transformers 2.8.0. Something must be messing up your environment. Can you try creating a new environment and installing the packages again?

In kaggle environment pip install --upgrade transformers resolve issue

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.

Was this page helpful?
0 / 5 - 0 ratings