albert_zh icon indicating copy to clipboard operation
albert_zh copied to clipboard

预训练模型中没有spm_model_file文件

Open 34127chi opened this issue 6 years ago • 2 comments

在预训练模型中没有看到spm_model_file 能否提供下这个文件?谢谢🙏 因为我在实验的时候会用到transformers这个库 它的字典文件现在默认是支持这个spm_model_file

34127chi avatar Dec 09 '19 12:12 34127chi

这个不能用transformers的albert加载吧,即便是用BertTokenizer代替,也会报下面的错误

RuntimeError: Error(s) in loading state_dict for AlbertForClozeExtra:
        size mismatch for bert.embeddings.position_embeddings.weight: copying a param with shape torch.Size([512, 2048]) from checkpoint, the shape in current model is torch.Size([512, 128]).
        size mismatch for bert.embeddings.token_type_embeddings.weight: copying a param with shape torch.Size([2, 2048]) from checkpoint, the shape in current model is torch.Size([2, 128]).
        size mismatch for bert.embeddings.LayerNorm.weight: copying a param with shape torch.Size([2048]) from checkpoint, the shape in current model is torch.Size([128]).
        size mismatch for bert.embeddings.LayerNorm.bias: copying a param with shape torch.Size([2048]) from checkpoint, the shape in current model is torch.Size([128]).

Vimos avatar Dec 10 '19 07:12 Vimos

这个不能用transformers的albert加载吧,即便是用BertTokenizer代替,也会报下面的错误

RuntimeError: Error(s) in loading state_dict for AlbertForClozeExtra:
        size mismatch for bert.embeddings.position_embeddings.weight: copying a param with shape torch.Size([512, 2048]) from checkpoint, the shape in current model is torch.Size([512, 128]).
        size mismatch for bert.embeddings.token_type_embeddings.weight: copying a param with shape torch.Size([2, 2048]) from checkpoint, the shape in current model is torch.Size([2, 128]).
        size mismatch for bert.embeddings.LayerNorm.weight: copying a param with shape torch.Size([2048]) from checkpoint, the shape in current model is torch.Size([128]).
        size mismatch for bert.embeddings.LayerNorm.bias: copying a param with shape torch.Size([2048]) from checkpoint, the shape in current model is torch.Size([128]).

transfomers库里面的albert是默认支持spm_model_file的 是sentencepiece库生成的

34127chi avatar Dec 11 '19 03:12 34127chi