datawhalechina / self-llm

《开源大模型食用指南》基于Linux环境快速部署开源大模型,更适合中国宝宝的部署教程
Apache License 2.0
6.08k stars 748 forks source link

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

Open LSK-1 opened 2 weeks ago

hongmin118 commented 1 week ago

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

KMnO4-zx commented 1 week ago

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

freecow commented 1 week ago

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

hkxxxxx commented 1 week ago

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

AXYZdong commented 1 week ago

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

pip install transformers-4.41.2
AXYZdong commented 1 week ago

max_new_tokens (=256)

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

AXYZdong commented 1 week ago

可能是由于 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 应该不会报错了。

AXYZdong commented 1 week ago

max_new_tokens (=256)

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

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

参考 https://github.com/THUDM/ChatGLM3/issues/1215

hkxxxxx commented 1 week ago

可能是由于 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,成功运行!感谢大佬

hongmin118 commented 1 week ago

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