CoolFace
Modelpublic

AmrMohamed21/arabert-fake-news

sourceHugging Faceapache-2.0updated 4mo agoView on Hugging Face
0likes12downloads
Model Card

๐Ÿ•ต๏ธ Arabic News Credibility Analyzer

<p align="center"> <img src="https://img.shields.io/badge/Language-Arabic-green?style=for-the-badge&logo=language" /> <img src="https://img.shields.io/badge/Model-AraBERTv2-blue?style=for-the-badge&logo=huggingface" /> <img src="https://img.shields.io/badge/Accuracy-98.8%25-brightgreen?style=for-the-badge" /> <img src="https://img.shields.io/badge/Task-TextClassification-orange?style=for-the-badge" /> </p>

A fine-tuned AraBERT v2 model for detecting fake news and credibility classification in Arabic text. Trained on 6,267 Arabic news articles, achieving 98.8% accuracy on the test set.


๐Ÿ“‹ Model Details

PropertyDetails
Base Modelaubmindlab/bert-base-arabertv02
TaskBinary Text Classification (Real vs Fake)
LanguageArabic (Modern Standard + Dialectal)
Training Samples6,267 Arabic news articles
Test Accuracy98.8%
FrameworkPyTorch + HuggingFace Transformers

๐Ÿš€ Quick Start

python
from transformers import pipeline

# Load model directly
classifier = pipeline(
    "text-classification",
    model="AmrMohamed21/arabert-fake-news"
)

text = "ุฃุนู„ู†ุช ุงู„ุญูƒูˆู…ุฉ ุงู„ูŠูˆู… ุนู† ุฎุทุฉ ุงู‚ุชุตุงุฏูŠุฉ ุฌุฏูŠุฏุฉ ู„ุฏุนู… ุงู„ู‚ุทุงุน ุงู„ุตู†ุงุนูŠ"
result = classifier(text)
print(result)
# [{'label': 'REAL', 'score': 0.997}]

๐Ÿ”ง Load Model Manually

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model_name = "AmrMohamed21/arabert-fake-news"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

def predict(text: str) -> dict:
    inputs = tokenizer(
        text,
        return_tensors="pt",
        truncation=True,
        max_length=512,
        padding=True
    )
    
    with torch.no_grad():
        outputs = model(**inputs)
        probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
    
    labels = ["FAKE", "REAL"]
    predicted_class = probabilities.argmax().item()
    
    return {
        "label": labels[predicted_class],
        "confidence": probabilities[0][predicted_class].item()
    }

# Example
text = "ู…ุตุฏุฑ ู…ุฌู‡ูˆู„ ูŠุฏุนูŠ ุณู‚ูˆุท ุงู„ุญูƒูˆู…ุฉ ุบุฏุงู‹ ุจุดูƒู„ ู…ูุงุฌุฆ"
print(predict(text))

๐Ÿ“Š Training & Evaluation

Training Configuration

python
training_args = TrainingArguments(
    output_dir="./arabert-fake-news",
    num_train_epochs=5,
    per_device_train_batch_size=16,
    per_device_eval_batch_size=16,
    learning_rate=2e-5,          # Carefully tuned to avoid catastrophic forgetting
    warmup_steps=500,
    weight_decay=0.01,
    evaluation_strategy="epoch",
    save_strategy="epoch",
    load_best_model_at_end=True,
)

Results

MetricScore
Accuracy98.8%
F1 Score98.7%
Precision98.9%
Recall98.6%

Confusion Matrix Highlights

  • โ€”โœ… Very low false positive rate (misclassifying real news as fake)
  • โ€”โœ… Strong performance on both Modern Standard Arabic and news-style text

๐Ÿ—๏ธ Architecture

Input Text (Arabic)
       โ†“
[AraBERT v2 Tokenizer]   โ† Handles Arabic morphology
       โ†“
[BERT Encoder ร— 12]      โ† Pre-trained Arabic language understanding
       โ†“
[CLS Token Representation]
       โ†“
[Dropout(0.1)]
       โ†“
[Linear(768 โ†’ 2)]        โ† Classification head
       โ†“
[Softmax]
       โ†“
Output: REAL / FAKE + confidence score

Why AraBERT v2?

  • โ€”Pre-trained specifically on Arabic text (24GB Arabic corpus)
  • โ€”Handles Arabic morphological complexity (root-based structure)
  • โ€”Understands Arabic news-specific vocabulary

๐Ÿ“ Dataset

The model was trained on 6,267 Arabic news articles collected from:

  • โ€”Arabic news websites (real articles)
  • โ€”Known disinformation sources (fake articles)
SplitSamples
Train~5,013 (80%)
Validation~627 (10%)
Test~627 (10%)
โš ๏ธ Note: Dataset contains Arabic news text from various domains including politics, economy, and social news.

โš ๏ธ Limitations & Bias

  • โ€”Trained primarily on Modern Standard Arabic โ€” may show reduced accuracy on heavy dialects
  • โ€”Performance may vary on domain-specific content (medical, legal, etc.)
  • โ€”News landscape evolves โ€” model reflects training data from its collection period
  • โ€”Should not be used as the sole decision-maker for content moderation

๐Ÿ”— Related Links

ResourceLink
๐Ÿ™ GitHub RepositoryArabic-News-Credibility-Analyzer
๐Ÿ‘ค HuggingFace Profile@AmrMohamed21
๐Ÿ“ฆ Base Modelaubmindlab/bert-base-arabertv02

๐Ÿ“„ Citation

If you use this model in your research or project, please cite:

bibtex
@misc{amrmohamed21-arabert-fake-news-2024,
  author       = {Amr Mohamed},
  title        = {Arabic News Credibility Analyzer: Fine-tuned AraBERT v2 for Fake News Detection},
  year         = {2024},
  publisher    = {HuggingFace},
  journal      = {HuggingFace Model Hub},
  howpublished = {\url{https://huggingface.co/AmrMohamed21/arabert-fake-news}}
}

๐Ÿ‘จโ€๐Ÿ’ป About the Author

Built by Amr Mohamed โ€” ML/AI Engineer specializing in Arabic NLP and production-grade AI systems.


Made with โค๏ธ for Arabic NLP