Views
No views yet
1# tested in transformers==4.18.0
2from transformers import BertTokenizer, BertForSequenceClassification, pipeline
3
4finbert = BertForSequenceClassification.from_pretrained('yiyanghkust/finbert-fls',num_labels=3)
5tokenizer = BertTokenizer.from_pretrained('yiyanghkust/finbert-fls')
6nlp = pipeline("text-classification", model=finbert, tokenizer=tokenizer)
7results = nlp('We expect the age of our fleet to enhance availability and reliability due to reduced downtime for repairs.')
8print(results) # [{'label': 'Specific FLS', 'score': 0.77278733253479}]
9