Skip to main content

Sentiment analysis

Last reviewed: 2026-07-07.

Sentiment analysis is the most-frequently requested African-language NLP task after machine translation — asked for by every civic-tech project, every social listening effort, every consumer feedback pipeline touching African markets. It is also the task where the community-lineage resources have unusually good coverage relative to the size of the ask. Read this page before scoping a new sentiment project so you do not end up re-annotating what AfriSenti or NaijaSenti already ship.

What already exists

Two community-curated corpora anchor African-language sentiment analysis. Everything else builds on or complements them.

Datasets — the core set

  • AfriSenti (Muhammad et al., 2023) — the reference sentiment corpus for African languages. Covers 14 languages (Amharic, Algerian Arabic/Darja, Hausa, Igbo, Kinyarwanda, Moroccan Arabic/Darija, Mozambican Portuguese, Nigerian Pidgin, Oromo, Swahili, Tigrinya, Twi, Xitsonga, Yoruba). Three-class annotation (positive, negative, neutral). Twitter/X-domain source with community-curated annotation and quality review. Data on the Hugging Face Hub and code and paper via the AfriSenti page.
  • NaijaSenti (Muhammad et al., 2022) — four Nigerian languages (Hausa, Igbo, Nigerian Pidgin, Yoruba) with sentiment and emotion annotation, again Twitter-derived. The precursor and complement to AfriSenti's Nigerian coverage; useful when a project wants the additional emotion labels beyond three-class sentiment.

Datasets — worth knowing about

  • SemEval-2023 Task 12 AfriSenti-SemEval — the shared-task version of AfriSenti, with published baseline results across the 14 languages and cross-lingual transfer tracks. Useful reference for expected out-of-the-box performance.
  • XED (Cross-lingual Emotion Detection) — a multilingual emotion dataset with limited African coverage; useful when the project needs emotion labels rather than sentiment polarity.
  • AfriMTEB (Uemura, Zhang, Adelani, EACL 2026) — the African-language extension of MTEB. 59 African languages / 14 tasks / 38 datasets, with 6 new datasets added covering hate speech, intent detection, and emotion classification. Not itself a sentiment-classification benchmark, but the emotion-classification surface is the closest adjacent-evaluation harness in 2026 for teams whose downstream deployment needs both sentiment and emotion signals; run your candidate encoder / embedder against it for the multi-task read on generalisation before locking in a single-task fine-tune.
  • Domain-specific sentiment work — smaller published corpora exist for domains (health, market feedback, election monitoring) in specific languages. Search recent AfricaNLP workshop proceedings before starting a domain-specific corpus from scratch.

Adjacent-but-distinct tasks — do not conflate the label sets

Three recent (SemEval-2026) shared tasks sit next to sentiment analysis in the labelling space and are increasingly asked for by downstream teams. Their label sets do not mean the same thing as AfriSenti's polarity, and using them interchangeably produces silently wrong models. Know which one your project actually needs.

  • POLAR (SemEval-2026 Task 9) (Naseem et al., 2026; task site: polar-semeval.github.io) — polarization detection across 22 languages including Amharic, Hausa, and Swahili. 110k+ annotated instances across news, Reddit, blogs, Bluesky, and regional forums. Three sub-tasks: detect polarization presence, identify polarization type, recognise polarization manifestation. This is not sentiment. Polarization is "sharp divisions or hostility between social, political, religious, ethnic, gender-based, or other identity groups" — a text can be simultaneously positive-in-sentiment and highly polarizing (a celebratory post about an in-group victory that dehumanises the out-group is a paradigm case). Macro-F1 evaluation. If your project is about civic-tech deployment, election monitoring, or content-moderation triage, this is likely the task you actually want, not sentiment.
  • DimABSA (SemEval-2026 Task 3, Track A) (Yu et al., 2026) — dimensional aspect-based sentiment analysis. Models sentiment as a valence–arousal regression rather than a three-way polarity classification, and combines it with aspect-triplet or -quadruplet extraction over public discourse (political, energy, climate issues). Three sub-tasks covering dimensional regression, triplet extraction, quadruplet extraction. Evaluated with continuous F1 (cF1). Not a strict African-language-first release, but co-organised by African-NLP researchers (Muhammad et al.) and the framework is directly applicable to African-language aspect sentiment where the three-way pos/neg/neutral of AfriSenti is too coarse. Use when you need sentiment toward specific aspects of an entity (e.g., a health service's cost vs. its friendliness) rather than a whole-document polarity.
  • DimStance (SemEval-2026 Task 3, Track B) — the stance-detection track of the same DimABSA effort, using the same valence–arousal regression frame for stance targets. Stance detection asks whether an author is in favour of, against, or neutral toward a specific claim or target, which is different from both sentiment (polarity toward whatever is discussed) and polarization (hostility between groups). Use when your evaluation target is a specific claim (e.g., "vaccine safety") and you need to know each post's stance toward it.

Editorial position on the four tasks. Sentiment answers "is this positive?"; aspect-based sentiment (DimABSA) answers "how does the author feel about this specific aspect of the thing?"; stance detection (DimStance) answers "is the author for or against this claim?"; polarization detection (POLAR) answers "is this text sowing division between groups?". They are complementary. A civic-tech deployment for election monitoring might legitimately need all four running in parallel on the same input stream.

Models — what has been trained on this data

  • AfroXLMR-large (Alabi et al., 2022) and its 76-language variant — the standard fine-tuning base for African-language classification tasks. Fine-tuned on AfriSenti for each covered language; several community releases on the Hub under Davlan/.
  • XLM-RoBERTa large (Conneau et al., 2020) — the general multilingual baseline. AfriSenti paper reports its scores alongside AfroXLMR for direct comparison.
  • AfriBERTa (Ogueji et al., 2021) — the African-language-pretrained encoder; a strong alternative to AfroXLMR for constrained-compute deployments.
  • AfriqueLLM (Yu et al. 2026) — decoder-only alternative to encoder-based classification for LLM-native prompt-based sentiment (with the caveat that generative LLMs for classification tasks are stronger on rare classes but noisier on high-frequency ones than task-specific fine-tuned encoders). Nine variants across Qwen / Gemma / Llama bases. Worth measuring against AfroXLMR fine-tuning when the deployment permits an LLM inference call.
  • Language-specific fine-tunes on the Hugging Face Hub under masakhane/ and Davlan/ — most AfriSenti-covered languages have a published fine-tune. Check the model card for the training split and expected metric before treating any single release as authoritative.

Editorial opinion. For a new project on a language covered by AfriSenti, the shortest path is: fine-tune AfroXLMR-large on the AfriSenti split for your language. That is the recipe the AfriSenti paper itself uses and the reported numbers are the honest floor. Deploy only after human-evaluating a random sample of outputs — automatic sentiment metrics on Twitter-domain data are notoriously optimistic about model quality.

Fork or start fresh?

Is your language covered by AfriSenti (14 languages) or NaijaSenti (4 Nigerian)?
├── Yes — is the source domain (Twitter/X) close enough to your target?
│ ├── Yes → Use AfriSenti/NaijaSenti. Fine-tune AfroXLMR-large.
│ │ Human-evaluate 200 random test outputs. Done.
│ └── No, domain mismatch (formal writing, market speech, health,
│ customer service) → Use AfriSenti's model as a starting point,
│ collect a 500-2000 example in-domain evaluation set FIRST,
│ and only if the transfer is inadequate collect a small
│ (2000-5000 example) in-domain training set for adaptive
│ fine-tuning.
└── No, your language is not covered.
├── Is it related to an AfriSenti-covered language? → Start with
│ cross-lingual transfer from the closest covered language.
│ See the [cross-language transfer](../cross-language-transfer/index.md)
│ chapter. Only then design a small validation corpus in your
│ target language.
└── Genuinely uncovered → Read the [long-tail language onboarding](../long-tail-language/index.md)
chapter first. Then chapters 3 and 4 (Annotation Design,
Data Quality). Start with a small (2000-5000 example)
pilot corpus following AfriSenti's annotation guidelines.

What it will actually cost you

Order-of-magnitude estimates drawn from the AfriSenti and NaijaSenti papers and the participatory workflow they used:

  • Fine-tuning AfroXLMR-large on AfriSenti for a covered language. One to two person-weeks, four to twelve GPU-hours on a T4 or better. Feasible on Colab free tier if chunked. Most of the effort is evaluation and human review, not training.
  • Extending AfriSenti with domain-specific data (health, market, customer service). Two to four months elapsed; two to five person-months of annotator work; one person-month of lead effort for guidelines and adjudication.
  • Building a new sentiment corpus for an uncovered language, aiming for 5-10k examples. Three to seven months elapsed; three to nine person-months of annotator work, plus one person-month of lead annotator effort for guidelines. Assumes participatory setup with two to four native-speaker annotators. Twitter-domain sourcing is cheapest; verified in-domain sourcing (transcribed voice notes, curated market speech) is 2-5x more expensive per example.
  • Achieving AfriSenti-comparable inter-annotator agreement on a new language. Budget one full round of annotator recalibration after the first 500 examples. AfriSenti's IAA was hard-won and is the reference for what is achievable.

Known limitations to watch for

  • Twitter is not your target domain. AfriSenti and NaijaSenti are Twitter-derived; models trained on them systematically over-fit to Twitter-style language (short, abbreviated, hashtag-carrying, code-switched). A model trained on AfriSenti and deployed on customer service transcripts, health surveys, or long-form comments will underperform. Always evaluate on your target domain before deployment.
  • Sentiment is culturally-specific. What reads as negative in one culture reads as neutral or even respectful in another. Direct criticism norms differ; irony conventions differ; indirect negative expression is common in many African-language contexts and is often mis-classified as neutral by cross-cultural annotators. Read AfriSenti's guidelines closely before writing your own.
  • Code-switching is the rule. Every AfriSenti-covered language shows heavy code-switching with English, French, or a regional lingua franca. Models must handle this as normal input, not as an edge case.
  • Neutral is the hardest class. Sarcasm, irony, indirect expression, mixed sentiment, and factual statements all cluster into "neutral" and lose distinguishability. Per-class F1 reporting (playbook policy — see core principles) is not optional; a headline macro-F1 hides catastrophic neutral-class recall.
  • Emotion is not sentiment. Three-class polarity (positive / negative / neutral) is the standard sentiment task; the multi-class emotion task (anger, joy, fear, sadness, surprise, disgust, love) is a distinct and harder problem. Use NaijaSenti or XED if you specifically need emotion labels. See also the emotion analysis chapter elsewhere in the playbook.
  • Hate speech and toxic content are separate tasks. Sentiment models detect polarity, not harm. Do not deploy a sentiment classifier as a content moderator. See the hate speech analysis chapter.
  • Cross-lingual sentiment transfer is unusually weak compared to structural tasks like NER. Sentiment expression relies on culture-specific vocabulary and idiom that transfer poorly even between related languages. Do not assume cross-lingual transfer will close a covered-language gap without measurement.

For fine-tuning an encoder model on a sentiment classification dataset, use the Hugging Face sequence-classification tutorial. It covers datasets loading, tokenisation, training loop, and evaluation with sklearn's classification_report (which the playbook's core principles require you to use for per-class reporting).

For sentiment specifically, the AfriSenti paper's companion GitHub repo has the annotation guidelines, the exact preprocessing, and reference fine-tuning scripts for each covered language. Follow it before writing your own.

Further reading

  • AfriSenti paper (Muhammad et al., 2023) — the reference community sentiment resource for African languages, with a substantial retrospective on annotation methodology and per-language IAA.
  • Alabi et al., 2022 — AfroXLMR — the base encoder that most current African-language classification fine-tunes start from.
  • POLAR paper (Naseem et al., 2026) — the SemEval-2026 Task 9 description of the 22-language polarization corpus and its label scheme; required reading before conflating polarization with sentiment or hate speech.
Additional references
Contributor
@abumafrim

Join the discussion

Spotted an error, have a question, or want to share what worked on a real project? Sign in with GitHub to add your voice — every thread lives in the open, powered by GitHub Discussions.

Loading discussion…

Thanks to our Contributors

The Playbook is built by a growing community of researchers, students, and language experts. If you've contributed code, content, or review — thank you.

SUPPORTED BY

Masakhane African Languages HubBayero University, KanoBahir Dar UniversityHausaNLPEthioNLP