Update README.md
Browse files
README.md
CHANGED
@@ -32,7 +32,7 @@ The *feel-it-italian-sentiment* model performs **sentiment analysis** on Italian
|
|
32 |
|
33 |
## Data
|
34 |
|
35 |
-
Our data has been collected by annotating tweets from a broad range of topics. In total, we have 2037 tweets annotated with an emotion label. More details can be found in our paper (
|
36 |
|
37 |
## Performance
|
38 |
|
@@ -48,29 +48,10 @@ The results show that training on FEEL-IT can provide better results on the SENT
|
|
48 |
## Usage
|
49 |
|
50 |
```python
|
51 |
-
import
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
# Load model and tokenizer
|
56 |
-
tokenizer = AutoTokenizer.from_pretrained("MilaNLProc/feel-it-italian-sentiment")
|
57 |
-
model = AutoModelForSequenceClassification.from_pretrained("MilaNLProc/feel-it-italian-sentiment")
|
58 |
-
|
59 |
-
sentence = 'Oggi sono proprio contento!'
|
60 |
-
inputs = tokenizer(sentence, return_tensors="pt")
|
61 |
-
|
62 |
-
# Call the model and get the logits
|
63 |
-
labels = torch.tensor([1]).unsqueeze(0) # Batch size 1
|
64 |
-
outputs = model(**inputs, labels=labels)
|
65 |
-
loss, logits = outputs[:2]
|
66 |
-
logits = logits.squeeze(0)
|
67 |
-
|
68 |
-
# Extract probabilities
|
69 |
-
proba = torch.nn.functional.softmax(logits, dim=0)
|
70 |
-
|
71 |
-
# Unpack the tensor to obtain negative and positive probabilities
|
72 |
-
negative, positive = proba
|
73 |
-
print(f"Probabilities: Negative {np.round(negative.item(),4)} - Positive {np.round(positive.item(),4)}")
|
74 |
```
|
75 |
|
76 |
## Citation
|
|
|
32 |
|
33 |
## Data
|
34 |
|
35 |
+
Our data has been collected by annotating tweets from a broad range of topics. In total, we have 2037 tweets annotated with an emotion label. More details can be found in our paper (https://aclanthology.org/2021.wassa-1.8/).
|
36 |
|
37 |
## Performance
|
38 |
|
|
|
48 |
## Usage
|
49 |
|
50 |
```python
|
51 |
+
from transformers import pipeline
|
52 |
+
classifier = pipeline("text-classification",model='MilaNLProc/feel-it-italian-sentiment',top_k=2)
|
53 |
+
prediction = classifier("Oggi sono proprio contento!", )
|
54 |
+
print(prediction)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
```
|
56 |
|
57 |
## Citation
|