iabufarha/ar_sarcasm
Viewer • Updated • 10.5k • 510 • 18
How to use Mostafa911/egyptian-arabic-sentiment-marbertv2 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Mostafa911/egyptian-arabic-sentiment-marbertv2") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Mostafa911/egyptian-arabic-sentiment-marbertv2")
model = AutoModelForSequenceClassification.from_pretrained("Mostafa911/egyptian-arabic-sentiment-marbertv2", device_map="auto")Three-class sentiment classifier (negative / neutral / positive) for Egyptian-dialect tweets. It is UBC-NLP/MARBERTv2 fine-tuned on the Egyptian subset of ArSarcasm.
Live demo: https://huggingface.co/spaces/Mostafa911/egyptian-arabic-sentiment-demo
| Model | Macro F1 |
|---|---|
| TF-IDF + Logistic Regression baseline | 0.545 |
| This model (best of 3 seeds, picked on validation) | 0.737 |
| This model, mean +/- std over 3 seeds | 0.744 +/- 0.012 |
By subset (best model):
| Subset | Tweets | Baseline | This model |
|---|---|---|---|
| Non-sarcastic | 325 | 0.531 | 0.741 |
| Sarcastic | 154 | 0.342 | 0.471 |
Sarcastic tweets are about 88% negative in the training data, so the neutral and positive classes inside that subset are tiny and its macro F1 is noisy. Accuracy on the sarcastic subset was about 77%.
from transformers import pipeline
clf = pipeline("text-classification", model="Mostafa911/egyptian-arabic-sentiment-marbertv2")
print(clf("الخدمة وحشة جدا ومش هرجع تاني"))
Base model
UBC-NLP/MARBERTv2