EulerFormer: Sequential User Behavior Modeling with Complex Vector Attention
Open Access
- 10 July 2024
- conference paper
- Published by Association for Computing Machinery (ACM)
- p. 1619-1628
Abstract
To capture user preference, transformer models have been widely applied to model sequential user behavior data. The core of transformer architecture lies in the self-attention mechanism, which computes the pairwise attention scores in a sequence. Due to the permutation-equivariant nature, positional encoding is used to enhance the attention between token representations. In this setting, the pairwise attention scores can be derived by both semantic difference and positional difference. However, prior studies often model the two kinds of difference measurements in different ways, which potentially limits the expressive capacity of sequence modeling. To address this issue, this paper proposes a novel transformer variant with complex vector attention, named EulerFormer, which provides a unified theoretical framework to formulate both semantic difference and positional difference. The EulerFormer involves two key technical improvements. First, it employs a new transformation function for efficiently transforming the sequence tokens into polar-form complex vectors using Euler's formula, enabling the unified modeling of both semantic and positional information in a complex rotation form. Secondly, it develops a differential rotation mechanism, where the semantic rotation angles can be controlled by an adaptation function, enabling the adaptive integration of the semantic and positional information according to the semantic contexts. Furthermore, a phase contrastive learning task is proposed to improve the isotropy of contextual representations in EulerFormer. Our theoretical framework possesses a high degree of completeness and generality (e.g., RoPE can be instantiated as a special case). It is more robust to semantic variations and possesses more superior theoretical properties (e.g., long-term decay) in principle. Extensive experiments conducted on four public datasets demonstrate the effectiveness and efficiency of our approach. Our code is available at https://github.com/RUCAIBox/EulerFormer.Keywords
All Related Versions
Funding Information
- Beijing Natural Science Foundation (4222027)
- National Natural Science Foundation of China (62222215)
This publication has 28 references indexed in Scilit:
- RoFormer: Enhanced transformer with Rotary Position EmbeddingNeurocomputing, 2023
- Contrastive Learning for Sequential Recommendation2022
- RecBole: Towards a Unified, Comprehensive and Efficient Framework for Recommendation Algorithms2021
- CauseRec: Counterfactual User Sequence Synthesis for Sequential Recommendation2021
- Lighter and Better: Low-Rank Decomposed Self-Attention Networks for Next-Item Recommendation2021
- SSE-PT: Sequential Recommendation Via Personalized Transformer2020
- BERT4Rec2019
- Behavior sequence transformer for e-commerce recommendation in Alibaba2019
- Self-Attentive Sequential Recommendation2018
- Learning Hierarchical Representation Model for NextBasket Recommendation2015