Closed LouisHeck closed 2 years ago
Hi, I am leanring your team brilliant works. I run english dataest very well, but when I run the runner.py code in chinese datasets(man made, inputs format as said in readme), there is wrong:
ssh://tongna@192.168.10.196:22/home/tongna/anaconda3/envs/PLMarker/bin/python3.7 -u /home/tongna/PythonCode/zhangxu/tmp/PLMarker/run_ner.py --model_type bertspanmarker --model_name_or_path /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese --data_dir winbidNer --learning_rate 1e-5 --num_train_epochs 8 --per_gpu_train_batch_size 4 --per_gpu_eval_batch_size 8 --gradient_accumulation_steps 2 --max_seq_length 512 --save_steps 2000 --max_pair_length 256 --max_mention_ori_length 8 --do_train --do_eval --evaluate_during_training --eval_all_checkpoints --seed 42 --onedropout --lminit --train_file plmark_100.train --dev_file plmark.dev --test_file plmark.test --output_dir plMarker_models/PL-Marker-winbid-bert-42 --overwrite_output_dir Experiment dir : plMarker_models/PL-Marker-winbid-bert-42 04/28/2022 11:01:14 - WARNING - main - Process rank: -1, device: cpu, n_gpu: 0, distributed training: False, 16-bits training: False 04/28/2022 11:01:14 - INFO - transformers.configuration_utils - loading configuration file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/config.json 04/28/2022 11:01:14 - INFO - transformers.configuration_utils - Model config BertConfig { "architectures": [ "BertForMaskedLM" ], "attention_probs_dropout_prob": 0.1, "bos_token_id": null, "directionality": "bidi", "do_sample": false, "eos_token_ids": null, "finetuning_task": null, "hidden_act": "gelu", "hidden_dropout_prob": 0.1, "hidden_size": 768, "id2label": { "0": "LABEL_0", "1": "LABEL_1" }, "initializer_range": 0.02, "intermediate_size": 3072, "is_decoder": false, "label2id": { "LABEL_0": 0, "LABEL_1": 1 }, "layer_norm_eps": 1e-12, "length_penalty": 1.0, "max_length": 20, "max_position_embeddings": 512, "model_type": "bert", "num_attention_heads": 12, "num_beams": 1, "num_hidden_layers": 12, "num_labels": 15, "num_return_sequences": 1, "output_attentions": false, "output_hidden_states": false, "output_past": true, "pad_token_id": 0, "pooler_fc_size": 768, "pooler_num_attention_heads": 12, "pooler_num_fc_layers": 3, "pooler_size_per_head": 128, "pooler_type": "first_token_transform", "pruned_heads": {}, "repetition_penalty": 1.0, "temperature": 1.0, "top_k": 50, "top_p": 1.0, "torchscript": false, "type_vocab_size": 2, "use_bfloat16": false, "vocab_size": 21128 }
04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - Model name '/home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese' 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 '/home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese' is a path, a model identifier, or url to a directory containing tokenizer files. 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - Didn't find file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/added_tokens.json. We won't load it. 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - Didn't find file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/special_tokens_map.json. We won't load it. 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - loading file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/vocab.txt 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - loading file None 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - loading file None 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - loading file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/tokenizer_config.json 04/28/2022 11:01:14 - INFO - transformers.modeling_utils - loading weights file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/pytorch_model.bin 04/28/2022 11:01:16 - INFO - transformers.modeling_utils - Weights of BertForSpanMarkerNER not initialized from pretrained model: ['ner_classifier.weight', 'ner_classifier.bias'] 04/28/2022 11:01:16 - INFO - transformers.modeling_utils - Weights from pretrained model not used in BertForSpanMarkerNER: ['cls.predictions.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.decoder.weight', 'cls.seq_relationship.weight', 'cls.seq_relationship.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.LayerNorm.bias'] 04/28/2022 11:01:16 - INFO - main - Training/evaluation parameters Namespace(adam_b2=0.999, adam_epsilon=1e-08, alpha=1, cache_dir='', cands_from_BIO=False, config_name='', data_dir='winbidNer', dev_file='plmark.dev', device=device(type='cpu'), do_eval=True, do_lower_case=False, do_test=False, do_train=True, eval_all_checkpoints=True, eval_on_cands=False, evaluate_during_training=True, fp16=False, fp16_opt_level='O1', gradient_accumulation_steps=2, group_axis=-1, group_edge=False, group_sort=False, learning_rate=1e-05, lminit=True, local_rank=-1, logging_steps=5, max_grad_norm=1.0, max_mention_ori_length=8, max_pair_length=256, max_seq_length=512, max_steps=-1, model_name_or_path='/home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese', model_type='bertspanmarker', n_gpu=0, no_cuda=False, norm_emb=False, num_labels=15, num_train_epochs=8.0, onedropout=True, output_candidates=False, output_dir='plMarker_models/PL-Marker-winbid-bert-42', overwrite_cache=False, overwrite_output_dir=True, per_gpu_eval_batch_size=8, per_gpu_train_batch_size=4, save_steps=2000, save_total_limit=1, seed=42, server_ip='', server_port='', shuffle=False, test_cand_file='', test_file='plmark.test', tokenizer_name='', train_file='plmark_100.train', use_full_layer=-1, warmup_steps=-1, weight_decay=0.0) 04/28/2022 11:01:16 - INFO - main - entity_id = 100 04/28/2022 11:01:16 - INFO - main - mask_id = 103 pad: 1 2 107315it [00:00, 2040804.76it/s] 100it [00:02, 38.00it/s] maxR: 9492 04/28/2022 11:01:18 - INFO - main - Running training 04/28/2022 11:01:18 - INFO - main - Num examples = 4838 04/28/2022 11:01:18 - INFO - main - Num Epochs = 8 04/28/2022 11:01:18 - INFO - main - Instantaneous batch size per GPU = 4 04/28/2022 11:01:18 - INFO - main - Total train batch size (w. parallel, distributed & accumulation) = 8 04/28/2022 11:01:18 - INFO - main - Gradient Accumulation steps = 2 04/28/2022 11:01:18 - INFO - main - Total optimization steps = 4840 Epoch: 0%| | 0/8 [00:00<?, ?it/s] Iteration: 0%| | 0/1210 [00:00<?, ?it/s] Iteration: 0%| | 1/1210 [00:06<2:19:25, 6.92s/it] Epoch: 0%| | 0/8 [00:06<?, ?it/s] Traceback (most recent call last): File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/run_ner.py", line 1425, in main() File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/run_ner.py", line 1356, in main global_step, tr_loss, best_f1 = train(args, model, tokenizer) File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/run_ner.py", line 891, in train outputs = model(inputs) File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, *kwargs) File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/transformers/src/transformers/modeling_bert.py", line 3251, in forward full_attention_mask=full_attention_mask, File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(input, kwargs) File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/transformers/src/transformers/modeling_bert.py", line 795, in forward input_ids=input_ids, position_ids=position_ids, token_type_ids=token_type_ids, inputs_embeds=inputs_embeds File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, *kwargs) File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/transformers/src/transformers/modeling_bert.py", line 175, in forward position_embeddings = self.position_embeddings(position_ids) File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(input, **kwargs) File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/sparse.py", line 160, in forward self.norm_type, self.scale_grad_by_freq, self.sparse) File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/functional.py", line 2183, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) IndexError: index out of range in self
Process finished with exit code 1
please help me. Thanks in advance.
The input format shown in the readme is used for end-to-end RE. We use run_acener.py to deal with this format.
The run_ner.py is used to deal with format of CONLL03.
My mistake, many thanks!
Hi, I am leanring your team brilliant works. I run english dataest very well, but when I run the runner.py code in chinese datasets(man made, inputs format as said in readme), there is wrong:
ssh://tongna@192.168.10.196:22/home/tongna/anaconda3/envs/PLMarker/bin/python3.7 -u /home/tongna/PythonCode/zhangxu/tmp/PLMarker/run_ner.py --model_type bertspanmarker --model_name_or_path /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese --data_dir winbidNer --learning_rate 1e-5 --num_train_epochs 8 --per_gpu_train_batch_size 4 --per_gpu_eval_batch_size 8 --gradient_accumulation_steps 2 --max_seq_length 512 --save_steps 2000 --max_pair_length 256 --max_mention_ori_length 8 --do_train --do_eval --evaluate_during_training --eval_all_checkpoints --seed 42 --onedropout --lminit --train_file plmark_100.train --dev_file plmark.dev --test_file plmark.test --output_dir plMarker_models/PL-Marker-winbid-bert-42 --overwrite_output_dir Experiment dir : plMarker_models/PL-Marker-winbid-bert-42 04/28/2022 11:01:14 - WARNING - main - Process rank: -1, device: cpu, n_gpu: 0, distributed training: False, 16-bits training: False 04/28/2022 11:01:14 - INFO - transformers.configuration_utils - loading configuration file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/config.json 04/28/2022 11:01:14 - INFO - transformers.configuration_utils - Model config BertConfig { "architectures": [ "BertForMaskedLM" ], "attention_probs_dropout_prob": 0.1, "bos_token_id": null, "directionality": "bidi", "do_sample": false, "eos_token_ids": null, "finetuning_task": null, "hidden_act": "gelu", "hidden_dropout_prob": 0.1, "hidden_size": 768, "id2label": { "0": "LABEL_0", "1": "LABEL_1" }, "initializer_range": 0.02, "intermediate_size": 3072, "is_decoder": false, "label2id": { "LABEL_0": 0, "LABEL_1": 1 }, "layer_norm_eps": 1e-12, "length_penalty": 1.0, "max_length": 20, "max_position_embeddings": 512, "model_type": "bert", "num_attention_heads": 12, "num_beams": 1, "num_hidden_layers": 12, "num_labels": 15, "num_return_sequences": 1, "output_attentions": false, "output_hidden_states": false, "output_past": true, "pad_token_id": 0, "pooler_fc_size": 768, "pooler_num_attention_heads": 12, "pooler_num_fc_layers": 3, "pooler_size_per_head": 128, "pooler_type": "first_token_transform", "pruned_heads": {}, "repetition_penalty": 1.0, "temperature": 1.0, "top_k": 50, "top_p": 1.0, "torchscript": false, "type_vocab_size": 2, "use_bfloat16": false, "vocab_size": 21128 }
04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - Model name '/home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese' 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 '/home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese' is a path, a model identifier, or url to a directory containing tokenizer files. 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - Didn't find file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/added_tokens.json. We won't load it. 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - Didn't find file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/special_tokens_map.json. We won't load it. 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - loading file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/vocab.txt 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - loading file None 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - loading file None 04/28/2022 11:01:14 - INFO - transformers.tokenization_utils - loading file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/tokenizer_config.json 04/28/2022 11:01:14 - INFO - transformers.modeling_utils - loading weights file /home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese/pytorch_model.bin 04/28/2022 11:01:16 - INFO - transformers.modeling_utils - Weights of BertForSpanMarkerNER not initialized from pretrained model: ['ner_classifier.weight', 'ner_classifier.bias'] 04/28/2022 11:01:16 - INFO - transformers.modeling_utils - Weights from pretrained model not used in BertForSpanMarkerNER: ['cls.predictions.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.decoder.weight', 'cls.seq_relationship.weight', 'cls.seq_relationship.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.LayerNorm.bias'] 04/28/2022 11:01:16 - INFO - main - Training/evaluation parameters Namespace(adam_b2=0.999, adam_epsilon=1e-08, alpha=1, cache_dir='', cands_from_BIO=False, config_name='', data_dir='winbidNer', dev_file='plmark.dev', device=device(type='cpu'), do_eval=True, do_lower_case=False, do_test=False, do_train=True, eval_all_checkpoints=True, eval_on_cands=False, evaluate_during_training=True, fp16=False, fp16_opt_level='O1', gradient_accumulation_steps=2, group_axis=-1, group_edge=False, group_sort=False, learning_rate=1e-05, lminit=True, local_rank=-1, logging_steps=5, max_grad_norm=1.0, max_mention_ori_length=8, max_pair_length=256, max_seq_length=512, max_steps=-1, model_name_or_path='/home/tongna/modelHub/PmNameRecognition/google/bert-base-chinese', model_type='bertspanmarker', n_gpu=0, no_cuda=False, norm_emb=False, num_labels=15, num_train_epochs=8.0, onedropout=True, output_candidates=False, output_dir='plMarker_models/PL-Marker-winbid-bert-42', overwrite_cache=False, overwrite_output_dir=True, per_gpu_eval_batch_size=8, per_gpu_train_batch_size=4, save_steps=2000, save_total_limit=1, seed=42, server_ip='', server_port='', shuffle=False, test_cand_file='', test_file='plmark.test', tokenizer_name='', train_file='plmark_100.train', use_full_layer=-1, warmup_steps=-1, weight_decay=0.0) 04/28/2022 11:01:16 - INFO - main - entity_id = 100 04/28/2022 11:01:16 - INFO - main - mask_id = 103 pad: 1 2 107315it [00:00, 2040804.76it/s] 100it [00:02, 38.00it/s] maxR: 9492 04/28/2022 11:01:18 - INFO - main - Running training 04/28/2022 11:01:18 - INFO - main - Num examples = 4838 04/28/2022 11:01:18 - INFO - main - Num Epochs = 8 04/28/2022 11:01:18 - INFO - main - Instantaneous batch size per GPU = 4 04/28/2022 11:01:18 - INFO - main - Total train batch size (w. parallel, distributed & accumulation) = 8 04/28/2022 11:01:18 - INFO - main - Gradient Accumulation steps = 2 04/28/2022 11:01:18 - INFO - main - Total optimization steps = 4840 Epoch: 0%| | 0/8 [00:00<?, ?it/s] Iteration: 0%| | 0/1210 [00:00<?, ?it/s] Iteration: 0%| | 1/1210 [00:06<2:19:25, 6.92s/it] Epoch: 0%| | 0/8 [00:06<?, ?it/s] Traceback (most recent call last): File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/run_ner.py", line 1425, in
main()
File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/run_ner.py", line 1356, in main
global_step, tr_loss, best_f1 = train(args, model, tokenizer)
File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/run_ner.py", line 891, in train
outputs = model(inputs)
File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, *kwargs)
File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/transformers/src/transformers/modeling_bert.py", line 3251, in forward
full_attention_mask=full_attention_mask,
File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(input, kwargs)
File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/transformers/src/transformers/modeling_bert.py", line 795, in forward
input_ids=input_ids, position_ids=position_ids, token_type_ids=token_type_ids, inputs_embeds=inputs_embeds
File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, *kwargs)
File "/home/tongna/PythonCode/zhangxu/tmp/PLMarker/transformers/src/transformers/modeling_bert.py", line 175, in forward
position_embeddings = self.position_embeddings(position_ids)
File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(input, **kwargs)
File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/modules/sparse.py", line 160, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File "/home/tongna/anaconda3/envs/PLMarker/lib/python3.7/site-packages/torch/nn/functional.py", line 2183, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
IndexError: index out of range in self
Process finished with exit code 1
please help me. Thanks in advance.