bojone / bert4keras

keras implement of transformers for humans
https://kexue.fm/archives/6915
Apache License 2.0
5.37k stars 929 forks source link

如何加载英文robert-large模型 #424

Open 447428054 opened 2 years ago

447428054 commented 2 years ago

提问时请尽可能提供如下信息:

基本信息

核心代码

model = build_transformer_model(config_path, checkpoint_path, model=’roberta’)

输出

tensorflow.python.framework.errors_impl.DataLossError: Unable to open table file /home/tguser/lz/pretrainModels/torch/eng/roberta_large/tf_model.h5: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?

自我尝试

尝试将huggingface robertalarge 模型tf_model.h5作为checkpoint加载,把vocab.json转为txt形式加载tokenizer

但是报错信息,loadcheckpoint似乎不能够加载h5

如果想要使用roberta-large英文的模型要如何加载呢 https://github.com/pytorch/fairseq/blob/main/examples/roberta/README.md

bojone commented 2 years ago

暂时不支持英文版roberta加载(捂脸)。

因为它没中文权重,而我不做非中文任务,所以开发时就没考虑......

我抽空补充一下吧。

447428054 commented 2 years ago

好的好的,谢谢