[BUG/Help] <title>运行示例代码时出现 TypeError 错误
这个问题存在吗?
我搜索了现有的问题
当前的行为
{\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢? `从变压器导入自动调试器、自动模型 导入火炬 model path="/home/songxinyue/ new/models/chatglm2-6b" (中文(简体) ). 指示器 = AutoTokenizer. from pretrained(模式 路径,信任 remote code=True) 设备 = 火炬.device ("cuda: 2" 如果火炬.cuda.is 可使用性() 其他"cpu")
模型 = AutoModel. from pretrained(模型 路径,信任 remote code=True). float ().
一半( )
把模型移到设备上 #model.to(设备) 型号=型号. eval() 响应,历史=model.chat(tokenizer,"hello",历史=[]) 打印( 回复) 回应,历史=model.chat(tokenizer,"如果晚上不能入睡我该怎么办?",历史=历史) 打印(答复)”
‘------------------------------------------------------------------- --- ------ -- - - - -- -- - - - - -- - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- TypeError 追踪( 最近的一次调用) 单元格入 [1], 第 13行 9 #. half () (中文(简体) ). 10 # 将模型移动到设备上 11 # model.to( 设备) 12个型号=型号. eval() --- > 13个响应,历史=model.chat(tokenizer,"hello",历史=[]) 14 个印 (回复) 15回 历史=model.chat (tokenizer,"我晚上睡不着会怎么办",历史=历史).
文件~/ new/enview/enview/anaconda3/envs/sxy/lib/python3.10/ site-packages/torch/autograd/grad mode.py:27,收录于 Decorator Contextmanager. call ..decorate context (*args,**kwargs). 24 个 @ functools. wraps( func) 25 def decorate context(*args, **kwargs) : (中文(简体) ). 26 有自定义. clone (): --- > 27回真菌(*args, **kwargs)
文件~/.cache/huggingface/modules/transfers modules/chatglm2-6b/modeling chatglm.py:1033,收于ChatGLMForContitionalGeneration.chat(自有,标致器,查询,历史,最大 长度,num 束, do sample,top p,温度,logits 处理器,**kwargs) 1030 gen kwargs = {"最大 长度":最大 长度"num 束":num 束"多":多"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"出"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取"取" 1031"温度":温度,"logits 处理器":logits 处理器,**kwargs} 1032个输入 =自建 输入(切入器,查询,历史=历史)
1033 输出 = self.generate(**输入,**gen kwargs) 1034 输出 = 输出.tolist () [0][len (输入 ["输入 ids"][0] :] 1035响应 = sorder.decode(输出)
文件~/ new/enview/enview/anaconda3/envs/sxy/lib/python3.10/ site-packages/torch/autograd/grad mode.py:27,收录于 Decorator Contextmanager. call ..decorate context (*args,**kwargs). 24 个 @ functools. wraps( func) 25 def decorate context(*args, **kwargs) : (中文(简体) ). 26 有自定义. clone (): --- > 27回真菌(*args, **kwargs)
文件~/新/环境/anaconda3/envs/sxy/lib/python3.10/ site-packages/transfers/generation/utils.py:2015 在GeneralMixin.generate(自来自来,输入,生成-配置,logits 处理器,停止-标准,前缀-allomed tokens fn,同步 gpus,助手-模型,流子,负-prompt ids,负-prompt atention mask,**kwargs)中,有1个字头,有2个字头. 2007年输入 IDs, . . . . . . .
内容来源: zai-org/ChatGLM2-6B