CoolFace
Modelpublic

sabaridsnfuji/arabic-ai-text-detector

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes199downloads
Model Card

๐Ÿ” 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

MetricScoreDescription
๐ŸŽฏ Accuracy95.0%Overall classification accuracy
โš–๏ธ Precision95.0%Precision across both classes
๐ŸŽช Recall94.0%Recall across both classes
๐Ÿ† F1 Score94.0%Harmonic mean of precision and recall

Evaluated on a balanced validation set with equal human and AI-generated Arabic texts.

๐Ÿš€ Quick Start

Installation

bash
pip install transformers torch

Basic Usage

python
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

python
# 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

python
# 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

  1. 1.Step-by-step training: Model trained in small chunks (0.2 epochs each)
  2. 2.Frequent validation: Evaluation after each training chunk
  3. 3.Best model selection: Saved only when validation loss improved
  4. 4.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

ModelAccuracyNotes
This Model95.0%Step-by-step trained AraBERT
GPTZero62.7%On AIRABIC benchmark
Random Baseline50.0%Random classification

โš ๏ธ 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

python
# 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

python
news_text = '''
ุฃุนู„ู†ุช ูˆุฒุงุฑุฉ ุงู„ุชุนู„ูŠู… ุนู† ุฅุทู„ุงู‚ ุจุฑู†ุงู…ุฌ ุฌุฏูŠุฏ ู„ุชุทูˆูŠุฑ ุงู„ู…ู†ุงู‡ุฌ ุงู„ุฏุฑุงุณูŠุฉ 
ููŠ ุงู„ู…ุฑุญู„ุฉ ุงู„ุซุงู†ูˆูŠุฉุŒ ูˆุงู„ุฐูŠ ูŠู‡ุฏู ุฅู„ู‰ ุชุนุฒูŠุฒ ู…ู‡ุงุฑุงุช ุงู„ุทู„ุงุจ ููŠ ุงู„ุชููƒูŠุฑ 
ุงู„ู†ู‚ุฏูŠ ูˆุงู„ุฅุจุฏุงุน. ูˆูŠุฃุชูŠ ู‡ุฐุง ุงู„ุจุฑู†ุงู…ุฌ ุถู…ู† ุฑุคูŠุฉ 2030 ู„ุชุทูˆูŠุฑ ุงู„ุชุนู„ูŠู….
'''

result = classifier(news_text)
# Expected: HUMAN (news articles are typically human-written)

Example 2: AI-Generated Text Detection

python
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:

bibtex
@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