nlpyang / PreSumm

code for EMNLP 2019 paper Text Summarization with Pretrained Encoders
MIT License
1.29k stars 465 forks source link

Error while trying to Summarize Raw Text Input by the downloaded trained model #162

Closed suchanun closed 4 years ago

suchanun commented 4 years ago

I use dev branch and put the downloaded model, bertext_cnndm_transformer.pt, into models folder.

I then go into src folder, and run ./train.py -task ext -mode test_text -model_path ../models/bertext_cnndm_transformer.pt -text_src ../raw_data/temp_ext.raw_src -test_from ../models/bertext_cnndm_transformer.pt -log_file ../logs/cnndm.log

Am I missing something? It can't find "../models/bertext_cnndm_transformer.pt/events.out.tfevents.1588910784.[myMachineName]"

Here's the log: Namespace(accum_count=1, alpha=0.6, batch_size=140, beam_size=5, bert_data_path='../bert_data_new/cnndm', beta1=0.9, beta2=0.999, block_trigram=True, dec_dropout=0.2, dec_ff_size=2048, dec_heads=8, dec_hidden_size=768, dec_layers=6, enc_dropout=0.2, enc_ff_size=512, enc_hidden_size=512, enc_layers=6, encoder='bert', ext_dropout=0.2, ext_ff_size=2048, ext_heads=8, ext_hidden_size=768, ext_layers=2, finetune_bert=True, generator_shard_size=32, gpu_ranks=[0], label_smoothing=0.1, large=False, load_from_extractive='', log_file='../logs/cnndm.log', lr=1, lr_bert=0.002, lr_dec=0.002, max_grad_norm=0, max_length=150, max_ndocs_in_batch=6, max_pos=512, max_tgt_len=140, min_length=15, mode='test_text', model_path='../models/bertext_cnndm_transformer.pt', optim='adam', param_init=0, param_init_glorot=True, recall_eval=False, report_every=1, report_rouge=True, result_path='../results/cnndm', save_checkpoint_steps=5, seed=666, sep_optim=False, share_emb=False, task='ext', temp_dir='../temp', test_all=False, test_batch_size=200, test_from='../models/bertext_cnndm_transformer.pt', test_start_from=-1, text_src='../raw_data/temp_ext.raw_src', text_tgt='', train_from='', train_steps=1000, use_bert_emb=False, use_interval=True, visible_gpus='-1', warmup_steps=8000, warmup_steps_bert=8000, warmup_steps_dec=8000, world_size=1) [2020-05-08 11:07:54,143 INFO] loading configuration file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-config.json from cache at ../temp/4dad0251492946e18ac39290fcfe91b89d370fee250efe9521476438fe8ca185.7156163d5fdc189c3016baca0775ffce230789d7fa2a42ef516483e4ca884517 [2020-05-08 11:07:54,144 INFO] Model config { "architectures": [ "BertForMaskedLM" ], "attention_probs_dropout_prob": 0.1, "finetuning_task": null, "hidden_act": "gelu", "hidden_dropout_prob": 0.1, "hidden_size": 768, "initializer_range": 0.02, "intermediate_size": 3072, "layer_norm_eps": 1e-12, "max_position_embeddings": 512, "model_type": "bert", "num_attention_heads": 12, "num_hidden_layers": 12, "num_labels": 2, "output_attentions": false, "output_hidden_states": false, "pad_token_id": 0, "pruned_heads": {}, "torchscript": false, "type_vocab_size": 2, "vocab_size": 30522 }

[2020-05-08 11:07:55,371 INFO] loading weights file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-pytorch_model.bin from cache at ../temp/aa1ef1aede4482d0dbcd4d52baad8ae300e60902e88fcb0bebdec09afd232066.36ca03ab34a1a5d5fa7bc3d03d55c4fa650fed07220e2eeebc06ce58d0e9a157 gpu_rank 0 Traceback (most recent call last): File "/Users/suchanun/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tensorboardX/record_writer.py", line 51, in open_file factory = REGISTERED_FACTORIES[prefix] KeyError: '../models/bertext_cnndm_transformer.pt/events.out.tfevents.1588910879.suchanuns-mbp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./train.py", line 155, in test_text_ext(args) File "/Users/suchanun/Documents/Nice/Senior/PreSumm/src/train_extractive.py", line 266, in test_text_ext trainer = build_trainer(args, device_id, model, None) File "/Users/suchanun/Documents/Nice/Senior/PreSumm/src/models/trainer_ext.py", line 45, in build_trainer writer = SummaryWriter(tensorboard_log_dir, comment="Unmt") File "/Users/suchanun/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tensorboardX/writer.py", line 257, in init self._get_file_writer() File "/Users/suchanun/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tensorboardX/writer.py", line 321, in _get_file_writer **self.kwargs) File "/Users/suchanun/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tensorboardX/writer.py", line 93, in init logdir, max_queue, flush_secs, filename_suffix) File "/Users/suchanun/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tensorboardX/event_file_writer.py", line 107, in init self._logdir, "events"), filename_suffix) File "/Users/suchanun/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tensorboardX/event_file_writer.py", line 43, in init self._py_recordio_writer = RecordWriter(self._file_name) File "/Users/suchanun/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tensorboardX/record_writer.py", line 113, in init self._writer = open_file(path) File "/Users/suchanun/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tensorboardX/record_writer.py", line 54, in open_file return open(path, 'wb') NotADirectoryError: [Errno 20] Not a directory: '../models/bertext_cnndm_transformer.pt/events.out.tfevents.1588910879.suchanuns-mbp'

Any help/explanation is very appreciated!

STEMlib commented 4 years ago

Try to remove -model_path ../models/bertext_cnndm_transformer.pt and make sure you're using the dev branch.

suchanun commented 4 years ago

It works now, thank you!