Downloads · 30 days
6
6% of all-time downloads
whrivt/camelbert-saudi-gmaps-sentiment
camelbert-saudi-gmaps-sentiment is a text classification model from whrivt. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
Fine-tuned Arabic BERT model for 3-class sentiment analysis on Saudi Google Maps reviews.
Downloads · 30 days
6
6% of all-time downloads
All-time downloads
106
Public
Parameters
109M
781 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors436 MB · 56%
From the Hugging Face model README
Fine-tuned Arabic BERT model for 3-class sentiment analysis on Saudi Google Maps reviews.
Classes: positive · negative · neutral
Base model: CAMeL-Lab/bert-base-arabic-camelbert-da-sentiment
Paper: Fine-Tuning CAMeL-BERT for Saudi Dialect Sentiment Analysis on Google Maps Reviews — Abdullah Mosfer, King Khalid University (2025)
| Metric | Original CAMeL-DA | Fine-tuned (ours) | Improvement |
|---|---|---|---|
| Accuracy | 69.92% | 75.07% | +5.15 pp ⬆ |
| F1-macro | 0.6690 | 0.7388 | +0.0698 ⬆ |
| F1-weighted | 0.6977 | 0.7567 | +0.0590 ⬆ |
| Class | Precision | Recall | F1-score | Support |
|---|---|---|---|---|
| positive | 0.8028 | 0.7972 | 0.8000 | 143 |
| negative | 0.8793 | 0.7183 | 0.7907 | 142 |
| neutral | 0.5495 | 0.7262 | 0.6256 | 84 |
| macro avg | 0.7439 | 0.7472 | 0.7388 | 369 |
| weighted avg | 0.7746 | 0.7507 | 0.7567 | 369 |
from transformers import pipeline
import re
clf = pipeline(
"text-classification",
model="whrivt/camelbert-saudi-gmaps-sentiment"
)
# IMPORTANT: always apply preprocessing before prediction
def clean_review(t):
import re
t = re.sub(r'<[^>]+>', ' ', t) # HTML tags
t = re.sub(r'https?://\S+|www\.\S+', ' ', t) # URLs
t = re.sub(r'@\w+', ' ', t) # mentions
t = re.sub(r'[إأآا]', 'ا', t) # alef normalization
t = re.sub(r'ى', 'ي', t) # ya normalization
t = re.sub(r'ة', 'ه', t) # ta-marbuta
t = re.sub(r'[\u0617-\u061A\u064B-\u0652\u0670\u0640]', '', t) # diacritics
t = re.sub(r'(.)\1{2,}', r'\1', t) # elongations
t = re.sub(r'\s+', ' ', t).strip()
return t
reviews = [
"المطعم رائع جدا والاكل لذيذ وننصح فيه",
"تجربه سيئه جدا الخدمه بطيئه ومافي نظافه",
"عادي مافي شي مميز بس مو سيي",
]
for review in reviews:
result = clf(clean_review(review))[0]
print(f"{review}")
print(f"→ {result['label']} (confidence: {result['score']:.2f})\n")
Output:
المطعم رائع جدا والاكل لذيذ وننصح فيه
→ positive (confidence: 0.94)
تجربه سيئه جدا الخدمه بطيئه ومافي نظافه
→ negative (confidence: 0.85)
عادي مافي شي مميز بس مو سيي
→ neutral (confidence: 0.61)
| ID | Label |
|---|---|
| 0 | positive |
| 1 | negative |
| 2 | neutral |
Stage 1 — Saudi-specific preprocessing: Arabic character normalization (alef variants, ya, ta-marbuta), diacritic removal, elongation collapse (راااائع → رائع), emoji-to-token conversion (😍 → "ايجابي", 😡 → "سلبي"), HTML and URL stripping.
Stage 2 — Automatic mislabel detection (5-fold cross-validation): Every training sample received an out-of-fold prediction from a model that never saw it during training. Samples where the model disagreed with the label at ≥ 0.95 confidence were removed. This identified 259 likely mislabeled rows (6.5%), with 63% from the neutral class. Removal was done using independent OOF predictions — not the fine-tuned model itself — to avoid circular bias.
Stage 3 — Anti-overfitting regularization: CAMeL-BERT has 110M parameters trained on only ~3,750 samples. To prevent memorization:
Stage 4 — Class-weighted training: Soft class weights (sqrt of inverse frequency): positive=0.914, negative=0.908, neutral=1.178. Applied via weighted cross-entropy loss.
Stage 5 — Multi-seed ensemble: Three models trained with seeds 42, 123, 7. Softmax outputs averaged at inference. Best single model (seed 42, val F1-macro=0.7087) saved for deployment.
| Parameter | Value |
|---|---|
| Base model | CAMeL-Lab/bert-base-arabic-camelbert-da-sentiment |
| Max sequence length | 192 tokens |
| Learning rate | 2e-5 |
| Batch size | 16 |
| Epochs | 3 + early stopping (patience=1) |
| Weight decay | 0.05 |
| Frozen layers | Embeddings + layers 0–5 |
| Hidden dropout | 0.2 |
| Classifier dropout | 0.3 |
| Label smoothing | 0.1 |
| Mixed precision | fp16 |
| Framework | Hugging Face Transformers 4.44.2 |
| GPU | NVIDIA Tesla T4 |
If you use this model, please cite:
@misc{mosfer2025camelbert,
title = {Fine-Tuning CAMeL-BERT for Saudi Dialect Sentiment Analysis on Google Maps Reviews},
author = {Mosfer, Abdullah},
year = {2025},
institution = {King Khalid University},
note = {Undergraduate Research Project. Model available at https://huggingface.co/whrivt/camelbert-saudi-gmaps-sentiment}
}