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_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"]
Note:
on the first run of this code block the function will download the trainable weight hosted on hugging face so it might take long to execute on the first run
⚙️ 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
File details
Details for the file zuba_classify-0.0.1.tar.gz.
File metadata
- Download URL: zuba_classify-0.0.1.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c65a063e0971da60c364f642eea2797b711cef35f76f244157d4eb79e010ceb
|
|
| MD5 |
e2d04fc6876da7d870a292171a0a4f97
|
|
| BLAKE2b-256 |
26df0a8559c9d26549ff9825e37496db94db6d916c78f39dfbca002448d1eb94
|