[BUG/Help] AttributeError: 'ChatGLMTokenizer' object has no attribute 'build_chat_input'
sofia-lrf opened this issue · 2 comments
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
根据官方文档,部署执行,调用model时报错了
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, device='cuda')
model = model.eval()
response, history = model.chat(tokenizer, "你好", history=[])
print(response)
Expected Behavior
No response
Steps To Reproduce
1.根据之前的issue,重新执行安装了pip install transformers==4.33.0
2.在执行response, history = model.chat(tokenizer, "你好", history=[])的时候报了以下错
AttributeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 response, history = model.chat(tokenizer, "你好", history=[])
1 frames
~/.cache/huggingface/modules/transformers_modules/THUDM/chatglm3-6b/6f3b58ec10f088978ae174398f9d20b6dfc71552/modeling_chatglm.py in chat(self, tokenizer, query, history, role, max_length, num_beams, do_sample, top_p, temperature, logits_processor, **kwargs)
1036 gen_kwargs = {"max_length": max_length, "num_beams": num_beams, "do_sample": do_sample, "top_p": top_p,
1037 "temperature": temperature, "logits_processor": logits_processor, **kwargs}
-> 1038 inputs = tokenizer.build_chat_input(query, history=history, role=role)
1039 inputs = inputs.to(self.device)
1040 eos_token_id = [tokenizer.eos_token_id, tokenizer.get_command("<|user|>"),
AttributeError: 'ChatGLMTokenizer' object has no attribute 'build_chat_input'
Environment
- OS: Ubuntu
- Python:Python 3.10.12
- Transformers:4.33.0
- PyTorch:2.3.0+cu121
- CUDA Support (`python -c "import torch; print(torch.cuda.is_available())"`) :True
Anything else?
No response
python3 web_demo.py
/root/ChatGLM-6B/web_demo.py:44: SyntaxWarning: invalid escape sequence '`'
line = line.replace("", "\
")
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
Loading model from: /root/chatglm3-6b
Traceback (most recent call last):
File "/root/ChatGLM-6B/web_demo.py", line 7, in
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/transformers/models/auto/tokenization_auto.py", line 865, in from_pretrained
return tokenizer_class.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/transformers/tokenization_utils_base.py", line 2110, in from_pretrained
return cls._from_pretrained(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/transformers/tokenization_utils_base.py", line 2336, in _from_pretrained
tokenizer = cls(*init_inputs, **init_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.cache/huggingface/modules/transformers_modules/chatglm3-6b/tokenization_chatglm.py", line 109, in init
self.tokenizer = SPTokenizer(vocab_file)
^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.cache/huggingface/modules/transformers_modules/chatglm3-6b/tokenization_chatglm.py", line 17, in init
assert os.path.isfile(model_path), model_path
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 30, in isfile
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
另外在把模型拉取到本地以后,加载模型的时候还报了这个错,貌似不支持本地路径
已解决
是下载的模型文件有问题