sabaridsnfuji/arabic-ai-text-detector
๐ Arabic AI Text Detection Model
<div align="center"> <img src="https://img.shields.io/badge/Language-Arabic-green" alt="Arabic"> <img src="https://img.shields.io/badge/Task-Text%20Classification-blue" alt="Task"> <img src="https://img.shields.io/badge/Base%20Model-AraBERT--v2-orange" alt="Base Model"> <img src="https://img.shields.io/badge/Accuracy-95.0%25-brightgreen" alt="Accuracy"> </div>
๐ Model Description
Arabic AI vs Human Text Detection Model - Fine-tuned AraBERT
This model is specifically designed to detect AI-generated text in Arabic language. It's fine-tuned from aubmindlab/bert-base-arabertv2 and can distinguish between:
- ๐ง Human-written Arabic text (label: 0, "HUMAN")
- ๐ค AI-generated Arabic text (label: 1, "AI")
The model was trained using advanced validation techniques with early stopping to ensure optimal performance and prevent overfitting.
๐ฏ Intended Use
Primary Use Cases
- Content Verification: Verify authenticity of Arabic articles and posts
- Academic Integrity: Detect AI-generated essays and assignments
- Social Media Monitoring: Identify automated Arabic content
- Research: Benchmark for Arabic AI detection studies
- Content Moderation: Flag potentially AI-generated Arabic text
Supported Text Types
- ๐ฐ News Articles (Modern Standard Arabic)
- ๐ Essays and Academic Writing
- ๐ฌ Social Media Posts
- ๐ Blog Posts and Articles
- ๐๏ธ Formal and Semi-formal Arabic Text
๐ Performance Metrics
Evaluated on a balanced validation set with equal human and AI-generated Arabic texts.
๐ Quick Start
Installation
pip install transformers torchBasic Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
import torch
# Method 1: Using pipeline (Recommended)
classifier = pipeline(
"text-classification",
model="sabaridsnfuji/arabic-ai-text-detector",
tokenizer="sabaridsnfuji/arabic-ai-text-detector"
)
# Test with Arabic text
arabic_text = "ูุฐุง ู
ุซุงู ุนูู ูุต ุจุงููุบุฉ ุงูุนุฑุจูุฉ"
result = classifier(arabic_text)
print(f"Prediction: {result[0]['label']}")
print(f"Confidence: {result[0]['score']:.2%}")Advanced Usage
# Method 2: Manual prediction with probabilities
model_name = "sabaridsnfuji/arabic-ai-text-detector"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
def predict_arabic_text(text):
# Tokenize
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
max_length=512,
padding=True
)
# Predict
with torch.no_grad():
outputs = model(**inputs)
probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
# Get results
predicted_class = torch.argmax(probabilities, dim=1).item()
confidence = torch.max(probabilities, dim=1)[0].item()
labels = {0: "HUMAN", 1: "AI"}
return {
"prediction": labels[predicted_class],
"confidence": confidence,
"probabilities": {
"human": probabilities[0][0].item(),
"ai": probabilities[0][1].item()
}
}
# Example usage
text = "ุงููุต ุงูุนุฑุจู ุงูู
ุฑุงุฏ ุชุตูููู ููุง"
result = predict_arabic_text(text)
print(result)Batch Processing
# Process multiple texts efficiently
texts = [
"ุงููุต ุงูุฃูู ุจุงููุบุฉ ุงูุนุฑุจูุฉ",
"ุงููุต ุงูุซุงูู ููุชุตููู",
"ุงูู
ุฒูุฏ ู
ู ุงููุตูุต ุงูุนุฑุจูุฉ"
]
results = classifier(texts)
for text, result in zip(texts, results):
print(f"Text: {text[:50]}...")
print(f"Prediction: {result['label']} ({result['score']:.2%})")
print("-" * 50)๐๏ธ Model Architecture
AraBERT-v2 Base Architecture
โโโ ๐ฅ Input: Arabic text (max 512 tokens)
โโโ ๐ค Tokenizer: AraBERT Arabic tokenizer
โโโ ๐ง Encoder: 12-layer Transformer (110M parameters)
โโโ ๐ฏ Classifier: Linear layer (768 โ 2 classes)
โโโ ๐ค Output: [Human, AI] classification + probabilities๐ Training Details
Dataset
- Size: Custom Arabic AI/Human dataset (4,798 samples)
- Language: Arabic (Modern Standard Arabic + dialectal variations)
- Balance: 50% human-written, 50% AI-generated
- Sources: News articles, essays, social media, academic texts
- Split: 80% training, 20% validation
Training Configuration
- Base Model: aubmindlab/bert-base-arabertv2 (AraBERT-v2)
- Strategy: Step-by-step training with validation loss tracking
- Epochs: 3 with early stopping
- Batch Size: 8
- Learning Rate: 2e-05
- Max Sequence Length: 512 tokens
- Optimizer: AdamW with weight decay (0.01)
- Hardware: GPU training with mixed precision (FP16)
Training Process
- Step-by-step training: Model trained in small chunks (0.2 epochs each)
- Frequent validation: Evaluation after each training chunk
- Best model selection: Saved only when validation loss improved
- Early stopping: Prevented overfitting with patience mechanism
๐ Evaluation & Benchmarks
Test Performance
- Validation Accuracy: 95.0%
- Cross-domain Testing: Tested on various Arabic text sources
- Robustness: Evaluated on different writing styles and topics
Comparison with Baselines
โ ๏ธ Limitations & Considerations
Known Limitations
- Text Length: Optimized for texts up to 512 tokens
- Domain: Best performance on formal/semi-formal Arabic
- Dialects: Primarily trained on Modern Standard Arabic
- Temporal: Training data has a specific time cutoff
Potential Biases
- Source Bias: Training data may reflect specific domains
- Dialectal Bias: May perform differently on regional Arabic varieties
- AI Model Bias: Trained primarily on specific AI models' outputs
Recommendations
- Best for: News articles, essays, formal Arabic text
- Consider carefully for: Informal chat, poetry, technical jargon
- Combine with: Human review for critical applications
๐ ๏ธ Technical Specifications
Model Details
- Architecture: BERT-based binary classifier
- Parameters: ~110M total parameters
- Model Size: ~440MB
- Precision: FP16 optimized for inference
- Inference Speed: ~50ms per text (GPU), ~200ms (CPU)
Input/Output Specification
# Input
{
"text": "ุงููุต ุงูุนุฑุจู ุงูู
ุฑุงุฏ ุชุตูููู",
"max_length": 512
}
# Output
{
"label": "HUMAN" | "AI",
"score": 0.95, # Confidence score
"probabilities": {
"HUMAN": 0.95,
"AI": 0.05
}
}๐ฌ Usage Examples
Example 1: News Article Detection
news_text = '''
ุฃุนููุช ูุฒุงุฑุฉ ุงูุชุนููู
ุนู ุฅุทูุงู ุจุฑูุงู
ุฌ ุฌุฏูุฏ ูุชุทููุฑ ุงูู
ูุงูุฌ ุงูุฏุฑุงุณูุฉ
ูู ุงูู
ุฑุญูุฉ ุงูุซุงูููุฉุ ูุงูุฐู ููุฏู ุฅูู ุชุนุฒูุฒ ู
ูุงุฑุงุช ุงูุทูุงุจ ูู ุงูุชูููุฑ
ุงูููุฏู ูุงูุฅุจุฏุงุน. ููุฃุชู ูุฐุง ุงูุจุฑูุงู
ุฌ ุถู
ู ุฑุคูุฉ 2030 ูุชุทููุฑ ุงูุชุนููู
.
'''
result = classifier(news_text)
# Expected: HUMAN (news articles are typically human-written)Example 2: AI-Generated Text Detection
ai_text = '''
ูู ูุฐุง ุงูู
ูุงูุ ุณููุงูุด ู
ูุถูุน ุงูุชูููููุฌูุง. ุงูุชูููููุฌูุง ู
ูู
ุฉ ุฌุฏุงู ูู
ุญูุงุชูุง. ูุฌุจ ุฃู ูููู
ุงูุชูููููุฌูุง ุจุดูู ุตุญูุญ. ุงูุชูููููุฌูุง ุชุณุงุนุฏูุง ูุซูุฑุงู.
'''
result = classifier(ai_text)
# Expected: AI (repetitive patterns typical of AI generation)๐ Citation
If you use this model in your research or applications, please cite:
@misc{sabaridsnfuji-arabic-ai-detector-20250730,
title={Arabic AI Text Detection Model},
author={sabaridsnfuji},
year={2025},
publisher={Hugging Face},
journal={Hugging Face Model Hub},
howpublished={\url{https://huggingface.co/sabaridsnfuji/arabic-ai-text-detector}}
}๐ค Contributing & Feedback
- Model Issues: Please report issues in the discussions tab
- Improvements: Suggestions for model improvements are welcome
- Collaborations: Open to research collaborations in Arabic NLP
๐ License
This model is released under the Apache 2.0 license. You are free to:
- โ Use commercially
- โ Modify and distribute
- โ Use in research
- โ Include in applications
๐ Acknowledgments
- Base Model: aubmindlab/bert-base-arabertv2
- Framework: Hugging Face Transformers
- Infrastructure: Google Colab for training
- Community: Arabic NLP research community
๐ Contact
- ๐ค Hugging Face: sabaridsnfuji
- ๐ง Issues: Use the repository discussions for questions
- ๐ Model Page: https://huggingface.co/sabaridsnfuji/arabic-ai-text-detector
<div align="center"> <p><strong>๐ If this model helps your work, please give it a โญ star! ๐</strong></p> <p><em>Built with โค๏ธ for the Arabic NLP community</em></p> </div>
Last updated: 2025-07-30
