Example #1
0
 def decode_output(self, output: Union[torch.Tensor, Dict[str,
                                                          torch.Tensor],
                                       Iterable[torch.Tensor], Any],
                   mask: torch.BoolTensor, batch: Dict[str, Any], decoder,
                   **kwargs) -> Union[Dict[str, Any], Any]:
     return TransformerNamedEntityRecognizer.decode_output(
         self, output, batch['mask'], batch, decoder)
Example #2
0
 def compute_loss(
         self, batch: Dict[str, Any],
         output: Union[torch.Tensor, Dict[str, torch.Tensor],
                       Iterable[torch.Tensor], Any], criterion
 ) -> Union[torch.FloatTensor, Dict[str, torch.FloatTensor]]:
     return TransformerNamedEntityRecognizer.compute_loss(
         self, criterion, output, batch['tag_id'], batch['mask'])
Example #3
0
 def update_metrics(self, batch: Dict[str, Any],
                    output: Union[torch.Tensor, Dict[str, torch.Tensor],
                                  Iterable[torch.Tensor], Any],
                    prediction: Dict[str, Any], metric: Union[MetricDict,
                                                              Metric]):
     return TransformerNamedEntityRecognizer.update_metrics(
         self, metric, output, batch['tag_id'], batch['mask'], batch,
         prediction)
Example #4
0
 def prediction_to_result(self, prediction: Dict[str, Any],
                          batch: Dict[str, Any]) -> Union[List, Dict]:
     return TransformerNamedEntityRecognizer.prediction_to_human(
         self, prediction, self.vocabs['tag'].idx_to_token, batch)
Example #5
0
 def input_is_flat(self, data) -> bool:
     return TransformerNamedEntityRecognizer.input_is_flat(self, data)
Example #6
0
 def build_metric(self, **kwargs):
     return TransformerNamedEntityRecognizer.build_metric(self, **kwargs)