{"action":"created","comment":{"url":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/comments/208381771","pull_request_review_id":144179886,"id":208381771,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODM4MTc3MQ==","diff_hunk":"@@ -250,6 +250,45 @@ def vectorize(self, obs, add_start=True, add_end=True, truncate=None):\n \n         return obs\n \n+    def _padded_tensor(self, items):\n+        \"\"\"Create a right-padded matrix from an uneven list of lists.\n+\n+        :param list[list[int]] items: List of items\n+        :param bool sort: If True, orders by the length\n+        :rtype: (Tensor[int64], list[int])\n+        :return: (padded, lengths)\n+        \"\"\"\n+        n = len(items)\n+        lens = [len(item) for item in items]\n+        t = max(lens)\n+        output = torch.LongTensor(n, t).fill_(self.NULL_IDX)\n+        for i in range(len(items)):\n+            output[i, :lens[i]] = items[i]\n+        if self.use_cuda:\n+            output = output.cuda()\n+        return output, lens\n+\n+    def _argsort(self, keys, *lists, descending=False):","path":"parlai/core/torch_agent.py","position":22,"original_position":22,"commit_id":"5b280d361c87841cbafafc5d7e991feb02f197c3","original_commit_id":"5b280d361c87841cbafafc5d7e991feb02f197c3","user":{"login":"stephenroller","id":31896,"node_id":"MDQ6VXNlcjMxODk2","avatar_url":"https://avatars2.githubusercontent.com/u/31896?v=4","gravatar_id":"","url":"https://api.github.com/users/stephenroller","html_url":"https://github.com/stephenroller","followers_url":"https://api.github.com/users/stephenroller/followers","following_url":"https://api.github.com/users/stephenroller/following{/other_user}","gists_url":"https://api.github.com/users/stephenroller/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenroller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenroller/subscriptions","organizations_url":"https://api.github.com/users/stephenroller/orgs","repos_url":"https://api.github.com/users/stephenroller/repos","events_url":"https://api.github.com/users/stephenroller/events{/privacy}","received_events_url":"https://api.github.com/users/stephenroller/received_events","type":"User","site_admin":false},"body":"TODO: unit test.\r\n\r\nBoth these utility methods could be useful as general utilities rather than being stuffed into this module here.","created_at":"2018-08-07T20:54:35Z","updated_at":"2018-08-07T20:56:19Z","html_url":"https://github.com/facebookresearch/ParlAI/pull/1052#discussion_r208381771","pull_request_url":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/1052","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/comments/208381771"},"html":{"href":"https://github.com/facebookresearch/ParlAI/pull/1052#discussion_r208381771"},"pull_request":{"href":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/1052"}}},"pull_request":{"url":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/1052","id":206823228,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2ODIzMjI4","html_url":"https://github.com/facebookresearch/ParlAI/pull/1052","diff_url":"https://github.com/facebookresearch/ParlAI/pull/1052.diff","patch_url":"https://github.com/facebookresearch/ParlAI/pull/1052.patch","issue_url":"https://api.github.com/repos/facebookresearch/ParlAI/issues/1052","number":1052,"state":"open","locked":false,"title":"Implement fairseq candidate ranking using generator.","user":{"login":"stephenroller","id":31896,"node_id":"MDQ6VXNlcjMxODk2","avatar_url":"https://avatars2.githubusercontent.com/u/31896?v=4","gravatar_id":"","url":"https://api.github.com/users/stephenroller","html_url":"https://github.com/stephenroller","followers_url":"https://api.github.com/users/stephenroller/followers","following_url":"https://api.github.com/users/stephenroller/following{/other_user}","gists_url":"https://api.github.com/users/stephenroller/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenroller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenroller/subscriptions","organizations_url":"https://api.github.com/users/stephenroller/orgs","repos_url":"https://api.github.com/users/stephenroller/repos","events_url":"https://api.github.com/users/stephenroller/events{/privacy}","received_events_url":"https://api.github.com/users/stephenroller/received_events","type":"User","site_admin":false},"body":"Uses avg probability per token of the sequence (should be same thing `seq2seq` uses). This is not configurable; it is just a dumb call to fairseq's grader.\r\n\r\nSupports variable number of candidates. The way this is done is with multiple calls to scorer, so the batch size isn't as exploited as it could be. We could increase throughput by streamlining, but it would come at the cost of complexity. Seems fine for now.\r\n\r\nHolding until #1049 is merged, as there will likely need to be unit test updates and resolving conflicts.","created_at":"2018-08-07T20:52:03Z","updated_at":"2018-08-07T20:56:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c53933d7636d12a34810a77036f850378f53d97","assignee":null,"assignees":[],"requested_reviewers":[{"login":"alexholdenmiller","id":1141354,"node_id":"MDQ6VXNlcjExNDEzNTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1141354?v=4","gravatar_id":"","url":"https://api.github.com/users/alexholdenmiller","html_url":"https://github.com/alexholdenmiller","followers_url":"https://api.github.com/users/alexholdenmiller/followers","following_url":"https://api.github.com/users/alexholdenmiller/following{/other_user}","gists_url":"https://api.github.com/users/alexholdenmiller/gists{/gist_id}","starred_url":"https://api.github.com/users/alexholdenmiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexholdenmiller/subscriptions","organizations_url":"https://api.github.com/users/alexholdenmiller/orgs","repos_url":"https://api.github.com/users/alexholdenmiller/repos","events_url":"https://api.github.com/users/alexholdenmiller/events{/privacy}","received_events_url":"https://api.github.com/users/alexholdenmiller/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":590886701,"node_id":"MDU6TGFiZWw1OTA4ODY3MDE=","url":"https://api.github.com/repos/facebookresearch/ParlAI/labels/CLA%20Signed","name":"CLA Signed","color":"009900","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/1052/commits","review_comments_url":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/1052/comments","review_comment_url":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebookresearch/ParlAI/issues/1052/comments","statuses_url":"https://api.github.com/repos/facebookresearch/ParlAI/statuses/5b280d361c87841cbafafc5d7e991feb02f197c3","head":{"label":"facebookresearch:gradecands","ref":"gradecands","sha":"5b280d361c87841cbafafc5d7e991feb02f197c3","user":{"login":"facebookresearch","id":16943930,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2OTQzOTMw","avatar_url":"https://avatars0.githubusercontent.com/u/16943930?v=4","gravatar_id":"","url":"https://api.github.com/users/facebookresearch","html_url":"https://github.com/facebookresearch","followers_url":"https://api.github.com/users/facebookresearch/followers","following_url":"https://api.github.com/users/facebookresearch/following{/other_user}","gists_url":"https://api.github.com/users/facebookresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/facebookresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebookresearch/subscriptions","organizations_url":"https://api.github.com/users/facebookresearch/orgs","repos_url":"https://api.github.com/users/facebookresearch/repos","events_url":"https://api.github.com/users/facebookresearch/events{/privacy}","received_events_url":"https://api.github.com/users/facebookresearch/received_events","type":"Organization","site_admin":false},"repo":{"id":89266735,"node_id":"MDEwOlJlcG9zaXRvcnk4OTI2NjczNQ==","name":"ParlAI","full_name":"facebookresearch/ParlAI","owner":{"login":"facebookresearch","id":16943930,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2OTQzOTMw","avatar_url":"https://avatars0.githubusercontent.com/u/16943930?v=4","gravatar_id":"","url":"https://api.github.com/users/facebookresearch","html_url":"https://github.com/facebookresearch","followers_url":"https://api.github.com/users/facebookresearch/followers","following_url":"https://api.github.com/users/facebookresearch/following{/other_user}","gists_url":"https://api.github.com/users/facebookresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/facebookresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebookresearch/subscriptions","organizations_url":"https://api.github.com/users/facebookresearch/orgs","repos_url":"https://api.github.com/users/facebookresearch/repos","events_url":"https://api.github.com/users/facebookresearch/events{/privacy}","received_events_url":"https://api.github.com/users/facebookresearch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebookresearch/ParlAI","description":"A framework for training and evaluating AI models on a variety of openly available dialog datasets.","fork":false,"url":"https://api.github.com/repos/facebookresearch/ParlAI","forks_url":"https://api.github.com/repos/facebookresearch/ParlAI/forks","keys_url":"https://api.github.com/repos/facebookresearch/ParlAI/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebookresearch/ParlAI/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebookresearch/ParlAI/teams","hooks_url":"https://api.github.com/repos/facebookresearch/ParlAI/hooks","issue_events_url":"https://api.github.com/repos/facebookresearch/ParlAI/issues/events{/number}","events_url":"https://api.github.com/repos/facebookresearch/ParlAI/events","assignees_url":"https://api.github.com/repos/facebookresearch/ParlAI/assignees{/user}","branches_url":"https://api.github.com/repos/facebookresearch/ParlAI/branches{/branch}","tags_url":"https://api.github.com/repos/facebookresearch/ParlAI/tags","blobs_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebookresearch/ParlAI/statuses/{sha}","languages_url":"https://api.github.com/repos/facebookresearch/ParlAI/languages","stargazers_url":"https://api.github.com/repos/facebookresearch/ParlAI/stargazers","contributors_url":"https://api.github.com/repos/facebookresearch/ParlAI/contributors","subscribers_url":"https://api.github.com/repos/facebookresearch/ParlAI/subscribers","subscription_url":"https://api.github.com/repos/facebookresearch/ParlAI/subscription","commits_url":"https://api.github.com/repos/facebookresearch/ParlAI/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebookresearch/ParlAI/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebookresearch/ParlAI/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebookresearch/ParlAI/contents/{+path}","compare_url":"https://api.github.com/repos/facebookresearch/ParlAI/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebookresearch/ParlAI/merges","archive_url":"https://api.github.com/repos/facebookresearch/ParlAI/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebookresearch/ParlAI/downloads","issues_url":"https://api.github.com/repos/facebookresearch/ParlAI/issues{/number}","pulls_url":"https://api.github.com/repos/facebookresearch/ParlAI/pulls{/number}","milestones_url":"https://api.github.com/repos/facebookresearch/ParlAI/milestones{/number}","notifications_url":"https://api.github.com/repos/facebookresearch/ParlAI/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebookresearch/ParlAI/labels{/name}","releases_url":"https://api.github.com/repos/facebookresearch/ParlAI/releases{/id}","deployments_url":"https://api.github.com/repos/facebookresearch/ParlAI/deployments","created_at":"2017-04-24T17:10:44Z","updated_at":"2018-08-07T17:26:53Z","pushed_at":"2018-08-07T20:52:03Z","git_url":"git://github.com/facebookresearch/ParlAI.git","ssh_url":"git@github.com:facebookresearch/ParlAI.git","clone_url":"https://github.com/facebookresearch/ParlAI.git","svn_url":"https://github.com/facebookresearch/ParlAI","homepage":"parl.ai","size":11850,"stargazers_count":3527,"watchers_count":3527,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":622,"mirror_url":null,"archived":false,"open_issues_count":25,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":622,"open_issues":25,"watchers":3527,"default_branch":"master"}},"base":{"label":"facebookresearch:master","ref":"master","sha":"383eefc6abccc6aa93cb04ad69aaf8eaea65d1a3","user":{"login":"facebookresearch","id":16943930,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2OTQzOTMw","avatar_url":"https://avatars0.githubusercontent.com/u/16943930?v=4","gravatar_id":"","url":"https://api.github.com/users/facebookresearch","html_url":"https://github.com/facebookresearch","followers_url":"https://api.github.com/users/facebookresearch/followers","following_url":"https://api.github.com/users/facebookresearch/following{/other_user}","gists_url":"https://api.github.com/users/facebookresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/facebookresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebookresearch/subscriptions","organizations_url":"https://api.github.com/users/facebookresearch/orgs","repos_url":"https://api.github.com/users/facebookresearch/repos","events_url":"https://api.github.com/users/facebookresearch/events{/privacy}","received_events_url":"https://api.github.com/users/facebookresearch/received_events","type":"Organization","site_admin":false},"repo":{"id":89266735,"node_id":"MDEwOlJlcG9zaXRvcnk4OTI2NjczNQ==","name":"ParlAI","full_name":"facebookresearch/ParlAI","owner":{"login":"facebookresearch","id":16943930,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2OTQzOTMw","avatar_url":"https://avatars0.githubusercontent.com/u/16943930?v=4","gravatar_id":"","url":"https://api.github.com/users/facebookresearch","html_url":"https://github.com/facebookresearch","followers_url":"https://api.github.com/users/facebookresearch/followers","following_url":"https://api.github.com/users/facebookresearch/following{/other_user}","gists_url":"https://api.github.com/users/facebookresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/facebookresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebookresearch/subscriptions","organizations_url":"https://api.github.com/users/facebookresearch/orgs","repos_url":"https://api.github.com/users/facebookresearch/repos","events_url":"https://api.github.com/users/facebookresearch/events{/privacy}","received_events_url":"https://api.github.com/users/facebookresearch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebookresearch/ParlAI","description":"A framework for training and evaluating AI models on a variety of openly available dialog datasets.","fork":false,"url":"https://api.github.com/repos/facebookresearch/ParlAI","forks_url":"https://api.github.com/repos/facebookresearch/ParlAI/forks","keys_url":"https://api.github.com/repos/facebookresearch/ParlAI/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebookresearch/ParlAI/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebookresearch/ParlAI/teams","hooks_url":"https://api.github.com/repos/facebookresearch/ParlAI/hooks","issue_events_url":"https://api.github.com/repos/facebookresearch/ParlAI/issues/events{/number}","events_url":"https://api.github.com/repos/facebookresearch/ParlAI/events","assignees_url":"https://api.github.com/repos/facebookresearch/ParlAI/assignees{/user}","branches_url":"https://api.github.com/repos/facebookresearch/ParlAI/branches{/branch}","tags_url":"https://api.github.com/repos/facebookresearch/ParlAI/tags","blobs_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebookresearch/ParlAI/statuses/{sha}","languages_url":"https://api.github.com/repos/facebookresearch/ParlAI/languages","stargazers_url":"https://api.github.com/repos/facebookresearch/ParlAI/stargazers","contributors_url":"https://api.github.com/repos/facebookresearch/ParlAI/contributors","subscribers_url":"https://api.github.com/repos/facebookresearch/ParlAI/subscribers","subscription_url":"https://api.github.com/repos/facebookresearch/ParlAI/subscription","commits_url":"https://api.github.com/repos/facebookresearch/ParlAI/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebookresearch/ParlAI/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebookresearch/ParlAI/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebookresearch/ParlAI/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebookresearch/ParlAI/contents/{+path}","compare_url":"https://api.github.com/repos/facebookresearch/ParlAI/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebookresearch/ParlAI/merges","archive_url":"https://api.github.com/repos/facebookresearch/ParlAI/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebookresearch/ParlAI/downloads","issues_url":"https://api.github.com/repos/facebookresearch/ParlAI/issues{/number}","pulls_url":"https://api.github.com/repos/facebookresearch/ParlAI/pulls{/number}","milestones_url":"https://api.github.com/repos/facebookresearch/ParlAI/milestones{/number}","notifications_url":"https://api.github.com/repos/facebookresearch/ParlAI/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebookresearch/ParlAI/labels{/name}","releases_url":"https://api.github.com/repos/facebookresearch/ParlAI/releases{/id}","deployments_url":"https://api.github.com/repos/facebookresearch/ParlAI/deployments","created_at":"2017-04-24T17:10:44Z","updated_at":"2018-08-07T17:26:53Z","pushed_at":"2018-08-07T20:52:03Z","git_url":"git://github.com/facebookresearch/ParlAI.git","ssh_url":"git@github.com:facebookresearch/ParlAI.git","clone_url":"https://github.com/facebookresearch/ParlAI.git","svn_url":"https://github.com/facebookresearch/ParlAI","homepage":"parl.ai","size":11850,"stargazers_count":3527,"watchers_count":3527,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":622,"mirror_url":null,"archived":false,"open_issues_count":25,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":622,"open_issues":25,"watchers":3527,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/1052"},"html":{"href":"https://github.com/facebookresearch/ParlAI/pull/1052"},"issue":{"href":"https://api.github.com/repos/facebookresearch/ParlAI/issues/1052"},"comments":{"href":"https://api.github.com/repos/facebookresearch/ParlAI/issues/1052/comments"},"review_comments":{"href":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/1052/comments"},"review_comment":{"href":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebookresearch/ParlAI/pulls/1052/commits"},"statuses":{"href":"https://api.github.com/repos/facebookresearch/ParlAI/statuses/5b280d361c87841cbafafc5d7e991feb02f197c3"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"stephenroller"}}