Instructions to use Attahir/AfribEMO-Multilingual with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Attahir/AfribEMO-Multilingual with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Attahir/AfribEMO-Multilingual")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Attahir/AfribEMO-Multilingual") model = AutoModelForSequenceClassification.from_pretrained("Attahir/AfribEMO-Multilingual", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- AfriEmo-AfriBERTa-Large-MFT
- Full Multilingual Fine-Tuning for African Language Emotion Classification
- Overview
- Dataset: AfriEmo
- Classification Task
- Model Architecture
- Multilingual Fine-Tuning (MFT)
- Experimental Results
- Training and Evaluation
- Repository Contents
- Intended Applications
- Research Contributions
- Limitations and Future Work
- Citation
- Acknowledgements
- Full Multilingual Fine-Tuning for African Language Emotion Classification
AfriEmo-AfriBERTa-Large-MFT
Full Multilingual Fine-Tuning for African Language Emotion Classification
Overview
AfriEmo-AfriBERTa-Large-MFT is a multilingual emotion classification model developed for 15 African languages using the AfriEmo dataset.
The model uses AfriBERTa-large as its pretrained multilingual encoder and employs Full Multilingual Fine-Tuning (MFT).
Training data from all supported languages are combined into a unified multilingual corpus. The shared pretrained encoder and a single classification head are jointly fine-tuned to perform emotion classification across multiple African languages.
The model learns shared multilingual representations across languages while maintaining a common classification framework.
Unlike Mixture-of-Experts (MoE) architectures, this configuration does not employ separate language-specific, language-family-specific, or language-script-specific classification heads.
Instead, all languages share the same encoder and classification head throughout training and evaluation.
This model is part of a comparative investigation of multilingual fine-tuning and expert-based language specialization for African multilingual text classification.
Dataset: AfriEmo
AfriEmo is a multilingual African emotion classification dataset containing 56,308 instances across 15 African languages.
The dataset supports research on emotion recognition and classification in African languages with diverse linguistic characteristics.
The languages included in this experiment are:
| Code | Language |
|---|---|
| amh | Amharic |
| ary | Moroccan Arabic |
| hau | Hausa |
| ibo | Igbo |
| kin | Kinyarwanda |
| orm | Oromo |
| pcm | Nigerian Pidgin |
| por | Mozambican Portuguese |
| som | Somali |
| swa | Swahili |
| tir | Tigrinya |
| vmw | Makhuwa |
| xho | Xhosa |
| yor | Yoruba |
| zul | Zulu |
Classification Task
AfriEmo is formulated as a multi-label emotion classification task involving six emotion categories.
The objective is to identify the emotion labels associated with an input text.
Unlike conventional single-label classification, multi-label classification allows an input text to be associated with multiple emotion categories.
The model uses sigmoid-based classification to produce emotion probabilities.
Macro-F1 is used as the primary evaluation metric, with macro-averaging across the emotion labels.
Model Architecture
AfriEmo-AfriBERTa-Large-MFT employs a standard shared-encoder multilingual transformer architecture.
1. Pretrained Multilingual Encoder
AfriBERTa-large serves as the shared pretrained multilingual encoder.
It extracts contextual representations from African language text and provides the representations used for emotion classification.
2. Multilingual Fine-Tuning
Training data from all 15 languages are merged into a unified multilingual training corpus.
The shared encoder is jointly fine-tuned using the combined multilingual dataset.
3. Shared Classification Head
A single classification head is attached to the shared encoder.
The classification head learns to identify the six emotion categories from the multilingual representations.
4. Multi-Label Emotion Prediction
The classification head produces logits for the six emotion categories.
Sigmoid activation is applied to obtain emotion probabilities, allowing multiple emotion labels to be predicted for an input.
Multilingual Fine-Tuning (MFT)
Multilingual Fine-Tuning serves as the conventional parameter-sharing approach in this research.
All supported languages contribute to the same training process.
The AfriBERTa-large encoder and the shared classification head are optimized jointly, allowing the model to learn representations across different African languages.
Unlike the five Mixture-of-Experts configurations investigated in the research, MFT uses a single classification head rather than independently parameterized expert heads.
This configuration provides a baseline for evaluating whether specialized expert routing offers advantages over conventional multilingual parameter sharing.
Experimental Results
AfriEmo using AfriBERTa-large
The multilingual fine-tuning configuration achieves an average Macro-F1 of 39.5%.
The following table presents the reported per-language Macro-F1 results.
| Language | Macro-F1 (%) |
|---|---|
| Amharic | 63.8 |
| Moroccan Arabic | 14.2 |
| Hausa | 69.0 |
| Igbo | 52.1 |
| Kinyarwanda | 44.6 |
| Oromo | 54.4 |
| Nigerian Pidgin | 49.7 |
| Mozambican Portuguese | 22.8 |
| Somali | 41.5 |
| Swahili | 26.0 |
| Tigrinya | 43.2 |
| Makhuwa | 20.2 |
| Xhosa | 32.0 |
| Yoruba | 32.9 |
| Zulu | 26.4 |
| Average | 39.5 |
Comparison with Other Configurations
The research evaluates six configurations using AfriBERTa-large on AfriEmo.
| Configuration | Average Macro-F1 (%) |
|---|---|
| Multilingual Fine-Tuning (MFT) | 39.5 |
| Language-Wise MoE (LW-MoE) | 34.1 |
| Language-Script MoE (LS-MoE) | 39.5 |
| Language-Family MoE (LF-MoE) | 37.3 |
| Family-Script MoE (FS-MoE) | 37.0 |
| Random-MoE | 36.7 |
Key Research Findings
The experimental results demonstrate that:
AfriBERTa-large achieves an average Macro-F1 of 39.5% using multilingual fine-tuning.
Multilingual fine-tuning matches Language-Script MoE, which also achieves 39.5%.
MFT outperforms Language-Wise MoE, Language-Family MoE, Family-Script MoE, and Random-MoE.
Amharic and Hausa achieve the strongest per-language Macro-F1 scores of 63.8% and 69.0%, respectively.
Performance varies considerably across the 15 African languages.
These findings highlight the effectiveness of shared multilingual parameter learning for African multilingual emotion classification.
They also demonstrate that expert specialization does not necessarily improve performance across all encoders and classification tasks.
Training and Evaluation
The experimental configuration follows the methodology described in the research paper.
| Parameter | Configuration |
|---|---|
| Dataset | AfriEmo |
| Dataset size | 56,308 instances |
| Number of languages | 15 |
| Encoder | AfriBERTa-large |
| Training approach | Full Multilingual Fine-Tuning |
| Architecture | Shared encoder and classification head |
| Task | Multi-label emotion classification |
| Number of emotion categories | 6 |
| Framework | PyTorch |
| NLP library | Hugging Face Transformers |
| Maximum sequence length | 256 tokens |
| Optimizer | AdamW |
| Learning rate | 1e-5 |
| Training epochs | 5 |
| Training batch size | 16 |
| Evaluation batch size | 32 |
| Random seed | 84 |
| Data split | 90% training / 10% testing |
| Primary evaluation metric | Macro-F1 |
Repository Contents
The repository contains the fine-tuned AfriBERTa-large model checkpoint and its supporting tokenizer resources.
The model files are organized as follows:
| File | Description |
|---|---|
| afriemo_results/afriberta_afriemo_mode/config.json | Model configuration |
| afriemo_results/afriberta_afriemo_mode/model.safetensors | Fine-tuned model weights |
| afriemo_results/afriberta_afriemo_mode/sentencepiece.bpe.model | SentencePiece tokenizer model |
| afriemo_results/afriberta_afriemo_mode/special_tokens_map.json | Special token configuration |
| afriemo_results/afriberta_afriemo_mode/tokenizer_config.json | Tokenizer configuration |
Intended Applications
AfriEmo-AfriBERTa-Large-MFT supports research and experimentation in:
- African multilingual emotion detection.
- Multi-label emotion classification.
- Low-resource African language NLP.
- Cross-lingual emotion classification.
- Multilingual transformer fine-tuning.
- African social media emotion analysis.
- Shared multilingual representation learning.
- African language technologies.
Research Contributions
This experiment investigates:
Full multilingual fine-tuning of AfriBERTa-large for African multilingual emotion classification.
Joint representation learning across 15 African languages.
Shared encoder and classification-head parameterization for multilingual learning.
Evaluation of conventional multilingual fine-tuning against five expert-routing configurations.
The effectiveness of multilingual parameter sharing for low-resource African languages.
Limitations and Future Work
Although multilingual fine-tuning facilitates cross-lingual knowledge transfer, shared parameters may not fully capture language-specific linguistic and cultural characteristics.
The experimental results also indicate that the effectiveness of multilingual fine-tuning and expert specialization varies across pretrained encoders and classification tasks.
Future research will investigate learned routing, language-family-based specialization, script-based expert grouping, random language grouping, and parameter-efficient fine-tuning.
Citation
"Language Family and Script as Routing Signals for African Multilingual Text Classification."- submitted to TACL
The AfriEmo dataset should be cited in accordance with its original publication.
Acknowledgements
We acknowledge the AfriEmo dataset contributors, the AfriBERTa research community, and the African NLP research community for advancing multilingual African language technologies.
- Downloads last month
- 20
Model tree for Attahir/AfribEMO-Multilingual
Base model
castorini/afriberta_large