Views
No views yet
1from transformers import BertTokenizer, BertForSequenceClassification
2from transformers import pipeline
3
4finbert = BertForSequenceClassification.from_pretrained('Forturne/Finbert_PB',num_labels=3)
5tokenizer = BertTokenizer.from_pretrained('Forturne/Finbert_PB')
6
7nlp = pipeline("sentiment-analysis", model=finbert, tokenizer=tokenizer)
8
9sentences = ["there is a shortage of capital, and we need extra financing",
10 "growth is strong and we have plenty of liquidity",
11 "there are doubts about our finances",
12 "profits are flat"]
13results = nlp(sentences)
14print(results) #LABEL_0: neutral; LABEL_1: positive; LABEL_2: negative