--- license: apache-2.0 language: - en pipeline_tag: text-classification tags: - llm-routing - router - from-scratch - small-language-model - on-device - privoid - gguf - safetensors ---

Privoid Router Evaluation

# 🧭 Privoid Router (Privoid-Router-34M) Privoid-Router-34M is an ultra-lightweight, 34-million parameter routing model **engineered entirely from scratch**. It acts as an intelligent local gatekeeper to orchestrate low-cost local routing workflows. The model dynamically predicts whether an incoming prompt requires strong reasoning (routing to a Frontier Model API like GPT-4) or can be safely and accurately executed locally using a resource-efficient Small Language Model (SLM). ## 📊 Key Highlights & Results - **Zero-leakage Custom Pipeline**: Developed with a custom BPE Tokenizer (16k vocab) and custom Transformer architecture (RoPE, RMSNorm, SwiGLU) trained from scratch. - **Unmatched Resource Efficiency**: At just **34M parameters**, it runs comfortably on edge devices and consumer CPUs, requiring 3x fewer parameters than standard BERT-based alternatives. - **Substantial Cost Savings**: Cuts modeled API operational costs by **49.6%** while recovering **80.7%** of the optimal quality gap. --- ## 📈 Evaluation Benchmarks ### 1. Baselines vs. Privoid Router (Held-Out Test Set, n=5000) | Routing Strategy | Area Under ROC (AUC) | Agreement with Oracle (APGR) | Call-to-Frontier Share (CPT@80%) | | :--- | :---: | :---: | :---: | | **Random Routing** | 0.500 | 0.500 | 80.0% | | 🏆 **Privoid-Router-34M (Ours)** | **0.754** | **0.720** | **47.3%** | | **Oracle (Perfect Routing)** | 1.000 | 1.000 | ~20.0% | ### 2. Literature Comparison against Established Routers | Model / Method | Parameters | Area Under ROC (AUC) | APGR Score | Frontier Traffic (CPT@80%) | | :--- | :---: | :---: | :---: | :---: | | **TF-IDF + Logistic Regression** | <1M | 0.670 | 0.620 | 61.0% | | **RouteLLM (Matrix Factorization)** | ~50M | 0.740 | 0.700 | 49.0% | | 🌟 **Privoid-Router-34M (Ours)** | **34M** | **0.754** | **0.720** | **47.3%** | | **RouteLLM (BERT-based)** | ~110M | 0.780 | 0.760 | 43.0% |

External Benchmarks

--- ## 🛠️ Multi-Format Integration & Usage ### 1. Python (PyTorch / Safetensors) Ensure you have `safetensors`, `tokenizers`, and `torch` installed. Put `privoid_model.py` in your working path: ```python import json, torch from safetensors.torch import load_file from tokenizers import Tokenizer from privoid_model import PrivoidRouter cfg = json.load(open('config.json')) tok = Tokenizer.from_file('tokenizer.json') model = PrivoidRouter(cfg, dropout=0.0) model.load_state_dict(load_file('model.safetensors')) model.eval() def route(prompt): ids = torch.tensor([[2] + tok.encode(prompt, add_special_tokens=False).ids[:cfg['max_len'] - 1]]) p = torch.sigmoid(model(ids, ids != 0)).item() decision = 'frontier' if p >= cfg['threshold'] else 'local' return decision, p decision, score = route("Design a distributed rate limiter for 1M requests/sec.") print(f"Route to: {decision.upper()} (score: {score:.3f})") ``` ### 2. Local Inference via GGUF Deploy locally with `llama.cpp` using the lightweight `model.gguf` asset: ```bash ./llama-cli -m model.gguf -p "[CLS] Is the earth round?" --temp 0.0 ``` --- ### 🧬 Training & Architecture - **Stage 1 (MLM Pre-training)**: Pre-trained with Masked Language Modeling on 300 million tokens of FineWeb-Edu + routing user prompts. - **Stage 2 (Router Fine-tuning)**: Fully supervised classifier head fine-tuning using quality scores derived from `routellm/gpt4_dataset` (score threshold < 4 indicates frontier delegation required). - **Optimizer**: AdamW with cosine learning rate decay and early stopping validation guarding. Built with 💙 by [privoid.ai](https://privoid.ai).