Team Ai
Modelpublic

thejosango/nuha-ajp-binary

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes49downloads
Model Card

nuha-ajp-binary

Model Summary

nuha-ajp-binary is a binary Arabic text classifier that detects hate speech in Jordanian social media comments. It fine-tunes `nuha-ajp-mlm` — a domain-adapted Arabic BERT — and outputs one of two labels:

LabelMeaning
non-hate-speechNot Online Violence
hate-speechOffensive Language or Online Gender Based Violence

This model was developed as part of a pilot proof-of-concept for the NUHA project by the Jordan Open Source Association (JOSA). Performance metrics reflect the complexity of hate speech detection in colloquial Arabic and the exploratory nature of this initial effort.

For a more granular three-class classifier, see `nuha-ajp-trinary`.

Uses

Direct Use

Classifying Arabic social media comments as hate speech or non-hate speech, particularly for Jordanian Arabic content from Facebook and X (Twitter).

python
from transformers import pipeline

classifier = pipeline(
    "text-classification",
    model="thejosango/nuha-ajp-binary",
    tokenizer="thejosango/nuha-ajp-binary",
)

result = classifier("أنتِ امرأة رائعة")
print(result)
# [{'label': 'non-hate-speech', 'score': ...}]

For batch inference:

python
comments = ["أنتِ امرأة رائعة", "اخرسي يا غبية"]
results = classifier(comments)
for comment, result in zip(comments, results):
    print(f"{result['label']} ({result['score']:.2f}): {comment}")

Out-of-Scope Use

  • —Other Arabic dialects: The model was trained primarily on Jordanian Arabic. Performance on Egyptian, Gulf, or Modern Standard Arabic is not validated.
  • —General hate speech: The model is specifically calibrated for online gender-based violence in a Jordanian context. It may not generalise to other forms of hate speech or other demographic targets.
  • —High-stakes automated decisions: Given the moderate performance (F1 ≈ 0.69) and pilot nature of this work, the model should not be used as a sole decision-maker in content moderation systems without human review.

Bias, Risks, and Limitations

  • —Pilot annotation quality: Training labels were produced in an exploratory annotation effort with variable inter-annotator agreement. The model inherits noise from that process.
  • —Class imbalance: The training data contains approximately 59% non-hate-speech and 41% hate-speech examples. Weighted loss was used during training to partially compensate.
  • —Colloquial Arabic only: The aggressive text cleaning (Arabic-only filtering) means the model has never seen URLs, numbers, punctuation, or Latin-script text. Inputs containing these will have them silently ignored by the preprocessing.
  • —Moderate performance: An F1 of 0.69 on the validation set reflects genuine difficulty of the task and the limitations of the pilot training data. Precision (0.65) is lower than recall (0.74), meaning the model tends toward false positives.

Training Details

Training Data

Fine-tuned on the binary configuration of `thejosango/nuha-ajp-dataset`, which maps:

  • —Not Online Violence → non-hate-speech
  • —Offensive Language → hate-speech
  • —Gender Based Violence → hate-speech

Preprocessing

At training and inference time, the following normalisation is applied to input text (in addition to the dataset-level Arabic-only filtering):

  1. 1.URLs replaced with [رابط] token
  2. 2.@mentions replaced with [مستخدم] token
  3. 3.Email addresses replaced with [بريد] token
  4. 4.Numbers removed
  5. 5.Punctuation removed
  6. 6.Arabic diacritics (harakat) removed
  7. 7.Whitespace normalised

Hyperparameters

ParameterValue
Base modelthejosango/nuha-ajp-mlm
Hidden layers4 (reduced from base's 12)
Classifier dropout0.50
Learning rate5e-5
LR scheduleLinear
Batch size64
Epochs5
Weight decay1e-3
Label smoothing0.1
Weighted lossYes (balanced class weights)
Data augmentationYes (contextual word substitution, ratio 0.75)
FrameworkTransformers 4.32.1, PyTorch 2.0.1

Evaluation Results

Evaluated on the validation split of thejosango/nuha-ajp-dataset (binary configuration):

MetricValue
F10.6879
Precision0.6464
Recall0.7351
Loss0.5743

This model was developed as part of an initial pilot study. Results should be interpreted accordingly.