SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Best-path-training selects the most probable path  $\hat{A} = (\hat{a}_1, \dots, \hat{a}_M)$  and takes the hidden states on path  $\hat{A}$  as input to the acoustic decoder. Formally, given the target phoneme sequence  $Y$ , we can find the most probable path  $\hat{A} = \arg \max_{A \in \Gamma} P_\theta(Y, A|X)$  via Viterbi algorithm [20]. Specifically, we use  $\delta_i(j)$  to denote the probability of the most probable path so far  $(\hat{a}_1, \dots, \hat{a}_i)$  with  $\hat{a}_i = j$  that generates  $(y_1, \dots, y_i)$ . Considering the definition of  $a_1 = 1$ , we have  $\delta_1(1) = \mathbf{P}_{1,y_1}$  and  $\delta_1(1 < j \leq L) = 0$ . For  $i > 1$ , we can sequentially calculate  $\delta_i(\cdot)$  from its previous step  $\delta_{i-1}(\cdot)$  due to the Markov property:
$$
\delta_ {i} (j) = \max  _ {k <   j} \left(\delta_ {i - 1} (k) \cdot \mathbf {E} _ {k, j} \cdot \mathbf {P} _ {j, y _ {i}}\right), \tag {16}
$$
$$
\phi_ {i} (j) = \underset {k <   j} {\arg \max } (\delta_ {i - 1} (k) \cdot \mathbf {E} _ {k, j} \cdot \mathbf {P} _ {j, y _ {i}}), \tag {17}
$$
where  $\phi_i(j)$  stores  $\hat{a}_{i-1}$  of the most probable path so far  $(\hat{a}_1, \dots, \hat{a}_{i-1}, \hat{a}_i = j)$ . After  $M$  iterations, we can obtain the most probable path by backtracking from  $\hat{a}_M = L$ :
$$
\hat {a} _ {i} = \phi_ {i + 1} (\hat {a} _ {i + 1}). \tag {18}
$$
Finally, we select the hidden states on the most probable path, i.e.,  $\mathbf{z}_i = \mathbf{v}_{\hat{a}_i}$ , as the input sequence of the acoustic decoder.