Skip to main content

No project description provided

Project description

RoRF - Routing on Random Forests

RoRF is a framework for training and serving random forest-based LLM routers.

Our core features include:

  • 12 pre-trained routers across 6 model pairs and 2 embedding models (jinaai/jina-embeddings-v3, voyageai/voyage-large-2-instruct) that reduce costs while either maintaining or improving performance.
  • Our pre-trained routers outperform existing routing solutions, including open-source and commercial offerings.

Installation

PyPI

pip install rorf

Source

git clone https://github.com/Not-Diamond/RoRF
cd RoRF
pip install -e .

Quickstart

We adopt RouteLLM's Controller to allow users to replace their existing routing setups with RoRF. Our Controller requires a router (available either locally or on Huggingface Hub) that routes between model_a (usually stronger/expensive) and model_b (usually weaker/cheaper). Our release includes 6 model pairs between different models and providers as described in Model Support.

from rorf.controller import Controller

router = Controller(
    router="notdiamond/rorf-jina-llama31405b-llama3170b",
    model_a="llama-3.1-405b-instruct",
    model_b="llama-3.1-70b-instruct",
    threshold=0.3,
)

recommended_model = router.route("What is the meaning of life?")
print(f"Recommended model: {recommended_model}")

We also provide a threshold parameter that determines the percentage of calls made to each model, allowing users to decide their own cost vs performance tradeoffs.

Training RoRF

We include our training framework for RoRF so that users can train custom routers on their own data and model pairs. trainer.py is the entry-point for training, and run_trainer.sh provides an example command to train a model router for llama-3.1-405b-instruct vs llama-3.1-70b-instruct on top of Jina AI's embeddings.

Motivation

Our experiments show that:

  • Routing between a pair of strong and weak models can reduce costs while maintaining the strong model's performance.
  • Routing between a pair of two strong models can reduce costs while outperforming both individual models.

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

rorf-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

rorf-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file rorf-0.1.1.tar.gz.

File metadata

  • Download URL: rorf-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/5.15.0-1068-aws

File hashes

Hashes for rorf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c771621562c7adceb6e773e2706a8457e7db6563c3316c58ccdc845501189d56
MD5 67d4b99b8958c33d8c016e915a8ce441
BLAKE2b-256 cb7ebd9b678013d2fb08bef29f7312144c5308400ba4bc57863a70ff1017530a

See more details on using hashes here.

File details

Details for the file rorf-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: rorf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/5.15.0-1068-aws

File hashes

Hashes for rorf-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c7030b7f4ba62ebe6be4341018a4b2229c601748873f232c9a79038fab5d8b7
MD5 564471c55ec329e6e4f15089e85cbd3f
BLAKE2b-256 e47add61905324867081d76c03d3a0e9c078a11548c97b4a6fef6b099e93ebc1

See more details on using hashes here.

Supported by

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