Views
No views yet
FinancialBERT's pre-training process can be found at: https://www.researchgate.net/publication/358284785_FinancialBERT_-_A_Pretrained_Language_Model_for_Financial_Text_Mining| sentiment | precision | recall | f1-score | support |
|---|---|---|---|---|
| negative | 0.96 | 0.97 | 0.97 | 58 |
| neutral | 0.98 | 0.99 | 0.98 | 279 |
| positive | 0.98 | 0.97 | 0.97 | 148 |
| macro avg | 0.97 | 0.98 | 0.98 | 485 |
| weighted avg | 0.98 | 0.98 | 0.98 | 485 |
1from transformers import BertTokenizer, BertForSequenceClassification
2from transformers import pipeline
3
4model = BertForSequenceClassification.from_pretrained("ahmedrachid/FinancialBERT-Sentiment-Analysis",num_labels=3)
5tokenizer = BertTokenizer.from_pretrained("ahmedrachid/FinancialBERT-Sentiment-Analysis")
6
7nlp = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
8
9sentences = ["Operating profit rose to EUR 13.1 mn from EUR 8.7 mn in the corresponding period in 2007 representing 7.7 % of net sales.",
10 "Bids or offers include at least 1,000 shares and the value of the shares must correspond to at least EUR 4,000.",
11 "Raute reported a loss per share of EUR 0.86 for the first half of 2009 , against EPS of EUR 0.74 in the corresponding period of 2008.",
12 ]
13results = nlp(sentences)
14print(results)
15
16[{'label': 'positive', 'score': 0.9998133778572083},
17 {'label': 'neutral', 'score': 0.9997822642326355},
18 {'label': 'negative', 'score': 0.9877365231513977}]Created by Ahmed Rachid Hazourli