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

merge_lora后调用模型产生AttributeError: can't set attribute错误 #149

Open
Asakinevergup opened this issue Oct 29, 2024 · 1 comment

Comments

@Asakinevergup
Copy link

No description provided.

@Asakinevergup Asakinevergup changed the title merge_lora merge_lora后调用模型产生AttributeError: can't set attribute错误 Oct 29, 2024
@Asakinevergup
Copy link
Author

Asakinevergup commented Oct 29, 2024

你好 我在训练好lora,使用merge_lora后尝试调用模型时候产生了下列错误,您能帮我看看哪里出问题了吗?谢谢!
(ChatGLM) @n1:~/ChatGLM-Finetuning-master$ python test.py
Traceback (most recent call last):
File "test.py", line 7, in
tokenizer = ChatGLMTokenizer.from_pretrained(model_dir)
File "/home/.local/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 2048, in from_pretrained
return cls._from_pretrained(
File "/home/.local/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 2287, in _from_pretrained
tokenizer = cls(*init_inputs, **init_kwargs)
File "/home/ChatGLM-Finetuning-master/glm3/tokenization_chatglm.py", line 108, in init
super().init(padding_side=padding_side, clean_up_tokenization_spaces=clean_up_tokenization_spaces,
File "/home/.local/lib/python3.8/site-packages/transformers/tokenization_utils.py", line 363, in init
super().init(**kwargs)
File "/home/.local/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 1603, in init
super().init(**kwargs)
File "/home/.local/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 861, in init
setattr(self, key, value)
AttributeError: can't set attribute

//下列是我的测试代码
import torch
from transformers import AutoTokenizer, AutoModel
from glm3.tokenization_chatglm import ChatGLMTokenizer
model_dir='./output-glm3/epoch-2-step-720/'

//使用 ChatGLMTokenizer 从本地路径加载分词器
tokenizer = ChatGLMTokenizer.from_pretrained(model_dir)
model = AutoModel.from_pretrained(model_dir, trust_remote_code=True).to("cuda").eval()

//测试模型
response, history = model.chat(tokenizer, "hello", history=[])
print("Response:", response)

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