MCPcopy Create free account
hub / github.com/FLC777/GLAT / __init__

Method __init__

fairseq/sequence_generator.py:863–882  ·  view source on GitHub ↗

Generates translations of a given source sentence. Produces alignments following "Jointly Learning to Align and Translate with Transformer Models" (Garg et al., EMNLP 2019). Args: left_pad_target (bool, optional): Whether or not the hypothesis sh

(
        self, models, tgt_dict, left_pad_target=False, print_alignment="hard", **kwargs
    )

Source from the content-addressed store, hash-verified

861
862class SequenceGeneratorWithAlignment(SequenceGenerator):
863 def __init__(
864 self, models, tgt_dict, left_pad_target=False, print_alignment="hard", **kwargs
865 ):
866 """Generates translations of a given source sentence.
867
868 Produces alignments following "Jointly Learning to Align and
869 Translate with Transformer Models" (Garg et al., EMNLP 2019).
870
871 Args:
872 left_pad_target (bool, optional): Whether or not the
873 hypothesis should be left padded or not when they are
874 teacher forced for generating alignments.
875 """
876 super().__init__(EnsembleModelWithAlignment(models), tgt_dict, **kwargs)
877 self.left_pad_target = left_pad_target
878
879 if print_alignment == "hard":
880 self.extract_alignment = utils.extract_hard_alignment
881 elif print_alignment == "soft":
882 self.extract_alignment = utils.extract_soft_alignment
883
884 @torch.no_grad()
885 def generate(self, models, sample, **kwargs):

Callers

nothing calls this directly

Calls 2

__init__Method · 0.45

Tested by

no test coverage detected