Outputting only one label and not all 25

#3
by NaomiKen - opened

I have been trying to use your model with this code:

finbert = BertForSequenceClassification.from_pretrained('nbroad/ESG-BERT', num_labels=26)
tokenizer = BertTokenizer.from_pretrained('nbroad/ESG-BERT')

nlp = pipeline("text-classification", model=finbert, tokenizer=tokenizer)
results = nlp('In fiscal year 2019, we reduced our comprehensive carbon footprint for the fourth consecutive year—down 35 percent compared to 2015, when Apple’s carbon emissions peaked, even as net revenue increased by 11 percent over that same period. In the past year, we avoided over 10 million metric tons from our emissions reduction initiatives—like our Supplier Clean Energy Program, which lowered our footprint by 4.4 million metric tons.')
print(results)

This works except for the fact that I only get the top output and not all 25. Do you know how to get all 25 numbers,

Here is what I would recommend:

nlp = pipeline("text-classification", model="nbroad/ESG-BERT")

text = 'In fiscal year 2019, we reduced our comprehensive carbon footprint for the fourth consecutive year—down 35 percent compared to 2015, when Apple’s carbon emissions peaked, even as net revenue increased by 11 percent over that same period. In the past year, we avoided over 10 million metric tons from our emissions reduction initiatives—like our Supplier Clean Energy Program, which lowered our footprint by 4.4 million metric tons.'

nlp(text, return_all_scores=True)

nbroad changed discussion status to closed

Sign up or log in to comment