GLM4-9B-chat-DI版本模型

我要开发同款
匿名用户2024年07月31日
32阅读
所属分类ai、chatglm、other
开源地址https://modelscope.cn/models/dash-infer/glm-4-9b-chat-DI
授权协议Apache License 2.0

作品详情

glm4-9b-chat-DI

本模型是glm4-9b-chat格式模型。

requirements

pip install modelscope dashinfer jinja2 tabulate torch transformers

下载模型

from modelscope import snapshot_download
model_dir = snapshot_download('dash-infer/glm-4-9b-chat-DI')

模型推理

参考如下python代码。

import copy
import random

from modelscope import snapshot_download
from dashinfer.helper import EngineHelper, ConfigManager

model_path = snapshot_download("dash-infer/glm-4-9b-chat-DI")

config_file = model_path + "/" + "di_config.json"
config = ConfigManager.get_config_from_json(config_file)
config["model_path"] = model_path

## init EngineHelper class
engine_helper = EngineHelper(config)
engine_helper.verbose = True
engine_helper.init_tokenizer(model_path)

## init engine
engine_helper.init_engine()

## prepare inputs and generation configs
user_input = "浙江的省会在哪"
prompt = "[gMASK] <sop> " + "<|user|>\n" + user_input + "<|assistant|>\n"
gen_cfg = copy.deepcopy(engine_helper.default_gen_cfg)
gen_cfg["seed"] = random.randint(0, 10000)
request_list = engine_helper.create_request([prompt], [gen_cfg])

## inference
engine_helper.process_one_request(request_list[0])
engine_helper.print_inference_result_all(request_list)

engine_helper.uninit_engine()
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论