AI软件下载
有趣网站推荐及实用软件下载

isin() received an invalid combination of arguments - got (elements=Tensor, test_elements=int, ), but expected one of

今天在测试阿里通义千问Qwen-1_8B-Chat-Int8的模型的时候发生报错,部分错误信息如下:

Traceback (most recent call last):
File “.\request_llms\local_llm_class.py”, line 160, in run
for response_full in self.llm_stream_generator(*kwargs): File “.\request_llms\bridge_qwen_local.py”, line 46, in llm_stream_generator for response in self._model.chat_stream(self._tokenizer, query, history=history): File “.\huggingface\modules\transformers_modules\Qwen\Qwen-1_8B-Chat-Int8\2fb5c225fe592d8d891cbf6c1ed5924cabe48a18\modeling_qwen.py”, line 1214, in stream_generator for token in self.generate_stream( File “.\python3\lib\site-packages\torch\utils_contextlib.py”, line 116, in decorate_context return func(args, **kwargs)
File “.\python3\lib\site-packages\transformers_stream_generator\main.py”, line 208, in generate
] = self._prepare_attention_mask_for_generation(
File “.\python3\lib\site-packages\transformers\generation\utils.py”, line 473, in _prepare_attention_mask_for_generation
torch.isin(elements=inputs, test_elements=pad_token_id).any()
TypeError: isin() received an invalid combination of arguments – got (elements=Tensor, test_elements=int, ), but expected one of:

  • (Tensor elements, Tensor test_elements, *, bool assume_unique = False, bool invert = False, Tensor out = None)
  • (Number element, Tensor test_elements, *, bool assume_unique = False, bool invert = False, Tensor out = None)
  • (Tensor elements, Number test_element, *, bool assume_unique = False, bool invert = False, Tensor out = None)

意思就是在 torch.isin() 函数中传入的参数类型不匹配导致的。torch.isin 期望的是两个张量(Tensor)参数或者一个数字和一个张量的组合,而传入的是一个张量(elements)和一个整数(test_elements)。

需要修改torch部分功能代码解决,还有另一种方法就是重新安装transformers,将版本降到4.41.0以下,可解决此报错问题

1V1答疑支持
爱发电:点击前往
赞(0) 打赏
文章名称:《isin() received an invalid combination of arguments - got (elements=Tensor, test_elements=int, ), but expected one of》
文章链接:https://nuowa.net/941
本站原创文章未经允许不得转载,分享资源仅供个人学习研究,不可用于违法违规用途,否则法律问题自行承担。

最新发布

觉得文章对你有帮助就打赏一下作者

非常感谢你的打赏,我将有更多的动力继续提供优质内容,让我们一起创建更加美好的世界!

支付宝扫一扫

微信扫一扫