espnet2.fst.lm_rescore.compute_am_scores_and_lm_scores
Less than 1 minute
espnet2.fst.lm_rescore.compute_am_scores_and_lm_scores
espnet2.fst.lm_rescore.compute_am_scores_and_lm_scores(lats: Fsa, word_fsas_with_epsilon_loops: Fsa, path_to_seq_map: Tensor, device: str = 'cuda', batch_size: int = 500) → Tuple[Tensor, Tensor]
Compute AM and LM scores of n-best lists (represented as word_fsas).
- Parameters:
- lats – An FsaVec, which is the output of k2.intersect_dense_pruned. It must have the attribute lm_scores.
- word_fsas_with_epsilon_loops – An FsaVec representing a n-best list. Note that it has been processed by k2.add_epsilon_self_loops.
- path_to_seq_map – A 1-D torch.Tensor with dtype torch.int32. path_to_seq_map[i] indicates which sequence the i-th Fsa in word_fsas_with_epsilon_loops belongs to. path_to_seq_map.numel() == word_fsas_with_epsilon_loops.arcs.dim0().
- batch_size – Batchify the n-best list when intersecting with inverted_lats. You could tune this to avoid GPU OOM issue or increase the GPU usage.
- Returns: Return a tuple of (1-D torch.Tensor, 1-D torch.Tensor) containing the AM and LM scores of each path. am_scores.numel() == word_fsas_with_epsilon_loops.shape[0] lm_scores.numel() == word_fsas_with_epsilon_loops.shape[0]
