Skip to main content

Model Serving Made Easy

Project description

xorbits

Xorbits Inference: Model Serving Made Easy 🤖

PyPI Latest Release License Build Status Slack Twitter

English | 中文介绍 | 日本語


Xorbits Inference(Xinference) is a powerful and versatile library designed to serve language, speech recognition, and multimodal models. With Xorbits Inference, you can effortlessly deploy and serve your or state-of-the-art built-in models using just a single command. Whether you are a researcher, developer, or data scientist, Xorbits Inference empowers you to unleash the full potential of cutting-edge AI models.

🔥 Hot Topics

Framework Enhancements

  • Incorporate vLLM: #445
  • Embedding model support: #418
  • LoRA support: #271
  • Multi-GPU support for PyTorch models: #226
  • Xinference dashboard: #93

New Models

Integrations

  • Dify: an LLMOps platform that enables developers (and even non-developers) to quickly build useful applications based on large language models, ensuring they are visual, operable, and improvable.
  • Chatbox: a desktop client for multiple cutting-edge LLM models, available on Windows, Mac and Linux.

Key Features

🌟 Model Serving Made Easy: Simplify the process of serving large language, speech recognition, and multimodal models. You can set up and deploy your models for experimentation and production with a single command.

⚡️ State-of-the-Art Models: Experiment with cutting-edge built-in models using a single command. Inference provides access to state-of-the-art open-source models!

🖥 Heterogeneous Hardware Utilization: Make the most of your hardware resources with ggml. Xorbits Inference intelligently utilizes heterogeneous hardware, including GPUs and CPUs, to accelerate your model inference tasks.

⚙️ Flexible API and Interfaces: Offer multiple interfaces for interacting with your models, supporting RPC, RESTful API(compatible with OpenAI API), CLI and WebUI for seamless management and monitoring.

🌐 Distributed Deployment: Excel in distributed deployment scenarios, allowing the seamless distribution of model inference across multiple devices or machines.

🔌 Built-in Integration with Third-Party Libraries: Xorbits Inference seamlessly integrates with popular third-party libraries including LangChain, LlamaIndex, Dify, and Chatbox.

Getting Started

Xinference can be installed via pip from PyPI. It is highly recommended to create a new virtual environment to avoid conflicts.

Installation

$ pip install "xinference"

xinference installs basic packages for serving models.

Installation with GGML

To serve ggml models, you need to install the following extra dependencies:

$ pip install "xinference[ggml]"

If you want to achieve acceleration on different hardware, refer to the installation documentation of the corresponding package.

Installation with PyTorch

To serve PyTorch models, you need to install the following extra dependencies:

$ pip install "xinference[pytorch]"

Installation with all dependencies

If you want to serve all the supported models, install all the dependencies:

$ pip install "xinference[all]"

Deployment

You can deploy Xinference locally with a single command or deploy it in a distributed cluster.

Local

To start a local instance of Xinference, run the following command:

$ xinference

Distributed

To deploy Xinference in a cluster, you need to start a Xinference supervisor on one server and Xinference workers on the other servers. Follow the steps below:

Starting the Supervisor: On the server where you want to run the Xinference supervisor, run the following command:

$ xinference-supervisor -H "${supervisor_host}"

Replace ${supervisor_host} with the actual host of your supervisor server.

Starting the Workers: On each of the other servers where you want to run Xinference workers, run the following command:

$ xinference-worker -e "http://${supervisor_host}:9997"

Once Xinference is running, an endpoint will be accessible for model management via CLI or Xinference client.

  • For local deployment, the endpoint will be http://localhost:9997.
  • For cluster deployment, the endpoint will be http://${supervisor_host}:9997, where ${supervisor_host} is the hostname or IP address of the server where the supervisor is running.

You can also view a web UI using the Xinference endpoint to chat with all the builtin models.

web UI

Xinference CLI

Xinference provides a command line interface (CLI) for model management. Here are some useful commands:

  • Launch a model (a model UID will be returned): xinference launch
  • List running models: xinference list
  • List all the supported models: xinference registrations
  • Terminate a model: xinference terminate --model-uid ${model_uid}

Xinference Client

Xinference also provides a client for managing and accessing models programmatically:

from xinference.client import Client

client = Client("http://localhost:9997")
model_uid = client.launch_model(model_name="chatglm2")
model = client.get_model(model_uid)

chat_history = []
prompt = "What is the largest animal?"
model.chat(
    prompt,
    chat_history,
    generate_config={"max_tokens": 1024}
)

Result:

{
  "id": "chatcmpl-8d76b65a-bad0-42ef-912d-4a0533d90d61",
  "model": "56f69622-1e73-11ee-a3bd-9af9f16816c6",
  "object": "chat.completion",
  "created": 1688919187,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The largest animal that has been scientifically measured is the blue whale, which has a maximum length of around 23 meters (75 feet) for adult animals and can weigh up to 150,000 pounds (68,000 kg). However, it is important to note that this is just an estimate and that the largest animal known to science may be larger still. Some scientists believe that the largest animals may not have a clear \"size\" in the same way that humans do, as their size can vary depending on the environment and the stage of their life."
      },
      "finish_reason": "None"
    }
  ],
  "usage": {
    "prompt_tokens": -1,
    "completion_tokens": -1,
    "total_tokens": -1
  }
}

See examples for more examples.

Builtin models

To view the builtin models, run the following command:

$ xinference registrations
Type Name Language Ability
LLM baichuan ['en', 'zh'] ['embed', 'generate']
LLM baichuan-2 ['en', 'zh'] ['embed', 'generate']
LLM baichuan-chat ['en', 'zh'] ['embed', 'chat']
LLM baichuan-2-chat ['en', 'zh'] ['embed', 'chat']
LLM chatglm ['en', 'zh'] ['embed', 'chat']
LLM chatglm2 ['en', 'zh'] ['embed', 'chat']
LLM chatglm2-32k ['en', 'zh'] ['embed', 'chat']
LLM code-llama ['en'] ['generate']
LLM code-llama-instruct ['en'] ['chat']
LLM code-llama-python ['en'] ['generate']
LLM falcon ['en'] ['embed', 'generate']
LLM falcon-instruct ['en'] ['embed', 'chat']
LLM glaive-coder ['en'] ['chat']
LLM gpt-2 ['en'] ['generate']
LLM internlm-7b ['en', 'zh'] ['embed', 'generate']
LLM internlm-chat-7b ['en', 'zh'] ['embed', 'chat']
LLM internlm-chat-20b ['en', 'zh'] ['embed', 'chat']
LLM llama-2 ['en'] ['embed', 'generate']
LLM llama-2-chat ['en'] ['embed', 'chat']
LLM opt ['en'] ['embed', 'generate']
LLM orca ['en'] ['embed', 'chat']
LLM qwen-chat ['en', 'zh'] ['embed', 'chat']
LLM starchat-beta ['en'] ['embed', 'chat']
LLM starcoder ['en'] ['generate']
LLM starcoderplus ['en'] ['embed', 'generate']
LLM vicuna-v1.3 ['en'] ['embed', 'chat']
LLM vicuna-v1.5 ['en'] ['embed', 'chat']
LLM vicuna-v1.5-16k ['en'] ['embed', 'chat']
LLM wizardlm-v1.0 ['en'] ['embed', 'chat']
LLM wizardmath-v1.0 ['en'] ['embed', 'chat']
LLM OpenBuddy ['en', 'zh'] ['embed', 'chat']

For in-depth details on the built-in models, please refer to built-in models.

NOTE:

  • Xinference will download models automatically for you, and by default the models will be saved under ${USER}/.xinference/cache.
  • If you have trouble downloading models from the Hugging Face, run export XINFERENCE_MODEL_SRC=modelscope to download models from modelscope. Models supported by modelscope:
    • llama-2
    • llama-2-chat
    • baichuan-2
    • baichuan-2-chat
    • chatglm2
    • chatglm2-32k
    • internlm-chat-20b

Custom models

Please refer to custom models.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xinference-0.5.1.tar.gz (11.2 MB view details)

Uploaded Source

Built Distribution

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

xinference-0.5.1-py3-none-any.whl (20.5 MB view details)

Uploaded Python 3

File details

Details for the file xinference-0.5.1.tar.gz.

File metadata

  • Download URL: xinference-0.5.1.tar.gz
  • Upload date:
  • Size: 11.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for xinference-0.5.1.tar.gz
Algorithm Hash digest
SHA256 7db0516d06f6a62cd147504143fe33d430de8b158b7960ecadd9178b3e0a7a69
MD5 fd285d1cefd1cdecce5bb418213ee785
BLAKE2b-256 5e1b625ea381b0e3e362181c73e3973cbdd0bf5705059809493011511826b34f

See more details on using hashes here.

File details

Details for the file xinference-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: xinference-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 20.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for xinference-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60011d0bf7de1a8adf80c27013c25b0aa31158abd5cbdf871803f12964e088fd
MD5 42db228106d5428c8f1cb96cb42385c7
BLAKE2b-256 72553b0cd68a304ee0ce60628bf4baaa75edc2eea9524ac748bea11c293b5ad8

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