Instructions to use Attahir/AfriSenti-MOE-Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Attahir/AfriSenti-MOE-Model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Attahir/AfriSenti-MOE-Model")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("Attahir/AfriSenti-MOE-Model") model = AutoModel.from_pretrained("Attahir/AfriSenti-MOE-Model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
AfriSenti-MOE-Lang
Language-Wise Mixture-of-Experts for African Sentiment Analysis
Overview
AfriSenti-MOE-Lang is a multilingual Language-Wise Mixture-of-Experts (LW-MoE) model developed for sentiment classification across 14 African languages using the AfriSenti dataset.
The model uses a shared multilingual encoder with independent language-specific classification experts.
Each input is routed to its corresponding language expert using its language identifier. This enables individual experts to specialize in sentiment classification for their assigned languages while sharing multilingual representations through the common encoder.
Dataset: AfriSenti
The model is developed using the AfriSenti multilingual sentiment analysis dataset.
The 14 languages covered in the experiments are:
| Code | Language |
|---|---|
| amh | Amharic |
| arq | Algerian Arabic |
| ary | Moroccan Arabic |
| hau | Hausa |
| ibo | Igbo |
| kin | Kinyarwanda |
| orm | Oromo |
| pcm | Nigerian Pidgin |
| por | Mozambican Portuguese |
| swa | Swahili |
| tir | Tigrinya |
| tso | Xitsonga |
| twi | Twi |
| yor | Yoruba |
Classification Task
Three-class sentiment classification:
- Positive
- Negative
- Neutral
Model Architecture
The model consists of:
Shared Multilingual Encoder: Extracts contextual representations from input text.
Language Identification: Identifies the language associated with each input.
Language-Wise Expert Router: Routes each input to its corresponding language expert.
Independent Classification Experts: Each language has a dedicated sentiment classification head.
Sentiment Prediction: Produces the final sentiment classification.
Experimental Results
Using AfroXLMR-Social on AfriSenti, Language-Wise MoE achieves the highest average Macro-F1 among the six evaluated configurations.
| Configuration | Macro-F1 (%) |
|---|---|
| Multilingual Fine-Tuning | 66.9 |
| Language-Wise MoE | 67.7 |
Key Result: LW-MoE achieves 67.7% average Macro-F1, an improvement of 0.8 percentage points over conventional multilingual fine-tuning.
This result represents the strongest configuration among the evaluated approaches for AfriSenti using AfroXLMR-Social.
Performance is encoder-dependent; the same advantage is not observed with AfriBERTa-large.
Evaluation
Macro-F1 is the primary evaluation metric because it gives equal importance to the sentiment classes.
The research uses PyTorch and Hugging Face Transformers with pretrained multilingual encoders.
Repository Contents
The repository contains:
- saved_moe_model/: Trained model checkpoint and supporting files.
- language_class_f1.csv: Language-level classification results.
- per_language_f1.csv: Per-language evaluation metrics.
The model checkpoint includes the shared encoder, language-specific expert heads, tokenizer configuration, and expert mapping files.
Intended Applications
- African multilingual sentiment analysis.
- Low-resource language NLP.
- Language-specific expert specialization.
- Multilingual text classification.
- Mixture-of-Experts research.
- African language technologies.
Research
"Language Family and Script as Routing Signals for African Multilingual Text Classification."- Submitted to TACL
The released checkpoint focuses specifically on the Language-Wise Mixture-of-Experts (LW-MoE) configuration evaluated on AfriSenti.
Acknowledgements
We acknowledge the AfriSenti dataset contributors and the African NLP research community for advancing multilingual language technologies.
- Downloads last month
- 31
Model tree for Attahir/AfriSenti-MOE-Model
Base model
Tadesse/AfroXLMR-Social