3b53962cd7a42d08bcc7c07f4f858b55bf9bbdad,fairseq/hub_utils.py,GeneratorHubInterface,score,#GeneratorHubInterface#Any#,124

Before Change



    def score(self, sentence: str, **kwargs):
        // NOTE: this doesn"t support translation tasks currently
        input = self.encode(sentence)
        return self.generate(input, score_reference=True, **kwargs)[0]

    def generate(self, tokens: torch.LongTensor, beam: int = 5, verbose: bool = False, **kwargs) -> torch.LongTensor:
        sample = self._build_sample(tokens)

After Change


        return [self.decode(hypos[0]["tokens"]) for hypos in batched_hypos]

    def score(self, sentences: List[str], **kwargs):
        if isinstance(sentences, str):
            return self.score([sentences], **kwargs)[0]
        // NOTE: this doesn"t support translation tasks currently
        tokenized_sentences = [self.encode(sentence) for sentence in sentences]
        return [hypos[0] for hypos in self.generate(tokenized_sentences, score_reference=True, **kwargs)]

    def generate(
        self,
        tokenized_sentences: List[torch.LongTensor],
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 21

Instances


Project Name: pytorch/fairseq
Commit Name: 3b53962cd7a42d08bcc7c07f4f858b55bf9bbdad
Time: 2019-12-25
Author: sai.r.prasanna@gmail.com
File Name: fairseq/hub_utils.py
Class Name: GeneratorHubInterface
Method Name: score


Project Name: elbayadm/attn2d
Commit Name: 3b53962cd7a42d08bcc7c07f4f858b55bf9bbdad
Time: 2019-12-25
Author: sai.r.prasanna@gmail.com
File Name: fairseq/hub_utils.py
Class Name: GeneratorHubInterface
Method Name: sample


Project Name: elbayadm/attn2d
Commit Name: 3b53962cd7a42d08bcc7c07f4f858b55bf9bbdad
Time: 2019-12-25
Author: sai.r.prasanna@gmail.com
File Name: fairseq/hub_utils.py
Class Name: GeneratorHubInterface
Method Name: score