Skip to content
DeepForgeby svx
All problems
HardNLPnlp-204

RNN-T Alignment Count

Problem

Return the number of monotonic RNN-T alignments between encoder_frames frames and target_tokens tokens: the binomial coefficient C(T + U, U).

Each alignment corresponds to a lattice path with T blank steps and U token steps. Negative inputs give 0.

Hint

Choose the positions of the token steps among all T + U steps.

Test cases

case 1
in: [2,1]
expected: 3
case 2
in: [3,2]
expected: 10
case 3
in: [0,0]
expected: 1
case 4
in: [0,2]
expected: 1
case 5
in: [4,0]
expected: 1
Starter codePython
import math
def rnnt_alignment_count(encoder_frames, target_tokens):
    # Your code here
    pass

5 test cases · run your code against them in the editor