Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

干净环境运行 trans_cli_demo.py 产生报错 TypeError: _pad() got an unexpected keyword argument 'padding_side' #577

Open
1 of 2 tasks
jiahuiLeee opened this issue Oct 6, 2024 · 0 comments

Comments

@jiahuiLeee
Copy link

System Info / 系統信息

python=3.9
CUDA Version: 12.4
GPU:4090 24G

新建的干净环境使用 pip install -r requirements.txt 安装的环境。安装版本与 requirements 相同

Who can help? / 谁可以帮助到您?

@wwewwt @cenyk1230

Information / 问题信息

  • The official example scripts / 官方的示例脚本
  • My own modified scripts / 我自己修改的脚本和任务

Reproduction / 复现过程

$ python /home/ljh/git/GLM-4/basic_demo/trans_cli_demo.py
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:01<00:00, 8.43it/s]
Some parameters are on the meta device because they were offloaded to the cpu.
Welcome to the GLM-4-9B CLI chat. Type your messages below.

You: 你好
Traceback (most recent call last):
File "/home/ljh/git/GLM-4/basic_demo/trans_cli_demo.py", line 82, in
model_inputs = tokenizer.apply_chat_template(
File "/home/ljh/.conda/envs/GLM4/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 1891, in apply_chat_template
out = self(
File "/home/ljh/.conda/envs/GLM4/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 3024, in call
encodings = self._call_one(text=text, text_pair=text_pair, **all_kwargs)
File "/home/ljh/.conda/envs/GLM4/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 3134, in _call_one
return self.encode_plus(
File "/home/ljh/.conda/envs/GLM4/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 3210, in encode_plus
return self._encode_plus(
File "/home/ljh/.conda/envs/GLM4/lib/python3.9/site-packages/transformers/tokenization_utils.py", line 801, in _encode_plus
return self.prepare_for_model(
File "/home/ljh/.conda/envs/GLM4/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 3706, in prepare_for_model
encoded_inputs = self.pad(
File "/home/ljh/.conda/envs/GLM4/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 3508, in pad
encoded_inputs = self._pad(
TypeError: _pad() got an unexpected keyword argument 'padding_side'


尝试降低版本为 transformers==4.44.2
可以正常回答,但是有警告信息(The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's attention_mask to obtain reliable results.),且响应十分缓慢。

Welcome to the GLM-4-9B CLI chat. Type your messages below.

You: 你好
GLM-4:The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's attention_mask to obtain reliable results.

您好👋!我是人工智能助手,很高兴为您服务。有什么可以帮助您的吗?

Expected behavior / 期待表现

麻烦更新修改后的代码~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant