RashidNLP commited on
Commit
de67ba2
1 Parent(s): 404d597

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -0
README.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - amazon_reviews_multi
4
+ language:
5
+ - en
6
+ library_name: transformers
7
+ tags:
8
+ - Text Classification
9
+ - Pytorch
10
+ - Sentiment_Analysis
11
+ - Deberta
12
+ ---
13
+ # Deberta for Sentiment Analysis
14
+
15
+ This model has been trained on over 400k reviews from Amazon's multi-reviews dataset.
16
+
17
+ ## How to use the model
18
+
19
+ ```python
20
+ import torch
21
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
22
+
23
+ def get_sentiment(sentence):
24
+ bert_dict = {}
25
+ vectors = tokenizer(sentence, return_tensors='pt').to(device)
26
+ outputs = bert_model(**vectors).logits
27
+ probs = torch.nn.functional.softmax(outputs, dim = 1)[0]
28
+ bert_dict['neg'] = round(probs[0].item(), 3)
29
+ bert_dict['neu'] = round(probs[1].item(), 3)
30
+ bert_dict['pos'] = round(probs[2].item(), 3)
31
+ return bert_dict
32
+
33
+ MODEL_NAME = 'RashidNLP/Amazon-Deberta-Base-Sentiment'
34
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
35
+
36
+ bert_model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME, num_labels = 3).to(device)
37
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
38
+
39
+ get_sentiment("This is quite a mess you have made")
40
+
41
+ ```
42
+