A lightweight, high-precision text classification model engineered for multimodal conversational systems and dialogue agents.
It deterministically identifies whether incoming user input intends to trigger on-demand visual image synthesis (IMAGE_GENERATION) versus standard conversational interaction, user-shared media discussions, or inquiries (TEXT_CHAT).
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 with linear classification head.| Class ID | Label | Definition | Exemplar Inputs |
|---|---|---|---|
0 |
TEXT_CHAT |
Standard dialogue, inquiries, compliments, user sharing personal media, or explicit generation prohibitions. | "I took a photo of the sunset today", "Do you like photography?", "You look great", "Photo mat bhejna", "No pictures please" |
1 |
IMAGE_GENERATION |
User requests the system/assistant to generate, take, or deliver an image/photo of a subject, outfit, or scene. | "Send me a photo in a red saree", "Can you take a selfie?", "Show me what you're wearing", "Apni cute photo bhejo na" |
Evaluated across a balanced holdout dataset (828 samples):
| Metric | Score |
|---|---|
| Accuracy | 100.00% |
| Macro F1 Score | 1.0000 |
| Weighted Precision | 1.0000 |
| Weighted Recall | 1.0000 |
| Evaluation Loss | 0.0033 |
| Evaluation Slice | Expected Class | Accuracy | Diagnostic Value |
|---|---|---|---|
| Direct Generation Commands (EN) | IMAGE_GENERATION |
100.0% (9/9) | High recall on concise direct requests. |
| Attire & Scene Specifications | IMAGE_GENERATION |
60.0% (6/10) | Captures complex multi-clause visual constraints. |
| Affectionate & Companion Requests | IMAGE_GENERATION |
100.0% (6/6) | Preserves action sensitivity on affectionate requests. |
| Hinglish & Regional Dialects | IMAGE_GENERATION |
100.0% (8/8) | Robust code-switching on Romanized Hindi. |
| Colloquial Abbreviations & Typos | IMAGE_GENERATION |
100.0% (7/7) | Resilient to informal shorthand ("plz send ur pic", "selfi"). |
| Trap: Negations & Prohibitions | TEXT_CHAT |
86.7% (13/15) | Suppresses generation on compound pre-/post-positioned negations. |
| Trap: User Sharing Personal Media | TEXT_CHAT |
87.5% (7/8) | Correctly distinguishes user photo-sharing from generation requests. |
| Trap: Technical Photography Q&A | TEXT_CHAT |
83.3% (5/6) | Filters out camera, lens, and exposure discussions. |
| Trap: Compliments (Zero Generation) | TEXT_CHAT |
90.0% (9/10) | Prevents false triggers on aesthetic or emotional statements. |
| Casual Conversation | TEXT_CHAT |
83.3% (5/6) | General chit-chat passes cleanly without interruption. |
Single-sentence inference benchmarked over 200 iterations:
| Runtime / Engine | Execution Provider | P50 (Median) | P95 | P99 | Throughput |
|---|---|---|---|---|---|
| ONNX Runtime | CPU (2 threads) | 12.16 ms | 13.86 ms | 26.96 ms | 79.3 req/s |
| PyTorch (Native) | CPU | 30.02 ms | 38.40 ms | 44.22 ms | 33.9 req/s |
| PyTorch (Native) | Tesla T4 GPU | 7.71 ms | 9.07 ms | 11.24 ms | 125.6 req/s |
Recommended for low-latency web backends (e.g., FastAPI, Flask) running on CPU-only infrastructure:
import onnxruntime as ort
import numpy as np
from transformers import AutoTokenizer
MODEL_ID = "Umranz/intent-classifier"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
session = ort.InferenceSession("model.onnx")
def predict_intent(text: str) -> dict:
inputs = tokenizer(text, return_tensors="np", truncation=True, max_length=128)
logits = session.run(None, {
"input_ids": inputs["input_ids"],
"attention_mask": inputs["attention_mask"]
})[0]
# Softmax probabilities
probs = np.exp(logits) / np.sum(np.exp(logits), axis=-1, keepdims=True)
p_img = float(probs[0][1])
# Recommended three-way decision threshold
if p_img >= 0.75:
intent = "IMAGE_GENERATION"
elif p_img >= 0.45:
intent = "AMBIGUOUS" # Conversational clarification recommended
else:
intent = "TEXT_CHAT"
return {"intent": intent, "p_image_generation": p_img, "p_text_chat": 1.0 - p_img}
# Example predictions
print(predict_intent("Can you show me a photo in traditional clothes?"))
# {'intent': 'IMAGE_GENERATION', 'p_image_generation': 0.985, ...}
print(predict_intent("I took a photo of the sunset yesterday."))
# {'intent': 'TEXT_CHAT', 'p_image_generation': 0.015, ...}
print(predict_intent("Photo mat bhejna please."))
# {'intent': 'TEXT_CHAT', 'p_image_generation': 0.021, ...}
from transformers import pipeline
classifier = pipeline("text-classification", model="Umranz/intent-classifier")
result = classifier("Show me a picture of you smiling")
print(result)
# [{'label': 'IMAGE_GENERATION', 'score': 0.985}]
For production systems with strict latency requirements, a hybrid routing architecture is recommended:
[ User Input ]
│
▼
[ Fast-Path Regex (0 ms) ] ── (Explicit commands or strict negations) ──► Direct Resolution
│ (Unmatched / Conversational)
▼
[ ONNX Intent Classifier (~12 ms CPU) ]
│
├── P(IMAGE) >= 0.75 ────────► Trigger Image Synthesis Pipeline
├── 0.45 <= P(IMAGE) < 0.75 ─► Request User Clarification
└── P(IMAGE) < 0.45 ─────────► Route to Conversational LLM
checkpoint-104/optimizer.pt 941 MBcheckpoint-113/optimizer.pt 941 MBcheckpoint-125/optimizer.pt 941 MBcheckpoint-208/optimizer.pt 941 MBcheckpoint-226/optimizer.pt 941 MBcheckpoint-250/optimizer.pt 941 MBcheckpoint-312/optimizer.pt 941 MBcheckpoint-339/optimizer.pt 941 MBcheckpoint-375/optimizer.pt 941 MBcheckpoint-416/optimizer.pt 941 MBcheckpoint-452/optimizer.pt 941 MBcheckpoint-500/optimizer.pt 941 MBcheckpoint-104/model.safetensors 471 MBcheckpoint-113/model.safetensors 471 MBcheckpoint-125/model.safetensors 471 MBcheckpoint-208/model.safetensors 471 MBcheckpoint-226/model.safetensors 471 MBcheckpoint-250/model.safetensors 471 MBcheckpoint-312/model.safetensors 471 MBcheckpoint-339/model.safetensors 471 MBcheckpoint-375/model.safetensors 471 MBcheckpoint-416/model.safetensors 471 MBcheckpoint-452/model.safetensors 471 MBcheckpoint-500/model.safetensors 471 MBmodel.safetensors 471 MBmodel.onnx 767.6 kBcheckpoint-104/rng_state.pth 14.6 kBcheckpoint-113/rng_state.pth 14.6 kBcheckpoint-125/rng_state.pth 14.6 kBcheckpoint-208/rng_state.pth 14.6 kBcheckpoint-226/rng_state.pth 14.6 kBcheckpoint-250/rng_state.pth 14.6 kBcheckpoint-312/rng_state.pth 14.6 kBcheckpoint-339/rng_state.pth 14.6 kBcheckpoint-375/rng_state.pth 14.6 kBcheckpoint-416/rng_state.pth 14.6 kBcheckpoint-452/rng_state.pth 14.6 kBcheckpoint-500/rng_state.pth 14.6 kBcheckpoint-104/training_args.bin 5.2 kBcheckpoint-113/training_args.bin 5.2 kBcheckpoint-125/training_args.bin 5.2 kBcheckpoint-208/training_args.bin 5.2 kBcheckpoint-226/training_args.bin 5.2 kBcheckpoint-250/training_args.bin 5.2 kBcheckpoint-312/training_args.bin 5.2 kBcheckpoint-339/training_args.bin 5.2 kBcheckpoint-375/training_args.bin 5.2 kBcheckpoint-416/training_args.bin 5.2 kBcheckpoint-452/training_args.bin 5.2 kBcheckpoint-500/training_args.bin 5.2 kBtraining_args.bin 5.2 kBcheckpoint-104/scheduler.pt 1.5 kBcheckpoint-113/scheduler.pt 1.5 kBcheckpoint-125/scheduler.pt 1.5 kBcheckpoint-208/scheduler.pt 1.5 kBcheckpoint-226/scheduler.pt 1.5 kBcheckpoint-250/scheduler.pt 1.5 kBcheckpoint-312/scheduler.pt 1.5 kBcheckpoint-339/scheduler.pt 1.5 kBcheckpoint-375/scheduler.pt 1.5 kBcheckpoint-416/scheduler.pt 1.5 kBcheckpoint-452/scheduler.pt 1.5 kBcheckpoint-500/scheduler.pt 1.5 kBcheckpoint-104/scaler.pt 1.4 kBcheckpoint-113/scaler.pt 1.4 kBcheckpoint-125/scaler.pt 1.4 kBcheckpoint-208/scaler.pt 1.4 kBcheckpoint-226/scaler.pt 1.4 kBcheckpoint-250/scaler.pt 1.4 kBcheckpoint-312/scaler.pt 1.4 kBcheckpoint-339/scaler.pt 1.4 kBcheckpoint-375/scaler.pt 1.4 kBcheckpoint-416/scaler.pt 1.4 kBcheckpoint-452/scaler.pt 1.4 kBcheckpoint-500/scaler.pt 1.4 kBsentence-transformers/paraphrase-multilingual-MiniLM-L12-v2