MinyeLee / Question-Generation-Pytorch

Question Generation model implementation in pytorch
12 stars 9 forks source link

Why did you define the `LuongAttnDecoderRNN` twice? #1

Open jnhwkim opened 5 years ago

jnhwkim commented 5 years ago

https://github.com/MinyeLee/Question-Generation-Pytorch/blob/0c5dd2b9ce568b22ebb3522712f1900ecef1ef14/main.py#L533

https://github.com/MinyeLee/Question-Generation-Pytorch/blob/0c5dd2b9ce568b22ebb3522712f1900ecef1ef14/main.py#L576

jnhwkim commented 5 years ago

It seems you update the code in main_new.py. Could you elaborate on your recent update?

MinyeLee commented 5 years ago

Hello, What I update is below.

(1) Vocabulary & Embedding before: I made one vocabulary dictionary which includes every words both from input sentences and questions.

updated version: However, according to the thesis, it said, “For the source side vocabulary V, we only keep the 45k most frequent tokens (including , and placeholders). For the target side vocabulary U, similarly, we keep the 28k most frequent tokens.”. So, I made separate vocabulary dictionary, one is source-side vocabulary for the encoder part, and the other is target-side vocabulary for decoder part. Also, I ignored non frequent words which appears less than 2, which reduces the size of embedding matrix and number of cases so that it helps performance.

(2) Shuffle, and ignore data before: The maximum length of both input sentence and questions was 50.

updated version: The maximum length of input sentence is 100 and target question is 50. I removed data which is longer than maximum sentence.

(3) Attention model before: At that time, I used dot method for attention, because i tested dot method has good performance. updated version: I changed to concat method according to paper.

I keep developing for better performance in Question Generation model, and i keep updating few changes.

jnhwkim commented 5 years ago

Thank you for the info. However, I've faced with this error when I run python main.py, which may relate to my first claim:

Iteration: 3998; Percent complete: 100.0%; Average loss: 2.9444
Iteration: 3999; Percent complete: 100.0%; Average loss: 2.9373
Iteration: 4000; Percent complete: 100.0%; Average loss: 2.6248
> In computer science, Artificial intelligence (AI), sometimes called machine intelligence, is intelligence demonstrated by machines, in contrast to the natural intelligence displayed by humans and other animals.
Traceback (most recent call last):
  File "main.py", line 981, in <module>
    evaluateInput(encoder, decoder, searcher, voc)
  File "main.py", line 883, in evaluateInput
    output_words = evaluate(encoder, decoder, searcher, voc, input_sentence)
  File "main.py", line 866, in evaluate
    tokens, scores = searcher(input_batch, lengths, max_length)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 503, in __call__
    result = self.forward(*input, **kwargs)
  File "main.py", line 829, in forward
    encoder_outputs, (encoder_hidden, encoder_cell_state) = self.encoder(input_seq, input_length)
ValueError: too many values to unpack (expected 2)
MinyeLee commented 5 years ago

Oh i got it. It is my mistake while i convert ipynb to python script. i should delete below one which uses gru model. I updated my code.

MinyeLee commented 5 years ago

It shows better performance. ====> docker pull minyelee/dok2qa:0.3 ====> docker run -it --runtime=nvidia --rm minyelee/dok2qa:0.3 python main.py

screen shot 2018-12-27 at 1 53 36 am

SundeepPidugu commented 5 years ago

@MinyeLee is there a way to run the same without the runtime as nvidia ? on my local desktop ?

MinyeLee commented 5 years ago

This QG module works on local (without GPU), if you remove option(runtime=nvidia)

please refer below command line. GPU Version docker run -it --runtime=nvidia --rm minyelee/dok2qa:0.3 python main.py

CPU Version docker run -it --rm minyelee/dok2qa:0.3 python main.py

Screen Shot 2019-04-12 at 5 34 46 PM

SundeepPidugu commented 5 years ago

Whats the simplest way to save the model and pass a text document to model to predict the question from the document ?

suresh96458 commented 4 years ago

I want it to run on GPU bit iam facing the bellow error while running the command


docker run -it --runtime=nvidia --rm minyelee/dok2qa:0.3 python main.py

docker: Error response from daemon: Unknown runtime specified nvidia.

@MinyeLee