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_mdfor 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
- Clone the repository:
git clone https://github.com/Perfect-Aimers-Enterprise/uni9ja_nlp.git
cd uni9ja_intent
- Install the library:
pip install uni9ja-intent
- 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.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| uni9ja_intent-0.1.2.tar.gz | 8.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uni9ja_intent-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.8 kB
Release files / uni9ja_intent-0.1.2.tar.gz
| Download URL | uni9ja_intent-0.1.2.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
373d6700c347dd93d5527624ed7a77199702749e12206b624e5ccde2e74d798e
|
|
BLAKE2b-256 checksum How to use checksums |
80457dfdb2379d20dc006a50c9ca0fdb6534513d67181787837afa4efa193ef5
|
| 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.2-py3-none-any.whl
| Download URL | uni9ja_intent-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d8521e8bf73bd5831bb03aa37672be4795ef3c011eb38695660903904370ab2
|
|
BLAKE2b-256 checksum How to use checksums |
4d83ae04ce604bd3c4c308d460d5ef1c268244982cc568f31c4a80dacb5f113b
|
| 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.2
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.