In connectionist temporal classification (CTC), an acoustic model gives, for each of frames, a distribution over the symbols . How are alignments mapped to labels, how many alignments of length 4 collapse to the label "ab", how many to "aa", and what is the probability of "ab" if every frame is uniform over the three symbols?
Sequence models and transformers, Sequence-to-sequence models
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you understand the CTC collapse rule and can count alignments, which is the sum that the CTC loss computes with dynamic programming.
Key idea
The collapse map first merges repeated symbols and then deletes blanks. CTC defines , a sum over all frame-level alignments that collapse to .
Steps
- Collapse rule. Merge consecutive repeats, then remove blanks. For example and , where "-" is the blank. The blank is what lets a label repeat.
- "ab" in 4 frames. Every valid alignment has the form: blanks, then repeated, blanks, repeated, blanks, with run lengths , , , , and . Write and , so the five non-negative numbers sum to .
- By stars and bars the count is . Listing a few: aaab, -aab, a-bb, abbb, ab--, -a-b.
- "aa" in 4 frames. A blank must sit between the two runs, so . Subtracting the forced symbols leaves total over five numbers, giving alignments, such as a-aa, aa-a, -a-a, a--a, a-a-. The alignment "aaaa" collapses to a single "a", not "aa".
- Probability with uniform frames. Each alignment has probability , so .
- In general, the sum is computed with the forward–backward recursion over the label sequence padded with blanks, in time, instead of enumerating alignments.
Common mistakes
- Counting aaaa as an alignment of "aa". Repeats are merged, so a blank is required between identical labels.
- Treating the collapse as "delete blanks, then merge". For that order would give "a", not "aa".
- Assuming CTC needs frame-level labels. It sums over all alignments, so only the label sequence is needed.
How long your answer should be
Half a page; 4–5 minutes.
Last checked on 4 December 2026.
Read this
Previous in Sequence models and transformers: Interpolated absolute discounting uses with . Choose so that the distribution sums to , and prove it. Then explain why Kneser–Ney replaces the lower-order unigram by the continuation probability , and check that this also sums to . If with distinct followers and , what is ?
Next in Sequence models and transformers: ALiBi adds no positional embedding. It adds a bias to the attention score between query position and key position , with a head-specific slope . For a query at position 4 whose four raw scores are all equal, what attention weights result when and when ? Give the slopes for 8 heads, and explain why ALiBi can help a model run on longer sequences than it was trained on?