Text Classification
Transformers
PyTorch
Safetensors
English
deberta-v2
Sentiment Classification
Finance
Deberta-v2
Inference Endpoints
RashidNLP commited on
Commit
2257feb
1 Parent(s): a5586f5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -1
README.md CHANGED
@@ -11,4 +11,41 @@ tags:
11
  - Sentiment Classification
12
  - Finance
13
  - Deberta-v2
14
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  - Sentiment Classification
12
  - Finance
13
  - Deberta-v2
14
+ ---
15
+
16
+ # Deberta for Financial Sentiment Analysis
17
+
18
+ I use a Deberta model trained on over 1 million reviews from Amazon's multi-reviews dataset and finetune it on 4 finance datasets that are categorized with Sentiment labels.
19
+ The datasets I use are
20
+
21
+ 1) financial_phrasebank
22
+ 2) chiapudding/kaggle-financial-sentiment
23
+ 3) zeroshot/twitter-financial-news-sentiment
24
+ 4) FinanceInc/auditor_sentiment
25
+
26
+
27
+ ## How to use the model
28
+
29
+ ```python
30
+ import torch
31
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
32
+
33
+ def get_sentiment(sentence):
34
+ bert_dict = {}
35
+ vectors = tokenizer(sentence, return_tensors='pt').to(device)
36
+ outputs = bert_model(**vectors).logits
37
+ probs = torch.nn.functional.softmax(outputs, dim = 1)[0]
38
+ bert_dict['neg'] = round(probs[0].item(), 3)
39
+ bert_dict['neu'] = round(probs[1].item(), 3)
40
+ bert_dict['pos'] = round(probs[2].item(), 3)
41
+ return bert_dict
42
+
43
+ MODEL_NAME = 'RashidNLP/Finance_Multi_Sentiment'
44
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
45
+
46
+ bert_model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME, num_labels = 3).to(device)
47
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
48
+
49
+ get_sentiment("The stock market will struggle to rally until debt ceiling is increased")
50
+
51
+ ```