Skip to main content
Xinference is a powerful and versatile library designed to serve LLMs, speech recognition models, and multimodal models, even on your laptop. It supports a variety of models compatible with GGML, such as chatglm, baichuan, whisper, vicuna, orca, and many others. This notebook demonstrates how to use Xinference with LangChain.

Installation

Install Xinference through PyPI:

Deploy Xinference Locally or in a Distributed Cluster

For local deployment, run xinference. To deploy Xinference in a cluster, first start an Xinference supervisor using the xinference-supervisor. You can also use the option -p to specify the port and -H to specify the host. The default port is 9997. Then, start the Xinference workers using xinference-worker on each server you want to run them on. You can consult the README file from Xinference for more information.

Wrapper

To use Xinference with LangChain, you need to first launch a model. You can use command line interface (CLI) to do so:
A model UID is returned for you to use. Now you can use Xinference with LangChain:

Integrate with a LLMChain

Lastly, terminate the model when you do not need to use it: