Skip to main content

Uni9ja Intent Classifier

A lightweight, high-performance Intent Classification library built on PyTorch and SpaCy. This library allows you to identify user intentions in text using word embeddings.

🛠 Features

  • Three-Mode Logic: Use our pretrained model, fine-tune it with your data, or train a new one from scratch.
  • SpaCy Integration: Uses en_core_web_md for high-quality semantic vectors.
  • Auto-Adaptive Architecture: Automatically rebuilds the model head if you add new intent categories during fine-tuning.
  • Production Ready: Includes Early Stopping, Learning Rate Scheduling, and Dropout for regularization.

Installation

  1. Clone the repository:
git clone https://github.com/Perfect-Aimers-Enterprise/uni9ja_nlp.git
cd uni9ja_intent
  1. Install the library:
pip install uni9ja-intent
  1. Download the language model:
python -m spacy download en_core_web_md

Usage Guide

1. Using the Pretrained Model (Inference)

If you just want to use the model out of the box to predict intents:

from uni9ja_intent import IntentModel

# Initialize and load weights
model = IntentModel()
model.load_model("pretrained/uni9ja_intent.pth")

# Predict
intent, confidence = model.predict("How do I sign up for the project?")
print(f"Intent: {intent} ({confidence:.2%})")

2. Fine-tuning with New Data

Use this when you want the model to keep its old knowledge but learn a few new phrases or categories.

new_data = [
    {"text": "I want to hire a freelancer", "label": "hire_request"},
    {"text": "Is there a discount for students?", "label": "pricing_query"}
]

model.finetune(new_data, epochs=20, save_path="pretrained/uni9ja_intent_v2.pth")

3. Training from Scratch (Custom Logic)

Use this if you have a completely different dataset and want to build a brand new brain.

my_custom_data = [
    {"text": "What is the weather?", "label": "weather"},
    {"text": "Play some music", "label": "media_control"},
    # ... more data
]

# Passing data to __init__ triggers the training setup
model = IntentModel(data=my_custom_data, hidden_dims=[256, 128], dropout=0.4)
model.train(epochs=100)
model.save_model("my_custom_model.pth")

Project Structure

.
├── pretrained/           # Saved .pth model checkpoints
├── uni9ja_intent/        # Core Library Source
│   ├── __init__.py       # Package entry point
│   ├── model.py          # PyTorch Neural Network Architecture
│   ├── trainer.py        # IntentModel Manager Class
│   └── spacy_loader.py   # Vectorization logic
├── setup.py              # Pip installation script
└── requirements.txt      # Dependencies

Configuration Parameters

Parameter Default Description
hidden_dims [128, 64] The size of the hidden layers in the MLP.
dropout 0.3 Probability of dropping neurons (prevents overfitting).
threshold 0.6 Minimum confidence score to return a label.

Pro-Tip for Terminal Users

To see your folder structure like the one in this documentation, remember to use the command we set up earlier: tree -I '__pycache__|.git'

Would you like me to create a test.py script for you that automatically verifies if all these features are working correctly?

Loading Data in Code

You can now load your files directly using the built-in utility:

Python from uni9ja_intent import IntentModel, load_data

1. Load data from file

training_data = load_data("path/to/your_data.json")

2. Feed it to the model

model = IntentModel(data=training_data) model.train(epochs=50)

Metadata

Release files for uni9ja-intent 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uni9ja-intent 0.1.4
File Size Uploaded Provenance
uni9ja_intent-0.1.4.tar.gz 8.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for uni9ja-intent 0.1.4
File Interpreter ABI Platform
uni9ja_intent-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / uni9ja_intent-0.1.4.tar.gz

Download URL uni9ja_intent-0.1.4.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f9f03f7a6df5e015bb1439851e72962c5708115c9e3ca9dcf868ccc58f253e27
BLAKE2b-256 checksum
How to use checksums
9222686cfb28d3ee8514dfca390906c1b51764a9ed9a95f700b0fd7ad661d563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.9

Release files / uni9ja_intent-0.1.4-py3-none-any.whl

Download URL uni9ja_intent-0.1.4-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b1dcdbb233058a2900822532bcacf56323d26dc3a8571a31ca57a00dc22169e
BLAKE2b-256 checksum
How to use checksums
7edadeac732e50cf8797fede05b77018dd8fcba052bbb43bd754e4cec3ada7c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.9

Security for uni9ja-intent 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page