Search

Search papers and lessons

Listen, Attend and Spell

William Chan, Navdeep Jaitly, Quoc V. Le et al. · 2015

Chan, Jaitly, Le and Vinyals (2015) trained one attention-based network to write speech as characters, jointly learning every part of a recognizer, and reached 14.1% word error without a language model.

On this page

  • Colour = topic mix
  • Discrete math
  • Calculus
  • Neural network basics
  • Linear algebra
  • Probability
  • Architectures
  • ReadReady to readNot yet

TL;DR

Listen, Attend and Spell (LAS) is a neural network that turns a recording of speech into text one character at a time. It has two parts: a listener that compresses the audio into a shorter sequence of features, and a speller that uses attention to look back at those features while it writes. Both parts are trained together from audio and transcripts alone. On a subset of Google voice search, LAS reached a word error rate of 14.1% without a dictionary or language model, and 10.3% after rescoring with a language model.

Builds on: Attention Mechanism, Encoder-Decoder Architecture, Bidirectional Recurrent Neural Network, Long Short-Term Memory · Leads to: attention-based end-to-end speech recognition

Why it mattered

Before this work, speech recognizers were built from parts. An acoustic model, a pronunciation dictionary and a language model were each trained separately and then glued together, usually with an Hidden Markov Model tying them. The end-to-end attempts of the time, such as connectionist temporal classification (CTC), trained a single network but assumed that each output was independent of the others.

LAS showed that a single attention-based encoder-decoder could be trained directly from audio to characters and be competitive with the best hybrid system of its day. Its design, in which an attention-based decoder writes characters while looking back over encoded audio, became a template for later end-to-end speech recognizers. The paper also established two practical tricks that people reused: compressing the time axis of the audio before attention, and training the decoder partly on its own predictions.

The problem

Speech is a long input. A few seconds of audio can be hundreds or thousands of frames, while the transcript is a few dozen characters. An encoder-decoder must squeeze that long input into something the decoder can use, and the authors found that a plain stacked recurrent listener converged so slowly that after a month of training its error was still well above the final result. Attention over a very long sequence is also expensive and hard to focus.

The second problem is the mismatch between training and use. During training the decoder is fed the correct previous character, but during decoding it is fed its own guesses, and one early mistake can corrupt everything after it. The third problem is the independence assumption in CTC, which the authors wanted to avoid: the model should be able to choose among spellings such as "triple a" and "aaa" for the same sound.

How it works

Here is one tiny trace through the pipeline. The numbers are illustrative, chosen to make the steps easy to follow; they are not from the paper.

  1. The input is a sequence of 40-dimensional log-mel filter bank features, one vector every 10 milliseconds. Take a short utterance of 16 frames.
  2. The listener's bottom layer is a bidirectional LSTM that reads all 16 frames and produces 16 feature vectors, one per frame.
  3. The first pyramid layer runs a bidirectional LSTM over the features but concatenates each pair of neighbouring outputs before passing them up. Sixteen frames become eight.
  4. Two more pyramid layers each halve the length again: eight becomes four, and four becomes two. The listener now holds two high-level vectors in place of sixteen frames, a reduction by a factor of 23=82^3 = 8.
  5. The speller starts with the start-of-sentence token. At each output step its decoder state asks the listener's vectors "which parts matter for the next character?". A Softmax over scores turns this into weights α\alpha that sum to one.
  6. The context vector is the weighted sum of the listener vectors. The decoder combines its state and the context to give a probability for each character. The most likely character is written.
  7. The chosen character is fed back to the decoder, and steps 5 and 6 repeat until the end-of-sentence token. During training, the correct character is fed back most of the time, and a sampled character is fed back 10% of the time.
  8. At test time, a beam of 32 partial transcripts is kept at each step. If a language model is used, complete transcripts are rescored by a combination of their probability and the language model's probability.
flowchart LR
  A[Filter bank frames] --> B[BLSTM bottom layer]
  B --> C[Pyramid layer 1: half the frames]
  C --> D[Pyramid layers 2 and 3: half again each]
  D --> E[Listener features h]
  E --> F[Attention weights alpha]
  G[Decoder state] --> F
  F --> H[Context c]
  H --> I[Character distribution]
  G --> I
  I --> J[Next character]
  J --> G

The math

The chain rule writes the probability of a transcript y\mathbf{y} given audio x\mathbf{x} as a product of next-character probabilities:

P(y∣x)=∏iP(yi∣x,y<i)P(\mathbf{y} \mid \mathbf{x}) = \prod_{i} P(y_i \mid \mathbf{x}, y_{\lt i})

Here y<iy_{\lt i} means all the characters before position ii. No independence is assumed between characters, which is the difference from CTC.

Step 2 in symbols: the listener

The listener turns the input into h=(h1,…,hU)\mathbf{h} = (h_1, \dots, h_U) with U≤TU \leq T. The pyramid layer jj at time ii reads two neighbouring outputs from the layer below:

hij=pBLSTM ⁣(hi−1j, [h2ij−1, h2i+1j−1])h_i^{j} = \mathrm{pBLSTM}\!\left(h_{i-1}^{j},\, [h_{2i}^{j-1},\, h_{2i+1}^{j-1}]\right)

Each pyramid layer halves UU, so three layers give U≈T/8U \approx T/8.

Step 5 in symbols: attention

For decoder state sis_i and each listener vector huh_u, the energy is a dot product of two learned transforms, ei,u=ϕ(si)⋅ψ(hu)e_{i,u} = \phi(s_i) \cdot \psi(h_u), where ϕ\phi and ψ\psi are small networks. A softmax gives the weights, and the context is their weighted sum:

αi,u=exp⁡(ei,u)∑u′exp⁡(ei,u′),ci=∑uαi,u hu\alpha_{i,u} = \frac{\exp(e_{i,u})}{\sum_{u'} \exp(e_{i,u'})}, \qquad c_i = \sum_{u} \alpha_{i,u}\, h_u

Each decoder step costs about UU dot products, so the attention step over a whole transcript of SS characters costs about U×SU \times S. Halving UU halves that cost.

Step 7 in symbols: training with sampled inputs

The plain training objective maximises ∑ilog⁡P(yi∣x,y<i∗)\sum_i \log P(y_i \mid \mathbf{x}, y^{*}_{\lt i}), where y∗y^{*} is the correct transcript. The paper's variant feeds the decoder a sampled character y~i−1\tilde{y}_{i-1} with probability 0.1, and otherwise the true one, so the training inputs look more like the model's own outputs.

Step 8 in symbols: rescoring

Each complete hypothesis is scored by

s(y∣x)=log⁡P(y∣x)∣y∣c+λlog⁡PLM(y)s(\mathbf{y} \mid \mathbf{x}) = \frac{\log P(\mathbf{y} \mid \mathbf{x})}{|\mathbf{y}|_c} + \lambda \log P_{\mathrm{LM}}(\mathbf{y})

where ∣y∣c|\mathbf{y}|_c is the number of characters, which corrects the model's small bias towards short utterances, and λ\lambda is the language model weight. The paper used λ=0.008\lambda = 0.008.

Worked examples

Example
1. How much the pyramid saves (tiny)

Take a 16-frame input and a 10-character output.

  1. Without pyramid layers, the attention sees U=16U = 16 frames. Its cost is about 16×10=16016 \times 10 = 160 dot products.
  2. With three pyramid layers, UU goes 16→8→4→216 \to 8 \to 4 \to 2, so U=2U = 2.
  3. The attention cost becomes about 2×10=202 \times 10 = 20 dot products.
  4. The ratio is 160/20=8160 / 20 = 8, which matches the reduction factor 23=82^3 = 8.

The listener made the attention eight times cheaper, and gave it fewer places to search.

Example
2. One attention step (standard)

The decoder scores four listener vectors with energies e=(2.0, 0.0, 1.0, −1.0)e = (2.0,\ 0.0,\ 1.0,\ -1.0). The listener vectors are the scalars h=(10,20,30,40)h = (10, 20, 30, 40), to keep the arithmetic visible.

  1. Exponentiate each energy: e2≈7.389e^{2} \approx 7.389, e0=1e^{0} = 1, e1≈2.718e^{1} \approx 2.718, e−1≈0.368e^{-1} \approx 0.368.
  2. Sum them: 7.389+1+2.718+0.368=11.4757.389 + 1 + 2.718 + 0.368 = 11.475.
  3. Divide each by the sum to get the weights: α≈(0.644, 0.087, 0.237, 0.032)\alpha \approx (0.644,\ 0.087,\ 0.237,\ 0.032). Check: they add to 1.000, up to rounding.
  4. Weight the listener vectors: 0.644×10=6.440.644 \times 10 = 6.44, 0.087×20=1.740.087 \times 20 = 1.74, 0.237×30=7.110.237 \times 30 = 7.11, 0.032×40=1.280.032 \times 40 = 1.28.
  5. Add the four products: 6.44+1.74+7.11+1.28=16.576.44 + 1.74 + 7.11 + 1.28 = 16.57.
  6. The context is about 16.57. The largest weight, 0.6440.644, sits on the vector 1010, which keeps the blend low, while the weight 0.2370.237 on 3030 pulls it up. A plain average of the four vectors would be 2525, so the weights clearly favour the first vector.

Attention is a soft lookup: the answer is a blend, and the blend is sharp when one energy is much larger than the rest.

Example
3. Choosing a transcript with the language model (realistic)

These numbers are made up to show the arithmetic of rescoring; they are not results from the paper. Suppose the beam holds two complete hypotheses for one utterance, with λ=0.008\lambda = 0.008.

  1. Hypothesis A has log⁡P(y∣x)=−12.0\log P(\mathbf{y} \mid \mathbf{x}) = -12.0, 20 characters, and language model log probability −30-30.
  2. Its acoustic part is −12.0/20=−0.600-12.0 / 20 = -0.600.
  3. Its language model part is 0.008×(−30)=−0.2400.008 \times (-30) = -0.240.
  4. Its score is −0.600−0.240=−0.840-0.600 - 0.240 = -0.840.
  5. Hypothesis B has log⁡P(y∣x)=−10.0\log P(\mathbf{y} \mid \mathbf{x}) = -10.0, 30 characters, and language model log probability −25-25.
  6. Its acoustic part is −10.0/30≈−0.333-10.0 / 30 \approx -0.333.
  7. Its language model part is 0.008×(−25)=−0.2000.008 \times (-25) = -0.200.
  8. Its score is −0.333−0.200=−0.533-0.333 - 0.200 = -0.533, which is higher than A's −0.840-0.840, so B is chosen.

Normalising by length is what lets the longer and more complete transcript win here, even though its raw acoustic log probability is higher than A's.

Try it: Hypothesis C has log⁡P=−6.0\log P = -6.0, 10 characters, and language model log probability −40-40. Compare C with B. Answer: C scores −6.0/10+0.008×(−40)=−0.600−0.320=−0.920-6.0/10 + 0.008 \times (-40) = -0.600 - 0.320 = -0.920, which is lower than B's −0.533-0.533, so B is still chosen.

Results

The main results are on a subset of Google voice search with about 3 million utterances (about 2000 hours), with data augmentation adding noise and reverberation, and test sets of 22K utterances for clean speech and a noisy copy of it. Word error rate (WER) is the measure, lower is better.

ModelClean WERNoisy WER
CLDNN-HMM (previous state of the art)8.08.9
LAS16.219.0
LAS + LM rescoring12.614.7
LAS + sampling14.116.5
LAS + sampling + LM rescoring10.312.0

What these numbers mean: LAS with sampling and language model rescoring is 2.3 points behind the hybrid baseline on clean speech (10.3 against 8.0) and 3.1 points behind on noisy speech (12.0 against 8.9), so it did not beat it. The sampling trick reduced the clean error from 16.2% to 14.1%. The beam width mattered up to 16 and gave little beyond that. The authors also found that errors are concentrated in very short and very long utterances, and that rare words are recognised less well than common ones. The paper names its own gaps: it did not use convolutional filters, which the authors suspect would help, and the baseline was unidirectional, so a bidirectional baseline might be stronger. Without a language model, the gap is much larger (16.2 against 8.0 on clean speech), so the language model does much of the work of closing it.

Reading guide

Check yourself

QuestionRecall: what is the main difference between LAS and CTC, in what each assumes about the output characters?Show answer
CTC assumes each output label is conditionally independent of the others given the input. LAS uses the chain rule and conditions each character on all the earlier characters, so it makes no such assumption.
QuestionComputation: a listener has 64 input frames and applies three pyramid layers. How many frames does the attention see, and what is the reduction factor?Show answer
Each pyramid layer halves the length: 64 to 32 to 16 to 8. The attention sees 8 frames, a reduction by a factor of 23=82^3 = 8.
QuestionWhy: why does the speller sometimes feed in its own sampled character during training?Show answer
At test time the decoder is fed its own predictions, and early mistakes can corrupt later steps. Training with the correct characters alone never exposes the model to its own errors. Feeding sampled characters 10% of the time makes training inputs resemble test-time inputs, which reduced the clean word error from 16.2% to 14.1% in the paper.
QuestionApplied: a team wants to use LAS-style decoding for a voice app and has a [[language-model|language model]]. Two hypotheses differ in length. Why should they normalise the acoustic score by the number of characters before adding the language model score?Show answer
The model has a small bias towards short utterances, so raw log probability favours short transcripts. Dividing by the character count removes much of that bias. The language model weight then controls how much the language model influences the choice, and the team should tune it on a held-out validation set, as the paper did.

Sources

Read the full paper

William Chan, Navdeep Jaitly, Quoc V. Le et al., 2015. arXiv:1508.01211