# MGT Detection for Bantu Languages - COS760 Group 45
> **Detecting Machine-Generated Text in low-resource Bantu languages (isiZulu, isiXhosa, Siswati) using a three-phase NLP pipeline: TF-IDF baseline → AfroXLM-R fine-tuning → SADiLaR morphological feature fusion.**
---
## Table of Contents
1. Project Description
2. Core Features
3. Tech Stack
4. Prerequisites
5. Google Drive Access
6. Installation
7. Environment Variables
8. Usage
9. Project Structure
---
## Project Description
This research project tackles the problem of **Machine-Generated Text (MGT) detection** in under-resourced Bantu languages, specifically **isiZulu**, **isiXhosa**, and **Siswati**. Given that modern large language models (LLMs) - including ChatGPT-4o, Claude, and Gemini 2.5 Pro - can now generate fluent text in these languages, the need for reliable automated detection is growing, particularly for academic integrity and media verification contexts.
The system is structured as a **three-phase pipeline**:
- **Phase 1 - Baseline:** A character n-gram TF-IDF + Logistic Regression classifier trained on isiZulu and isiXhosa, then evaluated zero-shot on Siswati.
- **Phase 2 - Transfer Learning:** Fine-tuning of `Davlan/afro-xlmr-base` (an XLM-RoBERTa variant pre-trained on African languages) on the same multilingual corpus, with Optuna hyperparameter search.
- **Phase 3 - Feature Fusion:** A Random Forest ensemble that combines the AfroXLM-R predicted probabilities with morphological features derived from the **SADiLaR** morphological resource (lexical diversity, morphological coverage, bigram repetition, etc.).
A **Streamlit web application** (`app.py`) exposes all three phases as an interactive demo, including SHAP-based explainability visualisations.
Human text is sourced from the **Vukuzenzele** government newsletter corpus (via Hugging Face's `dsfsi/vukuzenzele-monolingual` dataset). Machine-generated text was produced by prompting ChatGPT-4o, Claude, and Gemini 2.5 Pro, and is sto …