Towards Understanding Self-Pretraining for Sequence Classification with Transformers

Omar Coser, Loredana Zollo, Paolo Soda, Antonio OrvietoNeurIPS 2026

TL;DR

When you train a Transformer from scratch on sequence classification tasks using only class labels, its core Attention mechanism often completely fails to learn how to connect tokens. However, warming up the model by asking it to reconstruct masked parts of the exact same training dataset—a trick called self-pretraining (SPT)—unlocks massive accuracy gains. This paper opens the black box to show why: label supervision can be mathematically blind to crucial Attention patterns at initialization, whereas SPT forces query-key weights to build a local "proximity bias" that fine-tuning can actually use.

What Problem Does This Paper Address?

For years, Transformers struggled on the Long-Range Arena (LRA)—a benchmark testing how well models handle long sequences—losing out to newer State-Space Models (like S4 and Mamba). Recently, Amos et al. (2024) showed that Transformers weren't fundamentally incapable; they were just poorly initialized. By first pretraining the Transformer to predict masked tokens on the downstream dataset itself (without any external data) before training on labels, accuracy skyrocketed.

Figure 1: Training pipelines for classification. SPT is the method we study here.

While this Self-Pretraining (SPT) pipeline was a great practical fix, it left a nagging mystery: Why does training directly from labels fail so badly in the first place, and what magic is SPT performing on the exact same data to fix it?

Methods

Instead of proposing a new architecture, the authors play detective, using standard pre-norm Transformers (with additive sinusoidal positional encodings and mean-pooling) to isolate where the SPT magic lives:

  • Surgical Ablations: They systematically vary pretraining duration, shrink models down to a single layer, swap pretraining datasets across completely different tasks, freeze Attention layers during from-scratch training, and test "hybrid initializations" (transferring only specific pretrained weights, like query-key matrices $W_Q, W_K$, while resetting the rest to random).
  • Minimal Synthetic Sandbox: They design a stripped-down, 1-layer, bias-free, MLP-free Attention model to visualize exactly how Attention matrices and positional encodings interact during SPT.
  • Theoretical Analysis: They formulate a mathematical abstraction comparing mean-pooled label loss against a token-reconstruction loss around a uniform Attention initialization.

Datasets

  • Long-Range Arena (LRA): Five sequence classification tasks—ListOps, flattened grayscale CIFAR10, PathFinder, Retrieval, and Text. (PathX was excluded due to its $16\times$ higher compute cost).
  • Additional Signals: Human activity and physiological signal classification datasets (detailed in their appendix) to verify SPT beyond LRA.
  • New Synthetic Trajectory Dataset: A custom binary classification task of length-100 2D sequences representing noisy ellipsoidal trajectories oscillating between class-specific anchor points.

Key Insights and Ideas

  • It’s an optimization bottleneck, not a generalization trick: Training from scratch fails to even fit the training data well, and giving it $4\times$ the compute budget doesn't help. Surprisingly, pretraining on a completely different LRA dataset still boosts accuracy, proving SPT primarily rescues the model from a bad random initialization rather than just learning task-specific features.
Figure 3: Depth and dataset-swap ablation. We compare training from scratch, same-dataset SPT, and cross-dataset pretraining before finetuning. SPT can improve both train and test accuracy even for 1-layer models and with swapped pretraining data, pointing to an optimization benefit beyond task-specific representation learning.
  • From-scratch supervision practically ignores Attention: On 4 out of 5 LRA tasks, freezing all Attention weights at random initialization has virtually zero negative impact on from-scratch accuracy (and actually improves CIFAR10!). Label-only training relies almost entirely on the MLPs.
  • $W_Q$ and $W_K$ carry the SPT magic: In 1-layer models, transferring only the self-pretrained query ($W_Q$) and key ($W_K$) matrices—and randomly re-initializing everything else—recovers the entire performance boost of SPT.
  • Undoing positional encodings to build a "proximity bias": At random initialization, softmax Attention is flat and uniform. During SPT, the product $W_Q^\top W_K$ learns to interact with the additive sinusoidal positional encodings to create a sharp, diagonally-dominated Attention map (making tokens attend to their neighbors). Hard-coding this locality (like ALiBi does) helps on local tasks like CIFAR10, but fails on global tasks like PathFinder—showing SPT learns a flexible bias.
  • Why labels are "blind": In Proposition 1, the authors prove that when sequence outputs are mean-pooled for classification, first-order gradients for certain Attention-score directions literally cancel out to zero at uniform initialization. Token reconstruction doesn't pool, so it detects those directions immediately.

Key Results

  • Replicating huge SPT jumps: SPT boosts validation accuracy over from-scratch training across LRA: CIFAR10 jumps from 0.499 to 0.72, PathFinder from 0.67 to 0.85, ListOps from 0.402 to 0.56, and Text from 0.653 to 0.89.
  • Fast warmup: CIFAR10 and ListOps capture nearly their entire SPT accuracy boost after just 10 epochs of pretraining (with gains visible after 1 epoch), whereas PathFinder needs 100+ epochs to organize long-range connectivity.
Figure 2: SPT duration ablation. We vary self-pretraining epochs before 100 epochs of finetuning. CIFAR10 and ListOps benefit af- ter only a few epochs, PathFinder needs longer pretraining.
  • Isolating $Q$ and $K$: In 1-layer models, initializing only $W_Q, W_K$ from SPT matches full-model SPT initialization on both CIFAR10 (0.607 vs. 0.603, compared to 0.486 from scratch) and PathFinder (0.704 vs. 0.705, compared to 0.672 from scratch).

Limitations and Future Work

  • Compute & Seed Constraints: PathX was omitted, and large LRA sweeps used single seeds, with multi-seed runs focused mostly on CIFAR10 and PathFinder.
  • Simplified Theory and Toy Setup: To get clean math and visualizations, the theoretical setup and synthetic task strip away LayerNorm, MLPs, depth, and input-dependent Attention scores. In deep models, cross-layer representation mismatches also play a role.
  • Future Directions: Developing a unified theory of Attention optimization dynamics that accounts for depth, optimizer behavior, and alternative readout strategies—especially since preliminary appendix experiments show that swapping mean-pooling for a learned [CLS] token still suffers from the exact same from-scratch bottleneck.

Summary updated

Abstract

Amos et al. (2024) showed that the accuracy of Transformer models in sequence classification can be significantly improved by first pretraining with a masked token prediction objective without external data or augmentation, a procedure referred to as self-pretraining (SPT). While the primary objective of Amos et al. (2024) was to showcase that Transformers can achieve strong performance on the Long-Range Arena (LRA), their pipeline raises more fundamental questions: How does SPT drive optimization to better solutions? Why can standard supervised training fail in Transformers? To better understand this, we replicate and systematically ablate the findings of Amos et al.~(2024). Our ablations suggest that a central bottleneck in the studied settings is not depth or generalization alone, but the ability of label supervision to learn useful query-key Attention patterns from random initialization. With a minimal setup, we identify learning proximity interactions -- turning absolute positional encodings into proximity-biased Attention scores -- as a key source of the improvements brought by SPT. Finally, in a simplified theoretical setup, we show that label supervision can be locally blind to certain Attention-score directions that are instead detectable through masked reconstruction.
BibTeX
@inproceedings{coser2026towards,
  author = {Omar Coser and Loredana Zollo and Paolo Soda and Antonio Orvieto},
  title = {{Towards Understanding Self-Pretraining for Sequence Classification with Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=XC2lHn0w5A},
}
Figure