AraBERTv0.2 for Arabic Offensive Language Detection

This model is fine-tuned from AraBERTv0.2 for binary offensive-language detection in Arabic text.

The model was trained on an Arabic Offensive Language Superset compiled from nine publicly available dataset sources, including Hugging Face and research repositories. After cleaning and deduplication, the combined dataset contains 30,605 Arabic comments, covering offensive and non-offensive language.

Dataset

Split Not Offensive Offensive Total
Train 14,401 7,022 21,423
Validation 3,086 1,505 4,591
Test 3,087 1,504 4,591
Total 20,574 10,031 30,605

The dataset was divided using a stratified 70/15/15 split.

Evaluation Results

The model was evaluated on 4,591 held-out test samples.

Metric Score
Accuracy 86.67%
Macro-F1 84.87%
Weighted-F1 86.67%
Offensive Precision 79.65%
Offensive Recall 79.65%
Offensive F1 79.65%
Non-Offensive F1 90.09%

Training Configuration

The model was fine-tuned using Hugging Face Transformers with a learning rate of 2e-5, batch size of 16, maximum sequence length of 128, and up to 5 epochs. The best checkpoint was selected using validation macro-F1.

Usage

import torch
from transformers import pipeline
from arabert.preprocess import ArabertPreprocessor

model_id = "rafiulbiswas/arabertv02-arabic-offensive-detection"

preprocessor = ArabertPreprocessor(
    model_name="aubmindlab/bert-base-arabertv02",
    keep_emojis=True,
    apply_farasa_segmentation=False
)

classifier = pipeline(
    "text-classification",
    model=model_id,
    device=0 if torch.cuda.is_available() else -1
)

text = "أنت شخص غبي ولا تفهم شيئا"

result = classifier(
    preprocessor.preprocess(text),
    truncation=True,
    max_length=128
)

print(result)

Use the preprocessing shown above if it matches the saved checkpoint's training setup.

Limitations

Performance may vary across Arabic dialects, platforms, and linguistic contexts. The model may misclassify sarcasm, implicit insults, or context-dependent expressions. It is intended for research and human-assisted content moderation rather than fully automated moderation decisions.

Author

Md. Rafiul Biswas, PhD
Hamad Bin Khalifa University, Qatar

Hugging Face | Research Portfolio

Downloads last month
15
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for rafiulbiswas/arabertv02-arabic-offensive-detection

Finetuned
(4,053)
this model