irlab-sdu / fuzi.mingcha

夫子•明察司法大模型是由山东大学、浪潮云、中国政法大学联合研发,以 ChatGLM 为大模型底座,基于海量中文无监督司法语料与有监督司法微调数据训练的中文司法大模型。该模型支持法条检索、案例分析、三段论推理判决以及司法对话等功能,旨在为用户提供全方位、高精准的法律咨询与解答服务。
Apache License 2.0
236 stars 17 forks source link

position_ids报错:'NoneType' object has no attribute 'max' #18

Closed buptzyf closed 1 month ago

buptzyf commented 1 month ago

您好,我在部署模型后,调用时,出现了下面这个错误,可能是什么原因呢?

File "/gemini/platform/public/users/yafeng/xinference/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "/gemini/platform/public/users/yafeng/xinference/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(*args, *kwargs) File "/root/.cache/huggingface/modules/transformers_modules/fuzi-mingcha-v1_0/modeling_chatglm.py", line 1190, in forward transformer_outputs = self.transformer( File "/gemini/platform/public/users/yafeng/xinference/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/gemini/platform/public/users/yafeng/xinference/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(*args, kwargs) File "/root/.cache/huggingface/modules/transformers_modules/fuzi-mingcha-v1_0/modeling_chatglm.py", line 996, in forward layer_ret = layer( File "/gemini/platform/public/users/yafeng/xinference/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/gemini/platform/public/users/yafeng/xinference/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(args, kwargs) File "/root/.cache/huggingface/modules/transformers_modules/fuzi-mingcha-v1_0/modeling_chatglm.py", line 627, in forward attention_outputs = self.attention( File "/gemini/platform/public/users/yafeng/xinference/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/gemini/platform/public/users/yafeng/xinference/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(args, **kwargs) File "/root/.cache/huggingface/modules/transformers_modules/fuzi-mingcha-v1_0/modeling_chatglm.py", line 460, in forward cos, sin = self.rotary_emb(q1, seq_len=position_ids.max() + 1) AttributeError: [address=127.0.0.1:45803, pid=116574] 'NoneType' object has no attribute 'max'

buptzyf commented 1 month ago

torch 2.2.2 torchaudio 2.2.2 torchvision 0.17.2

buptzyf commented 1 month ago

sentence-transformers 2.7.0 transformers 4.40.2 transformers-stream-generator 0.0.5

Furyton commented 1 month ago

您好,

请问您是用仓库里提供的示例代码 cli_demo.py 吗,或者您可以分享一下您的测试脚本。

一个可能的原因是我们(包括当时我们所基于的 ChatGLM 6B)使用的 transformers 库版本是 <=4.30.x,比您的版本低很多。

buptzyf commented 1 month ago

您好,

请问您是用仓库里提供的示例代码 cli_demo.py 吗,或者您可以分享一下您的测试脚本。

一个可能的原因是我们(包括当时我们所基于的 ChatGLM 6B)使用的 transformers 库版本是 <=4.30.x,比您的版本低很多。

感谢您的回复,我调了一天,找到了问题所在,我用的是第三方工具中的自定义模型来部署的,然后因为他们开发节奏比较快,文档不是很细,所以踩了一些坑,问题的原因是:当在部署时不选择模型家族(chatglm)时来部署,会导致他内部通过model(input****),这样的代码来调用模型,这会导致其调用modeling_chatglm.py中的forward函数,会导致上述问题,修改后,就会调用modeling_chatglm.py其中的chat函数了,感谢你们的贡献

image