WuHuRestaurant/xf_event_extraction2020Top1

ERNIE1.0模型

Closed this issue · 12 comments

test.sh运行后读取ERNIE模型,我在https://github.com/nghuyong/ERNIE-Pytorch下载了ernie-1.0 (Chinese)模型,并将解压到文件放到bert/torch_ernie_1/下面,运行还是报错。请问你是在哪里下载的ERNIE模型,并做了什么处理呢?谢谢

Ernie文件夹目录看下

xf_master
bert
|---torch_roberta_wwm
|---torch_ernie_1
|-------config.json
|-------pytorch_model.bin
|-------bocab.txt

不应该是vocab.txt吗?还有你报的是啥错。。

vocab.txt。报错如下:
02/04/2021 08:39:59 - INFO - transformers.tokenization_utils - Model name '../bert/torch_ernie_1' not found in model shortcut name list (bert-base-uncased, bert-large-uncased, bert-base-cased, bert-large-cased, bert-base-multilingual-uncased, bert-base-multilingual-cased, bert-base-chinese, bert-base-german-cased, bert-large-uncased-whole-word-masking, bert-large-cased-whole-word-masking, bert-large-uncased-whole-word-masking-finetuned-squad, bert-large-cased-whole-word-masking-finetuned-squad, bert-base-cased-finetuned-mrpc, bert-base-german-dbmdz-cased, bert-base-german-dbmdz-uncased, bert-base-finnish-cased-v1, bert-base-finnish-uncased-v1, bert-base-dutch-cased). Assuming '../bert/torch_ernie_1' is a path, a model identifier, or url to a directory containing tokenizer files.
02/04/2021 08:39:59 - INFO - transformers.tokenization_utils - Didn't find file ../bert/torch_ernie_1/added_tokens.json. We won't load it.
02/04/2021 08:39:59 - INFO - transformers.tokenization_utils - Didn't find file ../bert/torch_ernie_1/special_tokens_map.json. We won't load it.
02/04/2021 08:39:59 - INFO - transformers.tokenization_utils - Didn't find file ../bert/torch_ernie_1/tokenizer_config.json. We won't load it.
02/04/2021 08:39:59 - INFO - transformers.tokenization_utils - loading file ../bert/torch_ernie_1/vocab.txt
02/04/2021 08:39:59 - INFO - transformers.tokenization_utils - loading file None
02/04/2021 08:39:59 - INFO - transformers.tokenization_utils - loading file None
02/04/2021 08:39:59 - INFO - transformers.tokenization_utils - loading file None
02/04/2021 08:39:59 - INFO - transformers.configuration_utils - loading configuration file ../bert/torch_ernie_1/config.json
02/04/2021 08:39:59 - INFO - transformers.configuration_utils - Model config BertConfig {
"attention_probs_dropout_prob": 0.1,
"hidden_act": "relu",
"hidden_dropout_prob": 0.1,
"hidden_size": 768,
"initializer_range": 0.02,
"intermediate_size": 3072,
"layer_norm_eps": 1e-05,
"max_position_embeddings": 513,
"model_type": "bert",
"num_attention_heads": 12,
"num_hidden_layers": 12,
"pad_token_id": 0,
"type_vocab_size": 2,
"vocab_size": 18000
}

02/04/2021 08:39:59 - INFO - transformers.modeling_utils - loading weights file ../bert/torch_ernie_1/pytorch_model.bin
Traceback (most recent call last):
File "test.py", line 291, in
ensemble_attribution(args.version)
File "/home/fk/event_extraction_exp/xf/ensemble_predict.py", line 144, in ensemble_attribution
all_polarity_logits /= float(count)
TypeError: unsupported operand type(s) for /=: 'NoneType' and 'float'

你模型训练了吗。。上来就test

4个模型训练了的,也改了模型的路径。这个执行了前面的抽取,然后执行到了ensemble attribution时,加载ernie后报错,我换过几个ernie都报错,就是不确定是不是这个的问题

这个代码的原因是执行 ensemble_attribution 时126行 ernie_models_path 没有读取到对应的模型路径,你可以打印出来 debug 看一下

请问你的ernie是在哪儿下载的呢,目录结果是一样的?

一样的地方,你ernie能训练为啥加载的时候有问题

谢谢提醒,我试试先换用这个ernie训练attribution模型

xf_master
bert
|---torch_roberta_wwm
|---torch_ernie_1
|-------config.json
|-------pytorch_model.bin
|-------bocab.txt

请问这个torch_roberta_wwm在哪里下载 我也遇到了 Model name './bert/torch_roberta_wwm' was not found in tokenizers model name list (bert-base-uncased,。。。
这个问题,请问你解决了嘛

xf_master
bert
|---torch_roberta_wwm
|---torch_ernie_1
|-------config.json
|-------pytorch_model.bin
|-------bocab.txt

请问这个torch_roberta_wwm在哪里下载 我也遇到了 Model name './bert/torch_roberta_wwm' was not found in tokenizers model name list (bert-base-uncased,。。。
这个问题,请问你解决了嘛

wwm这个模型的文件夹里面要有 vocab.txt 才行,有Bert的词表才能创建 tokenizer