Trouble Importing DistilBertForMultilabelSequenceClassification
Hi there, I am having trouble importing DistilBertForMultilabelSequenceClassification
.
In the attached two pictures you can see I am having no issues importing the AutoModelForSequenceClassification but when I try and import the DistilBertForMultilabelSequenceClassification I get:
ImportError Traceback (most recent call last)
Cell In [3], line 1
----> 1 from transformers import AutoTokenizer, DistilBertForMultilabelSequenceClassification
3 tokenizer = AutoTokenizer.from_pretrained("bhadresh-savani/bert-base-go-emotion")
5 model = DistilBertForMultilabelSequenceClassification.from_pretrained("bhadresh-savani/bert-base-go-emotion")
ImportError: cannot import name 'DistilBertForMultilabelSequenceClassification' from 'transformers' (C:\Users\name\AppData\Roaming\Python\Python310\site-packages\transformers_init_.py)
Hello,
I think you should use BertForSequenceClassification
. Since its Bert Model, DistilBertForMultilabelSequenceClassification
may not work because you are using class for Distilbert and model is not trained on the Multilabel
problem so that will also be inappropriate to use.
from transformers import AutoTokenizer, BertForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("bhadresh-savani/bert-base-go-emotion")
model = BertForSequenceClassification.from_pretrained("bhadresh-savani/bert-base-go-emotion")
The above syntax will work.
The error you are getting is because DistilBertForMultilabelSequenceClassification
is not the actual class in the transformer library. It should be BertForSequenceClassification