SpecFormer: Mitigating Embedding and Attention Collapse via Spectral-Aware Transformer for Recommendation

Yu Cui, Yi Xu, Jiahao Wang, Hao Zhang, Yu Zhang, Xiaoyi Zeng, Can Wang, Jinxin Hu, Jiawei ChenarXiv 2026

TL;DR

While Transformer architectures excel in language and vision tasks, directly applying them to recommender systems often leads to severe performance degradation due to "embedding and attention collapse." This paper introduces SpecFormer, a spectral-aware Transformer that breaks the vicious cycle of rank collapse by performing feature interactions within a dynamically softened spectral domain. Deployed at scale on Alibaba's production platform, SpecFormer successfully unlocks deep scaling for recommendation models, delivering substantial boosts to click-through rates and order volumes.

What Problem Does This Paper Address?

Transformers are notoriously difficult to scale effectively in Recommender Systems (RS). In Large Language Models (LLMs), stacking more layers consistently yields better representations. In contrast, deep Transformers in RS suffer from rapid performance degradation, often underperforming much simpler baseline models.

The authors reveal that this bottleneck stems from a vicious cycle of spectral collapse unique to recommendation data. Recommendation features (such as user profiles, item IDs, and contexts) are highly heterogeneous and follow a severe long-tail distribution. A few highly frequent "head" items dominate the representation space, causing the embedding matrix's rank to collapse.

During forward propagation, these collapsed embeddings force the attention matrix to degenerate into a sparse, low-rank form. Stacking layers compounds this issue because the low-rank attention matrix acts as a low-pass filter, aggressively smoothing out token representations. During backward propagation, gradients flowing through this low-rank attention matrix are forcefully projected onto the dominant principal components. This starves the minor spectral components (the long-tail features) of updates, accelerating the collapse in the next iteration.

Fig. 1: The comparison on fractional effective rank of attention matrix with the increase of Transformer layers. Unlike LLMs, attention matrix in recommendation suffers from serious col- lapse at the early Transformer layers.

Methods

To break this loop, the authors propose SpecFormer, which forces feature interactions to occur explicitly within a dynamically managed, balanced spectral space. It consists of three core components:

  1. Learnable Spectral Softening: At each layer, the model performs Singular Value Decomposition (SVD) on the input token embedding matrix. It then applies a power-law transformation ($\Sigma^* = \text{diag}(\sigma_i^\tau)$) where $\tau$ is a learnable parameter bounded between 0 and 1. This compresses the dominant singular values and redistributes representational energy across the minor components, effectively flattening the spectrum.
  2. Spectrum-softened Attention: The Query ($Q$) and Key ($K$) matrices are projected from these softened embeddings to ensure attention weights are computed in a balanced spectral space. Crucially, the Value ($V$) matrix retains the original, unsoftened embeddings to preserve raw feature content and avoid information loss.
  3. Spectral Residual Position Encoding: Completely flattening the spectrum can inadvertently penalize highly informative principal components. To compensate, SpecFormer introduces a learnable spectral bias ($P_{bias}$) derived from a second-order Taylor expansion of the singular values. This anchors the interactions back to the maximum spectrum, preserving vital primary signals.

Datasets

The model was evaluated on three large-scale datasets:

  • Industrial Dataset: Collected from Alibaba's online display advertising platform, containing approximately 1.2 billion exposure samples, user behavior sequences up to length 256, and 38 feature fields.
  • Criteo: A popular public benchmark for click-through rate (CTR) prediction containing 45 million real-world advertisement click logs (13 continuous and 26 categorical features).
  • Avazu: A public benchmark consisting of 40 million chronologically ordered ad click logs across 23 feature fields.

Key Insights and Ideas

  • The Vicious Cycle Uncovered: The realization that embedding collapse and attention collapse are not static, independent flaws, but rather a dynamic loop feeding into each other via forward and backward propagation, explains why standard Transformers fail in RS.
  • Softening vs. Obliterating: Completely uniformizing the spectral space hurts performance because principal components do carry vital recommendation patterns. The combination of Spectral Softening (to boost tail features) and Spectral Residual Position Encoding (to anchor back to the head features) provides the perfect balance.
  • Value Matrix Preservation: Keeping the Value matrix in the original space while softening Query and Key matrices ensures that the model captures spectral-aware interactions without distorting the underlying semantic content of the features.
Fig. 3: (a) Token frequency exhibits a severe long-tail dis- tribution in recommendation. (b) Cumulative singular value distribution of OneTrans and our method. OneTrans suffers from severe embedding collapse where top singular values dominate, and SpecFormer effectively mitigates this collapse.

Key Results

  • Offline Superiority: SpecFormer consistently outperformed traditional models (e.g., DeepFM, AutoInt), advanced Transformers (e.g., OneTrans, RankMixer), and spectral baselines across all datasets. On the Industrial dataset, SpecFormer achieved an AUC of 0.7611, significantly outperforming OneTrans (0.7555).
  • True Depth Scaling: Unlike standard Transformers whose effective rank collapses with depth, SpecFormer's fractional effective rank steadily increases as more layers are stacked, translating to continuous performance gains.
  • Production Gains: In a large-scale online A/B test on Alibaba's e-commerce advertising platform (covering 10% of production traffic over 10 days), SpecFormer achieved a +1.34% increase in CTR and a +16.72% boost in orders, with an acceptable latency overhead of only 5ms.

Limitations and Future Work

The paper does not include a dedicated "Limitations and Future Work" section. However, a clear challenge is the inherent computational complexity of performing SVD at each layer. While the authors successfully mitigated this using an in-batch SVD operator, a distributed dynamic embedding framework, and FlashAttention to achieve a 35% improvement in training efficiency, the real-time computational overhead of SVD remains a factor that requires careful system-level engineering for large-scale production environments. Future work could explore more computationally lightweight approximations of spectral softening.

Summary updated

BibTeX
@misc{cui2026specformer,
  author = {Yu Cui and Yi Xu and Jiahao Wang and Hao Zhang and Yu Zhang and Xiaoyi Zeng and Can Wang and Jinxin Hu and Jiawei Chen},
  title = {{SpecFormer: Mitigating Embedding and Attention Collapse via Spectral-Aware Transformer for Recommendation}},
  year = {2026},
  eprint = {2607.24025},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.24025},
}
Figure