class_docstr: A ``WikiTablesMmlSemanticParser`` is a :class:`WikiTablesSemanticParser` which is trained to
  maximize the marginal likelihood of an approximate set of logical forms which give the correct
  denotation. This is a re-implementation of the model used for the paper `Neural Semantic Parsing with Type
  Constraints for Semi-Structured Tables
  <https://www.semanticscholar.org/paper/Neural-Semantic-Parsing-with-Type-Constraints-for-Krishnamurthy-Dasigi/8c6f58ed0ebf379858c0bbe02c53ee51b3eb398a>`_,
  by Jayant Krishnamurthy, Pradeep Dasigi, and Matt Gardner (EMNLP 2017).
  
  WORK STILL IN PROGRESS.  We'll iteratively improve it until we've reproduced the performance of
  the original parser.
  
  Parameters
  ----------
  vocab : ``Vocabulary``
  question_embedder : ``TextFieldEmbedder``
      Embedder for questions. Passed to super class.
  action_embedding_dim : ``int``
      Dimension to use for action embeddings. Passed to super class.
  encoder : ``Seq2SeqEncoder``
      The encoder to use for the input question. Passed to super class.
  entity_encoder : ``Seq2VecEncoder``
      The encoder to used for averaging the words of an entity. Passed to super class.
  decoder_beam_search : ``BeamSearch``
      When we're not training, this is how we will do decoding.
  max_decoding_steps : ``int``
      When we're decoding with a beam search, what's the maximum number of steps we should take?
      This only applies at evaluation time, not during training. Passed to super class.
  attention : ``Attention``
      We compute an attention over the input question at each step of the decoder, using the
      decoder hidden state as the query.  Passed to WikiTablesDecoderStep.
  training_beam_size : ``int``, optional (default=None)
      If given, we will use a constrained beam search of this size during training, so that we
      use only the top ``training_beam_size`` action sequences according to the model in the MML
      computation.  If this is ``None``, we will use all of the provided action sequences in the
      MML computation.
  use_neighbor_similarity_for_linking : ``bool``, optional (default=False)
      If ``True``, we will compute a max similarity between a question token and the `neighbors`
      of an entity as a component of the linking scores.  This is meant to capture the same kind
      of information as the ``related_column`` feature. Passed to super class.
  dropout : ``float``, optional (default=0)
      If greater than 0, we will apply dropout with this probability after all encoders (pytorch
      LSTMs do not apply dropout to their last layer). Passed to super class.
  num_linking_features : ``int``, optional (default=10)
      We need to construct a parameter vector for the linking features, so we need to know how
      many there are.  The default of 10 here matches the default in the ``KnowledgeGraphField``,
      which is to use all ten defined features. If this is 0, another term will be added to the
      linking score. This term contains the maximum similarity value from the entity's neighbors
      and the question. Passed to super class.
  rule_namespace : ``str``, optional (default=rule_labels)
      The vocabulary namespace to use for production rules.  The default corresponds to the
      default used in the dataset reader, so you likely don't need to modify this. Passed to super
      class.
  tables_directory : ``str``, optional (default=/wikitables/)
      The directory to find tables when evaluating logical forms.  We rely on a call to SEMPRE to
      evaluate logical forms, and SEMPRE needs to read the table from disk itself.  This tells
      SEMPRE where to find the tables. Passed to super class.
class_docstr_tok: ["A","``","WikiTablesMmlSemanticParser","``","is","a",":","class",":","`","WikiTablesSemanticParser","`","which","is","trained","to","maximize","the","marginal","likelihood","of","an","approximate","set","of","logical","forms","which","give","the","correct","denotation",".","This","is","a","re-implementation","of","the","model","used","for","the","paper","`","Neural","Semantic","Parsing","with","Type","Constraints","for","Semi-Structured","Tables","<","https",":","\/\/www.semanticscholar.org\/paper\/Neural-Semantic-Parsing-with-Type-Constraints-for-Krishnamurthy-Dasigi\/8c6f58ed0ebf379858c0bbe02c53ee51b3eb398a",">","`","_",",","by","Jayant","Krishnamurthy",",","Pradeep","Dasigi",",","and","Matt","Gardner","(","EMNLP","2017",")",".","WORK","STILL","IN","PROGRESS",".","We","'ll","iteratively","improve","it","until","we","'ve","reproduced","the","performance","of","the","original","parser",".","Parameters","--","--","--","--","--","vocab",":","``","Vocabulary","``","question_embedder",":","``","TextFieldEmbedder","``","Embedder","for","questions",".","Passed","to","super","class",".","action_embedding_dim",":","``","int","``","Dimension","to","use","for","action","embeddings",".","Passed","to","super","class",".","encoder",":","``","Seq2SeqEncoder","``","The","encoder","to","use","for","the","input","question",".","Passed","to","super","class",".","entity_encoder",":","``","Seq2VecEncoder","``","The","encoder","to","used","for","averaging","the","words","of","an","entity",".","Passed","to","super","class",".","decoder_beam_search",":","``","BeamSearch","``","When","we","'re","not","training",",","this","is","how","we","will","do","decoding",".","max_decoding_steps",":","``","int","``","When","we","'re","decoding","with","a","beam","search",",","what","'s","the","maximum","number","of","steps","we","should","take","?","This","only","applies","at","evaluation","time",",","not","during","training",".","Passed","to","super","class",".","attention",":","``","Attention","``","We","compute","an","attention","over","the","input","question","at","each","step","of","the","decoder",",","using","the","decoder","hidden","state","as","the","query",".","Passed","to","WikiTablesDecoderStep",".","training_beam_size",":","``","int","``",",","optional","(","default=None",")","If","given",",","we","will","use","a","constrained","beam","search","of","this","size","during","training",",","so","that","we","use","only","the","top","``","training_beam_size","``","action","sequences","according","to","the","model","in","the","MML","computation",".","If","this","is","``","None","``",",","we","will","use","all","of","the","provided","action","sequences","in","the","MML","computation",".","use_neighbor_similarity_for_linking",":","``","bool","``",",","optional","(","default=False",")","If","``","True","``",",","we","will","compute","a","max","similarity","between","a","question","token","and","the","`","neighbors","`","of","an","entity","as","a","component","of","the","linking","scores",".","This","is","meant","to","capture","the","same","kind","of","information","as","the","``","related_column","``","feature",".","Passed","to","super","class",".","dropout",":","``","float","``",",","optional","(","default=0",")","If","greater","than","0",",","we","will","apply","dropout","with","this","probability","after","all","encoders","(","pytorch","LSTMs","do","not","apply","dropout","to","their","last","layer",")",".","Passed","to","super","class",".","num_linking_features",":","``","int","``",",","optional","(","default=10",")","We","need","to","construct","a","parameter","vector","for","the","linking","features",",","so","we","need","to","know","how","many","there","are",".","The","default","of","10","here","matches","the","default","in","the","``","KnowledgeGraphField","``",",","which","is","to","use","all","ten","defined","features",".","If","this","is","0",",","another","term","will","be","added","to","the","linking","score",".","This","term","contains","the","maximum","similarity","value","from","the","entity","'s","neighbors","and","the","question",".","Passed","to","super","class",".","rule_namespace",":","``","str","``",",","optional","(","default=rule_labels",")","The","vocabulary","namespace","to","use","for","production","rules",".","The","default","corresponds","to","the","default","used","in","the","dataset","reader",",","so","you","likely","do","n't","need","to","modify","this",".","Passed","to","super","class",".","tables_directory",":","``","str","``",",","optional","(","default=\/wikitables\/",")","The","directory","to","find","tables","when","evaluating","logical","forms",".","We","rely","on","a","call","to","SEMPRE","to","evaluate","logical","forms",",","and","SEMPRE","needs","to","read","the","table","from","disk","itself",".","This","tells","SEMPRE","where","to","find","the","tables",".","Passed","to","super","class","."]
code: def __init__(
      self,
      vocab,
      question_embedder,
      action_embedding_dim,
      encoder,
      entity_encoder,
      decoder_beam_search,
      max_decoding_steps,
      attention,
      mixture_feedforward=None,
      training_beam_size=None,
      use_neighbor_similarity_for_linking=False,
      dropout=0.0,
      num_linking_features=10,
      rule_namespace="rule_labels",
      tables_directory="/wikitables/",
  ):
      use_similarity = use_neighbor_similarity_for_linking
      super(WikiTablesMmlSemanticParser, self).__init__(
          vocab=vocab,
          question_embedder=question_embedder,
          action_embedding_dim=action_embedding_dim,
          encoder=encoder,
          entity_encoder=entity_encoder,
          max_decoding_steps=max_decoding_steps,
          use_neighbor_similarity_for_linking=use_similarity,
          dropout=dropout,
          num_linking_features=num_linking_features,
          rule_namespace=rule_namespace,
          tables_directory=tables_directory,
      )
      self._beam_search = decoder_beam_search
      self._decoder_trainer = MaximumMarginalLikelihood(
          training_beam_size
      )
      self._decoder_step = WikiTablesDecoderStep(
          encoder_output_dim=self._encoder.get_output_dim(),
          action_embedding_dim=action_embedding_dim,
          input_attention=attention,
          num_start_types=self._num_start_types,
          num_entity_types=self._num_entity_types,
          mixture_feedforward=mixture_feedforward,
          dropout=dropout,
      )
  
file_path: magnitude/pymagnitude/third_party/allennlp/models/semantic_parsing/wikitables/wikitables_mml_semantic_parser.py
imports: from __future__ import absolute_import
  import torch
  from allennlp.data import Vocabulary
  from allennlp.data.fields.production_rule_field import ProductionRuleArray
  from allennlp.models.model import Model
  from allennlp.models.semantic_parsing.wikitables.wikitables_decoder_step import WikiTablesDecoderStep
  from allennlp.models.semantic_parsing.wikitables.wikitables_semantic_parser import WikiTablesSemanticParser
  from allennlp.modules import Attention, FeedForward, Seq2SeqEncoder, Seq2VecEncoder, TextFieldEmbedder
  from allennlp.nn.decoding import BeamSearch
  from allennlp.nn.decoding.decoder_trainers import MaximumMarginalLikelihood
  from allennlp.semparse.worlds import WikiTablesWorld
  from allennlp.semparse import ParsingError
label_desc: Use image node_id 1 to create a new WikiTablesMmlSemanticParser object from inherited base classes: WikiTablesSemanticParser with example: obj = WikiTablesMmlSemanticParser(vocab, question_embedder, action_embedding_dim, encoder, entity_encoder, decoder_beam_search, max_decoding_steps, attention, mixture_feedforward, training_beam_size, use_neighbor_similarity_for_linking, dropout, num_linking_features, rule_namespace, tables_directory)