Manauu17 commited on
Commit
b797d00
·
1 Parent(s): 038b556

Initial commit

Browse files
Files changed (1) hide show
  1. README.md +55 -0
README.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # roberta_sentiments_es_en , A Sentiment Analysis model for Spanish sentences
2
+
3
+ This is a roBERTa-base model trained on ~58M tweets and finetuned for sentiment analysis. This model currently supports Spanish sentences
4
+
5
+ This is a enhanced version of 'Manauu17/roberta_sentiments_es' following the BERT's SOAT to acquire best results. The last 4 hidden layers were concatenated folowing dense layers to get classification results.
6
+
7
+ ## Example of classification
8
+
9
+ ```python
10
+ from transformers import AutoModelForSequenceClassification
11
+ from transformers import AutoTokenizer
12
+ import numpy as np
13
+ import pandas as pd
14
+ from scipy.special import softmax
15
+
16
+ MODEL = 'Manauu17/enhanced_roberta_sentiments_es'
17
+
18
+ tokenizer = AutoTokenizer.from_pretrained(MODEL)
19
+
20
+ # PyTorch
21
+ model = AutoModelForSequenceClassification.from_pretrained(MODEL)
22
+
23
+ text = ['@usuario siempre es bueno la opinión de un playo',
24
+ 'Bendito año el que me espera']
25
+
26
+ encoded_input = tokenizer(text, return_tensors='pt', padding=True, truncation=True)
27
+ output = model(**encoded_input)
28
+ scores = output[0].detach().numpy()
29
+
30
+ labels_dict = model.config.id2label
31
+
32
+ # Results
33
+ def get_scores(model_output, labels_dict):
34
+ scores = softmax(model_output)
35
+ frame = pd.DataFrame(scores, columns=model.config.id2label.values())
36
+ frame.style.highlight_max(axis=1,color="green")
37
+ return frame
38
+
39
+
40
+ # PyTorch
41
+ get_scores(scores, labels_dict).style.highlight_max(axis=1, color="green")
42
+
43
+
44
+ ```
45
+ Output:
46
+
47
+ ```
48
+ # PyTorch
49
+ get_scores(scores, labels_dict).style.highlight_max(axis=1, color="green")
50
+
51
+ Negative Neutral Positive
52
+ 0 0.000607 0.004851 0.906596
53
+ 1 0.079812 0.006650 0.001484
54
+
55
+ ```