Instructions to use Attahir/AfribSenti with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Attahir/AfribSenti with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Attahir/AfribSenti")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Attahir/AfribSenti") model = AutoModelForSequenceClassification.from_pretrained("Attahir/AfribSenti", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- AfriSenti-AfriBERTa-Large-MFT
- Multilingual Fine-Tuning for African Language Sentiment Classification
- Overview
- Dataset: AfriSenti
- 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
- Multilingual Fine-Tuning for African Language Sentiment Classification
AfriSenti-AfriBERTa-Large-MFT
Multilingual Fine-Tuning for African Language Sentiment Classification
Overview
AfriSenti-AfriBERTa-Large-MFT is a multilingual sentiment classification model developed for African languages using the AfriSenti 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 sentiment classification across multiple African languages.
Unlike Mixture-of-Experts (MoE) architectures, this configuration does not employ separate language-specific or language-group-specific classification experts.
Instead, it uses shared multilingual representations and a common classification head to facilitate cross-lingual knowledge transfer.
The model is part of a comparative investigation of multilingual fine-tuning and expert-based language specialization for African multilingual text classification.
Dataset: AfriSenti
AfriSenti is a multilingual African sentiment classification benchmark containing 112,515 instances across 14 African languages.
The dataset supports research on sentiment classification in low-resource African languages.
The languages included in this experiment 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
The model performs multilingual sentiment classification as a multi-class text classification task.
The objective is to predict the sentiment category associated with an input text.
The sentiment categories are:
- Positive
- Negative
- Neutral
The model produces class probabilities and predicts the most likely sentiment category.
Macro-F1 is used as the primary evaluation metric to account for differences in class distributions.
Model Architecture
AfriSenti-AfriBERTa-Large-MFT uses a shared-encoder transformer-based classification architecture.
1. Pretrained Encoder
AfriBERTa-large serves as the shared multilingual encoder.
It extracts contextual representations from African language text and provides the representations used for downstream classification.
2. Multilingual Fine-Tuning
Training data from all 14 languages are merged into a unified multilingual training corpus.
The shared encoder is fine-tuned jointly using the combined multilingual data.
3. Shared Classification Head
A single classification head is attached to the shared encoder.
The pooled [CLS] representation is used for sentiment prediction.
4. Sentiment Prediction
The classification head produces logits for the sentiment categories.
Softmax is applied to obtain class probabilities for multi-class sentiment classification.
Multilingual Fine-Tuning (MFT)
Multilingual Fine-Tuning serves as the conventional parameter-sharing baseline in this research.
All supported languages contribute to the same training process.
The encoder and classification head are optimized jointly, allowing the model to learn shared 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
AfriSenti using AfriBERTa-large
The multilingual fine-tuning configuration achieves an average Macro-F1 of 61.4%.
The following table presents the reported per-language Macro-F1 results.
| Language | Macro-F1 (%) |
|---|---|
| Amharic | 60.3 |
| Algerian Arabic | 55.9 |
| Moroccan Arabic | 66.4 |
| Hausa | 78.6 |
| Igbo | 80.3 |
| Kinyarwanda | 61.3 |
| Oromo | 44.9 |
| Nigerian Pidgin | 60.6 |
| Mozambican Portuguese | 56.2 |
| Swahili | 48.8 |
| Tigrinya | 59.5 |
| Xitsonga | 58.5 |
| Twi | 52.8 |
| Yoruba | 75.4 |
| Average | 61.4 |
Key Findings
The experimental results demonstrate that:
AfriBERTa-large achieves an average Macro-F1 of 61.4% using multilingual fine-tuning.
Igbo achieves the highest per-language Macro-F1 of 80.3%.
Hausa achieves a Macro-F1 of 78.6%, followed by Yoruba at 75.4%.
Oromo and Swahili remain challenging, achieving 44.9% and 48.8%, respectively.
Multilingual fine-tuning outperforms all evaluated MoE configurations on AfriSenti when using AfriBERTa-large.
These findings highlight the effectiveness of shared multilingual parameter learning for African language sentiment classification.
Training and Evaluation
The experimental configuration follows the methodology described in the research.
| Parameter | Configuration |
|---|---|
| Dataset | AfriSenti |
| Encoder | AfriBERTa-large |
| Training approach | Full Multilingual Fine-Tuning |
| 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 metric | Macro-F1 |
Repository Contents
The repository contains the fine-tuned AfriBERTa-large model and its supporting tokenizer resources.
| File | Description |
|---|---|
| full_finetuned_model/config.json | Model configuration |
| full_finetuned_model/model.safetensors | Fine-tuned model weights |
| full_finetuned_model/sentencepiece.bpe.model | SentencePiece tokenizer model |
| full_finetuned_model/special_tokens_map.json | Special token configuration |
| full_finetuned_model/tokenizer_config.json | Tokenizer configuration |
Additional evaluation results and experiment outputs may be provided in the repository.
Intended Applications
AfriSenti-AfriBERTa-Large-MFT supports research and experimentation in:
- African multilingual sentiment analysis.
- Low-resource African language NLP.
- Cross-lingual sentiment classification.
- Multilingual transformer fine-tuning.
- African social media sentiment analysis.
- Multilingual text classification.
- Shared multilingual representation learning.
Research Contributions
This experiment investigates:
Full multilingual fine-tuning of AfriBERTa-large for African multilingual sentiment classification.
Joint representation learning across 14 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 characteristics.
The experimental results also indicate that the effectiveness of multilingual fine-tuning and expert specialization varies across pretrained encoders and classification tasks.
Future work 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 AfriSenti dataset should be cited in accordance with its original publication.
Acknowledgements
We acknowledge the AfriSenti dataset contributors, the AfriBERTa research community, and the African NLP research community for advancing multilingual African language technologies.
- Downloads last month
- 24
Model tree for Attahir/AfribSenti
Base model
castorini/afriberta_large