espnet2.legacy.nets.beam_search.beam_search
Less than 1 minute
espnet2.legacy.nets.beam_search.beam_search
espnet2.legacy.nets.beam_search.beam_search(x: Tensor, sos: int, eos: int, beam_size: int, vocab_size: int, scorers: Dict[str, ScorerInterface], weights: Dict[str, float], token_list: List[str] = None, maxlenratio: float = 0.0, minlenratio: float = 0.0, pre_beam_ratio: float = 1.5, pre_beam_score_key: str = 'full') β list
Perform beam search with scorers.
- Parameters:
- x (torch.Tensor) β Encoded speech feature (T, D)
- sos (int) β Start of sequence id
- eos (int) β End of sequence id
- beam_size (int) β The number of hypotheses kept during search
- vocab_size (int) β The number of vocabulary
- scorers (dict *[*str , ScorerInterface ]) β Dict of decoder modules e.g., Decoder, CTCPrefixScorer, LM The scorer will be ignored if it is None
- weights (dict *[*str , float ]) β Dict of weights for each scorers The scorer will be ignored if its weight is 0
- token_list (list *[*str ]) β List of tokens for debug log
- maxlenratio (float) β Input length ratio to obtain max output length. If maxlenratio=0.0 (default), it uses a end-detect function to automatically find maximum hypothesis lengths
- minlenratio (float) β Input length ratio to obtain min output length.
- pre_beam_score_key (str) β key of scores to perform pre-beam search
- pre_beam_ratio (float) β beam size in the pre-beam search will be int(pre_beam_ratio * beam_size)
- Returns: N-best decoding results
- Return type: list
