## 3 Methods
### CTC Decoding  
CTC (connectionist temporal classification) decoding is a method for obtaining the most probable label sequence from the probability matrix output by a model [33; 34]. Unlike traditional alignment methods, CTC does not require manually design of the alignment between input X and output Y; it can automatically perform this alignment [35]. Given an input sequence X, CTC provides a probability distribution over all possible output sequences Y. From this distribution, we can compute the probability of a specific output. Its definition is as follows:  
\[p(y|x)=\sum_{z\in Z(y)}p(z|x) \tag{21}\]  
where \(y\) represents the target sequence, \(x\) is the input sequence, and \(Z(y)\) is the set of all possible label sequences (including the blank token). These label sequences correspond to the target sequence y during decoding.  
CTC decoding methods include greedy decoding and beam search decoding [36; 37]. Greedy decoding selects the most probable label at each time step and then removes consecutive duplicate labels. Mathematically, greedy decoding can be represented as follows:  
\[y_{t}=argmax(p(\cdot|x_{t})) \tag{22}\]  
where \(y_{t}\) is the predicted label at time step \(t\), and \(p(\cdot|x_{t})\) is the probability distribution over all possible labels at time step \(t\). Although simple and efficient, greedy decoding may not produce accurate results due to the presence of many blank and repeated tokens in the CTC output [37]. Beam search decoding is an extension of greedy decoding, where multiple hypotheses are considered at each time step. At each time step, the beam search algorithm evaluates all possible labels and computes a score for each label based on its log probability and the current state of the model. It then prunes away less-likely labels to maintain a fixed beam width. The scoring function for beam search is defined as:  
\[score(s)=\frac{logPrTotal(s)+\alpha\cdot logPrText(s)}{(len(s))^{\beta}} \tag{23}\]  
where \(logPrTotal(s)\) is the total log probability of sequence \(s\), and \(\alpha\) and \(\beta\) are hyperparameters that control the balance between the model's probability and the language model's probability. \(len(s)\) denotes the length of the sequence. The beam search algorithm continues until all time steps are processed and finally selects the most probable sequence as the output.  
We adopt beam search decoding with a width of 50. This approach maintains a limited set of candidate sequences, selecting the most-likely sequence expansions at each time step to achieve more-accurate decoding results. First, the log probability matrix output from the model is initialized by summing the probabilities of the gap markers and end-of-sentence markers. At each time step, a new beam state is created to store all possible predicted paths for the current expansion. The algorithm selects characters from the probability matrix whose probabilities exceed a threshold, reducing the computational load, and retains the best predicted paths from the previous time step, limiting their number within the beam width. For each best path, the algorithm calculates the log probabilities of duplicate and blank characters, expands each pruned character, calculates new log probabilities, and updates the beam state.  
During inference, a character-level language model is used to adjust the probability of new paths. The language model predicts one character at a time, using only the previous character as input. Once the current beam state is updated, the algorithm selects the final best-predicted path and appends the EOS marker. The language model, trained byAfouras et al. [31], consists of a recurrent network with four monolithic layers, each with 1024 LSTM units.  
Finally, the algorithm converts the optimal paths and lengths of all input sequences into a tensor and returns them. This process balances computational efficiency with decoding quality by retaining the best prediction paths at each time step and incorporating the language models to improve prediction accuracy.