微调时使用bmtrain加载模型报错 Error(s) in loading state_dict for CPMBee
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.4k
- Forks
- 176
- PR merge metrics
- No merged PRs in 30d
Description
使用finetune_cpm_bee微调时,基础模型加载不了
finetune_cpm_bee.sh中的参数如下:
OPTS+=" --use-delta"
OPTS+=" --model-config config/cpm-bee-1b.json"
...
OPTS+=" --load cpm-bee-1b/pytorch_model.bin"
报错信息如下
/home/lzr/CPM-Bee/src/finetune_cpm_bee.py:39 in get_model │
│ │
│ 36 │ config = CPMBeeConfig.from_json_file(args.model_config) │
│ 37 │ model = CPMBee(config) │
│ 38 │ if args.load is not None: │
│ ❱ 39 │ │ bmt.load(model, args.load) │
│ 40 │ else: │
│ 41 │ │ bmt.init_parameters(model) │
│ 42 │ # insert LoRA │
│ │
│ /home/lzr/.conda/envs/cpm/lib/python3.10/site-packages/bmtrain/store.py:227 in load │
│ │
│ 224 │ else: │
│ 225 │ │ state_dict = DistributedStateDictWrapper({}) │
│ 226 │ │
│ ❱ 227 │ ret = model.load_state_dict( │
│ 228 │ │ state_dict, │
│ 229 │ │ strict = strict │
│ 230 │ ) │
│ │
│ /home/lzr/.conda/envs/cpm/lib/python3.10/site-packages/torch/nn/modules/module.py:1671 in │
│ load_state_dict │
│ │
│ 1668 │ │ │ │ │ │ ', '.join('"{}"'.format(k) for k in missing_keys))) │
│ 1669 │ │ │
│ 1670 │ │ if len(error_msgs) > 0: │
│ ❱ 1671 │ │ │ raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( │
│ 1672 │ │ │ │ │ │ │ self.class.name, "\n\t".join(error_msgs))) │
│ 1673 │ │ return _IncompatibleKeys(missing_keys, unexpected_keys) │
│ 1674 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Error(s) in loading state_dict for CPMBee:
Missing key(s) in state_dict: "encoder.layers.1.self_att.layernorm_before_attention.weight",
"encoder.layers.1.self_att.self_attention.project_q.weight", "encoder.layers.1.self_att.self_attention.project_k.weight",
"encoder.layers.1.self_att.self_attention.project_v.weight", "encoder.layers.1.self_att.self_attention.attention_out.weight",
...
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with finetune_cpm_bee.sh and the get_model entry point in src/finetune_cpm_bee.py, then inspect config/cpm-bee-1b.json and the checkpoint passed to --load. Reproduce the bmt.load failure and compare the model's expected state keys with the checkpoint contents. Done means the base model loads without missing keys and fine-tuning can start.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100