Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
You can use this model with Transformers pipeline for sentiment analysis.
|
| 2 |
+
```python
|
| 3 |
+
from transformers import BertTokenizer, BertForSequenceClassification
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
|
| 6 |
+
finbert = BertForSequenceClassification.from_pretrained('yiyanghkust/finbert-tone',num_labels=3)
|
| 7 |
+
tokenizer = BertTokenizer.from_pretrained('yiyanghkust/finbert-tone')
|
| 8 |
+
|
| 9 |
+
nlp = pipeline("sentiment-analysis", model=finbert, tokenizer=tokenizer)
|
| 10 |
+
|
| 11 |
+
sentences = ["there is a shortage of capital, and we need extra financing",
|
| 12 |
+
"growth is strong and we have plenty of liquidity",
|
| 13 |
+
"there are doubts about our finances",
|
| 14 |
+
"profits are flat"]
|
| 15 |
+
results = nlp(sentences)
|
| 16 |
+
print(results) #LABEL_0: neutral; LABEL_1: positive; LABEL_2: negative
|