前言
Fastchat是一个开源的(https://github.com/lm-sys/FastChat)大模型部署框架,能提供兼容OpenAI的APIs给web应用远程访问,也自带Gradio组件直接提供Web UI服务(不过现在一般都用Streamlit前端来构建webui)。
本文主要讨论如何使用fastchat来构建APIs并进行测试和问题汇总。
步骤
第一步安装: pip install fschat
我用的fastchat版本是0.2.35 openai版本为1.9.0
第二步启动整个fastchat的控制程序controller
python3 -m fastchat.serve.controller --host 0.0.0.0 --port 21001
第三步构建model_worker将本地模型加载进来,并注册到controller。这里面两个小细节:1)本电脑使用的是CPU加载推理,所以用到了参数--device cpu 缺省的话会使用Nvidia gpu加载;2)由于本电脑内存条只有16G,为了节省内存资源,使用了8bit压缩格式: --load-8bit
python3 -m fastchat.serve.model_worker --model-name 'Qwen-1_8B-Chat' --model-path /work/rag/HuggingFace-Download-Accelerator/Qwen-1_8B-Chat --device cpu --load-8bit
第四步