ahmedrachid
commited on
Commit
•
feab972
1
Parent(s):
ba2863f
Update README.md
Browse files
README.md
CHANGED
@@ -17,18 +17,18 @@ We fine-tuned our model on Sentiment Analysis task using _FinancialPhraseBank_ d
|
|
17 |
# How to use
|
18 |
Our model can be used thanks to Transformers pipeline for sentiment analysis.
|
19 |
```python
|
20 |
-
from transformers import BertTokenizer, BertForSequenceClassification
|
21 |
-
from transformers import pipeline
|
22 |
|
23 |
-
|
24 |
-
tokenizer = BertTokenizer.from_pretrained("ahmedrachid/FinancialBERT-Sentiment-Analysis")
|
25 |
|
26 |
-
nlp = pipeline("sentiment-analysis", model=
|
27 |
|
28 |
-
sentences = ["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.",
|
29 |
"Bids or offers include at least 1,000 shares and the value of the shares must correspond to at least EUR 4,000.",
|
30 |
"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.",
|
31 |
]
|
32 |
-
results = nlp(sentences)
|
33 |
-
print(results)
|
34 |
```
|
|
|
17 |
# How to use
|
18 |
Our model can be used thanks to Transformers pipeline for sentiment analysis.
|
19 |
```python
|
20 |
+
>>> from transformers import BertTokenizer, BertForSequenceClassification
|
21 |
+
>>> from transformers import pipeline
|
22 |
|
23 |
+
>>> model = BertForSequenceClassification.from_pretrained("ahmedrachid/FinancialBERT-Sentiment-Analysis",num_labels=3)
|
24 |
+
>>> tokenizer = BertTokenizer.from_pretrained("ahmedrachid/FinancialBERT-Sentiment-Analysis")
|
25 |
|
26 |
+
>>> nlp = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
|
27 |
|
28 |
+
>>> sentences = ["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.",
|
29 |
"Bids or offers include at least 1,000 shares and the value of the shares must correspond to at least EUR 4,000.",
|
30 |
"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.",
|
31 |
]
|
32 |
+
>>> results = nlp(sentences)
|
33 |
+
>>> print(results)
|
34 |
```
|