{"action":"created","comment":{"url":"https://api.github.com/repos/allenai/allennlp/pulls/comments/181504898","pull_request_review_id":112153056,"id":181504898,"diff_hunk":"@@ -0,0 +1,69 @@\n+from typing import Generic, List, TypeVar\n+\n+import torch\n+\n+# Note that the bound here is `DecoderState` itself.  This is what lets us have methods that take\n+# lists of a `DecoderState` subclass and output structures with the subclass.  Really ugly that we\n+# have to do this generic typing _for our own class_, but it makes mypy happy and gives us good\n+# type checking in a few important methods.\n+T = TypeVar('T', bound='DecoderState')\n+\n+class DecoderState(Generic[T]):\n+    \"\"\"\n+    Represents the (batched) state of a transition-based decoder.\n+\n+    There are two different kinds of batching we need to distinguish here.  First, there's the\n+    batch of training instances passed to ``model.forward()``.  We'll use \"batch\" and\n+    ``batch_size`` to refer to this through the docs and code.  We additionally batch together\n+    computation for several states at the same time, where each state could be from the same\n+    training instance in the original batch, or different instances.  We use \"group\" and\n+    ``group_size`` in the docs and code to refer to this kind of batching, to distinguish it from\n+    the batch of training instances.\n+\n+    So, using this terminology, a single ``DecoderState`` object represents a `grouped` collection\n+    of states.  Because different states in this group might finish at different timesteps, we have\n+    methods and member variables to handle some bookkeeping around this, to split and regroup\n+    things.\n+\n+    Parameters\n+    ----------\n+    batch_indices : ``List[int]``\n+        Our internal variables (like scores, action histories, hidden states, whatever) are\n+        `grouped`, and our ``group_size`` is likely different from the original ``batch_size``.\n+        This variable keeps track of which batch instance each group element came from (e.g., to\n+        know what the correct action sequences are, or which encoder outputs to use).\n+    action_history : ``List[List[int]]``\n+        The list of actions taken so far in this state.  This is also grouped, so each state in the\n+        group has a list of actions.\n+\n+        The type annotation says this is an ``int``, but none of the training logic relies on this\n+        being an ``int``.  In some cases, items from this list will get passed as inputs to\n+        ``DecodeStep``, so this must return items that are compatible with inputs to your\n+        ``DecodeStep`` class.\n+    score : ``List[torch.autograd.Variable]``\n+        This state's score.  It's a variable, because typically we'll be computing a loss based on\n+        this score, and using it for backprop during training.  Like the other variables here, it's","path":"allennlp/nn/decoding/decoder_state.py","position":45,"original_position":45,"commit_id":"a0d83a14d59cfdfb6b8db99e385741c87d35fef8","original_commit_id":"a0d83a14d59cfdfb6b8db99e385741c87d35fef8","user":{"login":"schmmd","id":954798,"avatar_url":"https://avatars3.githubusercontent.com/u/954798?v=4","gravatar_id":"","url":"https://api.github.com/users/schmmd","html_url":"https://github.com/schmmd","followers_url":"https://api.github.com/users/schmmd/followers","following_url":"https://api.github.com/users/schmmd/following{/other_user}","gists_url":"https://api.github.com/users/schmmd/gists{/gist_id}","starred_url":"https://api.github.com/users/schmmd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schmmd/subscriptions","organizations_url":"https://api.github.com/users/schmmd/orgs","repos_url":"https://api.github.com/users/schmmd/repos","events_url":"https://api.github.com/users/schmmd/events{/privacy}","received_events_url":"https://api.github.com/users/schmmd/received_events","type":"User","site_admin":false},"body":"`s/\"Like the other variables here, it's grouped\"/\"The list length corresponds to the number of groups\"/`","created_at":"2018-04-13T20:41:27Z","updated_at":"2018-04-13T20:41:27Z","html_url":"https://github.com/allenai/allennlp/pull/1086#discussion_r181504898","pull_request_url":"https://api.github.com/repos/allenai/allennlp/pulls/1086","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/allenai/allennlp/pulls/comments/181504898"},"html":{"href":"https://github.com/allenai/allennlp/pull/1086#discussion_r181504898"},"pull_request":{"href":"https://api.github.com/repos/allenai/allennlp/pulls/1086"}}},"pull_request":{"url":"https://api.github.com/repos/allenai/allennlp/pulls/1086","id":181564821,"html_url":"https://github.com/allenai/allennlp/pull/1086","diff_url":"https://github.com/allenai/allennlp/pull/1086.diff","patch_url":"https://github.com/allenai/allennlp/pull/1086.patch","issue_url":"https://api.github.com/repos/allenai/allennlp/issues/1086","number":1086,"state":"open","locked":false,"title":"Adding the decoding framework from the wikitables branch","user":{"login":"matt-gardner","id":3291951,"avatar_url":"https://avatars2.githubusercontent.com/u/3291951?v=4","gravatar_id":"","url":"https://api.github.com/users/matt-gardner","html_url":"https://github.com/matt-gardner","followers_url":"https://api.github.com/users/matt-gardner/followers","following_url":"https://api.github.com/users/matt-gardner/following{/other_user}","gists_url":"https://api.github.com/users/matt-gardner/gists{/gist_id}","starred_url":"https://api.github.com/users/matt-gardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matt-gardner/subscriptions","organizations_url":"https://api.github.com/users/matt-gardner/orgs","repos_url":"https://api.github.com/users/matt-gardner/repos","events_url":"https://api.github.com/users/matt-gardner/events{/privacy}","received_events_url":"https://api.github.com/users/matt-gardner/received_events","type":"User","site_admin":false},"body":"This PR adds the transition-based decoding framework from the `wikitables` branch.  All of the code here has already been reviewed, so this doesn't need a thorough look at the code (unless you _want_ to go over it in detail!).  What I'm looking for in a review at this point is to make sure that the high-level structure of this module makes sense, and that the documentation is sufficient to know what each piece does and when it should be used.\r\n\r\nIt might be easiest to browse the code in my fork of the repo, found here: https://github.com/matt-gardner/allennlp/tree/decoding/allennlp/nn/decoding.  Start by looking at the module docstring in `__init__.py`, then look over the class structure, and class docstrings.  If anything isn't clear or could use some more documentation, let me know!","created_at":"2018-04-13T18:35:11Z","updated_at":"2018-04-13T20:41:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a4b92356d7447f4013aa147e87df8d4ff668977b","assignee":null,"assignees":[],"requested_reviewers":[{"login":"DeNeutoy","id":16001974,"avatar_url":"https://avatars1.githubusercontent.com/u/16001974?v=4","gravatar_id":"","url":"https://api.github.com/users/DeNeutoy","html_url":"https://github.com/DeNeutoy","followers_url":"https://api.github.com/users/DeNeutoy/followers","following_url":"https://api.github.com/users/DeNeutoy/following{/other_user}","gists_url":"https://api.github.com/users/DeNeutoy/gists{/gist_id}","starred_url":"https://api.github.com/users/DeNeutoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeNeutoy/subscriptions","organizations_url":"https://api.github.com/users/DeNeutoy/orgs","repos_url":"https://api.github.com/users/DeNeutoy/repos","events_url":"https://api.github.com/users/DeNeutoy/events{/privacy}","received_events_url":"https://api.github.com/users/DeNeutoy/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/allenai/allennlp/pulls/1086/commits","review_comments_url":"https://api.github.com/repos/allenai/allennlp/pulls/1086/comments","review_comment_url":"https://api.github.com/repos/allenai/allennlp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/allenai/allennlp/issues/1086/comments","statuses_url":"https://api.github.com/repos/allenai/allennlp/statuses/a0d83a14d59cfdfb6b8db99e385741c87d35fef8","head":{"label":"matt-gardner:decoding","ref":"decoding","sha":"a0d83a14d59cfdfb6b8db99e385741c87d35fef8","user":{"login":"matt-gardner","id":3291951,"avatar_url":"https://avatars2.githubusercontent.com/u/3291951?v=4","gravatar_id":"","url":"https://api.github.com/users/matt-gardner","html_url":"https://github.com/matt-gardner","followers_url":"https://api.github.com/users/matt-gardner/followers","following_url":"https://api.github.com/users/matt-gardner/following{/other_user}","gists_url":"https://api.github.com/users/matt-gardner/gists{/gist_id}","starred_url":"https://api.github.com/users/matt-gardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matt-gardner/subscriptions","organizations_url":"https://api.github.com/users/matt-gardner/orgs","repos_url":"https://api.github.com/users/matt-gardner/repos","events_url":"https://api.github.com/users/matt-gardner/events{/privacy}","received_events_url":"https://api.github.com/users/matt-gardner/received_events","type":"User","site_admin":false},"repo":{"id":95491709,"name":"allennlp","full_name":"matt-gardner/allennlp","owner":{"login":"matt-gardner","id":3291951,"avatar_url":"https://avatars2.githubusercontent.com/u/3291951?v=4","gravatar_id":"","url":"https://api.github.com/users/matt-gardner","html_url":"https://github.com/matt-gardner","followers_url":"https://api.github.com/users/matt-gardner/followers","following_url":"https://api.github.com/users/matt-gardner/following{/other_user}","gists_url":"https://api.github.com/users/matt-gardner/gists{/gist_id}","starred_url":"https://api.github.com/users/matt-gardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matt-gardner/subscriptions","organizations_url":"https://api.github.com/users/matt-gardner/orgs","repos_url":"https://api.github.com/users/matt-gardner/repos","events_url":"https://api.github.com/users/matt-gardner/events{/privacy}","received_events_url":"https://api.github.com/users/matt-gardner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matt-gardner/allennlp","description":"A natural language processing toolkit using state-of-the-art deep learning models.","fork":true,"url":"https://api.github.com/repos/matt-gardner/allennlp","forks_url":"https://api.github.com/repos/matt-gardner/allennlp/forks","keys_url":"https://api.github.com/repos/matt-gardner/allennlp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matt-gardner/allennlp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matt-gardner/allennlp/teams","hooks_url":"https://api.github.com/repos/matt-gardner/allennlp/hooks","issue_events_url":"https://api.github.com/repos/matt-gardner/allennlp/issues/events{/number}","events_url":"https://api.github.com/repos/matt-gardner/allennlp/events","assignees_url":"https://api.github.com/repos/matt-gardner/allennlp/assignees{/user}","branches_url":"https://api.github.com/repos/matt-gardner/allennlp/branches{/branch}","tags_url":"https://api.github.com/repos/matt-gardner/allennlp/tags","blobs_url":"https://api.github.com/repos/matt-gardner/allennlp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matt-gardner/allennlp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matt-gardner/allennlp/git/refs{/sha}","trees_url":"https://api.github.com/repos/matt-gardner/allennlp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matt-gardner/allennlp/statuses/{sha}","languages_url":"https://api.github.com/repos/matt-gardner/allennlp/languages","stargazers_url":"https://api.github.com/repos/matt-gardner/allennlp/stargazers","contributors_url":"https://api.github.com/repos/matt-gardner/allennlp/contributors","subscribers_url":"https://api.github.com/repos/matt-gardner/allennlp/subscribers","subscription_url":"https://api.github.com/repos/matt-gardner/allennlp/subscription","commits_url":"https://api.github.com/repos/matt-gardner/allennlp/commits{/sha}","git_commits_url":"https://api.github.com/repos/matt-gardner/allennlp/git/commits{/sha}","comments_url":"https://api.github.com/repos/matt-gardner/allennlp/comments{/number}","issue_comment_url":"https://api.github.com/repos/matt-gardner/allennlp/issues/comments{/number}","contents_url":"https://api.github.com/repos/matt-gardner/allennlp/contents/{+path}","compare_url":"https://api.github.com/repos/matt-gardner/allennlp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matt-gardner/allennlp/merges","archive_url":"https://api.github.com/repos/matt-gardner/allennlp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matt-gardner/allennlp/downloads","issues_url":"https://api.github.com/repos/matt-gardner/allennlp/issues{/number}","pulls_url":"https://api.github.com/repos/matt-gardner/allennlp/pulls{/number}","milestones_url":"https://api.github.com/repos/matt-gardner/allennlp/milestones{/number}","notifications_url":"https://api.github.com/repos/matt-gardner/allennlp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matt-gardner/allennlp/labels{/name}","releases_url":"https://api.github.com/repos/matt-gardner/allennlp/releases{/id}","deployments_url":"https://api.github.com/repos/matt-gardner/allennlp/deployments","created_at":"2017-06-26T21:38:48Z","updated_at":"2018-04-13T18:52:38Z","pushed_at":"2018-04-13T20:00:37Z","git_url":"git://github.com/matt-gardner/allennlp.git","ssh_url":"git@github.com:matt-gardner/allennlp.git","clone_url":"https://github.com/matt-gardner/allennlp.git","svn_url":"https://github.com/matt-gardner/allennlp","homepage":null,"size":10966,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"allenai:master","ref":"master","sha":"3ea82b1ff95de532d7624ed4c4488f72ec0f23bd","user":{"login":"allenai","id":5667695,"avatar_url":"https://avatars3.githubusercontent.com/u/5667695?v=4","gravatar_id":"","url":"https://api.github.com/users/allenai","html_url":"https://github.com/allenai","followers_url":"https://api.github.com/users/allenai/followers","following_url":"https://api.github.com/users/allenai/following{/other_user}","gists_url":"https://api.github.com/users/allenai/gists{/gist_id}","starred_url":"https://api.github.com/users/allenai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenai/subscriptions","organizations_url":"https://api.github.com/users/allenai/orgs","repos_url":"https://api.github.com/users/allenai/repos","events_url":"https://api.github.com/users/allenai/events{/privacy}","received_events_url":"https://api.github.com/users/allenai/received_events","type":"Organization","site_admin":false},"repo":{"id":91356408,"name":"allennlp","full_name":"allenai/allennlp","owner":{"login":"allenai","id":5667695,"avatar_url":"https://avatars3.githubusercontent.com/u/5667695?v=4","gravatar_id":"","url":"https://api.github.com/users/allenai","html_url":"https://github.com/allenai","followers_url":"https://api.github.com/users/allenai/followers","following_url":"https://api.github.com/users/allenai/following{/other_user}","gists_url":"https://api.github.com/users/allenai/gists{/gist_id}","starred_url":"https://api.github.com/users/allenai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenai/subscriptions","organizations_url":"https://api.github.com/users/allenai/orgs","repos_url":"https://api.github.com/users/allenai/repos","events_url":"https://api.github.com/users/allenai/events{/privacy}","received_events_url":"https://api.github.com/users/allenai/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/allenai/allennlp","description":"An open-source NLP research library, built on PyTorch.","fork":false,"url":"https://api.github.com/repos/allenai/allennlp","forks_url":"https://api.github.com/repos/allenai/allennlp/forks","keys_url":"https://api.github.com/repos/allenai/allennlp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/allenai/allennlp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/allenai/allennlp/teams","hooks_url":"https://api.github.com/repos/allenai/allennlp/hooks","issue_events_url":"https://api.github.com/repos/allenai/allennlp/issues/events{/number}","events_url":"https://api.github.com/repos/allenai/allennlp/events","assignees_url":"https://api.github.com/repos/allenai/allennlp/assignees{/user}","branches_url":"https://api.github.com/repos/allenai/allennlp/branches{/branch}","tags_url":"https://api.github.com/repos/allenai/allennlp/tags","blobs_url":"https://api.github.com/repos/allenai/allennlp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/allenai/allennlp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/allenai/allennlp/git/refs{/sha}","trees_url":"https://api.github.com/repos/allenai/allennlp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/allenai/allennlp/statuses/{sha}","languages_url":"https://api.github.com/repos/allenai/allennlp/languages","stargazers_url":"https://api.github.com/repos/allenai/allennlp/stargazers","contributors_url":"https://api.github.com/repos/allenai/allennlp/contributors","subscribers_url":"https://api.github.com/repos/allenai/allennlp/subscribers","subscription_url":"https://api.github.com/repos/allenai/allennlp/subscription","commits_url":"https://api.github.com/repos/allenai/allennlp/commits{/sha}","git_commits_url":"https://api.github.com/repos/allenai/allennlp/git/commits{/sha}","comments_url":"https://api.github.com/repos/allenai/allennlp/comments{/number}","issue_comment_url":"https://api.github.com/repos/allenai/allennlp/issues/comments{/number}","contents_url":"https://api.github.com/repos/allenai/allennlp/contents/{+path}","compare_url":"https://api.github.com/repos/allenai/allennlp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/allenai/allennlp/merges","archive_url":"https://api.github.com/repos/allenai/allennlp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/allenai/allennlp/downloads","issues_url":"https://api.github.com/repos/allenai/allennlp/issues{/number}","pulls_url":"https://api.github.com/repos/allenai/allennlp/pulls{/number}","milestones_url":"https://api.github.com/repos/allenai/allennlp/milestones{/number}","notifications_url":"https://api.github.com/repos/allenai/allennlp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/allenai/allennlp/labels{/name}","releases_url":"https://api.github.com/repos/allenai/allennlp/releases{/id}","deployments_url":"https://api.github.com/repos/allenai/allennlp/deployments","created_at":"2017-05-15T15:52:41Z","updated_at":"2018-04-13T20:26:53Z","pushed_at":"2018-04-13T20:00:39Z","git_url":"git://github.com/allenai/allennlp.git","ssh_url":"git@github.com:allenai/allennlp.git","clone_url":"https://github.com/allenai/allennlp.git","svn_url":"https://github.com/allenai/allennlp","homepage":"http://www.allennlp.org/","size":10991,"stargazers_count":1898,"watchers_count":1898,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":250,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":250,"open_issues":49,"watchers":1898,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/allenai/allennlp/pulls/1086"},"html":{"href":"https://github.com/allenai/allennlp/pull/1086"},"issue":{"href":"https://api.github.com/repos/allenai/allennlp/issues/1086"},"comments":{"href":"https://api.github.com/repos/allenai/allennlp/issues/1086/comments"},"review_comments":{"href":"https://api.github.com/repos/allenai/allennlp/pulls/1086/comments"},"review_comment":{"href":"https://api.github.com/repos/allenai/allennlp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/allenai/allennlp/pulls/1086/commits"},"statuses":{"href":"https://api.github.com/repos/allenai/allennlp/statuses/a0d83a14d59cfdfb6b8db99e385741c87d35fef8"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"schmmd"}}