A lightweight Nigerian language classifier.
Project description
🇳🇬 Zuba Language Classifier
Zuba Language Classifier is a lightweight Python package for classifying text into four major Nigerian languages:
- Hausa
- Yoruba
- Igbo
- Broken English (Pidgin)
The model is built using a fine-tuned GPT-2 architecture and loads automatically from the HuggingFace Hub, so you do not need to download or bundle any model files manually.
The package supports both single-sentence and batch predictions.
Features
- Predicts four Nigerian languages
- Works with single strings or lists
- Auto-downloads model from HuggingFace Hub
- Fast inference and minimal dependencies
📥 Installation
Install the package from PyPI:
pip install zuba-language-classifier
Install PyTorch if you do not already have it:
pip install torch
🧠 Model Setup
The classifier automatically downloads the trained GPT-2 model from the HuggingFace Hub the first time you use it.
No manual setup is required.
You may also use a custom model if your architecture differs.
🚀 Quick Start
from Zuba.Prediction import Classify
Classifier = Classify()
classifier=Classify()
result=classifier.predict([
"Ina jin dadin wannan rana.",
"Mo fẹ jẹ iyan.",
"A na m aga ahịa echi."
])
print(result)
Output:
["hausa", "yoruba", "igbo"]
⚙️ How It Works
- Your model class is loaded by the
Classifyconstructor. - The package downloads the trained weights from HuggingFace automatically.
- Text is tokenized with GPT-2 tokenizer (tiktoken).
- Input is encoded, padded, and truncated to the required sequence length.
- The model performs inference and outputs one of the four language labels.
classifier.py
Handles tokenization, preprocessing, batching, and predictions.
model_loader.py
Downloads and loads the trained model weights from HuggingFace.
🔧 Configuration
Tokenization Length
The default maximum token length is:
277
🔗 Important Constants
REPO_ID = "your-username/your-repo-name"
PACKAGE_LINK = "PYPI_link"
📜 License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zuba-0.0.2.tar.gz.
File metadata
- Download URL: zuba-0.0.2.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cca91042b15ac29d15bfbd847f233b3d9593ec82734b4f8e7f2f34a292e1fbc
|
|
| MD5 |
e1b9d5965fd6aaa70a5d7f82b8f45176
|
|
| BLAKE2b-256 |
8b5b971f76e564f9ccb5d783c2ed4d42a20fca98498ce2befdefbbc8a9fa98c5
|
File details
Details for the file zuba-0.0.2-py3-none-any.whl.
File metadata
- Download URL: zuba-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fa7f48d2278b2f68f7ed932159d9a927bfadb3ca7785e4b49fb2a36e5712283
|
|
| MD5 |
95ab2416999749b312173c8b451f07d4
|
|
| BLAKE2b-256 |
9ab9f0c75d737f490642100580ae45414df8b3f77b37bdf73b5254102785d664
|