From 6a7718722fa58e52639e8172dca1bac423ee3cb9 Mon Sep 17 00:00:00 2001 From: wehub-resource-sync Date: Mon, 13 Jul 2026 10:25:31 +0000 Subject: [PATCH] docs: make Chinese README the default --- README.md | 308 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 157 insertions(+), 151 deletions(-) diff --git a/README.md b/README.md index 6510b8a..3fc176f 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,88 @@ + +> [!NOTE] +> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。 +> [English](./README.en.md) · [原始项目](https://github.com/lm-sys/FastChat) · [上游 README](https://github.com/lm-sys/FastChat/blob/HEAD/README.md) +> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。 + # FastChat | [**Demo**](https://lmarena.ai/) | [**Discord**](https://discord.gg/6GXcFg3TH8) | [**X**](https://x.com/lmsysorg) | -FastChat is an open platform for training, serving, and evaluating large language model based chatbots. -- FastChat powers Chatbot Arena ([lmarena.ai](https://lmarena.ai)), serving over 10 million chat requests for 70+ LLMs. -- Chatbot Arena has collected over 1.5M human votes from side-by-side LLM battles to compile an online [LLM Elo leaderboard](https://lmarena.ai/?leaderboard). +FastChat 是一个用于训练、部署和评估基于大语言模型(LLM)的聊天机器人的开放平台。 +- FastChat 为 Chatbot Arena([lmarena.ai](https://lmarena.ai)), 提供支持,已为 70 多款 LLM 处理超过 1000 万次聊天请求。 +- Chatbot Arena 已通过并排 LLM 对战收集了超过 150 万条人工投票,并据此编制了在线 [LLM Elo 排行榜](https://lmarena.ai/?leaderboard). -FastChat's core features include: -- The training and evaluation code for state-of-the-art models (e.g., Vicuna, MT-Bench). -- A distributed multi-model serving system with web UI and OpenAI-compatible RESTful APIs. +FastChat 的核心功能包括: +- 最先进模型(例如 Vicuna、MT-Bench)的训练与评估代码。 +- 带 Web UI 且兼容 OpenAI 的 RESTful API 的分布式多模型服务系统。 ## News -- [2024/03] 🔥 We released Chatbot Arena technical [report](https://arxiv.org/abs/2403.04132). -- [2023/09] We released **LMSYS-Chat-1M**, a large-scale real-world LLM conversation dataset. Read the [report](https://arxiv.org/abs/2309.11998). -- [2023/08] We released **Vicuna v1.5** based on Llama 2 with 4K and 16K context lengths. Download [weights](#vicuna-weights). -- [2023/07] We released **Chatbot Arena Conversations**, a dataset containing 33k conversations with human preferences. Download it [here](https://huggingface.co/datasets/lmsys/chatbot_arena_conversations). +- [2024/03] 🔥 我们发布了 Chatbot Arena 技术[报告](https://arxiv.org/abs/2403.04132). +- [2023/09] 我们发布了 **LMSYS-Chat-1M**,一个大规模真实世界 LLM 对话数据集。阅读[报告](https://arxiv.org/abs/2309.11998). +- [2023/08] 我们基于 Llama 2 发布了 **Vicuna v1.5**,支持 4K 和 16K 上下文长度。下载[权重](#vicuna-weights)。 +- [2023/07] 我们发布了 **Chatbot Arena Conversations**,一个包含 3.3 万条带有人类偏好标注的对话数据集。在[此处](https://huggingface.co/datasets/lmsys/chatbot_arena_conversations). 下载。
-More +更多 -- [2023/08] We released **LongChat v1.5** based on Llama 2 with 32K context lengths. Download [weights](#longchat). -- [2023/06] We introduced **MT-bench**, a challenging multi-turn question set for evaluating chatbots. Check out the blog [post](https://lmsys.org/blog/2023-06-22-leaderboard/). -- [2023/06] We introduced **LongChat**, our long-context chatbots and evaluation tools. Check out the blog [post](https://lmsys.org/blog/2023-06-29-longchat/). -- [2023/05] We introduced **Chatbot Arena** for battles among LLMs. Check out the blog [post](https://lmsys.org/blog/2023-05-03-arena). -- [2023/03] We released **Vicuna: An Open-Source Chatbot Impressing GPT-4 with 90% ChatGPT Quality**. Check out the blog [post](https://vicuna.lmsys.org). +- [2023/08] 我们基于 Llama 2 发布了 **LongChat v1.5**,支持 32K 上下文长度。下载[权重](#longchat)。 +- [2023/06] 我们推出了 **MT-bench**,一套用于评估聊天机器人的挑战性多轮问答集。查看博客[文章](https://lmsys.org/blog/2023-06-22-leaderboard/). +- [2023/06] 我们推出了 **LongChat**,即我们的长上下文聊天机器人及评估工具。查看博客[文章](https://lmsys.org/blog/2023-06-29-longchat/). +- [2023/05] 我们推出了 **Chatbot Arena**,用于 LLM 之间的对战。查看博客[文章](https://lmsys.org/blog/2023-05-03-arena). +- [2023/03] 我们发布了 **Vicuna: An Open-Source Chatbot Impressing GPT-4 with 90% ChatGPT Quality**。查看博客[文章](https://vicuna.lmsys.org).
## Contents -- [Install](#install) -- [Model Weights](#model-weights) -- [Inference with Command Line Interface](#inference-with-command-line-interface) -- [Serving with Web GUI](#serving-with-web-gui) +- [安装](#install) +- [模型权重](#model-weights) +- [使用命令行界面进行推理](#inference-with-command-line-interface) +- [使用 Web GUI 部署服务](#serving-with-web-gui) - [API](#api) -- [Evaluation](#evaluation) -- [Fine-tuning](#fine-tuning) -- [Citation](#citation) +- [评估](#evaluation) +- [微调](#fine-tuning) +- [引用](#citation) -## Install +## 安装 -### Method 1: With pip +### 方法 1:使用 pip ```bash pip3 install "fschat[model_worker,webui]" ``` -### Method 2: From source +### 方法 2:从源码安装 -1. Clone this repository and navigate to the FastChat folder +1. 克隆本仓库并进入 FastChat 文件夹 ```bash git clone https://github.com/lm-sys/FastChat.git cd FastChat ``` -If you are running on Mac: +如果你在 Mac 上运行: ```bash brew install rust cmake ``` -2. Install Package +2. 安装软件包 ```bash pip3 install --upgrade pip # enable PEP 660 support pip3 install -e ".[model_worker,webui]" ``` -## Model Weights -### Vicuna Weights -[Vicuna](https://lmsys.org/blog/2023-03-30-vicuna/) is based on Llama 2 and should be used under Llama's [model license](https://github.com/facebookresearch/llama/blob/main/LICENSE). +## 模型权重 +### Vicuna 权重 +[Vicuna](https://lmsys.org/blog/2023-03-30-vicuna/) 基于 Llama 2,使用时应遵守 Llama 的[模型许可证](https://github.com/facebookresearch/llama/blob/main/LICENSE). -You can use the commands below to start chatting. It will automatically download the weights from Hugging Face repos. -Downloaded weights are stored in a `.cache` folder in the user's home folder (e.g., `~/.cache/huggingface/hub/`). +你可以使用下面的命令开始聊天。权重将自动从 Hugging Face 仓库下载。 +下载的权重保存在用户主目录下的 `.cache` 文件夹中(例如 `~/.cache/huggingface/hub/`)。 -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.** +**注意:16K 版本需要 `transformers>=4.31`。** -| Size | Chat Command | Hugging Face Repo | +| 规模 | 聊天命令 | Hugging Face 仓库 | | --- | --- | --- | | 7B | `python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5` | [lmsys/vicuna-7b-v1.5](https://huggingface.co/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](https://huggingface.co/lmsys/vicuna-7b-v1.5-16k) | @@ -84,166 +90,166 @@ See more command options and how to handle out-of-memory in the "Inference with | 13B-16k | `python3 -m fastchat.serve.cli --model-path lmsys/vicuna-13b-v1.5-16k` | [lmsys/vicuna-13b-v1.5-16k](https://huggingface.co/lmsys/vicuna-13b-v1.5-16k) | | 33B | `python3 -m fastchat.serve.cli --model-path lmsys/vicuna-33b-v1.3` | [lmsys/vicuna-33b-v1.3](https://huggingface.co/lmsys/vicuna-33b-v1.3) | -**Old weights**: see [docs/vicuna_weights_version.md](docs/vicuna_weights_version.md) for all versions of weights and their differences. +**旧版权重**:有关所有权重的版本及其差异,请参阅 [docs/vicuna_weights_version.md](docs/vicuna_weights_version.md)。 -### Other Models -Besides Vicuna, we also released two additional models: [LongChat](https://lmsys.org/blog/2023-06-29-longchat/) and FastChat-T5. -You can use the commands below to chat with them. They will automatically download the weights from Hugging Face repos. +### 其他模型 +除 Vicuna 外,我们还发布了另外两款模型:[LongChat](https://lmsys.org/blog/2023-06-29-longchat/) 和 FastChat-T5。 +你可以使用下面的命令与它们聊天。权重将自动从 Hugging Face 仓库下载。 -| Model | Chat Command | Hugging Face Repo | +| 模型 | 聊天命令 | Hugging Face 仓库 | | --- | --- | --- | | LongChat-7B | `python3 -m fastchat.serve.cli --model-path lmsys/longchat-7b-32k-v1.5` | [lmsys/longchat-7b-32k](https://huggingface.co/lmsys/longchat-7b-32k-v1.5) | | FastChat-T5-3B | `python3 -m fastchat.serve.cli --model-path lmsys/fastchat-t5-3b-v1.0` | [lmsys/fastchat-t5-3b-v1.0](https://huggingface.co/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.) +(实验性功能:你可以指定 `--style rich` 以启用富文本输出,并改善部分非 ASCII 内容的文本流式输出质量。某些终端上可能无法正常工作。) -#### Supported Models -FastChat supports a wide range of models, including -LLama 2, Vicuna, Alpaca, Baize, ChatGLM, Dolly, Falcon, FastChat-T5, GPT4ALL, Guanaco, MTP, OpenAssistant, OpenChat, RedPajama, StableLM, WizardLM, xDAN-AI and more. +#### 支持的模型 +FastChat 支持多种模型,包括 +LLama 2、Vicuna、Alpaca、Baize、ChatGLM、Dolly、Falcon、FastChat-T5、GPT4ALL、Guanaco、MTP、OpenAssistant、OpenChat、RedPajama、StableLM、WizardLM、xDAN-AI 等。 -See a complete list of supported models and instructions to add a new model [here](docs/model_support.md). +完整支持的模型列表及添加新模型的说明请见[此处](docs/model_support.md)。 -#### 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](#not-enough-memory) below if you do not have enough memory. -`--model-path` can be a local folder or a Hugging Face repo name. +#### 单 GPU +下面的命令大约需要 14GB GPU 显存(Vicuna-7B)和 28GB GPU 显存(Vicuna-13B)。 +如果显存不足,请参阅下文[「内存不足」](#not-enough-memory)一节。 +`--model-path` 可以是本地文件夹或 Hugging Face 仓库名称。 ``` python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 ``` -#### Multiple GPUs -You can use model parallelism to aggregate GPU memory from multiple GPUs on the same machine. +#### 多 GPU +你可以使用模型并行,聚合同一台机器上多块 GPU 的显存。 ``` python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 --num-gpus 2 ``` -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, +提示: +有时 huggingface/transformers 中的「auto」设备映射策略无法在多块 GPU 之间完美平衡内存分配。 +你可以使用 `--max-gpu-memory` 指定每块 GPU 用于存储模型权重的最大内存。 +这样可为激活值分配更多内存,从而使用更长的上下文长度或更大的批大小。例如, ``` python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 --num-gpus 2 --max-gpu-memory 8GiB ``` -#### 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. +#### 仅 CPU +这仅在 CPU 上运行,不需要 GPU。Vicuna-7B 大约需要 30GB CPU 内存,Vicuna-13B 大约需要 60GB CPU 内存。 ``` python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 --device cpu ``` -Use Intel AI Accelerator AVX512_BF16/AMX to accelerate CPU inference. +使用 Intel AI Accelerator AVX512_BF16/AMX 加速 CPU 推理。 ``` CPU_ISA=amx python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 --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. +#### Metal 后端(搭载 Apple Silicon 或 AMD GPU 的 Mac 电脑) +使用 `--device mps` 在 Mac 电脑上启用 GPU 加速(需要 torch >= 2.0)。 +使用 `--load-8bit` 开启 8 位压缩。 ``` python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 --device mps --load-8bit ``` -Vicuna-7B can run on a 32GB M1 Macbook with 1 - 2 words / second. +Vicuna-7B 可在 32GB 内存的 M1 Macbook 上运行,速度约为每秒 1–2 个词。 -#### Intel XPU (Intel Data Center and Arc A-Series GPUs) -Install the [Intel Extension for PyTorch](https://intel.github.io/intel-extension-for-pytorch/xpu/latest/tutorials/installation.html). Set the OneAPI environment variables: +#### Intel XPU(Intel 数据中心 GPU 与 Arc A 系列 GPU) +安装 [Intel Extension for PyTorch](https://intel.github.io/intel-extension-for-pytorch/xpu/latest/tutorials/installation.html). 并设置 OneAPI 环境变量: ``` source /opt/intel/oneapi/setvars.sh ``` -Use `--device xpu` to enable XPU/GPU acceleration. +使用 `--device xpu` 启用 XPU/GPU 加速。 ``` python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 --device xpu ``` -Vicuna-7B can run on an Intel Arc A770 16GB. +Vicuna-7B 可在 Intel Arc A770 16GB 上运行。 #### Ascend NPU -Install the [Ascend PyTorch Adapter](https://github.com/Ascend/pytorch). Set the CANN environment variables: +安装 [Ascend PyTorch Adapter](https://github.com/Ascend/pytorch). 并设置 CANN 环境变量: ``` source /usr/local/Ascend/ascend-toolkit/set_env.sh ``` -Use `--device npu` to enable NPU acceleration. +使用 `--device npu` 启用 NPU 加速。 ``` python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 --device npu ``` -Vicuna-7B/13B can run on an Ascend NPU. +Vicuna-7B/13B 可在 Ascend NPU 上运行。 -#### 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. +#### 内存不足 +如果内存不足,你可以在上述命令中添加 `--load-8bit` 以启用 8 位压缩。 +这可将内存占用减少约一半,但模型质量会略有下降。 +它兼容 CPU、GPU 和 Metal 后端。 -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. +启用 8 位压缩后,Vicuna-13B 可在单块 16 GB 显存的 GPU 上运行,例如 Nvidia RTX 3090、RTX 4080、T4、V100(16GB)或 AMD RX 6800 XT。 ``` python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 --load-8bit ``` -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. +此外,你还可以在上述命令中添加 `--cpu-offloading`,将无法放入 GPU 显存的权重卸载到 CPU 内存。 +这需要启用 8 位压缩并安装 bitsandbytes 包,该包仅在 Linux 操作系统上可用。 -#### More Platforms and Quantization -- For AMD GPU users, please install ROCm and [the ROCm version of PyTorch](https://pytorch.org/get-started/locally/) before you install FastChat. See also this [post](https://github.com/lm-sys/FastChat/issues/104#issuecomment-1613791563). -- FastChat supports ExLlama V2. See [docs/exllama_v2.md](/docs/exllama_v2.md). -- FastChat supports GPTQ 4bit inference with [GPTQ-for-LLaMa](https://github.com/qwopqwop200/GPTQ-for-LLaMa). See [docs/gptq.md](/docs/gptq.md). -- FastChat supports AWQ 4bit inference with [mit-han-lab/llm-awq](https://github.com/mit-han-lab/llm-awq). See [docs/awq.md](/docs/awq.md). -- [MLC LLM](https://mlc.ai/mlc-llm/), backed by [TVM Unity](https://github.com/apache/tvm/tree/unity) compiler, deploys Vicuna natively on phones, consumer-class GPUs and web browsers via Vulkan, Metal, CUDA and WebGPU. +#### 更多平台与量化 +- 对于 AMD GPU 用户,请在安装 FastChat 之前安装 ROCm 和 [ROCm 版 PyTorch](https://pytorch.org/get-started/locally/)。另请参阅这篇[帖子](https://github.com/lm-sys/FastChat/issues/104#issuecomment-1613791563). +- FastChat 支持 ExLlama V2。请参阅 [docs/exllama_v2.md](/docs/exllama_v2.md)。 +- FastChat 支持通过 [GPTQ-for-LLaMa](https://github.com/qwopqwop200/GPTQ-for-LLaMa). 进行 GPTQ 4 位推理。请参阅 [docs/gptq.md](/docs/gptq.md)。 +- FastChat 支持通过 [mit-han-lab/llm-awq](https://github.com/mit-han-lab/llm-awq). 进行 AWQ 4 位推理。请参阅 [docs/awq.md](/docs/awq.md)。 +- 由 [TVM Unity](https://github.com/apache/tvm/tree/unity) 编译器支持的 [MLC LLM](https://mlc.ai/mlc-llm/), 可通过 Vulkan、Metal、CUDA 和 WebGPU 在手机、消费级 GPU 和 Web 浏览器上原生部署 Vicuna。 -#### Use models from modelscope -For Chinese users, you can use models from www.modelscope.cn via specify the following environment variables. +#### 使用 ModelScope 模型 +中国用户可通过设置以下环境变量,使用来自 www.modelscope.cn 的模型。 ```bash export FASTCHAT_USE_MODELSCOPE=True ``` -## Serving with Web GUI +## 使用 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](docs/server_arch.md). +要通过 Web UI 提供服务,你需要三个主要组件:与用户交互的 Web 服务器、托管一个或多个模型的模型 worker,以及用于协调 Web 服务器和模型 worker 的控制器。你可以在[此处](docs/server_arch.md)了解更多架构信息。 -Here are the commands to follow in your terminal: +请在终端中执行以下命令: -#### Launch the controller +#### 启动控制器 ```bash python3 -m fastchat.serve.controller ``` -This controller manages the distributed workers. +该控制器负责管理分布式 worker。 -#### Launch the model worker(s) +#### 启动模型 worker ```bash python3 -m fastchat.serve.model_worker --model-path lmsys/vicuna-7b-v1.5 ``` -Wait until the process finishes loading the model and you see "Uvicorn running on ...". The model worker will register itself to the controller . +等待进程完成模型加载,并看到 "Uvicorn running on ..."。模型 worker 会自动向控制器注册。 -To ensure that your model worker is connected to your controller properly, send a test message using the following command: +为确保模型 worker 已正确连接到控制器,请使用以下命令发送测试消息: ```bash python3 -m fastchat.serve.test_message --model-name vicuna-7b-v1.5 ``` -You will see a short output. +你将看到简短输出。 -#### Launch the Gradio web server +#### 启动 Gradio Web 服务器 ```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. -If the models do not show up, try to reboot the gradio web server. +按照这些步骤,你就可以通过 Web UI 提供模型服务。你现在可以打开浏览器与模型对话。 +如果模型未显示,请尝试重启 gradio web 服务器。 -## Launch Chatbot Arena (side-by-side battle UI) +## 启动 Chatbot Arena(并排对战 UI) -Currently, Chatbot Arena is powered by FastChat. Here is how you can launch an instance of Chatbot Arena locally. +目前,Chatbot Arena 由 FastChat 驱动。以下介绍如何在本地启动 Chatbot Arena 实例。 -FastChat supports popular API-based models such as OpenAI, Anthropic, Gemini, Mistral and more. To add a custom API, please refer to the model support [doc](./docs/model_support.md). Below we take OpenAI models as an example. +FastChat 支持 OpenAI、Anthropic、Gemini、Mistral 等主流基于 API 的模型。要添加自定义 API,请参阅模型支持[文档](./docs/model_support.md)。以下以 OpenAI 模型为例。 -Create a JSON configuration file `api_endpoint.json` with the api endpoints of the models you want to serve, for example: +创建 JSON 配置文件 `api_endpoint.json`,填写你想提供的模型的 API 端点,例如: ``` { "gpt-4o-2024-05-13": { @@ -255,73 +261,73 @@ Create a JSON configuration file `api_endpoint.json` with the api endpoints of t } } ``` -For Anthropic models, specify `"api_type": "anthropic_message"` with your Anthropic key. Similarly, for gemini model, specify `"api_type": "gemini"`. More details can be found in [api_provider.py](https://github.com/lm-sys/FastChat/blob/main/fastchat/serve/api_provider.py). +对于 Anthropic 模型,请使用你的 Anthropic 密钥指定 `"api_type": "anthropic_message"`。同样地,对于 Gemini 模型,请指定 `"api_type": "gemini"`。更多细节请参阅 [api_provider.py](https://github.com/lm-sys/FastChat/blob/main/fastchat/serve/api_provider.py). -To serve your own model using local gpus, follow the instructions in [Serving with Web GUI](#serving-with-web-gui). +要使用本地 GPU 提供你自己的模型服务,请遵循[使用 Web GUI 提供服务](#serving-with-web-gui)中的说明。 -Now you're ready to launch the server: +现在你可以启动服务器了: ``` python3 -m fastchat.serve.gradio_web_server_multi --register-api-endpoint-file api_endpoint.json ``` -#### (Optional): Advanced Features, Scalability, Third Party UI -- 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. +#### (可选)高级功能、可扩展性与第三方 UI +- 你可以将多个模型 worker 注册到单个控制器,用于以更高吞吐量提供单个模型服务,或同时提供多个模型。这样做时,请为不同的模型 worker 分配不同的 GPU 和端口。 ``` # worker 0 CUDA_VISIBLE_DEVICES=0 python3 -m fastchat.serve.model_worker --model-path lmsys/vicuna-7b-v1.5 --controller http://localhost:21001 --port 31000 --worker http://localhost:31000 # worker 1 CUDA_VISIBLE_DEVICES=1 python3 -m fastchat.serve.model_worker --model-path lmsys/fastchat-t5-3b-v1.0 --controller http://localhost:21001 --port 31001 --worker http://localhost:31001 ``` -- You can also launch a multi-tab gradio server, which includes the Chatbot Arena tabs. +- 你也可以启动包含 Chatbot Arena 标签页的多标签 Gradio 服务器。 ```bash python3 -m fastchat.serve.gradio_web_server_multi ``` -- The default model worker based on huggingface/transformers has great compatibility but can be slow. If you want high-throughput batched serving, you can try [vLLM integration](docs/vllm_integration.md). -- If you want to host it on your own UI or third party UI, see [Third Party UI](docs/third_party_ui.md). +- 基于 huggingface/transformers 的默认模型 worker 兼容性很好,但可能较慢。如果你需要高吞吐量的批处理服务,可以尝试 [vLLM integration](docs/vllm_integration.md)。 +- 如果你想在自己的 UI 或第三方 UI 上托管,请参阅 [Third Party UI](docs/third_party_ui.md)。 ## API -### OpenAI-Compatible RESTful APIs & SDK -FastChat provides OpenAI-compatible APIs for its supported models, so you can use FastChat as a local drop-in replacement for OpenAI APIs. -The FastChat server is compatible with both [openai-python](https://github.com/openai/openai-python) library and cURL commands. -The REST API is capable of being executed from Google Colab free tier, as demonstrated in the [FastChat_API_GoogleColab.ipynb](https://github.com/lm-sys/FastChat/blob/main/playground/FastChat_API_GoogleColab.ipynb) notebook, available in our repository. -See [docs/openai_api.md](docs/openai_api.md). +### 兼容 OpenAI 的 RESTful API 与 SDK +FastChat 为其支持的模型提供兼容 OpenAI 的 API,因此你可以将 FastChat 用作 OpenAI API 的本地替代方案。 +FastChat 服务器同时兼容 [openai-python](https://github.com/openai/openai-python) 库和 cURL 命令。 +REST API 可在 Google Colab 免费版中运行,如仓库中的 [FastChat_API_GoogleColab.ipynb](https://github.com/lm-sys/FastChat/blob/main/playground/FastChat_API_GoogleColab.ipynb) 笔记本所示。 +请参阅 [docs/openai_api.md](docs/openai_api.md)。 -### Hugging Face Generation APIs -See [fastchat/serve/huggingface_api.py](fastchat/serve/huggingface_api.py). +### Hugging Face 生成 API +请参阅 [fastchat/serve/huggingface_api.py](fastchat/serve/huggingface_api.py)。 -### LangChain Integration -See [docs/langchain_integration](docs/langchain_integration.md). +### LangChain 集成 +请参阅 [docs/langchain_integration](docs/langchain_integration.md)。 -## Evaluation -We use MT-bench, a set of challenging multi-turn open-ended questions to evaluate models. -To automate the evaluation process, we prompt strong LLMs like GPT-4 to act as judges and assess the quality of the models' responses. -See instructions for running MT-bench at [fastchat/llm_judge](fastchat/llm_judge). +## 评估 +我们使用 MT-bench,这是一组具有挑战性的多轮开放式问题,用于评估模型。 +为自动化评估流程,我们提示 GPT-4 等强大的 LLM 担任评委,评估模型回答的质量。 +有关运行 MT-bench 的说明,请参阅 [fastchat/llm_judge](fastchat/llm_judge)。 -MT-bench is the new recommended way to benchmark your models. If you are still looking for the old 80 questions used in the vicuna blog post, please go to [vicuna-blog-eval](https://github.com/lm-sys/vicuna-blog-eval). +MT-bench 是评测模型的新推荐方式。如果你仍在寻找 vicuna 博客文章中使用的旧版 80 个问题,请前往 [vicuna-blog-eval](https://github.com/lm-sys/vicuna-blog-eval). -## Fine-tuning -### Data +## 微调 +### 数据 -Vicuna is created by fine-tuning a Llama base model using approximately 125K user-shared conversations gathered from ShareGPT.com with public APIs. To ensure data quality, we convert the HTML back to markdown and filter out some inappropriate or low-quality samples. Additionally, we divide lengthy conversations into smaller segments that fit the model's maximum context length. For detailed instructions to clean the ShareGPT data, check out [here](docs/commands/data_cleaning.md). +Vicuna 通过对 Llama 基础模型进行微调创建,使用了从 ShareGPT.com 通过公开 API 收集的约 125K 条用户共享对话。为确保数据质量,我们将 HTML 转换回 markdown,并过滤掉部分不当或低质量样本。此外,我们将冗长对话拆分为符合模型最大上下文长度的小段。有关清洗 ShareGPT 数据的详细说明,请查看[此处](docs/commands/data_cleaning.md)。 -We will not release the ShareGPT dataset. If you would like to try the fine-tuning code, you can run it with some dummy conversations in [dummy_conversation.json](data/dummy_conversation.json). You can follow the same format and plug in your own data. +我们不会发布 ShareGPT 数据集。如果你想试用微调代码,可以使用 [dummy_conversation.json](data/dummy_conversation.json) 中的一些虚拟对话来运行。你可以遵循相同格式并填入自己的数据。 -### Code and Hyperparameters -Our code is based on [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca) with additional support for multi-turn conversations. -We use similar hyperparameters as the Stanford Alpaca. +### 代码与超参数 +我们的代码基于 [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca),并额外支持多轮对话(multi-turn conversations)。 +我们使用的超参数与 Stanford Alpaca 类似。 -| Hyperparameter | Global Batch Size | Learning rate | Epochs | Max length | Weight decay | +| 超参数 | 全局批次大小 | 学习率 | 训练轮数 | 最大长度 | 权重衰减 | | --- | ---: | ---: | ---: | ---: | ---: | | Vicuna-13B | 128 | 2e-5 | 3 | 2048 | 0 | -### Fine-tuning Vicuna-7B with Local GPUs +### 使用本地 GPU 微调 Vicuna-7B -- Install dependency +- 安装依赖 ```bash pip3 install -e ".[train]" ``` -- You can use the following command to train Vicuna-7B with 4 x A100 (40GB). Update `--model_name_or_path` with the actual path to Llama weights and `--data_path` with the actual path to data. +- 你可以使用以下命令,在 4 x A100 (40GB) 上训练 Vicuna-7B。请将 `--model_name_or_path` 更新为 Llama 权重的实际路径,并将 `--data_path` 更新为数据的实际路径。 ```bash torchrun --nproc_per_node=4 --master_port=20001 fastchat/train/train_mem.py \ --model_name_or_path meta-llama/Llama-2-7b-hf \ @@ -349,22 +355,22 @@ torchrun --nproc_per_node=4 --master_port=20001 fastchat/train/train_mem.py \ --lazy_preprocess True ``` -Tips: -- If you are using V100 which is not supported by FlashAttention, you can use the [memory-efficient attention](https://arxiv.org/abs/2112.05682) implemented in [xFormers](https://github.com/facebookresearch/xformers). Install xformers and replace `fastchat/train/train_mem.py` above with [fastchat/train/train_xformers.py](fastchat/train/train_xformers.py). -- If you meet out-of-memory due to "FSDP Warning: When using FSDP, it is efficient and recommended... ", see solutions [here](https://github.com/huggingface/transformers/issues/24724#issuecomment-1645189539). -- If you meet out-of-memory during model saving, see solutions [here](https://github.com/pytorch/pytorch/issues/98823). -- To turn on logging to popular experiment tracking tools such as Tensorboard, MLFlow or Weights & Biases, use the `report_to` argument, e.g. pass `--report_to wandb` to turn on logging to Weights & Biases. +提示: +- 如果你使用的是不受 FlashAttention 支持的 V100,可以使用 [memory-efficient attention](https://arxiv.org/abs/2112.05682) implemented in [xFormers](https://github.com/facebookresearch/xformers). 安装 xformers,并将上文中的 `fastchat/train/train_mem.py` 替换为 [fastchat/train/train_xformers.py](fastchat/train/train_xformers.py)。 +- 如果因 "FSDP Warning: When using FSDP, it is efficient and recommended... " 而出现显存不足,请参阅[此处](https://github.com/huggingface/transformers/issues/24724#issuecomment-1645189539). 的解决方案。 +- 如果在模型保存过程中遇到显存不足,请参阅[此处](https://github.com/pytorch/pytorch/issues/98823). 的解决方案。 +- 若要开启 Tensorboard、MLFlow 或 Weights & Biases 等常用实验跟踪工具的日志记录,请使用 `report_to` 参数,例如传入 `--report_to wandb` 以开启 Weights & Biases 日志记录。 -### Other models, platforms and LoRA support -More instructions to train other models (e.g., FastChat-T5) and use LoRA are in [docs/training.md](docs/training.md). +### 其他模型、平台与 LoRA 支持 +关于训练其他模型(例如 FastChat-T5)和使用 LoRA 的更多说明,请参阅 [docs/training.md](docs/training.md)。 -### Fine-tuning on Any Cloud with SkyPilot -[SkyPilot](https://github.com/skypilot-org/skypilot) is a framework built by UC Berkeley for easily and cost effectively running ML workloads on any cloud (AWS, GCP, Azure, Lambda, etc.). -Find SkyPilot documentation [here](https://github.com/skypilot-org/skypilot/tree/master/llm/vicuna) on using managed spot instances to train Vicuna and save on your cloud costs. +### 使用 SkyPilot 在任意云上微调 +[SkyPilot](https://github.com/skypilot-org/skypilot) 是由 UC Berkeley 构建的框架,用于在任意云(AWS、GCP、Azure、Lambda 等)上轻松且经济高效地运行机器学习工作负载。 +请在[此处](https://github.com/skypilot-org/skypilot/tree/master/llm/vicuna) 查阅 SkyPilot 文档,了解如何使用 managed spot 实例(managed spot instances)训练 Vicuna 并节省云成本。 -## Citation -The code (training, serving, and evaluation) in this repository is mostly developed for or derived from the paper below. -Please cite it if you find the repository helpful. +## 引用 +本仓库中的代码(训练、serving 和评估)大多是为下文论文开发或衍生而来。 +如果你觉得本仓库有帮助,请引用该论文。 ``` @misc{zheng2023judging, @@ -377,4 +383,4 @@ Please cite it if you find the repository helpful. } ``` -We are also planning to add more of our research to this repository. +我们也计划将更多研究成果添加到本仓库。