Install
Method 1: With pip
Method 2: From source
- Clone this repository and navigate to the FastChat folder
If you are running on Mac:
- Install Package
Model Weights
Vicuna Weights
Vicuna is based on LLaMA and should be used under LLaMA’s model license.
You can use the commands below to start chatting. It will automatically download the weights from Hugging Face repos. See more command options and how to handle out-of-memory in the “Inference with Command Line Interface” section below.
NOTE: transformers>=4.31
is required for 16K versions.
Size | Chat Command | Hugging Face Repo |
---|---|---|
7B | python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 | lmsys/vicuna-7b-v1.5 |
7B-16k | python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5-16k | lmsys/vicuna-7b-v1.5-16k |
13B | python3 -m fastchat.serve.cli --model-path lmsys/vicuna-13b-v1.5 | lmsys/vicuna-13b-v1.5 |
13B-16k | python3 -m fastchat.serve.cli --model-path lmsys/vicuna-13b-v1.5-16k | lmsys/vicuna-13b-v1.5-16k |
33B | python3 -m fastchat.serve.cli --model-path lmsys/vicuna-33b-v1.3 | lmsys/vicuna-33b-v1.3 |
Old weights: see vicuna_weights_version for all versions of weights and their differences.
LongChat
We release LongChat models under LLaMA’s model license.
Size | Chat Command | Hugging Face Repo |
---|---|---|
7B | python3 -m fastchat.serve.cli --model-path lmsys/longchat-7b-32k-v1.5 | lmsys/longchat-7b-32k |
FastChat-T5
You can use the commands below to chat with FastChat-T5. It will automatically download the weights from Hugging Face repos.
Size | Chat Command | Hugging Face Repo |
---|---|---|
3B | python3 -m fastchat.serve.cli --model-path lmsys/fastchat-t5-3b-v1.0 | lmsys/fastchat-t5-3b-v1.0 |
Inference with Command Line Interface
(Experimental Feature: You can specify --style rich
to enable rich text output and better text streaming quality for some non-ASCII content. This may not work properly on certain terminals.)
Supported Models
FastChat supports a wide range of models, including LLama 2, Vicuna, Alpaca, Baize, ChatGLM, Dolly, Falcon, FastChat-T5, GPT4ALL, Guanaco, MTP, OpenAssistant, RedPajama, StableLM, WizardLM, and more.
See a complete list of supported models and instructions to add a new model here.
Single GPU
The command below requires around 14GB of GPU memory for Vicuna-7B and 28GB of GPU memory for Vicuna-13B.
See the “Not Enough Memory” section below if you do not have enough memory.
--model-path
can be a local folder or a Hugging Face repo name.
Multiple GPUs
You can use model parallelism to aggregate GPU memory from multiple GPUs on the same machine.
Tips:
Sometimes the “auto” device mapping strategy in huggingface/transformers does not perfectly balance the memory allocation across multiple GPUs.
You can use --max-gpu-memory
to specify the maximum memory per GPU for storing model weights.
This allows it to allocate more memory for activations, so you can use longer context lengths or larger batch sizes. For example,
CPU Only
This runs on the CPU only and does not require GPU. It requires around 30GB of CPU memory for Vicuna-7B and around 60GB of CPU memory for Vicuna-13B.
Use Intel AI Accelerator AVX512_BF16/AMX to accelerate CPU inference.
Metal Backend (Mac Computers with Apple Silicon or AMD GPUs)
Use --device mps
to enable GPU acceleration on Mac computers (requires torch >= 2.0).
Use --load-8bit
to turn on 8-bit compression.
Vicuna-7B can run on a 32GB M1 Macbook with 1 - 2 words / second.
Intel XPU (Intel Data Center and Arc A-Series GPUs)
Install the Intel Extension for PyTorch. Set the OneAPI environment variables:
Use --device xpu
to enable XPU/GPU acceleration.
Vicuna-7B can run on an Intel Arc A770 16GB.
Ascend NPU (Huawei AI Processor)
Install the Ascend PyTorch Adapter. Set the CANN environment variables:
Use --device npu
to enable NPU acceleration.
Vicuna-7B/13B can run on an Ascend 910B NPU 60GB.
Not Enough Memory
If you do not have enough memory, you can enable 8-bit compression by adding --load-8bit
to commands above.
This can reduce memory usage by around half with slightly degraded model quality.
It is compatible with the CPU, GPU, and Metal backend.
Vicuna-13B with 8-bit compression can run on a single GPU with 16 GB of VRAM, like an Nvidia RTX 3090, RTX 4080, T4, V100 (16GB), or an AMD RX 6800 XT.
In addition to that, you can add --cpu-offloading
to commands above to offload weights that don’t fit on your GPU onto the CPU memory.
This requires 8-bit compression to be enabled and the bitsandbytes package to be installed, which is only available on linux operating systems.
More Platforms and Quantization
- For AMD GPU users, please install ROCm and the ROCm version of PyTorch before you install FastChat. See also this post.
- FastChat supports GPTQ 4bit inference with GPTQ-for-LLaMa. See gptq.
- FastChat supports AWQ 4bit inference with mit-han-lab/llm-awq. See awq.
- MLC LLM, backed by TVM Unity compiler, deploys Vicuna natively on phones, consumer-class GPUs and web browsers via Vulkan, Metal, CUDA and WebGPU.
Serving with Web GUI
To serve using the web UI, you need three main components: web servers that interface with users, model workers that host one or more models, and a controller to coordinate the webserver and model workers. You can learn more about the architecture here.
Here are the commands to follow in your terminal:
Launch the controller
This controller manages the distributed workers.
Launch the model worker(s)
Wait until the process finishes loading the model and you see “Uvicorn running on …”. The model worker will register itself to the controller .
To ensure that your model worker is connected to your controller properly, send a test message using the following command:
You will see a short output.
Launch the Gradio web server
This is the user interface that users will interact with.
By following these steps, you will be able to serve your models using the web UI. You can open your browser and chat with a model now. If the models do not show up, try to reboot the gradio web server.
(Optional): Advanced Features
- You can register multiple model workers to a single controller, which can be used for serving a single model with higher throughput or serving multiple models at the same time. When doing so, please allocate different GPUs and ports for different model workers.
- You can also launch a multi-tab gradio server, which includes the Chatbot Arena tabs.
- The default model worker based on huggingface/transformers has great compatibility but can be slow. If you want high-throughput serving, you can try vLLM integration.