pytext.models.qna package

Submodules

pytext.models.qna.bert_squad_qa module

class pytext.models.qna.bert_squad_qa.BertSquadQAModel(encoder: torch.nn.modules.module.Module, decoder: torch.nn.modules.module.Module, has_ans_decoder: torch.nn.modules.module.Module, output_layer: torch.nn.modules.module.Module, stage: pytext.common.constants.Stage = <Stage.TRAIN: 'Training'>, is_kd: bool = False)[source]

Bases: pytext.models.bert_classification_models.NewBertModel

arrange_model_inputs(tensor_dict)[source]
arrange_targets(tensor_dict)[source]
forward(*inputs)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

classmethod from_config(config: pytext.models.qna.bert_squad_qa.BertSquadQAModel.Config, tensorizers)[source]

pytext.models.qna.dr_qa module

class pytext.models.qna.dr_qa.DrQAModel(dropout: torch.nn.modules.module.Module, embedding: torch.nn.modules.module.Module, ques_rnn: torch.nn.modules.module.Module, doc_rnn: torch.nn.modules.module.Module, ques_self_attn: torch.nn.modules.module.Module, ques_aligned_doc_attn: torch.nn.modules.module.Module, start_attn: torch.nn.modules.module.Module, end_attn: torch.nn.modules.module.Module, doc_rep_pool: torch.nn.modules.module.Module, has_ans_decoder: torch.nn.modules.module.Module, output_layer: torch.nn.modules.module.Module, is_kd: bool = False)[source]

Bases: pytext.models.model.BaseModel

arrange_model_inputs(tensor_dict)[source]
arrange_targets(tensor_dict)[source]
classmethod create_embedding(model_config: pytext.models.qna.dr_qa.DrQAModel.Config, tensorizers: Dict[str, pytext.data.tensorizers.Tensorizer])[source]
forward(doc_tokens: torch.Tensor, doc_seq_len: torch.Tensor, doc_mask: torch.Tensor, ques_tokens: torch.Tensor, ques_seq_len: torch.Tensor, ques_mask: torch.Tensor) → Tuple[torch.Tensor, torch.Tensor, torch.Tensor][source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

classmethod from_config(config: pytext.models.qna.dr_qa.DrQAModel.Config, tensorizers: Dict[str, pytext.data.tensorizers.Tensorizer])[source]

Module contents