Skip to main content

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

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

  1. Your model class is loaded by the Classify constructor.
  2. The package downloads the trained weights from HuggingFace automatically.
  3. Text is tokenized with GPT-2 tokenizer (tiktoken).
  4. Input is encoded, padded, and truncated to the required sequence length.
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zuba-0.0.3.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zuba-0.0.3-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file zuba-0.0.3.tar.gz.

File metadata

  • Download URL: zuba-0.0.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for zuba-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0d1f0a473d78012c2c6fca9c06d8c2ac3d9a78269797e98d288d13253cd12ba0
MD5 72f2ade3f522b15877c725ba41a692a5
BLAKE2b-256 c5dcbe0f89cad367c52d8b18fce9a96fe4b509889c3bcfd9e477e112b5a9b56a

See more details on using hashes here.

File details

Details for the file zuba-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: zuba-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for zuba-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1bf4be0533610d1f32bedfcd06ed5e8a22dd62ebb8b98e8ae391955460c45ff7
MD5 1bfc7c2518bdc6a3dd081834ea6dd9c6
BLAKE2b-256 53f35f1a69723424bb4883195afcecb43b2f1bf50d10adf0ad5b3907c15435ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page