Instructions to use Wailnsar4/hespress-arabic-hierarchical-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Wailnsar4/hespress-arabic-hierarchical-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Wailnsar4/hespress-arabic-hierarchical-classifier")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Wailnsar4/hespress-arabic-hierarchical-classifier") model = AutoModelForSequenceClassification.from_pretrained("Wailnsar4/hespress-arabic-hierarchical-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
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:
- Web scraping
- Data preprocessing
- Hierarchical classification
- Arabic NLP
- AraBERT fine-tuning
Author
Wail Ali (Wailnsar4)
- Downloads last month
- -