Instructions to use e2rea1/RouteWeaver-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use e2rea1/RouteWeaver-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="e2rea1/RouteWeaver-4B") 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("e2rea1/RouteWeaver-4B") model = AutoModelForCausalLM.from_pretrained("e2rea1/RouteWeaver-4B", 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
- vLLM
How to use e2rea1/RouteWeaver-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "e2rea1/RouteWeaver-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "e2rea1/RouteWeaver-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/e2rea1/RouteWeaver-4B
- SGLang
How to use e2rea1/RouteWeaver-4B 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 "e2rea1/RouteWeaver-4B" \ --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": "e2rea1/RouteWeaver-4B", "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 "e2rea1/RouteWeaver-4B" \ --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": "e2rea1/RouteWeaver-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use e2rea1/RouteWeaver-4B with Docker Model Runner:
docker model run hf.co/e2rea1/RouteWeaver-4B
RouteWeaver-4B
The routing policy from RouteWeaver: Weaving Mode Selection and Execution into Unified LLM Routing.
Existing LLM routers fix the execution paradigm in advance — single-round, multi-round or agentic — so they adapt which models to call but not how the calls are organized. RouteWeaver makes the paradigm itself a routing decision: this model selects an execution mode, then routes frozen worker models inside the mode it chose.
- 📄 Paper: coming soon
- 💻 Code: https://github.com/LaughKing/RouteWeaver
- 🌐 Project page: https://laughking.github.io/RouteWeaver/
- 📊 Datasets: https://huggingface.co/datasets/e2rea1/RouteWeaver-data
- 💸 Cost-aware variants: https://huggingface.co/e2rea1/RouteWeaver-4B-cost
- 🗂️ Everything on the Hub: https://huggingface.co/collections/e2rea1/routeweaver-6ac89596851c1c7650f72aa4
- Base model: Qwen3-4B-Instruct-2507, all parameters fine-tuned
- Training: COMET-GRPO with progressive exploration, task reward only (α = 0)
What this model does
It is not a chat model and it does not answer questions. It writes routing actions, and the surrounding agent loop executes them against a worker pool:
<mode>agentic</mode>
<route model="worker_3" role="planner" refs="">Split the problem into sub-tasks: ...</route>
<observation id="n1" role="planner">...</observation>
<route model="worker_3" role="executor" refs="n1">Compute ...</route>
<observation id="n2" role="executor">...</observation>
<answer>9</answer>
Three modes share one action grammar:
| mode | execution |
|---|---|
single |
exactly one worker call |
multi |
two to four sequential calls, each seeing the previous observation |
agentic |
up to eight calls over role-structured layers (planner / executor / verifier / summarizer) with explicit references between them |
Workers are addressed only by anonymous ids (worker_1 … worker_6) that the
prompt pairs with capability descriptions; the router never sees model names or
prices. The ids are positional: they mean what the prompt says they mean, so
the model must be served with the same pool definition it was trained with
(configs/route_channels.yaml in the code repository).
Usage
The model only behaves as a router inside the agent loop that parses its actions and calls the workers. Use the code repository:
git clone https://github.com/LaughKing/RouteWeaver && cd RouteWeaver
bash setup_env.sh && conda activate routeweaver
CKPT=$(python -c "from huggingface_hub import snapshot_download as d; print(d('e2rea1/RouteWeaver-4B'))")
TAG=routeweaver GPU=0 bash scripts/eval.sh paper
Loading the weights on their own works as usual, and is useful for inspecting what it emits:
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("e2rea1/RouteWeaver-4B", dtype="bfloat16")
tok = AutoTokenizer.from_pretrained("e2rea1/RouteWeaver-4B")
This model is trained with α = 0 — task reward only. Three cost-aware
operating points of the same method are in
RouteWeaver-4B-cost:
α = 0.1 cuts worker cost 23% for 1.0 point of accuracy, α = 0.3 cuts it 61% for
3.1 points.
Decoding used for every reported number: greedy at evaluation time (temperature 0.8 / top-p 0.95 during training), prompts capped at 6,144 tokens, the multi-turn response budget at 16,384, each observation at 2,048.
Worker pool
The six frozen workers the router was trained against. Serving a different pool changes what the ids mean, and the policy's choices stop being meaningful.
| id | model |
|---|---|
| worker_1 | Qwen3-8B |
| worker_2 | Llama-3.1-8B-Instruct |
| worker_3 | Qwen3-30B-A3B-Instruct-2507 |
| worker_4 | Gemma-3-27B-IT |
| worker_5 | Llama-3.3-70B-Instruct |
| worker_6 | Gemini-2.5-Flash-Lite |
Limitations
- Pool-specific. The policy learned which anonymous id is good at what. It does not transfer to a different worker pool without retraining.
- Not a standalone model. Without the agent loop it emits actions nobody executes.
- It inherits the limitations of the workers it calls: a wrong worker answer propagates, and the router cannot verify facts itself.
- Trained on Math / Code / Knowledge / Reason / Recall questions in English.
Citation
@article{routeweaver2026,
title = {RouteWeaver: Weaving Mode Selection and Execution into Unified LLM Routing},
author = {Wang, Xiaohan and Zhang, Haozhen and Liu, Qingyuan and Feng, Tao and Wang, Wenya},
journal = {arXiv preprint},
year = {2026}
}
Built on verl and vLLM; the base model is Qwen3-4B-Instruct-2507.
- Downloads last month
- 66