julien-c HF staff commited on
Commit
59c671b
1 Parent(s): 71cfc50

Migrate model card from transformers-repo

Browse files

Read announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/unideeplearning/polibert_sa/README.md

Files changed (1) hide show
  1. README.md +53 -0
README.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: it
3
+ tags:
4
+ - sentiment
5
+ - Italian
6
+ license: MIT
7
+ widget:
8
+ - text: 'Giuseppe Rossi è un ottimo politico'
9
+ ---
10
+
11
+ # 🤗 + polibert_SA - POLItic BERT based Sentiment Analysis
12
+
13
+ ## Model description
14
+
15
+ This model performs sentiment analysis on Italian political twitter sentences. It was trained starting from an instance of "bert-base-italian-uncased-xxl" and fine-tuned on an Italian dataset of tweets. You can try it out at https://www.unideeplearning.com/twitter_sa/ (in italian!)
16
+
17
+ #### Hands-on
18
+
19
+ ```python
20
+ import torch
21
+ from torch import nn
22
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
23
+
24
+ tokenizer = AutoTokenizer.from_pretrained("unideeplearning/polibert_sa")
25
+ model = AutoModelForSequenceClassification.from_pretrained("unideeplearning/polibert_sa")
26
+
27
+
28
+
29
+
30
+ text = "Giuseppe Rossi è un pessimo politico"
31
+ input_ids = tokenizer.encode(text, add_special_tokens=True, return_tensors= 'pt')
32
+
33
+ logits, = model(input_ids)
34
+ logits = logits.squeeze(0)
35
+
36
+ prob = nn.functional.softmax(logits, dim=0)
37
+
38
+ # 0 Negative, 1 Neutral, 2 Positive
39
+ print(prob.argmax().tolist())
40
+ ```
41
+
42
+ #### Hyperparameters
43
+
44
+ - Optimizer: **AdamW** with learning rate of **2e-5**, epsilon of **1e-8**
45
+ - Max epochs: **2**
46
+ - Batch size: **16**
47
+
48
+ ## Acknowledgments
49
+
50
+ Thanks to the support from:
51
+ the [Hugging Face](https://huggingface.co/), https://www.unioneprofessionisti.com
52
+
53
+ https://www.unideeplearning.com/