Search

Search papers and lessons

Deep Speech 2: End-to-End Speech Recognition in English and Mandarin

Dario Amodei, Rishita Anubhai, Eric Battenberg et al. · 2015

Amodei and colleagues (2015) built one neural network that turns speech spectrograms into English or Mandarin text, trained on about 10,000 hours per language, and approached human accuracy on several benchmarks.

On this page

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

TL;DR

Deep Speech 2 is a single neural network that takes a spectrogram of speech and outputs text, with no hand-built acoustic pipeline. The same design works for English and Mandarin, and it is trained with a loss that lets the network learn the alignment between audio and characters itself. The authors trained it on 11,940 hours of English and 9,400 hours of Mandarin speech, combined it with an n-gram language model, and reported accuracy that approached or exceeded human transcribers on several benchmarks.

Builds on: CTC, recurrent networks, Batch Normalization · Leads to: Automatic Speech Recognition systems built end to end, and the batch-dispatch approach to serving large models

Why it mattered

Deep Speech 2 showed that end-to-end speech recognition could work at production scale and in more than one language. Before it, a speech recogniser was a chain of separately tuned parts: feature extraction, an acoustic model, a pronunciation model and a language model. The paper replaced most of that chain with one network trained on a very large labelled dataset, and the same recipe then applied to Mandarin with only small changes.

The paper also made a practical point that shaped later work. Its authors described how to make training fast enough that an experiment which had taken weeks could run in days, and how to serve the network with low latency. Those systems details, from data-parallel training on GPUs to batch dispatch at serving time, were as much a contribution as the architecture.

The problem

Speech varies a great deal: accents, background noise, far-field microphones, spontaneous speech. The previous system from the same group, Deep Speech 1, was already end to end, but its error rates were high in many conditions and it was trained on less data. The authors wanted a model that could approach or exceed human transcription on standard test sets, work in a second language with little change, and still be fast enough to deploy.

The main difficulty is alignment. Audio arrives as a long sequence of frames, many per second, while the text has far fewer characters, and nobody labels which frame corresponds to which letter. The network needs a loss function that accepts a transcript without an alignment, and an output scheme that can handle the many frames that correspond to silence or to the middle of a letter.

How it works

The system takes four stages, shown below. The walkthrough follows one short utterance through them. The example is illustrative, not from the paper.

  1. Input: a spectrogram. The audio is cut into short overlapping frames, and each frame is turned into a vector of power values across frequency bins, a spectrogram. The power is normalised over the clip. A two-second clip becomes a sequence of frame vectors, one per time step. Check: the network sees a sequence of vectors, not a waveform and not characters.
  2. Convolution and striding. One to three convolutional layers slide filters over the frames. A stride of 3 in the first layer keeps only every third output, which shortens the sequence the recurrent layers have to process. The best English model uses three 2D convolution layers. Check: a sequence of 300 frames with stride 3 becomes about 100 steps, so later layers do a third of the work.
  3. Recurrent layers. Between one and seven bidirectional recurrent layers read the sequence forward and backward and pass context along. The best English model uses seven. Each layer is followed by Batch Normalization, which the paper found helped deep recurrent stacks reach better final error. Check: after this stage, each time step carries information from both earlier and later audio.
  4. Output and decoding. A softmax layer gives, at each time step, a probability over the characters of the language plus a special blank symbol. A CTC rule reads the most likely path and collapses it: repeated characters merge, and blanks separate real repeats. Then a beam search keeps the best candidate transcripts and adds a score from a language model. Check: with the path "h h blank i", collapsing gives "hi". With "h blank h i", it gives "hhi", because the blank keeps the two h's apart.
flowchart LR
  A[Spectrogram frames] --> B[1 to 3 convolution layers]
  B --> C[1 to 7 bidirectional RNN layers]
  C --> D[Softmax over characters and blank]
  D --> E[CTC collapse plus language model beam search]
  E --> F[Transcript]

The math

The notation follows the paper. An utterance xx is a sequence of frames xtx_t for t=0,…,T−1t = 0, \ldots, T - 1, and xt,px_{t,p} is the power in frequency bin pp at time tt.

Step 2 in symbols: the convolution

Let ht,ilh^{l}_{t,i} be activation ii of layer ll at time tt. For a context window of size cc on the previous layer's output, the convolution computes

ht,il=f ⁣(wil∘ht−c:t+cl−1),h^{l}_{t,i} = f\!\left(w^{l}_{i} \circ h^{l-1}_{t-c:t+c}\right),

where wilw^{l}_{i} is filter ii, ∘\circ is the element-wise product summed over the window, and ff is the nonlinearity. The paper uses a clipped ReLU, σ(x)=min⁡{max⁡{x,0},20}\sigma(x) = \min\{\max\{x, 0\}, 20\}, which is the ReLU with a ceiling of 20. Striding by ss means the window moves ss frames at a time.

Step 3 in symbols: the recurrent layer

A bidirectional layer computes a forward state h→t\overrightarrow{h}_t and a backward state h←t\overleftarrow{h}_t, and adds them. The simplest recurrence is

h→tl=f ⁣(Wlhtl−1+U→lh→t−1l+bl),\overrightarrow{h}_{t}^{l} = f\!\left(W^{l} h_{t}^{l-1} + \overrightarrow{U}^{l} \overrightarrow{h}_{t-1}^{l} + b^{l}\right),

where WlW^{l} maps the input, U→l\overrightarrow{U}^{l} carries the state from the previous step, and blb^{l} is a bias. The paper also compares GRU cells with this simple recurrence. LSTM cells are another option it mentions.

Step 4 in symbols: the output and the loss

After the recurrent layers, one or more fully connected layers feed a softmax. The probability of symbol kk at time tt is

p(ℓt=k∣x)=exp⁡(wkL⋅htL−1)∑jexp⁡(wjL⋅htL−1).p(\ell_t = k \mid x) = \frac{\exp(w^{L}_{k} \cdot h^{L-1}_{t})}{\sum_{j} \exp(w^{L}_{j} \cdot h^{L-1}_{t})}.

The CTC loss sums the probability of every alignment that collapses to the correct transcript yy. For an utterance xx and transcript yy, the paper writes

L(x,y;θ)=−log⁡∑ℓ∈Align(x,y)∏t=1Tpctc(ℓt∣x;θ),\mathcal{L}(x, y; \theta) = -\log \sum_{\ell \in \mathrm{Align}(x, y)} \prod_{t=1}^{T} p_{\mathrm{ctc}}(\ell_t \mid x; \theta),

where Align(x,y)\mathrm{Align}(x, y) is the set of all frame-level paths that collapse to yy, and θ\theta are the network weights. Training follows the gradient of this loss with Backpropagation through time.

Step 4 again: decoding with a language model

At inference, the system looks for the transcript that maximises a score combining the network and a language model:

Q(y)=log⁡pctc(y∣x)+αlog⁡plm(y)+β⋅word_count(y).Q(y) = \log p_{\mathrm{ctc}}(y \mid x) + \alpha \log p_{\mathrm{lm}}(y) + \beta \cdot \mathrm{word\_count}(y).

The weight α\alpha sets how much the language model counts, and β\beta rewards more words. Both are tuned on a development set.

Batch normalisation in symbols

For a layer with an affine map WhWh, the paper inserts B\mathcal{B} before the nonlinearity:

B(x)=γx−E[x]Var[x]+ϵ+β.\mathcal{B}(x) = \gamma \frac{x - \mathrm{E}[x]}{\sqrt{\mathrm{Var}[x] + \epsilon}} + \beta.

The mean and variance are taken over a minibatch and over the time steps of each sequence in it (the paper calls this sequence-wise normalisation). γ\gamma and β\beta are learned, and ϵ\epsilon is a small constant for stability. The bias bb is dropped because mean removal cancels it.

Worked examples

Example
Tiny: scoring a word error rate

Word error rate (WER) counts the mistakes a transcript makes against a reference. It is the number of substitutions, deletions and insertions, divided by the number of words in the reference. Take the reference "the cat sat on the mat" and the hypothesis "the cat sat on mat".

  1. The reference has 6 words.
  2. Align the two sentences. The only difference is that the hypothesis is missing the word "the" before "mat". That is one deletion.
  3. Count the errors: 0 substitutions, 1 deletion and 0 insertions, so 1 error in total.
  4. Divide: WER =1/6≈0.167= 1/6 \approx 0.167, which is 16.7%.

Interpretation: one dropped word in six gives a WER of about 17%. A WER can exceed 100% when the hypothesis contains many insertions.

Example
Standard: choosing between two transcripts

The decoder scores two candidate transcripts with Q(y)Q(y). The values below are illustrative, not the paper's tuned settings. Use α=0.5\alpha = 0.5 and β=1.0\beta = 1.0.

  1. Candidate A: the network gives log⁡pctc=−4.0\log p_{\mathrm{ctc}} = -4.0, the language model gives log⁡plm=−6.0\log p_{\mathrm{lm}} = -6.0, and the word count is 3.
  2. Score A: Q(A)=−4.0+0.5×(−6.0)+1.0×3=−4.0−3.0+3.0=−4.0Q(A) = -4.0 + 0.5 \times (-6.0) + 1.0 \times 3 = -4.0 - 3.0 + 3.0 = -4.0.
  3. Candidate B: the network gives log⁡pctc=−3.5\log p_{\mathrm{ctc}} = -3.5, the language model gives log⁡plm=−9.0\log p_{\mathrm{lm}} = -9.0, and the word count is 2.
  4. Score B: Q(B)=−3.5+0.5×(−9.0)+1.0×2=−3.5−4.5+2.0=−6.0Q(B) = -3.5 + 0.5 \times (-9.0) + 1.0 \times 2 = -3.5 - 4.5 + 2.0 = -6.0.
  5. Compare: Q(A)=−4.0Q(A) = -4.0 is larger than Q(B)=−6.0Q(B) = -6.0, so the decoder keeps A.

Interpretation: B is slightly more likely under the acoustic network, but the language model finds it unlikely, and the word bonus does not make up the difference. This is the trade-off the language model weight controls.

Example
Realistic: a noisy real-world test set

The paper's CHiME "real" test set was recorded in actual noisy places: a bus, a cafe, a street. Table 15 reports the following WER values (single channel).

Test setDS1DS2Human
CHiME eval clean6.303.343.46
CHiME eval real67.9421.7911.84
CHiME eval sim80.2745.0531.33
  1. On the real noisy set, DS1 has 67.94% WER and DS2 has 21.79%. The drop is 67.94−21.79=46.1567.94 - 21.79 = 46.15 points.
  2. The relative reduction is 46.15/67.94≈0.67946.15 / 67.94 \approx 0.679, so DS2 makes about 68% fewer errors than DS1 on this set.
  3. Human transcribers reach 11.84% on the same audio, so DS2 is still 21.79−11.84=9.9521.79 - 11.84 = 9.95 points behind them.
  4. On the simulated set, where noise was added synthetically to clean speech, DS2 is at 45.05% against 31.33% for humans, a gap of 13.72 points.

Interpretation: the model improved a great deal on real noise, but the gap to humans is larger on real noise than on synthetic noise. The paper says this directly, and it is the main limit of the result.

Try it: using the same table, what is the gap between DS2 and humans on the clean set, in points?

Answer: 3.34−3.46=−0.123.34 - 3.46 = -0.12, so DS2 is 0.12 points better than the human transcribers on clean speech.

Results

Scale and accuracy. The English system was trained on 11,940 hours of speech and the Mandarin system on 9,400 hours. The paper reports that its system reduced English error rates by up to 43% relative to Deep Speech 1, and that it is competitive with human transcription on several benchmarks.

Language model. Table 6 compares word error rate (WER, explained in the first worked example) for English and character error rate (CER) for Mandarin, with and without the language model. The English 9-layer, 7-recurrent-layer model goes from 14.93 to 9.52 WER, and the Mandarin version from 7.55 to 5.81 CER. The relative gain from the language model is smaller for deeper models: 48% falls to 36% in English, and 27% falls to 23% in Mandarin. The authors suggest that deeper recurrent models learn more of a language model themselves.

Model size. Table 11 varies the layer width on the regular and noisy development sets. The 100 million parameter RNN model gives the lowest errors, at 7.73 regular and 13.06 noisy. The paper uses this model for all further English results. The authors also note that at this size the simple RNN slightly beats the GRU, and that it trains faster.

Benchmarks against Deep Speech 1 and humans. On read speech (Table 13), DS2 beats the human baseline on three of four sets. On LibriSpeech test-other it is at 13.25, against 12.69 for humans, so it is competitive rather than better there. On accented speech (Table 14), DS2 improves on DS1 for every accent, but human performance is still better in all four groups. Table 14 shows humans with the lower error in all four groups, though the text says this holds for all groups but the Indian one. The gap is smallest for the Indian group, where humans have 22.15 and DS2 has 22.44, a difference of 0.29 points. On noisy speech (Table 15), the gaps are shown above.

Internal test sets. On a Baidu internal set of 3,300 utterances (Table 12), DS2 has 13.59% WER against 24.01% for DS1, a relative improvement of 43.4%.

Mandarin. Table 16 shows the effect of each architectural change on a Mandarin development and test set. The 5-layer, 1-RNN model has 7.13 and 15.41. The 9-layer, 7-RNN model with BatchNorm and 2D convolution has 5.81 and 7.93. On a 100-utterance test, a group of five humans had a 4.0% error rate against 3.7% for the system, while a single human transcriber on 250 utterances had 9.7% against 5.7% for the model.

Limits. Many results are on internal Baidu data that outside readers cannot inspect. The human baselines come from paid transcription workers, and the paper's own noisy-speech results show the largest human gap on real noise. The Mandarin human comparison uses small samples. The paper is a systems report, so its claims are about these benchmarks and this system, not about all speech recognition.

Reading guide

The paper is long, and its sections map onto the prerequisites as follows.

Check yourself

QuestionIn one sentence, what does the network output at each time step, and what does the CTC rule do with those outputs?Show answer

At each time step the network outputs a probability over the characters and a blank symbol. The CTC rule reads the most likely path, merges repeated characters and removes blanks, which gives the transcript.

QuestionThe reference transcript has 8 words. A hypothesis has 2 substitutions, 1 deletion and 1 insertion. What is the word error rate?Show answer

The total number of errors is 2+1+1=42 + 1 + 1 = 4. The WER is 4/8=0.54 / 8 = 0.5, which is 50%.

QuestionWhy does the paper use a language model in decoding, and why does the benefit shrink for deeper models?Show answer

The paper uses an n-gram language model because such models scale to large amounts of unlabelled text, so they can add knowledge about word and character sequences that the acoustic training data does not provide. The benefit shrinks with depth because the authors hypothesise that deeper recurrent networks learn more of the language structure themselves, so the external model adds less.

QuestionA team wants to use the paper's approach for a voice assistant that runs in busy kitchens. Their test set is recorded in real kitchens. Using the paper's own results, what should they expect, and what should they check?Show answer

They should expect the model to be much better than older systems on real noise, but still behind human transcribers, and the paper shows the gap is largest on real noisy audio. They should check their own real-noise test set rather than clean benchmarks, measure WER against human transcripts, and treat the paper's numbers as a guide to the kind of result, not a guarantee for their device.

Sources

Read the full paper

Dario Amodei, Rishita Anubhai, Eric Battenberg et al., 2015. arXiv:1512.02595