radmada commited on
Commit
3e53067
·
verified ·
1 Parent(s): a959d03

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +48 -3
README.md CHANGED
@@ -1,3 +1,48 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Usage
2
+
3
+ ```python
4
+ from transformers import BertTokenizer, BertForSequenceClassification
5
+ import numpy as np
6
+
7
+ finbert = BertForSequenceClassification.from_pretrained('yiyanghkust/finbert-tone',num_labels=3)
8
+ tokenizer = BertTokenizer.from_pretrained('yiyanghkust/finbert-tone')
9
+
10
+ sentences = ["there is a shortage of capital, and we need extra financing",
11
+ "growth is strong and we have plenty of liquidity",
12
+ "there are doubts about our finances",
13
+ "profits are flat"]
14
+
15
+ inputs = tokenizer(sentences, return_tensors="pt", padding=True)
16
+ outputs = finbert(**inputs)[0]
17
+
18
+ labels = {0:'neutral', 1:'positive',2:'negative'}
19
+ for idx, sent in enumerate(sentences):
20
+ print(sent, '----', labels[np.argmax(outputs.detach().numpy()[idx])])
21
+
22
+ '''
23
+ there is a shortage of capital, and we need extra financing ---- negative
24
+ growth is strong and we have plenty of liquidity ---- positive
25
+ there are doubts about our finances ---- negative
26
+ profits are flat ---- neutral
27
+ '''
28
+
29
+ ```
30
+
31
+ # Cite
32
+
33
+ ```latex
34
+ @misc{yang2020finbert,
35
+ title={FinBERT: A Pretrained Language Model for Financial Communications},
36
+ author={Yi Yang and Mark Christopher Siy UY and Allen Huang},
37
+ year={2020},
38
+ eprint={2006.08097},
39
+ archivePrefix={arXiv},
40
+ }
41
+
42
+ ```
43
+
44
+ # License
45
+
46
+ ---
47
+ license: apache-2.0
48
+ ---