[Python] [fixed]Missing or Unexpected key(s) in state_dict [closed]

Discussão em 'Python' iniciado por Stack, Setembro 16, 2024.

  1. Stack

    Stack Membro Participativo

    I was trying to replicate a math reasoning model using RAG.

    I want to run the predict stage of its retrieval model.Its originally trained using a google byt5-small.

    So,I first write a py script to transfer the source model file from .safetensors to .ckpt. then, I config the transfered .ckpt file as the checkpoint(because the model is Pytorch Lightning module) then it says:

    self.trainer.strategy.load_model_state_dict(
    15944 File "/root/miniconda3/envs/lean/lib/python3.11/site-packages/pytorch_lightning/strategies/strategy.py", line 371, in load_model_state_dict
    15945 self.lightning_module.load_state_dict(checkpoint["state_dict"], strict=strict)
    15946 File "/root/miniconda3/envs/lean/lib/python3.11/site-packages/torch/nn/modules/module.py", line 2215, in load_state_dict
    15947 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
    15948 RuntimeError: Error(s) in loading state_dict for PremiseRetriever:
    15949 Missing key(s) in state_dict:....
    ...
    Unexpected key(s) in state_dict: ....

    Continue reading...

Compartilhe esta Página