espnet2.ps2st.qwen2_scorer.Qwen2HFScorer
Less than 1 minute
espnet2.ps2st.qwen2_scorer.Qwen2HFScorer
class espnet2.ps2st.qwen2_scorer.Qwen2HFScorer(model, input_ids, attention_mask, input_features=None, feature_attention_mask=None)
Bases: ScorerInterface
final_score(states)
Score eos (optional).
- Parameters:state – Scorer state for prefix tokens
- Returns: final score
- Return type: float
init_state(xs)
Get an initial state for decoding (optional).
- Parameters:x (torch.Tensor) – The encoded feature tensor
Returns: initial state
score(ys, state, xs)
Forward scoring function.
ys: 1D LongTensor of generated tokens so far state: dict with ‘past_kv’ and ‘step’
select_state(states, idx)
Select state with relative ids in the main beam search.
- Parameters:
- state – Decoder state for prefix tokens
- i (int) – Index to select a state in the main beam search
- new_id (int) – New label index to select a state if necessary
- Returns: pruned state
- Return type: state