8 篇文章带有标签 “fastchat”

LLM 的基准测试

安装 FastChat & vLLM

安装 FastChat

安装 FlashAttention

FlashAttention-2 currently supports:

  • Ampere, Ada, or Hopper GPUs (e.g., A100, RTX 3090, RTX 4090, H100). Support for Turing GPUs (T4, RTX 2080) is coming soon, please use FlashAttention 1.x for Turing GPUs for now.
  • Datatype fp16 and bf16 (bf16 requires Ampere, Ada, or Hopper GPUs).
  • All head dimensions up to 256. Head dim > 192 backward requires A100/A800 or H100/H800.

Turing GPU T4 不支持,需要使用 FlashAttention 1.x,否则会报错 ❌:

使用 FastChat 在 CUDA 上部署 LLM

安装 FastChat & vLLM

安装 FastChat

pip install "fschat[model_worker,webui]"

安装 FlashAttention

  • Turing GPU T4 不支持 FlashAttention 2,需要使用 FlashAttention 1.x 。
  • Turing GPU T4 不支持 bf16,需要使用 fp16

安装 vLLM

pip install vllm -i https://mirrors.aliyun.com/pypi/simple/

升级 FastChat & vLLM

git pull
pip install -e ".[model_worker,webui]"
pip install -U vllm

部署 LLM

运行 Controller

python -m fastchat.serve.controller

运行 OpenAI API Server

python -m fastchat.serve.openai_api_server

运行 Model Worker Qwen-1_8B-Chat export CUDA_VISIBLE_DEVIC

在 MacBook Pro M2 Max 上安装 FastChat

FastChat

FastChat 是一个开放平台,用于训练、服务和评估基于大型语言模型的聊天机器人。

FastChat Server 架构图

安装 FastChat

克隆代码

git clone https://github.com/lm-sys/FastChat
cd FastChat

创建虚拟环境

python -m venv env
source env/bin/activate

安装

pip install --upgrade pip
pip install -e ".[model_worker,webui]"

升级 FastChat

git pull
pip install -e ".[model_worker,webui]"

创建大模型链接 LLM Qwen mkdir Qwen ln -s /Users/junjian/HuggingFace/Qwen/Qwen-14B-Chat Qwen/Qwen-14B-Chat ln -s /Users/junjian/HuggingFace/Qwen/Qwen-1_8B Qwen/Qwen-1_8B ln -s /Users/junjian/HuggingFace/Qwen/Qwen-1_8B-Chat Qwen/Qwen-1_8B-Chat ln

基于 PyCharm 使用 Tabby 和 CodeGPT 插件搭建免费的 GitHub Copilot

使用的模型

  • 代码生成 Tabby 使用的是 Deepseek Coder 6.7B 模型。
  • AI 聊天 CodeGPT 使用的是 ChatGLM3-6B 模型。这个后面考虑使用 Deepseek Coder 6.7B 来替换。

部署服务器端

Tabby 服务

docker run -d --runtime nvidia --name tabby -p 8080:8080 \
  -e TABBY_DOWNLOAD_HOST=modelscope.cn \
  -e NVIDIA_VISIBLE_DEVICES=3 \
  -e RUST_BACKTRACE=1 \
  -v `pwd`/.tabby:/data tabbyml/tabby \
  serve --model TabbyML/DeepseekCoder-6.7B  --device cuda

OpaneAI 服务

  • 启动服务 Controller
python -m fastchat.serve.controller
  • 启动服务 Model Worker
python -m fastchat.serve.model_worker \
  --model-path THUDM/chatglm3-6b --port 21002 \
  --worker-address http://localhost:21002 \
  --model-names chatglm3-6b,gpt-3.5-turbo

AI 大模型基础服务架构图

大模型基础服务架构图

<center>
<div class="mermaid">
%%{init: {"flowchart": {"htmlLabels": false}} }%%
flowchart TB
  subgraph tool[聊天工具]
    direction TB
    chatgpt-next(ChatGPT Next Web)
    langchain-chatchat(Langchain-Chatchat)
    wechat(chatgpt-on-wechat)
  end
  subgraph business-application[业务应用层]
    direction TB
    app1(发电)
    app2(调度)
    app3(输变电)
// ...

代码大模型基础服务架构图

Langchain‐Chatchat 和 FastChat 结合

[FastChat][FastChat]

安装

# 克隆仓库
git clone https://github.com/lm-sys/FastChat
cd FastChat

# 创建虚拟环境
python -m venv env
source env/bin/activate

# 安装
pip install --upgrade pip
pip install -e ".[model_worker,webui]"

创建大模型链接

LLM

mkdir THUDM
ln -s /Users/junjian/HuggingFace/THUDM/chatglm3-6b THUDM/chatglm3-6b

Embedding Model

mkdir BAAI
ln -s /Users/junjian/HuggingFace/BAAI/bge-base-zh-v1.5 BAAI/bge-base-zh-v1.5

启动服务 Controller

python -m fastchat.serve.controller

启动服务 Model Worker LLM python -m fastchat.serve.

Qwen (通义千问)

快速开始

克隆代码

git clone https://github.com/QwenLM/Qwen.git
cd Qwen

创建虚拟环境

python -m venv env
source env/bin/activate

安装依赖

pip install -r requirements.txt

创建大模型链接

mkdir Qwen
ln -s /Users/junjian/HuggingFace/Qwen/Qwen-14B-Chat Qwen/Qwen-14B-Chat
ln -s /Users/junjian/HuggingFace/Qwen/Qwen-1_8B Qwen/Qwen-1_8B
ln -s /Users/junjian/HuggingFace/Qwen/Qwen-1_8B-Chat Qwen/Qwen-1_8B-Chat
ln -s /Users/junjian/HuggingFace/Qwen/Qwen-7B-Chat Qwen/Qwen-7B-Chat

聊天

  • 命令行聊天
python cli_demo.py
  • Web 聊天
python web_demo.py

FastChat

克隆代码

git clone https://github.com/lm-sys/FastChat
cd FastChat

创建虚拟环境 python -m venv env source env

FastChat 部署多模型


* [Chatbot Arena](https://chat.lmsys.org/) * [FastChat](https://github.com/lm-sys/FastChat) * [LMSYS BLOG](https://lmsys.org/blog/) * [Use AutoGen for Local LLMs](https://microsoft.github.io/autogen/blog/2023/07/14/Local-LLMs/)

安装

pip

pip install "fschat[model_worker,webui]"

源代码

这种方式安装比较容易调试,适合开发者。

克隆代码

git clone https://github.com/lm-sys/FastChat.git
cd FastChat

创建环境

python -m venv env
source env/bin/activate

安装