Intelligent LLM Infrastructure with Smart Model Selection
Project description
Nordlys
Smart LLM model routing with a checkpoint-based runtime.
Install
uv pip install -e .
Quick Start
from nordlys import Dataset, Trainer, Router, ModelConfig
# 1. Define models
models = [
ModelConfig(id="openai/gpt-4", cost_input=30.0, cost_output=60.0),
ModelConfig(id="openai/gpt-4o-mini", cost_input=0.15, cost_output=0.6),
]
# 2. Build training dataset with binary targets per model
dataset = Dataset.from_list([
{
"id": "1",
"input": "Design a database schema for this app",
"targets": {"openai/gpt-4": 1, "openai/gpt-4o-mini": 0},
},
{
"id": "2",
"input": "Summarize this short changelog",
"targets": {"openai/gpt-4": 0, "openai/gpt-4o-mini": 1},
},
])
# 3. Train checkpoint, then create runtime router
checkpoint = Trainer(models=models).fit(dataset)
router = Router(checkpoint=checkpoint)
result = router.route("Implement this parser")
print(result.model_id)
How It Works
- Clusters similar prompts together
- Learns which model performs best per cluster
- Routes new prompts to the optimal model
Runtime API
router.route(prompt, models=None)routes one prompt.router.route_batch(prompts, models=None)routes a list of prompts.- Optional
modelsfilter restricts candidates to specific model IDs.
Checkpoint I/O
checkpoint.to_json_file("router.json")
loaded = Router(checkpoint="router.json")
Links
Citation
This project is inspired by the Universal Router approach:
@article{universalrouter2025,
title={Universal Router: Foundation Model Routing for Arbitrary Tasks},
author={},
journal={arXiv preprint arXiv:2502.08773},
year={2025},
url={https://arxiv.org/pdf/2502.08773}
}
Paper: Universal Router: Foundation Model Routing for Arbitrary Tasks
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nordlys-0.7.5.tar.gz
(206.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
nordlys-0.7.5-py3-none-any.whl
(81.5 kB
view details)
File details
Details for the file nordlys-0.7.5.tar.gz.
File metadata
- Download URL: nordlys-0.7.5.tar.gz
- Upload date:
- Size: 206.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4ca5fac6abfda0bef7727859457318b1391b0fc3bb0ddf50dd41fb0aa87ebc4
|
|
| MD5 |
7fc6d2262ea56d636583b3373bb45387
|
|
| BLAKE2b-256 |
cbc62a3fe416e1b2c307b3702ab56bc5e218c1367371456f28550f6afbbca3e1
|
File details
Details for the file nordlys-0.7.5-py3-none-any.whl.
File metadata
- Download URL: nordlys-0.7.5-py3-none-any.whl
- Upload date:
- Size: 81.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
394eb48609bac8bcab91c1a445f69b66a9ce9c9c5b5c0b1ebaa7e6276e4bde47
|
|
| MD5 |
c2e8f584375f49c76ee3718c8f883d0f
|
|
| BLAKE2b-256 |
2cf6128dbdd028d0b19b1fff820e354b6f8e115c1584d9ded1992747b45e4f8b
|