Skip to content

Add f-router-v2 - #286

Open
ehanmire wants to merge 1 commit into
RouteWorks:mainfrom
ehanmire:f-router-v2
Open

ehanmire wants to merge 1 commit into
RouteWorks:mainfrom
ehanmire:f-router-v2

Conversation

@ehanmire

Copy link
Copy Markdown
Contributor

Add f-router-v2

f-router-v2 is a new router from the team behind f-router (#270). It uses a different classifier, a different routing rule and different candidate models. It does not replace f-router.

Files:

  • router_inference/config/f-router-v2.json
  • router_inference/predictions/f-router-v2.json (full, generated_result populated)
  • router_inference/predictions/f-router-v2-robustness.json (routing only)
  • model_cost/model_profiles.yaml + regenerated model_cost/model_cost.json: one new entry for the router's own classifier (Qwen3-1.7B, run locally)

How it routes

  1. A local model, Qwen3-1.7B (bf16, not quantized), reads each query inside a fixed classifier prompt that asks it to classify the request, not to answer it. Queries longer than 2,000 tokens are cut to their first 1,500 and last 500 tokens, with an omission marker between them (27 of 8,400 queries on full). The model runs one forward pass over the prompt and does not decode any output tokens. We take the last-layer hidden state of the last prompt token.
  2. Small L2 logistic regressions on that hidden state predict request labels: a primary type (coding, translation or other), whether the request needs multi-step reasoning, whether that reasoning is deep, and five subject areas. The subject-area labels are not used for routing in this version.
  3. A fixed rule table picks the model:
    • coding → Qwen/Qwen3-Coder-Next
    • translation → google/gemini-3.8-flash
    • other, predicted to need deep multi-step reasoning, and P(deep) ≥ 0.99872 → openai/gpt-6.1-sol
    • everything else → google/gemini-3.8-flash

The 0.99872 cut-off is set so that about 4% of our validation rows (29 of 731) go to GPT-6.1 Sol. This rule caps how often the expensive model is used; we did not choose the cut-off by comparing answer accuracy. On full the router sent 8,004 queries to Gemini 3.8 Flash, 379 to Qwen3-Coder-Next and 17 to GPT-6.1 Sol.

Training data (no RouterArena data)

The classifier was fit on 2,364 labelled requests, and its regularization and per-label thresholds were chosen on a separate validation set of 731 (by cross-validation on the training rows for labels with fewer than 10 validation positives). No RouterArena questions, labels, prompt templates, configs, cached results, other submissions or leaderboard scores were used to build, train, tune or select anything.

Source Train Validation Notes
WMT24++ (both directions, 5 language pairs) 893 304 translation
BIG-Bench Extra Hard 599 200 mostly reasoning tasks; 39 linguini rows are labelled translation
Our earlier question set (from the f-router project) 415 140 generator output and LLM-written problems backed by programs; includes coding and translation rows
Newly written requests (this project) 397 51 includes 237 medicine, law and science requests
BigCodeBench-Hard 60 36 coding

How we built it

We built this router in a copilot workflow with Claude Code: our team set the direction, made the decisions and reviewed each step, and AI coding agents, mainly Claude Code, wrote and ran the code.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ehanmire

Copy link
Copy Markdown
Contributor Author

/evaluate

@github-actions

Copy link
Copy Markdown

Router Evaluation Results

Router: f-router-v2
Dataset Split: full
Evaluator: main @ 00cb25a

RouterArena Metrics

Metric Value
RouterArena Score 0.7666
Accuracy 81.25%
Total Cost $8.805080
Avg Cost per Query $0.001048
Avg Cost per 1K Queries $1.0482
Number of Queries 8400
Abnormal Entries 0
Robustness Score 0.9833

Evaluation completed by RouterArena automated workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant