Text Classification
Scikit-learn
Joblib
English
llm-routing
model-selection
budget-optimization
nearest-neighbor
Run this model with HF Jobs
Run JiaqiXue/R2-Router-RouterArena on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/JiaqiXue/R2-Router-RouterArena. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/JiaqiXue/R2-Router-RouterArena on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use JiaqiXue/R2-Router-RouterArena with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use JiaqiXue/R2-Router-RouterArena with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("JiaqiXue/R2-Router-RouterArena", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Fix: use transformers AutoModel instead of sentence_transformers for Qwen3 compatibility
Browse files33 unmodified lines3435363738394041424344454647485 unmodified lines545556575859606119 unmodified lines818283848586878889909192939495969733 unmodified lines### Installation```bashpip install scikit-learn numpy joblib huggingface_hub sentence-transformers```### Complete Example```pythonfrom huggingface_hub import snapshot_downloadfrom sentence_transformers import SentenceTransformerimport sys# 1. Download routerpath = snapshot_download("JiaqiXue/r2-router")5 unmodified linesrouter = R2Router.from_pretrained(path)# 3. Embed your query with Qwen3-0.6B (1024-dim)embedder = SentenceTransformer("Qwen/Qwen3-0.6B")embedding = embedder.encode("What is the capital of France?")# 4. Route!result = router.route(embedding)19 unmodified lines### Alternative: vLLM Embeddings (Faster for Batches)```pythonfrom vllm import LLMllm = LLM(model="Qwen/Qwen3-0.6B", runner="pooling")outputs = llm.embed(["What is the capital of France?"])embedding = outputs[0].outputs.embedding```Or with vLLM for faster batch inference:```pythonfrom vllm import LLMllm = LLM(model="Qwen/Qwen3-0.6B", runner="pooling")outputs = llm.embed(["What is the capital of France?"])embedding = outputs[0].outputs.embedding33 unmodified lines343536373839404142434445464748495 unmodified lines555657585960616263646566676819 unmodified lines888990919293949596979833 unmodified lines### Installation```bashpip install scikit-learn numpy joblib huggingface_hub torch transformers>=4.51```### Complete Example```pythonfrom huggingface_hub import snapshot_downloadimport sys, torchimport numpy as npfrom transformers import AutoModel, AutoTokenizer# 1. Download routerpath = snapshot_download("JiaqiXue/r2-router")5 unmodified linesrouter = R2Router.from_pretrained(path)# 3. Embed your query with Qwen3-0.6B (1024-dim)tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")model = AutoModel.from_pretrained("Qwen/Qwen3-0.6B")query = "What is the capital of France?"inputs = tokenizer(query, return_tensors="pt", padding=True, truncation=True)with torch.no_grad():output = model(**inputs)embedding = output.last_hidden_state.mean(dim=1).squeeze().numpy()# 4. Route!result = router.route(embedding)19 unmodified lines### Alternative: vLLM Embeddings (Faster for Batches)For GPU-accelerated batch embedding:```pythonfrom vllm import LLMllm = LLM(model="Qwen/Qwen3-0.6B", runner="pooling")outputs = llm.embed(["What is the capital of France?"])embedding = outputs[0].outputs.embedding
README.md+14-13