使用魔搭社区部署AI

启动实例

通义千问7B模型启动

使用阿里提供的ModelScope Library,经过长时间的依赖安装,成功运行。

但是ModelScope的实例不够稳定且无法联网调用,这对开发造成了许多困难,因此还是需要本地部署。

本地安装

运行代码:

git clone https://github.com/Dao-AILab/flash-attention
cd flash-attention && pip install .

在本地安装成功后,运行示例代码:

from modelscope import AutoModelForCausalLM, AutoTokenizer
from modelscope import GenerationConfig
​
# Note: The default behavior now has injection attack prevention off.
tokenizer = AutoTokenizer.from_pretrained("qwen/Qwen-7B-Chat", trust_remote_code=True)
​
# use auto mode, automatically select precision based on the device.
model = AutoModelForCausalLM.from_pretrained("qwen/Qwen-7B-Chat", device_map="auto", trust_remote_code=True).eval()
​
# 第一轮对话 1st dialogue turn
response, history = model.chat(tokenizer, "你好", history=None)
print(response)
# 你好!很高兴为你提供帮助。

虽然成功运行,但是运行速度缓慢,且时不时会发生爆RAM的情况,运行失败。

需要编写Flask程序才能使用api接口调用本地的模型服务。

灵活度不高,完全是clone了通义千问的github库,在此基础上直接使用,经过尝试后放弃这个方案,考虑使用一些更加高度集成的工具进行辅助开发。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值