在 MacBook Pro M2 Max 上安装 FastChat
类别: FastChat 标签: FastChat Qwen DeepSeek ChatGLM OpenAI MacBookProM2Max目录
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 -s /Users/junjian/HuggingFace/Qwen/Qwen-7B-Chat Qwen/Qwen-7B-Chat
- DeepSeek
mkdir deepseek-ai ln -s /Users/junjian/HuggingFace/deepseek-ai/deepseek-llm-7b-chat deepseek-ai/deepseek-llm-7b-chat ln -s /Users/junjian/HuggingFace/deepseek-ai/deepseek-coder-1.3b-instruct deepseek-ai/deepseek-coder-1.3b-instruct
- ChatGLM
mkdir THUDM ln -s /Users/junjian/HuggingFace/THUDM/chatglm3-6b THUDM/chatglm3-6b
Embedding LLM
- bge
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
Embedding LLM
- BAAI/bge-base-zh-v1.5
python -m fastchat.serve.model_worker \ --model-path BAAI/bge-base-zh-v1.5 --port 21100 \ --worker-address http://localhost:21100 \ --model-names bge-base-zh,text-embedding-ada-002 \ --device mps
- BAAI/bge-base-zh-v1.5
- BAAI/bge-large-zh-v1.5
LLM
- THUDM/chatglm3-6b
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 \ --device mps
- deepseek-ai/deepseek-llm-7b-chat
python -m fastchat.serve.model_worker \ --model-path deepseek-ai/deepseek-llm-7b-chat --port 21002 \ --worker-address http://localhost:21002 \ --device mps
Code LLM
- deepseek-ai/deepseek-coder-1.3b-instruct
python -m fastchat.serve.model_worker \ --model-path deepseek-ai/deepseek-coder-1.3b-instruct --port 21002 \ --worker-address http://localhost:21002 \ --device mps
OpenAI API Server
python -m fastchat.serve.openai_api_server
Web Server
python -m fastchat.serve.gradio_web_server
访问浏览器:http://localhost:7860/
停止服务
kill -9 $(pgrep -f fastchat)
清除日志
rmlog.sh
rm *-conv.json
rm controller.log*
rm model_worker_*.log
rm gradio_web_server.log*
rm gradio_web_server_multi.log*
rm openai_api_server.log*
测试 OpenAI API
curl http://127.0.0.1:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-llm-7b-chat",
"prompt": "天空为什么是蓝色的?",
"temperature": 0.7,
"max_tokens": 1000
}'