datawhalechina/self-llm

TypeError: transformers.generation.utils.GenerationMixin.generate() argument after ** must be a mapping, not Tensor

Opened this issue · 10 comments

LSK-1 commented
TypeError: transformers.generation.utils.GenerationMixin.generate() argument after ** must be a mapping, not Tensor

我也是这个错(GLM-4-9B-chat FastApi)
Snipaste_2024-06-21_17-00-34

请多提供一些报错信息,比如:

  • 什么环境,windows or linux?
  • fastapi的请求参数是什么?

也是报同样的错,环境是直接采用github推荐的AutoDL镜像self-llm/GLM-4,fastapi调用格式:
curl -X POST "http://127.0.0.1:6006"
-H 'Content-Type: application/json'
-d '{"prompt": "你好", "history": []}'

+1同样的错误,GLM-4-9B-Chat Fastapi:
image

可能是由于 transformers 版本低的问题,升级一下 transformers 可以解决。

pip install transformers-4.41.2

max_new_tokens (=256)

最大的token是设置的,没有回答完整很正常~

可能是由于 transformers 版本低的问题,升级一下 transformers 可以解决。

pip install transformers-4.41.2

在我的环境中transformers就是4.41.2这个版本,直接使用的autodl上的社区镜像,但是依然报错 Message: 'Both max_new_tokens (=256) and max_length(=272) seem to have been set. max_new_tokens will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)' Arguments: (<class 'UserWarning'>,) 且没有生成完整的回答: image

对于 fastapi 应该不会报错了。

max_new_tokens (=256)

最大的token是设置的,没有回答完整很正常~

这个在哪里设置呀,请大佬指条明路

参考 THUDM/ChatGLM3#1215

可能是由于 transformers 版本低的问题,升级一下 transformers 可以解决。

pip install transformers-4.41.2

在我的环境中transformers就是4.41.2这个版本,直接使用的autodl上的社区镜像,但是依然报错 Message: 'Both max_new_tokens (=256) and max_length(=272) seem to have been set. max_new_tokens will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)' Arguments: (<class 'UserWarning'>,) 且没有生成完整的回答: image

对于 fastapi 应该不会报错了。

是的,我在fastapi项目中重装了transformers==4.41.2,成功运行!感谢大佬

pip install transformers==4.41.2,OK,感谢大佬