File size: 5,289 Bytes
b989f08 ea87219 c7e4763 ea87219 64a6578 ea87219 f447393 ea87219 dee2dcf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
---
inference: false
---
# Vicuna 13b Weights vicuna-weights
Converted model from https://huggingface.co/lmsys/vicuna-13b-delta-v1.1
## Install
```bash
pip3 install fschat
```
## 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.)
<a href="https://chat.lmsys.org"><img src="assets/screenshot_cli.png" width="70%"></a>
When use huggingface, the </path/to/vicuna/weights> is "jinxuewen/vicuna-13b"
#### Single GPU
The command below requires around 28GB of GPU memory for Vicuna-13B and 14GB of GPU memory for Vicuna-7B.
See the "No Enough Memory" section below if you do not have enough memory.
```
python3 -m fastchat.serve.cli --model-path /path/to/vicuna/weights
```
#### Multiple GPUs
You can use model parallelism to aggregate GPU memory from multiple GPUs on the same machine.
```
python3 -m fastchat.serve.cli --model-path /path/to/vicuna/weights --num-gpus 2
```
#### CPU Only
This runs on the CPU only and does not require GPU. It requires around 60GB of CPU memory for Vicuna-13B and around 30GB of CPU memory for Vicuna-7B.
```
python3 -m fastchat.serve.cli --model-path /path/to/vicuna/weights --device cpu
```
#### 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.
```
python3 -m fastchat.serve.cli --model-path /path/to/vicuna/weights --device mps --load-8bit
```
Vicuna-7B can run on a 32GB M1 Macbook with 1 - 2 words / second.
#### No Enough Memory or Other Platforms
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 NVIDIA 3090/4080/V100(16GB) GPU.
```
python3 -m fastchat.serve.cli --model-path /path/to/vicuna/weights --load-8bit
```
Besides, we are actively exploring more methods to make the model easier to run on more platforms.
Contributions and pull requests are welcome.
## Serving with Web GUI
<a href="https://chat.lmsys.org"><img src="assets/screenshot_gui.png" width="70%"></a>
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. Here are the commands to follow in your terminal:
#### Launch the controller
```bash
python3 -m fastchat.serve.controller
```
This controller manages the distributed workers.
#### Launch the model worker
```bash
python3 -m fastchat.serve.model_worker --model-path /path/to/vicuna/weights
```
Wait until the process finishes loading the model and you see "Uvicorn running on ...". You can launch multiple model workers to serve multiple models concurrently. The model worker will connect to the controller automatically.
To ensure that your model worker is connected to your controller properly, send a test message using the following command:
```bash
python3 -m fastchat.serve.test_message --model-name vicuna-13b
```
#### Launch the Gradio web server
```bash
python3 -m fastchat.serve.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.
## API
### Huggingface Generation APIs
See [fastchat/serve/huggingface_api.py](fastchat/serve/huggingface_api.py)
### OpenAI-compatible RESTful APIs & SDK
(Experimental. We will keep improving the API and SDK.)
#### Chat Completion
Reference: https://platform.openai.com/docs/api-reference/chat/create
Some features/compatibilities to be implemented:
- [ ] streaming
- [ ] support of some parameters like `top_p`, `presence_penalty`
- [ ] proper error handling (e.g. model not found)
- [ ] the return value in the client SDK could be used like a dict
**RESTful API Server**
First, launch the controller
```bash
python3 -m fastchat.serve.controller
```
Then, launch the model worker(s)
```bash
python3 -m fastchat.serve.model_worker --model-name 'vicuna-7b-v1.1' --model-path /path/to/vicuna/weights
```
Finally, launch the RESTful API server
```bash
export FASTCHAT_CONTROLLER_URL=http://localhost:21001
python3 -m fastchat.serve.api --host localhost --port 8000
```
Test the API server
```bash
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "vicuna-7b-v1.1",
"messages": [{"role": "user", "content": "Hello!"}]
}'
```
**Client SDK**
Assuming environment variable `FASTCHAT_BASEURL` is set to the API server URL (e.g., `http://localhost:8000`), you can use the following code to send a request to the API server:
```python
import os
from fastchat import client
client.set_baseurl(os.getenv("FASTCHAT_BASEURL"))
completion = client.ChatCompletion.create(
model="vicuna-7b-v1.1",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
``` |