dbiir / UER-py

Open Source Pre-training Model Framework in PyTorch & Pre-trained Model Zoo
https://github.com/dbiir/UER-py/wiki
Apache License 2.0
2.97k stars 528 forks source link

KeyError when convert_bert_from_huggingface_to_uer 出错 #223

Open withchencheng opened 2 years ago

withchencheng commented 2 years ago

由于uer的modelzoo里面没有提供英文bert的下载地址,所以去 huggingface 下载了一个再转换格式。 转换格式期间遇到错误。

可能是您用的旧版本的huggingface bert. 我刚下载的 huggingface bert (https://huggingface.co/bert-base-uncased/tree/main), key 已经变了

    output_model["embedding.layer_norm.gamma"] = input_model["model.encoder.layernorm_embedding.weight"]

报错:KeyError: 'model.encoder.layernorm_embedding.weight' 我看到 input model里面有个key是 bert.embeddings.LayerNorm.gamma 应该就是这个了,其他的key我还没有一一核对。

withchencheng commented 2 years ago

update huggingface model keys #224 师兄好,我刚刚改了一下,跑通了,有个pull request 您看下

hhou435 commented 2 years ago

您好,实际上是bert-base-uncased这个模型使用的旧版transformers,您可以看到他的上传时间非常早,新版的模型参数都是使用的weight和bias

skye95git commented 2 years ago

由于uer的modelzoo里面没有提供英文bert的下载地址,所以去 huggingface 下载了一个再转换格式。 转换格式期间遇到错误。

可能是您用的旧版本的huggingface bert. 我刚下载的 huggingface bert (https://huggingface.co/bert-base-uncased/tree/main), key 已经变了

    output_model["embedding.layer_norm.gamma"] = input_model["model.encoder.layernorm_embedding.weight"]

报错:KeyError: 'model.encoder.layernorm_embedding.weight' 我看到 input model里面有个key是 bert.embeddings.LayerNorm.gamma 应该就是这个了,其他的key我还没有一一核对。

Hi, I meet the same problem. I download the RoBERTa from huggingface: https://huggingface.co/roberta-base/tree/main. Then I run the script https://github.com/dbiir/UER-py/blob/master/scripts/convert_bert_from_huggingface_to_uer.py. There is an error:

12163

What should I do?