Cross-lingual fine-tuning of XLM-R for Hausa-English code-switched sentiment analysis (ACM TALLIP 2026)
# Cross-Lingual Fine-Tuning of XLM-R for Sentiment Analysis in Hausa-English Code-Switched Dialogues
Reference implementation for the ACM **TALLIP** article:
> **Cross-Lingual Fine-Tuning of XLM-R for Sentiment Analysis in Hausa-English Code-Switched Dialogues**
> Osei Wusu Brempong Jnr, Junaid Hussain Muzamal, Liu Zhaobin.
> *ACM Transactions on Asian and Low-Resource Language Information Processing (TALLIP)*, 2026.
> DOI: **10.1145/3830015**
This repository fine-tunes **XLM-R** for three-class sentiment classification
(negative / neutral / positive) on **Hausa-English-Pidgin code-switched**
social-media text. It implements a code-switch-aware pipeline with
back-translation + Ghanaian Pidgin injection, self-attention pooling, an
auxiliary token-level language-identification objective, adapter-based
parameter-efficient fine-tuning, a fairness-aware loss, a full evaluation
suite, and ONNX export for deployment.
> **License & intended use.** The **code** is released under
> **CC BY 4.0** and is intended
> for **non-commercial, academic research use**. © 2026 Copyright is held by
> the owner/author(s). The **datasets** this repo downloads (NaijaSenti /
> AfriSenti) are licensed **CC BY-NC-SA 4.0** (non-commercial). Please cite the
> ACM TALLIP article above and the dataset papers (see Citation).
---
## Table of contents
- Requirements & installation
- Datasets: where and how to download
- Preprocessing
- Quickstart (offline smoke run)
- Reproducing the paper
- Ablations, adapters & fairness
- Inference & deployment
- Repository layout
- How each paper component maps to code
- Testing
- Citation
- License
---
## Requirements & installation
- Python **3.9+**
- PyTorch **2.0+** (CPU is fine for the smoke run; a GPU is recommended for full training)
```bash
# 1. Clone
git clone
github.com
cd hausa-sentiment-xlmr
# 2. (Recommended) create a virtual environment
python -m venv .venv && source .venv/bin/activate # …