PreSumm
PreSumm copied to clipboard
Test_text mode: IndexError: tensors used as indices must be long, byte or bool tensors
When I try to run this command:
python src/train.py -mode test_text -text_src data/sum_twitter_sample.txt -test_from bertext_cnndm_transformer.pt
I get this error:
[2020-11-18 17:36:53,512 INFO] Loading checkpoint from bertext_cnndm_transformer.pt
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/', 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='bertext_cnndm_transformer.pt', test_start_from=-1, text_src='data/sum_twitter_sample.txt', 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-11-18 17:36:54,331 INFO] loading configuration file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-config.json from cache at ../temp/4dad0251492946e18ac39290fcfe91b89d370fee250efe9521476438fe8ca185.7156163d5fdc189c3016baca0775ffce230789d7fa2a42ef516483e4ca884517
[2020-11-18 17:36:54,331 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-11-18 17:36:54,364 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
[2020-11-18 17:36:56,735 INFO] * number of parameters: 120512513
[2020-11-18 17:36:56,782 INFO] https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-vocab.txt not found in cache or force_download set to True, downloading to /tmp/tmpf1gooeaa
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 231508/231508 [00:00<00:00, 28786165.38B/s]
[2020-11-18 17:36:56,817 INFO] copying /tmp/tmpf1gooeaa to cache at /home/ubuntu/.cache/torch/pytorch_transformers/26bc1ad6c0ac742e9b52263248f6d0f00068293b33709fae12320c0e35ccfbbb.542ce4285a40d23a559526243235df47c5f75c197f04f37d1a0c124c32c9a084
[2020-11-18 17:36:56,817 INFO] creating metadata file for /home/ubuntu/.cache/torch/pytorch_transformers/26bc1ad6c0ac742e9b52263248f6d0f00068293b33709fae12320c0e35ccfbbb.542ce4285a40d23a559526243235df47c5f75c197f04f37d1a0c124c32c9a084
[2020-11-18 17:36:56,817 INFO] removing temp file /tmp/tmpf1gooeaa
[2020-11-18 17:36:56,817 INFO] loading vocabulary file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-vocab.txt from cache at /home/ubuntu/.cache/torch/pytorch_transformers/26bc1ad6c0ac742e9b52263248f6d0f00068293b33709fae12320c0e35ccfbbb.542ce4285a40d23a559526243235df47c5f75c197f04f37d1a0c124c32c9a084
0%| | 0/14469 [00:00<?, ?it/s]Traceback (most recent call last):
File "src/train.py", line 155, in <module>
test_text_ext(args)
File "/home/ubuntu/workspace/PreSumm/src/train_extractive.py", line 267, in test_text_ext
trainer.test(test_iter, -1)
File "/home/ubuntu/workspace/PreSumm/src/models/trainer_ext.py", line 248, in test
sent_scores, mask = self.model(src, segs, clss, mask, mask_cls)
File "/home/ubuntu/anaconda3/envs/presumm/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in __call__
result = self.forward(*input, **kwargs)
File "/home/ubuntu/workspace/PreSumm/src/models/model_builder.py", line 172, in forward
sents_vec = top_vec[torch.arange(top_vec.size(0)).unsqueeze(1), clss]
IndexError: tensors used as indices must be long, byte or bool tensors
0%| | 1/14469 [00:00<24:25, 9.88it/s]
hey @MackieBlackburn, i'm getting the same error, did u figure this out?
I get it work by placing the document in a single line and spliting the sentences with [CLS] [SEP]
.
Hi @hedonihilist @germanenik. How did you run the code in the test_text
mode? I am getting this error: train.py: error: argument -mode: invalid choice: 'test_text' (choose from 'train', 'validate', 'test')