Vasu Dev Reddy
Vasu Dev Reddy

Reputation: 19

Getting an error(cannot import name 'BertPreTrainedModel') while importing classification model from simpletransformers

Getting the following error while trying to import the classificationmodel from simpletransformers.


ImportError                               Traceback (most recent call last)
<ipython-input-1-29f08e6c2d87> in <module>()
----> 1 from simpletransformers.classification import ClassificationModel, ClassificationArgs

3 frames
/usr/local/lib/python3.6/dist-packages/simpletransformers/classification/transformer_models/roberta_model.py in <module>()
      2 import torch.nn as nn
      3 from torch.nn import CrossEntropyLoss, MSELoss
----> 4 from transformers.modeling_roberta import (
      5     ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
      6     BertPreTrainedModel,

ImportError: cannot import name 'BertPreTrainedModel'

---------------------------------------------------------------------------

Upvotes: 1

Views: 2823

Answers (1)

N. Kiefer
N. Kiefer

Reputation: 337

In this github issue the problem was an old version of simpletransformers. To get the latest version do pip install --upgrade simpletransformers. Maybe even do this for the transformers package as well.

Upvotes: 2

Related Questions