-
Notifications
You must be signed in to change notification settings - Fork 143
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
基于提供的模型进行sft报错 #13
Comments
首先感谢反馈。
# step 2. 加载预训练模型
model = None
if os.path.isdir(config.finetune_from_ckp_file):
# 传入文件夹则 from_pretrained
model = TextToTextModel.from_pretrained(config.finetune_from_ckp_file)
else:
# load_state_dict
t5_config = get_T5_config(T5ModelConfig(), vocab_size=len(tokenizer), decoder_start_token_id=tokenizer.pad_token_id, eos_token_id=tokenizer.eos_token_id)
model = TextToTextModel(t5_config)
model.load_state_dict(torch.load(config.finetune_from_ckp_file, map_location='cpu')) # set cpu for no exception |
第三步,我就是在model = TextToTextModel.from_pretrained(config.finetune_from_ckp_file)这一行报的错,我已经把模型的文件放到model_save/pretrain下面了,中间没有其他文件夹。但是就是报错Error while deserializing header: HeaderTooLarge |
你的这个 ├─model_save
| ├─config.json
| ├─configuration_chat_model.py
| ├─generation_config.json
| ├─model.safetensors
| ├─modeling_chat_model.py
| ├─special_tokens_map.json
| ├─tokenizer.json
| └─tokenizer_config.json |
model_svae目录下面自带一个tokenizer文件是历史遗留问题了2333,当时做的时候没规划好。我都想删了但是又怕别人会用到或者等会哪里又报错了。 |
还是不行,文件的位置、内容,现在都和代码是符合的,但是跑sft的时候,就是报safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
model_id = 'charent/ChatLM-mini-Chinese'
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id, trust_remote_code=True).to(device) |
我去搜了一下这个错误,就是模型文件的问题,文件不完整,重新下载即可。我这边提供通过 1de0ba231817fcdaf97e025aa0dfcd00 config.json
e7356676de6c8bad26d2c7ceedc92fad generation_config.json
655bcc42640baefba8b188a0aa65d339 model.safetensors
adeee419c31a613d7dd281b736e3873a modeling_chat_model.py
ba22587440fe5ff64aab2cb552cb8654 special_tokens_map.json
0b65eef22c7fb9e1c16a4e51f359134a tokenizer.json
9fc5ebbabcf9eb5ad752e16649938afc tokenizer_config.json |
问题解决了,因为没有装git lfs,导致模型文件下载不全。建议在readme里面把检测有没有git lfs的步骤放一下。 |
我在readme已经写了要通过git命令下载文件的话要先安装Git LFS。我看还有人直接使用浏览器手动下载再移动过去的,我就没有标重点,我下次更新readme的时候改一下吧。 第二个问题,你说的是两个 两个方法都行,我的代码里面本地加载模型都是用的 |
几个问题:
1、3.2.3 下载预训练模型及模型配置文件,模型下载下来的名字是ChatLM-mini-Chinese,但是命令里面是mv ChatLM-Chinese-0.2B model_save,文件夹名字不匹配
2、模型文件夹放到model_save下,用python sft_train.py,报错说不存在model_save/pretrain目录
3、把文件夹改名为pretrain后,用python sft_train.py,报错说Error while deserializing header: HeaderTooLarge
网上有说把safetensors的后缀改成ckpt,试了一下,报错说找不到OSError: Error no file named pytorch_model.bin, tf_model.h5, model.ckpt.index or flax_model.msgpack found in directory。
怎么才能把sft跑起来?
The text was updated successfully, but these errors were encountered: