predibase/lorax

★ 3,832⑂ 0

Multi-LoRA inference server that scales to 1000s of fine-tuned LLMs

About predibase/lorax

predibase/lorax is an open-source project on GitHub, mainly written in Python. Multi-LoRA inference server that scales to 1000s of fine-tuned LLMs It currently holds 3,832 stars and 0 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the AI Models & LLM Tools board.

GitHub Repository Details

Repository predibase/lorax · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

https://github.com/predibase/lorax/blob/HEAD/LoRAX Logo

_LoRAX: Multi-LoRA inference server that scales to 1000s of fine-tuned LLMs_

License Artifact Hub

LoRAX (LoRA eXchange) is a framework that allows users to serve thousands of fine-tuned models on a single GPU, dramatically reducing the cost of serving without compromising on throughput or latency.

📖 Table of contents

🌳 Features

🏠 Models

Serving a fine-tuned model with LoRAX consists of two components:

LoRAX supports a number of Large Language Models as the base model including Llama (including CodeLlama), Mistral (including Zephyr), and Qwen. See Supported Architectures for a complete list of supported base models.

Base models can be loaded in fp16 or quantized with bitsandbytes, GPT-Q, or AWQ.

Supported adapters include LoRA adapters trained using the PEFT and Ludwig libraries. Any of the linear layers in the model can be adapted via LoRA and loaded in LoRAX.

🏃‍♂️ Getting Started

We recommend starting with our pre-built Docker image to avoid compiling custom CUDA kernels and other dependencies.

Requirements

The minimum system requirements need to run LoRAX include:

Launch LoRAX Server

Prerequisites

Install nvidia-container-toolkit Then
model=mistralai/Mistral-7B-Instruct-v0.1
volume=$PWD/data

docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data \ ghcr.io/predibase/lorax:main --model-id $model

For a full tutorial including token streaming and the Python client, see Getting Started - Docker.

Prompt via REST API

Prompt base LLM:

curl 127.0.0.1:8080/generate \
    -X POST \
    -d '{
        "inputs": "[INST] Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May? [/INST]",
        "parameters": {
            "max_new_tokens": 64
        }
    }' \
    -H 'Content-Type: application/json'

Prompt a LoRA adapter:

curl 127.0.0.1:8080/generate \
    -X POST \
    -d '{
        "inputs": "[INST] Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May? [/INST]",
        "parameters": {
            "max_new_tokens": 64,
            "adapter_id": "vineetsharma/qlora-adapter-Mistral-7B-Instruct-v0.1-gsm8k"
        }
    }' \
    -H 'Content-Type: application/json'

See Reference - REST API for full details.

Prompt via Python Client

Install:

pip install lorax-client

Run:

from lorax import Client

client = Client("http://127.0.0.1:8080")

Prompt the base LLM

prompt = "[INST] Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May? [/INST]" print(client.generate(prompt, max_new_tokens=64).generated_text)

Prompt a LoRA adapter

adapter_id = "vineetsharma/qlora-adapter-Mistral-7B-Instruct-v0.1-gsm8k" print(client.generate(prompt, max_new_tokens=64, adapter_id=adapter_id).generated_text)

See Reference - Python Client for full details.

For other ways to run LoRAX, see Getting Started - Kubernetes, Getting Started - SkyPilot, and Getting Started - Local.

Chat via OpenAI API

LoRAX supports multi-turn chat conversations combined with dynamic adapter loading through an OpenAI compatible API. Just specify any adapter as the model parameter.

from openai import OpenAI

client = OpenAI( api_key="EMPTY", base_url="http://127.0.0.1:8080/v1", )

resp = client.chat.completions.create( model="alignment-handbook/zephyr-7b-dpo-lora", messages=[ { "role": "system", "content": "You are a friendly chatbot who always responds in the style of a pirate", }, {"role": "user", "content": "How many helicopters can a human eat in one sitting?"}, ], max_tokens=100, ) print("Response:", resp.choices[0].message.content)

See OpenAI Compatible API for details.

Next steps

Here are some other interesting Mistral-7B fine-tuned models to try out:

You can find more LoRA adapters here, or try fine-tuning your own with PEFT or Ludwig.

🙇 Acknowledgements

LoRAX is built on top of HuggingFace's text-generation-inference, forked from v0.9.4 (Apache 2.0).

We'd also like to acknowledge Punica for their work on the SGMV kernel, which is used to speed up multi-adapter inference under heavy load.

🗺️ Roadmap

Our roadmap is tracked here.

GitHub Stars & Activity

3,832Stars
0Forks
0Open issues
PythonLanguage

GitHub Popularity

GitHub stars3,832
Forks0
Open issues0
Primary languagePython
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

1

huggingface / transformers

Python★ 166,453⑂ 0
2

TauricResearch / TradingAgents

Python★ 107,797⑂ 0
3

PaddlePaddle / PaddleOCR

Python★ 89,891⑂ 0
4

unslothai / unsloth

Python★ 76,497⑂ 0
5

hiyouga / LlamaFactory

Python★ 74,932⑂ 0
6

headroomlabs-ai / headroom

Python★ 73,265⑂ 0
7

ZhuLinsen / daily_stock_analysis

Python★ 65,382⑂ 0
8

BerriAI / litellm

Python★ 59,247⑂ 0

More AI Rankings