Techniqueresearch
Joint CTC-attention
Also called hybrid CTC-attention, joint CTC-attention decoding.
Train an attention encoder-decoder with an extra CTC loss on the encoder, and combine both scores in decoding for monotonic alignment.
Joint CTC-attention combines the two main end-to-end losses for speech recognition in one model. An attention encoder-decoder, such as listen, attend and spell, conditions each output on all previous outputs but has no notion of monotonic alignment, so it can skip or repeat parts of the audio, and it learns its alignment slowly. CTC aligns the audio to the labels monotonically, but assumes the outputs are independent given the audio. The technique adds a CTC output layer on the shared encoder and trains with a weighted sum of the two losses. In decoding, each hypothesis of the attention decoder also gets the CTC probability of its prefix, so hypotheses that do not fit a monotonic alignment of the whole audio score low.
In plain words
Two students transcribe the same recording. The first writes fluent sentences but sometimes loses their place and repeats a line or skips one. The second follows the audio second by second and never loses their place, but writes clumsy text. Joint CTC-attention trains both students on one shared listening skill, and then lets them grade each other's drafts.
In training, the shared part of the network must serve both, so it learns to follow the audio in order. In decoding, the fluent student proposes the next letters, and the careful student checks whether the text so far still fits the audio from start to end. A draft that skipped a line fits badly and drops out of the search.
When it applies
- The model is an attention encoder-decoder for a task with a monotonic alignment between input and output, such as speech recognition or handwriting recognition. It does not suit machine translation, where the word order changes.
- The encoder outputs have a frame structure, so a CTC layer can read them, and they are at least as many as the labels (after any time reduction).
- The label set for CTC is the output vocabulary of the decoder plus a blank.
The template
Model. A shared encoder maps the input to . A CTC head (a linear layer and a softmax with a blank) gives for each . An attention decoder gives .
Training. Minimize
where by the CTC forward algorithm and with teacher forcing (Kim, Hori and Watanabe 2017).
Decoding (Watanabe et al. 2017). Run a beam search over output prefixes of the decoder. A prefix gets the score
optionally plus . Here is the CTC prefix probability: the total CTC probability of all labelings that begin with . For a complete hypothesis that ends with the end symbol, the CTC term is the full probability .
The CTC prefix probability. For , keep for each frame the probabilities and of the paths over frames that collapse to and end in a label or in a blank, the same two numbers as in CTC prefix beam search. With the values of stored, and if the last label of is not , if it is,
where if is empty and 0 otherwise. Each term of the sum is the probability of the paths in which the label of first appears at frame . The cost is for each new prefix. In the rescoring variant, the attention beam search runs alone and the CTC score is added to its best hypotheses.
Classic examples
A worked prefix score. Use the CTC outputs of the example on the CTC page, with frames 1 to 3 and the symbols blank, a and b: , and . From the empty prefix, and . For $h = $ "a": , then adds and adds , so . In the same way . With the probability 0.06 of the empty labeling, . If the attention decoder gives and , then with the scores are and , so the CTC term moves "a" ahead. The full CTC probability of "a" alone is only 0.176; most of its prefix probability is in "ab" (0.378 as a prefix).
Multi-task training on WSJ and CHiME-4. Kim, Hori and Watanabe (2017) used a 4-layer BLSTM encoder with 320 cells that reduces the frame rate by 4, and location-based attention, with . With , the character error rate on WSJ1 was 7.36%, against 8.97% for CTC alone and 8.17% for attention alone; on CHiME-4 it was 44.99%, against 48.79% and 47.58% (measurements, beam 20). The attention weights also became monotonic after fewer training steps.
Joint decoding. Watanabe et al. (2017) added the CTC prefix score to the beam search of the attention decoder, either by rescoring the best hypotheses or in one pass with the recursion above.
Variations
- Weight in training and in decoding. The weight of the CTC term may differ between the two. A small weight in training (0.1 to 0.3) is common, and the decoding weight is tuned on held-out data.
- Encoders. The same combination works with Transformer and Conformer encoders; the CTC head reads the last encoder layer, or an intermediate one.
- CTC as an auxiliary loss only. Train with both losses and decode with the attention decoder alone. This keeps most of the training benefit and the cost of decoding is lower.
- Attention rescoring of CTC. Decode with CTC prefix beam search, which can stream, and rescore its best list with the attention decoder.
- Transducers. An RNN transducer gets a monotonic alignment by its own loss; CTC can also be added to its encoder as an extra loss.
Pitfalls
- Prefix probability and full probability. The prefix probability of counts every labeling that begins with , not itself. A finished hypothesis must use the full CTC probability when the end symbol is added, or short hypotheses win.
- Cost of the prefix score. The prefix score costs for every candidate extension of every hypothesis. Limit the candidates to the best few labels of the attention decoder.
- Time reduction too strong. CTC needs at least as many encoder frames as labels, plus one for each repeated label. A strong reduction of the frame rate with short sub-word units can make some targets impossible.
- Different vocabularies. The CTC head and the decoder must share the label set; the end symbol of the decoder has no CTC label.
Exercises
- Show that equals plus the sum of over all labels . Check it on the example for $g = $ "a" with , and .
- Explain why leaves out when equals the last label of .
- With in decoding, what does the beam search compute? Is it the same as CTC prefix beam search?
- Give an input where an attention decoder alone would prefer a hypothesis that drops a word, and show how the CTC prefix score penalizes it.
References
- Suyoun Kim, Takaaki Hori and Shinji Watanabe, Joint CTC-attention based end-to-end speech recognition using multi-task learning, ICASSP 2017, pages 4835 to 4839, the sections on the multi-task objective, the experimental setup (the BLSTM encoder and location-based attention) and the results on WSJ1 and CHiME-4
- Shinji Watanabe, Takaaki Hori, Suyoun Kim, John R. Hershey and Tomoki Hayashi, Hybrid CTC/attention architecture for end-to-end speech recognition, IEEE Journal of Selected Topics in Signal Processing 11(8), 2017, pages 1240 to 1253, the sections on the multi-objective training and on joint decoding (rescoring, one-pass beam search and the CTC prefix score)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag B2YXXF Edit this page History Report an error Markdown