RouteFM
Official Python package for Pretrain Once, Route Anywhere: Towards a Foundation Model for LLM Routing.
RouteFM is a pretrained router that adapts a frozen model to new tasks and candidate pools through behavioral Context. Candidate identities are not used as features: each candidate is characterized by a small number of observed query, quality, and relative-cost tuples.
Install
RouteFM requires Python 3.10 or newer. Install the BGE text interface with:
python -m pip install "routefm-router[bge]"
The RouteFM package is lightweight; released routing checkpoints remain on Hugging Face and are downloaded and checksum-verified on first use. The built-in text API also pins the compatible BGE encoder revision.
Route text in Python
from routefm import RouteFMRouter
router = RouteFMRouter.from_pretrained(encoder="bge", device="cpu")
router.set_context({
"small-model": [
{"query": "What is 2 + 2?", "score": 1.0, "cost": 0.01},
{"query": "Summarize this paragraph.", "score": 0.7, "cost": 0.02},
],
"large-model": [
{"query": "What is 2 + 2?", "score": 1.0, "cost": 0.10},
{"query": "Summarize this paragraph.", "score": 0.95, "cost": 0.20},
],
})
decision = router.route("Prove that there are infinitely many primes.")
print(decision.model_name)
print(decision.predicted_scores)
The default decision rule selects the highest predicted quality. Predicted cost is relative rather than calibrated currency or latency and is not used by that rule. No RouteFM parameter update occurs.
For precomputed BGE or Qwen multimodal embeddings, use
RouteFMRouter.predict_arrays(...). The existing routefm-predict CLI and
.npz workflow remain supported.
Resources
- Paper
- Source and documentation
- Frozen checkpoints and model card
- Custom-data schema
- Pretraining guide
Citation
@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}
}
RouteFM source code and released routing weights use the Apache License 2.0. Third-party encoders and datasets retain their own licenses and terms.
Metadata
Release files for routefm-router 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| routefm_router-1.1.0.tar.gz | 90.0 kB | With provenance | Details for routefm_router-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| routefm_router-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for routefm_router-1.1.0-py3-none-any.whl |
Total release size: 184.7 kB
Release files / routefm_router-1.1.0.tar.gz
| Download URL | routefm_router-1.1.0.tar.gz |
|---|---|
| Size | 90.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e713f360539e667959aca36ba9cf351466945905c6ad3b779fa5990dcc7cb9c7
|
|
BLAKE2b-256 checksum How to use checksums |
d77d2f670f2049647b70b49c7ea94b1a826a8b40c9110242dbb96ba9ebc3f1fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / routefm_router-1.1.0-py3-none-any.whl
| Download URL | routefm_router-1.1.0-py3-none-any.whl |
|---|---|
| Size | 94.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b89b2e32f1616436332defde3af552b7009469951d8c59e019446a82a890398c
|
|
BLAKE2b-256 checksum How to use checksums |
7c0cca210953ddc05f015afa499fe26811adf64e78be0ee44d8493098d92670d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logSecurity for routefm-router 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for routefm_router-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.