TL;DR
TokenFormer unifies multi-field feature interactions and sequential user behavior modeling into a single, homogeneous Transformer backbone. By introducing a layered attention scheme and non-linear gating, it prevents "sequential collapse" caused by low-information static fields, delivering significant accuracy and throughput gains in production.
What Problem Does This Paper Address?
Modern recommender systems deal with two distinct types of data: static multi-field categorical features (e.g., user demographics, device type) and sequential behavior logs (e.g., a user's recent click history). Historically, these have been handled by separate architectures—Collaborative Filtering/CTR models for static fields and sequential models (like SASRec or HSTU) for behavior histories—and fused late in the pipeline.
While recent trends attempt to unify these into a single Transformer backbone by flattening everything into a token stream, the authors discover a hidden trap: Sequential Collapse Propagation (SCP). Static features often have low information density and occupy a low-dimensional subspace. When forced to interact with sequential features through standard linear attention, this low-rank "noise" propagates, causing the high-dimensional sequential representations to dimensionally collapse and lose their predictive power.
Methods
TokenFormer addresses SCP through a homogeneous decoder-only architecture featuring two main innovations:
- Bottom-Full-Top-Sliding (BFTS) Attention: Instead of uniform attention across all layers, TokenFormer uses full causal attention in the lower layers to thoroughly mix static fields and sequence tokens. In deeper layers, it switches to a shrinking-window Sliding Window Attention (SWA) and completely discards the static tokens. This ensures global context is captured early, while deeper layers focus purely on local temporal dynamics.
- Non-Linear Interaction Representation (NLIR): To prevent rank collapse, TokenFormer introduces a multiplicative gating mechanism on the attention output. By applying a one-sided non-linear transformation ($\sigma(G^{(l)}) \odot A^{(l)}$), it injects high-order non-linearity that acts as a mathematical safeguard, preserving the rank richness and expressiveness of the feature space.
Additionally, it uses a unified Rotary Positional Embedding (RoPE) scheme to handle relative chronological ordering across the entire token stream without needing explicit type embeddings.
Datasets
The authors evaluated TokenFormer on both academic and massive industrial scales:
- KuaiRand-27K: A public sequential recommendation benchmark containing approximately 27k unique user interaction trajectories.
- Tencent Ads Platform: Massive, production-grade datasets containing billions of interaction logs characterized by extreme feature sparsity and dynamic user intent.
Key Insights and Ideas
- The Unification Tradeoff: Naively throwing static and sequential features into a vanilla Transformer improves representation discriminability (measured by mutual information) but severely degrades dimensional robustness (effective rank). TokenFormer achieves the best of both worlds.
- Gating as a Rank Preserver: Multiplicative gating (NLIR) isn't just a feature filter; it actively prevents representation collapse by promoting feature decorrelation and preserving subspace dimensionality.
- Static Features are Early-Stage Priors: Static features provide valuable context initially, but repeatedly attending to them in deep layers introduces structural noise. Discarding them in upper layers allows the model to focus entirely on temporal dynamics.
Key Results
- Offline Performance: On the KuaiRand-27K dataset, TokenFormer-T (Tiny) outperformed the vanilla Transformer baseline by 5.00‰ in AUC and beat the strong HSTU-Ultra baseline by 2.05‰. Larger variants scaled even higher, with TokenFormer-L achieving an +8.15‰ AUC improvement.
- Online Production Impact: Deployed in production on Tencent's WeChat Channels advertising system, TokenFormer achieved a 4.03% uplift in GMV (Gross Merchandise Value) and a +0.22% relative AUC improvement over a highly optimized production baseline.
- Serving Efficiency: By utilizing a decoupled serving strategy (compressing user-side tokens) combined with BFTS, TokenFormer boosted inference throughput from 126 QPS to 695 QPS—a 5.5× speedup, making it highly practical for large-scale industrial deployment.
Limitations and Future Work
The authors note that TokenFormer's performance plateaus on smaller academic datasets beyond a certain model size due to data cardinality bottlenecks (i.e., limited sample volume to regularize high-capacity models). Its full potential as a heavy-duty backbone adhering to neural scaling laws is best unlocked in data-abundant, large-scale industrial regimes. Future work could explore better regularization techniques to make these unified architectures more data-efficient on smaller benchmarks.
Summary updated