0

我正在使用simpletransformers库在具有 13 个不同实体的自定义数据集上微调命名实体识别 (NER) 的 BERT 模型。即使在提供之后model_args.labels_list,也会NERModel()产生以下错误。

RuntimeError: Error(s) in loading state_dict for BertForTokenClassification:
    size mismatch for classifier.weight: copying a param with shape torch.Size([9, 768]) from checkpoint, the shape in current model is torch.Size([13, 768]).
    size mismatch for classifier.bias: copying a param with shape torch.Size([9]) from checkpoint, the shape in current model is torch.Size([13]).

示例代码:

from simpletransformers.ner import NERModel, NERArgs

model_args = NERArgs()
model_args.labels_list = ["ENT1", "ENT2", "ENT3", "ENT4", "ENT5", "ENT6", "ENT7", "ENT8", "ENT9", "ENT10", "ENT11", "ENT12", "ENT13"]  # this list is having thirteen entities from my dataset

model = NERModel(
    "bert",
    "dslim/bert-base-NER",
    args=model_args,
)
4

1 回答 1

0

我有同样的问题。我更新了我的 simpletransformers,它解决了这个问题。

于 2022-02-21T04:19:20.490 回答