Skip to content

更换bert-base-chinese #4

@YaelLee

Description

@YaelLee

你好,我这边想更换预训练的模型,改为使用bert-base-multilingual-cased,可以正常训练并且保存模型,但是运行detector时会报错:

Traceback (most recent call last):
File "detector.py", line 220, in
model = JointIntentSlotDetector.from_pretrained(
File "detector.py", line 27, in from_pretrained
model = JointBert.from_pretrained(
File "/home/liye/.local/lib/python3.8/site-packages/transformers/modeling_utils.py", line 3706, in from_pretrained
) = cls._load_pretrained_model(
File "/home/liye/.local/lib/python3.8/site-packages/transformers/modeling_utils.py", line 4166, in _load_pretrained_model
raise RuntimeError(f"Error(s) in loading state_dict for {model.class.name}:\n\t{error_msg}")
RuntimeError: Error(s) in loading state_dict for JointBert:
size mismatch for seq_heads.0.weight: copying a param with shape torch.Size([14, 768]) from checkpoint, the shape in current model is torch.Size([15, 768]).
size mismatch for seq_heads.0.bias: copying a param with shape torch.Size([14]) from checkpoint, the shape in current model is torch.Size([15]).
You may consider adding ignore_mismatched_sizes=True in the model from_pretrained method.
想请教一下这是什么原因?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions