Instructions to use radmada/FinBERT-BaseVocab-Cased with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use radmada/FinBERT-BaseVocab-Cased with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="radmada/FinBERT-BaseVocab-Cased")# Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("radmada/FinBERT-BaseVocab-Cased") model = AutoModelForMaskedLM.from_pretrained("radmada/FinBERT-BaseVocab-Cased", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 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 |
+
---
|