FreedomIntelligence / HuatuoGPT

HuatuoGPT, Towards Taming Language Models To Be a Doctor. (An Open Medical GPT)
Apache License 2.0
1.08k stars 142 forks source link

13b convert OSError: Unable to load weights from pytorch checkpoint file #24

Closed w179962443 closed 11 months ago

w179962443 commented 1 year ago

root@instance:/home/wy/HuatuoGPT-main# python apply_delta.py --base-model-path /data/nvme0/model/llama-13b-hf --target-model-path /data/nvme0/wy/huatuo-13b_converted --delta-path /data/nvme0/wy/HuatuoGPT-13B Loading the base model from /data/nvme0/model/llama-13b-hf Setting ds_accelerator to cuda (auto detect) Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████| 3/3 [00:12<00:00, 4.15s/it] Loading the delta from /data/nvme0/wy/HuatuoGPT-13B Loading checkpoint shards: 0%| | 0/7 [00:00<?, ?it/s] Traceback (most recent call last): File "/data/nvme0/lg/anaconda3/envs/belle/lib/python3.8/site-packages/transformers/modeling_utils.py", line 463, in load_state_dict return torch.load(checkpoint_file, map_location="cpu") File "/data/nvme0/lg/anaconda3/envs/belle/lib/python3.8/site-packages/torch/serialization.py", line 797, in load with _open_zipfile_reader(opened_file) as opened_zipfile: File "/data/nvme0/lg/anaconda3/envs/belle/lib/python3.8/site-packages/torch/serialization.py", line 283, in init super().init(torch._C.PyTorchFileReader(name_or_buffer)) RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/data/nvme0/lg/anaconda3/envs/belle/lib/python3.8/site-packages/transformers/modeling_utils.py", line 467, in load_state_dict if f.read(7) == "version": File "/data/nvme0/lg/anaconda3/envs/belle/lib/python3.8/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 128: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "apply_delta.py", line 40, in apply_delta(args.base_model_path, args.target_model_path, args.delta_path) File "apply_delta.py", line 18, in apply_delta delta = AutoModelForCausalLM.from_pretrained(delta_path, torch_dtype=torch.float16, low_cpu_mem_usage=True) File "/data/nvme0/lg/anaconda3/envs/belle/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py", line 484, in from_pretrained return model_class.from_pretrained( File "/data/nvme0/lg/anaconda3/envs/belle/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2881, in from_pretrained ) = cls._load_pretrained_model( File "/data/nvme0/lg/anaconda3/envs/belle/lib/python3.8/site-packages/transformers/modeling_utils.py", line 3214, in _load_pretrained_model state_dict = load_state_dict(shard_file) File "/data/nvme0/lg/anaconda3/envs/belle/lib/python3.8/site-packages/transformers/modeling_utils.py", line 479, in load_state_dict raise OSError( OSError: Unable to load weights from pytorch checkpoint file for '/data/nvme0/wy/HuatuoGPT-13B/pytorch_model-00001-of-00007.bin' at '/data/nvme0/wy/HuatuoGPT-13B/pytorch_model-00001-of-00007.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

heheda166 commented 1 year ago

I have the same issue with you

jymChen commented 1 year ago

Hi @w179962443 @heheda166 ,

Thanks for reporting the error! We've fixed this error and uploaded the correct delta weights of our 13B model. Please re-download the delta weights at https://huggingface.co/FreedomIntelligence/HuatuoGPT-13b-delta.

Best, Junying

shelfofclub commented 1 year ago

~@jymChen The 7B model has the similar bug. (commit 67f0603659ec598cb72c700fa15434408488f7bd in the 🤗 model repo)~ Sorry. One of my downloaded ckpt file is incomplete. It is difficult to download files from 🤗 recently. 😥