Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -1,3 +1,64 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- sentiment-analysis
|
5 |
+
- roberta
|
6 |
+
- twitter
|
7 |
+
- huggingface
|
8 |
+
- sentiment140
|
9 |
+
datasets:
|
10 |
+
- sentiment140
|
11 |
+
model_name: cardiffnlp/twitter-roberta-base-sentiment-latest
|
12 |
+
task: text-classification
|
13 |
+
license: apache-2.0
|
14 |
+
---
|
15 |
+
|
16 |
+
# Twitter-RoBERTa Sentiment140 Fine-tuned
|
17 |
+
|
18 |
+
Questo modello è una versione fine-tuned di `cardiffnlp/twitter-roberta-base-sentiment-latest` sul dataset Sentiment140, ottimizzato per l'analisi del sentiment di tweet in italiano e inglese. Il modello classifica i testi in tre categorie: negativo, neutro, positivo.
|
19 |
+
|
20 |
+
## Caratteristiche tecniche
|
21 |
+
- **Base model:** cardiffnlp/twitter-roberta-base-sentiment-latest
|
22 |
+
- **Dataset:** Sentiment140 (5000 esempi train, 500 validazione, 5000 test)
|
23 |
+
- **Task:** Sentiment Analysis (3 classi: negativo, neutro, positivo)
|
24 |
+
- **Tokenizzazione:** max_length=128, padding='max_length', truncation=True
|
25 |
+
- **Batch size:** 16
|
26 |
+
- **Epochs:** 3
|
27 |
+
- **Learning rate:** 2e-5
|
28 |
+
- **Weight decay:** 0.01
|
29 |
+
|
30 |
+
## Come usare il modello
|
31 |
+
|
32 |
+
```python
|
33 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
34 |
+
import torch
|
35 |
+
|
36 |
+
tokenizer = AutoTokenizer.from_pretrained("<MODEL_DIR>")
|
37 |
+
model = AutoModelForSequenceClassification.from_pretrained("<MODEL_DIR>")
|
38 |
+
|
39 |
+
text = "Questo è un tweet fantastico!"
|
40 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="max_length", max_length=128)
|
41 |
+
with torch.no_grad():
|
42 |
+
logits = model(**inputs).logits
|
43 |
+
predicted_class = logits.argmax(-1).item()
|
44 |
+
|
45 |
+
# Mappatura delle classi:
|
46 |
+
# 0 = Negativo, 1 = Neutro, 2 = Positivo
|
47 |
+
print(f"Sentiment: {predicted_class}")
|
48 |
+
```
|
49 |
+
Sostituisci `<MODEL_DIR>` con il percorso della cartella del modello salvato (es. `./results/hf_model`).
|
50 |
+
|
51 |
+
## Dataset
|
52 |
+
Il dataset Sentiment140 contiene tweet etichettati come negativo (0), neutro (2), positivo (4). Le etichette sono state rimappate come segue:
|
53 |
+
- 0 → 0 (Negativo)
|
54 |
+
- 2 → 1 (Neutro)
|
55 |
+
- 4 → 2 (Positivo)
|
56 |
+
|
57 |
+
## Addestramento
|
58 |
+
L'addestramento è stato effettuato con HuggingFace Transformers Trainer, utilizzando una suddivisione 90/10 per train/validation e limitando la dimensione dei dati per rapidità di test.
|
59 |
+
|
60 |
+
## Licenza
|
61 |
+
Apache 2.0
|
62 |
+
|
63 |
+
## Autore
|
64 |
+
Machine Innovators (proai-machineinnovators)
|