facebookresearch / ParlAI

A framework for training and evaluating AI models on a variety of openly available dialogue datasets.
https://parl.ai
MIT License
10.48k stars 2.1k forks source link

Type error while generating self-chats for dailydialog task #3383

Closed adisaw closed 3 years ago

adisaw commented 3 years ago

Bug description Getting a type error while generating self-chats for the dailydialog task using the hred model

Reproduction steps //Using colab !git clone https://github.com/facebookresearch/ParlAI.git !nvidia-smi !apt install build-essential -qq !apt install python3.7 -qq !apt install python3-pip -qq !python3.7 -m pip -q install setuptools !python3.7 -m pip -q install --upgrade pip !python3.7 -m pip -q install --upgrade setuptools !python3.7 -m pip -q install tensorboard !python3.7 -m pip --quiet install -r ParlAI/requirements.txt !python3.7 -m pip -q install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html !cd ParlAI; python3.7 setup.py develop !parlai train_model -t dailydialog -bs 4 -eps 5 -vp 10 -m hred -mf hred_dd !parlai self_chat -mf hred_dd -t dailydialog --inference topk --num-self-chats 10 --display-examples True -dt valid //Line causing error

Expected behavior the self chats to be generated

Logs Please paste the command line output: 18:41:13 | Overriding opt["inference"] to topk (previously: greedy) 18:41:13 | Overriding opt["display_examples"] to True (previously: False) 18:41:13 | Overriding opt["datatype"] to valid (previously: train) 18:41:13 | Using CUDA 18:41:13 | loading dictionary from hred_dd.dict 18:41:13 | num words = 20678 18:41:13 | Hred: full interactive mode on. 18:41:18 | Total parameters: 8,819,142 (8,819,142 trainable) 18:41:18 | Loading existing model params from hred_dd 18:41:18 | Agent 1 Opt: 18:41:18 | adafactor_eps: '[1e-30, 0.001]' 18:41:18 | adam_eps: 1e-08 18:41:18 | add_p1_after_newln: False 18:41:18 | aggregate_micro: False 18:41:18 | allow_missing_init_opts: False 18:41:18 | batchsize: 4 18:41:18 | beam_block_full_context: True 18:41:18 | beam_block_list_filename: None 18:41:18 | beam_block_ngram: -1 18:41:18 | beam_context_block_ngram: -1 18:41:18 | beam_delay: 30 18:41:18 | beam_length_penalty: 0.65 18:41:18 | beam_min_length: 1 18:41:18 | beam_size: 1 18:41:18 | betas: '[0.9, 0.999]' 18:41:18 | bpe_add_prefix_space: None 18:41:18 | bpe_debug: False 18:41:18 | bpe_dropout: None 18:41:18 | bpe_merge: None 18:41:18 | bpe_vocab: None 18:41:18 | compute_tokenized_bleu: False 18:41:18 | datapath: /content/ParlAI/data 18:41:18 | datatype: valid 18:41:18 | delimiter: '\n' 18:41:18 | dict_class: parlai.core.dict:DictionaryAgent 18:41:18 | dict_endtoken: end 18:41:18 | dict_file: hred_dd.dict 18:41:18 | dict_include_test: False 18:41:18 | dict_include_valid: False 18:41:18 | dict_initpath: None 18:41:18 | dict_language: english 18:41:18 | dict_loaded: True 18:41:18 | dict_lower: False 18:41:18 | dict_max_ngram_size: -1 18:41:18 | dict_maxexs: -1 18:41:18 | dict_maxtokens: -1 18:41:18 | dict_minfreq: 0 18:41:18 | dict_nulltoken: null 18:41:18 | dict_starttoken: start 18:41:18 | dict_textfields: text,labels 18:41:18 | dict_tokenizer: re 18:41:18 | dict_unktoken: unk 18:41:18 | display_add_fields: 18:41:18 | display_examples: True 18:41:18 | download_path: None 18:41:18 | dropout: 0.1 18:41:18 | dynamic_batching: None 18:41:18 | embedding_projection: random 18:41:18 | embedding_type: random 18:41:18 | embeddingsize: 128 18:41:18 | eval_batchsize: None 18:41:18 | evaltask: None 18:41:18 | force_fp16_tokens: False 18:41:18 | fp16: False 18:41:18 | fp16_impl: apex 18:41:18 | gpu: -1 18:41:18 | gradient_clip: 0.1 18:41:18 | hiddensize: 128 18:41:18 | hide_labels: False 18:41:18 | history_add_global_end_token: None 18:41:18 | history_reversed: False 18:41:18 | history_size: -1 18:41:18 | image_cropsize: 224 18:41:18 | image_mode: raw 18:41:18 | image_size: 256 18:41:18 | inference: topk 18:41:18 | init_model: None 18:41:18 | init_opt: None 18:41:18 | input_dropout: 0.0 18:41:18 | interactive_mode: True 18:41:18 | invsqrt_lr_decay_gamma: -1 18:41:18 | label_truncate: None 18:41:18 | learningrate: 1 18:41:18 | log_every_n_secs: 10 18:41:18 | log_keep_fields: all 18:41:18 | loglevel: info 18:41:18 | lookuptable: unique 18:41:18 | lr_scheduler: reduceonplateau 18:41:18 | lr_scheduler_decay: 0.5 18:41:18 | lr_scheduler_patience: 3 18:41:18 | max_lr_steps: -1 18:41:18 | max_train_time: -1 18:41:18 | metrics: default 18:41:18 | model: hred 18:41:18 | model_file: hred_dd 18:41:18 | momentum: 0 18:41:18 | multitask_weights: [1] 18:41:18 | nesterov: True 18:41:18 | no_cuda: False 18:41:18 | num_epochs: 5.0 18:41:18 | num_self_chats: 10 18:41:18 | numlayers: 2 18:41:18 | nus: [0.7] 18:41:18 | optimizer: sgd 18:41:18 | outfile: None 18:41:18 | override: "{'model_file': 'hred_dd', 'task': 'dailydialog', 'inference': 'topk', 'num_self_chats': 10, 'display_examples': True, 'datatype': 'valid'}" 18:41:18 | parlai_home: /content/ParlAI 18:41:18 | partner_model_file: None 18:41:18 | partner_opt_file: None 18:41:18 | person_tokens: False 18:41:18 | rank_candidates: False 18:41:18 | save_after_valid: False 18:41:18 | save_every_n_secs: -1 18:41:18 | save_format: conversations 18:41:18 | seed: 42 18:41:18 | seed_messages_from_task: False 18:41:18 | selfchat_max_turns: 6 18:41:18 | selfchat_task: True 18:41:18 | short_final_eval: False 18:41:18 | skip_generation: False 18:41:18 | special_tok_lst: None 18:41:18 | split_lines: False 18:41:18 | starttime: Jan14_17-09 18:41:18 | task: dailydialog 18:41:18 | temperature: 1.0 18:41:18 | tensorboard_log: False 18:41:18 | tensorboard_logdir: None 18:41:18 | text_truncate: None 18:41:18 | topk: 10 18:41:18 | topp: 0.9 18:41:18 | truncate: -1 18:41:18 | update_freq: 1 18:41:18 | use_reply: label 18:41:18 | validation_cutoff: 1.0 18:41:18 | validation_every_n_epochs: -1 18:41:18 | validation_every_n_secs: -1 18:41:18 | validation_max_exs: -1 18:41:18 | validation_metric: accuracy 18:41:18 | validation_metric_mode: None 18:41:18 | validation_patience: 10 18:41:18 | validation_share_agent: False 18:41:18 | verbose: False 18:41:18 | warmup_rate: 0.0001 18:41:18 | warmup_updates: -1 18:41:18 | weight_decay: None 18:41:18 | Current ParlAI commit: ff73d1f20ce712a041502f7e0ac105bfd5398eca 18:41:18 | creating task(s): dailydialog Traceback (most recent call last): File "/usr/local/bin/parlai", line 33, in sys.exit(load_entry_point('parlai', 'console_scripts', 'parlai')()) File "/content/ParlAI/parlai/main.py", line 14, in main superscript_main() File "/content/ParlAI/parlai/core/script.py", line 306, in superscript_main return SCRIPT_REGISTRY[cmd].klass._run_from_parser_and_opt(opt, parser) File "/content/ParlAI/parlai/core/script.py", line 89, in _run_from_parser_and_opt return script.run() File "/content/ParlAI/parlai/scripts/self_chat.py", line 171, in run return self_chat(self.opt) File "/content/ParlAI/parlai/scripts/self_chat.py", line 141, in self_chat _run_self_chat_episode(opt, world, logger) File "/content/ParlAI/parlai/scripts/self_chat.py", line 88, in _run_self_chat_episode world.parley() File "/content/ParlAI/parlai/core/worlds.py", line 344, in parley acts[0] = agents[0].act() File "/content/ParlAI/parlai/core/torch_agent.py", line 1950, in act response = self.batch_act([self.observation])[0] File "/content/ParlAI/parlai/core/torch_agent.py", line 1974, in batch_act self.is_training = any('labels' in obs for obs in observations) File "/content/ParlAI/parlai/core/torch_agent.py", line 1974, in self.is_training = any('labels' in obs for obs in observations) TypeError: argument of type 'NoneType' is not iterable

Additional context Add any other context about the problem here. (like proxy settings, network setup, overall goals, etc.)

stephenroller commented 3 years ago

DailyDialog doesn't have a custom world to provide context/initial utterances. I believe you can drop the -t dailydialog arg to get your self chats.

When no self chat world exists, we should raise an error message which suggests that you drop the argument. Assigning to @jxmsML

stephenroller commented 3 years ago

Another alternative would be a generic self world that grabs initial utterances but that seems like behavior we'd want very intentionally specified by the user.

stephenroller commented 3 years ago

@adisaw, can you tell me a bit about what you might expect to happen when you generate a self chat for a dataset which doesn't have special context?

adisaw commented 3 years ago

I tried this command dropping -t dailydialog !parlai self_chat -mf hred_dd --num-self-chats 10 --display-examples True -dt valid but it gives a runtime error

Traceback (most recent call last): File "/usr/local/bin/parlai", line 33, in sys.exit(load_entry_point('parlai', 'console_scripts', 'parlai')()) File "/content/ParlAI/parlai/main.py", line 14, in main superscript_main() File "/content/ParlAI/parlai/core/script.py", line 306, in superscript_main return SCRIPT_REGISTRY[cmd].klass._run_from_parser_and_opt(opt, parser) File "/content/ParlAI/parlai/core/script.py", line 89, in _run_from_parser_and_opt return script.run() File "/content/ParlAI/parlai/scripts/self_chat.py", line 171, in run return self_chat(self.opt) File "/content/ParlAI/parlai/scripts/self_chat.py", line 141, in self_chat _run_self_chat_episode(opt, world, logger) File "/content/ParlAI/parlai/scripts/self_chat.py", line 88, in _run_self_chat_episode world.parley() File "/content/ParlAI/parlai/tasks/self_chat/worlds.py", line 167, in parley acts[1] = agents[1].act() File "/content/ParlAI/parlai/core/torch_agent.py", line 1950, in act response = self.batch_act([self.observation])[0] File "/content/ParlAI/parlai/core/torch_agent.py", line 2011, in batch_act output = self.eval_step(batch) File "/content/ParlAI/parlai/core/torch_generator_agent.py", line 894, in eval_step beam_preds_scores, beams = self._generate(batch, self.beam_size, maxlen) File "/content/ParlAI/parlai/core/torch_generator_agent.py", line 1103, in _generate encoder_states = model.encoder(self._encoder_input(batch)) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, *kwargs) File "/content/ParlAI/parlai/agents/hred/modules.py", line 181, in forward (_, (sorted_hiddenstate, ), _) = super().forward(sorted_context_vec) File "/content/ParlAI/parlai/agents/seq2seq/modules.py", line 303, in forward xes = self.dropout(self.lt(xs)) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, **kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/sparse.py", line 126, in forward self.norm_type, self.scale_grad_by_freq, self.sparse) File "/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py", line 1852, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.cuda.FloatTensor instead (while checking arguments for embedding)

adisaw commented 3 years ago

I was expecting it to use the daily dialog test set utterances as context to further generate the self chats

stephenroller commented 3 years ago

Hred_dd is not one of our models. I think it might have to do with that code, at this point.

adisaw commented 3 years ago

hred_dd is the model_file. hred model trained on the dailydialog task

github-actions[bot] commented 3 years ago

This issue has not had activity in 30 days. Please feel free to reopen if you have more issues. You may apply the "never-stale" tag to prevent this from happening.