CoolFace
Modelpublic

iMeshal/arabic-sentiment-classifier-marbert

sourceHugging Faceapache-2.0updated 11mo agoView on Hugging Face
0likes94downloads
Model Card

MARBERT Model for Arabic Sentiment Analysis (Positive/Negative)

This is a fine-tuned version of UBC-NLP/MARBERTv2 for Arabic Sentiment Analysis. The model is trained to classify Arabic text (specifically tweets) into two categories: Positive (`LABEL_1`) or Negative (`LABEL_0`).

๐Ÿš€ Live Demo

You can test the model live on the Hugging Face Space: [https://huggingface.co/spaces/iMeshal/arabic-sentiment-app](https://huggingface.co/spaces/iMeshal/arabic-sentiment-app)


๐Ÿ“Š Model Performance

The model was trained on 80% of the training data and validated on 20%. The final evaluation was performed on a separate, unseen test set.

Final Test Set Results (Accuracy: 94.40%)

MetricScore
Accuracy94.40%
F1 (Macro)94.40%
Precision (Macro)94.40%
Recall (Macro)94.40%
Loss0.1667

The model achieved its best validation accuracy of 93.4% at Epoch 2, and load_best_model_at_end was used.


๐Ÿ’ป Intended Use (How to use)

You can use this model directly with the transformers pipeline.

python
from transformers import pipeline

# Load the pipeline
pipe = pipeline(
    "sentiment-analysis", 
    model="iMeshal/arabic-sentiment-classifier-marbert"
)

# Test with new texts
texts = [
    "ู‡ุฐุง ุงู„ู…ู†ุชุฌ ุฑุงุฆุน ุฌุฏุงู‹ ุฃู†ุตุญ ุจู‡",
    "ุฃุณูˆุฃ ุฎุฏู…ุฉ ุนู…ู„ุงุก ุนู„ู‰ ุงู„ุฅุทู„ุงู‚",
    "ุงู„ุฌูˆ ุงู„ูŠูˆู… ุฌู…ูŠู„"
]

results = pipe(texts)
print(results)
# Output:
# [
#   {'label': 'LABEL_1', 'score': 0.99...}, # Positive
#   {'label': 'LABEL_0', 'score': 0.99...}, # Negative
#   {'label': 'LABEL_1', 'score': 0.98...}  # Positive
# ]

๐Ÿ“š Training Data

The model was trained on the [Arabic Sentiment Twitter Corpus](https://www.kaggle.com/datasets/mksaad/arabic-sentiment-twitter-corpus) dataset from Kaggle.

  • โ€”Preprocessing: Long/concatenated tweets (which appeared to be noise) were cleaned.
  • โ€”Training Set: ~24,163 samples.
  • โ€”Validation Set: ~6,041 samples.
  • โ€”Test Set: ~11,508 samples.
  • โ€”Balance: All datasets were perfectly balanced (approx. 50% Positive / 50% Negative).

โš™๏ธ Training Procedure

The model was trained using the transformers.Trainer class with the following key hyperparameters:

  • โ€”Framework: PyTorch
  • โ€”Base Model: UBC-NLP/MARBERTv2
  • โ€”Epochs: 3 (with Early Stopping)
  • โ€”Early Stopping: Patience set to 2 (training stopped at Epoch 3, but Epoch 2 was the best).
  • โ€”Batch Size: 16
  • โ€”Learning Rate: 2e-5
  • โ€”Tokenizer: AutoTokenizer (with padding="max_length", truncation=True, max_length=512)

๐Ÿ“ž Contact