Loading…
Loading…
TinyRouter1-22M is a lightweight 22.7M parameter prompt router. It classifies an English prompt into one of 4 broad domains, so you can route it to the right specialist model:
| Label | Meaning | Example | Route to |
|---|---|---|---|
code |
Programming, debugging, code generation | "Write a Python script to calculate average with pandas" | Code model |
general |
Everyday chat, general knowledge | "What will the weather be like tomorrow?" | General chat model |
multilingual |
Non-English or translation requests | "Translate this sentence to English: Bugun cok yorgunum" | Translation / multilingual model |
stem |
Science, Technology, Engineering, Math | "How do I solve integrals and derivatives?" | Math / Science model |
It is designed for edge, mobile, and low-cost inference. 85MB, runs on CPU in <50ms, no GPU needed for inference.
Test set: 1255 held-out domain-routing examples, filtered from MaziyarPanahi/Jev-Intent-Domain-Routing-130K (domain task only).
Accuracy: 89.48%
Measured on the same 1255 test examples after each epoch:
| Epoch | Accuracy |
|---|---|
| 0 | 84.46% |
| 1 | 87.73% |
| 2 | 88.84% |
| 3 | 89.48% (best, saved) |
| 4 | 89.16% |
| 5 | ~89% (plateau) |
Training plateaus after epoch 3. More epochs do not help - the dataset has noisy labels and the ceiling for MiniLM on this task is around 90-91%.
Tested with the final saved model:
| Prompt | Predicted | Confidence |
|---|---|---|
| "Write a Python script to calculate average with pandas" | code |
91.8% |
| "What will the weather be like tomorrow?" | general |
77.7% |
| "How do I solve integrals and derivatives?" | stem |
78.6% |
| "Translate this sentence to English: Bugun cok yorgunum" | multilingual |
59.1% |
The last example is intentionally hard: half English, half Turkish. The model still picks multilingual correctly, but with lower confidence. Mixed-language prompts are the hardest case.
sentence-transformers/all-MiniLM-L6-v2 (22.7M)MaziyarPanahi/Jev-Intent-Domain-Routing-130K, filtered to question_key == "domain" only. Train + validation + test domain splits combined, then re-split 95% / 5%.state_preview + " [SEP] " + question_text, truncated to 256 tokensfrom transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch, json
tok = AutoTokenizer.from_pretrained("Kuantum-ai1/TinyRouter1-22M")
model = AutoModelForSequenceClassification.from_pretrained("Kuantum-ai1/TinyRouter1-22M")
model.eval()
labels = ["code", "general", "multilingual", "stem"]
def predict(prompt: str):
state = json.dumps({"conversation": [{"content": prompt, "role": "user"}]})
text = state + " [SEP] Which broad domain best describes this conversation?"
enc = tok(text, truncation=True, max_length=256, return_tensors="pt")
with torch.no_grad():
probs = torch.softmax(model(**enc).logits, dim=-1)[0]
return {labels[i]: round(float(p)*100, 1) for i, p in enumerate(probs)}
print(predict("Write a Python script to calculate average with pandas"))
# {'code': 91.8, 'general': 2.0, 'multilingual': 3.0, 'stem': 3.1}
print(predict("How do I solve integrals and derivatives?"))
# {'code': 6.7, 'general': 9.0, 'multilingual': 5.8, 'stem': 78.6}
# Route to specialist models based on prediction
result = predict(user_prompt)
domain = max(result, key=result.get)
if domain == "code":
answer = code_model.generate(user_prompt)
elif domain == "stem":
answer = math_model.generate(user_prompt)
elif domain == "multilingual":
answer = translation_model.generate(user_prompt)
else:
answer = general_model.generate(user_prompt)
multilingual by design, not routed by topic. Turkish, Chinese, etc. will all go to multilingual.general.general and stem (e.g. weather can be both). This caps accuracy around 90-91% for this architecture.Apache 2.0. Same as base model all-MiniLM-L6-v2. Free for commercial use.
@misc{tinyrouter1-22m,
title = {TinyRouter1-22M: Lightweight 22M Prompt Router},
author = {Kuantum-ai1},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Kuantum-ai1/TinyRouter1-22M}}
}
sentence-transformers/all-MiniLM-L6-v2MaziyarPanahi/Jev-Intent-Domain-Routing-130Ksentence-transformers/all-MiniLM-L6-v2