我用的程序是:
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("ZhipuAI/chatglm2-6b-int4", trust_remote_code=True)
model = AutoModel.from_pretrained("ZhipuAI/chatglm2-6b-int4", trust_remote_code=True).cuda()
model = model.eval()
response, history = model.chat(tokenizer, "你好", history=[])
response, history = model.chat(tokenizer, "晚上睡不着应该怎么办", history=history)
print(response)
出的错误是:
File ~/.cache/huggingface/modules/transformers_modules/chatglm2-6b-int4/quantization.py:287, in extract_weight_to_half(weight, scale_list, source_bit_width)
285 func = kernels.int8WeightExtractionHalf
286 elif source_bit_width == 4:
--> 287 func = kernels.int4WeightExtractionHalf
288 else:
289 assert False, "Unsupported bit-width"
AttributeError: 'NoneType' object has no attribute 'int4WeightExtractionHalf'
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352