Downloads · 30 days
10
5% of all-time downloads
AmrMohamed21/arabert-fake-news
arabert-fake-news is a text classification model from AmrMohamed21. 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.
<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" / <…
Downloads · 30 days
10
5% of all-time downloads
All-time downloads
183
Public
Parameters
135M
541 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors541 MB · 100%
From the Hugging Face model README
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.
| Property | Details |
|---|---|
| Base Model | aubmindlab/bert-base-arabertv02 |
| Task | Binary Text Classification (Real vs Fake) |
| Language | Arabic (Modern Standard + Dialectal) |
| Training Samples | 6,267 Arabic news articles |
| Test Accuracy | 98.8% |
| Framework | PyTorch + HuggingFace Transformers |
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}]
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_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,
)
| Metric | Score |
|---|---|
| Accuracy | 98.8% |
| F1 Score | 98.7% |
| Precision | 98.9% |
| Recall | 98.6% |
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?
The model was trained on 6,267 Arabic news articles collected from:
| Split | Samples |
|---|---|
| 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.
| Resource | Link |
|---|---|
| 🐙 GitHub Repository | Arabic-News-Credibility-Analyzer |
| 👤 HuggingFace Profile | @AmrMohamed21 |
| 📦 Base Model | aubmindlab/bert-base-arabertv02 |
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}}
}
Built by Amr Mohamed — ML/AI Engineer specializing in Arabic NLP and production-grade AI systems.
Made with ❤️ for Arabic NLP