Instructions to use smoll-swarm/SmolRouter-135M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use smoll-swarm/SmolRouter-135M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="smoll-swarm/SmolRouter-135M") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("smoll-swarm/SmolRouter-135M") model = AutoModelForCausalLM.from_pretrained("smoll-swarm/SmolRouter-135M", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use smoll-swarm/SmolRouter-135M with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf smoll-swarm/SmolRouter-135M:Q4_K_M # Run inference directly in the terminal: llama cli -hf smoll-swarm/SmolRouter-135M:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf smoll-swarm/SmolRouter-135M:Q4_K_M # Run inference directly in the terminal: llama cli -hf smoll-swarm/SmolRouter-135M:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf smoll-swarm/SmolRouter-135M:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf smoll-swarm/SmolRouter-135M:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf smoll-swarm/SmolRouter-135M:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf smoll-swarm/SmolRouter-135M:Q4_K_M
Use Docker
docker model run hf.co/smoll-swarm/SmolRouter-135M:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use smoll-swarm/SmolRouter-135M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "smoll-swarm/SmolRouter-135M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "smoll-swarm/SmolRouter-135M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/smoll-swarm/SmolRouter-135M:Q4_K_M
- SGLang
How to use smoll-swarm/SmolRouter-135M with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "smoll-swarm/SmolRouter-135M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "smoll-swarm/SmolRouter-135M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "smoll-swarm/SmolRouter-135M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "smoll-swarm/SmolRouter-135M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use smoll-swarm/SmolRouter-135M with Ollama:
ollama run hf.co/smoll-swarm/SmolRouter-135M:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use smoll-swarm/SmolRouter-135M with Docker Model Runner:
docker model run hf.co/smoll-swarm/SmolRouter-135M:Q4_K_M
- Lemonade
How to use smoll-swarm/SmolRouter-135M with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull smoll-swarm/SmolRouter-135M:Q4_K_M
Run and chat with the model
lemonade run user.SmolRouter-135M-Q4_K_M
List all available models
lemonade list
- Atomic Chat
๐ SMOL ROUTER 135M
The ultra-fast routing gateway for SMOL SWARM.
135M Parameters ยท Runs on CPU ยท Deterministic JSON Output ยท Zero Cloud Dependency
๐ Overview
SmolRouter-135M is the gateway agent for the SMOL SWARM ecosystem.
Its sole job is to analyze incoming user queries in under 2 milliseconds on a laptop CPU and output a clean, deterministic routing decision. Instead of running a large, heavy LLM to decide what to do, SmolRouter rapidly points the task to the right specialized worker model.
Think of it as the receptionist of your multi-agent system: it doesn't do the work itself, but it instantly knows exactly which specialist should handle each incoming request.
| Route | Target Model | Intended Task |
|---|---|---|
extractor |
SmolExtractor-1.7B |
Invoices, receipts, logs, messy text โ strict JSON schemas |
compressor |
SmolCompressor-360M |
Summarization, RAG chunk pruning, context reduction |
planner |
SmolPlanner-1.7B |
Multi-step workflows, project roadmaps, goal decomposition |
coder |
SmolCoder-1.7B |
Helper functions, scripts, regex, code debugging |
direct |
Fallback / Local LLM | Simple factual questions, casual chat, direct answers |
import json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_ID = "smoll-swarm/SmolRouter-135M"
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
torch_dtype=torch.float32,
device_map="auto"
)
SYSTEM_PROMPT = """You are SmolRouter, the routing coordinator for SmolSwarm.
Your job is to analyze the user's input and select the optimal agent to handle the task.
You must respond ONLY with a valid JSON object matching this schema:
{"route": "extractor" | "compressor" | "planner" | "coder" | "direct", "confidence": float, "reason": "short explanation"}"""
user_input = "Extract the order ID and billing total from this receipt: Invoice #8841, total due $99.12."
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_input}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=80,
do_sample=False,
pad_token_id=tokenizer.eos_token_id
)
generated = outputs[0][inputs.input_ids.shape[1]:]
response_text = tokenizer.decode(generated, skip_special_tokens=True).strip()
decision = json.loads(response_text)
print(decision)
# Output:
# {"route": "extractor", "confidence": 0.96, "reason": "Receipt parsing."}
{
"route": "extractor",
"confidence": 0.96,
"reason": "Receipt parsing."
}
User Request
โ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ SmolRouter-135M โ ~2ms latency on CPU
โ (Gatekeeper) โ
โโโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโฌโโโโโโโดโโโโโโโโฌโโโโโโโโโโโโโโโ
โผ โผ โผ โผ
โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ
โ Extractor โ โCompressor โ โ Planner โ โ Coder โ
โ (1.7B) โ โ (360M) โ โ (1.7B) โ โ (1.7B) โ
โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ
| User Input | Routed To | โ |
|---|---|---|
| "Extract the order ID and billing total from receipt #8841..." | extractor |
โ |
| "Can you condense this 4000-word market research document..." | compressor |
โ |
| "Write a Python script to download images from an S3 bucket." | coder |
โ |
| "How should I organize a migration plan from AWS to GCP?" | planner |
โ |
| "What is the theory of general relativity?" | direct |
โ |
generation_config = {
"do_sample": False,
"max_new_tokens": 80,
"pad_token_id": tokenizer.eos_token_id
}
| Property | Value |
|---|---|
| Base Model | HuggingFaceTB/SmolLM2-135M-Instruct |
| Parameters | 135 Million |
| License | Apache 2.0 |
- Dataset: 1,500 synthetically-generated routing samples balanced across all 5 Smol Swarm routes.
- Format: ChatML.
- Loss Masking: Only the assistant JSON response contributes to the loss, with the prompt tokens masked using
-100. - Optimizer: AdamW (lr
1e-4, weight decay0.01). - Scheduler: Cosine decay with 10 warmup steps.
- Epochs: 3.
- Batch Size: 16.
- Hardware: 2ร NVIDIA T4 GPUs via Kaggle.
- Precision: FP32 (full precision for maximum stability).
- Final Loss:
~0.07.
- Routing-only: This model only decides a route; it does not perform the task itself. The downstream specialist models (SmolExtractor, SmolCompressor, etc.) do the actual work.
- Calibration: Confidence values are learned outputs, not statistically calibrated probabilities.
- Language: Primarily trained on English prompts.
- Prompt Format: Must use the exact system prompt provided above for best results.
Follow the Smol Swarm Org to track upcoming model releases.
@misc{smolrouter2025,
title = {SmolRouter-135M: An Ultra-Fast Gateway Model for Local Multi-Agent AI},
author = {QuillBytes},
year = {2026},
url = {https://huggingface.co/smoll-swarm/SmolRouter-135M}
}
- Downloads last month
- 76
Model tree for smoll-swarm/SmolRouter-135M
Base model
HuggingFaceTB/SmolLM2-135M