TL;DR
data2vec is one learning recipe that works for speech, images and text. A student network sees a masked version of an input and must predict the hidden representations that a teacher network computes from the full, unmasked input. The targets are averages of several internal layers, so they carry context from the whole input rather than a single patch or word. The paper reports state-of-the-art or competitive results in all three modalities.
Builds on: Masked Autoencoder, Exponential Moving Average, Knowledge Distillation · Leads to: the later work on general self-supervised objectives across modalities
Why it mattered
Before data2vec, each modality had its own self-supervised recipe. Speech models such as wav2vec 2.0 and HuBERT predicted discrete speech units. Vision models predicted visual tokens, raw pixels or augmentation-invariant features. Text models predicted words or sub-words. data2vec showed that one objective, with only the input encoder changed, could match or beat the specialised recipes. In the paper's ImageNet-1K tests a ViT-B model reached 84.2 top-1 accuracy, above the single-model masked-prediction baselines listed in its Table 1. The paper also argues that a shared objective makes later multi-modal learning simpler, though it does not train across modalities itself.
The problem
Self-supervised learning needs a target that the model must predict from the data itself. Each modality has trouble with that. Speech has no natural vocabulary of units, so models first learn a set of discrete units. Images have no words, so models learn visual tokens or regress raw pixels, which are local and noisy. Text targets are fixed tokens, and a BERT-style model learns one embedding per token that must fit every use of that token.
The paper's question is whether a target can be defined without any of these modality-specific choices. Its answer is to use continuous, contextual representations that the model computes for itself, so no vocabulary, tokenizer or pixel reconstruction is needed.
How it works
The method has one network used in two modes, and one training loop. Here is the pipeline for one training example.
- Embed the input. A modality-specific encoder turns the input into a sequence of tokens. For images, the input is split into 16 by 16 pixel patches, giving 196 tokens for a 224 by 224 image. For speech, a stack of seven 1-D convolutions maps 16 kHz audio to 50 tokens per second. For text, sub-word units are embedded with learned vectors.
- Make the teacher target. Feed the unmasked tokens through the teacher. The teacher is a copy of the student whose weights are a slow moving average of the student's weights. Record the output of each of the top Transformer blocks at every time step.
- Normalise and average the layers. Normalise each block's output, then average the top of them at each time step. The average is the target for time step .
- Mask the student input. Replace some tokens with a learned MASK embedding. For images, mask blocks of adjacent patches covering about 60 percent of the image. For speech, mask spans of about ten steps, which masks about 49 percent of the sequence. For text, mask 15 percent of tokens, or spans of four tokens.
- Predict the targets. Run the masked sequence through the student. At the masked positions only, its prediction is compared with using a regression loss.
- Update. Update the student with gradient descent. Update the teacher as the moving average of the student. Repeat over the dataset.
flowchart LR X[input] --> E1[modality encoder] E1 --> T[teacher: unmasked, slow average of student] T --> A[average top K blocks, normalised] E1 --> M[mask some tokens] M --> S[student] S --> P[prediction at masked steps] A --> L[regression loss] P --> L L -->|update| S S -->|moving average| T
Two details matter. First, the targets are contextual: the teacher has self-attention over the whole input, so the target for a masked patch or frame already depends on the rest of the sample. Second, the loss is computed only at masked positions, so the student must infer what it cannot see.
The math
Let be the student parameters and the teacher parameters. After each step the teacher updates as , where is close to 1. In words: the teacher keeps most of its old value and takes a small step toward the student.
Step 2 in symbols: the teacher target
Let be the output of block at time step in the teacher. Normalise each block to get . With blocks in total, the target for step is the average over the top blocks:
The paper uses for ViT-B and ViT-L, for speech Base, for NLP and for the AudioSet speech model.
Step 5 in symbols: the loss
The paper uses a Smooth L1 loss with transition point . For a gap :
Small gaps are penalised quadratically, as in a squared loss. Large gaps are penalised linearly, which makes the loss less sensitive to outliers. The paper uses for vision, for NLP, and an L2 loss for speech.
Worked examples
- Suppose and, at one masked time step, the normalised outputs of the top two blocks are 2 and 4.
- Average them: .
- The student predicts , so the gap is .
- Use . Since , use the quadratic branch: .
The loss is small because the gap is small compared with .
- Speech is encoded at 50 frames per second, so one second has 50 time steps.
- Take 100 time steps. Each step is chosen as a span start with probability , and each start masks the next ten steps.
- Expected number of span starts: .
- If spans did not overlap, steps would be masked.
- Spans do overlap, so the real fraction is lower. The paper reports that about 49 percent of steps are masked for a typical training sequence.
The example shows why the paper's number is below the naive estimate: overlapping spans cover the same steps twice.
- The speech encoder has a receptive field of 400 input samples. At 16 kHz that is seconds, or 25 milliseconds.
- Its output stride is about 20 milliseconds, which is samples per output step.
- Take a 3-second clip. It has encoder steps.
- About 49 percent are masked: , so roughly 74 steps.
- The student therefore sees about 76 of the 150 steps and must predict the other 74 from the context around them.
Try it: a clip is 10 seconds long. How many encoder steps are there, and roughly how many are masked? Answer: 500 steps; masked steps.
Results
The paper reports results in four places. All numbers below are copied from the paper's tables.
- Images (Table 1). ImageNet-1K top-1 accuracy, single models. ViT-B: data2vec 84.2, MaskFeat 84.0, SimMIM 83.8, iBOT 83.8, MAE 83.6. ViT-L: data2vec 86.6, MaskFeat 85.7, MAE 85.9. The paper calls data2vec the best single model for both sizes. Note that the multi-model rows (BEiT, PeCo) use extra tokenizers or distillation, so they are not directly comparable.
- Speech (Table 2). Word error rate on Librispeech test-other, LS-960 pre-training, 4-gram language model. Base models with 10 minutes of labels: data2vec 12.3, wav2vec 2.0 15.6, HuBERT 15.3. Base models with 960 hours of labels: data2vec 5.5, wav2vec 2.0 6.1. Large models with 10 minutes: data2vec 8.4, HuBERT 10.1. For Large models with 960 hours, data2vec 3.7 ties HuBERT 3.7 and is behind wav2vec 2.0 at 3.6, so it is not the best there. The paper describes the resource-rich settings as comparable.
- Audio events (Table 3). AudioSet mAP: data2vec 34.5, MaskSpec 32.3, SSAST 31.0.
- Language (Table 4). GLUE development average: data2vec 82.7, RoBERTa baseline 82.5, BERT 80.7. With wav2vec 2.0 span masking, 82.9. The paper's own comparison is against its retrained RoBERTa baseline, and the average gain is 0.2 points.
Two ablations matter for understanding the method. Table 5 shows that targets from the feed-forward output (FFN) give a word error rate of 13.1, while targets from the self-attention output alone give 100.0, which the paper calls unusable. Figure 2 shows that averaging several layers beats predicting only the top layer for all three modalities, with the largest effect for speech and text.
Limits. The paper does not train one model on several modalities. Each modality still uses its own encoder and masking strategy, and some settings add extra choices (DeepNorm and layer-normalised targets for AudioSet, a particular span mask for text). The gains in language are small, and the speech gains are largest in the lowest-label settings.
Reading guide
- Abstract and Section 1 (Introduction). Needs Self-Supervised Learning and Masked Autoencoder for the masked-prediction idea.
- Section 2 (Related Work). Needs Vision Transformer (ViT) for patches and Transformer for the architecture. Read it for the contrast with BYOL and DINO, which regress the top layer only.
- Section 3.1 (Model architecture). Needs Transformer and Attention Mechanism for the teacher's contextual outputs.
- Section 3.2 and 3.3 (Masking and targets). Needs Exponential Moving Average for the teacher, Layer Normalization and Instance Normalization for normalising targets.
- Section 3.4 (Objective). Needs Knowledge Distillation for the teacher-student idea and the loss of regression to a target.
- Section 4 (Setup). Speech setup relies on wav2vec 2.0 for the feature encoder and masking.
- Section 5 (Results). Read the tables with the caveats above in mind.
Check yourself
QuestionIn data2vec, what is the regression target at a masked time step?Show answer
It is the average of the normalised outputs of the top teacher blocks at that time step. The teacher sees the unmasked input, so the target is contextual, and it is continuous rather than a discrete token or pixel value.
QuestionThe teacher of 'data2vec' updates with . If , and , what is the new ?Show answer
. The teacher moves a small step toward the student.
QuestionWhy does the loss use a Smooth L1 form rather than a plain squared loss?Show answer
A squared loss punishes large gaps very heavily, so a few outlier targets can dominate training. Smooth L1 is quadratic for small gaps, below , and linear for large gaps, so outliers have less influence. The paper notes that must be tuned.
QuestionWhy does the paper average several layers rather than predict only the top layer?Show answer
Different layers hold different kinds of features, and averaging several layers gives a richer target. Figure 2 shows the top-only setting () is worse for all three modalities, and by a wide margin for speech and text.
QuestionFor the speech encoder, one frame covers 320 samples at 16 kHz. What is the frame rate?Show answer
frames per second, which matches the paper's 50 Hz representation.