Modelresearch
wav2vec 2.0
Also called wav2vec2.
Self-supervised speech pretraining that masks latent frames and learns to pick the true quantized latent among distractors by contrastive loss.
wav2vec 2.0 learns speech representations from raw audio without transcripts and then turns them into a recognizer with very little labeled data. A convolutional feature encoder maps the waveform to latent vectors, about one every 20 ms. Some spans of these latents are masked, and a Transformer reads the masked sequence. For each masked position, the model must pick out the true latent, discretized by a learned quantizer, from 100 distractors taken from other masked positions of the same utterance. This is a contrastive task, in the spirit of masked language modeling but with speech units that the model learns itself. After pretraining, a linear layer and a CTC loss fine-tune the network on transcribed speech. With ten minutes of labeled audio it reached word error rates that earlier systems needed hundreds of hours for.
The machine
Feature encoder. Seven 1-D convolution layers with 512 channels, strides and kernel widths , map 16 kHz audio to latent vectors . The total stride is samples, 20 ms, so there are about 49 vectors per second, and each sees samples, 25 ms of audio.
Context network. A Transformer reads the latents, after a projection, and outputs context vectors . Instead of fixed position embeddings, a convolution with kernel size 128 and 16 groups adds relative position information. The paper has two sizes:
| model | blocks | width | feedforward width | heads | parameters |
|---|---|---|---|---|---|
| BASE | 12 | 768 | 3072 | 8 | 95 M |
| LARGE | 24 | 1024 | 4096 | 16 | 317 M |
Quantization module. It maps each to a discrete code , the training target. There are codebooks with entries each. A linear layer maps to logits , and one entry is chosen from each codebook by a Gumbel softmax: in the forward pass the entry with the largest , where is Gumbel noise (the Gumbel-max trick), and in the backward pass the gradient of the softmax with temperature (the straight-through estimator). The temperature falls from 2 to 0.5 (BASE) or 0.1 (LARGE) during training. The chosen entries are concatenated and mapped linearly to . This gives possible codes, as in product quantization.
Masking. Each time step is chosen as a span start with probability , and the steps from each start are masked; spans may overlap. The masked are replaced by one learned vector before the Transformer. About of the steps end up masked, in spans of 14.7 steps on average.
Objective. For each masked step , with the cosine similarity , a temperature and a set that holds and distractors sampled from other masked steps of the same utterance,
A diversity loss , where is the softmax probability of entry averaged over a batch, rewards using all codebook entries. The loss is .
Fine-tuning. A linear layer on the context vectors maps to the output symbols (for LibriSpeech, 29 characters plus a word boundary token), and the model is trained with the CTC loss on the labeled data. Decoding may add an n-gram or Transformer language model.
Example. Take 2 seconds of audio: samples give about 99 latent vectors. With , about 6 or 7 span starts are drawn, and their 10-step spans mask roughly half of the vectors. Each masked position gives one 101-way classification: its own quantized latent against 100 others from the masked positions of the same 2 seconds.
What it counts
Pretraining gives a network whose context vectors are a representation of the audio around ; it does not output text. Fine-tuning with CTC turns it into a recognizer, with from the CTC forward algorithm. The cost per utterance of latent steps is for the feature encoder, for a Transformer of blocks and width , for the quantizer, and for the contrastive loss over masked steps. The self-attention term dominates for long inputs.
Relation to other models
- BERT and masked language modeling. Both mask parts of the input and predict them from the context. Text has a fixed vocabulary of tokens; speech has none, so wav2vec 2.0 learns the units by quantization and uses a contrastive loss instead of a softmax over a vocabulary.
- Contrastive predictive coding and noise contrastive estimation. The loss picks the true target among sampled distractors, a contrastive method in the same family.
- CTC. The fine-tuning loss. Other heads, such as a transducer or an attention decoder, can also be put on the pretrained encoder.
- SpecAugment. The masking of time spans in the latent space resembles the time masks of SpecAugment, but here the masked spans are the prediction targets, not only noise.
- Hybrid and supervised end-to-end models. They need many hours of transcribed audio. wav2vec 2.0 moves most of the learning to unlabeled audio.
Known results in the model
- LibriSpeech with little labeled data. With the LARGE model pretrained on the largest unlabeled set and a language model in decoding, Baevski et al. (2020) report word error rates of 4.8% on test-clean and 8.2% on test-other with 10 minutes of labeled data, 2.0% and 4.0% with 100 hours, and 1.8% and 3.3% with all 960 hours (measurements).
- Masking statistics. With and , the expected fraction of masked steps is for steps far from the ends (a calculation, which matches the 49% the paper reports).
- Feature rate. The feature encoder has a stride of 20 ms and a receptive field of 25 ms (a property of the layer sizes).
- Number of codes. Two codebooks of 320 entries give codes, of which the diversity loss pushes the model to use many (a property of the construction).
References
- The model, the quantization module, the masking, the contrastive and diversity losses, fine-tuning with CTC and the LibriSpeech results, Section 2 (feature encoder, contextualized representations, quantization module), Section 3 (masking, the objective, fine-tuning), Section 4 (the setup, BASE and LARGE) and Section 5 (results with 10 minutes to 960 hours of labeled data)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W3 standard |
|
Tag HA15NQ Edit this page History Report an error Markdown