AI Logic

Architectures

Jasper

Updated:

Architecture of Jasper. The left side shows the overall flow of Jasper 10x5 (mel filterbank features → Conv1 → blocks B1 to B5, twice each → Conv2, Conv3, Conv4 → CTC loss). The right side shows the inside of one block: sub-blocks of 1D convolution, batch normalization, ReLU, and dropout are repeated R−1 times; at the last sub-block, the block input passed through a 1×1 convolution and batch normalization is added as a residual to the batch normalization output, and the sum then goes through ReLU and dropout

Background and Overview

Jasper is an end-to-end speech recognition model that deeply stacks only basic components (1D convolution, batch normalization, ReLU, dropout, and residual connections), outputs per-time-step character probabilities from audio features, and is trained with CTC. Li et al. of NVIDIA published it in 2019, and it was accepted at INTERSPEECH 2019.

CTC-based speech recognizers such as Deep Speech 2 stacked deep RNNs on top of convolutions. An RNN computes time steps one by one in order, which makes it hard to parallelize on GPUs. Jasper drops the RNN and captures the surrounding context with 1D convolutions along the time axis alone. Convolution, batch normalization, and ReLU are operations heavily optimized for GPUs, so both training and inference run fast.

The deepest version has 54 convolutional layers (333 million parameters). To make such depth trainable, each block includes a residual connection. The best model, Jasper DR 10x5, achieved a word error rate of 3.86% on LibriSpeech test-clean with greedy decoding and no language model, and 2.95% when combined with an external Transformer-XL language model.

As an analogy, Deep Speech 2 lines up several "people who read from front to back in order (RNNs)," while Jasper stacks dozens of tiers of "people who survey a somewhat wider range at once (convolutions)," widening the visible range with each tier. Since everyone can work at the same time, processing is fast.

Architecture

Jasper is built by stacking blocks and is called Jasper BxR after the number of blocks BB and the number of sub-blocks per block RR. The left side of the figure at the top of the article shows the overall flow of Jasper 10x5, which, following Table 1 of the paper, processes in the following order.

  1. Input: Mel filterbank features computed over 20 ms windows (64 dimensions for LibriSpeech; see mel scale).
  2. Preprocessing convolution Conv1: Kernel 11, stride 2, 256 channels. The stride halves the number of time steps.
  3. Blocks B1 to B5: Kernel sizes 11, 13, 17, 21, and 25 and channels 256, 384, 512, 640, and 768, growing toward the top. In Jasper 10x5, each is repeated twice for 10 blocks.
  4. Postprocessing convolutions Conv2 to Conv4: Conv2 has kernel 29, dilation 2, and 896 channels; Conv3 has kernel 1 and 1,024 channels; Conv4 has kernel 1, with output channels equal to the number of characters (graphemes).
  5. Loss: Probabilities of characters and the blank are output at each time step and trained with the CTC loss.

A sub-block inside a block performs the following four operations in order (right side of the figure at the top).

  • 1D convolution
  • Batch normalization
  • ReLU
  • Dropout

All sub-blocks in the same block have the same number of channels. The residual connection passes the block input through a 1×11 \times 1 convolution (to match the channel count) and batch normalization, and adds it to the batch normalization output of the last sub-block. The sum is passed through ReLU and dropout to form the block output. With block input xx and the last sub-block's convolution Conv\mathrm{Conv}, this can be written as follows.

y=Dropout(ReLU(BN(Conv(hR−1))+BN(Conv1×1(x))))y = \mathrm{Dropout}\Bigl(\mathrm{ReLU}\bigl(\mathrm{BN}(\mathrm{Conv}(h_{R-1})) + \mathrm{BN}(\mathrm{Conv}_{1\times1}(x))\bigr)\Bigr)

hR−1h_{R-1} is the value after passing through R−1R-1 sub-blocks. The dropout rate is 0.2 for Conv1 and B1 to B3, 0.3 for B4 and B5, and 0.4 for Conv2 and Conv3.

The sub-block operations are chosen so that they can be fused into a single GPU kernel at inference. Dropout is unused at inference and removed, batch normalization is folded into the weights of the preceding convolution, ReLU just clips values, and the residual addition can be treated as a kind of bias. Jasper limits itself to convolution, batch normalization, and ReLU for this speed.

Dense Residual and the Choice of Normalization and Activation

The Jasper paper chose its current form after comparing combinations of components.

Dense Residual (DR): In the basic Jasper, the residual comes only from the input of the previous block. In Jasper DR, following DenseNet, the output of each block is added to the inputs of all subsequent blocks. DenseNet concatenates outputs (along the channel dimension), whereas Jasper DR combines them by addition like the residuals of ResNet. Concatenation requires tuning how fast the channel count grows (the growth rate) as layers deepen, but addition needs no such tuning.

The comparison of residual schemes is as follows (Jasper 10x3, 400 epochs, word error rate on LibriSpeech dev, greedy decoding, Table 4 of the paper).

Residual schemeParametersdev-cleandev-other
Residual201M4.65%14.36%
Dense Residual211M4.51%14.15%
DenseNet205M4.77%14.55%
DenseRNet211M4.32%14.21%

Dense Residual and DenseRNet were about the same, and the paper chose Dense Residual, which needs no growth-rate tuning. It also reports that models deeper than Jasper 5x3 did not converge without residual connections.

Normalization and activation: The paper compared three normalizations (batch normalization, Weight Normalization, and Layer Normalization) and five activations (ReLU, clipped ReLU, Leaky ReLU, GLU, and GAU). For the small Jasper 5x3, the combination of Layer Normalization and GAU was best, while for the larger Jasper 10x4, batch normalization with ReLU was best (dev-clean 6.15% and dev-other 17.58% after 50 epochs). With Weight Normalization, activation values diverged and training was unstable.

NovoGrad: The paper also proposes NovoGrad, an optimizer similar to Adam. Adam keeps a second moment for each weight, whereas NovoGrad keeps only one per layer (ll is the layer and gtlg^l_t is its gradient).

vtl=β2⋅vt−1l+(1−β2)⋅∥gtl∥2,mtl=β1⋅mt−1l+gtlvtl+ϵ+d⋅wtv^l_t = \beta_2 \cdot v^l_{t-1} + (1 - \beta_2) \cdot \lVert g^l_t \rVert^2, \qquad m^l_t = \beta_1 \cdot m^l_{t-1} + \frac{g^l_t}{\sqrt{v^l_t} + \epsilon} + d \cdot w_t

d⋅wtd \cdot w_t is weight decay in the same form as AdamW, and the weights are updated as wt+1=wt−αt⋅mtw_{t+1} = w_t - \alpha_t \cdot m_t. The paper states that it uses less memory and is numerically stable. For Jasper DR 10x5, replacing SGD with momentum by NovoGrad lowered the dev-clean word error rate from 4.00% to 3.64%.

Experimental Results

The LibriSpeech results are as follows (word error rate; excerpt from Table 5 of the paper). Jasper DR 10x5 was trained with NovoGrad for 400 epochs, using speed perturbation that varies the speed by ±10% during training.

ModelEnd-to-endLanguage modeltest-cleantest-other
Deep Speech 2Yes5-gram5.33%13.25%
wav2letter++YesConvolutional LM3.44%11.24%
LAS + SpecAugmentYesRNN2.5%5.8%
Jasper DR 10x5YesNone (greedy decoding)3.86%11.95%
Jasper DR 10x5Yes6-gram3.34%9.62%
Jasper DR 10x5YesTransformer-XL2.95%8.79%
Jasper DR 10x5 + time/frequency maskingYesTransformer-XL2.84%7.84%

When a language model is used, candidates are first generated with a word N-gram language model and beam search with a beam width of 2,048, and then rescored with an external Transformer-XL language model. The paper reports a strong correlation: the lower the language model's perplexity, the lower the word error rate. The LAS + SpecAugment row is a result that appeared after Jasper's initial submission, and the paper adds a result for Jasper with time and frequency masking similar to SpecAugment.

Results on other datasets are as follows.

DatasetModelLanguage modelWord error rate
WSJ (80 hours) nov92Jasper 10x3None / 4-gram / Transformer-XL13.3% / 7.1% / 6.9%
Hub5'00 SwitchboardJasper DR 10x54-gram / Transformer-XL8.3% / 7.8%
Hub5'00 CallHomeJasper DR 10x54-gram / Transformer-XL19.3% / 16.2%

With little training data, as in WSJ, or with difficult conversational speech, as in CallHome, a gap with other methods remained. The paper also lists improving CallHome as future work.

Practical Considerations

Jasper has a very large number of parameters (about 333 million for Jasper DR 10x5). The paper's results come from training for 400 epochs on LibriSpeech training data with speed perturbation; on small data such as WSJ (80 hours), the word error rate without a language model was high at 13.3%. For small data or limited compute, QuartzNet, from the same family with far fewer parameters, is a candidate.

  • CTC outputs are mutually independent: CTC treats the output at each time step as independent, so spelling and word-order errors tend to remain, and combining an external language model improves results greatly (3.86% → 2.95% on test-clean). When comparing numbers in the paper, match whether a language model is used.
  • Handling padding: Padding used to equalize lengths within a mini-batch affects normalization statistics. In the paper, masking padding before convolution helped (dev-other 17.62% → 16.77%), but also masking it in the batch normalization statistics made results slightly worse.
  • Use model.eval() at inference: Batch normalization uses the mean and variance collected during training, and dropout is turned off.
  • Receptive field along time: The surrounding context is determined by kernel size and depth, so unlike an RNN, the model does not see the entire sequence. Kernel sizes grow in higher layers, and Conv2 widens the view with a dilated convolution.

Comparison with Other Models

Comparing end-to-end speech recognition models trained with CTC from the same angles gives the following.

ModelYearEncoderHow it captures temporal contextParameters (best LibriSpeech model)Output mechanism
Deep Speech 220152D convolution + deep bidirectional RNNWhole sequence via RNNAbout 100 millionCTC
Jasper20191D convolutions only (up to 54 layers)Stacked convolutions333 millionCTC
QuartzNet20191D time-channel separable convolutionsStacked convolutions (kernels about 3x larger)18.9 millionCTC
Conformer2020Attention + convolutionWhole sequence via attention + local via convolution118.8 million (L)RNN-Transducer in the paper

Rough guidelines for choosing are as follows.

  • You want simple, convolution-only speech recognition that runs fast on GPUs: Jasper's design is an easy-to-understand starting point. It has few components, and its operations are easy to fuse at inference.
  • You want fewer parameters or to run on devices: QuartzNet, which replaces Jasper's convolutions with depthwise separable convolutions, is a good fit. In its paper, it reached about the same word error rate with about 1/18 the parameters of Jasper DR 10x5.
  • Accuracy comes first: Designs that combine attention and convolution, such as Conformer, later became mainstream. Evaluation is generally compared by word error rate (WER).

PyTorch example

Show code
python
import torch
import torch.nn as nn
import torch.nn.functional as F


class SubBlock(nn.Module):
  """Sub-block: 1D convolution → batch normalization → ReLU → dropout"""
  def __init__(self, c_in, c_out, k, dropout, dilation=1, stride=1):
    super().__init__()
    pad = dilation * (k // 2)
    self.conv = nn.Conv1d(c_in, c_out, k, stride=stride, padding=pad, dilation=dilation, bias=False)
    self.bn = nn.BatchNorm1d(c_out)
    self.drop = nn.Dropout(dropout)

  def forward(self, x):
    return self.drop(F.relu(self.bn(self.conv(x))))


class JasperBlock(nn.Module):
  """R sub-blocks. In the last one, the residual (1×1 conv → BN) is added to the BN output before ReLU and dropout"""
  def __init__(self, c_in, c_out, k, R, dropout):
    super().__init__()
    layers = []
    for i in range(R - 1):
      layers.append(SubBlock(c_in if i == 0 else c_out, c_out, k, dropout))
    self.subs = nn.Sequential(*layers)
    self.last_conv = nn.Conv1d(c_out if R > 1 else c_in, c_out, k, padding=k // 2, bias=False)
    self.last_bn = nn.BatchNorm1d(c_out)
    self.res = nn.Sequential(nn.Conv1d(c_in, c_out, 1, bias=False), nn.BatchNorm1d(c_out))
    self.drop = nn.Dropout(dropout)

  def forward(self, x):
    h = self.last_bn(self.last_conv(self.subs(x)))
    return self.drop(F.relu(h + self.res(x)))


class Jasper(nn.Module):
  """Jasper BxR (the 10x5 setting from Table 1 of the paper; repeat=2 repeats B1-B5 twice each)"""
  def __init__(self, n_feats=64, n_labels=29, R=5, repeat=2):
    super().__init__()
    # (kernel, channels, dropout)
    cfg = [(11, 256, 0.2), (13, 384, 0.2), (17, 512, 0.2), (21, 640, 0.3), (25, 768, 0.3)]
    self.conv1 = SubBlock(n_feats, 256, 11, 0.2, stride=2)
    blocks, c = [], 256
    for k, ch, p in cfg:
      for _ in range(repeat):
        blocks.append(JasperBlock(c, ch, k, R, p))
        c = ch
    self.blocks = nn.Sequential(*blocks)
    self.conv2 = SubBlock(c, 896, 29, 0.4, dilation=2)
    self.conv3 = SubBlock(896, 1024, 1, 0.4)
    self.conv4 = nn.Conv1d(1024, n_labels, 1)  # characters + CTC blank

  def forward(self, feats):
    # feats: (batch, feature dim, time)
    x = self.conv3(self.conv2(self.blocks(self.conv1(feats))))
    return self.conv4(x)  # (batch, num labels, time)


# Example of computing the CTC loss with a smaller setting (R=3, once each = Jasper 5x3)
model = Jasper(R=3, repeat=1)
ctc = nn.CTCLoss(blank=0, zero_infinity=True)

feats = torch.randn(2, 64, 400)                  # 2 utterances, 64 dims, 400 frames
targets = torch.randint(1, 29, (2, 50))          # 0 is the blank, so it is not used
model.train()
logits = model(feats)                            # (2, 29, 200); Conv1's stride 2 halves the time steps
log_probs = logits.permute(2, 0, 1).log_softmax(-1)  # CTCLoss expects (time, batch, num labels)
input_lengths = torch.full((2,), log_probs.size(0), dtype=torch.long)
target_lengths = torch.full((2,), 50, dtype=torch.long)
loss = ctc(log_probs, targets, input_lengths, target_lengths)
loss.backward()

# Inference: batch norm uses training statistics and dropout is off. Greedy decoding takes the max at each time step
model.eval()
with torch.no_grad():
  best = model(feats).argmax(dim=1)              # (2, 200); then remove repeated symbols and blanks

FAQ

Q. Why can Jasper recognize speech with convolutions alone, without an RNN?
A.

Because when 1D convolutions along the time axis are stacked deeply, higher layers see a wider span of time. In Jasper 10x5, kernel sizes grow from 11 to 25 toward the top, and a dilation-2 convolution (kernel 29) is used at the end. Unlike an RNN, all time steps can be computed simultaneously, so training and inference run fast on GPUs.

Q. What does the "10x5" in Jasper mean?
A.

It is the number of blocks B=10B = 10 and the number of sub-blocks per block R=5R = 5. Jasper 10x5 has 10 blocks made by repeating five kinds of blocks, B1 to B5, twice each, and each block has five sub-blocks. Adding one preprocessing convolution and three postprocessing convolutions gives 10×5+4=5410 \times 5 + 4 = 54 convolutional layers in total.

Q. How do Jasper and QuartzNet differ?
A.

QuartzNet is based on Jasper and replaces the standard 1D convolution with a "time-channel separable convolution" split into a depthwise convolution and a pointwise (1×11 \times 1) convolution. Because this greatly reduces the weights, even with kernels about 3 times wider, QuartzNet 15x5 has 18.9 million parameters, about 1/18 of Jasper DR 10x5 (333 million). Even so, its word error rate on LibriSpeech was about the same.

References

  1. Li, J., Lavrukhin, V., Ginsburg, B., Leary, R., Kuchaiev, O., Cohen, J. M., Nguyen, H., & Gadde, R. T. (2019). Jasper: An End-to-End Convolutional Neural Acoustic Model. INTERSPEECH 2019. arXiv:1904.03288.
  2. Kriman, S., Beliaev, S., Ginsburg, B., Huang, J., Kuchaiev, O., Lavrukhin, V., Leary, R., Li, J., & Zhang, Y. (2019). QuartzNet: Deep Automatic Speech Recognition with 1D Time-Channel Separable Convolutions. arXiv:1910.10261.
  3. PyTorch. torch.nn.CTCLoss documentation.