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_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

  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_classify-0.0.1.tar.gz (7.3 kB view details)

Uploaded Source

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

Hashes for zuba_classify-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5c65a063e0971da60c364f642eea2797b711cef35f76f244157d4eb79e010ceb
MD5 e2d04fc6876da7d870a292171a0a4f97
BLAKE2b-256 26df0a8559c9d26549ff9825e37496db94db6d916c78f39dfbca002448d1eb94

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