Qwen2-1.5B-DI

我要开发同款
匿名用户2024年07月31日
46阅读
所属分类ai、qwen2、other
开源地址https://modelscope.cn/models/dash-infer/Qwen2-1.5B-DI
授权协议Apache License 2.0

作品详情

本模型是qwen/Qwen2-1.5BDashInfer格式模型。

requirements

pip install modelscope dashinfer jinja2 tabulate torch transformers

下载模型

from modelscope import snapshot_download
model_dir = snapshot_download("dash-infer/Qwen2-1.5B-DI")

模型推理

参考如下python代码。

```python import copy import random

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

modelpath = snapshotdownload("dash-infer/Qwen2-1.5B-DI")

configfile = modelpath + "/" + "diconfig.json" config = ConfigManager.getconfigfromjson(configfile) config["modelpath"] = model_path

init EngineHelper class

enginehelper = EngineHelper(config) enginehelper.verbose = True enginehelper.inittokenizer(model_path)

init engine

enginehelper.initengine()

prepare inputs and generation configs

userinput = "浙江的省会在哪" prompt = "<|imstart|>" + "system\n" + "You are a helpful assistant." + "<|imend|>\n" + \ "<|imstart|>" + "user\n" + userinput + "<|imend|>\n" + \ "<|imstart|>" + "assistant\n" gencfg = copy.deepcopy(enginehelper.defaultgencfg) gencfg["seed"] = random.randint(0, 10000) requestlist = enginehelper.createrequest([prompt], [gencfg])

inference

enginehelper.processonerequest(requestlist[0]) enginehelper.printinferenceresultall(request_list)

enginehelper.uninitengine()

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

评论