yuanzhoulvpi2017 / zero_nlp

中文nlp解决方案(大模型、数据、模型、训练、推理)
MIT License
2.95k stars 363 forks source link

使用训练后的模型报错 #41

Closed bh4ffu closed 1 year ago

bh4ffu commented 1 year ago

代码: `from transformers import AutoTokenizer from thuglm.modeling_chatglm import ChatGLMForConditionalGeneration import torch

model = ChatGLMForConditionalGeneration.from_pretrained(".//test005//checkpoint-300").cuda() tokenizer = AutoTokenizer.from_pretrained("thuglm", trust_remote_code=True)

with torch.autocast("cuda"): res, history = model.chat(tokenizer=tokenizer, query="你是谁? ")

res = model.forward(input_ids=all_input.get('input_ids').cuda())

print(res)`

报错: Traceback (most recent call last): File "simple_api.py", line 5, in model = ChatGLMForConditionalGeneration.from_pretrained(".//test005//checkpoint-300").cuda() File "/usr/local/python3/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2274, in from_pretrained raise EnvironmentError( OSError: Error no file named pytorch_model.bin, tf_model.h5, model.ckpt.index or flax_model.msgpack found in directory .//test005//checkpoint-300.

bh4ffu commented 1 year ago

test005/checkpoint-300下的文件如下: -rw-r--r-- 1 root root 14700127 Mar 30 16:03 chatglm-lora.pt -rw-r--r-- 1 root root 697 Mar 30 16:14 config.json -rw-r--r-- 1 root root 29393541 Mar 30 16:03 optimizer.pt -rw-r--r-- 1 root root 14575 Mar 30 16:03 rng_state.pth -rw-r--r-- 1 root root 557 Mar 30 16:03 scaler.pt -rw-r--r-- 1 root root 627 Mar 30 16:03 scheduler.pt -rw-r--r-- 1 root root 2235 Mar 30 16:03 trainer_state.json

yuanzhoulvpi2017 commented 1 year ago

看最新的readme.md

bh4ffu commented 1 year ago

@yuanzhoulvpi2017 截图的代码能贴一下么?

yuanzhoulvpi2017 commented 1 year ago

具体查看这个issue:https://github.com/yuanzhoulvpi2017/zero_nlp/issues/39

bh4ffu commented 1 year ago

昨天都跑通了,训练了一下我们领域内的数据,有效果,持续关注,感谢 @yuanzhoulvpi2017