Giter Site home page Giter Site logo

kedz / nnsum Goto Github PK

View Code? Open in Web Editor NEW
108.0 9.0 19.0 489 KB

An extractive neural network text summarization library for the EMNLP 2018 paper "Content Selection in Deep Learning Models of Summarization" (https://arxiv.org/abs/1810.12343).

Python 100.00%

nnsum's Introduction

nnsum

An extractive neural network text summarization library for the EMNLP 2018 paper Content Selection in Deep Learning Models of Summarization (https://arxiv.org/abs/1810.12343).

Installation

  1. Install pytorch using pip or conda.
  2. run:
git clone https://github.com/kedz/nnsum.git
cd nnsum
python setup.py install
  1. Get the data:
git clone https://github.com/kedz/summarization-datasets.git
cd summarization-datasets
python setup.py install

See README.md in summarization-datasets for details on how to get each dataset from the paper.

Training A Model

All models from the paper can be trained from the same convenient training script: script_bin/train_model.py. The general pattern for usage is:

python script_bin/train_model.py \
  --trainer TRAINER_ARGS --emb EMBEDDING_ARGS \
  --enc ENCODER_ARGS --ext EXTRACTOR_ARGS

Every model has a set of word embeddings, a sentence encoder, and a sentence extractor. Each argument section allows you to pick an architecture/options for that component. For the most part, defaults match the paper's primary evaluation settings. For example, to train the CNN encoder with Seq2Seq extractor on gpu 0, run the following:

python script_bin/train_model.py \
    --trainer --train-inputs PATH/TO/INPUTS/TRAIN/DIR \
              --train-labels PATH/TO/LABELS/TRAIN/DIR \
              --valid-inputs PATH/TO/INPUTS/VALID/DIR \
              --valid-labels PATH/TO/LABELS/VALID/DIR \
              --valid-refs PATH/TO/HUMAN/REFERENCE/VALID/DIR \
              --weighted \
              --gpu 0 \
              --model PATH/TO/SAVE/MODEL \
              --results PATH/TO/SAVE/VALIDATION/SCORES \
              --seed 12345678 \
    --emb --pretrained-embeddings PATH/TO/200/DIM/GLOVE \
    --enc cnn \
    --ext s2s --bidirectional 

Trainer Arguments

These arguments set the data to train on, batch sizes, training epochs, etc.

  • --train-inputs PATH Path to training inputs directory. (required)
  • --train-labels PATH Path to training labels directory. (required)
  • --valid-inputs PATH Path to validation inputs directory. (required)
  • --valid-labels PATH Path to validation labels directory. (required)
  • --valid-refs PATH Path to validation reference summaries directory. (required)
  • --seed SEED Random seed for getting repeatable results. Due to randomness in cudnn drivers the CNN sentence encoder will still have randomness.
  • --epochs EPOCHS Number of training epochs to run. (Default: 50)
  • --batch-size BATCH_SIZE Batch size for sgd. (Default: 32)
  • --gpu GPU Select gpu device. When set to -1, use cpu. (Default: -1)
  • --teacher-forcing EPOCHS Number of epochs to use teacher forcing. After the EPOCHS training epoch, teacher forcing is disabled. Only effects the Cheng & Lapata extractor. (Default: 25)
  • --sentence-limit LIMIT Only load the first LIMIT sentences of each document. Useful for saving memory/compute time when some of the data contains outlier documents with long length. (Default: 50)
  • --weighted When this flag is used, upweight positive labels to make them proportional to the negative labels. This is helpful because this is an inbalanced classification problem and we only want to select 3 or 4 sentences out of 30-50 sentences.
  • --summary-length LENGTH Set the maximum summary word length for ROUGE evaluation.
  • --remove-stopwords When flag is set, ROUGE is computed with stopwords removed.
  • --model PATH Location to save model. (Optional)
  • --results PATH Location to save results json. Stores per epoch training cross entropy, and per epoch validation cross-entropy, rouge-1, and rouge-2. (optional)

Embedding Arguments

These arguments set the word embeddings size, the path to pretrained embeddings, whether to fix the embeddings during learning, etc.

  • --embedding-size SIZE Dimenstion of word embeddings. Must match the size of pretrained embeddings if using pretrained. (Default: 200)
  • --pretrained-embeddings PATH Path to pretrained embeddings. Embeddings file should be a text file each line in the format: word e1 e2 e3... where e1, e2, ... are the values of the embedding at that dimension. (optional)
  • --top-k TOP_K Only keep the TOP_K most frequent words in the embedding vocabulary where counts are based on the training dataset. Default keeps all words. Only active when not using pretrained embeddings. (Default: None)
  • --at-least AT_LEAST Keep only words that occur at least AT_LEAST times in the training dataset. Default keeps all words that occur at least once. Only active when not using pretrained embeddings. (Default: 1)
  • --word-dropout PROB Apply dropout to tokens in the input document with drop prob PROB. (Default: 0)
  • --embedding-dropout PROB Apply dropout to the word embeddings with drop prob PROB. (default: .25)
  • --update-rule RULE Options are update-all and fix-all. update-all treats the embeddings as parameters to be learned during training. fix-all prevents word embeddings from being updated. (Default: fix-all)
  • --filter-pretrained When flag is set, apply --top-k and --at-least filters to pretrained embedding vocabulary.

Encoder Arguments

The encoder arguments select for one of three sentence encoder architectures: avg, rnn, or cnn, and their various parameters e.g. --enc avg or --enc cnn CNN_ARGUMENTS. The sentence encoder takes a sentence, i.e. an arbitrarily long sequence of word embeddings and encodes them as a fixed length embedding. Below we describe the options for each architecture.

Averaging Encoder

A sentence embedding is simply the average of the word embeddings.

  • --dropout PROB Drop probability applied after averaging the word embeddings. (Default: .25)

RNN Encoder

A sentence embedding is the final output state of an RNN applied to the word embedding sequence.

  • --hidden-size SIZE Size of the RNN output layer (and hidden if using LSTM cell). (Default: 200)
  • --bidirectional When flag is set, use a bi-directional RNN. Output is the concatenation of the final forward and backward outputs.
  • --dropout PROB Drop propability applied to output layers of the RNN. (Default: .25)
  • --num-layers NUM Number layers in the RNN. (Default: 1)
  • --cell CELL RNN cell type to use. Options are rnn, gru, or lstm. (Default: gru)

CNN Encoder

A sentence embedding is the output of a convolutional + relu + dropout layer. The output size is the sum of the --feature-maps argument.

  • --dropout PROB Drop probability applied to convolutional layer output. (Default: .25)
  • --filter-windows WIN [WIN ...] Filter window widths, i.e. size in ngrams of each convolutional feature window. Number of args must be the same length as --feature-maps. (Default: 1 2 3 4 5 6)
  • --feature-maps MAPS [MAPS ...] Number of convolutional feature maps. Number of args must be the same length as --filter-windows. (Default: 25 25 50 50 50 50)

Extractor Arguments

The extractor arguments select for one of four sentence extractor architectures: rnn, s2s, cl, or sr, and their various parameters e.g. --ext cl or --enc s2s S2S_ARGUMENTS. The sentence extractor takes an arbitrarily long sequence of sentence embeddings and predicts whether each sentence should be included in the summary. Below we describe the options for each architecture.

RNN Extractor

Sentence embeddings are run through an RNN and then fed into a multi-layer perceptron MLP to predict sentence extraction.

  • --hidden-size SIZE Size of the RNN output layer/hidden layer. (Default: 300)
  • --bidirectional When flag is set, use a bi-directional RNN.
  • --rnn-dropout PROB Drop propability applied to output layers of the RNN. (Default: .25)
  • --num-layers NUM Number of layers in the RNN. (Default: 1)
  • --cell CELL RNN cell type to use. Options are rnn, gru, or lstm. (Default: gru)
  • --mlp-layers SIZE [SIZE ...] A list of sizes of the hidden layers in the MLP. Must be the same length as --mlp-dropouts. (Default: 100)
  • --mlp-dropouts PROB [PROBS ...] A list the MLP hidden layer dropout probabilities. Must be the same length as --mlp-layers. (Default: .25)

Seq2Seq Extractor

Sentence embeddings are run through a seq2seq based extractor with attention and MLP layer for predicting sentence extraction.

  • --hidden-size SIZE Size of the RNN output layer/hidden layer. (Default: 300)
  • --bidirectional When flag is set, use a bi-directional RNN.
  • --rnn-dropout PROB Drop propability applied to output layers of the RNN. (Default: .25)
  • --num-layers NUM Number of layers in the RNN. (Default: 1)
  • --cell CELL RNN cell type to use. Options are rnn, gru, or lstm. (Default: gru)
  • --mlp-layers SIZE [SIZE ...] A list of sizes of the hidden layers in the MLP. Must be the same length as --mlp-dropouts. (Default: 100)
  • --mlp-dropouts PROB [PROBS ...] A list the MLP hidden layer dropout probabilities. Must be the same length as --mlp-layers. (Default: .25)

Cheng & Lapata Extractor

This is an implementation of the sentence extractive summarizer from: https://arxiv.org/abs/1603.07252

  • --hidden-size SIZE Size of the RNN output layer/hidden layer. (Default: 300)
  • --bidirectional When flag is set, use a bi-directional RNN.
  • --rnn-dropout PROB Drop propability applied to output layers of the RNN. (Default: .25)
  • --num-layers NUM Number of layers in the RNN. (Default: 1)
  • --cell CELL RNN cell type to use. Options are rnn, gru, or lstm. (Default: gru)
  • --mlp-layers SIZE [SIZE ...] A list of sizes of the hidden layers in the MLP. Must be the same length as --mlp-dropouts. (Default: 100)
  • --mlp-dropouts PROB [PROBS ...] A list the MLP hidden layer dropout probabilities. Must be the same length as --mlp-layers. (Default: .25)

SummaRunner Extractor

This is an implementation of the sentence extractive summarizer from: https://arxiv.org/abs/1611.04230

  • --hidden-size SIZE Size of the RNN output layer/hidden layer. (Default: 300)
  • --bidirectional When flag is set, use a bi-directional RNN.
  • --rnn-dropout PROB Drop propability applied to output layers of the RNN. (Default: .25)
  • --num-layers NUM Number of layers in the RNN. (Default: 1)
  • --cell CELL RNN cell type to use. Options are rnn, gru, or lstm. (Default: gru)
  • --sentence-size SIZE Dimension of sentence representation (after RNN layer) (Default: 100)
  • --document-size SIZE Dimension of the document representation (Default: 100)
  • --segments SEG Number of coarse position chunks, e.g. 4 segments means sentences in first quarter of the document would get the same segment embedding, the second quarter and so on. (Default: 4)
  • --max-position-weights NUM The number of unique sentence position embeddings to use. The first NUM sentences will get unique sentence position embeddings. Documents longer than NUM will have the last sentence position embedding repeated. (Default: 50)
  • --segment-size SIZE Dimension of segment embeddings. (Default: 16)
  • --position-size SIZE Dimension of position embeddings. (Default: 16)

Evaluating a Model

To get a model's ROUGE scores on the train, validation, or test set use script_bin/eval_model.py.

E.g.:

python eval_model.py \
  --inputs PATH/TO/INPUTS/DIR \
  --refs PATH/TO/REFERENCE/DIR \
  --model PATH/TO/MODEL \
  --results PATH/TO/WRITE/RESULTS \
  --summary-length 100 

Eval script parameters are described below:

  • --batch-size BATCH_SIZE Batch size to use when generating summaries. (Default: 32)
  • --gpu GPU Which gpu device to use. When GPU == -1, use cpu. (Default: -1)
  • --sentence-limit LIMIT Only read in the first LIMIT sentences in the document to be summarized. By default there is no limit. (Default: None)
  • --summary-length LENGTH The summary word length to use in ROUGE evauation. (Default: 100)
  • --remove-stopwords When flag is true ROUGE evaluation is done with stopwords removed.
  • --inputs PATH Path to input data directory. (required)
  • --refs PATH Path to human reference summary directory. (required)
  • --model PATH Path to saved model to evaluate. (required)
  • --results PATH Path to write results json. Stores per document ROUGE scores and dataset average scores. (optional)

nnsum's People

Contributors

kedz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nnsum's Issues

custom data

How does one go about summarizing a couple news articles, which are outside of the data sets you've mentioned?

somethings goes wrong after loading data

Hi,

I encountered a problem when using your code.
here is the command I used:

python script_bin/train_model.py \
	--trainer	--train-inputs cnn-dailymail/inputs/train \
			--train-labels cnn-dailymail/labels/train \
			--valid-inputs cnn-dailymail/inputs/valid \
			--valid-labels cnn-dailymail/labels/valid \
			--valid-refs cnn-dailymail/human-abstracts/valid \
			--weighted \
			--gpu 0 \
			--seed 12345678 \
	--emb	--pretrained-embeddings glove/glove.6B.200d.txt \
	--enc cnn \
	--ext s2s --bidirectional

and here is the msg on the screen:

{'train_inputs': PosixPath('cnn-dailymail/inputs/train'), 'train_labels': PosixPath('cnn-dailymail/labels/train'), 'valid_inputs': PosixPath('cnn-dailymail/inputs/valid'), 'valid_labels': PosixPath('cnn-dailymail/labels/valid'), 'valid_refs': PosixPath('cnn-dailymail/human-abstracts/valid'), 'seed': 12345678, 'epochs': 50, 'batch_size': 32, 'gpu': 0, 'teacher_forcing': 25, 'sentence_limit': 50, 'weighted': True, 'loader_workers': 8, 'raml_samples': 25, 'raml_temp': 0.05, 'summary_length': 100, 'remove_stopwords': False, 'shuffle_sents': False, 'model': None, 'results': None}

{'embedding_size': 200, 'pretrained_embeddings': 'glove/glove.6B.200d.txt', 'top_k': None, 'at_least': 1, 'word_dropout': 0.0, 'embedding_dropout': 0.25, 'update_rule': 'fix-all', 'filter_pretrained': False}

{'dropout': 0.25, 'filter_windows': [1, 2, 3, 4, 5, 6], 'feature_maps': [25, 25, 50, 50, 50, 50], 'OPT': 'cnn'}

{'hidden_size': 300, 'bidirectional': True, 'rnn_dropout': 0.25, 'num_layers': 1, 'cell': 'gru', 'mlp_layers': [100], 'mlp_dropouts': [0.25], 'OPT': 's2s'}
Initializing vocabulary and embeddings.
INFO:root: Reading pretrained embeddings from glove/glove.6B.200d.txt
INFO:root: Read 400002 embeddings of size 200
INFO:root: EmbeddingContext(
  (embeddings): Embedding(400002, 200, padding_idx=0)
)
Loading training data.
Loading validation data.
INFO:root: Computing class weights...
287113/287113
INFO:root: Counts y=0: 8980574, y=1 1119138
INFO:root: Reweighting y=1 by 8.024545677119354

Placing model on device: 0
INFO:root: Model parameter initialization started.
INFO:root: EmbeddingContext initialization started.
INFO:root: Initializing with pretrained embeddings.
INFO:root: EmbeddingContext initialization finished.
INFO:root: CNNSentenceEncoder initialization started.
INFO:root: filters.0.weight (25,1,1,1,200): Xavier normal init.
INFO:root: filters.0.bias (25): constant (0) init.
INFO:root: filters.1.weight (25,1,1,2,200): Xavier normal init.
INFO:root: filters.1.bias (25): constant (0) init.
INFO:root: filters.2.weight (50,1,1,3,200): Xavier normal init.
INFO:root: filters.2.bias (50): constant (0) init.
INFO:root: filters.3.weight (50,1,1,4,200): Xavier normal init.
INFO:root: filters.3.bias (50): constant (0) init.
INFO:root: filters.4.weight (50,1,1,5,200): Xavier normal init.
INFO:root: filters.4.bias (50): constant (0) init.
INFO:root: filters.5.weight (50,1,1,6,200): Xavier normal init.
INFO:root: filters.5.bias (50): constant (0) init.
INFO:root: CNNSentenceEncoder initialization finished.
INFO:root: Seq2SeqSentenceExtractor initialization started.
INFO:root: decoder_start (250): random normal init.
INFO:root: encoder_rnn.weight_ih_l0 (900,250): Xavier normal init.
INFO:root: encoder_rnn.weight_hh_l0 (900,300): Xavier normal init.
INFO:root: encoder_rnn.bias_ih_l0 (900): constant (0) init.
INFO:root: encoder_rnn.bias_hh_l0 (900): constant (0) init.
INFO:root: encoder_rnn.weight_ih_l0_reverse (900,250): Xavier normal init.
INFO:root: encoder_rnn.weight_hh_l0_reverse (900,300): Xavier normal init.
INFO:root: encoder_rnn.bias_ih_l0_reverse (900): constant (0) init.
INFO:root: encoder_rnn.bias_hh_l0_reverse (900): constant (0) init.
INFO:root: decoder_rnn.weight_ih_l0 (900,250): Xavier normal init.
INFO:root: decoder_rnn.weight_hh_l0 (900,300): Xavier normal init.
INFO:root: decoder_rnn.bias_ih_l0 (900): constant (0) init.
INFO:root: decoder_rnn.bias_hh_l0 (900): constant (0) init.
INFO:root: decoder_rnn.weight_ih_l0_reverse (900,250): Xavier normal init.
INFO:root: decoder_rnn.weight_hh_l0_reverse (900,300): Xavier normal init.
INFO:root: decoder_rnn.bias_ih_l0_reverse (900): constant (0) init.
INFO:root: decoder_rnn.bias_hh_l0_reverse (900): constant (0) init.
INFO:root: mlp.0.weight (100,1200): Xavier normal init.
INFO:root: mlp.0.bias (100): constant (0) init.
INFO:root: mlp.3.weight (1,100): Xavier normal init.
INFO:root: mlp.3.bias (1): constant (0) init.
INFO:root: Seq2SeqSentenceExtractor initialization finished.
INFO:root: Model parameter initialization finished.

INFO:ignite.engine.engine.Engine:Engine run starting with max_epochs=50
ERROR:ignite.engine.engine.Engine:Current run is terminating due to exception: 'NoneType' object has no attribute 'data'
ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: 'NoneType' object has no attribute 'data'
Traceback (most recent call last):
  File "script_bin/train_model.py", line 79, in <module>
    main()
  File "script_bin/train_model.py", line 76, in main
    results_path=args["trainer"]["results"])
  File "/home/bowen/packages/anaconda3/lib/python3.6/site-packages/nnsum-1.0-py3.6.egg/nnsum/trainer/labels_mle_trainer.py", line 164, in labels_mle_trainer
  File "/home/bowen/packages/anaconda3/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 326, in run
    self._handle_exception(e)
  File "/home/bowen/packages/anaconda3/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 291, in _handle_exception
    raise e
  File "/home/bowen/packages/anaconda3/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 313, in run
    hours, mins, secs = self._run_once_on_dataset()
  File "/home/bowen/packages/anaconda3/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 280, in _run_once_on_dataset
    self._handle_exception(e)
  File "/home/bowen/packages/anaconda3/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 291, in _handle_exception
    raise e
  File "/home/bowen/packages/anaconda3/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 272, in _run_once_on_dataset
    self.state.output = self._process_function(self, batch)
  File "/home/bowen/packages/anaconda3/lib/python3.6/site-packages/nnsum-1.0-py3.6.egg/nnsum/trainer/labels_mle_trainer.py", line 188, in _update
AttributeError: 'NoneType' object has no attribute 'data'

I don't know what is the problem? Hope you can help me:)

Thanks!

ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: 'rouge'.

Hi, @kedz
Getting the following error, I am trying with reddit data for "train the CNN encoder with Seq2Seq extractor on gpu 0"

ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: 'rouge'.
Traceback (most recent call last):
File "/content/drive/My Drive/Colab Notebooks/SummaRuNNer-implem/nnsum-master/script_bin/train_model.py", line 81, in
main()
File "/content/drive/My Drive/Colab Notebooks/SummaRuNNer-implem/nnsum-master/script_bin/train_model.py", line 78, in main
results_path=args["trainer"]["results"])
File "/content/drive/My Drive/Colab Notebooks/SummaRuNNer-implem/nnsum-master/nnsum/trainer/labels_mle_trainer.py", line 164, in labels_mle_trainer
trainer.run(train_dataloader, max_epochs=max_epochs)
File "/usr/local/lib/python3.6/dist-packages/ignite/engine/engine.py", line 658, in run
return self._internal_run()
File "/usr/local/lib/python3.6/dist-packages/ignite/engine/engine.py", line 729, in _internal_run
self._handle_exception(e)
File "/usr/local/lib/python3.6/dist-packages/ignite/engine/engine.py", line 437, in _handle_exception
raise e
File "/usr/local/lib/python3.6/dist-packages/ignite/engine/engine.py", line 704, in _internal_run
self._fire_event(Events.EPOCH_COMPLETED)
File "/usr/local/lib/python3.6/dist-packages/ignite/engine/engine.py", line 393, in _fire_event
func(*first, *(event_args + others), **kwargs)
File "/content/drive/My Drive/Colab Notebooks/SummaRuNNer-implem/nnsum-master/nnsum/trainer/labels_mle_trainer.py", line 115, in log_validation_results
if valid_metrics["rouge"]["rouge-1"] > trainer.state.max_valid_rouge1:
KeyError: 'rouge'

how to use the rouge_papier to test lead algorithm

Can you provide me an example for test lead algorithm with rouge_papier?
I have obtained the top words with your settings in your paper and the gold extract summaries, how I can compute the rouge score?
the fold is :
lead-x/result/ each article as a file, and one sentence in a line
lead-x/ref/ each article as a file, and one sentence in a line
how can I do?
Best wishes for you ๏ผ

Test problem

I have trained the model using given command, when I use the given command of testing, I have encountered the following problem.
AttributeError: 'collections.OrderedDict' object has no attribute 'embeddings'

ImportError: cannot import name '_to_hours_mins_secs'

I run the program but got error: ImportError: cannot import name '_to_hours_mins_secs'
Can you guide me how to solve this error.
Thanks.

(nnsum) C:\Users\17674\Desktop\MultiModalSummary\nnsum-master>python script_bin/train_model.py --trainer --train-inputs data\ami.v2\inputs\train --train-labels data\ami.v2\labels\train --valid-inputs data\ami.v2\inputs\valid --valid-labels data\ami.v2\labels\valid --valid-refs data\ami.v2\human-abstracts\valid  --weighted --model save --results log --seed 12345678 --emb --pretrained-embeddings D:\Code\Glove\glove.42B.300d.txt  --enc cnn --ext s2s --bidirectional
Traceback (most recent call last):
  File "script_bin/train_model.py", line 4, in <module>
    import nnsum
  File "C:\Users\17674\anaconda3\envs\nnsum\lib\site-packages\nnsum-1.0-py3.6.egg\nnsum\__init__.py", line 4, in <module>
  File "C:\Users\17674\anaconda3\envs\nnsum\lib\site-packages\nnsum-1.0-py3.6.egg\nnsum\trainer\__init__.py", line 1, in <module>
  File "C:\Users\17674\anaconda3\envs\nnsum\lib\site-packages\nnsum-1.0-py3.6.egg\nnsum\trainer\labels_mle_trainer.py", line 8, in <module>
ImportError: cannot import name '_to_hours_mins_secs'

Problem downloading PubMed dataset

Hi,
I tried downloading PubMed data-set using

python summarization-datasets/preprocess_pubmed.py
--data-dir data/

This creates directory data/pubmed on my system (Windows 10) and has disk size of approx. 1.47 GB but within pubmed folder, all the files are of 0 KB.

ERROR:ignite.engine.engine.Engine:Current run is terminating due to exception: 'NoneType' object has no attribute 'data'. ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: 'NoneType' object has no attribute 'data'.

when I try to use this repo to run the AMI dataset , I got this error ,can you help me?
My command is:
python train_model.py --trainer --train-inputs /home/workspace/IdeaProjects/word2sentExtract/datasets/ami/inputs/train/ --train-labels /home/workspace/IdeaProjects/word2sentExtract/datasets/ami/labels/train/ --valid-inputs /home/workspace/IdeaProjects/word2sentExtract/datasets/ami/inputs/valid/ --valid-labels /home/workspace/IdeaProjects/word2sentExtract/datasets/ami/labels/valid/ --valid-refs /home/workspace/IdeaProjects/word2sentExtract/datasets/ami/human-abstracts/valid/ --model best_model --results results/ --seed 12345678 --emb --enc cnn --ext s2s --bidirectional
the error message are follows:
`{'train_inputs': PosixPath('/home/workspace/IdeaProjects/word2sentExtract/datasets/ami/inputs/train'), 'train_labels': PosixPath('/home/workspace/IdeaProjects/word2sentExtract/datasets/ami/labels/train'), 'valid_inputs': PosixPath('/home/workspace/IdeaProjects/word2sentExtract/datasets/ami/inputs/valid'), 'valid_labels': PosixPath('/home/workspace/IdeaProjects/word2sentExtract/datasets/ami/labels/valid'), 'valid_refs': PosixPath('/home/workspace/IdeaProjects/word2sentExtract/datasets/ami/human-abstracts/valid'), 'seed': 12345678, 'epochs': 50, 'batch_size': 32, 'gpu': -1, 'teacher_forcing': 25, 'sentence_limit': 50, 'weighted': False, 'loader_workers': 8, 'raml_samples': 25, 'raml_temp': 0.05, 'summary_length': 100, 'remove_stopwords': False, 'shuffle_sents': False, 'model': PosixPath('best_model'), 'results': PosixPath('results')}

{'embedding_size': 200, 'pretrained_embeddings': None, 'top_k': None, 'at_least': 1, 'word_dropout': 0.0, 'embedding_dropout': 0.25, 'update_rule': 'fix-all', 'filter_pretrained': False}

{'dropout': 0.25, 'filter_windows': [1, 2, 3, 4, 5, 6], 'feature_maps': [25, 25, 50, 50, 50, 50], 'OPT': 'cnn'}

{'hidden_size': 300, 'bidirectional': True, 'rnn_dropout': 0.25, 'num_layers': 1, 'cell': 'gru', 'mlp_layers': [100], 'mlp_dropouts': [0.25], 'OPT': 's2s'}
Initializing vocabulary and embeddings.
INFO:root: Creating new embeddings with normal initializaion.
INFO:root: # Unique Words: 8663
INFO:root: After filtering, # Unique Words: 8665
WARNING:root: Embeddings are randomly initialized but update rule is not 'update-all'
INFO:root: EmbeddingContext(
(embeddings): Embedding(8665, 200, padding_idx=0)
)
Loading training data.
Loading validation data.
INFO:root: Model parameter initialization started.
INFO:root: EmbeddingContext initialization started.
INFO:root: Initializing with random normal.
INFO:root: EmbeddingContext initialization finished.
INFO:root: CNNSentenceEncoder initialization started.
INFO:root: filters.0.weight (25,1,1,1,200): Xavier normal init.
INFO:root: filters.0.bias (25): constant (0) init.
INFO:root: filters.1.weight (25,1,1,2,200): Xavier normal init.
INFO:root: filters.1.bias (25): constant (0) init.
INFO:root: filters.2.weight (50,1,1,3,200): Xavier normal init.
INFO:root: filters.2.bias (50): constant (0) init.
INFO:root: filters.3.weight (50,1,1,4,200): Xavier normal init.
INFO:root: filters.3.bias (50): constant (0) init.
INFO:root: filters.4.weight (50,1,1,5,200): Xavier normal init.
INFO:root: filters.4.bias (50): constant (0) init.
INFO:root: filters.5.weight (50,1,1,6,200): Xavier normal init.
INFO:root: filters.5.bias (50): constant (0) init.
INFO:root: CNNSentenceEncoder initialization finished.
INFO:root: Seq2SeqSentenceExtractor initialization started.
INFO:root: decoder_start (250): random normal init.
INFO:root: encoder_rnn.weight_ih_l0 (900,250): Xavier normal init.
INFO:root: encoder_rnn.weight_hh_l0 (900,300): Xavier normal init.
INFO:root: encoder_rnn.bias_ih_l0 (900): constant (0) init.
INFO:root: encoder_rnn.bias_hh_l0 (900): constant (0) init.
INFO:root: encoder_rnn.weight_ih_l0_reverse (900,250): Xavier normal init.
INFO:root: encoder_rnn.weight_hh_l0_reverse (900,300): Xavier normal init.
INFO:root: encoder_rnn.bias_ih_l0_reverse (900): constant (0) init.
INFO:root: encoder_rnn.bias_hh_l0_reverse (900): constant (0) init.
INFO:root: decoder_rnn.weight_ih_l0 (900,250): Xavier normal init.
INFO:root: decoder_rnn.weight_hh_l0 (900,300): Xavier normal init.
INFO:root: decoder_rnn.bias_ih_l0 (900): constant (0) init.
INFO:root: decoder_rnn.bias_hh_l0 (900): constant (0) init.
INFO:root: decoder_rnn.weight_ih_l0_reverse (900,250): Xavier normal init.
INFO:root: decoder_rnn.weight_hh_l0_reverse (900,300): Xavier normal init.
INFO:root: decoder_rnn.bias_ih_l0_reverse (900): constant (0) init.
INFO:root: decoder_rnn.bias_hh_l0_reverse (900): constant (0) init.
INFO:root: mlp.0.weight (100,1200): Xavier normal init.
INFO:root: mlp.0.bias (100): constant (0) init.
INFO:root: mlp.3.weight (1,100): Xavier normal init.
INFO:root: mlp.3.bias (1): constant (0) init.
INFO:root: Seq2SeqSentenceExtractor initialization finished.
INFO:root: Model parameter initialization finished.

INFO:ignite.engine.engine.Engine:Engine run starting with max_epochs=50.
ERROR:ignite.engine.engine.Engine:Current run is terminating due to exception: 'NoneType' object has no attribute 'data'.
ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: 'NoneType' object has no attribute 'data'.
Traceback (most recent call last):
File "train_model.py", line 79, in
main()
File "train_model.py", line 76, in main
results_path=args["trainer"]["results"])
File "/home/qxm/anaconda3/lib/python3.7/site-packages/nnsum-1.0-py3.7.egg/nnsum/trainer/labels_mle_trainer.py", line 164, in labels_mle_trainer
File "/home/qxm/anaconda3/lib/python3.7/site-packages/pytorch_ignite-0.5.0.dev20200721-py3.7.egg/ignite/engine/engine.py", line 658, in run
return self._internal_run()
File "/home/qxm/anaconda3/lib/python3.7/site-packages/pytorch_ignite-0.5.0.dev20200721-py3.7.egg/ignite/engine/engine.py", line 729, in _internal_run
self._handle_exception(e)
File "/home/qxm/anaconda3/lib/python3.7/site-packages/pytorch_ignite-0.5.0.dev20200721-py3.7.egg/ignite/engine/engine.py", line 437, in _handle_exception
raise e
File "/home/qxm/anaconda3/lib/python3.7/site-packages/pytorch_ignite-0.5.0.dev20200721-py3.7.egg/ignite/engine/engine.py", line 697, in _internal_run
time_taken = self._run_once_on_dataset()
File "/home/qxm/anaconda3/lib/python3.7/site-packages/pytorch_ignite-0.5.0.dev20200721-py3.7.egg/ignite/engine/engine.py", line 795, in _run_once_on_dataset
self._handle_exception(e)
File "/home/qxm/anaconda3/lib/python3.7/site-packages/pytorch_ignite-0.5.0.dev20200721-py3.7.egg/ignite/engine/engine.py", line 437, in _handle_exception
raise e
File "/home/qxm/anaconda3/lib/python3.7/site-packages/pytorch_ignite-0.5.0.dev20200721-py3.7.egg/ignite/engine/engine.py", line 778, in _run_once_on_dataset
self.state.output = self._process_function(self, self.state.batch)
File "/home/qxm/anaconda3/lib/python3.7/site-packages/nnsum-1.0-py3.7.egg/nnsum/trainer/labels_mle_trainer.py", line 188, in _update
AttributeError: 'NoneType' object has no attribute 'data'
`

How can I fix it?
Best wishes for you!

ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: Loss must have at least one example before it can be computed

Hi,

Getting the following error. I am trying with the pubmed data for "train the CNN encoder with Seq2Seq extractor on gpu 0"

Traceback (most recent call last):
File "script_bin/train_model.py", line 79, in
main()
File "script_bin/train_model.py", line 76, in main
results_path=args["trainer"]["results"])
File "/home/paperspace/Documents/python3env/lib/python3.6/site-packages/nnsum-1.0-py3.6.egg/nnsum/trainer/labels_mle_trainer.py", line 164, in labels_mle_trainer
File "/home/paperspace/Documents/python3env/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 326, in run
self._handle_exception(e)
File "/home/paperspace/Documents/python3env/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 291, in _handle_exception
raise e
File "/home/paperspace/Documents/python3env/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 317, in run
self._fire_event(Events.EPOCH_COMPLETED)
File "/home/paperspace/Documents/python3env/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/engine/engine.py", line 226, in _fire_event
func(self, *(event_args + args), **kwargs)
File "/home/paperspace/Documents/python3env/lib/python3.6/site-packages/pytorch_ignite-0.1.2-py3.6.egg/ignite/metrics/metric.py", line 68, in completed
engine.state.metrics[name] = self.compute()
File "/home/paperspace/Documents/python3env/lib/python3.6/site-packages/nnsum-1.0-py3.6.egg/nnsum/metrics/loss.py", line 21, in compute
ignite.exceptions.NotComputableError: Loss must have at least one example before it can be computed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.