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

TypeError: ChatGLMTokenizer._pad() got an unexpected keyword argument 'padding_side' #1324

Open
1 of 2 tasks
jeejeelee opened this issue Sep 26, 2024 · 19 comments · Fixed by intel-analytics/ipex-llm#12185
Open
1 of 2 tasks
Assignees

Comments

@jeejeelee
Copy link

jeejeelee commented Sep 26, 2024

System Info / 系統信息

torch==2.4.0
transformers==4.45.0

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

No response

Information / 问题信息

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

Reproduction / 复现过程

Step1

升级到transformers到4.45.0

Step2

运行如下代码:

from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True)
model = AutoModel.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True).half().cuda()
model = model.eval()
response, history = model.chat(tokenizer, "你好", history=[])
print(response)
response, history = model.chat(tokenizer, "晚上睡不着应该怎么办", history=history)
print(response)

Expected behavior / 期待表现

应该需要更新HF仓库中的:ChatGLMTokenizer._pad 的参数

@jeejeelee
Copy link
Author

@zRzRzRzRzRzRzR 辛苦花点时间看下这个问题,glm4也存在类似问题,非常感谢~

@lilqz66
Copy link

lilqz66 commented Sep 27, 2024

import torch
from datasets import Dataset
from diffusers import FluxPipeline, KolorsPipeline
from PIL import Image # 导入PIL库用于保存图片

from yijian_community.defense import InternVL2ImageDefense, ThuCoaiShieldLM
from yijian_community.model import HFTxt2ImgInfer

def txt2img_zh_usage_example(txt2img_zh_model="/mnt/public/lqz/prompt_attack/Kolors-diffusers"):
txt2img_zh = HFTxt2ImgInfer(
model_path=txt2img_zh_model,
pipe=KolorsPipeline,
variant="fp16",
)

# 生成一张图片
text_prompt = "今天天气很好。"
img = txt2img_zh.infer_data(
    data=text_prompt, guidance_scale=5.0, num_inference_steps=50
)


# 保存图片到指定路径
output_path = "test.jpg"
img.save(output_path)  # 保存图片

print(f"图片已保存到 {output_path}")

txt2img_zh_usage_example()

kolor文本好像用的是chaglm3,现在也会报错:
TypeError: ChatGLMTokenizer._pad() got an unexpected keyword argument 'padding_side'

环境:
Package Version


accelerate 0.34.2
aiohappyeyeballs 2.4.0
aiohttp 3.10.5
aioprometheus 23.12.0
aiosignal 1.3.1
annotated-types 0.7.0
anyio 4.5.0
async-timeout 4.0.3
attrs 24.2.0
bert-score 0.3.13
certifi 2024.8.30
charset-normalizer 3.3.2
click 8.1.7
cloudpickle 3.0.0
colorama 0.4.6
contourpy 1.3.0
cycler 0.12.1
datasets 3.0.0
diffusers 0.30.3
dill 0.3.8
diskcache 5.6.3
distro 1.9.0
einops 0.8.0
exceptiongroup 1.2.2
fastapi 0.115.0
filelock 3.16.1
fonttools 4.53.1
frozenlist 1.4.1
fsspec 2024.6.1
gguf 0.10.0
h11 0.14.0
httpcore 1.0.5
httptools 0.6.1
httpx 0.27.2
huggingface-hub 0.25.0
idna 3.10
importlib_metadata 8.5.0
iniconfig 2.0.0
interegular 0.3.3
jieba 0.42.1
Jinja2 3.1.4
jiter 0.5.0
joblib 1.4.2
jsonschema 4.23.0
jsonschema-specifications 2023.12.1
kiwisolver 1.4.7
lark 1.2.2
llvmlite 0.43.0
lm-format-enforcer 0.10.6
lxml 5.3.0
markdown-it-py 3.0.0
MarkupSafe 2.1.5
matplotlib 3.9.2
mdurl 0.1.2
mistral_common 1.4.3
mpmath 1.3.0
msgpack 1.1.0
msgspec 0.18.6
multidict 6.1.0
multiprocess 0.70.16
nest-asyncio 1.6.0
networkx 3.3
ninja 1.11.1.1
numba 0.60.0
numpy 1.26.4
nvidia-cublas-cu12 12.1.3.1
nvidia-cuda-cupti-cu12 12.1.105
nvidia-cuda-nvrtc-cu12 12.1.105
nvidia-cuda-runtime-cu12 12.1.105
nvidia-cudnn-cu12 9.1.0.70
nvidia-cufft-cu12 11.0.2.54
nvidia-curand-cu12 10.3.2.106
nvidia-cusolver-cu12 11.4.5.107
nvidia-cusparse-cu12 12.1.0.106
nvidia-ml-py 12.560.30
nvidia-nccl-cu12 2.20.5
nvidia-nvjitlink-cu12 12.6.68
nvidia-nvtx-cu12 12.1.105
openai 1.50.0
orjson 3.10.7
outlines 0.0.46
packaging 24.1
pandas 2.2.2
partial-json-parser 0.2.1.1.post4
pillow 10.4.0
pip 24.2
pluggy 1.5.0
portalocker 2.10.1
prometheus_client 0.21.0
prometheus-fastapi-instrumentator 7.0.0
protobuf 5.28.2
psutil 6.0.0
py-cpuinfo 9.0.0
pyairports 2.1.1
pyarrow 17.0.0
pycountry 24.6.1
pydantic 2.9.2
pydantic_core 2.23.4
Pygments 2.18.0
pyparsing 3.1.4
pytest 8.3.3
python-dateutil 2.9.0.post0
python-dotenv 1.0.1
pytz 2024.2
PyYAML 6.0.2
pyzmq 26.2.0
quantile-python 1.1
ray 2.36.0
referencing 0.35.1
regex 2024.9.11
requests 2.32.3
rich 13.8.1
rouge-metric 1.0.1
rpds-py 0.20.0
sacrebleu 2.4.3
safetensors 0.4.5
scikit-learn 1.5.2
scipy 1.14.1
sentence-transformers 3.1.1
sentencepiece 0.2.0
setuptools 59.6.0
six 1.16.0
sniffio 1.3.1
starlette 0.38.5
sympy 1.13.3
tabulate 0.9.0
threadpoolctl 3.5.0
tiktoken 0.7.0
timm 1.0.9
tokenizers 0.20.0
tomli 2.0.1
torch 2.4.0
torchvision 0.19.0
tqdm 4.66.5
transformers 4.45.1
triton 3.0.0
typing_extensions 4.12.2
tzdata 2024.1
urllib3 2.2.3
uvicorn 0.30.6
uvloop 0.20.0
vllm 0.6.2
watchfiles 0.24.0
websockets 13.0.1
xformers 0.0.27.post2
xxhash 3.5.0
yarl 1.11.1
yijian-community 0.1.4
zipp 3.20.2

@LeiyanGithub
Copy link

chatglm3-6b-32k报错
image

@bjr-yql
Copy link

bjr-yql commented Sep 29, 2024

kolors也使用了chatglm也存在这个问题,把transformers库的版本下降到Version: 4.34.0可以解决这个问题

@LeiyanGithub
Copy link

kolors也使用了chatglm也存在这个问题,把transformers库的版本下降到Version: 4.34.0可以解决这个问题
请问只是降低了版本就解决了么?我这边尝试发现还是没法解决呢

@jeejeelee
Copy link
Author

kolors也使用了chatglm也存在这个问题,把transformers库的版本下降到Version: 4.34.0可以解决这个问题
请问只是降低了版本就解决了么?我这边尝试发现还是没法解决呢

4.43.0 应该可以解决这个问题。
PS: 建议遇到类似问题的,可以去GLM4的repo提issue,可能会响应更快点(GLM4也存在类似的问题)

@huolongguo1O
Copy link

modelscope上说了是chatglm不支持最新版本

@LeiyanGithub
Copy link

kolors也使用了chatglm也存在这个问题,把transformers库的版本下降到Version: 4.34.0可以解决这个问题
请问只是降低了版本就解决了么?我这边尝试发现还是没法解决呢

4.43.0 应该可以解决这个问题。 PS: 建议遇到类似问题的,可以去GLM4的repo提issue,可能会响应更快点(GLM4也存在类似的问题)

之前的问题解决了,貌似出现了新的问题,vllm不支持这个版本!
image

@zRzRzRzRzRzRzR
Copy link
Member

已经收到这个问题,预计节后投入人力解决

@zRzRzRzRzRzRzR zRzRzRzRzRzRzR self-assigned this Oct 1, 2024
@countzero
Copy link

Hi,

I ran into the same error in the context of llama.cpp trying to convert https://huggingface.co/THUDM/glm-4-9b-chat to GGUF.

Error

TypeError: ChatGLM4Tokenizer._pad() got an unexpected keyword argument 'padding_side'

Workaround

Downgrade the transformers package to version 4.44.2:

pip uninstall transformers -y; pip install transformers==4.44.2

It seems as if this bug is introduced with the transformers release v4.45.0.

I hope this helps someone 😉

@wuhanzhuyang
Copy link

降低版本到4.40.2,可以了
pip uninstall transformers -y; pip install transformers==4.40.2

@Orenji-Tangerine
Copy link

Can Transformers 4.45.0 run without errors now? If not, any plan to address this?

@BLANKBLK
Copy link

BLANKBLK commented Oct 9, 2024

换成4.40会出现新的错误,怎么办?
ModuleNotFoundError: No module named 'transformers.models.phi3'

@huolongguo1O
Copy link

换成4.40会出现新的错误,怎么办? ModuleNotFoundError: No module named 'transformers.models.phi3'

换4.42
或移除phi3相关代码

@ababiya-worku
Copy link

Hi guys I have the same issue recently, even though i mainly use FLUX, I recently switched to KOLORS, which is literally MJV6.1 killer with lower CFG and samplers, But I have this issue of the GLM thing, I tried everything and its not working! pls help!

@ababiya-worku
Copy link

We have received this question and plan to invest manpower to solve it after the holiday.

please!!!!!

@huolongguo1O
Copy link

Hi guys I have the same issue recently, even though i mainly use FLUX, I recently switched to KOLORS, which is literally MJV6.1 killer with lower CFG and samplers, But I have this issue of the GLM thing, I tried everything and its not working! pls help!

Same as this issue?

@ababiya-worku
Copy link

Hi,

I ran into the same error in the context of llama.cpp trying to convert https://huggingface.co/THUDM/glm-4-9b-chat to GGUF.

Error

TypeError: ChatGLM4Tokenizer._pad() got an unexpected keyword argument 'padding_side'

Workaround

Downgrade the transformers package to version 4.44.2:

pip uninstall transformers -y; pip install transformers==4.44.2

It seems as if this bug is introduced with the transformers release v4.45.0.

I hope this helps someone 😉

unfortunately it didn't help bro! thank you though

@Foluolaaa
Copy link

可以参考这个解决方案
https://huggingface.co/THUDM/LongWriter-glm4-9b/commit/778b5712634889f5123d6c463ca383bc6dd5c621#d2h-069285

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

Successfully merging a pull request may close this issue.