Gonyai: Ultra-Lightweight Konkani Intent Router (ONNX)
Model: Elfibolt/gonyai-intent-classifier-onnx
Size: 2.00 MB (ONNX)
Latency: < 1 millisecond (CPU)
Language: Goan Konkani (Devanagari script)
Classes (4): WEATHER, NEWS, CONTEXT, DIRECT
🎯 Overview & Purpose
In the Gonyai Konkani AI Assistant, this classifier acts as a high-speed router in front of the main LLM.
Before generating an answer, it classifies user queries in under 1 millisecond on CPU to determine if external information needs to be retrieved and injected inside a <संदर्भ> ... </संदर्भ> (Context) tag:
WEATHER$\rightarrow$ Fetches real-time weather/rain forecast and injects into<संदर्भ>tag.NEWS$\rightarrow$ Fetches live news / breaking event search and injects into<संदर्भ>tag.CONTEXT$\rightarrow$ Retrieves text from uploaded user documents, bills, reports, or RAG store and injects into<संदर्भ>tag.DIRECT$\rightarrow$ Standard conversations, poetry, advice, recipes (bypasses retrieval, no<संदर्भ>tag).
📊 Benchmark Evaluation Across 70 Adversarial Prompts
The model was rigorously stress-tested across 70 tricky, indirect, and adversarial Konkani test cases designed with zero explicit keywords:
| Adversarial Suite | Test Scenario | Score |
|---|---|---|
| Suite 1 (Extended) | Indirect questions & hard negatives | 20 / 20 (100.0%) |
| Suite 2 (Hardcore) | Cross-domain traps (flood insurance, sowing seeds) | 25 / 25 (100.0%) |
| Suite 3 (Nightmare) | Ultra-indirect idioms (drying papads, humidity, dew point) | 22 / 25 (88.0%) |
| Total Adversarial Score | 70 challenging edge cases | 67 / 70 (95.7%) |
Note: In boundary cases, the model safely defaults to DIRECT, preventing false API triggers.
🚀 Quickstart Usage
Installation
pip install onnxruntime numpy scikit-learn huggingface_hub
Python Inference
import json
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from sklearn.feature_extraction.text import HashingVectorizer
REPO_ID = "Elfibolt/gonyai-intent-classifier-onnx"
# 1. Download model and config
model_path = hf_hub_download(repo_id=REPO_ID, filename="model.onnx")
config_path = hf_hub_download(repo_id=REPO_ID, filename="config.json")
with open(config_path, "r", encoding="utf-8") as f:
config = json.load(f)
# 2. Setup Vectorizer & ONNX Runtime Session
vectorizer = HashingVectorizer(
n_features=config["n_features"],
ngram_range=(config["ngram_min"], config["ngram_max"]),
analyzer="char_wb",
alternate_sign=False
)
session = ort.InferenceSession(model_path, providers=["CPUExecutionProvider"])
input_name = session.get_inputs()[0].name
output_name = session.get_outputs()[0].name
id2label = {int(k): v for k, v in config["id2label"].items()}
def route_query(query: str, confidence_threshold=0.55):
feat = vectorizer.transform([query]).toarray().astype(np.float32)
logits = session.run([output_name], {input_name: feat})[0][0]
probs = np.exp(logits - np.max(logits))
probs = probs / probs.sum()
top_idx = int(np.argmax(probs))
intent = id2label[top_idx]
confidence = float(probs[top_idx])
if confidence < confidence_threshold:
intent = "DIRECT"
needs_context = intent in ["WEATHER", "NEWS", "CONTEXT"]
return intent, confidence, needs_context
# 3. Test Query
query = "आयज दनपरां म्हापश्यां भायली स्थिती पळयल्यार गाडी स्लिप जावपाची शक्यताय आसा काय?"
intent, conf, needs_ctx = route_query(query)
print(f"Query: {query}")
print(f"Intent: {intent} ({conf*100:.1f}%), Needs <संदर्भ>: {needs_ctx}")
🏷️ Intent Classes
WEATHER: Inquiries about live weather, rain forecasts, travel conditions, marine waves, temperature, humidity.NEWS: Breaking events, civic utility outages, sports outcomes, policy decisions, local incident verification.CONTEXT: Document grounding queries referencing uploaded bills, lab reports, contracts, RTI documents, gazettes.DIRECT: Creative writing, general advice, recipes, science explanations, poetry, and conversational chat (no external retrieval needed).
📜 License
Apache-2.0
- Downloads last month
- -