In connectionist temporal classification (CTC), an acoustic model gives, for each of T=4 frames, a distribution over the symbols {a,b,blank}. 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 B first merges repeated symbols and then deletes blanks. CTC defines P(y∣x)=∑π: B(π)=y∏tpt(πt), a sum over all frame-level alignments π that collapse to y.

Steps

  1. Collapse rule. Merge consecutive repeats, then remove blanks. For example B(a a - b)=ab and B(a - a)=aa, where "-" is the blank. The blank is what lets a label repeat.
  2. "ab" in 4 frames. Every valid alignment has the form: blanks, then a repeated, blanks, b repeated, blanks, with run lengths n0≥0, n1≥1, n2≥0, n3≥1, n4≥0 and ∑ni=4. Write n1′=n1−1 and n3′=n3−1, so the five non-negative numbers sum to 2.
  3. By stars and bars the count is (2+44)=15. Listing a few: aaab, -aab, a-bb, abbb, ab--, -a-b.
  4. "aa" in 4 frames. A blank must sit between the two a runs, so n2≥1. Subtracting the forced symbols leaves total 4−3=1 over five numbers, giving (1+44)=5 alignments, such as a-aa, aa-a, -a-a, a--a, a-a-. The alignment "aaaa" collapses to a single "a", not "aa".
  5. Probability with uniform frames. Each alignment has probability (1/3)4=1/81, so P(ab∣x)=15/81≈0.185.
  6. In general, the sum is computed with the forward–backward recursion over the label sequence padded with blanks, in O(T⋅∣y∣) time, instead of enumerating alignments.

Common mistakes

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 P(w∣v)=max⁡(c(vw)−d,0)c(v)+λ(v)Plow(w) with 0<d<1. Choose λ(v) so that the distribution sums to 1, and prove it. Then explain why Kneser–Ney replaces the lower-order unigram by the continuation probability Pcont(w)=N1+(∙w)N1+(∙∙), and check that this also sums to 1. If c(v)=10 with 4 distinct followers and d=0.75, what is λ(v)?
Next in Sequence models and transformers: ALiBi adds no positional embedding. It adds a bias −m(i−j) to the attention score between query position i and key position j≤i, with a head-specific slope m. For a query at position 4 whose four raw scores are all equal, what attention weights result when m=0.5 and when m=1/16? Give the slopes for 8 heads, and explain why ALiBi can help a model run on longer sequences than it was trained on?