Skip to page content
SAVRN
Search Plan a project

Open-weight model

RouteFM

by Guannan Lai AIGNLAI/RouteFM

RouteFM is an open-weight model from Guannan Lai, released under Apache License 2.0. Its published files total 230.6 MB. It draws 65 downloads a month.

RouteFM is a pretrained in-context model router. Given an anonymous candidate pool, behavioral observations of candidate quality and relative cost, and a new target query, it predicts the target-specific quality and relative cost of every candidate.

Parameters—
Context—
Weights191.0 MB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads65

Model Card

By Guannan Lai, published under apache-2.0, revision 13cfa99f3c2e.

RouteFM is a pretrained in-context model router. Given an anonymous candidate pool, behavioral observations of candidate quality and relative cost, and a new target query, it predicts the target-specific quality and relative cost of every candidate. A frozen RouteFM adapts to new routing environments through context alone, without target-domain parameter updates. On MMR-Bench, which is excluded from pretraining, RouteFM outperforms the strongest non-RouteFM baseline by 2.23 quality points with only eight observations per candidate. 90-second introductions in English and Chinese, with matching narration, on-screen text, and captions. Concept footage and narration are AI-generated; method…

Read Guannan Lai's full model card

RouteFM: Pretrain Once, Route Anywhere

Pretrain Once, Route Anywhere: Towards a Foundation Model for LLM Routing
Guannan Lai and Han-Jia Ye · Nanjing University

Project page · Live demo · Run in Colab · Routing collection · GitHub · Paper · PDF

RouteFM is a pretrained in-context model router. Given an anonymous candidate pool, behavioral observations of candidate quality and relative cost, and a new target query, it predicts the target-specific quality and relative cost of every candidate. A frozen RouteFM adapts to new routing environments through context alone, without target-domain parameter updates.

On MMR-Bench, which is excluded from pretraining, RouteFM outperforms the strongest non-RouteFM baseline by 2.23 quality points with only eight observations per candidate.

Video overview

90-second introductions in English and Chinese, with matching narration, on-screen text, and captions.

English

Download English MP4 · English subtitles

中文

下载中文版 MP4 · 中文字幕

Watch on the project page · All video assets and checksums

Concept footage and narration are AI-generated; method diagrams and results use original paper materials. The final composition is 1080p; the concept footage is native 720p.

Interactive demo

The RouteFM demo provides a free interactive explorer for switching among environments, target queries, and context budgets. Its predictions were precomputed with the released RouteFM-BGE checkpoint; the built-in behavioral contexts are synthetic illustrations, not benchmark records. For real inference with arbitrary target queries and custom context, use the one-click Colab or run the full Gradio app in the GitHub repository.

Model description

RouteFM turns LLM routing from repeated local fitting into global routing pretraining. Candidate identities, providers, parameter counts, and other explicit identity features are never exposed to the router. Instead, it:

  1. builds a compact capability profile for every anonymous candidate from behavioral context;
  2. retrieves complementary evidence from both the profile and the original observations for each target query;
  3. compares the current pool jointly with a permutation-equivariant Transformer; and
  4. predicts target-specific quality and relative cost.

The released architecture uses 24 capability tokens, hidden dimension 256, and episodic pretraining with candidate-slot permutation. The training objective combines point prediction, pairwise ranking, and routing regret. See the paper for the complete method.

Released variants

Variant Compatible query encoder Dimension Query modality Parameters
RouteFM-Qwen Qwen3-VL-Embedding-8B 4096 Joint text and image 12,781,059
RouteFM-BGE BAAI/bge-base-en-v1.5, CLS pooling 768 Text only 11,070,467

Each variant contains a canonical model.safetensors and config.json. The legacy/ directory contains the exact PyTorch checkpoint bytes from the GitHub v1.0.0 release. manifest.json records sizes, configurations, immutable revisions, and SHA-256 digests. The root config.json indexes both variants and is the standard Hugging Face query file used for repository download statistics.

The query encoders are frozen external feature extractors. They are not included in this repository, and RouteFM is not a fine-tune of either encoder. Users must obtain the encoders or compatible embedding services separately and comply with their licenses and access terms.

Usage

Install the official package from PyPI:

python -m pip install "routefm-router[bge]"

The package downloads the correct safetensors checkpoint from the immutable Hub artifact revision, validates its SHA-256 digest, and stores it in the standard Hugging Face cache.

routefm-predict --encoder qwen --input my_episode.npz \
  --output predictions.json --device cpu

To prefetch both released variants for offline jobs:

routefm-download --encoder all

The input schema, embedding instructions, observation masks, local checkpoint overrides, and output format are documented in docs/CUSTOM_DATA.md.

Training

Both variants were trained from random initialization in one continuous 10,000-update run. All router modules were trained jointly, while the external query encoder remained frozen. The configured pretraining mixture is LLMRouterBench 45%, RouterBench 25%, RouterEval 25%, and MixInstruct 5%. MMR-Bench is not a pretraining source.

The complete data contract, source proportions, episode construction, curriculum, and optimization commands are available in docs/PRETRAINING.md. Underlying third-party datasets and embedding models are not redistributed.

Evaluation

The paper evaluates the frozen Qwen-based RouteFM on held-out RouterEval queries and on cross-modal transfer to MMR-Bench.

Evaluation K=8 K=16 K=32 K=64 Large
RouterEval (in-domain) 0.6192 0.6433 0.6627 0.6611 —
MMR-Bench (cross-modal) 0.7323 0.7457 0.7487 0.7504 0.7614

These are the paper's matched-protocol results. MMR-Bench uses dataset-wise five-fold context/target splits in the limited-observation setting and a 40%/60% split in the large-observation setting. RouteFM remains frozen and uses no evaluation labels for parameter updates.

The GitHub release additionally publishes a fixed seed-31010 split for artifact auditing. That split is retrospective and post-selected, differs from the paper's five-fold protocol, and should not be compared directly with the table above. Its exact IDs, hashes, aggregation rules, and reference outputs are documented in docs/MMRBENCH_V1.md.

Intended use and limitations

RouteFM is intended for research on routing among a user-supplied candidate pool with observed context outcomes. It does not call candidate models, generate query embeddings, or establish that a candidate is safe or suitable.

  • Candidate order and embedding family must remain consistent within an episode.
  • Each candidate needs at least one valid context observation.
  • Predicted cost is relative, not a calibrated monetary or latency estimate.
  • The default decision rule ignores predicted cost and selects maximum predicted quality.
  • Performance may change across encoder revisions, languages, domains, candidate pools, and context sizes outside the training distribution.

License

RouteFM source code and released routing weights are licensed under Apache-2.0. Third-party assets retain their own licenses and terms; see THIRD_PARTY_NOTICES.md.

Citation

If you use RouteFM in your research, please cite:

@misc{lai2026pretrainoncerouteanywhere,
  title         = {Pretrain Once, Route Anywhere: Towards a Foundation Model for LLM Routing},
  author        = {Guannan Lai and Han-Jia Ye},
  year          = {2026},
  eprint        = {2609.37362},
  archivePrefix = {arXiv},
  primaryClass  = {cs.AI},
  url           = {https://arxiv.org/abs/2609.37362}
}

Identity and Version

Repository
AIGNLAI/RouteFM
Publisher
Guannan Lai
Task
Not stated by the source
Modality
Other
Library
routefm-router
Parameters
Not stated by the source
Languages
llm-routing
Revision
13cfa99f3c2ebda4872386f7d94ee56b25b4b48d
First published
2026-09-29
Last updated
2026-10-14

Files and Weights

26 files, 230.6 MB in total. The weights are 4 files totalling 191.0 MB in pt, safetensors.

Weights4 files · 191.0 MB
Configuration5 files · 8.1 KB
Documentation4 files · 21.6 KB
Other12 files · 39.6 MB
Repository1 file · 1.9 KB
Every file
FileTypeSizeSHA-256
bge/model.safetensorsWeights44.3 MB 3245698f2f6b
legacy/routefm_bge.ptWeights44.4 MB 0f7ce1b26949
legacy/routefm_qwen.ptWeights51.2 MB e28d6203e99c
qwen/model.safetensorsWeights51.1 MB 881b648ead20
bge/config.jsonConfiguration1.3 KB —
config.jsonConfiguration479 B —
manifest.jsonConfiguration3.1 KB —
qwen/config.jsonConfiguration2.2 KB —
videos/routefm-video-manifest.jsonConfiguration1.1 KB —
LICENSEDocumentation11.4 KB —
NOTICEDocumentation109 B —
README.mdDocumentation9.2 KB —
THIRD_PARTY_NOTICES.mdDocumentation915 B —
CITATION.cffOther870 B —
assets/intro_new.pngOther400.8 KB 7a6e8f5c6088
assets/method.pngOther309.7 KB 88bbe9b188a4
videos/SHA256SUMSOther756 B —
videos/routefm-en-poster.pngOther554.4 KB e6d563ea47a6
videos/routefm-en.mp4Other18.8 MB 704ec7ea9337
videos/routefm-en.srtOther1.6 KB —
videos/routefm-en.vttOther1.4 KB —
videos/routefm-zh-poster.pngOther548.1 KB 62260501a663
videos/routefm-zh.mp4Other18.9 MB 3637b8351fce
videos/routefm-zh.srtOther1.9 KB —
videos/routefm-zh.vttOther1.7 KB —
.gitattributesRepository1.9 KB —

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
191.0 MB
Download from Guannan Lai

Released by Guannan Lai through its official repository on Hugging Face. Read the license.

Built From

  • Described by arXiv:2609.37362

Memory Requirements

PrecisionWeights in memory
As published191.0 MB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About RouteFM

Can I use RouteFM commercially?

Yes. RouteFM is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.