espnet.nets.scorer_interface.PartialScorerInterface
Less than 1 minute
espnet.nets.scorer_interface.PartialScorerInterface
class espnet.nets.scorer_interface.PartialScorerInterface
Bases: ScorerInterface
Partial scorer interface for beam search.
The partial scorer performs scoring when non-partial scorer finished scoring, and receives pre-pruned next tokens to score because it is too heavy to score all the tokens.
Examples
- Prefix search for connectionist-temporal-classification models : *
espnet.nets.scorers.ctc.CTCPrefixScorer
score_partial(y: Tensor, next_tokens: Tensor, state: Any, x: Tensor) → Tuple[Tensor, Any]
Score new token (required).
- Parameters:
- y (torch.Tensor) – 1D prefix token
- next_tokens (torch.Tensor) – torch.int64 next token to score
- state – decoder state for prefix tokens
- x (torch.Tensor) – The encoder feature that generates ys
- Returns: Tuple of a score tensor for y that has a shape (len(next_tokens),) and next state for ys
- Return type: tuple[torch.Tensor, Any]