Hiformer: Heterogeneous Feature Interactions Learning with Transformers for Recommender Systems

Huan Gui, Ruoxi Wang, Ke Yin, Long Jin, Maciej Kula, Taibai Xu, Lichan Hong, Ed H. ChiarXiv 2023 · DOI

Introduction

Recommender systems (RecSys) are fundamental to modern web platforms, relying heavily on capturing complex "feature interactions"—the non-linear relationships between diverse inputs like user demographics, item attributes, and contextual data. While Deep Neural Networks (DNNs) have long been the standard, the Transformer architecture, which revolutionized Natural Language Processing (NLP), has faced significant hurdles in web-scale recommendation environments.

The primary challenges are two-fold: heterogeneity and latency. Unlike NLP, where inputs are homogeneous word tokens, RecSys inputs are a mixture of categorical IDs and dense scalars. Furthermore, the quadratic complexity of standard Transformers often exceeds the strict latency requirements of real-time ranking systems. This paper introduces Hiformer, a tailored Transformer architecture that addresses these issues through heterogeneous attention and efficiency-focused optimizations.

The Hiformer Architecture

Hiformer reimagines the Transformer to better suit the multi-modal nature of recommendation data. The model is structured into four distinct layers: the Input Layer, Preprocessing Layer, Feature Interaction Layer, and Output Layer.

Hiformer Architecture Overview

In the Preprocessing Layer, Hiformer treats different feature types uniquely. Categorical features undergo embedding look-ups, while dense scalar features are normalized and projected. A key innovation is the use of Task Tokens (similar to [CLS] tokens in BERT), which are learned embeddings specifically designed to aggregate information for final prediction tasks.

Heterogeneous Attention Layer

The core of the Feature Interaction Layer is the Heterogeneous Attention mechanism. In a vanilla Transformer, all features share the same projection matrices for Query ($Q$), Key ($K$), and Value ($V$). Hiformer instead learns individual projection matrices for each feature type. This "semantic alignment" allows the model to map disparate features into a shared space where their interactions are more meaningful.

Efficiency and Latency Optimizations

To make Hiformer viable for production environments like Google Play, the authors implemented two critical efficiency strategies:

  1. Low-Rank Approximation: Analysis of the learned projection matrices revealed they are naturally low-rank. By factorizing these matrices, the model significantly reduces the number of parameters and computation required during inference.
  2. Model Pruning: In the final layers, the model stops updating every individual feature representation and focuses solely on the Task Token. This reduces the complexity of the final interaction from quadratic to linear ($O(L)$).
Low-rank nature of projection matrices

As shown in the singular value analysis, the rapid decay of singular values in the value matrix justifies the use of low-rank approximations, enabling a 62.7% reduction in inference latency with negligible impact on model quality.

Results and Impact

Hiformer was evaluated on a massive Google Play ranking dataset featuring over 60 categorical and dense features.

  • Offline Performance: Hiformer achieved an AUC of 0.7875, outperforming established baselines such as DCN-v2 (0.7857) and AutoInt.
  • Online Deployment: In a live A/B test on Google Play, Hiformer delivered a +2.66% boost in user engagement compared to the baseline Transformer model.

Conclusion

Hiformer demonstrates that Transformers can be highly effective for web-scale recommendation when adapted for feature heterogeneity and optimized for serving constraints. By giving each feature its own "voice" through individual projections and leveraging low-rank approximations, Hiformer bridges the gap between the expressive power of Transformers and the practical requirements of production recommender systems.

Summary updated

BibTeX
@misc{gui2023hiformer,
  author = {Huan Gui and Ruoxi Wang and Ke Yin and Long Jin and Maciej Kula and Taibai Xu and Lichan Hong and Ed H. Chi},
  title = {{Hiformer: Heterogeneous Feature Interactions Learning with Transformers for Recommender Systems}},
  year = {2023},
  eprint = {2311.05884},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.05884},
}
Figure