# CSC5035Z Assignment 2 — Fine-Tuning Language Models on African Language NLP Tasks
**Course:** CSC5035Z Natural Language Processing, UCT 2026
**Student number:** JRVPRA001
**Language:** Yoruba (`yor`)
**Extension:** B — Vocabulary Adaptation
---
## Project Description
This project fine-tunes `jhu-clsp/mmBERT-small` (a compact multilingual BERT encoder) on two Yoruba NLP tasks from the AfroBench benchmark:
1. **MasakhaNews** — news topic classification (9 categories, metric: macro-F1)
2. **MasakhaNER 2.0** — named entity recognition (PER, ORG, LOC, DATE, metric: seqeval span-F1)
**Extension B (Vocabulary Adaptation):** The mmBERT-small tokeniser is extended with ~1,000 Yoruba-specific BPE tokens, each initialised as the mean of its constituent subword embeddings from the original model. Both tasks are then re-fine-tuned on this extended model to measure the impact on tokeniser fertility and downstream performance.
---
## Quickest Path — Inspect Pre-computed Results (No Training Required)
All result files are included in the submission. To view tables and figures without running any training:
**Option A — Jupyter (local):**
```bash
# 1. Create and activate a virtual environment
python -m venv venv
# Windows:
venv\Scripts\activate
# macOS / Linux:
source venv/bin/activate
# 2. Install dependencies
pip install -r requirements.txt
pip install jupyter
# 3. Launch Jupyter and open the results notebook
jupyter notebook notebooks/results_analysis.ipynb
```
Then run all cells (Kernel → Restart & Run All).
**Option B — VS Code:**
Open the project folder in VS Code, select the Python interpreter from your virtual environment, then open `notebooks/results_analysis.ipynb` and click **Run All**.
**Option C — Google Colab:**
Upload `notebooks/results_analysis.ipynb` to Colab and upload the `results/` folder to your Drive at `MyDrive/csc5035z-a2/results/`. Run all cells.
---
## Full Pipeline — Reproduce Training from Scratch
Requires a GPU (tested on NVIDIA T4). …