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
Built Distribution
File details
Details for the file rorf-0.1.2.tar.gz
.
File metadata
- Download URL: rorf-0.1.2.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Linux/5.15.0-1068-aws
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45a6beef67382b179dff07a0f770301a876d71bda9e4adbf2b1f13cc6bd5729e |
|
MD5 | 97adeaf570d8b090297c44e09a40b8c0 |
|
BLAKE2b-256 | b99e212429a4f91b032354f0714fea7790a3b2a1b54fdeea1a2b1f34a241f111 |
File details
Details for the file rorf-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: rorf-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Linux/5.15.0-1068-aws
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcfa5dc712de545e686ab6502d3c1b745ed280766b2f2ddd43839047a5de8680 |
|
MD5 | f52fa960f6beadd7efdb07b2c6b89efe |
|
BLAKE2b-256 | 8281c7ea276c63ebca8235a254c6da63435ae1847f3713cddb43c089152099f1 |