shibing624 / MedicalGPT

MedicalGPT: Training Your Own Medical GPT Model with ChatGPT Training Pipeline. 训练医疗大模型,实现了包括增量预训练(PT)、有监督微调(SFT)、RLHF、DPO、ORPO。
Apache License 2.0
2.94k stars 452 forks source link

扩充词表后,预训练完成进行lora合并时出现size mismatch问题,请问这个问题该怎么解决 #322

Closed lainxx closed 4 months ago

lainxx commented 5 months ago

Loading LoRA for causal language model The argument trust_remote_code is to be used with Auto classes. It has no effect here and is ignored. Loading checkpoint shards: 0%| | 0/2 [00:00<?, ?it/s]/home/jovyan/.local/lib/python3.10/site-packages/torch/_utils.py:776: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() return self.fget.get(instance, owner)() Loading checkpoint shards: 100%|██████████████████| 2/2 [00:11<00:00, 5.50s/it] Traceback (most recent call last): File "/data/pe-task/ai_storage_base/chusiyi/my_train/MedicalGPT/merge_peft_adapter.py", line 109, in main() File "/data/pe-task/ai_storage_base/chusiyi/my_train/MedicalGPT/merge_peft_adapter.py", line 92, in main new_model = PeftModel.from_pretrained( File "/home/jovyan/.local/lib/python3.10/site-packages/peft/peft_model.py", line 352, in from_pretrained model.load_adapter(model_id, adapter_name, is_trainable=is_trainable, **kwargs) File "/home/jovyan/.local/lib/python3.10/site-packages/peft/peft_model.py", line 692, in load_adapter load_result = set_peft_model_state_dict(self, adapters_weights, adapter_name=adapter_name) File "/home/jovyan/.local/lib/python3.10/site-packages/peft/utils/save_and_load.py", line 201, in set_peft_model_state_dict load_result = model.load_state_dict(peft_model_state_dict, strict=False) File "/home/jovyan/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 2041, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for PeftModelForCausalLM: size mismatch for base_model.model.model.embed_tokens.modules_to_save.default.weight: copying a param with shape torch.Size([70840, 4096]) from checkpoint, the shape in current model is torch.Size([32000, 4096]). size mismatch for base_model.model.lm_head.modules_to_save.default.weight: copying a param with shape torch.Size([70840, 4096]) from checkpoint, the shape in current model is torch.Size([32000, 4096]).

shibing624 commented 5 months ago

resize model emb.