ThilinaRajapakse / simpletransformers

Transformers for Information Retrieval, Text Classification, NER, QA, Language Modelling, Language Generation, T5, Multi-Modal, and Conversational AI
https://simpletransformers.ai/
Apache License 2.0
4.11k stars 727 forks source link

Importing TransformerModel is giving error #328

Closed saurabh502 closed 4 years ago

saurabh502 commented 4 years ago

Describe the bug When importing from simpletransformers.model import TransformerModel getting below error. I guess this is due to recent upgrade for Electra

`--------------------------------------------------------------------------- ImportError Traceback (most recent call last)

in ----> 1 from simpletransformers.model import TransformerModel 2 3 # Create a TransformerModel 4 model = TransformerModel('xlmroberta', 'xlm-roberta-large', num_labels=len(label),args = {"overwrite_output_dir": True, "max_seq_length": 128,"train_batch_size": 16}) 5 /opt/conda/lib/python3.6/site-packages/simpletransformers/model.py in ----> 1 from simpletransformers.classification.classification_model import ClassificationModel 2 3 TransformerModel = ClassificationModel /opt/conda/lib/python3.6/site-packages/simpletransformers/classification/__init__.py in ----> 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/classification_model.py in 36 from simpletransformers.classification.transformer_models.xlnet_model import XLNetForSequenceClassification 37 from simpletransformers.config.global_args import global_args ---> 38 from simpletransformers.custom_models.models import ElectraForSequenceClassification 39 from tensorboardX import SummaryWriter 40 from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset /opt/conda/lib/python3.6/site-packages/simpletransformers/custom_models/models.py in 2 from torch import nn 3 from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss ----> 4 from transformers import ( 5 BertModel, 6 BertPreTrainedModel, ImportError: cannot import name 'ElectraForMaskedLM'`
ThilinaRajapakse commented 4 years ago

Closed as duplicated of #306