Group 23- Detecting machine generated content in low resource African languages
Human vs Machine Text Detector
For South African Civic/Government Text in Low-Resource Languages
This Streamlit application leverages an ensemble of two fine-tuned transformer models—AfriBERTa and XLM-RoBERTa—to classify whether a given sentence in a civic or governmental context is human-written or machine-generated. The tool is designed to support four low-resource South African languages:
Xhosa (xho)
Tsonga (tso)
Tshivenda (ven)
Northern Sotho (nso)
Features
Ensemble Predictions: Combines outputs from AfriBERTa and XLM-RoBERTa for robust classification.
LIME Explanations: Provides transparent, word-level insights into model predictions.
Multi-Language Support: Handles four low-resource South African languages.
Custom UI: Features a sleek, dark-themed interface for enhanced user experience.
Offline Capability: Models are loaded from local directories, ensuring no internet dependency.
Robust Error Handling: Gracefully manages issues during model loading and inference.
Folder Structure
project-root/
│
├── app.py # Streamlit demo interface
├── model_utils.py # Shared ensemble prediction functions
├── evaluate_model.py # Evaluation pipeline for metrics and robustness
├── requirements.txt # Project dependencies
├── afriberta_dir/ # Fine-tuned AfriBERTa model directory
├── xlmr_dir/ # Fine-tuned XLM-RoBERTa model directory
└── final_dataset2.csv # Cleaned dataset for evaluation
Each model directory (afriberta_dir/ and xlmr_dir/) must contain:
config.json
pytorch_model.bin or model.safetensors
tokenizer_config.json, tokenizer.json
Additional tokenizer files: vocab.txt, special_tokens_map.json, etc.
Installation
Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies:
pip install -r requirements.txt
Running the App
Start the Streamlit app: streamlit run app.py
Open your browser and navigate to …