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
3.01k stars 525 forks source link

转换 hfl/chinese-macbert-base的模型成UER格式 #302

Closed sl403 closed 2 years ago

sl403 commented 2 years ago

请问HFL Chinese hfl/chinese-macbert-base的模型是通过 "convert_bert_from_huggingface_to_uer.py" 进行转换成UER格式吗? 但是进行转换会报错: $ python scripts/convert_bert_from_huggingface_to_uer.py --input_model_path hfl_macbert/pytorch_model.bin --output_model_path hfl_macbert/hfl_macbert_model.bin

sl403 commented 2 years ago

错误讯息:

Traceback (most recent call last):
  File "scripts/convert_bert_from_huggingface_to_uer.py", line 84, in <module>
    main()
  File "scripts/convert_bert_from_huggingface_to_uer.py", line 54, in main
    input_model = torch.load(args.input_model_path, map_location="cpu")
  File "/home/user/anaconda3/envs/roberta/lib/python3.8/site-packages/torch/serialization.py", line 608, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/user/anaconda3/envs/roberta/lib/python3.8/site-packages/torch/serialization.py", line 777, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, 'v'.
sl403 commented 2 years ago

問題已解決