MyGit

bentoml/OpenLLM

Fork: 629 Star: 9897 (更新于 2024-10-20 07:35:26)

license: Apache-2.0

Language: Python .

Run any open-source LLMs, such as Llama 3.1, Gemma, as OpenAI compatible API endpoint in the cloud.

最后发布版本: v0.6.13 ( 2024-10-17 21:17:35)

官方网址 GitHub网址

🦾 OpenLLM: Self-Hosting LLMs Made Easy

License: Apache-2.0 Releases CI X Community

OpenLLM allows developers to run any open-source LLMs (Llama 3.2, Qwen2.5, Phi3 and more) or custom models as OpenAI-compatible APIs with a single command. It features a built-in chat UI, state-of-the-art inference backends, and a simplified workflow for creating enterprise-grade cloud deployment with Docker, Kubernetes, and BentoCloud.

Understand the design philosophy of OpenLLM.

Get Started

Run the following commands to install OpenLLM and explore it interactively.

pip install openllm  # or pip3 install openllm
openllm hello

hello

Supported models

OpenLLM supports a wide range of state-of-the-art open-source LLMs. You can also add a model repository to run custom models with OpenLLM.

Model Parameters Quantization Required GPU Start a Server
Llama 3.1 8B - 24G openllm serve llama3.1:8b
Llama 3.1 8B AWQ 4bit 12G openllm serve llama3.1:8b-4bit
Llama 3.1 70B AWQ 4bit 80G openllm serve llama3.1:70b-4bit
Llama 3.2 1B - 12G openllm serve llama3.2:1b
Llama 3.2 3B - 12G openllm serve llama3.2:3b
Llama 3.2 Vision 11B - 80G openllm serve llama3.2:11b-vision
Mistral 7B - 24G openllm serve mistral:7b
Qwen 2.5 1.5B - 12G openllm serve qwen2.5:1.5b
Gemma 2 9B - 24G openllm serve gemma2:9b
Phi3 3.8B - 12G openllm serve phi3:3.8b

...

For the full model list, see the OpenLLM models repository.

Start an LLM server

To start an LLM server locally, use the openllm serve command and specify the model version.

[!NOTE] OpenLLM does not store model weights. A Hugging Face token (HF_TOKEN) is required for gated models.

  1. Create your Hugging Face token here.
  2. Request access to the gated model, such as meta-llama/Meta-Llama-3-8B.
  3. Set your token as an environment variable by running:
    export HF_TOKEN=<your token>
    
openllm serve llama3:8b

The server will be accessible at http://localhost:3000, providing OpenAI-compatible APIs for interaction. You can call the endpoints with different frameworks and tools that support OpenAI-compatible APIs. Typically, you may need to specify the following:

  • The API host address: By default, the LLM is hosted at http://localhost:3000.
  • The model name: The name can be different depending on the tool you use.
  • The API key: The API key used for client authentication. This is optional.

Here are some examples:

OpenAI Python client
from openai import OpenAI

client = OpenAI(base_url='http://localhost:3000/v1', api_key='na')

# Use the following func to get the available models
# model_list = client.models.list()
# print(model_list)

chat_completion = client.chat.completions.create(
    model="meta-llama/Meta-Llama-3-8B-Instruct",
    messages=[
        {
            "role": "user",
            "content": "Explain superconductors like I'm five years old"
        }
    ],
    stream=True,
)
for chunk in chat_completion:
    print(chunk.choices[0].delta.content or "", end="")
LlamaIndex
from llama_index.llms.openai import OpenAI

llm = OpenAI(api_bese="http://localhost:3000/v1", model="meta-llama/Meta-Llama-3-8B-Instruct", api_key="dummy")
...

Chat UI

OpenLLM provides a chat UI at the /chat endpoint for the launched LLM server at http://localhost:3000/chat.

openllm_ui

Chat with a model in the CLI

To start a chat conversation in the CLI, use the openllm run command and specify the model version.

openllm run llama3:8b

Model repository

A model repository in OpenLLM represents a catalog of available LLMs that you can run. OpenLLM provides a default model repository that includes the latest open-source LLMs like Llama 3, Mistral, and Qwen2, hosted at this GitHub repository. To see all available models from the default and any added repository, use:

openllm model list

To ensure your local list of models is synchronized with the latest updates from all connected repositories, run:

openllm repo update

To review a model’s information, run:

openllm model get llama3:8b

Add a model to the default model repository

You can contribute to the default model repository by adding new models that others can use. This involves creating and submitting a Bento of the LLM. For more information, check out this example pull request.

Set up a custom repository

You can add your own repository to OpenLLM with custom models. To do so, follow the format in the default OpenLLM model repository with a bentos directory to store custom LLMs. You need to build your Bentos with BentoML and submit them to your model repository.

First, prepare your custom models in a bentos directory following the guidelines provided by BentoML to build Bentos. Check out the default model repository for an example and read the Developer Guide for details.

Then, register your custom model repository with OpenLLM:

openllm repo add <repo-name> <repo-url>

Note: Currently, OpenLLM only supports adding public repositories.

Deploy to BentoCloud

OpenLLM supports LLM cloud deployment via BentoML, the unified model serving framework, and BentoCloud, an AI inference platform for enterprise AI teams. BentoCloud provides fully-managed infrastructure optimized for LLM inference with autoscaling, model orchestration, observability, and many more, allowing you to run any AI model in the cloud.

Sign up for BentoCloud for free and log in. Then, run openllm deploy to deploy a model to BentoCloud:

openllm deploy llama3:8b

[!NOTE] If you are deploying a gated models, make sure to set HF_TOKEN in enviroment variables

Once the deployment is complete, you can run model inference on the BentoCloud console:

bentocloud_ui

Community

OpenLLM is actively maintained by the BentoML team. Feel free to reach out and join us in our pursuit to make LLMs more accessible and easy to use 👉 Join our Slack community!

Contributing

As an open-source project, we welcome contributions of all kinds, such as new features, bug fixes, and documentation. Here are some of the ways to contribute:

Acknowledgements

This project uses the following open-source projects:

We are grateful to the developers and contributors of these projects for their hard work and dedication.

最近版本更新:(数据更新于 2024-10-20 07:35:04)

2024-10-17 21:17:35 v0.6.13

2024-10-17 20:46:44 v0.6.12

2024-09-30 19:12:41 v0.6.11

2024-08-20 03:25:21 v0.6.10

2024-08-12 19:14:45 v0.6.9

2024-08-12 19:14:07 v0.6.8

2024-08-02 18:32:14 v0.6.7

2024-08-01 14:09:44 v0.6.6

2024-07-15 17:36:51 v0.6.5

2024-07-11 16:30:43 v0.6.3

主题(topics):

bentoml, fine-tuning, llama, llama2, llama3-1, llama3-2, llama3-2-vision, llm, llm-inference, llm-ops, llm-serving, llmops, mistral, mlops, model-inference, open-source-llm, openllm, vicuna

bentoml/OpenLLM同语言 Python最近更新仓库

2024-11-05 15:03:24 Cinnamon/kotaemon

2024-11-05 11:00:51 home-assistant/core

2024-11-04 23:11:11 DS4SD/docling

2024-11-04 10:56:18 open-compass/opencompass

2024-11-04 08:51:21 yt-dlp/yt-dlp

2024-11-02 04:45:40 princeton-vl/infinigen