Commit
·
dc490b9
1
Parent(s):
3ee59e1
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
thumbnail: https://cdn.pixabay.com/photo/2017/09/07/08/54/money-2724241__340.jpg
|
5 |
+
tags:
|
6 |
+
- text-classification
|
7 |
+
- sentiment-analysis
|
8 |
+
- finance-sentiment-detection
|
9 |
+
- finance-sentiment
|
10 |
+
license: apache-2.0
|
11 |
+
datasets:
|
12 |
+
- cyrilzhang/financial_phrasebank_split
|
13 |
+
metrics:
|
14 |
+
- Accuracy, F1 score
|
15 |
+
widget:
|
16 |
+
- text: "HK stocks open lower after Fed rate comments"
|
17 |
+
example_title: "HK stocks open lower"
|
18 |
+
- text: "US stocks end lower on earnings worries"
|
19 |
+
example_title: "US stocks end lower"
|
20 |
+
- text: "Muted Fed, AI hopes send Wall Street higher"
|
21 |
+
example_title: "Muted Fed"
|
22 |
+
|
23 |
+
---
|
24 |
+
## nickwong64/bert-base-uncased-finance-sentiment
|
25 |
+
Bert is a Transformer Bidirectional Encoder based Architecture trained on MLM(Mask Language Modeling) objective.
|
26 |
+
[bert-base-uncased](https://huggingface.co/bert-base-uncased) finetuned on the [cyrilzhang/financial_phrasebank_split](https://huggingface.co/datasets/cyrilzhang/financial_phrasebank_split) dataset using HuggingFace Trainer with below training parameters.
|
27 |
+
```
|
28 |
+
learning rate 2e-5,
|
29 |
+
batch size 8,
|
30 |
+
num_train_epochs=6,
|
31 |
+
```
|
32 |
+
|
33 |
+
## Model Performance
|
34 |
+
| Epoch | Training Loss | Validation Loss | Accuracy | F1 |
|
35 |
+
| --- | --- | --- | --- | --- |
|
36 |
+
| 6 | 0.034100 | 0.954745 | 0.853608 | 0.854358 |
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
## How to Use the Model
|
41 |
+
```python
|
42 |
+
from transformers import pipeline
|
43 |
+
nlp = pipeline(task='text-classification',
|
44 |
+
model='nickwong64/bert-base-uncased-finance-sentiment')
|
45 |
+
p1 = "HK stocks open lower after Fed rate comments"
|
46 |
+
p2 = "US stocks end lower on earnings worries"
|
47 |
+
p3 = "Muted Fed, AI hopes send Wall Street higher"
|
48 |
+
print(nlp(p1))
|
49 |
+
print(nlp(p2))
|
50 |
+
print(nlp(p3))
|
51 |
+
"""
|
52 |
+
output:
|
53 |
+
[{'label': 'negative', 'score': 0.9991507530212402}]
|
54 |
+
[{'label': 'negative', 'score': 0.9997240900993347}]
|
55 |
+
[{'label': 'neutral', 'score': 0.9834381937980652}]
|
56 |
+
"""
|
57 |
+
```
|
58 |
+
|
59 |
+
## Dataset
|
60 |
+
[cyrilzhang/financial_phrasebank_split](https://huggingface.co/datasets/cyrilzhang/financial_phrasebank_split)
|
61 |
+
|
62 |
+
## Labels
|
63 |
+
```
|
64 |
+
{0: 'negative', 1: 'neutral', 2: 'positive'}
|
65 |
+
```
|
66 |
+
|
67 |
+
## Evaluation
|
68 |
+
```
|
69 |
+
{'test_loss': 0.9547446370124817,
|
70 |
+
'test_accuracy': 0.8536082474226804,
|
71 |
+
'test_f1': 0.8543579048224414,
|
72 |
+
'test_runtime': 4.9865,
|
73 |
+
'test_samples_per_second': 97.263,
|
74 |
+
'test_steps_per_second': 12.233}
|
75 |
+
```
|
76 |
+
|