This is the output I get after I append the outputs of a pipeline
using facebook-bart-large-mnli
model.
[{'labels': ['recreation', 'entertainment', 'travel', 'dining'],
'scores': [0.8873, 0.1528, 0.0002, 0.0001],
'sequence': 'laundromat'},
{'labels': ['recreation', 'travel', 'entertainment', 'dining'],
'scores': [0.9932, 0.9753, 0.2099, 0.0001],
'sequence': 'running trail'},
{'labels': ['dining', 'entertainment', 'recreation', 'travel'],
'scores': [0.8846, 0.1825, 0.1067, 0.0001],
'sequence': 'affordable housing for young families,cafe or restaurant,none'},
{'labels': ['travel', 'entertainment', 'recreation', 'dining'],
'scores': [0.3595, 0.0716, 0.0187, 0.0039],
'sequence': 'electric vehicle chargers,ev charger'},
classifiedText.append(classifier2(sequence_to_classify, candidate_labels, multi_label=True))
Is there a way for the pipeline to follow the ordering of candidate_labels? (it is a list)
I am trying to output the results of the zero shot classification performed by transformers into a pandas Dataframe, and I found that just using the .to_dict
method poses a problem because the output of the pipeline has a different order for each phrase that is classified.
Is there a way to get the labels to be consistent? (Of course, still matching to the correct value under the scores
key.)