3b53962cd7a42d08bcc7c07f4f858b55bf9bbdad,fairseq/hub_utils.py,GeneratorHubInterface,sample,#GeneratorHubInterface#Any#Any#Any#,119
Before Change
return self.sample(sentence, beam, verbose, **kwargs)
def sample(self, sentence: str, beam: int = 1, verbose: bool = False, **kwargs) -> str:
input = self.encode(sentence)
hypo = self.generate(input, beam, verbose, **kwargs)[0]["tokens"]
return self.decode(hypo)
def score(self, sentence: str, **kwargs):
// NOTE: this doesn"t support translation tasks currently
input = self.encode(sentence)
After Change
return self.sample(sentences, beam, verbose, **kwargs)
def sample(self, sentences: List[str], beam: int = 1, verbose: bool = False, **kwargs) -> List[str]:
if isinstance(sentences, str):
return self.sample([sentences], beam=beam, verbose=verbose, **kwargs)[0]
tokenized_sentences = [self.encode(sentence) for sentence in sentences]
batched_hypos = self.generate(tokenized_sentences, beam, verbose, **kwargs)
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]
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: 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: sample
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