如何使用我们的自定义数据进一步预训练bert模型,并增加vocab大小?

2024-06-26 00:10:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用自定义数据进一步预训练bert基础模型。我下面的步骤如下:

  1. 从自定义数据生成单词列表,并将这些单词添加到现有的bert base vocab文件中。vocab大小已从35022增加到35880

  2. 我使用来自the bert official github pagecreate_pretraining_data.py创建了输入数据

  3. 使用运行\u pretraining.py执行预训练,但遇到不匹配错误:

ValueError: Shape of variable bert/embeddings/word_embeddings:0 ((35880, 128)) doesn't match with shape of tensor bert/embeddings/word_embeddings ([30522, 128]) from checkpoint reader.

注意:我将bert_config文件更改为vocab_size文件

请帮助我了解错误以及应该做哪些更改,以便我可以使用自定义vocab文件进行预训练


Tags: 文件ofpy模型列表错误步骤单词