Text Generation
Transformers.js
ONNX
English
llama
router
orchestrator
slm
edge-computing
mixture-of-experts
Instructions to use jromarllegue/Supra-Router-51M-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use jromarllegue/Supra-Router-51M-ONNX with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'jromarllegue/Supra-Router-51M-ONNX');
Upload folder using huggingface_hub
Browse files- README.md +117 -0
- config.json +36 -0
- generation_config.json +7 -0
- onnx/model.onnx +3 -0
- onnx/model_bnb4.onnx +3 -0
- onnx/model_fp16.onnx +3 -0
- onnx/model_int8.onnx +3 -0
- onnx/model_q4.onnx +3 -0
- onnx/model_q4f16.onnx +3 -0
- onnx/model_quantized.onnx +3 -0
- onnx/model_uint8.onnx +3 -0
README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers.js
|
| 3 |
+
tags:
|
| 4 |
+
- router
|
| 5 |
+
- orchestrator
|
| 6 |
+
- slm
|
| 7 |
+
- edge-computing
|
| 8 |
+
- mixture-of-experts
|
| 9 |
+
- text-generation
|
| 10 |
+
pipeline_tag: text-generation
|
| 11 |
+
model_type: llama
|
| 12 |
+
datasets:
|
| 13 |
+
- SupraLabs/Prompt-Routing-Dataset
|
| 14 |
+
language:
|
| 15 |
+
- en
|
| 16 |
+
base_model:
|
| 17 |
+
- SupraLabs/Supra-Router-51M
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# Supra-Router-51M (ONNX)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
This is an ONNX version of [SupraLabs/Supra-Router-51M](https://huggingface.co/SupraLabs/Supra-Router-51M). It was automatically converted and uploaded using [this Hugging Face Space](https://huggingface.co/spaces/onnx-community/convert-to-onnx).
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
## Usage with Transformers.js
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
See the pipeline documentation for `text-generation`: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.TextGenerationPipeline
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
<h1 align="center">Supra-Router-51M · Multi-Task Infrastructure Routing Model</h1>
|
| 38 |
+
|
| 39 |
+

|
| 40 |
+
|
| 41 |
+
<h2 align="center">About the Model</h2>
|
| 42 |
+
|
| 43 |
+
GGUF model [here](https://huggingface.co/SupraLabs/Supra-Router-51M-gguf)
|
| 44 |
+
|
| 45 |
+
**Supra-Router-51M** is an ultra-lightweight, high-speed infrastructure traffic controller optimized for localized edge orchestration. With only **51.7 million parameters**, this micro-LLM acts as a defensive gateway for multi-model ecosystems, accurately determining when user requests can be processed locally by an Edge SLM or when they must be triaged to a cloud-hosted frontier intelligence layer.
|
| 46 |
+
|
| 47 |
+
The model was built by fine-tuning a pre-trained 51M base on the `SupraLabs/Prompt-Routing-Dataset` (992 rows). Rather than acting as a naive binary classifier, the model uses **Multi-Task Sequence Generation** to map out the underlying properties of a prompt before predicting the final routing token, anchoring its attention heads to robust language and structural logic features.
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## Multi-Task Decision Sequence
|
| 52 |
+
|
| 53 |
+
To run inference, wrap your user query inside the structural framing tokens used during training (`Task: [Prompt]\nAnalysis: `). The model will output a deterministic, pipe-separated string containing the full telemetry of the prompt's cognitive requirements:
|
| 54 |
+
|
| 55 |
+
### Expected Output Target Schema:
|
| 56 |
+
```text
|
| 57 |
+
Domain: [Semantic Field] | Complexity: [1-5] | Math: [True/False] | Code: [True/False] | Route: [small model/big model] | Justification: [Rule-driven infrastructure reasoning]
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## Why this works:
|
| 61 |
+
|
| 62 |
+
By forcing a sub-100M parameter model to calculate the semantic domain, structural complexity, and technical flags before it emits the final Route token, the network effectively runs an internal feature-activation map. This multi-task sequence prevents localized weight collapse and guarantees stable routing boundaries.
|
| 63 |
+
|
| 64 |
+
## Training Telemetry & Optimization
|
| 65 |
+
|
| 66 |
+
- Dataset Source: SupraLabs/Prompt-Routing-Dataset (992 samples)
|
| 67 |
+
- Training Duration: 5 Epochs
|
| 68 |
+
- Checkpoint Selection: Peak generalization was reached during Epoch 3 (eval_loss: 0.1342). To eliminate late-stage micro-model memorization and validation drift, the training state was automatically rewound and saved at this numerical peak.
|
| 69 |
+
- Precision: bfloat16
|
| 70 |
+
- Hardware Footprint: Optimized sequence processing length of 3840 tokens, ensuring rapid inference execution with negligible CPU/GPU overhead (sub-millisecond generation speeds).
|
| 71 |
+
|
| 72 |
+
## Inference & Gateway Implementation
|
| 73 |
+
|
| 74 |
+
Use this direct script to test or wrap the model inside a live production orchestrator or FastAPI gateway. It enforces greedy decoding (do_sample=False) for maximum decision stability.
|
| 75 |
+
|
| 76 |
+
```python
|
| 77 |
+
import torch
|
| 78 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 79 |
+
|
| 80 |
+
MODEL_ID = "SupraLabs/Supra-Router-51M"
|
| 81 |
+
|
| 82 |
+
print("[*] Initializing local infrastructure router...")
|
| 83 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 84 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 85 |
+
MODEL_ID,
|
| 86 |
+
dtype=torch.bfloat16,
|
| 87 |
+
device_map="auto"
|
| 88 |
+
)
|
| 89 |
+
model.eval()
|
| 90 |
+
|
| 91 |
+
# Example prompt showcasing keyword-trap evasion
|
| 92 |
+
user_prompt = "Write a movie script about a chef who gets lost at sea."
|
| 93 |
+
|
| 94 |
+
# Format to match internal SFT attention alignment
|
| 95 |
+
formatted_input = f"Task: {user_prompt}\nAnalysis: "
|
| 96 |
+
inputs = tokenizer(formatted_input, return_tensors="pt").to(model.device)
|
| 97 |
+
|
| 98 |
+
with torch.no_grad():
|
| 99 |
+
outputs = model.generate(
|
| 100 |
+
**inputs,
|
| 101 |
+
max_new_tokens=128,
|
| 102 |
+
do_sample=False,
|
| 103 |
+
pad_token_id=tokenizer.pad_token_id,
|
| 104 |
+
eos_token_id=tokenizer.eos_token_id
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
generated_ids = outputs[0][inputs["input_ids"].shape[1]:]
|
| 108 |
+
print(tokenizer.decode(generated_ids, skip_special_tokens=True).strip())
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
## Proven Benchmarks & Defensive Boundaries
|
| 112 |
+
|
| 113 |
+
During edge validation testing, Supra-Router-51M demonstrated robust resilience against adversarial prompt strings:
|
| 114 |
+
|
| 115 |
+
- Keyword Trap Evasion: Successfully identifies semantic context rather than matching tokens. Prompts containing words like "script" or "calculus" are correctly parsed as creative writing (not programming/math code) and routed locally to the small model when complexity is low.
|
| 116 |
+
- Complexity-Driven Safety Net: In instances where programming syntax or technical boundaries are ambiguous (e.g., complex regex or architectural database frames), the model naturally scales its evaluation metrics to Complexity: 3, automatically triggering a big model route override.
|
| 117 |
+
- Deterministic Offloading: Safely captures multi-step logic paths, calculus concepts, and code generation scripts, instantly assigning them to cloud-scale frontier endpoints.
|
config.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"dtype": "float32",
|
| 9 |
+
"eos_token_id": 2,
|
| 10 |
+
"head_dim": 64,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 512,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 1408,
|
| 15 |
+
"max_position_embeddings": 5120,
|
| 16 |
+
"mlp_bias": false,
|
| 17 |
+
"model_type": "llama",
|
| 18 |
+
"num_attention_heads": 8,
|
| 19 |
+
"num_hidden_layers": 12,
|
| 20 |
+
"num_key_value_heads": 4,
|
| 21 |
+
"pad_token_id": 1,
|
| 22 |
+
"pretraining_tp": 1,
|
| 23 |
+
"rms_norm_eps": 1e-06,
|
| 24 |
+
"rope_parameters": {
|
| 25 |
+
"factor": 1.0,
|
| 26 |
+
"rope_theta": 10000.0,
|
| 27 |
+
"rope_type": "linear",
|
| 28 |
+
"type": "linear"
|
| 29 |
+
},
|
| 30 |
+
"rope_scaling": null,
|
| 31 |
+
"rope_theta": 10000.0,
|
| 32 |
+
"tie_word_embeddings": true,
|
| 33 |
+
"transformers_version": "4.57.6",
|
| 34 |
+
"use_cache": true,
|
| 35 |
+
"vocab_size": 32000
|
| 36 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 0,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"pad_token_id": 1,
|
| 6 |
+
"transformers_version": "4.57.6"
|
| 7 |
+
}
|
onnx/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0bfdc54738a098d0cb96efcb16053ca82077d0cb505cde14b303b60d80af51db
|
| 3 |
+
size 273175838
|
onnx/model_bnb4.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:09e59d7ec80266c2996e3b285c5eb29662056bbd2cbaa66675ff25b2ba9b4d1e
|
| 3 |
+
size 98453262
|
onnx/model_fp16.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c3dd6d22c1b5ad92e01f2369ca10ddec95fec6590f20a09cd25691e41727a9e1
|
| 3 |
+
size 137057529
|
onnx/model_int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f1b4685aaa5f7849da809507f07a85764be8b1d7335a5926177c01adde8338c1
|
| 3 |
+
size 69001679
|
onnx/model_q4.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:09e59d7ec80266c2996e3b285c5eb29662056bbd2cbaa66675ff25b2ba9b4d1e
|
| 3 |
+
size 98453262
|
onnx/model_q4f16.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a8face6fcbe0e8389f3ed17274fae57f5197b67757869dcf25cee8007aa63089
|
| 3 |
+
size 62597905
|
onnx/model_quantized.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f1b4685aaa5f7849da809507f07a85764be8b1d7335a5926177c01adde8338c1
|
| 3 |
+
size 69001679
|
onnx/model_uint8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e1126a497e691428bb9547e80614886e282d0304657ab6c2ed0f7acfe6894f55
|
| 3 |
+
size 69001726
|