Multiple Categories (labels)
Hi@joeddavand@bhadresh-savaniI am using your text-classification models, but I am encountering a problem, nothing I try allows me to retrieve all the values: always just the first value is returned, would you be able to advise me, thanks so much.image1040×157 7.12 KBhuggingface.cojoeddav/distilbert-base-uncased-go-emotions-student · Hugging FaceWe’re on a journey to advance and democratize artificial intelligence through open source and open science.huggingface.cobhadresh-savani/distilbert-base-uncased-emotion · Hugging FaceWe’re on a journey to advance and democratize artificial intelligence through open source and open science.
2021-06-18T12:58:58Z
Hi@snowdere,I am really glad you use this model, you can use it like either of the below waysfrom transformers import pipeline
classifier = pipeline("text-classification",model='bhadresh-savani/distilbert-base-uncased-emotion', return_all_scores=True)
prediction = classifier("I love using transformers. The best part is wide range of support and its easy to use", )
print(prediction)orfrom transformers import pipeline
classifier = pipeline("sentiment-analysis",model='bhadresh-savani/distilbert-base-uncased-emotion', return_all_scores=True)
prediction = classifier("I love using transformers. The best part is wide range of support and its easy to use", )
print(prediction)return_all_scores=Trueshould be in thepipeline()argument.Output:[[
{'label': 'sadness', 'score': 0.0006792712374590337}, 
{'label': 'joy', 'score': 0.9959300756454468}, 
{'label': 'love', 'score': 0.0009452480007894337}, 
{'label': 'anger', 'score': 0.0018055217806249857}, 
{'label': 'fear', 'score': 0.00041110432357527316}, 
{'label': 'surprise', 'score': 0.0002288572577526793}
]]Thanks
2021-06-21T08:23:42Z
bhadresh-savani:from transformers import pipeline
classifier = pipeline("text-classification",model='bhadresh-savani/distilbert-base-uncased-emotion', return_all_scores=True)
prediction = classifier("I love using transformers. The best part is wide range of support and its easy to use", )
print(prediction)Thanks for the answer that is great, so can this also be used for multiclassification (if it is both for example joy and love?) i.e. 60% joy, and 70% love and 20% anger etc…if not, do you know what model I can use for this?
2021-06-21T09:52:38Z
Hi@snowdere,Currently,text-classificationpipeline only has multiclass classification. It uses softmax if more than two labels. You can try zero-shot pipeline, it supports multilabel things that you required. This model I trained for multiclass classification as the emotion dataset is multiclass kind of dataset(i.e. having labels like [1 0 0 0 0 0] with six class).
2023-02-01T10:31:56Z
return_all_scoreshas been Deprecated. Instead passtop_k=Noneif you want all scores.