【无标题python bit】

本文介绍了如何在Python项目中使用BitsandBytes模型库,通过`pipinstall`安装预训练的AutoModel,实现4位精度的模型加载,并展示如何利用该模型进行GPU加速的聊天交互。
摘要由CSDN通过智能技术生成

pip install bitsandbytes

from modelscope import AutoTokenizer, AutoModel, snapshot_download
model_dir = "E:\project\pythonProject1f\ZhipuAI"
tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
#model = AutoModel.from_pretrained(model_dir, trust_remote_code=True).half().cuda()
model = AutoModel.from_pretrained(model_dir, load_in_4bit=True, trust_remote_code=True)
model = model.eval()
response, history = model.chat(tokenizer, "你好", history=[])
print(response)
response, history = model.chat(tokenizer, "晚上睡不着应该怎么办", history=history)
print(response)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值