Closed ruiyeNLP closed 1 year ago
Are the links under 'Pretrained models' the GECToR models? Sorry but the description on readme remains unclear for me.
Error occured with command python predict.py --model_path ./model/bert_0_gectorv2.th --vocab_path ./data/output_vocabulary --input_file test_input.txt --output_file test_output.txt
File "predict.py", line 128, in
main(args) File "predict.py", line 47, in main weigths=args.weights) File "/home/rui.ye/CISPA-projects/actionable_gdpr-2022/NLP_robustness/gector-master/gector/gec_model.py", line 69, in init model.load_state_dict(torch.load(model_path), strict=False) File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1483, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for Seq2Labels: size mismatch for text_field_embedder.token_embedder_bert.bert_model.embeddings.position_ids: copying a param with shape torch.Size([1, 512]) from checkpoint, the shape in current model is torch.Size([1, 514]). size mismatch for text_field_embedder.token_embedder_bert.bert_model.embeddings.word_embeddings.weight: copying a param with shape torch.Size([28996, 768]) from checkpoint, the shape in current model is torch.Size([50266, 768]). size mismatch for text_field_embedder.token_embedder_bert.bert_model.embeddings.position_embeddings.weight: copying a param with shape torch.Size([512, 768]) from checkpoint, the shape in current model is torch.Size([514, 768]). size mismatch for text_field_embedder.token_embedder_bert.bert_model.embeddings.token_type_embeddings.weight: copying a param with shape torch.Size([2, 768]) from checkpoint, the shape in current model is torch.Size([1, 768]).
While python predict.py --model_path ./model/xlnet_0_gectorv2.th --vocab_path ./data/output_vocabulary --input_file test_input.txt --output_file test_output.txt
and python predict.py --model_path ./model/roberta_1_gectorv2.th --vocab_path ./data/output_vocabulary --input_file test_input.txt --output_file test_output.txt
succeed.
Looks like the embeddings are twice as big for your BERT version. Please check transformers
version
Thanks a lot for this work. Do you plan to realize a trained Gector so that other projects could use it as an API or library in their project? Looking forward to your reply.