Advanced techniques
Masked Modeling and Predictive Pretraining
Study masked language models, masked autoencoders, temporal prediction, and the tradeoff between semantic structure and low-level reconstruction.
By the end you can
- Explain why masking creates a scalable self-supervised prediction problem
- Compare token masking, patch masking, reconstruction, and latent prediction
- Relate mask ratio and decoder design to task difficulty and compute
- Evaluate whether predictive pretraining transfers beyond the reconstruction objective
Prediction from partial evidence
Masked modeling removes part of an observation. It asks the model to infer what is missing from context. In language, a token can often be predicted from surrounding syntax and semantics. In images, missing patches can be reconstructed from objects, texture, and spatial layout. In sensor streams, a hidden interval can be predicted from temporal patterns. The method forces the encoder to represent dependencies that make the hidden content predictable.
But the target matters, and two systems show how much. BEiT kept the corruption and changed only what was reconstructed. Pixels went out, discrete visual tokens from a learned tokenizer came in: “The pre-training objective is to recover the original visual tokens based on the corrupted image patches.” The payoff is in the same abstract — “base-size BEiT achieves 83.2% top-1 accuracy on ImageNet-1K, significantly outperforming from-scratch DeiT training (81.8%) with the same setup”. An independent group, the masked-autoencoder authors, lists BEiT's ViT-B result at that same 83.2 and records that “BEiT reported a 1.8% degradation [2] when reconstructing pixels with ViT-B”. Same patches, same corruption, different target, 1.8 points.
data2vec moved the target off the input entirely. Published in 2022, it “predicts contextualized latent representations that contain information from the entire input” rather than words, pixels or visual tokens. Its authors then asked which internal layer should supply those representations. “Table 5 shows that the output of the feed-forward network (FFN) block works best while the output of the self-attention block does not yield a usable model.” On Librispeech, feed-forward-block targets give 13.1 WER. Self-attention-block targets give 100.0. Not a worse model — no model. Nothing changed between those two rows except which tensor was being predicted.
A powerful decoder can also absorb too much of the reconstruction burden, allowing the encoder to remain weak. Masking policy, mask ratio, target representation, and decoder capacity jointly define the learning problem. They should be selected with downstream use in mind rather than copied from another modality.
The target is not a detail of the objective: 13.1 WER against 100.0, changing only which block supplied it.
Case
Fifteen percent of a sentence, seventy-five percent of an image
Fifteen percent is the number everyone copied, and BERT set it in 2019. The paper is plain about it: “In all of our experiments, we mask 15% of all WordPiece tokens in each sequence at random.” Not every chosen position is corrupted the same way. The generator “chooses 15% of the token positions at random for prediction”, then replaces the chosen token with “the [MASK] token 80% of the time (2) a random token 10% of the time (3) the unchanged i-th token 10% of the time”. Even inside the 15%, the mask token does not cover everything.
Images tolerate far more. Masked autoencoders removed 75% of the patches and reconstructed the missing pixels, reporting that “masking a high proportion of the input image, e.g., 75%, yields a nontrivial and meaningful self-supervisory task”. The encoder is asymmetric — it is the one “that operates only on the visible subset of patches (without mask tokens)” — and that let the authors “accelerate training (by 3x or more) and improve accuracy”. Accuracy went up as well as speed: “a vanilla ViT-Huge model achieves the best accuracy (87.8%) among methods that use only ImageNet-1K data”. They put the gap down to information density. Language is “highly semantic and information-dense”. Images are “natural signals with heavy spatial redundancy”.
The trap is to read 15% as the answer for text. Wettig and colleagues tested it directly in 2023, in a paper titled Should You Mask 15% in Masked Language Modeling? Their answer: “Specifically, we find that masking 40% outperforms 15% for BERT-large size models on GLUE and SQuAD. Interestingly, an extremely high masking rate of 80% can still preserve 95% fine-tuning performance and most of the accuracy in linguistic probing, challenging the conventional wisdom about the role of the masking rate.” The most-copied ratio in the field is not the optimum even for the modality it came from. At BERT-large scale a rate more than twice as high beats it, and a rate more than five times as high still keeps 95% of fine-tuning performance.
Visual
The four design decisions in a masked objective
Changing any one of these can alter both compute and representation quality, and two of the four have been measured with everything else held fixed.
What to predict. I-JEPA ran that comparison with one line changed. With a ViT-L/16, computing the loss on target-encoder outputs gave 66.9% top-1 on the 1%-ImageNet-1K linear evaluation after 500 epochs. Computing the same loss in pixel space gave 40.7% after 800 epochs. The worse number is the one that cost more epochs. “From Table 7, it is clear that predicting in pixel-space leads to a significant degradation in the linear probing performance.”
Where to reconstruct. SimMIM swept the prediction head on a Swin-B backbone, from a single linear layer up to an inverse Swin-B. Heavier heads reconstructed better and transferred worse: “While generally heavier heads produce slightly lower losses, for example, 0.3722 (inverse Swin-B) versus 0.3743 (a linear layer), the transferring performances on the down-stream ImageNet-1K task are lower. It indicates that stronger inpainting capability does not necessarily result in better down-stream performance.” The inverse Swin-B head carries 174.8M parameters and 2.3x the training cost, and fine-tunes to 82.5% top-1 against the linear layer's 82.8%. The authors' own summary of the sweep: “the prediction head can be as light as a linear layer, with no worse performance than heavier ones”.
What to hide
Tokens, patches, spans, channels, frames, or graph elements.
How much to hide
The mask ratio determines task ambiguity and encoder workload.
What to predict
Raw input, discrete codes, teacher features, or latent targets.
Where to reconstruct
A lightweight or powerful decoder changes what the encoder must retain.
Masking is not one method; it is a family defined by corruption and target choices.
Comparison
How masking differs across modalities
The same headline idea produces different engineering and semantic pressures. The temporal column is the one most often asserted rather than shown, so it is worth naming a system. wav2vec 2.0 arrived in 2020. It masks the speech input in latent space rather than the raw waveform, and fine-tuned on all of Librispeech it reaches 1.8/3.3 WER on test-clean/test-other. The result that shows what the pretraining actually bought is the low-label one: “Using just ten minutes of labeled data and pre-training on 53k hours of unlabeled data still achieves 4.8/8.2 WER.” Ten minutes of transcription set against 53,000 hours of unlabelled audio. That is the argument for temporal masking, in a form a reader can go and check.
Text masking
Hide tokens and predict vocabulary identities from bidirectional context.
- Targets are discrete symbols
- Context carries syntax and semantics
- Masking creates a train–fine-tune mismatch
- Example: BERT-style pretraining
Image patch masking
Hide a high fraction of patches and reconstruct pixels or features.
- Spatial redundancy supports high mask ratios
- Asymmetric encoders save compute
- Pixel targets may emphasize texture
- Example: masked autoencoders
Temporal masking
Hide spans or predict future latent structure in sequences.
- Natural for audio, video, and sensors
- Must avoid future leakage in evaluation
- Target horizon changes difficulty
- Useful for event and state representations
Key idea
Temporal prediction can accidentally see the future
When masked or predictive objectives are applied to logs and sequences, the code that builds the features can leak future events. Normalization windows, aggregations, bidirectional context and overlapping examples are the usual routes. A pretraining setup may be valid for retrospective representation learning and invalid for an online forecasting use case.
Document the information boundary for each downstream task. If production predictions are causal, include causal or past-only pretraining variants in the comparison rather than assuming bidirectional context is deployable.
The legal context window is part of the problem definition, not merely an architecture choice.
Example
What happens when the design moves too far
The optimal difficulty is empirical and modality dependent. Each of these failure modes has been measured somewhere, and the measurement is what tells you which direction you are failing in.
- Mask ratio too low: the task may be solved through local interpolation with little semantic understanding — Wettig and colleagues found that masking 40% outperforms 15% for BERT-large size models on GLUE and SQuAD.
- Mask ratio too high: the target may become underdetermined or optimization unstable, though the ceiling sits higher than the folklore ratio implies — the same authors found that an 80% masking rate still preserves 95% of fine-tuning performance and most of the accuracy in linguistic probing.
- Decoder too strong: reconstruction quality can improve while encoder transfer gets worse — SimMIM's inverse Swin-B head (174.8M parameters, 2.3x the training cost) reached a lower pre-training loss than a single linear layer, 0.3722 against 0.3743, and a lower ImageNet-1K fine-tuning top-1, 82.5% against 82.8%.
- Raw target too detailed: the model may spend capacity on nuisance texture or sensor noise — I-JEPA's ViT-L/16 scored 66.9% on the 1%-ImageNet-1K linear evaluation from target-encoder outputs and 40.7% from pixels.
- Mask pattern too regular: the encoder can exploit positional artifacts instead of contextual structure — in Table 6 of the same I-JEPA paper, rasterized quadrant masking reached 15.5% top-1 where multi-block masking reached 54.2%.
- Evaluation too narrow: a flat number on one protocol can hide the whole effect — across masked-autoencoder decoder depths of 1, 2, 4, 8 and 12 blocks, fine-tuning accuracy reads 84.8%, 84.9%, 84.9%, 84.9% and 84.4%, while linear probing on the same runs reads 65.5%, 70.0%, 71.9%, 73.5% and 73.3%.
Analogy
Restoring a damaged document
A restorer working on a document with missing words and torn images reads grammar, layout, topic, and nearby clues. Local patterns may recover one missing letter. A damaged paragraph requires broader context. When too much is missing, several restorations can remain plausible.
The restorer is trying to recover what the page meant. A model can optimize token or pixel accuracy without ever reaching the interpretation a human cares about, so a downstream test must show that the skill produced reusable understanding.
Mask difficulty should force useful context modeling without making the target arbitrary.
Steps
A masked-pretraining ablation plan
Ablations reveal which part of the objective creates transfer value, and step 4 is the one whose result is easiest to miss. The masked-autoencoder paper ran exactly that sweep: a ViT-L/16 on ImageNet-1K, decoder depths of 1, 2, 4, 8 and 12 Transformer blocks. Linear probing reads 65.5%, 70.0%, 71.9%, 73.5% and 73.3%. Fine-tuning over the same five runs moves only between 84.8%, 84.9%, 84.9%, 84.9% and 84.4%. The authors' summary is one sentence: “A sufficiently deep decoder is important for linear probing.” An 8-point swing under one protocol is invisible under the other. A sweep reported through a single evaluation can conclude that the component does not matter. Step 5 has a concrete case behind it too: wav2vec 2.0 shows the transfer value at its largest with ten minutes of labelled data, not with the full corpus.
1. Fix the encoder and data
Change one objective component at a time.
2. Sweep mask ratio
Measure compute, pretraining loss, and downstream transfer.
3. Compare target types
Test raw reconstruction against discrete or latent targets.
4. Vary decoder capacity
Check whether a strong decoder hides a weak encoder.
5. Evaluate several label budgets
Transfer value may be largest in low-label regimes.
6. Test causal compatibility
Match the allowed context to production constraints.
Comparison
What should be hidden, corrupted, or predicted?
Corruption design controls whether the model learns local repair, global semantics, or temporal structure. At a fixed backbone and budget, the pattern alone can outweigh most other choices. I-JEPA held the model and the schedule constant — ViT-B/16, 300 epochs, linear evaluation on 1% of ImageNet-1K — and varied only the masking strategy. Multi-block masking reached 54.2% top-1. Single-block masking reached 20.2%, random masking 17.6%, rasterized quadrant masking 15.5%. The caption of Table 6 states the conclusion plainly: “The proposed multi-block masking strategy is helpful for guiding I-JEPA to learn semantic representations.” One caveat belongs with the figures. The context budget is not identical across the four rows: Table 6 lists an average context ratio of 0.25 for multi-block and rasterized masking and 0.40 for block and random masking. So this compares masking strategies as configured, not patterns at a fixed number of visible patches. Even with that qualification, the spread from 15.5% to 54.2% comes from the corruption policy and nothing else in the architecture.
Sparse masking
Hide a modest fraction of tokens, patches, or measurements.
- Preserves abundant local context
- Can reward short-range interpolation
- Usually easier to optimize
- Useful when fine detail matters
Aggressive masking
Remove a large portion of the input.
- Forces broader context use
- Raises ambiguity and optimization difficulty
- Can emphasize semantic structure
- May discard small but important signals
Future or cross-view prediction
Predict another time step, modality, or representation.
- Targets temporal or cross-modal consistency
- Depends on alignment quality
- Can learn dynamics or shared factors
- Risks exploiting synchronization shortcuts
Key takeaways
- Masked modeling predicts hidden content from observed context; the corruption policy and the prediction target are the supervision.
- Published mask ratios are starting points, not answers — Wettig and colleagues found 40% beats BERT's 15% for BERT-large size models on GLUE and SQuAD, and 80% still preserves 95% of fine-tuning performance.
- Raw reconstruction and latent prediction emphasise different information. I-JEPA's ViT-L/16 scored 66.9% on the 1%-ImageNet-1K linear evaluation from target-encoder outputs and 40.7% from pixels. data2vec's Librispeech targets gave 13.1 WER from feed-forward-block outputs against 100.0 from self-attention-block outputs.
- A low pretraining loss does not guarantee a transferable encoder — SimMIM's inverse Swin-B head reached 0.3722 against a linear layer's 0.3743 and still fine-tuned to 82.5% against 82.8%.
- Temporal and bidirectional objectives must respect production information boundaries.
- Ablations across mask ratios, targets, decoder strength and evaluation protocol are central: masked-autoencoder decoder depth moves linear probing from 65.5% to 73.5% while fine-tuning stays inside 84.4-84.9%.