brightmart / albert_zh

A LITE BERT FOR SELF-SUPERVISED LEARNING OF LANGUAGE REPRESENTATIONS, 海量中文预训练ALBERT模型
https://arxiv.org/pdf/1909.11942.pdf
3.94k stars 753 forks source link

预训练模型中没有spm_model_file文件 #85

Open 34127chi opened 4 years ago

34127chi commented 4 years ago

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

Vimos commented 4 years ago

这个不能用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]).
34127chi commented 4 years ago

这个不能用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库生成的