Skip to main content

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

  1. Clusters similar prompts together
  2. Learns which model performs best per cluster
  3. 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 models filter 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


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.1.tar.gz (207.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nordlys-0.7.1-py3-none-any.whl (80.7 kB view details)

Uploaded Python 3

File details

Details for the file nordlys-0.7.1.tar.gz.

File metadata

  • Download URL: nordlys-0.7.1.tar.gz
  • Upload date:
  • Size: 207.1 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

Hashes for nordlys-0.7.1.tar.gz
Algorithm Hash digest
SHA256 d0ca4bdf9fd245a57762fff1b61036dc53a83dbcf0eba15a6fa63573f9409c6a
MD5 74752ce668419822cb576d2270708b52
BLAKE2b-256 ec6ba2b247a17df1db00b6c1cd1b32c1f956d6dc20d86301151500a9069b6a69

See more details on using hashes here.

File details

Details for the file nordlys-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: nordlys-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 80.7 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

Hashes for nordlys-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 adab54782f0c32b4adf0e151a3e7c0ddc49105625ec4f575d4f653b76ddb6380
MD5 1907ff4922f0c2b85d9f93aa6d6f1128
BLAKE2b-256 be307498f86d79417cdb34a63c5e54ffea0cb958ea0e0f36c26e7c65bdb40378

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page