Hespress Arabic Hierarchical Text Classifier

This model is a fine-tuned Arabic AraBERT model for hierarchical classification of Arabic news articles.

Model

The model is based on aubmindlab/bert-base-arabertv2.

The model was fine-tuned on Arabic articles collected from Hespress.

Dataset

After preprocessing and hierarchical classification:

  • Total articles: 70,782
  • Main categories: 16
  • Hierarchical labels: 148
  • Training samples: 56,625
  • Validation samples: 7,078
  • Test samples: 7,079

Hierarchical labels use the following format:

main_category__subcategory

Example:

اقتصاد__الاستثمار

Main Categories

  • اقتصاد
  • خارج الحدود
  • جهات
  • مجتمع
  • سياسة
  • رياضة
  • حوادث
  • فن وثقافة
  • منوعات
  • مغاربة العالم
  • بيئة وعلوم
  • 24 ساعة
  • مصدر مطلع
  • تمازيغت
  • عالم التقنية
  • سيارات

Training

  • Base model: AraBERT v2
  • Maximum sequence length: 512
  • Number of labels: 148
  • Learning rate: 2e-5
  • Effective batch size: 20
  • Epochs: 5
  • Weight decay: 0.01
  • FP16 mixed precision
  • Best checkpoint: checkpoint-13000

Usage

from transformers import AutoTokenizer, AutoModelForSequenceClassification

model_id = "Wailnsar4/hespress-arabic-hierarchical-classifier"

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

text = "شهدت أسعار النفط ارتفاعًا في الأسواق العالمية اليوم."

inputs = tokenizer(
    text,
    return_tensors='pt',
    truncation=True,
    max_length=512
)

outputs = model(**inputs)
prediction = outputs.logits.argmax(dim=-1).item()

print(model.config.id2label[prediction])

Intended Use

This model is intended for educational and research purposes, particularly for Arabic NLP and hierarchical text classification.

Limitations

The model was trained on articles collected from a specific Arabic news source. Its performance may vary when used with articles from other sources, writing styles, or domains.

The model should not be considered a general-purpose Arabic news classifier.

Project

This model was developed as part of an academic artificial intelligence project involving:

  1. Web scraping
  2. Data preprocessing
  3. Hierarchical classification
  4. Arabic NLP
  5. AraBERT fine-tuning

Author

Wail Ali (Wailnsar4)

Downloads last month
-
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support