FastChat 大模型部署推理;Baichuan2-13B-Chat测试、chatglm2-6b测试

参考:
https://github.com/lm-sys/FastChat
https://blog.csdn.net/qq128252/article/details/132759107

##安装
pip3 install "fschat[model_worker,webui]"

1、chatglm2-6b测试

python3 -m fastchat.serve.cli --model-path ./chatglm2-6b --num-gpus 2

在这里插入图片描述

web使用

1)启动控制器

python3 -m fastchat.serve.controller

2)启动模型工作

python3 -m fastchat.serve.model_worker --model-path ./chatglm2-6b --num-gpus 2  --host=0.0.0.0  --port=21002

3)web服务启动

python3 -m fastchat.serve.gradio_web_server

在这里插入图片描述
打开网址查看:
在这里插入图片描述

api服务

1)启动控制器

python3 -m fastchat.serve.controller

2)启动模型工作

python3 -m fastchat.serve.model_worker --model-path ./chatglm2-6b --num-gpus 2  --host=0.0.0.0  --port=21002

3)web服务启动

python3 -m fastchat.serve.api --host 0.0.0.0

4)客户端访问

import requests
import json


headers = {"Content-Type": "application/json"}
pload = {
    "model": "chatglm2-6b",
    "messages": [
      {
        "role": "system",
        "content": "AI专家"
      },
      {
        "role": "user",
        "content": "你AI小助手,小名昵称为小乐,你主要擅长是智慧城***过30个字"
      },
      {"role": "assistant",
		"content": "好的,小乐很乐意为你服务"},
      {
        "role": "user",
        "content": "你能做啥?"
      }
    ]
  }
response = requests.post("http://192****:8000/v1/chat/completions", headers=headers, json=pload, stream=True)
print(response.text)

在这里插入图片描述

2、Baichuan2-13B-Chat测试

##运行命令:

python3 -m fastchat.serve.cli --model-path ./Baichuan2-13B-Chat --num-gpus 4

在这里插入图片描述

1)ValueError: Tokenizer class BaichuanTokenizer does not exist or is not currently imported. 2)offload报错,ValueError: The current device_map had weights offloaded to the disk. Please provide an offload_folder for them.也需要增加

按照报错信息需要更改:
/site-packages/fastchat/serve/inference.py

增加trust_remote_code=True
在这里插入图片描述文章来源地址https://uudwc.com/A/rZ3ab

原文地址:https://blog.csdn.net/weixin_42357472/article/details/133199866

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请联系站长进行投诉反馈,一经查实,立即删除!

h
上一篇 2023年09月23日 17:49
微信公众号开发以及测试公众号前端自测网页授权
下一篇 2023年09月23日 17:49