paddlespeech.s2t.decoders.scorers.length_bonus 模块
长度奖励模块。
- class paddlespeech.s2t.decoders.scorers.length_bonus.LengthBonus(n_vocab: int)[来源]
-
束搜索中的长度奖励。
方法
batch_init_state(x)获取解码的初始状态(可选).
batch_score(ys, states, xs)评分新令牌批次。
final_score(state)得分 eos(可选)。
init_state(x)获取用于解码的初始状态(可选)。
score(y, state, x)评分新令牌。
select_state(state, i[, new_id])在主光束搜索中选择具有相对ID的状态。
- batch_score(ys: Tensor, states: List[Any], xs: Tensor) Tuple[Tensor, List[Any]][来源]
评分新令牌批处理。
- Args:
ys (paddle.Tensor): paddle.int64 前缀标记 (n_batch, ylen). states (List[Any]): 前缀标记的计分器状态。 xs (paddle.Tensor):
生成ys的编码器特征(n_batch,xlen,n_feat)。
- Returns:
- tuple[paddle.Tensor, List[Any]]: Tuple of
下一个标记的批处理分数,形状为(n_batch, n_vocab),以及 ys 的下一个状态列表。