-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Can't instantiate abstract class MultiLabelPipeline with abstract methods _forward, _sanitize_parameters, postprocess, preprocess #7
Comments
Hey, I had the same issue but I managed to make it work with this: `from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained( def tokenize_text(text): texts = [ goemotions = MultiLabelPipeline( Just make sure to use the multilabel_pipeline provided in the python with the same name in this repo! |
This will still not work, if you create a custom Pipeline with abstract Pipeline, you have to override the |
Solution :
|
the implementation above is nearly identical to the pipeline.py but i get different result. can somebody explain what the reason for this is? results:
|
@bubbazz if you mean that you aren't getting outputs for all labels, but only the main labels, try this. from transformers import BertTokenizer, AutoModelForSequenceClassification, pipeline
model_name = 'original' #'ekman'
tokenizer = BertTokenizer.from_pretrained(f"monologg/bert-base-cased-goemotions-{model_name}")
model = AutoModelForSequenceClassification.from_pretrained(f"monologg/bert-base-cased-goemotions-{model_name}", num_labels=28)
goemotions=pipeline(
model=model,
tokenizer=tokenizer,
task="text-classification",
return_all_scores=True,
function_to_apply='sigmoid',
)
goemotions(texts) |
Thanks for this great work.
I am using transformer v4
I know this is not transformer v2 as requested in the readme file but I cannot install v2.11.0 anymore because there are dependency errors in that version. And I tried v2.4.1 it raise other errors.
In transformer v4, it raises:
Traceback (most recent call last):
goemotions = MultiLabelPipeline(
TypeError: Can't instantiate abstract class MultiLabelPipeline with abstract methods _forward, _sanitize_parameters, postprocess, preprocess
Do you think you can update your code so it can work with the latest Hugginface transformer (v4)?
The text was updated successfully, but these errors were encountered: