ThilinaRajapakse/simpletransformers

ModuleNotFoundError: No module named 'transformers.models.mmbt'

DeepakGaurAerospace opened this issue ยท 12 comments

For BERT model training in Colab, I have installed following libraries:

  1. !pip install simpletransformers
  2. !pip install transformers -U (4.31.0)
  3. !pip install --upgrade tqdm (4.65.0)
  4. !pip install --upgrade simpletransformers

To Reproduce
Steps to reproduce the behavior:

import simpletransformers
from simpletransformers.classification import ClassificationModel


ModuleNotFoundError Traceback (most recent call last)
in <cell line: 1>()
----> 1 from simpletransformers.classification import ClassificationModel

1 frames
/usr/local/lib/python3.10/dist-packages/simpletransformers/classification/multi_modal_classification_model.py in
45 BertTokenizer,
46 )
---> 47 from transformers.models.mmbt.configuration_mmbt import MMBTConfig
48
49 from simpletransformers.classification.classification_utils import (

ModuleNotFoundError: No module named 'transformers.models.mmbt'


NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.

Expected behavior
Previously, when I tried calling this function, it worked flawlessly, which was barely 3 days earlier.

Screenshots
image

I am also having this same problem with similar steps to reproduce.

!pip install simpletransformers
from simpletransformers.classification import ClassificationModel, ClassificationArgs, MultiLabelClassificationModel, MultiLabelClassificationArgs

This results in:

ModuleNotFoundError: No module named 'transformers.models.mmbt'

I am also using Colab and had no issues two days ago.

image

I had the same issue.

Until this is fixed, the following workaround can be used (see issue #1538):

!pip install simpletransformers "transformers==4.30.2"

Until this is fixed, the following workaround can be used (see issue #1538):

!pip install simpletransformers "transformers==4.30.2"

This is work for me. Thanks !

Same here.

This workaround worked for me. However, when trying to infer/predict using a pre-trained model, i get this error. Anybody knows what's going on here? I dire need. Thanks!

Screenshot 2023-07-21 at 3 10 29 PM

This workaround worked for me. However, when trying to infer/predict using a pre-trained model, i get this error. Anybody knows what's going on here? I dire need. Thanks!
Screenshot 2023-07-21 at 3 10 29 PM

The predict method works in the examples I've just tried. Could you share your code with us? Maybe we can work out what's happening.

Thank you

This workaround worked for me. However, when trying to infer/predict using a pre-trained model, i get this error. Anybody knows what's going on here? I dire need. Thanks!
Screenshot 2023-07-21 at 3 10 29 PM

The predict method works in the examples I've just tried. Could you share your code with us? Maybe we can work out what's happening.

Thank you so much. This is the whole code. Pretty simple, I'm loading a pre-trained model to predict. It pretty much runs through but fails at the very end. Any help would be much appreciated!
Screenshot 2023-07-21 at 7 56 11 PM

This is the whole code. Pretty simple, I'm loading a pre-trained model to predict. It pretty much runs through but fails at the very end. Any help would be much appreciated!

I can't seem to recreate the error, despite saving and loading a number of roberta based models. It's possible that there's something about the particular model being loaded that simple transformers or scipy isn't getting on with.

I notice that in the latest version of scipy (1.11.1) the default behaviour of the mode method has changed. Assuming the latest version of scipy was installed as a dependency when simple transformers was installed, maybe instead using a previous version of scipy could help. Perhaps try the following:

pip install simpletransformers "transformers==4.30.2" "scipy==1.10.1"

This is only a slight possibility though unfortunately. I think it's difficult to say for sure what the problem is without taking a look at your conda environment and saved model in detail.

This is the whole code. Pretty simple, I'm loading a pre-trained model to predict. It pretty much runs through but fails at the very end. Any help would be much appreciated!

I can't seem to recreate the error, despite saving and loading a number of roberta based models. It's possible that there's something about the particular model being loaded that simple transformers or scipy isn't getting on with.

I notice that in the latest version of scipy (1.11.1) the default behaviour of the mode method has changed. Assuming the latest version of scipy was installed as a dependency when simple transformers was installed, maybe instead using a previous version of scipy could help. Perhaps try the following:

pip install simpletransformers "transformers==4.30.2" "scipy==1.10.1"

This is only a slight possibility though unfortunately. I think it's difficult to say for sure what the problem is without taking a look at your conda environment and saved model in detail.

Installing simpletransformers with scipy1.10.1 indeed worked! Seemed like incompatibility with new scipy mode function was the issue. Thank you so much!

Looks like the latest version of transformers is incompatible with the current Simple Transformers version. I will look into this next week. Until then, please use the workaround suggested by @owendw1 (thanks!).

This should be fixed now. The latest version of Simple Transformers should be compatible with the latest Transformers (as well as Python and PyTorch) versions.