flairNLP / flair

A very simple framework for state-of-the-art Natural Language Processing (NLP)
https://flairnlp.github.io/flair/
Other
13.9k stars 2.1k forks source link

predict(sentence, multi_class_prob=True) in TextClassification no longer works #1709

Closed Amyylam closed 4 years ago

Amyylam commented 4 years ago

Describe the bug predict(sentence, multi_class_prob=True) used to give probabilities for all labels, but now only give out one label and associated probability. I have to revert to earlier commit to produce multiple class probabilities (pip install --upgrade git+https://github.com/flairNLP/flair.git@63aeabf9a18bdf53af3bcba5bd80f43ac717656e).

To Reproduce Steps to reproduce the behavior (e.g. which model did you train? what parameters did you use? etc.).

sentence = Sentence("Growth weakens as investment drops, consumers fade")

finetuned_classifier.predict(sentence,multi_class_prob=True)

print(sentence.labels)

Expected behavior it should return: [1 (0.0), -1 (1.0), 0 (0.0)] given the training data has 3 classes.

Screenshots now above steps returns only: [0 (0.0)]

Environment (please complete the following information):

alanakbik commented 4 years ago

@Amyylam should be fixed now! Can you check?

Amyylam commented 4 years ago

Thanks for the bug fix! It's working now!