↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Block 1 of 24 every third block recorded frames 0–-1 of 101 (20 ms each) · 16 heads · RoPE · depthwise kernel 31 on each of 1024 channels
Loading recorded Conformer block…

What a Conformer is

Speech has structure at two scales. Over a few tens of milliseconds, formants and the transitions between phones are local patterns, the kind a convolution captures well. Across an utterance, what a sound is depends on content far away, the kind attention captures well. The Conformer (Gulati et al., 2020) puts both in every block: self-attention for global, content-based interactions and a convolution module for local ones. On LibriSpeech the paper reports word error rates of 2.1 % and 4.3 % on test and test-other without a language model.

The page records Wav2Vec2-Conformer large: a wav2vec 2.0 speech encoder of 24 Conformer blocks with rotary position embeddings, fine-tuned on 960 hours of LibriSpeech to transcribe speech. Its input is a LibriSpeech clip, “WHERE IS MY BROTHER NOW”, which the feature encoder turns into 101 frames of 20 ms. Each example is a 24-frame window of the same run, and every third block is recorded.

The block

A Conformer block puts attention and convolution between two half-step feed-forward layers, a layout the paper takes from Macaron-Net:

Each sublayer normalises its input and adds its output back to the residual stream. The page follows the stream from the attention card into the convolution module, one column per step.

The convolution module

Inside , each step has its own column:

  • Pointwise · GLU: after a LayerNorm, a 1 × 1 convolution widens each frame from 1,024 to 2,048 channels, and a gated linear unit halves it again, , one half gating the other.
  • Depthwise conv: each of the 1,024 channels is convolved over time with its own kernel of 31 taps; channels do not mix.
  • BatchNorm · Swish: batch normalisation, then .
  • Pointwise: a second 1 × 1 convolution, 1,024 → 1,024, mixes the channels again before the residual add.

Only the depthwise convolution mixes frames. The pointwise convolutions and the gate act on each frame separately, so all of the module's sense of time sits in 31 numbers per channel.

A convolution is a fixed matrix

For one channel with kernel and input , the depthwise convolution is

centred on the frame, because the encoder sees the whole clip at once, and zero past the clip's ends. Written for all frames at once it is a banded Toeplitz matrix: the same 31 taps on every row, shifted one place per row, and zero more than 15 frames from the diagonal. At 20 ms a frame, 31 frames span 0.62 s.

The Depthwise conv card draws the 24 × 24 block of that matrix inside the window for one channel; its pager steps through the 16 channels with the largest kernels, and the plot beside it shows the selected frame's row. Taps that reach frames outside the window add an edge term, which the row's popup reports, so that the row reproduces the recorded output. Above all, the matrix does not depend on the audio: the same weights apply to every clip and every frame.

Attention beside it

The Self-attention card shows the same block's attention for one head over the same window, , with the rotary embedding applied to the block input before the query and key projections. Its softmax runs over all 101 frames, so a row's weights inside the window need not sum to one; the popup gives the share that falls inside. Unlike the convolution's, these weights change with the audio.

Comparing the two cards is the point of the design. The convolution gives every frame the same local filter, whatever was said; attention lets each frame pick other frames by what they contain, at any distance. Stepping through the blocks shows how both change with depth.

Where it came from

By 2020 both Transformer and convolutional acoustic models were strong; the Conformer combined them and became a common encoder for speech recognition. wav2vec 2.0 (Baevski et al., 2020) pre-trains a speech encoder without transcripts, by masking stretches of frames and picking the right quantised target among distractors; fairseq's speech-to-text toolkit (Wang et al., 2020) later offered Conformer blocks in that encoder, which gives the model recorded here. The convolution module's relatives have their own tabs: Hyena mixes with one long causal filter per channel, ConvNeXt with a depthwise 7 × 7 convolution over image patches.

Papers

  1. Conformer: Convolution-augmented Transformer for Speech Recognition Anmol Gulati et al. · Interspeech 2020 The Conformer block: half-step feed-forward layers around self-attention and a convolution module.
  2. wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli · NeurIPS 2020 Self-supervised pre-training of the speech encoder that the recorded model is built on.
  3. fairseq S2T: Fast Speech-to-Text Modeling with fairseq Changhan Wang et al. · AACL 2020 fairseq's speech-to-text toolkit with Conformer encoders; Hugging Face cites it for the Wav2Vec2-Conformer checkpoints recorded here.
  4. Librispeech: An ASR corpus based on public domain audio books Vassil Panayotov, Guoguo Chen, Daniel Povey, Sanjeev Khudanpur · ICASSP 2015 The read-speech corpus the model was fine-tuned on and the clip on this page comes from.
  5. RoFormer: Enhanced Transformer with Rotary Position Embedding Jianlin Su et al. · arXiv 2021 Rotary position embeddings, the positions of the recorded model's attention.
  6. Language Modeling with Gated Convolutional Networks Yann N. Dauphin, Angela Fan, Michael Auli, David Grangier · ICML 2017 The gated linear unit that opens the convolution module.
  7. Searching for Activation Functions Prajit Ramachandran, Barret Zoph, Quoc V. Le · arXiv 2017 Swish, x times its sigmoid, the activation after the module's BatchNorm.

See also