SlowGuess/ACL_2020_OCR huggingface dataset:
Chengyi Wang $^{1}$ , Yu Wu $^{2}$ , Shujie Liu $^{2}$ , Ming Zhou $^{2}$ , Zhenglu Yang $^{1}$
$^{1}$ Nankai University, Tianjin, China
<sup>2</sup>Microsoft Research Asia, Beijing, China
cywang@mail.nankai.edu.cn, Wu.Yu@microsoft.com,
shujliu@microsoft.com, mingzhou@microsoft.com, yangzl@nankai.edu.cn
End-to-end speech translation poses a heavy burden on the encoder because it has to transcribe, understand, and learn cross-lingual semantics simultaneously. To obtain a powerful encoder, traditional methods pre-train it on ASR data to capture speech features. However, we argue that pre-training the encoder only through simple speech recognition is not enough, and high-level linguistic knowledge should be considered. Inspired by this, we propose a curriculum pre-training method that includes an elementary course for transcription learning and two advanced courses for understanding the utterance and mapping words in two languages. The difficulty of these courses is gradually increasing. Experiments show that our curriculum pre-training method leads to significant improvements on En-De and En-Fr speech translation benchmarks.
Speech-to-Text translation (ST) is essential to breaking the language barrier for communication. It aims to translate a segment of source language speech to the target language text. To perform this task, prior works either employ a cascaded method, where an automatic speech recognition (ASR) model and a machine translation (MT) model are chained together, or an end-to-end approach, where a single model converts the source language audio sequence to the target language text sequence directly (Berard et al., 2016).
Due to the alleviation of error propagation and lower latency, the end-to-end ST model has been a hot topic in recent years. However, large paired data of source audios and target sentences are required to train such a model, which is not easy to satisfy for most language pairs. To address this
(a) previous encoder pre-training
(b) curriculum encoder pre-training
Figure 1: Comparison between previous encoder pre-training method with our curriculum pre-training method.
issue, previous works resort to pre-training technique (Berard et al., 2018; Bansal et al., 2019), where they leverage the available ASR and MT data to pre-train an ASR model and an MT model respectively, and then initialize the ST model with the ASR encoder and the MT decoder. This strategy can bring faster convergence and better results.
The end-to-end ST encoder has three essential roles: transcribe the speech, extract the syntactic and semantic knowledge of the source sentence and then map it to a semantic space, based on which the decoder can generate the correct target sentence. These pose a heavy burden to the encoder, which can be alleviated by pre-training. However, we argue that the current pre-training method restricts the power of pre-trained representations. The encoder pre-trained on the ASR task mainly
*Works are done during internship at Microsoft
Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 3728-3738 July 5 - 10, 2020. ©2020 Association for Computational Linguistics
focuses on transcription, which learns the alignment between the acoustic feature with phonemes or words. It cannot capture linguistic knowledge or understand the semantics, which is essential for translation.
In order to teach the model to understand the sentence and incorporate the required knowledge, extra courses should be taken before learning translation. Motivated by this, we propose a curriculum pre-training method for end-to-end ST. As shown in Figure 1, we first teach the model transcription through ASR task. After that, we design two tasks, named frame-based masked language model (FMLM) task and frame-based bilingual lexicon translation (FBLT) task, to enable the encoder to understand the meaning of a sentence and map words in different languages. Finally, we fine-tune the model on ST data to obtain the translation ability.
For the FMLM task, we mask several segments of the input speech feature, each of which corresponds to a complete word. Then we let the encoder predict the masked word. This task aims to force the encoder to recognize the content of the utterance and understand the inner meaning of the sentence. In FBLT, for each speech segment that aligns with a complete word, whether or not it is masked, we ask the encoder to predict the corresponding target word. In this task, we give the model more explicit and strong cross-lingual training signals. Thus, the encoder has the ability to perform simple word translation, and the burden on the ST decoder is largely reduced. Besides, we adopt a hierarchical manner where different layers are guided to perform different tasks (first 8 layers for ASR and FMLM pre-training, and another 4 layers for FBLT pre-training). This is mainly because the three pre-training tasks have different requirements for language understanding and different output spaces. The hierarchical pre-training method can make the division of labor more clear and separate the incorporation of source semantic knowledge and cross-lingual alignments.
We conduct experiments on the LibriSpeech En-Fr and IWSLT18 En-De speech translation tasks, demonstrating the effectiveness of our pre-training method. The contributions of our paper are as follows: (1) We propose a novel curriculum pretraining method with three courses: transcription, understanding and mapping, forcing the encoder to have the ability to generate necessary features
for the decoder. (2) We propose two new tasks to learn linguistic features, FMLM and FBLT, which explicitly teach the encoder to do source language understanding and target language meaning mapping. (3) Experiments show that both the proposed courses are helpful for speech translation, and our proposed curriculum pre-training leads to significant improvements.
2.1 Speech Translation
Early work on speech translation used a cascade of an ASR model and an MT model (Ney, 1999; Matusov et al., 2005; Mathias and Byrne, 2006), which makes the MT model access to ASR errors. Recent successes of end-to-end models in the MT field (Bahdanau et al., 2015; Luong et al., 2015; Vaswani et al., 2017) and the ASR fields (Chan et al., 2016; Chiu et al., 2018) inspired the research on end-to-end speech-to-text translation system, which avoids error propagation and high latency issues.
In this research line, Berard et al. (2016) give the first proof of the potential for an end-to-end ST model. After that, pre-training, multitask learning, attention-passing and knowledge distillation have been applied to improve the ST performance (Anastasopoulos et al., 2016; Duong et al., 2016; Berard et al., 2018; Weiss et al., 2017; Bansal et al., 2018, 2019; Sperber et al., 2019; Liu et al., 2019; Jia et al., 2019). However, none of them attempt to guide the encoder to learn linguistic knowledge explicitly. Recently, Wang et al. (2019b) propose to stack an ASR encoder and an MT encoder as a new ST encoder, which incorporates acoustic and linguistic knowledge respectively. However, the gap between these two encoders is hard to bridge by simply concatenating the encoders. Kano et al. (2017) propose structured-based curriculum learning for English-Japanese speech translation, where they use a new decoder to replace the ASR decoder and to learn the output from the MT decoder (fast track) or encoder (slow track). They formalize learning strategies from easier networks to more difficult network structures. In contrast, we focus on curriculum learning in pre-training and increase the difficulty of pre-training tasks.
2.2 Curriculum Learning
Curriculum learning is a learning paradigm that starts from simple patterns and gradually increases
Figure 2: Proposed curriculum pre-training process.  $\mathcal{L}_{FMLM}$  only predicts the mask word, while  $\mathcal{L}_{FBLT}$  predicts all words in the target language.
to more complex patterns. This idea is inspired by the human learning process and is first applied in the context of machine learning by Bengio et al. (2009). The study shows that this training approach results in better generalization and speeds up the convergence. Its effectiveness has been verified in multiple tasks, including shape recognition (Bengio et al., 2009), object classification (Gong et al., 2016), question answering (Graves et al., 2017), etc. However, most studies focus on how to control the difficulty of the training samples and organize the order of the learning data in the context of single-task learning.
Our method differs from previous works in two ways: (1) We leverage the idea of curriculum learning for pre-training. (2) We do not train the model on the ST task directly with more and more difficult training examples or use more and more complicated structures. Instead, we design a series of tasks with increased difficulty to teach the encoder to incorporate diverse knowledge.
The overview of our training process is shown in Figure 2. It can be divided into three steps: First, we train the model towards the ASR objective  $L_{ASR}$  to learn transcription. We note this as the elementary course. Next, we design two advanced courses (tasks) to teach the model understanding a sentence and mapping words in two languages, named Frame-based Masked Language Model (FMLM) task and Frame-based Bilingual
Lexicon Translation (FBLT) task. In the FMLM task, we mask some speech segments and ask the encoder to predict the masked words. In the FBLT task, we ask the encoder to predict the target word for each speech segment which corresponds to a complete source word. In this stage, the encoder is updated by  $L_{ADV}$ . We adopt a hierarchical training manner where  $N$  encoder blocks are used to perform ASR and FMLM tasks as they both require outputs in source word space, and  $N_e$  blocks are used in the FBLT task. After the two-phases pretraining, the encoder is finally combined with a new decoder or a pre-trained MT decoder to perform the ST task towards  $L_{ST}$ .
Problem Formulation The speech translation corpus usually contains speech-transcription-translation triples, denoted as  $\mathcal{S} = \{(x,y^s,y^t)\}$ . Specially,  $\pmb{x} = (x_{1},\dots ,x_{T_{x}})$  is a sequence of acoustic features which are extracted from the speech signals.  $\pmb{y}^{s} = (y_{1}^{s},\dots ,y_{Ts}^{s})$  and  $\pmb{y}^{t} = (y_{1}^{t},\dots ,y_{T_{t}}^{t})$  represent the corresponding transcription in source language and the translation in target language respectively. To pre-train the encoder, an extra ASR dataset  $\mathcal{A} = \{(x,y^s)\}$  can be leveraged. Finally, the data for encoder pre-training is denoted as  $\{(x,y^s)|(x,y^s)\in \mathcal{A}\lor$ $(x,y^{s},y^{t})\in S\}$
After the encoder is pre-trained, we fine-tune the model using only  $S$ , to enable it generate  $\pmb{y}^t$  from  $\pmb{x}$  directly. The model is updated using cross-entropy loss  $\mathcal{L}_{ST} = -\log P(\pmb{y}^t|\pmb{x})$ .
Model Architecture In this work, we adopt the architecture of Transformer as in (Karita et al.,
2019). The encoder is a stack of two  $3 \times 3$  2D CNN layers with stride 2 and  $N_{e}$  Transformer encoder blocks. The CNN layers result in downsampling by a factor of 4. The decoder is a stack of  $N_{d}$  Transformer decoder blocks.
3.2 Elementary Course: Transcription
In the elementary course, we train an end-to-end ASR model, which has similar architecture as the ST model. The ASR encoder consists of  $N$  blocks, and these blocks are used to initialize the bottom  $N$  blocks of the ST encoder. For the ASR task, we follow Karita et al. (2019), to employ a multitask learning strategy, that is, both the E2E decoder and a CTC module predict the source sentence. Offline experiments indicate that the CTC objective is crucial for attentional encoder-decoder based ASR models. The final objective combines the CTC loss  $\mathcal{L}_{ctc}$  and the cross-entropy loss  $\mathcal{L}_{CE}$ :
$$
\begin{array}{l} \mathcal {L} _ {A S R} = \alpha \mathcal {L} _ {C T C} + (1 - \alpha) \mathcal {L} _ {C E} \\ = - \alpha \log P _ {c t c} (\boldsymbol {y} ^ {\boldsymbol {s}} | \boldsymbol {x}) - (1 - \alpha) \log P _ {s 2 s} (\boldsymbol {y} ^ {\boldsymbol {s}} | \boldsymbol {x}) \tag {1} \\ \end{array}
$$
In this work, we set  $\alpha$  to 0.3. The CTC loss works on the encoder output and it pushes the encoder to learn frame-wise alignment between speech with words.
3.3 Advanced Courses: Understanding and Word Mapping
With the ability of transcription, we further propose two new tasks for the advanced courses.
3.3.1 Frame-based Masked Language Model
The design of the Frame-based Masked Language Model task is inspired by the Masked Language Model (MLM) objective of BERT (Devlin et al., 2019) and semantic mask for ASR task (Wang et al., 2019a). This task enables the encoder to understand the inner meaning of a segment of speech.
As shown in Figure 2, we first perform forcealignment between the speech and the transcript- sentence to determine where in time particular words occur in the speech segment. For each word  $y_{i}^{s}$ , we obtain its corresponding start position  $s_i$  and the end position  $e_i$  in the sequence  $x$  according to force alignment results. At each training iteration, we randomly sample some percentage of the words in the  $y^{s}$  and denote the selected word set as  $\tilde{y}^s$ . Next, for each selected token  $y_j^s$  in  $\tilde{y}^s$ , we mask the corresponding speech piece  $[x_{s_j}:x_{e_j}]$ . The masked utterance is denoted as  $\tilde{x}$  and used as input
to the encoder:
$$
\boldsymbol {h} = \operatorname {E n c} (\tilde {\boldsymbol {x}}) \tag {2}
$$
After that, for a masked piece  $[x_{s_j}:x_{e_j}]$ , we average the corresponding output hidden states  $[h_{\lfloor \frac{s_j}{4}\rfloor}:h_{\lceil \frac{e_j}{4}\rceil}]^1$ , and compute the distribution probability over source words as shown in follows:
$$
\tilde {h} _ {j} = \operatorname {m e a n} \left(\left[ h _ {\lfloor \frac {s _ {j}}{4} \rfloor}: h _ {\lceil \frac {e _ {j}}{4} \rceil} \right]\right) \tag {3}
$$
$$
p \left(y _ {j} ^ {\mathrm {s}} \mid \tilde {\boldsymbol {x}}\right) = \operatorname {s o f t m a x} \left(\tilde {h} _ {j} \cdot W\right) \tag {4}
$$
In practice, the sentence is represented in BPE tokens and  $W \in \mathcal{R}^{d_{model} \times |V_s|}$ , where  $|V_s|$  is the size of source vocabulary. In this way, a speech piece can be aligned with one or more tokens. We compute KL-Divergence loss as:
$$
\mathcal {L} _ {F M L M} = - \sum_ {y _ {j} ^ {s} \in \tilde {\boldsymbol {y}} ^ {s}} \sum q \left(y _ {j} ^ {s}\right) \log \frac {p \left(y _ {j} ^ {s} \mid \tilde {\boldsymbol {x}}\right)}{q \left(y _ {j} ^ {s}\right)} \tag {5}
$$
$q(y_{i}^{s})\in \mathcal{R}^{|V_{s}|}$  is a distribution over all BPE tokens in source vocabulary  $V_{s}$  and defined as:
$$
q \left(y _ {j} ^ {s}\right) _ {(p o s)} = \left\{ \begin{array}{l l} 1 / n _ {j}, & V _ {s} [ p o s ] \in y _ {j} ^ {s} \\ 0, & \text {o t h e r w i s e .} \end{array} \right. \tag {6}
$$
where  $pos$  represents the dimension index and  $n_j$  is the total number of BPE tokens contained in word  $y_{j}^{s}$ .
In this work, we use a mask ratio of  $15\%$  following BERT and the masked speech piece is filled with the mean value of the whole utterance following Park et al. (2019). Because FMLM focuses on the understanding of source language, we computes its loss at the  $N$ -th layer of encoder (same with ASR loss), in the hope that the bottom  $N$  layers are only concerned with source language.
3.3.2 Frame-based Bilingual Lexicon Translation
Aside from predicting masked source words, we go further to leverage cross-lingual information. Specifically, for each segment of speech features  $[x_{s_i}:x_{e_i}]$  which aligned with a source word  $y_{i}^{s}$ , we assume we can obtain its target counterpart  $\tilde{y}_i^t$ . Similar to FMLM, we average the output hidden states from position  $\left\lfloor \frac{s_i}{4}\right\rfloor$  to  $\left\lceil \frac{e_i}{4}\right\rceil$ , and then compute the distribution probability over target vocabulary. The alignment between speech segments and target
1The position indexes are divided by 4 due to downsampling.
words is a many-to-many correspondence, so there are cases where  $\tilde{y}_i^t$  contains nothing or contains multiple foreign words. For the former case, we set the loss to zero, and for the latter case, we also compute KL-Divergence loss as:
$$
\mathcal {L} _ {F B L T} = - \sum_ {\tilde {y} _ {i} ^ {t}} \sum q (\tilde {y} _ {i} ^ {t}) \log \frac {p (\tilde {y} _ {i} ^ {t} | \tilde {\boldsymbol {x}})}{q (\tilde {y} _ {i} ^ {t})} \tag {7}
$$
The definition of  $q(\tilde{y}_i^t)$  is the length normalized distribution over all tokens appear in  $\tilde{y}_i^t$ . Note that the loss is computed on every speech segments, whether or not it is masked.
The only question remaining is how to obtain  $\tilde{y}_i^t$  for each speech segment. Since there are two types of data for pre-training,  $(\pmb{x},\pmb{y}^{s},\pmb{y}^{t})\in S$  and  $(\pmb {x},\pmb{y}^{s})\in \mathcal{A}$ , we use two methods to get the alignment:
For training examples  $(\pmb{x},\pmb{y}^s,\pmb{y}^t)\in S$  , we use reference-supervised method. In particular, we simply run Moses2 scripts to establish word alignments. It begins from running of GIZA++3 to get source-to-target and target-to-source alignments, and then runs a heuristic grow-diag-final algorithm to get the final results, which means  $\forall y_i^s\in \mathbf{y}^s$  , we choose one word from its translation sentence as the corresponding word  $\exists \tilde{y}_i^t\in \pmb {y}^t$  s.t.  $\tilde{y}_i^t\sim \pmb {y}^s$
For training examples  $(\pmb{x},\pmb{y}^s)\in \mathcal{A}$  we apply dictionary-supervised method. Through the above alignment process, we can calculate a bilingual lexical translation table  $\mathcal{T}$  with  $\{(y^{s},y^{t})|(x,y^{s},y^{t})\in S\}$ , which estimates the translation probability between a source word  $w_{i}^{s}$  and a target word  $w_{j}^{t}$ , denoted as  $\mathcal{T} = (w_i^s,w_j^t,p(w_i^s,w_j^t))$ . After that, we compute a  $\tilde{y}_i^t$  for each  $y_{i}^{s}$  in  $\pmb{y}^{s}$  according to  $\tilde{y}_i^t = \mathrm{argmax}_{w_i^s}p(y_i^s,w_j^s)$ .
We compute the  $\mathcal{L}_{FBLT}$  at the top layer of the encoder, indicating that the top  $N_{e} - N$  layers are duty on bilingual word mapping. The final training objective in the advanced course combines FMLM and FBLT losses
$$
\mathcal {L} _ {A D V} = \mathcal {L} _ {F M L M} + \mathcal {L} _ {F B L T} \tag {8}
$$
4.1 Data and Preprocess
We conduct experiments on two publicly available speech translation datasets: the LibriSpeech En-Fr
Corpus (Kocabiyikoglu et al., 2018) and the IWSLT En-De Corpus (Niehues et al., 2018).
LibriSpeech En-Fr: This corpus is a subset of the LibriSpeech ASR corpus (Panayotov et al., 2015) and aligned with French e-books, which contains 236 hours of speech in total. Following previous works, we use the 100 hours clean training set and double the ST size by concatenating the aligned references with the provided Google Translate references, resulting in 90k training instances. We validate on the dev set and report results on the test set (2048 utterances).
IWSLT En-De: The corpus contains 271 hours of data, with English wave, English transcription, and German translation in each example. We follow Inaguma et al. (2019) to remove utterances of low alignment quality, resulting in 137k utterances. We sample 2k segments from the ST-TED corpus as dev set and  $tst2013$  is used as the test set (993 utterances).
Data Preprocessing: We run ESPnet $^4$  (Watanabe et al., 2018) recipes to perform data preprocessing. For both tasks, our acoustic features are 80-dimensional log-Mel filterbanks stacked with 3-dimensional pitch features extracted with a step size of 10ms and window size of 25ms. The features are normalized by the mean and the standard deviation for each training set. Utterances of more than 3000 frames are discarded. We perform speed perturbation with factors 0.9 and 1.1. The alignment results between speech and transcriptions are obtained by Montreal Forced Aligner (McAuliffe et al., 2017).
For references pre-processing, we tokenize and lowercase all the text with the Moses scripts. For pre-training tasks, the vocabulary is generated using sentencepiece (Kudo and Richardson, 2018) with a fixed size of 5k tokens for all languages, and the punctuation is removed. For ST task, we normalize the punctuation using Moses and use the character-level vocabulary due to its better performance (Berard et al., 2018). Since there is no human-annotated segmentation provided in the I-WSLT tst2013, we use two methods to segment the audios: 1) Following ESPnet, we segment each audio with the LIUM SpkDiarization tool (Meignier and Merlin, 2010). For evaluation, the hypotheses and references are aligned using the MWER method with RWTH toolkit (Bender et al., 2004).
<sup>2</sup>http://www.statmt.org/moses
<sup>3</sup>https://github.com/moses-smt/giza-pp
4https://github.com/espnet/espnet
2) We perform sentence-level force-alignment between audio and transcription using aeneas<sup>5</sup> tool and segment the audio according to alignment results.
Experiments are conducted in two settings: base setting and expanded setting. In base setting, only the corpus described in Section 4.1 is used for each task. In the expanded setting, additional ASR and/or MT data can be used. All results are reported on case-insensitive BLEU with the multibleu.perl script unless noted.
4.2.1 End-to-End ST Baselines
We mainly compare our method with the conventional encoder pre-training method which uses only the ASR task to pre-train the encoder. Besides, we also compare with the results of the other works in the literature by copying their numbers.
LibriSpeech: In the context of base setting, Berard et al. (2018) and ESPnet have reported results on a LSTM-based ST model with pre-training and/or multi-task learning strategy. Liu et al. (2019) use a Transformer ST model and knowledge distillation method. Wang et al. (2019b) stack an ASR encoder and an MT encoder for final ST task, named as TCEN. Regarding the expanded setting, Bahar et al. (2019) apply the SpecAugment on ST task. They use the total 236h of speech for ASR pre-training. Inaguma et al. (2019) combine three ST datasets of 472h training data to train a multilingual ST model. In our work, we use the LibriSpeech ASR corpus as additional pre-training data, including 960h of speech. As the dev and test set of LibriSpeech ST task are extracted from the 960h corpus, we exclude all training utterances with the same speaker that appear in dev or test sets.
IWSLT: Since previous works use different segmentation methods and BLEU-score scripts, it is unfair to copy their numbers. In our work, we choose the ESPnet results as base setting baseline, the multilingual model and TCEN-LSTM model as expanded baselines. Inaguma et al. (2019) use the same multilingual model as described in LibriSpeech baselines. And Wang et al. (2019b) use an additional 272h TEDLIUM2(Rousseau et al., 2014)
ASR corpus and 41M parallel data from WMT18 and WIT3<sup>7</sup>. All of them use ESPnet code, LIUM segmentation method and multi-bleu.perl script. We follow Wang et al. (2019b) to use another 272h ASR data for encoder pre-training and a subset of WMT18<sup>8</sup> for decoder pre-training. We use the same processing method for MT data, resulting in 4M parallel sentences in total. We also reimplement the CL-fast track of Kano et al. (2017) using our model architecture and data as another baseline.
4.2.2 Cacased Baselines
For LibriSpeech ST task, we use results of Berard et al. (2018), Inaguma et al. (2019) and Liu et al. (2019) as base cascaded baselines. The first two use LSTM models for ASR and MT. While the last work trains Transformer ASR and MT models. We build an expanded cascaded system with the pretrained Transformer ASR model and a LSTM MT model with the default setting in ESPnet recipe. For IWSLT ST task, we use Inaguma et al. (2019) as base cascaded baseline, which is based on LSTM architecture. And we implement a Transformer-based baseline using our pre-trained ASR and MT models in the expanded setting.