Exploring Semantic Relatedness in African Languages using Transfer Learning and Data Augmentation
# COS760 Group 20 - Cross-lingual Semantic Relatedness for African Languages
This project investigates whether NLP models can transfer knowledge about semantic relatedness across African languages, with a focus on Bantu language families and South African languages.
## Research Question
Do African languages from the same family share enough structure to transfer semantic relatedness knowledge between them?
We fine-tune AfroXLMR and XLM-R on Kinyarwanda relatedness data and test zero-shot transfer to Hausa and Amharic, then evaluate how well the models cluster South African Bantu languages they have never seen with relatedness labels.
## How to Run
The script `src/complete_notebook.py` runs the full pipeline and works on both Google Colab and a local machine, no changes needed either way. It auto-detects its environment and handles paths and login accordingly.
---
### Option A: Google Colab (recommended, free GPU)
**Step 1: Get the file**
Go to the GitHub repo, click on `src/complete_notebook.py`, then click the download icon (or right-click Raw → Save As) to download the file.
**Step 2: Open Google Colab and upload the file**
Go to colab.research.google.com and open a new notebook. In the left sidebar, click the **folder icon** to open the Files panel, then click the **upload icon** and upload `complete_notebook.py`.
**Step 3: Enable GPU**
```
Runtime > Change runtime type > T4 GPU → Save
```
**Step 4: Set up your Hugging Face token**
Create a free account at
huggingface.co and get a read token at
huggingface.co.
In Colab, click the **key icon** in the left sidebar, then:
- Click **Add new secret**
- Name: `HF_TOKEN`
- Value: paste your token
- Toggle **Notebook access ON**
**Step 5: Run**
Because the script runs as a subprocess, Colab Secrets aren't directly accessible inside it. First run this in a cell to export the token so the subprocess can see it:
```python
import os
from google.colab import userdata
os.envi …