AmrMohamed21/arabert-fake-news
๐ต๏ธ 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
๐ Quick Start
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
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
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
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 scoreWhy 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)
โ ๏ธ 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
๐ Citation
If you use this model in your research or project, please cite:
@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.
- ๐ค HuggingFace: @AmrMohamed21
- ๐ GitHub: @Amr-Mo-ali
Made with โค๏ธ for Arabic NLP
