internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: facebookresearch/ParlAI

Issue:
Error when running DrQA PyTorch 1.0.0
When running the basic example on SQUAD 
```python examples/train_model.py -m drqa -t squad -bs 32```
Throwing this. 
```[ training... ]
/content/DuReader/data/ParlAI/parlai/agents/drqa/layers.py:177: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  alpha_flat = F.softmax(scores.view(-1, y.size(1)))
/content/DuReader/data/ParlAI/parlai/agents/drqa/layers.py:237: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  alpha = F.softmax(scores)
/content/DuReader/data/ParlAI/parlai/agents/drqa/layers.py:210: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.
  alpha = F.log_softmax(xWy)
Traceback (most recent call last):
  File "examples/train_model.py", line 16, in <module>
    TrainLoop(opt).train()
  File "/content/DuReader/data/ParlAI/parlai/scripts/train_model.py", line 500, in train
    world.parley()
  File "/content/DuReader/data/ParlAI/parlai/core/worlds.py", line 641, in parley
    batch_act = self.batch_act(agent_idx, batch_observations[agent_idx])
  File "/content/DuReader/data/ParlAI/parlai/core/worlds.py", line 614, in batch_act
    batch_actions = a.batch_act(batch_observation)
  File "/content/DuReader/data/ParlAI/parlai/agents/drqa/drqa.py", line 227, in batch_act
    self.model.update(batch)
  File "/content/DuReader/data/ParlAI/parlai/agents/drqa/model.py", line 102, in update
    self.train_loss.update(loss.data[0], ex[0].size(0))
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
```
I think this is related to the new version of PyTorch and the fix should be fairly trivial. Anyone working on fixing it soon? If not I could probably do a PR. 


Discussion:

Resolving patch:
diff --git a/parlai/agents/drqa/model.py b/parlai/agents/drqa/model.py
--- a/parlai/agents/drqa/model.py
+++ b/parlai/agents/drqa/model.py
@@ -99,7 +99,7 @@ def update(self, ex):
 
         # Compute loss and accuracies
         loss = F.nll_loss(score_s, target_s) + F.nll_loss(score_e, target_e)
-        self.train_loss.update(loss.data[0], ex[0].size(0))
+        self.train_loss.update(loss.data.item(), ex[0].size(0))
 
         # Clear gradients and run backward
         self.optimizer.zero_grad()


Test patch:
Repository: facebookresearch/ParlAI

Issue:
Training transformer model on dialydialog with poor results
Hi everyone,
after training a transfomer/generator model with the dailydialog task, I received poor result interacting with the trained model. Below you can find the parameters I used for training and a screenshot of the "conversation". 
My question is, what could be the cause of this? Should I set other parameters as well? Should I use the transformer/ranker model? Please let me know if you have any information regarding this topic.

The parameters from the command: 
1. -m transformer/generator
2. -t dailydialog
3. -bs 8
4. -eps 25
5. -esz 512
6. -nl 6
7. -hid 512
8. --dropout 0.1
9. --n-heads 8
10. -mf /user....

![image](https://user-images.githubusercontent.com/26432380/55953188-b7fb7480-5c5b-11e9-88a7-af53f6286a06.png)



Discussion:
Seems like a problem with the interactive mode as I'm getting similar results with transfomer/generator. For me displaying the predictions works:

`python examples/display_model.py --model ${MODEL} -t ${TASK} -mf ${MODEL_FILE} -dt valid`

Something related to https://github.com/facebookresearch/ParlAI/pull/579?
I'm pretty sure you've just heavily overfit, and the messages you're entering into the model are sufficiently different from daily dialog for the model to be confused. Try copy pasting exact messages from the daily dialog validation set into the interactive session, and I bet it will do much better.

That transformer you're training is far too large for learning only daily dialog. You can make it slightly better by using pretrained embeddings (`-emb fasttext_cc`), but you're never really going to have success in this setup. You can make things more robust by multitasking it with a larger dataset (`-t twitter,dailydialog -et dailydialog`).

you can also use like, `--beam-size 5 --beam-min-length 5` to force longer responses.
Actually, I've got an idea of what it is.
I also ran into this problem, and I don't think it's overfitting since I tried the model at the minimum validation loss that it reached. Also, setting the beam size arguments doesn't seem to solve the problem (for me), it just generates longer responses that are not good.

Resolving patch:
diff --git a/parlai/core/torch_generator_agent.py b/parlai/core/torch_generator_agent.py
--- a/parlai/core/torch_generator_agent.py
+++ b/parlai/core/torch_generator_agent.py
@@ -603,7 +603,10 @@ def eval_step(self, batch):
             )
         elif self.beam_size == 1:
             # greedy decode
-            _, preds, *_ = self.model(*self._model_input(batch), bsz=bsz)
+            maxlen = self.label_truncate or 256
+            _, preds, *_ = self.model(
+                *self._model_input(batch), bsz=bsz, maxlen=maxlen
+            )
         elif self.beam_size > 1:
             out = self.beam_search(
                 self.model,


Test patch:
Repository: facebookresearch/ParlAI

Issue:
embeddingsize or embedding_size
When I search 'embeddingsize' in this repository, I see many files referencing `opt['embeddingsize']` and similarly for 'embedding_size'. Unless there is a real reason for having both, could you please merge the two options 'embeddingsize' and 'embedding_size'? This threw me off. Here is one example set of files:

'embeddingsize'
https://github.com/facebookresearch/ParlAI/blob/a43f2880719c5a048fdf3d0aa5d5b25eeb9a1a41/projects/wizard_of_wikipedia/generator/train_end2end.py#L21

'embedding_size'
https://github.com/facebookresearch/ParlAI/blob/8ab911a29dbbe5cfb7d3e615cccf8f4c76066ff1/projects/wizard_of_wikipedia/generator/agents.py#L33


Discussion:

Resolving patch:
diff --git a/projects/wizard_of_wikipedia/generator/train_end2end.py b/projects/wizard_of_wikipedia/generator/train_end2end.py
--- a/projects/wizard_of_wikipedia/generator/train_end2end.py
+++ b/projects/wizard_of_wikipedia/generator/train_end2end.py
@@ -18,7 +18,7 @@
         n_heads=2,
         dropout=0.20,
         ffn_size=512,
-        embeddingsize=256,
+        embedding_size=256,
         log_every_n_secs=10,
         validation_patience=12,
         validation_metric='ppl',


Test patch:
Repository: facebookresearch/ParlAI

Issue:
TorchAgents have an inadequate default id
Right now, all models must manually set `Agent.id`, including TorchAgent models. Presently, TorchAgent sets its id to `"TorchAgent"` and is used nearly everywhere. We should have TorchAgent set the default based on the class name of the current implementor, or something, so that things like display_data.py use better names.

transformer/generator is a good testing ground.


Discussion:

Resolving patch:
diff --git a/parlai/core/torch_agent.py b/parlai/core/torch_agent.py
--- a/parlai/core/torch_agent.py
+++ b/parlai/core/torch_agent.py
@@ -540,8 +540,10 @@ def __init__(self, opt, shared=None):
         # indicate whether using fp16
         self.fp16 = self.opt.get('fp16', False)
 
+        # Default to the class name, sans "Agent". child can override
+        self.id = type(self).__name__.replace("Agent", "")
+
         # now set up any fields that all instances may need
-        self.id = 'TorchAgent'  # child can override
         self.EMPTY = torch.LongTensor([])
         self.NULL_IDX = self.dict[self.dict.null_token]
         self.START_IDX = self.dict[self.dict.start_token]


Test patch:
Repository: facebookresearch/ParlAI

Issue:
AttributeError when TorchAgent.scheduler doesn't exist.
Hi contributors,

Please have a look at this line:

https://github.com/facebookresearch/ParlAI/blob/85653ee4f04b1236a6f6d32944f5856e54418ccd/parlai/core/torch_agent.py#L1366

If the TorchAgent object doesn't have the 'scheduler' attribute, it'll raise an AttributeError. Does this `getattr` meant to be `hasattr` like the above lines?


Discussion:
Probably should be `getattr(self, 'scheduler', None)`.

```python-console
>>> class Test(object):
...     foo = "bar"
...
>>> t = Test()
>>> t.foo
'bar'
>>> getattr(t, 'foo')
'bar'
>>> getattr(t, 'foo2')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Test' object has no attribute 'foo2'
>>> getattr(t, 'foo2', None)
>>>
```
Feel free to make a PR.
Yeah `getattr` definitely works well here but I thought `hasattr` is more suitable here and consistent with the line:

https://github.com/facebookresearch/ParlAI/blob/85653ee4f04b1236a6f6d32944f5856e54418ccd/parlai/core/torch_agent.py#L1347

Could you explain the reason for using `getattr(self, 'scheduler', None)` instead of `hasattr(self, 'scheduler')`?
Because scheduler is set to `None` when the user opts out of a scheduler

https://github.com/facebookresearch/ParlAI/blob/48db0dbbb235e1a6c5dd5caa7389d79b88b8af84/parlai/core/torch_agent.py#L710-L711

`hasattr` will still trigger when the attribute is set to `None`, but `getattr(attrname, None)` will return `None`, which will fail the if condition.

Resolving patch:
diff --git a/parlai/core/torch_agent.py b/parlai/core/torch_agent.py
--- a/parlai/core/torch_agent.py
+++ b/parlai/core/torch_agent.py
@@ -780,7 +780,8 @@ def _invsqrt_lr(step):
             self._number_training_updates = states['number_training_updates']
         if self.scheduler and 'lr_scheduler' in states:
             self.scheduler.load_state_dict(states['lr_scheduler'])
-        if states.get('warmup_scheduler') and getattr(self, 'warmup_scheduler'):
+        if states.get('warmup_scheduler') and getattr(self, 'warmup_scheduler',
+                                                      None):
             self.warmup_scheduler.load_state_dict(states['warmup_scheduler'])
 
     def report(self):
@@ -1373,10 +1374,10 @@ def state_dict(self):
             )
         else:
             states['number_training_updates'] = self._number_training_updates
-            if getattr(self, 'scheduler'):
+            if getattr(self, 'scheduler', None):
                 states['lr_scheduler'] = self.scheduler.state_dict()
                 states['lr_scheduler_type'] = self.opt['lr_scheduler']
-            if getattr(self, 'warmup_scheduler'):
+            if getattr(self, 'warmup_scheduler', None):
                 states['warmup_scheduler'] = self.warmup_scheduler.state_dict()
 
         return states


Test patch:
Repository: facebookresearch/ParlAI

Issue:
ParlAI User Survey: Last day!!!
Hello ParlAI Users!

We're conducting a user survey in order to better understand our users and their needs. We would greatly appreciate it if you would help us out by filling it out!

[https://forms.gle/uEFbYGP7w6hiuGQT9](https://forms.gle/uEFbYGP7w6hiuGQT9)

We will close the survey in one month.

Thank you for all your feedback,
The ParlAI Team


Discussion:
We will close the survey in 2 weeks.

Resolving patch:
diff --git a/parlai/core/params.py b/parlai/core/params.py
--- a/parlai/core/params.py
+++ b/parlai/core/params.py
@@ -26,6 +26,8 @@ def print_announcements(opt):
 
     Also gives the user the option to suppress the output.
     """
+    # no annoucements to make right now
+    return
 
     noannounce_file = os.path.join(opt.get('datapath'), 'noannouncements')
     if os.path.exists(noannounce_file):
@@ -54,29 +56,18 @@ def print_announcements(opt):
     stars = ''.join([color + '*' * size for color in rainbow])
     stars += RESET
 
-    # compute the countdown
-    import datetime
-    now = datetime.datetime.utcnow().timestamp()
-    closes = 1558151989  # 23:59:59 EDT Fri, May 18, 2019
-    daysleft = max(0, (int(closes - now) // (60 * 60 * 24)))
-
     # do the actual output
-    print("\n".join([
-        "",
-        stars + RESET,
-        'Thank you for using ParlAI! We are conducting a user survey.',
-        'Please fill it out at https://forms.gle/uEFbYGP7w6hiuGQT9',
-        '',
-        '{}The survey will close in {}{} day{}{}, on May 17, 2019.{}'.format(
-            BOLD,  RED, daysleft, 's' if daysleft != 1 else '', RESET + BOLD, RESET,
-        ),
+    print('\n'.join([
         '',
+        stars,
+        BOLD,
+        'Announcements go here.',
+        RESET,
         # don't bold the suppression command
-        '{}To suppress this message (and future announcements), run\n`touch {}`'.format(
-            RESET, noannounce_file
+        'To suppress this message (and future announcements), run\n`touch {}`'.format(
+            noannounce_file
         ),
         stars,
-        RESET,
     ]))
 
 


Test patch:
Repository: facebookresearch/ParlAI

Issue:
Instructions at https://parl.ai yield: Parse Error: unrecognized arguments: -n 100
From the examples section at https://parl.ai/, when running:

```bash
python examples/display_data.py -t babi:task1k:1,squad -n 100
```

I get the error:
```
Parse Error: unrecognized arguments: -n 100
```


Discussion:

Resolving patch:
diff --git a/parlai/scripts/display_data.py b/parlai/scripts/display_data.py
--- a/parlai/scripts/display_data.py
+++ b/parlai/scripts/display_data.py
@@ -29,9 +29,9 @@ def setup_args(parser=None):
         parser = ParlaiParser(True, True, 'Display data from a task')
     parser.add_pytorch_datateacher_args()
     # Get command line arguments
-    parser.add_argument('-ne', '--num_examples', type=int, default=10)
-    parser.add_argument('-mdl', '--max_display_len', type=int, default=1000)
-    parser.add_argument('--display_ignore_fields', type=str, default='agent_reply')
+    parser.add_argument('-n', '-ne', '--num-examples', type=int, default=10)
+    parser.add_argument('-mdl', '--max-display-len', type=int, default=1000)
+    parser.add_argument('--display-ignore-fields', type=str, default='agent_reply')
     parser.set_defaults(datatype='train:stream')
     return parser
 
diff --git a/parlai/scripts/display_model.py b/parlai/scripts/display_model.py
--- a/parlai/scripts/display_model.py
+++ b/parlai/scripts/display_model.py
@@ -24,7 +24,7 @@
 
 def setup_args():
     parser = ParlaiParser(True, True, 'Display model predictions.')
-    parser.add_argument('-n', '--num-examples', default=10)
+    parser.add_argument('-n', '-ne', '--num-examples', default=10)
     parser.add_argument('--display-ignore-fields', type=str, default='')
     # by default we want to display info about the validation set
     parser.set_defaults(datatype='valid')


Test patch:
Repository: facebookresearch/ParlAI

Issue:
AttributeError: 'dict' object has no attribute 'force_set'
**Bug description**
When I try the pretrained model of Self-feeding Chatbot, by `python projects/self_feeding/interactive.py --model-file zoo:self_feeding/hh131k_hb60k_fb60k_st1k/model --no-cuda`, error occurs: AttributeError: 'dict' object has no attribute 'force_set'

**Logs**
Please paste the command line output:

```
Enter Your Message: hello
Traceback (most recent call last):
  File "projects/self_feeding/interactive.py", line 87, in <module>
    interactive(parser.parse_args(print_args=False), print_parser=parser)
  File "projects/self_feeding/interactive.py", line 78, in interactive
    world.parley()
  File "/home/han/Github/ParlAI/parlai/core/worlds.py", line 273, in parley
    agents[1].observe(validate(acts[0]))
  File "/home/han/Github/ParlAI/projects/self_feeding/self_feeding_agent.py", line 370, in observe
    observation.force_set(
AttributeError: 'dict' object has no attribute 'force_set'
```

**Additional context**
Add any other context about the problem here. (like proxy settings, network setup, overall goals, etc.)



Discussion:

Resolving patch:
diff --git a/parlai/agents/local_human/local_human.py b/parlai/agents/local_human/local_human.py
--- a/parlai/agents/local_human/local_human.py
+++ b/parlai/agents/local_human/local_human.py
@@ -8,6 +8,7 @@
 """
 
 from parlai.core.agents import Agent
+from parlai.core.message import Message
 from parlai.core.utils import display_messages, load_cands
 
 
@@ -46,7 +47,7 @@ def observe(self, msg):
         )
 
     def act(self):
-        reply = {}
+        reply = Message()
         reply['id'] = self.getID()
         reply_text = input("Enter Your Message: ")
         reply_text = reply_text.replace('\\n', '\n')
@@ -55,7 +56,7 @@ def act(self):
         reply['episode_done'] = False
         reply['label_candidates'] = self.fixedCands_txt
         if '[DONE]' in reply_text:
-            reply['episode_done'] = True
+            reply.force_set('episode_done', True)
             self.episodeDone = True
             reply_text = reply_text.replace('[DONE]', '')
         reply['text'] = reply_text


Test patch:
Repository: facebookresearch/ParlAI

Issue:
Quickstart AttributeError: 'HogwildWorld' object has no attribute 'acts'
**Bug description**
When going through the ParlAI [quickstart](https://parl.ai/docs/tutorial_quick.html#install), I got the following error:

``` python
Traceback (most recent call last):
  File "examples/interactive.py", line 18, in <module>
    interactive(opt, print_parser=parser)
  File "/root/ParlAI/parlai/scripts/interactive.py", line 68, in interactive
    agent = create_agent(opt, requireModelExists=True)
  File "/root/ParlAI/parlai/core/agents.py", line 683, in create_agent
    model = load_agent_module(opt)
  File "/root/ParlAI/parlai/core/agents.py", line 548, in load_agent_module
    return model_class(new_opt)
  File "/root/ParlAI/parlai/agents/memnn/memnn.py", line 86, in __init__
    super().__init__(opt, shared)
  File "/root/ParlAI/parlai/core/torch_ranker_agent.py", line 135, in __init__
    super().__init__(opt, shared)
  File "/root/ParlAI/parlai/core/torch_agent.py", line 737, in __init__
    self.set_interactive_mode(opt['interactive_mode'], shared)
  File "/root/ParlAI/parlai/core/torch_ranker_agent.py", line 206, in set_interactive_mode
    path = self.get_task_candidates_path()
  File "/root/ParlAI/parlai/core/torch_ranker_agent.py", line 230, in get_task_candidates_path
    build_cands(opt)
  File "/root/ParlAI/parlai/scripts/build_candidates.py", line 47, in build_cands
    acts = world.get_acts()[0]
  File "/root/ParlAI/parlai/core/worlds.py", line 162, in get_acts
    return self.acts
AttributeError: 'HogwildWorld' object has no attribute 'acts'
```

**While running**
```python
python examples/interactive.py -mf /tmp/babi_memnn -ecands vocab
```



Discussion:
Thanks for filing

Resolving patch:
diff --git a/parlai/scripts/build_candidates.py b/parlai/scripts/build_candidates.py
--- a/parlai/scripts/build_candidates.py
+++ b/parlai/scripts/build_candidates.py
@@ -23,6 +23,9 @@
 
 def build_cands(opt):
     # create repeat label agent and assign it to the specified task
+    if opt['numthreads'] > 1:
+        # Broken in hogwild mode. Just fall back to single processing mode
+        opt['numthreads'] = 1
     agent = RepeatLabelAgent(opt)
     world = create_task(opt, agent)
     if opt['outfile'] is None:


Test patch:
Repository: facebookresearch/ParlAI

Issue:
Rename the wikipedia_2016-12-21 module
Blocks #2163.

When I've tried to run mypy, I got this error message. It's correct, there's an invalid module in our repo. It should be renamed to remove the hyphens, or deleted. I previously tried just a quick move of it and it resolved the issue.

```
$ mypy --ignore-missing-imports parlai
wikipedia_2016-12-21 is not a valid Python package name
```

Presumably adding type checking will prevent this from happening again.


Discussion:

Resolving patch:
diff --git a/parlai/zoo/model_list.py b/parlai/zoo/model_list.py
--- a/parlai/zoo/model_list.py
+++ b/parlai/zoo/model_list.py
@@ -15,7 +15,7 @@
 ... code-block:
 
    python examples/interactive.py --model-file
-       "zoo:wikipedia_2016-12-21/tfidf_retriever/drqa_docs"
+       "zoo:wikipedia_20161221/tfidf_retriever/drqa_docs"
 
 
 There are a number of guidelines you should follow in the zoo:
@@ -103,14 +103,14 @@
     },
     {
         "title": "Wikipedia Retriever (used for open SQuAD)",
-        "id": "wikipedia_2016-12-21",
-        "path": "zoo:wikipedia_2016-12-21/tfidf_retriever/drqa_docs",
+        "id": "wikipedia_20161221",
+        "path": "zoo:wikipedia_20161221/tfidf_retriever/drqa_docs",
         "agent": "tfidf_retriever",
         "external_website": "https://github.com/facebookresearch/DrQA",
         "task": "wikipedia:full",
         "example": (
             "python -m parlai.scripts.interactive --model tfidf_retriever "
-            "-mf zoo:wikipedia_2016-12-21/tfidf_retriever/drqa_docs"
+            "-mf zoo:wikipedia_20161221/tfidf_retriever/drqa_docs"
         ),
         "result": (
             """
diff --git a/parlai/zoo/wikipedia_2016-12-21/__init__.py b/parlai/zoo/wikipedia_20161221/__init__.py
similarity index 100%
rename from parlai/zoo/wikipedia_2016-12-21/__init__.py
rename to parlai/zoo/wikipedia_20161221/__init__.py
diff --git a/parlai/zoo/wikipedia_2016-12-21/tfidf_retriever.py b/parlai/zoo/wikipedia_20161221/tfidf_retriever.py
similarity index 76%
rename from parlai/zoo/wikipedia_2016-12-21/tfidf_retriever.py
rename to parlai/zoo/wikipedia_20161221/tfidf_retriever.py
--- a/parlai/zoo/wikipedia_2016-12-21/tfidf_retriever.py
+++ b/parlai/zoo/wikipedia_20161221/tfidf_retriever.py
@@ -5,7 +5,7 @@
 # LICENSE file in the root directory of this source tree.
 """TFIDF retriever for Wikipedia (for use with e.g. DrQA+SQuAD).
 access from model zoo with:
-  --model-file "models:wikipedia_2016-12-21/tfidf_retriever/drqa_docs"
+  --model-file "zoo:wikipedia_20161221/tfidf_retriever/drqa_docs"
 """
 
 from parlai.core.build_data import download_models
@@ -15,4 +15,4 @@ def download(datapath):
     opt = {'datapath': datapath}
     fnames = ['drqa_docs.tgz']
     opt['model_type'] = 'tfidf_retriever'  # for builder
-    download_models(opt, fnames, 'wikipedia_2016-12-21', use_model_type=True)
+    download_models(opt, fnames, 'wikipedia_20161221', use_model_type=True)


Test patch: