From 531488eb7cdbd59cd0f279179a1f4470be4b0f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E8=88=AA=E5=AE=87?= <3364451258@qq.com> Date: Sat, 13 Jun 2026 21:20:13 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=20GRAB=20=E5=92=8C?= =?UTF-8?q?=20HSTU=20=E8=AE=BA=E6=96=87=20OCR=20markdown=EF=BC=88PaddleOCR?= =?UTF-8?q?=20=E8=AF=86=E5=88=AB=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 论文/GRAB.md | 618 ++++++++++++++++++++++++++++++++++++++++++ 论文/HSTU.md | 737 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1355 insertions(+) create mode 100644 论文/GRAB.md create mode 100644 论文/HSTU.md diff --git a/论文/GRAB.md b/论文/GRAB.md new file mode 100644 index 0000000..1a53789 --- /dev/null +++ b/论文/GRAB.md @@ -0,0 +1,618 @@ +# GRAB: An LLM-Inspired Sequence-First Click-Through Rate Prediction Modeling Paradigm + +Shaopeng Chen $ ^{1} $ Chuyue Xie $ ^{1} $ Huimin Ren $ ^{1} $ Shaozong Zhang $ ^{1} $ Han Zhang $ ^{1} $ Ruobing Cheng $ ^{1} $ + +Zhiqiang Cao $ ^{1} $ Zehao Ju $ ^{1} $ Yu Gao $ ^{1} $ Jie Ding $ ^{1} $ Xiaodong Chen $ ^{1} $ Xuewu Jiao $ ^{1} $ Shuanglong Li $ ^{1} $ Lin Liu $ ^{1} $ + +## Abstract + +Traditional Deep Learning Recommendation Models (DLRMs) face increasing bottlenecks in performance and efficiency, often struggling with generalization and long-sequence modeling. Inspired by the scaling success of Large Language Models (LLMs), we propose Generative Ranking for Ads at Baidu (GRAB), an end-to-end generative framework for Click-Through Rate (CTR) prediction. GRAB integrates a novel Causal Action-aware Multi-channel Attention (CamA) mechanism to effectively capture temporal dynamics and specific action signals within user behavior sequences. Full-scale online deployment demonstrates that GRAB significantly outperforms established DLRMs, delivering a 3.05% increase in revenue and a 3.49% rise in CTR. Furthermore, the model demonstrates desirable scaling behavior: its expressive power shows a monotonic and approximately linear improvement as longer interaction sequences are utilized. + +### 1. Introduction + +For a long time, Deep Learning Recommendation Models (DLRMs) (Naumov et al., 2019) have remained the mainstream choice in industrial recommender systems, especially for advertising Click-Through Rate (CTR) prediction (Mudigere et al., 2022; Zhou et al., 2018; Cheng et al., 2016; Guo et al., 2017; Bai et al., 2025; Wang et al., 2017; Ma et al., 2018a), due to their strong capability to process high-cardinality sparse features and to model feature interactions with expressive neural networks. However, as user behavior data grows exponentially, traditional DLRMs face increasing bottlenecks in both performance and efficiency (detailed discussions in Appendix A.1). Fundamentally, DLRMs rely on rule-based feature engineering and suffer from the inherent flaw of “strong memory, weak reasoning” (Cheng et al., 2016; Wu et al., 2024). They often fail to generalize to new ads or scenarios that require logical inference, and their gains exhibit diminishing returns: further improvements typically demand exponentially increasing computational costs, rendering long-term deployment and iteration economically unsustainable (Zhang et al., 2024b; Mudigere et al., 2022). + + + +Departing from the structural constraints of DLRMs, the rise of Large Language Models (LLMs) has been driven by scaling laws (Kaplan et al., 2020; Zhang et al., 2024a; b), where performance predictably improves with increased parameters, data, and compute. This success has inspired the extension of scaling laws to recommendation systems, fostering the LLMs for Recommendation (LLM4Rec) paradigm (Wu et al., 2024; Li et al., 2024a) (see Appendix A.2 for a taxonomy). A key innovation within this framework is Generative Recommendation (GR) (Li et al., 2024a; Rajput et al., 2023). Representative works like HSTU (Zhai et al., 2024) formulate recommendation as autoregressive sequence prediction, effectively modeling long user sequences to capture temporal dynamics (Zhou et al., 2018; 2019; Kang & McAuley, 2018; Sun et al., 2019). Crucially, GR exhibits scaling properties similar to LLMs, offering a practical path to transcend the performance bottlenecks of traditional DLRMs (Naumov et al., 2019; Zhai et al., 2024; Zhang et al., 2024a). + +Despite these theoretical advancements, deploying GR models in high-throughput industrial systems remains challenging due to strict online serving and optimization constraints. The primary obstacle is computational efficiency. Standard Transformer training requires extensive padding for variable-length sequences, resulting in significant computational waste (Vaswani et al., 2017; Krell et al., 2021). While the sequence packing—a common Natural Language Processing (NLP) technique for concatenating multiple short sequences—effectively mitigates this issue (Krell et al., 2021), its straightforward application to recommendation systems triggers a more subtle yet damaging failure mode: Distribution Skew (Baylor et al., 2017; Polyzotis et al., 2019; Sculley et al., 2015; Han et al., 2025). + +In recommendations, packing a user's full history creates mini-batches with excessive intra-user correlation, which violates the i.i.d. assumption typically relied on by SGD-style optimization (Doan et al., 2020). This skew (details in Appendix D.1) causes sparse parameters (i.e., embedding tables) to overfit specific users, hindering the generalization of dense parameters (e.g., Transformer weights responsible for inference) (Naumov et al., 2019; Li et al., 2024b). This reveals a fundamental tension: sparse parameters require diverse, uncorrelated samples for robust “memorization”, whereas dense parameters benefit from long, coherent contexts for sequential “reasoning” (Cheng et al., 2016; Kang & McAuley, 2018; Sun et al., 2019). This misalignment implies that standard synchronous training on packed sequences may lead to suboptimal convergence due to the conflicting gradient requirements of the sparse and dense components (Yu et al., 2020). + +Meanwhile, existing GR models typically ignore data heterogeneity, resulting in performance limitations (see Appendix A.3 for detailed discussion). To overcome these challenges, we propose Generative Ranking for Ads at Baidu (GRAB), an end-to-end sequential training and inference framework for industrial-grade CTR prediction. GRAB introduces three core innovations to reconcile the demands for performance, efficiency, and training stability: + +- End-to-End Framework: We introduce GRAB, an end-to-end framework that combines the strengths of DLRMs and GR. Specifically, it fuses the large-scale sparse feature engineering inherent to DLRMs with the sequential inference capabilities of GR, thereby achieving a balance between explicit memorization and implicit reasoning. + +- Causal Action-aware Multi-channel Attention (CamA) mechanism: We propose CamA, a multi-channel, action-aware mechanism designed to boost model performance by modeling both user exposure and interaction signals, improving generalization and robustness across tasks and scenarios. + +• Sequence-Then-Sparse (STS) Training: To address distribution skew from sequence packing, we propose STS, a training strategy that decouples the optimization of dense parameters and sparse embeddings. This resolves their gradient conflict, stabilizes training, and improves convergence without extra compute, enabling high-throughput industrial deployment of GR. + +We have completed a comprehensive evaluation of GRAB in Baidu's commercial advertising CTR ranking business. In offline comparisons, GRAB outperformed mainstream industrial DLRMs as well as emerging GR models (achieving 0.19% relative improvement over the best baseline). Compared to the production DLRM baseline, GRAB achieved an AUC uplift of approximately 2 basis points in online A/B testing, resulting in a 3.05% increase in CPM and a 3.49% increase in CTR. Furthermore, scaling analysis demonstrates that the model's AUC improves monotonically with both model capacity and the length of behavior sequences, indicating that the architecture can stably benefit from modeling longer behavior chains without saturation. + + + +### 2. Related Works + +DLRM-based industrial CTR prediction. Industrial CTR prediction has long been dominated by DLRMs, which embed high-cardinality categorical fields and model feature interactions via MLP/Cross-style modules (Naumov et al., 2019; Cheng et al., 2016; Guo et al., 2017; Wang et al., 2017). To incorporate user histories, production systems often attach explicit behavior encoders to DLRMs, e.g., target-attention/memory based models such as DIN, DIEN, MIMN, and SIM (Zhou et al., 2018; 2019; Pi et al., 2019; 2020), as well as stronger industrial variants like TWIN (Si et al., 2024). Despite their effectiveness, these approaches still heavily rely on hand-crafted statistics and engineered cross features (He et al., 2014; Cheng et al., 2016), and typically compress long histories into fixed-size vectors, making it difficult to scale to long sequences and heterogeneous action signals (Pi et al., 2019). + +GR. Recent GR work models recommendation as causal Transformer-based sequential prediction, enabling long-context modeling and exhibiting favorable scaling behavior (Zhai et al., 2024; Chai et al., 2025; Petrov & Macdonald, 2023). However, deploying GR in the industrial advertising CTR stack still presents challenges in the following aspects: (i) bridging large-scale sparse feature engineering with tokenized sequential modeling (Han et al., 2025; Chai et al., 2025), (ii) modeling heterogeneous action semantics often discarded by naive homogeneous serialization (Zhai et al., 2024), and (iii) training instability introduced by sequence packing (distribution skew) under strict optimization constraints (Krell et al., 2021). Detailed discussion of GR and comparisons between GRAB and related work are given in Appendix B. + +### 3. Methodology + +#### 3.1. DLRMs + +The traditional DLRM architecture, as shown in Fig. 1, follows a modular processing pipeline for CTR prediction, handling raw features from users, candidate ads, and contextual signals. The pipeline involves: (a) expanding categorical features into fixed fields via feature engineering, (b) mapping these fields through hashing to obtain discrete ID vectors for embedding lookup in a Sparse Parameter Server Table (PSTable), and (c) concatenating and normalizing the retrieved embeddings to form a fixed-length flattened vector. This unified representation is then fed into an MLP, typically enhanced with a gating network, to model high-orderfeature interactions and generate the final CTR prediction. + +
Image
+ + +
Figure 1. The traditional DLRM architecture: sparse features are hashed to IDs and embedded via PSTable, and then concatenated into a fixed-length flattened vector for CTR prediction.
+ + +#### 3.2. Overall Architecture of GRAB + +GRAB, with the overall architecture shown in Fig. 2, is designed to model user behavior history sequences in an end-to-end manner, as applied in scenarios like CTR prediction. GRAB follows a three-stage pipeline: (i) sparse feature layer; (ii) dense tokenizer; and (iii) sequence modeling layer. Given raw behavior logs, GRAB first converts heterogeneous categorical signals into sparse IDs at the event level, then tokenizes each event into a dense representation, and finally applies a sequence model to estimate the click probability of candidate ads. GRAB uses its dense representation calculated from the dense tokenizer to bridge DLRM-style sparse feature engineering and GR-style sequential modeling, enabling end-to-end training and inference along a single, unified computation path from input to output, thereby improving CTR prediction performance through end-to-end sequential modeling of event-level user behaviors. + +Sparse Feature Layer. The sparse feature layer (details in Appendix C.1) processes raw logs into time-ordered event sequences. Each event's categorical fields are converted into sparse IDs using standard DLRM feature engineering (Section 3.1), yielding a structured sequence of events annotated with field-wise IDs. + +Dense Tokenizer. Unlike DLRM, which collapses field embeddings into a fixed-length, order-agnostic vector for pointwise processing, GRAB preserves the temporal event structure. It aggregates per-event field embeddings and projects them into $ \mathbb{R}^{d_{model}} $ to form sequential event tokens (Appendix C.2), resulting in a time-ordered token sequence. This sequence serves as the input to a subsequent Transformer, thereby enabling the modeling of long-range dependencies and interest drift. + +Autoregressive-like Sequence Modeling Layer. Built on sequence packing (Section 3.3.1), heterogeneous tokens (Section 3.3.2), and action-aware relative attention bias (Section 3.3.3), our core contribution is the CamA mechanism (Section 3.3.4). CamA integrates a multi-channel design for parallel processing of diverse behaviors and inherits action-aware contextualization from RAB, providing a unified and efficient framework for modeling complex user interest patterns across scenarios. + + + +#### 3.3. Autoregressive-like Sequence Modeling Layer + +Following the dense tokenizer, this layer is designed to capture the temporal dependencies and dynamic evolution of user interests, which takes the sequence of dense event tokens generated by the preceding layer as input (as described in Appendix C.3). Formally, for a user $ u $, the input sequence consists of the behavior history $ \mathbf{E}^{\mathrm{beh}} = \{e_t^{\mathrm{beh}}\}_{t=1}^T $ and the candidate advertisements $ \mathbf{E}^{\mathrm{ad}} = \{e_i^{\mathrm{ad}}\}_{i=1}^N_u $, where $ \mathbf{e}_t^{\mathrm{beh}}, \mathbf{e}_i^{\mathrm{ad}} \in \mathbb{R}^{d_{\mathrm{model}}} $ are the dense embeddings of the $ t $-th behavior event and the $ i $-th candidate ad, respectively, $ T_u $ is the behavior history length, and $ N_u $ is the number of candidate ads. + +##### 3.3.1. SEQUENCE PACKING AND USER-ISOLATED CAUSAL MASK + +In industrial training logs, as shown in the left image of Fig. 3a., a mini-batch is typically formed by sampling $ B_{ins} $ impression instances. Each instance contains a variable-length token sequence composed of (i) a subsequence of the user's historical behavior tokens and (ii) target advertisement tokens to be scored. A straightforward batching strategy pads every instance to a fixed length $ L_{max} $, yielding a dense tensor with dimensions $ B_{ins} \times L_{max} \times d_{model} $, + +which introduces substantial computational waste when most instances are much shorter than $ L_{max} $. + +To eliminate such padding overhead while preserving the temporal semantics, GRAB performs sequence packing by grouping tokens by user. Specifically, tokens from multiple impression instances belonging to the same user u are merged into a single contiguous token segment, while segments of different users are strictly separated. Within each user segment, all tokens are stably sorted by timestamp so that the packed segment forms a single timeline for sequential modeling. After packing, the batch is represented as one long packed tensor $ H = \text{Pack}(\mathbf{E}^{beh}, \mathbf{E}^{ad}) \in \mathbb{R}^{1 \times L \times d_{model}} $, where $ L $ denotes the total packed length across all users in the mini-batch. + +For convenience, we associate each packed position $ p \in \{1, \ldots, L\} $ with (i) a segment $ id \sigma(p) \in U_B $ indicating which user it belongs to, and (ii) a local time index $ \ell(p) \in \{1, \ldots, L_{\sigma(p)}\} $ within that user segment. + +User-isolated causal mask. On the packed tensor $ H $, we construct an additive attention mask $ M^{\text{pack}} \in \mathbb{R}^{L \times L} $ that
Image
+ + +
Figure 2. Overview of GRAB's end-to-end CTR prediction pipeline: (1) Tokenizing raw fields via a sparse PSTable and fusing them into event tokens. (2) Packing tokens per user with causal and heterogeneous masks. (3) Processing through N Transformer layers equipped with the Causal Action-aware Multi-channel Attention (CamA) mechanism. (4) Final CTR prediction from the output representations.
+ + +enforces two constraints: (1) user isolation (no cross-user attention), and (2) causality within each user's timeline (no future leakage). Formally, for query position p and key position q, + + $$ M_{p,q}^{\mathrm{pack}}=\begin{cases}1,&if\sigma(p)=\sigma(q)and\ell(q)\leq\ell(p),\\0,&otherwise.\end{cases} $$ + +This yields a block-diagonal lower-triangular structure (as shown in Fig. 3b), where each block corresponds to one user segment. + +##### 3.3.2. HETEROGENEOUS BEHAVIOR TOKENS AND HETEROGENEOUS VISIBILITY MASK + +After sequence packing, for each user $u$, we obtain a user-isolated, time-ordered packed stream with its causal mask $M_{\text{pack}}$. To further reduce redundancy in the packed history while preserving the information needed for scoring the current candidate, we instantiate two token views at each packed timestamp $t$: the partial token (history) $h_t \in \mathbb{R}^{d_{\text{model}}}$, which retains only time-varying information that is useful for representing history and discards static or highly repetitive fields (e.g., user_id) that would otherwise be duplicated across historical steps and could lead to overfitting; and the full token (candidate) $h'_t \in \mathbb{R}^{d_{\text{model}}}$, which retains the complete information required to score the candidate at time $t$, including the static fields omitted from the partial history view. We then interleave them to form the heterogeneous packed sequence: $H_u = [\mathbf{h}_1, \mathbf{h}_1', \mathbf{h}_2, \mathbf{h}_2', \ldots, \mathbf{h}_{T_u}, \mathbf{h}_{T_u}']$. + +Heterogeneous Visibility Mask. On top of the user-isolated causal constraint encoded by $ M^{pack} $, we apply a mask-rewriting operator $ \mathcal{R}(\cdot) $ to obtain the heterogeneous visibility mask $ M^{het} $. Concretely, $ \mathcal{R}(\cdot) $ rewrites the visibility pattern according to the token types in the following way: (i) partial $ (\mathcal{P}) $ tokens only attend to partial history tokens; and (ii) full $ (\mathcal{F}) $ tokens attend to partial history tokens and themselves, but never attend to other full tokens. Formally, index positions in $ H_u $ by $ n \in \{1, \ldots, 2T_u\} $, we define the time index $ \tau(n) = \lceil n/2 \rceil $ and token type $ \kappa(n) = \mathcal{P} $ if $ n $ is odd, otherwise $ \kappa(n) = \mathcal{F} $. Then the heterogeneous mask (as shown in Fig. 4) is + + + + $$ M_{p,q}^{\mathrm{h e t}}=\begin{cases}{1,}&{\kappa(p)=\mathcal{P},\;\kappa(q)=\mathcal{P},\;\tau(q)\leq\tau(p),}\\ {1,}&{\kappa(p)=\mathcal{F},\;\kappa(q)=\mathcal{P},\;\tau(q)\leq\tau(p),}\\ {1,}&{\kappa(p)=\mathcal{F},\;p=q,}\\ {0,}&{\mathrm{o t h e r w i s e}.}\\ \end{cases} $$ + +##### 3.3.3. ACTION-AWARE ATTENTION: RELATIVE ENCODING AND EFFICIENT COMPUTATION + +On top of the heterogeneous behavior tokens and the heterogeneous visibility mask $ M^{het} $, we further adopt a action-aware RAB(i.e., relative attention bias) causal attention mechanism. It augments standard multi-head self-attention with three designs: a causal mask to prevent future leakage, a dual sliding-window visibility constraint to support streaming-style training, and a query-aware relative bias that enables the query to directly interact with relative position/time/action signals. + +Action-aware relative attention logits. Given a query $ q_{i} $ and a key $ k_{j} $, the attention logit is computed as + + $$ w_{i,j}=\boldsymbol{q}_{i}^{\top}\cdot\left(k_{j}+P o s_{i,j}+A c t i o n_{i,j}+T i m e_{i,j}\right), $$ + +where $ Pos_{i,j} $, $ Action_{i,j} $, and $ Time_{i,j} $ are learnable embeddings derived from relative position, relative action, and relative time, respectively. For continuous or large-range
Image
+ + +
(a) Sequence Packing
+ + +
(b) User-isolated Causal Mask
+ + +
Figure 3. Sequence packing and user-isolated causal masking in GRAB. (a) Instead of padding each impression instance to a fixed length $ L_{max} $, tokens from multiple impressions are concatenated within each user and different users are kept in disjoint segments, yielding a single packed sequence of length $ N_{token} $ for compute-efficient batching. (b) The user-isolated causal mask exhibits a block-diagonal lower-triangular pattern, so each token can only attend to past tokens within the same user segment, enforcing both user isolation and temporal causality.
+ + +signals (e.g., action statistics or play durations), we first discretize them into buckets and then perform embedding lookup. + +Compared with a query-agnostic relative bias (e.g., $ w_{i,j} = q_i^\top k_j + Pos_{i,j} + \cdots $), Eq. 3 makes the relative signals action-aware via the interaction $ q_i^\top Pos_{i,j} $, $ q_i^\top Action_{i,j} $, and $ q_i^\top Time_{i,j} $, allowing the model to adaptively emphasize different contextual relations under different queries (i.e., target ads). + +
Image
+ + +
Figure 4. Heterogeneous behavior tokens and heterogeneous visibility mask $ M^{het} $ (blue entries). Partial tokens attend only to partial-history tokens up to the current time, while full tokens attend to partial-history tokens up to their time index and to themselves, but never to other full tokens, preventing duplicated static information from propagating along time.
+ + +Causal mask with dual sliding windows. We enforce causality and further restrict attention using combined time and length windows. The mask is defined as $ M_{p,q}^{\text{rab}} = 1 $ if $ q \leq p $ and the distance p - q does not exceed the length sliding-window limit $ L_w $; otherwise $ M_{p,q}^{\text{rab}} = 0 $. + +This serves two key industrial purposes: (1) it bounds per-token computation, guaranteeing stable throughput/latency over growing behavior histories; (2) it matches the online training paradigm—events arrive incrementally, and the model updates attention context on the fly without reprocessing the full sequence, boosting training efficiency and serving practicality. + + + +Efficient computation. The naive implementation of Eq. 3 would yield an $ O(L^2d_{\text{model}}) $ intermediate tensor, which is prohibitively memory-intensive in practice. We adopt the optimization in (Golovneva et al., 2024) to re-order the computation. We define codebooks $ B^{\text{pos/act/time}} \in \mathbb{R}^{N_s \times d_{\text{model}}} $ and bucketized indices $ p_{i,j}, a_{i,j}, t_{i,j} $. Then Eq. 3 can be equivalently written as: + + $$ w_{i,j}=q_{i}^{\top}k_{j}+(s_{i}^{p o s})[p_{i,j}]+(s_{i}^{a c t})[a_{i,j}]+(s_{i}^{t i m e})[t_{i,j}]. $$ + +where $ s_{i}^{\mathrm{pos}} = q_{i}^{\top}B^{\mathrm{pos}} $, $ s_{i}^{\mathrm{act}} = q_{i}^{\top}B^{\mathrm{act}} $, and $ s_{i}^{\mathrm{time}} = q_{i}^{\top}B^{\mathrm{time}} $. In practice, we first compute the projection vectors $ s_{i}^{*} $, then obtain relative terms via fast gather operations. This completely avoids the large $ L \times L \times d_{model} $ tensor, dramatically reducing peak memory and improving computational efficiency. + +##### 3.3.4. MULTI-CHANNEL ATTENTION + +While the action-aware RAB attention (Section 3.3.3) enhances each individual attention logit with relative position/action/time signals, it still treats the packed stream as a single mixed sequence. However, in industrial logs, user behaviors are highly heterogeneous (e.g., spanning different time windows or encompassing different behavior types),
Image
+ + +
Figure 5. Action-aware relative attention bias (RAB) with efficient computation. Left: a causal mask with dual sliding windows, which limits each query to attend only to recent past tokens visible within the sliding-window. Right: the action-aware relative encoding pipeline: relative time, position, and action signals are bucketized (as needed), embedded, summed, and injected to the attention logits.
+ + +and different behavioral subsets often exhibit distinct temporal dynamics and predictive value. A straightforward design is to flatten all tokens into a single sequence and apply causal self-attention, yet this couples heterogeneous sources into one interaction graph and incurs a quadratic cost (e.g., $ O((n + m)^2) $ for two sources with lengths $ n $ and $ m $). To improve both modeling effectiveness and efficiency, we further introduce the Causal Action-aware Multi-channel Attention (CamA) mechanism, which integrates a multi-channel design, conceptually analogous to multi-head attention but with channel-specific visibility constraints. We therefore model each channel with an independent causal self-attention stack, and fuse the channel-wise representations via a lightweight gated mixing module. Let $ \mathcal{C} = \{1, \ldots, C\} $ denote the channel set. For each user, channel $ c $ provides a token sequence $ \mathbf{X}^{(c)} \in \mathbb{R}^{T_c \times d} $, and we append the shared target token $ X^{ad} \in \mathbb{R}^d $: + + $$ \mathbf{S}^{(c)}=[\mathbf{X}^{(c)};\mathbf{x}^{\mathrm{t a r}}]\in\mathbb{R}^{(T_{c}+1)\times d},\qquad t^{\star}=T_{c}+1. $$ + +Each channel is equipped with its own causal visibility mask $ \mathbf{M}^{(c)} $, and is encoded independently: + + $$ \begin{align*}\mathbf{H}^{(c,\ell+1)}&=\mathrm{Layer}_{\ell}^{(c)}\Big(\tilde{\mathbf{H}}^{(c,\ell)};\mathbf{M}^{(c)}\Big),\\\mathbf{H}^{(c,0)}&=\mathbf{S}^{(c)},\quad c\in\mathcal{C}.\end{align*} $$ + +Target-token gated mixing. To enable cross-channel information sharing while keeping computation lightweight, we perform mixing only on the target position $ t^* $ at each layer. The mixed representation $ \tilde{\mathbf{h}}^{(c,\ell)} $ is obtained by first computing channel-wise gating weights $ \beta^{(c,\ell)} $ and then aggregating information from all other channels: + + $$ \tilde{\mathbf{h}}^{(c,\ell)}=\mathbf{h}^{(c,\ell)}+\sum_{i\in\mathcal{C}\backslash\{c\}}\beta^{(i,\ell)}\odot\mathbf{h}^{(i,\ell)}. $$ + +This updated representation replaces $ \mathbf{h}^{(c,\ell)} $ at position $ t^{*} $, forming the updated channel representation $ \tilde{\mathbf{H}}^{(c,\ell)} $ used in (6). Finally, the concatenated last-layer target representations from all channels are used for CTR prediction. + + + +#### 3.4. Sequence Then Sparse Training + +While sequence packing (Section 3.3.1) significantly enhances computational efficiency, it introduces a critical challenge: distribution skew. Since samples within a packed mini-batch belong to the same user, the high intra-user correlation leads to redundant updates for specific sparse IDs, causing the model to overfit to specific user-ad interactions, rather than learning generalizable patterns. To mitigate this, we propose the Sequence Then Sparse (STS) training paradigm (detailed discussions in Appendix D), a two-stage decoupled optimization strategy that balances long-range sequential modeling with robust sparse feature learning. + +##### 3.4.1. STAGE I: SEQUENCE MODELING (SEQUENCE PHASE) + +The first stage focuses on capturing the evolution of user interests and temporal dependencies. We perform end-to-end autoregressive-like learning on the packed user sequences Z, which include candidate tokens and their historical trajectories. In this phase, we optimize the dense tokenizer and the causal Transformer, while keeping the Sparse Embedding Table $ \Phi $ frozen. By freezing $ \Phi $, we stabilize the token space, forcing the Transformer to focus exclusively on the relational dynamics between events rather than over-memorizing specific ID features. + +##### 3.4.2. STAGE II: SPARSE FEATURE LEARNING (SPARSE PHASE) + +The second stage is designed to refine the discrete representations, particularly for long-tail IDs. In this phase, we revert to a non-sequential format, treating each sample as an independent user-ad exposure to break the distribution skewness. This stage optimizes the sparse embeddings $ \Phi $, which act as a robust corrector for the gradient accumulation amplified by sequence packing. It ensures that the basic feature representations remain accurate and unbiased across the entire traffic distribution. + +### 4. System Deployment + +GRAB has been successfully deployed in a large-scale feed ad ranking system, handling billions of daily requests. Unlike conventional memory-bound DLRMs, GR is markedly compute-bound due to the quadratic complexity of Transformer self-attention. To satisfy stringent latency requirements, we implemented a co-designed hardware-software architecture. Due to space constraints, we provide the comprehensive system overview (Fig. 8) and detailed deployment optimizations in Appendix E.### 5. Experiment + +#### 5.1. Overall Performance Comparison + +We first compared the performance of GRAB against state-of-the-art recommendation models on the Baidu real-world industrial dataset. The training data, derived from the Baidu real recommendation advertising scene, contains billions of users, exposure logs, and click logs. The test set includes millions of users, billions of exposure logs, and millions of click logs. The baselines encompass both DL-RMs and GR models, including: DIN (Zhou et al., 2018), which models short-term user behavior with target attention; SIM(Soft) (Pi et al., 2020), a sequential model that uses soft-search to encode user interests; TWIN (Si et al., 2024), which extends multi-head target attention from ESU to GSU; HSTU (Zhai et al., 2024), an efficient model for long-sequence behavior modeling; and LONGER (Chai et al., 2025), a Transformer-based architecture designed for ultra-long behavior sequences. Experimental results are presented in Table 1: GRAB outperforms all other baselines, achieving a 0.19% relative improvement over the most competitive model. Meanwhile, Fig. 6a illustrates the performance of different models across varying lengths of user behavior sequences. GRAB surpasses other recommendation models at all sequence lengths, with its performance gains becoming more pronounced as the sequence length increases. + +
Table 1. Overall performance in industrial settings
+ + + +
ModelAUC
DIN0.83309
SIM Soft0.83520
TWIN0.83556
HSTU0.83590
LONGER0.83615
GRAB-small0.83661
GRAB-standard0.83772
+ +#### 5.2. Scaling Analysis + +We evaluate model performance across different capacity scales by independently scaling the number of Transformer blocks( $ n_{layer} $), the number of attention heads( $ n_{head} $), and the feature dimension of the model( $ d_{model} $) in Table 2, Fig. 6b presents the test-set performance of the GRAB model under varying configurations (i.e., $ n_{layer} $, $ n_{head} $ and $ d_{model} $). These results demonstrate that increasing model capacity effectively improves model performance. We also found that as the model capacity increases, the performance improvement on longer user behavior sequences becomes more significant. Moreover, no significant saturation trend is observed within the current range of configurations, which also confirms the strong scalability of the GRAB model. + +
Table 2. Comparison of models with different settings
+ + + +
ModelParamsSetting
GRAB $ _{2l-2h-64d} $6.51M$ n_{layer}=2 $, $ n_{head}=2 $, $ d_{model}=64 $
GRAB $ _{4l-2h-64d} $6.67M$ n_{layer}=4 $, $ n_{head}=2 $, $ d_{model}=64 $
GRAB $ _{6l-2h-64d} $6.83M$ n_{layer}=6 $, $ n_{head}=2 $, $ d_{model}=64 $
GRAB $ _{2l-4h-64d} $6.48M$ n_{layer}=2 $, $ n_{head}=4 $, $ d_{model}=64 $
GRAB $ _{4l-4h-64d} $6.63M$ n_{layer}=4 $, $ n_{head}=4 $, $ d_{model}=64 $
GRAB $ _{4l-4h-128d} $7.05M$ n_{layer}=4 $, $ n_{head}=4 $, $ d_{model}=128 $
GRAB $ _{4l-4h-256d} $8.13M$ n_{layer}=4 $, $ n_{head}=4 $, $ d_{model}=256 $
GRAB $ _{4l-4h-512d} $11.27M$ n_{layer}=4 $, $ n_{head}=4 $, $ d_{model}=512 $
+ +#### 5.3. Ablation Study + +Heterogeneous Tokens. We conduct ablation studies on heterogeneous representations with three configurations: GRAB with heterogeneous, only partial, or only full tokens (Table 3). Results show that heterogeneous representations achieve the best performance. Using only partial tokens leads to significant degradation, confirming that full feature representations are more beneficial for target scoring. Notably, using only full tokens also degrades performance, suggesting that artificially designed statistical features can introduce confusion and impair sequence modeling. + +
Table 3. Ablation studies of GRAB
+ + + +
ModelAUC
GRAB0.83772
GRAB w/ Partial Token0.83492
GRAB w/ Full Token0.83749
GRAB w/o relative pos0.83768
GRAB w/o relative time0.83743
GRAB w/o relative action0.83724
GRAB w/o Multi-channel0.83743
GRAB w/o Target-token mix0.83768
GRAB_sparse0.83614
GRAB_sparse w/o STS0.83549
+ +Action-aware Attention. We ablate three components of GRAB's Action-aware Attention: relative position, time, and action. The results (Table 3) show that removing any of these components degrades performance. The decline is more pronounced for time and action than for position, indicating that historical sequences are more sensitive to behavioral and temporal signals. We also analyze the attention weight distribution across buckets defined by relative position/time differences (smaller values denote more recent tokens). As shown in Figure 7, weights decrease as bucket values increase, confirming that more recent behaviors better reflect user interest and receive higher weights. For relative action, we compare positive (click) and negative (non-click) labels. The weight distribution is highly skewed: positive labels account for 88% of the total weight, versus only 12%
Image
+ + +
(a) Overall Performance
+ + +
Image
+ + +
(b) Scaling Performance
+ + +
Figure 6. DLRMs vs. GRs across different user behavior sequence lengths (a), with a +0.1% improvement in AUC, indicating a significant enhancement. GRABs comparison in different parameter scale(b)
+ + +for negative labels. This suggests that incorporating more positive feedback could further improve sequence modeling. + +
Image
+ + +
Figure 7. The weight distribution of action-aware attention in relative position and relative time.
+ + +Multi-channel Attention. To verify the effectiveness of multi-channel attention in sequence modeling, we conduct the following settings: 1) the GRAB model without multi-channel attention, that is, using a single channel for sequence modeling, 2) remain the multi-channel attention and only remove the target token mix component. As shown in Table 3, both configurations have varying degrees of performance degradation, indicating that each component is indispensable. In terms of performance, multi-channel attention is crucial, and adding the target token mix component can further improve performance. + +STS Training. We evaluate the STS paradigm by comparing GRAB's second-stage training with and without sequence modeling for sparse feature learning. With STS, sparse embeddings are updated through sequence modeling on packed user behavior sequences; without STS, the same batch data is treated as independent exposures. Results (as shown in Table 3) show that STS brings significant accuracy gains in sparse feature learning, confirming the efficacy of the two-stage training. This demonstrates that STS alleviates the distribution skew and overfitting caused by direct sequence-packed training. + + + +#### 5.4. Online A/B Test + +To assess the online performance of GRAB, we deployed it in Baidu home feed scenario of Baidu and compared its performance with the current online DLRM model. The experiment used 10% of the main traffic and remained online for about a month. Online evaluation shows that GRAB delivered 3.49% improvement in CTR and 3.05% improvement in CPM, which indicates that GRAB achieves more accurate advertising estimation and brings considerable revenue increments. Notably, GRAB has already been fully deployed on Baidu, and the online inference costs on par with the previous online DLRM model. + +### 6. Conclusion + +We propose GRAB, an end-to-end generative ranking framework that integrates a novel CamA mechanism to effectively capture temporal dynamics and specific action signals within user behavior sequences. On Baidu billion-scale industrial dataset, GRAB establishes a new state-of-the-art, outperforming DLRM and other GR baselines. Ablation studies validate the necessity of its key components, and our proposed STS training paradigm effectively mitigates distribution shift. Scaling analysis indicates continued gains from larger models and longer sequences. Finally, full online A/B testing in Baidu home feed ads shows that GRAB boosts CTR by 3.49% and CPM by 3.05%, leading to full production deployment. Further discussion of this work can be found in the Appendix F.## References + +Agarwal, S., Yan, C., Zhang, Z., and Venkataraman, S. Bagpipe: Accelerating deep recommendation model training. In Proceedings of the 29th Symposium on Operating Systems Principles, pp. 348–363, 2023. + +Bai, J., Geng, X., Deng, J., Xia, Z., Jiang, H., Yan, G., and Liang, J. A comprehensive survey on advertising click-through rate prediction algorithm. The Knowledge Engineering Review, 40:e3, 2025. + +Bao, K., Zhang, J., Zhang, Y., Wang, W., Feng, F., and He, X. Tallrec: An effective and efficient tuning framework to align large language model with recommendation. In Proceedings of the 17th ACM conference on recommender systems, pp. 1007–1014, 2023. + +Cao, Y., Mehta, N., Yi, X., Keshavan, R. H., Heldt, L., Hong, L., Chi, E., and Sathiamoorthy, M. Aligning large language models with recommendation knowledge. In Findings of the Association for Computational Linguistics: NAACL 2024, pp. 1051–1066, 2024. + +Baylor, D., Breck, E., Cheng, H.-T., Fiedel, N., Foo, C. Y., Haque, Z., Haykal, S., Ispir, M., Jain, V., Koc, L., et al. Tfx: A tensorflow-based production-scale machine learning platform. In Proceedings of the 23rd ACM SIGKDD international conference on knowledge discovery and data mining, pp. 1387–1395, 2017. + +Chai, Z., Ren, Q., Xiao, X., Yang, H., Han, B., Zhang, S., Chen, D., Lu, H., Zhao, W., Yu, L., et al. Longer: Scaling up long sequence modeling in industrial recommenders. In Proceedings of the Nineteenth ACM Conference on Recommender Systems, pp. 247–256, 2025. + +Chen, J., Chi, L., Peng, B., and Yuan, Z. Hllm: Enhancing sequential recommendations via hierarchical large language models for item and user modeling. arXiv preprint arXiv:2409.12740, 2024. + +Cheng, H.-T., Koc, L., Harmsen, J., Shaked, T., Chandra, T., Aradhye, H., Anderson, G., Corrado, G., Chai, W., Ispir, M., et al. Wide & deep learning for recommender systems. In Proceedings of the 1st workshop on deep learning for recommender systems, pp. 7–10, 2016. + +Covington, P., Adams, J., and Sargin, E. Deep neural networks for youtube recommendations. In Proceedings of the 10th ACM conference on recommender systems, pp. 191–198, 2016. + +Di Palma, D., Biancofiore, G. M., Anelli, V. W., Narducci, F., Di Noia, T., and Di Sciascio, E. Evaluating chatgpt as a recommender system: A rigorous approach. arXiv preprint arXiv:2309.03613, 2023. + +Doan, T. T., Nguyen, L. M., Pham, N. H., and Romberg, J. Finite-time analysis of stochastic gradient descent under markov randomness. arXiv preprint arXiv:2003.10973, 2020. + +Geng, B., Huan, Z., Zhang, X., He, Y., Zhang, L., Yuan, F., Zhou, J., and Mo, L. Breaking the length barrier: Llm-enhanced ctr prediction in long textual user behaviors. In Proceedings of the 47th International ACM SIGIR Conference on Research and Development in Information Retrieval, pp. 2311–2315, 2024. + +Golovneva, O., Wang, T., Weston, J., and Sukhbaatar, S. Contextual position encoding: Learning to count what's important. arXiv preprint arXiv:2405.18719, 2024. + +Guo, H., Tang, R., Ye, Y., Li, Z., and He, X. Deepfm: a factorization-machine based neural network for ctr prediction. arXiv preprint arXiv:1703.04247, 2017. + +Han, R., Yin, B., Chen, S., Jiang, H., Jiang, F., Li, X., Ma, C., Huang, M., Li, X., Jing, C., et al. Mtgr: Industrial-scale generative recommendation framework in meituan. In Proceedings of the 34th ACM International Conference on Information and Knowledge Management, pp. 5731–5738, 2025. + +He, X., Pan, J., Jin, O., Xu, T., Liu, B., Xu, T., Shi, Y., Atallah, A., Herbrich, R., Bowers, S., et al. Practical lessons from predicting clicks on ads at facebook. In Proceedings of the eighth international workshop on data mining for online advertising, pp. 1–9, 2014. + +He, Z., Xie, Z., Jha, R., Steck, H., Liang, D., Feng, Y., Majumder, B. P., Kallus, N., and McAuley, J. Large language models as zero-shot conversational recommenders. In Proceedings of the 32nd ACM international conference on information and knowledge management, pp. 720–730, 2023. + +Hou, Y., Mu, S., Zhao, W. X., Li, Y., Ding, B., and Wen, J.-R. Towards universal sequence representation learning for recommender systems. In Proceedings of the 28th ACM SIGKDD conference on knowledge discovery and data mining, pp. 585–593, 2022. + +Hou, Y., He, Z., McAuley, J., and Zhao, W. X. Learning vector-quantized item representation for transferable sequential recommenders. In Proceedings of the ACM Web Conference 2023, pp. 1162–1171, 2023. + +Jia, J., Wang, Y., Li, Y., Chen, H., Bai, X., Liu, Z., Liang, J., Chen, Q., Li, H., Jiang, P., et al. Learn: Knowledge adaptation from large language model to recommendation for practical industrial application. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 39, pp. 11861–11869, 2025.Kang, W.-C. and McAuley, J. Self-attentive sequential recommendation. In 2018 IEEE international conference on data mining (ICDM), pp. 197–206. IEEE, 2018. + +Kaplan, J., McCandlish, S., Henighan, T., Brown, T. B., Chess, B., Child, R., Gray, S., Radford, A., Wu, J., and Amodei, D. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020. + +Krell, M. M., Kosec, M., Perez, S. P., and Fitzgibbon, A. Efficient sequence packing without cross-contamination: Accelerating large language models without impacting performance. arXiv preprint arXiv:2107.02027, 2021. + +Li, L., Zhang, Y., Liu, D., and Chen, L. Large language models for generative recommendation: A survey and visionary discussions. In Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024), pp. 10146–10159, 2024a. + +Li, R., Deng, W., Cheng, Y., Yuan, Z., Zhang, J., and Yuan, F. Exploring the upper limits of text-based collaborative filtering using large language models: Discoveries and insights. In Proceedings of the 34th ACM International Conference on Information and Knowledge Management, pp. 1643–1653, 2025. + +Li, S., Guo, H., Tang, X., Tang, R., Hou, L., Li, R., and Zhang, R. Embedding compression in recommender systems: A survey. ACM Computing Surveys, 56(5):1–21, 2024b. + +Lin, J., Dai, X., Xi, Y., Liu, W., Chen, B., Zhang, H., Liu, Y., Wu, C., Li, X., Zhu, C., et al. How can recommender systems benefit from large language models: A survey. ACM Transactions on Information Systems, 43(2):1–47, 2025. + +Lin, Z., Ding, H., Hoang, N. T., Kveton, B., Deoras, A., and Wang, H. Pre-trained recommender systems: A causal debiasing perspective. In Proceedings of the 17th ACM International Conference on Web Search and Data Mining, pp. 424–433, 2024. + +Liu, J., Liu, C., Zhou, P., Lv, R., Zhou, K., and Zhang, Y. Is chatgpt a good recommender? a preliminary study. arXiv preprint arXiv:2304.10149, 2023. + +Luo, S., He, B., Zhao, H., Shao, W., Qi, Y., Huang, Y., Zhou, A., Yao, Y., Li, Z., Xiao, Y., et al. Recranker: Instruction tuning large language model as ranker for top-k recommendation. ACM Transactions on Information Systems, 43(5):1–31, 2025. + +Ma, J., Zhao, Z., Yi, X., Chen, J., Hong, L., and Chi, E. H. Modeling task relationships in multi-task learning with multi-gate mixture-of-experts. In Proceedings of the 24th + +ACM SIGKDD international conference on knowledge discovery & data mining, pp. 1930–1939, 2018a. + +Ma, X., Zhao, L., Huang, G., Wang, Z., Hu, Z., Zhu, X., and Gai, K. Entire space multi-task model: An effective approach for estimating post-click conversion rate. In The 41st International ACM SIGIR Conference on Research & Development in Information Retrieval, pp. 1137–1140, 2018b. + +Mudigere, D., Hao, Y., Huang, J., Jia, Z., Tulloch, A., Sridharan, S., Liu, X., Ozdal, M., Nie, J., Park, J., et al. Software-hardware co-design for fast and scalable training of deep learning recommendation models. In Proceedings of the 49th Annual International Symposium on Computer Architecture, pp. 993–1011, 2022. + +Naumov, M., Mudigere, D., Shi, H.-J. M., Huang, J., Sundaraman, N., Park, J., Wang, X., Gupta, U., Wu, C.-J., Azzolini, A. G., et al. Deep learning recommendation model for personalization and recommendation systems. arXiv preprint arXiv:1906.00091, 2019. + +Ning, L., Liu, L., Wu, J., Wu, N., Berlowitz, D., Prakash, S., Green, B., O'Banion, S., and Xie, J. User-llm: Efficient llm contextualization with user embeddings. In Companion Proceedings of the ACM on Web Conference 2025, pp. 1219–1223, 2025. + +Petrov, A. V. and Macdonald, C. Generative sequential recommendation with gptrec. arXiv preprint arXiv:2306.11114, 2023. + +Pi, Q., Bian, W., Zhou, G., Zhu, X., and Gai, K. Practice on long sequential user behavior modeling for click-through rate prediction. In Proceedings of the 25th ACM SIGKDD international conference on knowledge discovery & data mining, pp. 2671–2679, 2019. + +Pi, Q., Zhou, G., Zhang, Y., Wang, Z., Ren, L., Fan, Y., Zhu, X., and Gai, K. Search-based user interest modeling with lifelong sequential behavior data for click-through rate prediction. In Proceedings of the 29th ACM International Conference on Information & Knowledge Management, pp. 2685–2692, 2020. + +Polyzotis, N., Zinkevich, M., Roy, S., Breck, E., and Whang, S. Data validation for machine learning. Proceedings of machine learning and systems, 1:334–347, 2019. + +Rajput, S., Mehta, N., Singh, A., Hulikal Keshavan, R., Vu, T., Heldt, L., Hong, L., Tay, Y., Tran, V., Samost, J., et al. Recommender systems with generative retrieval. Advances in Neural Information Processing Systems, 36: 10299–10315, 2023.Sculley, D., Holt, G., Golovin, D., Davydov, E., Phillips, T., Ebner, D., Chaudhary, V., Young, M., Crespo, J.-F., and Dennison, D. Hidden technical debt in machine learning systems. Advances in neural information processing systems, 28, 2015. + +Sheng, X.-R., Gao, J., Cheng, Y., Yang, S., Han, S., Deng, H., Jiang, Y., Xu, J., and Zheng, B. Joint optimization of ranking and calibration with contextualized hybrid model. In Proceedings of the 29th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pp. 4813–4822, 2023. + +Shin, K., Kwak, H., Kim, S. Y., Ramström, M. N., Jeong, J., Ha, J.-W., and Kim, K.-M. Scaling law for recommendation models: Towards general-purpose user representations. In Proceedings of the AAAI conference on artificial intelligence, volume 37, pp. 4596–4604, 2023. + +Si, Z., Guan, L., Sun, Z., Zang, X., Lu, J., Hui, Y., Cao, X., Yang, Z., Zheng, Y., Leng, D., et al. Twin v2: Scaling ultra-long user behavior sequence modeling for enhanced ctr prediction at kuaishou. In Proceedings of the 33rd ACM International Conference on Information and Knowledge Management, pp. 4890–4897, 2024. + +Sun, F., Liu, J., Wu, J., Pei, C., Lin, X., Ou, W., and Jiang, P. Bert4rec: Sequential recommendation with bidirectional encoder representations from transformer. In Proceedings of the 28th ACM international conference on information and knowledge management, pp. 1441–1450, 2019. + +Sun, Z., Si, Z., Zang, X., Zheng, K., Song, Y., Zhang, X., and Xu, J. Large language models enhanced collaborative filtering. In Proceedings of the 33rd ACM International Conference on Information and Knowledge Management, pp. 2178–2188, 2024. + +Tan, J., Xu, S., Hua, W., Ge, Y., Li, Z., and Zhang, Y. + +Idgenrec: Llm-recsys alignment with textual id learning. + +In Proceedings of the 47th international ACM SIGIR + +conference on research and development in information + +retrieval, pp. 355–364, 2024. + +Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., and Polosukhin, I. Attention is all you need. Advances in neural information processing systems, 30, 2017. + +Wang, R., Fu, B., Fu, G., and Wang, M. Deep & cross network for ad click predictions. In Proceedings of the ADKDD'17, pp. 1–7. 2017. + +Wu, L., Zheng, Z., Qiu, Z., Wang, H., Gu, H., Shen, T., Qin, C., Zhu, C., Zhu, H., Liu, Q., et al. A survey on large language models for recommendation. World Wide Web, 27(5):60, 2024. + +Xu, L., Zhang, J., Li, B., Wang, J., Chen, S., Zhao, W. X., and Wen, J.-R. Tapping the potential of large language models as recommender systems: A comprehensive framework and empirical analysis. ACM Transactions on Knowledge Discovery from Data, 19(5):1–51, 2025. + +Yu, T., Kumar, S., Gupta, A., Levine, S., Hausman, K., and Finn, C. Gradient surgery for multi-task learning. Advances in neural information processing systems, 33: 5824–5836, 2020. + +Yuan, Z., Yuan, F., Song, Y., Li, Y., Fu, J., Yang, F., Pan, Y., and Ni, Y. Where to go next for recommender systems? id-vs. modality-based recommender models revisited. In Proceedings of the 46th International ACM SIGIR Conference on Research and Development in Information Retrieval, pp. 2639–2649, 2023. + +Yue, Z., Rabhi, S., Moreira, G. d. S. P., Wang, D., and Oldridge, E. Llamarec: Two-stage recommendation using large language models for ranking. arXiv preprint arXiv:2311.02089, 2023. + +Zhai, J., Liao, L., Liu, X., Wang, Y., Li, R., Cao, X., Gao, L., Gong, Z., Gu, F., He, M., et al. Actions speak louder than words: Trillion-parameter sequential transducers for generative recommendations. arXiv preprint arXiv:2402.17152, 2024. + +Zhang, B. et al. Wukong: Towards a scaling law for large-scale recommendation, 2024a. + +Zhang, J., Xie, R., Hou, Y., Zhao, X., Lin, L., and Wen, J.-R. Recommendation as instruction following: A large language model empowered recommendation approach. ACM Transactions on Information Systems, 43(5):1–37, 2025. + +Zhang, Y. et al. Scaling law of large sequential recommendation models, 2024b. + +Zhao, Z., Fan, W., Li, J., Liu, Y., Mei, X., Wang, Y., Wen, Z., Wang, F., Zhao, X., Tang, J., et al. Recommender systems in the era of large language models (llms). IEEE Transactions on Knowledge and Data Engineering, 36(11):6889–6907, 2024. + +Zhou, G., Zhu, X., Song, C., Fan, Y., Zhu, H., Ma, X., Yan, Y., Jin, J., Li, H., and Gai, K. Deep interest network for click-through rate prediction. In Proceedings of the 24th ACM SIGKDD international conference on knowledge discovery & data mining, pp. 1059–1068, 2018. + +Zhou, G., Mou, N., Fan, Y., Pi, Q., Bian, W., Zhou, C., Zhu, X., and Gai, K. Deep interest evolution network for click-through rate prediction. In Proceedings of the AAAI conference on artificial intelligence, volume 33, pp. 5941–5948, 2019.Zhu, Y., Wu, L., Guo, Q., Hong, L., and Li, J. Collaborative large language model for recommender systems. In Proceedings of the ACM Web Conference 2024, pp. 3162–3172, 2024.### A. Extended Background + +#### A.1. The Performance-Efficiency Trade-off in Industrial CTR Prediction + +The overall design of industrial-grade recommendation systems and their recommendation models almost always revolves around two goals: performance and efficiency (Covington et al., 2016; Naumov et al., 2019; Mudigere et al., 2022; Agarwal et al., 2023; Bai et al., 2025). Performance is not only reflected in the model's fitting capabilities as measured by metrics such as AUC and PCOC, but also in its ability to sensitively capture user interest and changes in content distribution under varying traffic patterns (Sheng et al., 2023; Pi et al., 2020). Efficiency, on the other hand, is comprehensively reflected in the computational power consumption, memory/bandwidth usage, and online inference speed during the training and inference phases. Among these, training and inference costs are prerequisites for the long-term deployment and continuous iteration of the model in a real production environment (Naumov et al., 2019; Mudigere et al., 2022; Agarwal et al., 2023). + +Although DLRMs have achieved considerable success, it faces bottlenecks in both performance and efficiency (Bai et al., 2025; Zhang et al., 2024a; Han et al., 2025). On the one hand, DLRMs rely on an experience- and rule-based feature system, which suffers from the inherent flaw of “strong memory, weak reasoning.” This makes the DLRMs insufficiently generalizable when dealing with new advertisements, new users, or scenarios requiring logical inference (Cheng et al., 2016; He et al., 2014; Ma et al., 2018b; Wu et al., 2024). At the same time, with the exponential growth of user behavior, traditional DLRMs suffer from significant information loss in ultra-long sequence modeling and has poor adaptability to different scenarios (Zhou et al., 2018; Pi et al., 2020; Zhang et al., 2024b). On the other hand, as the network design of DLRMs becomes increasingly complex, the performance improvement of the model shows diminishing returns. To achieve further performance improvements, it often requires exponentially increased computational costs, making the long-term deployment and continuous iteration of the model in a real production environment problematic (Zhang et al., 2024a; Mudigere et al., 2022; Han et al., 2025). + +#### A.2. A Taxonomy of LLM-based Recommendation Research + +LLMs have recently emerged as a promising direction for recommendation systems, giving rise to a growing line of research commonly referred to as LLM4Rec(Wu et al., 2024; Lin et al., 2025; Zhao et al., 2024; Li et al., 2024a). The motivation behind this paradigm shift lies in the inherent limitations of traditional ID-based recommendation models, which often struggle with semantic understanding, cold-start problems, and cross-domain generalization(Yuan et al., 2023; Li et al., 2025). LLMs offer the potential to introduce extensive world knowledge, robust reasoning capabilities, and high-quality textual generation into the recommendation pipeline(Zhang et al., 2025; He et al., 2023). However, integrating LLMs into industrial-scale systems presents unique challenges, primarily the “ID-Text dilemma”—where high-cardinality sparse IDs do not map naturally to the continuous token space of LLMs(Tan et al., 2024; Rajput et al., 2023)—and the prohibitive inference latency of decoder-only architectures in real-time scoring(Yue et al., 2023). Based on recent literature and industrial practices, LLM4Rec approaches can be systematically categorized into three distinct paradigms: LLM as Recommender, LLM for Representation, and Generative Sequential Modeling. + +LLM as Recommender. This category explores the direct application of LLM capabilities—such as memory, reasoning, and zero-shot generalization—to core recommendation tasks including retrieval and ranking (Wu et al., 2024; Lin et al., 2025; Xu et al., 2025). Methods in this domain typically adapt recommendation data into natural language prompts, leveraging techniques like Instruction Tuning to align the LLM with recommendation objectives (Zhu et al., 2024; Zhang et al., 2025; Bao et al., 2023; Luo et al., 2025). While these methods demonstrate promise in explainability and conversational recommendation, their performance on traditional metrics (e.g., CTR) often falls short of specialized ID-based models (Liu et al., 2023; Di Palma et al., 2023; Cao et al., 2024). In recommendation scenarios, user behavior is heavily influenced by implicit feedback and specific context rather than the explicit semantic logic found in natural language; consequently, general world-knowledge reasoning does not necessarily translate effectively to modeling complex user-item interaction patterns (Bao et al., 2023; Cao et al., 2024; Zhu et al., 2024). Furthermore, the inference latency remains a significant bottleneck for real-time industrial deployment (Xu et al., 2025). + +LLM for Representation. In this paradigm, LLMs function as sophisticated feature encoders (Lin et al., 2025; Wu et al., 2024). Instead of performing the ranking directly, the intermediate layers or final output embeddings of the LLM are extracted and utilized as semantic features to augment the input of traditional recommendation models (Sun et al., 2024; Jia et al., 2025; Geng et al., 2024; Chen et al., 2024; Ning et al., 2025). This approach aims to enhance the model's semantic understanding without bearing the full cost of LLM inference during the serving phase. LLM-derived representations significantly mitigate the limitations of discrete feature models, particularly regarding the generalization capability forlong-tail items and cold-start users/ads (Hou et al., 2022; 2023). However, this methodology faces notable limitations. There is typically a limited gain on warm items, as the strong collaborative filtering signals derived from abundant historical interactions often outweigh the semantic benefits provided by the LLM (Hou et al., 2023; Lin et al., 2024). Furthermore, employing large-scale models for representation learning introduces a high inference cost, which creates substantial latency and resource bottlenecks during both the offline feature extraction and online serving phases (Lin et al., 2025). + +Generative Sequential Modeling. This category represents a structural adaptation rather than a direct semantic application. It borrows the architectural innovations underlying LLMs—specifically the Transformer architecture, Causal Masking, and Long-context modeling capabilities—to reconstruct recommendation systems (Vaswani et al., 2017; Kang & McAuley, 2018; Sun et al., 2019). These models (such as GR models) treat user history as a sequence and the next item prediction as a generative task, similar to next token prediction (Kang & McAuley, 2018; Petrov & Macdonald, 2023; Han et al., 2025). By employing generative sequential modeling techniques and combining them with discrete features that precisely characterize user historical behavior, these models have shown significant potential (Han et al., 2025). A key observation in this domain is the emergence of “scaling laws” within recommendation systems, where model performance metrics improve predictably as the sequence length and model capacity increase (Shin et al., 2023; Zhang et al., 2024b), mirroring the trajectory seen in NLP. + +A comparative overview of the three LLM4Rec paradigms is presented in Table 4, highlighting their core mechanisms, key strengths, and primary limitations. + +
Table 4. Comparison of LLM4Rec Paradigms.
+ + + +
CategoryCore MechanismKey StrengthPrimary Limitation
LLM as RecommenderInstruction tuning / prompting for rankingExplainability, Zero-shot generalizationHigh latency, ineffective interaction modeling
LLM for RepresentationFeature Encoder (Extracting embeddings)Cold-start handling, Semantic understandingLimited gain on warm items, high inference cost
Generative Seq. ModelingTransformer decoder, next token predictionScaling laws, high capacityHigh inference latency, high resource consumption
+ +#### A.3. Limitations of GR in Performance + +Existing GR models often inherit NLP-style causal Transformers with minimal adaptation to recommender logs, implicitly assuming that user history can be represented as a homogeneous token stream. In practice, recommendation data are inherently heterogeneous: events comprise multiple fields (e.g., item, context, query, creator), and user trajectories interleave distinct behavior types (e.g., exposure, click, like, skip, dwell). A naive serialization pipeline typically collapses this structured record into a single sequence of item IDs (or flattened tokens), which discards action semantics—the critical distinction between what the user was shown and how the user responded. + +This structural mismatch leads to a performance bottleneck: the model conflates semantically different interactions, dilutes supervision signals, and learns spurious correlations (e.g., treating exposures as implicit positives or mixing weak/strong feedback). As a result, even with larger models and longer contexts, GR may underperform in industrial CTR settings where fine-grained behavior semantics and cross-field interactions are decisive, highlighting the need for action-aware, heterogeneity-preserving sequence modeling rather than direct NLP-style tokenization. + +### B. Extended Related Work + +#### B.1. Limitations of Emerging Generative Ranking Models + +While GR models have successfully introduced the scaling laws of LLMs into recommendation systems, their direct application to industrial CTR prediction faces distinct structural and optimization challenges. + +Mitigation of Distribution Skew in Sequence Packing. To improve training efficiency with variable-length user sequences, standard GR models often employ sequence packing techniques borrowed from NLP (e.g., concatenating multiple short sequences). However, unlike NLP where samples are generally Independent and Identically Distributed (I.I.D.), packing inrecommendation systems groups multiple interactions from the same user into a single training instance to maintain context. This creates a severe distribution skew, where a mini-batch is dominated by highly correlated samples from a few users. This correlation causes the model—especially the sparse embedding parameters—to overfit specific user identities rather than learning generalizable interaction patterns. + +Action heterogeneity. Existing GR models often treat user history as a homogeneous token stream, neglecting the inherent heterogeneity of recommendation data. This reliance on naive serialization discards critical action semantics—distinguishing what was shown from how the user responded—thereby diluting supervision signals and limiting performance in complex industrial scenarios (as discussed in Appendix A.3). + +Explicit Modeling of Relative Action Signals. Standard GR models rely on the vanilla Scaled Dot-Product Attention, often supplemented only by absolute or relative positional encodings. While effective for capturing sequential order (as emphasized in LONGER), this approach treats the nature of the interaction as implicit. It fails to explicitly differentiate between varying feedback signals (e.g., “clicked” vs. “viewed” vs. “purchased”) and their relative timing in a query-dependent manner. + +#### B.2. Comparative Discussion with Existing Ranking Models + +To position GRAB within the evolving landscape of recommendation systems, we provide a qualitative comparison against two primary categories of existing models: traditional DLRMs and emerging GR approaches in Table 5. + +
Table 5. Comparison of DLRM, HSTU, LONGER, and GRAB based on Key Dimensions from the Paper
+ + + +
DimensionDLRMsHSTULONGERGRAB
Core ArchitectureEmbedding + MLP + Target Attention (DIN/SIM)Pure Transformer (Generative Ranking)Transformer-based (Optimized for Long Seq)End-to-End Generative Framework
Feature InteractionManual Cross Features & MLP / GatingStandard Self-Attention (Global)Standard Self-Attention (Long Context)Causal Action-aware Multi-channel Attention (CamA)
Heterogeneous FeaturesConcatenation & Flattening (Fixed-length vector)Homogeneous Tokens (Often redundant static info)Homogeneous Tokens (Similar to HSTU)Heterogeneous Tokens (Partial History / Full Candidate)
Action Semantic ModelingImplicit or via Engineered FeaturesImplicit (Learned via sequence order)Implicit (Focus on sequence length)Action-aware RAB (Explicit Relative Bias)
Training StrategyStandard Supervised (Pointwise BCE)Autoregressive / Next-Token (Suffers from Dist. Skew)Autoregressive (Standard GR Training)Sequence-Then-Sparse (STS) (Decoupled Optimization)
Scaling PotentialDiminishing Returns (Saturated Performance)High (Follows Scaling Laws)High (Scaling in Sequence Length)High & Linear (No saturation observed)
+ +### C. Detailed Architecture and Data Flow of GRAB + +#### C.1. Sparse Feature Layer + +In the sparse feature layer, GRAB expands user u's raw behavior sequence and the candidate ad sequence into event-level representations, preserving their original temporal order to form a structured, time-ordered event sequence: + + $$ \left\{S_{t}^{{b e h}}\right\}_{t=1}^{T_{u}},\qquad\left\{S_{i}^{{a d}}\right\}_{i=1}^{N_{u}} $$ + +where $ T_u $ denotes the length of user $ u $'s behavior history, $ N_u $ denotes the number of candidate advertisements for user $ u $. GRAB takes user behavior history and candidate ads as input sequences. Specifically, the $ t $-th behavior event $ S_t^{beh} $ consists of user attributes U, context C, and behavior attributes B, while the $ i $-th candidate ad $ S_i^{ad} $ consists of context C and item attributes A, as follows: + + $$ S_{t}^{b e h}=\big(U_{u},C_{t},B_{t}\big),\quad S_{i}^{a d}=\big(A_{i},C_{i}\big) $$ + +Following the discrete feature engineering standard of DLRMs, we apply a structured expansion function $ \Phi $ to transform each event into a fixed multi-field representation. Subsequently, each field value is mapped to a discrete ID via a sparse PSTable $ \Pi $. The event-level representations of the raw behavior sequence and the candidate ad sequence can be obtained as: + + $$ \begin{aligned}\mathbf{x}_{t}^{beh}&=\Pi\big(\Phi\big(S_{t}^{beh}\big)\big),\quad&t&=1,\ldots,T_{u}\\\mathbf{x}_{i}^{ad}&=\Pi\big(\Phi\big(S_{i}^{ad}\big)\big),\quad&i&=1,\ldots,N_{u}\end{aligned} $$ #### C.2. Dense Tokenizer + +Unlike the DLRM approach, which concatenates all field embeddings into a fixed-length flattened vector, GRAB preserves the event structure by aggregating field embeddings within each event into a single event token. This yields a time-ordered token sequence that is fed into a Transformer to capture long-range behavioral dependencies and interest drift. Given the structured discrete ID sequences from Section C.1, GRAB converts each event into a dense token for Transformer-based sequential modeling. Specifically, each event is first transformed into a vector through a field-wise embedding lookup followed by a multi-field fusion process, as follows: + + $$ v_{t}=\operatorname{E m b}(x_{t}),\quad v_{i}=\operatorname{E m b}(x_{i}) $$ + +Subsequently, the token representation for each event is generated by the GateMLP module, which consists of an MLP and a Gate layer, formulated as: + + $$ \begin{aligned}\mathbf{e}=\mathbf{G a t e M L P}\big(v\big)\in\mathbb{R}^{d_{m o d e l}}\\\mathbf{E}^{b e h}=\{\mathbf{e}_{t}^{b e h}\}_{t=1}^{T_{u}},\qquad\mathbf{E}^{a d}=\{\mathbf{e}_{i}^{a d}\}_{i=1}^{N_{u}}.\end{aligned} $$ + +#### C.3. Autoregressive-like Sequence Modeling Layer + +Taking the output $ (\mathbf{E}^{beh} $ and $ E^{ad}) $ from the previous dense layer as input, we feed it into the sequence modeling layer(for more details about this layer, please see Section 3.3) to capture sequential dependencies. Let Z denote the final output representation of the sequence layer: + + $$ Z=\mathrm{S e q L a y e r}(\mathbf{E}^{b e h},\mathbf{E}^{a d}). $$ + +Finally, the output of the sequence modeling layer is fed into a logistic head to yield the CTR prediction. The model is trained to minimize the binary cross-entropy loss: + + $$ \begin{align*}\hat{y}&=\sigma\big(\mathbf{w}^{\top}Z+b\big)\in(0,1),\\\mathcal{L}_{\mathrm{BCE}}&=-\left[y\log\hat{y}+(1-y)\log(1-\hat{y})\right].\end{align*} $$ + +### D. In-Depth Analysis of STS Training + +While sequence packing dramatically improves computational resource utilization by eliminating padding, it introduces a non-trivial optimization challenge known as Distribution Skew. In this section, we provide the theoretical justification for the proposed STS training paradigm, detail its mathematical formulation, and discuss how it reconciles the learning space inconsistency between stages. + +#### D.1. Distribution Skew + +Standard Stochastic Gradient Descent (SGD) relies on the assumption that samples within a mini-batch are I.I.D.. Formally, for a loss function $ \mathcal{L} $, the gradient g computed on a batch $ \mathcal{B} $ is an unbiased estimator of the true gradient: + + $$ \mathbb{E}[g_{\mathcal{B}}]=\nabla\mathcal{L},\quad\operatorname{V a r}(g_{\mathcal{B}})=\frac{\sigma^{2}}{|\mathcal{B}|} $$ + +where $ |B| $ is the batch size. + +In sequence packing, we form a packed mini-batch $ \mathcal{B}_{\text{pack}} $ by concatenating multiple actions from the same user $ u $ into a single training instance (or a user-dominated batch) to avoid padding waste. While efficient, this construction makes samples within $ \mathcal{B}_{\text{pack}} $ highly correlated: for $ i, j \in \mathcal{B}_{\text{pack}} $, $ \text{Cov}(x_i, x_j) \gg 0 $, because they share the same user_id, static context, and long-term interests. As a result, the effective batch size is substantially reduced and the variance of the stochastic gradient estimator increases, yielding noisier and less stable updates. + +This issue is most damaging for the sparse embedding table $ \Phi $. Since a packed batch repeatedly contains the same user features (e.g., user_id=123 appears L times along the packed sequence), the update for that single embedding vector is amplified by repeated contributions: + + $$ \Delta\Phi_{u}\propto\sum_{t=1}^{L}\nabla\mathcal{L}_{t}. $$ Such oversized, user-specific updates encourage $ \Phi $ to memorize individual trajectories rather than learn generalizable interaction patterns. Meanwhile, the dense sequence model (e.g., Transformer) suffers from batch-to-batch distribution skew: consecutive packed batches may be dominated by different users (User A $ \rightarrow $ User B), causing abrupt shifts in inputs and gradients, which hinders stable convergence of sequential reasoning parameters. + +#### D.2. Formalization of STS Stages + +To mitigate the distribution skew, STS decouples the optimization into two orthogonal objectives: relational reasoning (Dense) and feature representation (Sparse). The algorithm flow of STS is shown in Algorithm 1. + +Algorithm 1 Two-Stage Alternating Training Strategy + +Require: Training dataset $ \mathcal{D} $, Learning rate $ \eta $ + +1: Initialize: Dense tokenizer $ \theta_{cont} $, Causal Transformer $ \theta_{tr} $, Sparse Embedding Table $ \Phi $ + +2: while not converged do + +3: // Stage I: Sequence Modeling (Sequence Phase) + +4: Sample packed user sequences batch $ Z = (x_{hist}, x_{cand}) \sim \mathcal{D} $ + +5: Freeze Sparse Embedding Table $ \Phi $ + +6: Compute sequence output: + +7: $ \hat{y}_{seq} \leftarrow f_{seq}(Z; \theta_{cont}, \theta_{tr}, \Phi) $ + +8: Compute sequence loss: + +9: $ \mathcal{L}_{seq} \leftarrow BCE(\hat{y}_{seq}, y) $ + +10: Update dense modules: + +11: $ \{\theta_{cont}, \theta_{tr}\} \leftarrow SGD(\nabla_{\{\theta_{cont}, \theta_{tr}\}} \mathcal{L}_{seq}) $ + +12: // Stage II: Sparse Feature Learning (Sparse Phase) + +13: Sample independent user-ad batch $ (x^{beh}, x^{ad}) \sim \mathcal{D} $ + +14: Freeze Sequential modules $ \{\theta_{cont}, \theta_{tr}\} $ + +15: Compute aggregated features (breaking distribution skewness): + +16: $ s \leftarrow \text{Agg}(\{\Phi(x_{t}^{beh})\}) \parallel \Phi(x^{ad}) $ + +17: Compute sparse phase prediction: + +18: $ \hat{y}_{sp} \leftarrow f_{sp}(s) $ + +19: Update sparse embeddings: + +20: $ \Phi \leftarrow SGD(\nabla_{\Phi} \mathcal{L}_{sp}) $ + +21: end while + +#### D.3. Discussion: A Pre-training & Transfer Perspective + +The STS paradigm can be viewed through the lens of pre-training and transfer learning. Stage I serves as a sequential pre-training step that encodes interest evolution into the dense space, while Stage II transfers these insights back to the target sparse feature space for fine-tuning. Although this non-end-to-end mode might introduce a subtle objective inconsistency between stages, our results demonstrate that the benefit of resolving distribution skew far outweighs the cost of misalignment. STS ensures that the end-to-end sequence predictor (Stage I) consistently validates against the optimal embeddings refined in Stage II, providing a pragmatic path to balance efficiency and generalization in large-scale recommendation systems. + +### E. System Deployment Details + +#### E.1. Platform Architecture + +As illustrated in Fig. 8, the proposed system is implemented within a comprehensive Online Advertising System that operates as a closed-loop platform integration of Online Services and Offline Services. The architecture is designed to handle high-concurrence requests while maintaining model freshness through continuous updates. + +##### E.1.1. ONLINE SERVING + +The online serving component processes user interactions in real-time. The workflow initiates with a Page View (PV) Request, which sequentially passes through matching and ranking phases to select appropriate advertisements.The core of the ranking mechanism involves a CTR Prediction module that relies on two primary inputs: + +• User Representation: A user model processes historical tokens and maintains a KV-cache to efficiently manage state. + +• Ad Representation: The system generates ad tokens corresponding to candidate advertisements. + +This process results in the display of ads, where user interactions are captured in the online behavior log, consisting of impression logs and action logs. + +##### E.1.2. OFFLINE TRAINING AND FEEDBACK LOOP + +The offline component ensures the model evolves with user behavior. The process involves: + +• Data Collection and Storage: Logs are collected and stored in behavior storage, which organizes data into User (user_id, gender), AD (ad_id, brand), and Context (location, device, behavior) categories. + +• Feature Engineering: The system performs sparse feature engineering on the collected logs. + +• Training: Training data is grouped by user ID (uid) to facilitate model offline training. + +• Deployment: Updated models are pushed back to the online environment via an hourly release mechanism, updating the CTR prediction and user model components. + +#### E.2. Deployment Constraints and Optimization + +The system, referred to as GRAB, has been deployed in a feed ad ranking system handling billions of daily requests. The deployment addresses several critical engineering challenges distinguishable from conventional DLRMs: + +• Computational Complexity: Unlike memory-bound DLRMs, GR in this context is compute-bound. This is primarily attributed to the quadratic complexity ( $ O(L^{2}) $) of Transformer self-attention mechanisms required for processing long sequences. + +- Latency Requirements: The system's performance is bound by critical latency thresholds defined in the Service Level Agreements (SLAs). + +To meet these demands, the deployment utilizes a co-designed architecture incorporating data compression, hierarchical storage, and disaggregated serving. + +#### E.3. Data Infrastructure and Training Optimization + +User-Centric Data Layout and Compression. Traditional industrial pipelines use time-partitioned logs, necessitating expensive global shuffling. We transitioned to a User Slice storage architecture, where user behavior logs are pre-aggregated by User ID into contiguous physical file blocks. To further reduce I/O overhead, we upgraded from standard Gzip text storage to a Binary + LZ4 compression scheme. The binary format combined with LZ4 (which is highly efficient for repetitive user behavior patterns) reduced storage costs by 12% compared to Gzip and decreased decoding latency by 70%, enabling the system to stream complete user histories with near-linear scalability. + +Hierarchical Parameter Server (PaddleBox). To handle terabyte-scale embedding tables, we utilized the training framework with a three-tier storage hierarchy: + +• L1 (GPU HBM): Stores hot embeddings for the current micro-batch. + +• L2 (CPU DRAM): Buffers warm parameters. + +• L3 (SSD): Utilizes NVMe SSDs for massive long-tail feature embeddings. An intelligent prefetching engine asynchronously moves parameters between tiers, masking SSD I/O latency.
Image
+ + +
Figure 8. Overview of an online advertising CTR system with an online-offline closed loop. Online services handle PV requests via matching and ranking, and feed the CTR predictor with user-side historical tokens (maintained by a user model with KV-cache) and candidate ad tokens; user interactions are continuously logged as an impression/action logs. Offline services collect these logs, apply sparse feature engineering, group training samples by user ID, and perform offline training; updated models are released (e.g., hourly) back to online.
+ + +Handling Long-Tail Sequences. Real-world user history lengths exhibit a heavy-tailed distribution, where the top 5% of sequences can cause “Out Of Memory” (OOM). We implemented an Inverse Sliding Window strategy during training. Instead of random slicing, sequences are sliced from the most recent action backwards. This prioritizes recent user interests and ensures that extreme long-tail data does not destabilize GPU memory usage. + +#### E.4. High-Performance Inference Architecture + +Disaggregated Serving and Parallelism. We adopted a disaggregated serving architecture using a User Interest Center (UIC). The UIC asynchronously computes and updates the Transformer's Key-Value (KV) cache triggered by user actions. Crucially, we implemented Parallel Material Recall, where the user's historical sequence encoding overlaps with the candidate generation (ad retrieval) phase. By the time candidate ads are retrieved, the user's dense state is already computed, significantly hiding latency. + +KV-Cache Reuse and M-FALCON. To avoid re-computing the user history for every candidate ad, we integrated the M-FALCON algorithm (Zhai et al., 2024). It utilizes a broadcast-attention mechanism where the fetched user KV cache is shared across a micro-batch of candidate items, reducing the marginal inference complexity per item from quadratic to linear. + +Operator Fusion and Mixed Precision. To maximize throughput on GPUs, we employed aggressive operator fusion (e.g., fusing Gemm + Bias + LayerNorm), which reduced kernel launch overheads and improved latency by roughly 43%. Furthermore, rather than simple INT8 quantization which may degrade accuracy, we adopted a Mixed Precision strategy: utilizing TF32 for Transformer matrix operations to accelerate computation and FP16 for fully connected layers, achieving a balance between 28% performance gain and negligible precision loss. + +#### E.5. Data Consistency + +A major challenge in GRs is the Freshness Gap (Train-Serve Skew). We addressed this by implementing a streaming data pipeline based on Flink & TableStore. We utilized a Global Strictly Incremental ID mechanism to ensure strict ordering of user actions across distributed nodes. This allows the inference engine to fetch the exact state of the user corresponding to the training checkpoint, reducing data synchronization delay from minutes to seconds and ensuring the model always predicts based on the most consistent context.### F. Discussion + +#### F.1. Limitations and Challenges + +Operational Complexity of Two-Stage Training. A primary limitation of GRAB lies in the operational overhead introduced by the Sequence Then Sparse (STS) training paradigm. While STS effectively resolves the distribution skew caused by sequence packing and stabilizes the optimization of dense versus sparse parameters, it inherently complicates the model iteration pipeline. Unlike standard DLRMs that support continuous, single-stage online learning, STS requires a decoupled scheduling of sequence modeling (freezing sparse features) and sparse feature learning (freezing dense parameters). This increases the engineering maintenance cost and introduces latency in incorporating fresh feature embeddings into the dense sequential context, potentially affecting the model's responsiveness to emerging trends in real-time environments. + +Compute-Bound Hardware Constraints. The shift from DLRMs to Generative Ranking marks a fundamental transition from memory-bound to compute-bound workloads in recommendation infrastructure. Although we mitigated inference latency via optimizations like Action-aware RAB and KV-cache reuse (Appendix E.4), the quadratic complexity of attention mechanisms—even when bounded by sliding windows—remains computationally heavier than the MLP layers of traditional models. Scaling GRAB to significantly longer sequences (e.g., user lifetimes spanning months) or deploying it on edge devices with limited compute capacity poses a significant challenge, necessitating further research into linear attention mechanisms or more aggressive token pruning strategies specifically tailored for recommendation data. + +Interpretability of Generative Signals. While the Multi-channel Attention mechanism allows us to inspect which behavior subsets contribute to a prediction, the end-to-end generative nature of GRAB can obscure the precise “why” behind a ranking decision compared to feature-engineered linear models. Understanding whether a prediction is driven by short-term intent (sequential reasoning) or long-term habit (sparse memorization) remains a non-trivial task, which is critical for debugging bad cases in commercial systems. + +#### F.2. Future Directions + +Towards Multimodal Generative Ranking. Currently, GRAB operates on discretized ID tokens derived from categorical features. However, the architecture's Heterogeneous Token design (Section 3.3.2) is naturally extensible to other modalities. A promising future direction is to integrate raw modal tokens—such as image patches (Visual Tokens) or ad textual descriptions (Language Tokens)—directly into the interaction sequence. By leveraging GRAB's strong sequence modeling capabilities, the model could learn semantic alignment between visual cues and user behaviors end-to-end, overcoming the information loss inherent in pre-extracted ID features and enabling true multimodal CTR prediction. + +Unified Generative Representation Across Domains. Finally, the “pre-training & fine-tuning” paradigm common in NLP has yet to be fully realized in industrial recommendation. We envision extending GRAB to learn a Universal User Representation by pre-training on diverse behavior logs across multiple business scenarios (e.g., Home Feed, Search, and Short Video). A unified GRAB model could transfer learned sequential patterns from data-rich domains to cold-start scenarios, effectively solving the “data silo” problem prevalent in large-scale platforms. + +Foundation for Agent-based Recommender Systems. GRAB's ability to model the transition probabilities of user states $ (s_{t} \rightarrow s_{t+1}) $ positions it as a powerful “World Model” or User Simulator for future agent-based recommendation systems. By accurately predicting not just the next click, but the evolution of user interests over time, GRAB can serve as the environment model for Reinforcement Learning (RL) agents. This would allow the system to move beyond myopic CTR optimization toward maximizing Long-Term Value (LTV) or user satisfaction by simulating how current recommendations influence future user trajectories. \ No newline at end of file diff --git a/论文/HSTU.md b/论文/HSTU.md new file mode 100644 index 0000000..e4c634f --- /dev/null +++ b/论文/HSTU.md @@ -0,0 +1,737 @@ +# Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations + +Jiaqi Zhai $ ^{1} $ Lucy Liao $ ^{1} $ Xing Liu $ ^{1} $ Yueming Wang $ ^{1} $ Rui Li $ ^{1} $ + +Xuan Cao $ ^{1} $ Leon Gao $ ^{1} $ Zhaojie Gong $ ^{1} $ Fangda Gu $ ^{1} $ Michael He $ ^{1} $ Yinghai Lu $ ^{1} $ Yu Shi $ ^{1} $ + +## Abstract + +Large-scale recommendation systems are characterized by their reliance on high cardinality, heterogeneous features and the need to handle tens of billions of user actions on a daily basis. Despite being trained on huge volume of data with thousands of features, most Deep Learning Recommendation Models (DLRMs) in industry fail to scale with compute. Inspired by success achieved by Transformers in language and vision domains, we revisit fundamental design choices in recommendation systems. We reformulate recommendation problems as sequential transduction tasks within a generative modeling framework (“Generative Recommenders”), and propose a new architecture, HSTU, designed for high cardinality, non-stationary streaming recommendation data. HSTU outperforms baselines over synthetic and public datasets by up to 65.8% in NDCG, and is 5.3x to 15.2x faster than FlashAttention2-based Transformers on 8192 length sequences. HSTU-based Generative Recommenders, with 1.5 trillion parameters, improve metrics in online A/B tests by 12.4% and have been deployed on multiple surfaces of a large internet platform with billions of users. More importantly, the model quality of Generative Recommenders empirically scales as a power-law of training compute across three orders of magnitude, up to GPT-3/LLaMa-2 scale, which reduces carbon footprint needed for future model developments, and further paves the way for the first foundation models in recommendations. + +### 1. Introduction + +Recommendation systems, quintessential in the realm of online content platforms and e-commerce, play a pivotal role + +
Image
+ + +
Figure 1. Total compute used to train deep learning models over the years. DLRM results are from (Mudigere et al., 2022); GRs are deployed models from this work. DLRMs/GRs are continuously trained in a streaming setting; we report compute used per year.
+ + +in personalizing billions of user experiences on a daily basis. State-of-the-art approaches in recommendations have been based on Deep Learning Recommendation Models (DLRMs) (Mudigere et al., 2022) for about a decade (Covington et al., 2016; Cheng et al., 2016; Zhou et al., 2018; Tang et al., 2020; Wang et al., 2021; Xia et al., 2023). DLRMs are characterized by their usage of heterogeneous features, such as numerical features – counters and ratios, embeddings, and categorical features such as creator ids, user ids, etc. Due to new content and products being added every minute, the feature space is of extreme high cardinality, often in the range of billions (Eksombatchai et al., 2018). To leverage tens of thousands of such features, DLRMs employ various neural networks to combine features, transform intermediate representations, and compose the final outputs. + +Despite utilizing extensive human-engineered feature sets and training on vast amounts of data, most DLRMs in industry scale poorly with compute (Zhao et al., 2023). This limitation is noteworthy and remains unanswered. + +Inspired by the success achieved by Transformers in language and vision, we revisit fundamental design choices in modern recommendation systems. We observe that alternative formulations at billion-user scale need to overcome three challenges. First, features in recommendation systems lack explicit structures. While sequential formulations have been explored in small-scale settings (detailed discussionsin Appendix B), heterogeneous features, including high cardinality ids, cross features, counters, ratios, etc. play critical roles in industry-scale DLRMs (Mudigere et al., 2022). Second, recommendation systems use billion-scale vocabularies that change continuously. A billion-scale dynamic vocabulary, in contrast to 100K-scale static ones in language (Brown et al., 2020), creates training challenges and necessitates high inference cost given the need to consider tens of thousands of candidates in a target-aware fashion (Zhou et al., 2018; Wang et al., 2020). Finally, computational cost represents the main bottleneck in enabling large-scale sequential models. GPT-3 was trained on a total of 300B tokens over a period of 1-2 months with thousands of GPUs (Brown et al., 2020). This scale appears daunting, until we contrast it with the scale of user actions. The largest internet platforms serve billions of daily active users, who engage with billions of posts, images, and videos per day. User sequences could be of length up to $ 10^{5} $ (Chang et al., 2023). Consequently, recommendation systems need to handle a few orders of magnitude more tokens per day than what language models process over 1-2 months. + +In this work, we treat user actions as a new modality in generative modeling. Our key insights are, a) core ranking and retrieval tasks in industrial-scale recommenders can be cast as generative modeling problems given an appropriate new feature space; b) this paradigm enables us to systematically leverage redundancies in features, training, and inference to improve efficiency. Due to our new formulation, we deployed models that are three orders of magnitude more computationally complex than prior state-of-the-art, while improving topline metrics by 12.4%, as shown in Figure 1. + +Our contributions are as follows. We first propose Generative Recommenders (GRs) in Section 2, a new paradigm replacing DLRMs. We sequentialize and unify the heterogeneous feature space in DLRMs, with the new approach approximating the full DLRM feature space as sequence length tends to infinity. This enables us to reformulate the main recommendation problems, ranking and retrieval, as pure sequential transduction tasks in GRs. Importantly, this further enables model training to be done in a sequential, generative fashion, which permits us to train on orders of magnitude more data with the same amount of compute. + +We next address computational cost challenges throughout training and inference. We propose a new sequential transduction architecture, Hierarchical Sequential Transduction Units (HSTU). HSTU modifies attention mechanism for large, non-stationary vocabulary, and exploits characteristics of recommendation datasets to achieve 5.3x to 15.2x speedup vs FlashAttention2-based Transformers on 8192 length sequences. Further, through a new algorithm, M-FALCON, that fully amortizes computational costs via micro-batching (Section 3.4), we can serve 285x more complex GR models while achieving 1.50x-2.99x speedups, all with the same inference budget used by traditional DLRMs. + + + +We finally validate the proposed techniques over synthetic datasets, public datasets, and deployments on multiple surfaces of a large internet platform with billions of daily active users in Section 4. To the best of our knowledge, our work represents the first result that shows pure sequential transduction-based architectures, like HSTU, in generative settings (GRs) to significantly outperform DLRMs in large-scale industrial settings. Remarkably, not only did we overcome known scaling bottlenecks in traditional DLRMs, we further succeeded in showing that scaling law (Kaplan et al., 2020) applies to recommendations, representing the potential ChatGPT moment for recommendation systems. + +### 2. Recommendation as Sequential Transduction Tasks: From DLRMs to GRs + +#### 2.1. Unifying heterogeneous feature spaces in DLRMs + +Modern DLRM models are usually trained with a vast number of categorical ('sparse') and numerical ('dense') features. In GRs, we consolidate and encode these features into a single unified time series, as depicted in Figure 2. + +Categorical ('sparse') features. Examples of such features include items that user liked, creators in a category (e.g., Outdoors) that user is following, user languages, communities that user joined, cities from which requests were initiated, etc. We sequentialize these features as follows. We first select the longest time series, typically by merging the features that represent items user engaged with, as the main time series. The remaining features are generally time series that slowly change over time, such as demographics or followed creators. We compress these time series by keeping the earliest entry per consecutive segment and then merge the results into the main time series. Given these time series change very slowly, this approach does not significantly increase the overall sequence length. + +Numerical ('dense') features. Examples of such features include weighted and decayed counters, ratios, etc. For instance, one feature could represent user's past click through rate (CTR) on items matching a given topic. Compared to categorical features, these features change much more frequently, potentially with every single (user, item) interaction. It is therefore infeasible to fully sequentialize such features from computational and storage perspectives. However, an important observation is that the categorical features (e.g., item topics, locations) over which we perform these aggregations are already sequentialized and encoded in GRs. Hence, we can remove numerical features in GRs given a sufficiently expressive sequential transduction architecture coupled with a target-aware formulation (Zhou et al., 2018) can meaningfully capture numerical features as we increase
Image
+ + +
Figure 2. Comparison of features and training procedures: DLRMs vs GRs. $ E, F, G, H $ denote categorical features. $ \Phi_i $ represents the $ i $-th item in the merged main time series. $ \Psi_k(t_j) $ denotes training example $ k $ emitted at time $ t_j $. Full notations can be found in Appendix A.
+ + +the overall sequence length and compute in GRs. + +#### 2.2. Reformulating ranking and retrieval as sequential transduction tasks + +Given a list of $n$ tokens $x_0, x_1, \ldots, x_{n-1}$ ($x_i \in \mathbb{X}$) ordered chronologically, the time when those tokens are observed $t_0, t_1, \ldots, t_{n-1}$, a sequential transduction task maps this input sequence to the output tokens $y_0, y_1, \ldots, y_{n-1}$ ($y_i \in \mathbb{X} \cup \{\varnothing\}$), where $y_i = \varnothing$ indicates that $y_i$ is undefined. + +We use $ \Phi_i \in \mathbb{X}_c $ ( $ \mathbb{X}_c \subseteq \mathbb{X} $) to denote a content (e.g., images or videos) that the system provides to the user. Given new content are constantly created, $ \mathbb{X}_c $ and $ \mathbb{X} $ are non-stationary. The user can respond to $ \Phi_i $ with some action $ a_i $ (e.g., like, skip, video completion+share) $ a_i \in \mathbb{X} $. We denote the total number of contents that a user has interacted with by $ n_c $. + +The standard ranking and retrieval tasks, in causal autoregressive settings, can then be defined as sequential transduction tasks (Table 1). We make the following observations: + + +
TaskSpecification (Inputs / Outputs)
Ranking$ x_{i}s $$ \Phi_{0}, a_{0}, \Phi_{1}, a_{1}, \ldots, \Phi_{n_{c}-1}, a_{n_{c}-1} $
$ y_{i}s $$ a_{0}, \varnothing, a_{1}, \varnothing, \ldots, a_{n_{c}-1}, \varnothing $
Retrieval$ x_{i}s $$ (\Phi_{0}, a_{0}), (\Phi_{1}, a_{1}), \ldots, (\Phi_{n_{c}-1}, a_{n_{c}-1}) $
$ y_{i}s $$ \Phi_{1}^{\prime}, \Phi_{2}^{\prime}, \ldots, \Phi_{n_{c}-1}^{\prime}, \varnothing $
$ (\Phi_{i}^{\prime}] = \Phi_{i} $ if $ a_{i} $ is positive, otherwise $ \varnothing $
+ +
Table 1. Ranking and retrieval as sequential transduction tasks. Other categorical features are omitted for simplicity. We compare GRs with traditional sequential recommenders in Appendix B.2.
+ + +Retrieval. In recommendation system’s retrieval stage, we learn a distribution $ p(\Phi_{i+1}|u_i) $ over $ \Phi_{i+1} \in \mathbb{X}_c $, where $ u_i $ is the user’s representation at token $ i $. A typical objective is to select $ \arg \max_{\Phi \in \mathbb{X}_c} p(\Phi|u_i) $ to maximize some reward. This differs from a standard autoregressive setup in two ways. First, the supervision for $ x_i $, $ y_i $, is not necessarily $ \Phi_{i+1} $, as users could respond negatively to $ \Phi_{i+1} $. Second, $ y_i $ is undefined when $ x_{i+1} $ represents a non-engagement related categorical feature, such as demographics. + + + +Ranking. Ranking tasks in GRs pose unique challenges as industrial recommendation systems often require a “target-aware” formulation. In such settings, “interaction” of target, $ \Phi_{i+1} $, and historical features needs to occur as early as possible, which is infeasible with a standard autoregressive setup where “interaction” happens late (e.g., via softmax after encoder output). We address this by interleaving items and actions in Table 1, which enables the ranking task to be formulated as $ p(a_{i+1}|\Phi_{0},a_{0},\Phi_{1},a_{1},\ldots,\Phi_{i+1}) $ (before categorical features). We apply a small neural network to transform outputs at $ \Phi_{i+1} $ into multi-task predictions in practice. Importantly, this enables us to apply target-aware cross-attention to all $ n_{c} $ engagements in one pass. + +#### 2.3. Generative training + +Industrial recommenders are commonly trained in a streaming setup, where each example is processed sequentially as they become available. In this setup, the total computational requirement for self-attention based sequential transduction architectures, such as Transformers (Vaswani et al., 2017), scales as $ \sum_{i} n_i (n_i^2 d + n_i d_{ff} d) $, where $ n_i $ is the number of tokens of user $ i $, and $ d $ is the embedding dimension. The first part in the parentheses comes from self-attention, with assumed $ O(n^2) $ scaling factor due to most subquadratic algorithms involving quality tradeoffs and underperforming quadratic algorithms in wall-clock time (Dao et al., 2022). The second part comes from pointwise MLP layers, with hidden layers of size $ O(d_{ff}) = O(d) $. Taking $ N = \max_i n_i $, the overall time complexity reduces to $ O(N^3 d + N^2 d^2) $, which is cost prohibitive for recommendation settings. + +To tackle the challenge of training sequential transduc-tion models over long sequences in a scalable manner, we move from traditional impression-level training to generative training, reducing the computational complexity by an $ O(N) $ factor, as shown at the top of Figure 2. By doing so, encoder costs are amortized across multiple targets. More specifically, when we sample the $ i $-th user at rate $ s_u(n_i) $, the total training cost now scales as $ \sum_i s_u(n_i) n_i (n_i^2 d + n_i d^2) $, which is reduced to $ O(N^2 d + N d^2) $ by setting $ s_u(n_i) $ to $ 1/n_i $. One way to implement this sampling in industrial-scale systems is to emit training examples at the end of a user's request or session, resulting in $ \hat{s}_u(n_i) \propto 1/n_i $. + +### 3. A High Performance Self-Attention Encoder for Generative Recommendations + +To scale up GRs for industrial-scale recommendation systems with large, non-stationary vocabularies, we next introduce a new encoder design, Hierarchical Sequential Transduction Unit (HSTU). HSTU consists of a stack of identical layers connected by residual connections (He et al., 2015). Each layer contains three sub-layers: Pointwise Projection (Equation 1), Spatial Aggregation (Equation 2), and Pointwise Transformation (Equation 3): + + $$ U(X),V(X),Q(X),K(X)=\operatorname{S p l i t}(\phi_{1}(f_{1}(X))) $$ + + $$ A(X)V(X)=\phi_{2}\left(Q(X)K(X)^{T}+\mathrm{r a b}^{p,t}\right)V(X) $$ + + $$ Y(X)=f_2\left(\operatorname{Norm}\left(A(X)V(X)\right)\odot U(X)\right) $$ + +where $f_i(X)$ denotes an MLP; we use one linear layer, $f_i(X) = W_i(X) + b_i$ for $f_1$ and $f_2$ to reduce compute complexity and further batches computations for queries $Q(X)$, keys $K(X)$, values $V(X)$, and gating weights $U(X)$ with a fused kernel; $\phi_1$ and $\phi_2$ denote nonlinearity, for both of which we use SiLU (Elfwing et al., 2017); Norm is layer norm; and $\mathrm{rab}^{p,t}$ denotes relative attention bias (Raffel et al., 2020) that incorporates positional $(p)$ and temporal $(t)$ information. Full notations used can be found in Table 9. + +HSTU encoder design allows for the replacement of heterogeneous modules in DLRMs with a single modular block. We observe that there are, effectively, three main stages in DLRMs: Feature Extraction, Feature Interactions, and Transformations of Representations. Feature Extractions retrieves the pooled embedding representations of categorical features. Their most advanced versions can be generalized as pairwise attention and target-aware pooling (Zhou et al., 2018), which is captured with HSTU layers. + +Feature Interaction is the most critical part of DLRMs. Common approaches used include factorization machines and their neural network variants (Rendle, 2010; Guo et al., 2017; Xiao et al., 2017), higher order feature interactions (Wang et al., 2021), etc. HSTU replaces feature interactions by enabling attention pooled features to directly “interact” with other features via Norm $ (A(X)V(X)) \odot U(X) $. + +
Image
+ + +
Figure 3. Comparison of key model components: DLRMs vs GRs. The complete DLRM setup (Mudigere et al., 2022) is shown on the left side and a simplified HSTU is shown on the right.
+ + +This design is motivated by the difficulty of approximating dot products with learned MLPs (Rendle et al., 2020; Zhai et al., 2023a). Given SiLU is applied to $ U(X) $, $ \text{Norm}(A(X)V(X)) \odot U(X) $ can also be interpreted as a variant of SwiGLU (Shazeer, 2020). + +Transformations of Representations is commonly done with Mixture of Experts (MoEs) and routing to handle diverse, heterogeneous populations. A key idea is to perform conditional computations by specializing sub-networks for different users (Ma et al., 2018; Tang et al., 2020). Element-wise dot products in HSTU can virtually perform gating operations used in MoEs up to a normalization factor. + +#### 3.1. Pointwise aggregated attention + +HSTU adopts a new pointwise aggregated (normalized) attention mechanism (in contrast, softmax attention computes normalization factor over the entire sequence). This is motivated by two factors. First, the number of prior data points related to target serves as a strong feature indicating the intensity of user preferences, which is hard to capture after softmax normalization. This is critical as we need to predict both the intensity of engagements, e.g., time spent on a given item, and the relative ordering of the items, e.g., predicting an ordering to maximize AUC. Second, while softmax activation is robust to noise by construction, it is less suited for non-stationary vocabularies in streaming settings. + +The proposed pointwise aggregated attention mechanism is depicted in Equation (2). Importantly, layer norm is needed after pointwise pooling to stabilize training. One way to
Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations
+ + + +
ArchitectureHR@10HR@50
Transformers.0442.2025
HSTU $ (-rab^{p,t}, Softmax) $.0617.2496
HSTU $ (-rab^{p,t}) $.0893.3170
+ +
Table 2. Synthetic data in one-pass streaming settings.
+ + +understand this design is through synthetic data following a Dirichlet Process that generates streaming data over a nonstationary vocabulary (details in Appendix C). In this setting, we can observe gaps as large as 44.7% between softmax and pointwise attention setups as shown in Table 2. + +#### 3.2. Leveraging and algorithmically increasing sparsity + +In recommendation systems, the length of user history sequences often follows a skewed distribution, leading to sparse input sequences, particularly in the settings with very long sequences. This sparsity can be leveraged to significantly improve the efficiency of the encoder. To achieve this, we have developed an efficient attention kernel for GPUs that fuses back-to-back GEMMs in a manner similar to (Rabe & Staats, 2021; Dao et al., 2022) but performs fully raggifted attention computations. This essentially transforms the attention computation into grouped GEMMs of various sizes (Appendix G). As a result, self-attention in HSTU becomes memory-bound and scales as $ \Theta(\sum_i n_i^2 d_{qk}^2 R^{-1}) $ in terms of memory accesses, where $ n_i $ is the sequence length for sample $ i $, $ d_{qk} $ is attention dimension, and $ R $ is the register size. This approach by itself leads to 2-5x throughput gains as discussed in Section 4.2. + +We further algorithmically increase the sparsity of user history sequences via Stochastic Length (SL). One key characteristic of user history sequences in recommendations is that user behaviors are temporally repetitive, as user behaviors manifest at multiple scales throughout their interaction history. This represents an opportunity to increase sparsity artificially without compromising model quality, thereby significantly reducing encoder cost that scales as $ \Theta(\sum_{i} n_{i}^{2}) $. + +We can represent user $j$'s history as a sequence $(x_i)_{i=0}^{n_{c,j}}$, where $n_{c,j}$ is the number of contents user interacted with. Let $N_c = \max_j n_{c,j}$. Let $(x_{i_k})_{k=0}^L$ be a subsequence of length $L$ constructed from the original sequence $(x_i)_{i=0}^{n_{c,j}}$. SL selects input sequences as follows: + + $$ (x_{i})_{i=0}^{n_{c,j}}\mathrm{if}n_{c,j}\leq N_{c}^{\alpha/2} $$ + + $$ \left(x_{i_{k}}\right)_{k=0}^{N_{c}^{\alpha/2}}\mathrm{if}n_{c,j}>N_{c}^{\alpha/2},\mathrm{w/probability}1-N_{c}^{\alpha}/n_{c,j}^{2} $$ + + $$ \left(x_{i}\right)_{i=0}^{n_{c,j}}\mathrm{if}n_{c,j}>N_{c}^{\alpha/2},\mathrm{w/probability}N_{c}^{\alpha}/n_{c,j}^{2} $$ + +which reduces attention-related complexity to $ O(N_c^\alpha d) = O(N^\alpha d) $ for $ \alpha \in (1,2] $. A more thorough discussion of subsequence selection can be found in Appendix F.1. We remark that applying SL to training leads to a cost-effective system design, as training generally involves a significantly higher computational cost compared to inference. + + +
Alpha ( $ \alpha $)Max Sequence Lengths
1,0242,0484,0968,192
1.671.5%76.1%80.5%84.4%
1.756.1%63.6%69.8%75.6%
1.840.2%45.3%54.1%66.4%
1.917.2%21.0%36.3%64.1%
2.03.1%6.6%29.1%64.1%
+ +
Table 3. Impact of Stochastic Length (SL) on sequence sparsity.
+ + +Table 3 presents the sparsity (see Appendix F) for different sequence lengths and $ \alpha $ values, for a representative industry-scale configuration with 30-day user history. The settings that result in negligible regression in model quality are underlined and highlighted in blue. The rows labeled “ $ \alpha = 2.0 $” represents the base sparsity case where SL is not applied. Lower $ \alpha $’s are applicable to longer sequences up to the longest sequence length we tested, 8,192. + +#### 3.3. Minimizing activation memory usage + +In recommendation systems, the use of large batch sizes is crucial for both training throughput (Mudigere et al., 2022) and model quality (Yang et al., 2020; Chen et al., 2020; Zhai et al., 2023a). Consequently, activation memory usage becomes a major scaling bottleneck, in contrast to large language models that are commonly trained with small batch sizes and dominated by parameter memory usage. + +Compared to Transformers, HSTU employs a simplified and fully fused design that significantly reduces activation memory usage. Firstly, HSTU reduces the number of linear layers outside of attention from six to two, aligning with recent work that uses elementwise gating to reduce MLP computations (Hua et al., 2022; Gu et al., 2022). Secondly, HSTU aggressively fuses computations into single operators, including $ \phi_1(f_1(\cdot)) $ in Equation (1), and layer norm, optional dropout, and output MLP in Equation (3). This simplified design reduces the activation memory usage to $ 2d + 2d + 4hd_{qk} + 4hd_v + 2hd_v = 14d $ per layer in bfloat16. + +For comparison, Transformers use a feedforward layer and dropout after attention (intermediate state of $ 3hd_v $), followed by a pointwise feedforward block consisting of layer norm, linear, activation, linear, and dropout, with intermediate states of $ 2d + 4d_{ff} + 2d + 1d = 4d + 4d_{ff} $. Here, we make standard assumptions that $ hd_v \geq d $ and that $ d_{ff} = 4d $ (Vaswani et al., 2017; Brown et al., 2020). Thus, after accounting for input and input layer norm (4d) and qkv projections, the total activation states is 33d. HSTU's design hence enables scaling to > 2x deeper layers. + +Additionally, large scale atomic ids used to represent vocabularies also require significant memory usage. With a 10b vocabulary, 512d embeddings, and Adam optimizer, storing embeddings and optimizer states in fp32 already requires 60TB memory. To alleviate memory pressure, we employ rowwise AdamW optimizers (Gupta et al., 2014; Khudiaet al., 2021) and place optimizer states on DRAM, which reduces HBM usage per float from 12 bytes to 2 bytes. + +#### 3.4. Scaling up inference via cost-amortization + +The last challenge we address is the large number of candidates recommendation systems need to process at serving time. We focus on ranking as for retrieval, encoder cost is fully amortizable, and efficient algorithms exist for both MIPS leveraging quantization, hashing, or partitioning (Jegou et al., 2011; Shrivastava & Li, 2014; Li et al., 2002; Zhai et al., 2011) and non-MIPS cases via beam search or hierarchical retrieval (Zhuo et al., 2020; Zhai et al., 2023a). + +For ranking, we have up to tens of thousands of candidates (Covington et al., 2016; Wang et al., 2020). We propose an algorithm M-FALCON (Microbatched-Fast Attention Leveraging Cacheable OperatioNs) to perform inference for m candidates with an input sequence size of n. + +Within a forward pass, M-FALCON handles $ b_m $ candidates in parallel by modifying attention masks and $ rab^{p,t} $ biases such that the attention operations performed for $ b_m $ candidates are exactly the same. This reduces the cost of applying cross-attention from $ O(b_m n^2 d) $ to $ O((n + b_m)^2 d) = O(n^2 d) $ when $ b_m $ can be considered a small constant relative to $ n $. We optionally divide the overall $ m $ candidates into $ \lceil m/b_m \rceil $ microbatches of size $ b_m $ to leverage encoder-level KV caching (Pope et al., 2022) either across forward passes to reduce cost, or across requests to minimize tail latency (More detailed discussions in Appendix H). + +Overall, M-FALCON enables model complexity to linearly scale up with the number of candidates in traditional DL-RMs's ranking stages; we succeeded in applying a $ 285\times $ more complex target-aware cross attention model at $ 1.5\times-3\times $ throughput with a constant inference budget for a typical ranking configuration discussed in Section 4.3. + +### 4. Experiments + +#### 4.1. Validating Inductive Hypotheses of HSTU Encoder + +##### 4.1.1. TRADITIONAL SEQUENTIAL SETTINGS + +We first evaluate the performance of HSTU on two popular recommender datasets, MovieLens and Amazon Reviews. We follow sequential recommendation settings in literature, including full shuffle and multi-epoch training. For baseline, we use SASRec, a state-of-the-art Transformer implementation (Kang & McAuley, 2018) $ ^{1} $. We report Hit Rate@K and NDCG@K over the entire corpus, consistent with recent work (Dallmann et al., 2021; Zhai et al., 2023a). + +Results are presented in Table 4. “SASRec (2023)” denotes the best SASRec recipe reported in (Zhai et al., 2023a). The rows labeled “HSTU” use identical configurations as SASRec (same number of layers, heads, etc.). “HSTU-large” represents larger HSTU encoders (4x number of layers and 2x number of heads). Results show that a) HSTU, with its design optimized for recommendations, significantly outperforms the baseline when using the same configuration, and b) HSTU further improves performance when scaled up. + + + +It is important to note that the evaluation methodology used here differs significantly from industrial-scale settings, as full-shuffle and multi-epoch training are generally not practical in streaming settings used in industry (Liu et al., 2022). + +##### 4.1.2. INDUSTRIAL-SCALE STREAMING SETTINGS + +We next compare the performance of HSTU, ablated HS-TUs, and transformers using industrial-scale datasets in a streaming setting. Throughout the rest of this section, we report Normalized Entropy (NE) (He et al., 2014) for ranking. We train the models over 100B examples (DLRM equivalent), with 64-256 H100s used per job. Given ranking is done in a multi-task setting, we report the main engagement event (“E-Task”) and the main consumption event (“C-Task”). In our context, we consider a 0.001 reduction in NE significant as it generally leads to .5% topline metric improvements for billions of users. For retrieval, given the setup is similar to language modeling, we report log perplexity. We fix encoder parameters in a smaller-scale setting (l = 3, n = 2048, d = 512 for ranking and l = 6, n = 512, d = 256 for retrieval), and grid-search other hyperparameters due to resource limits. + +We show results in Table 5. First, HSTU significantly outperforms Transformers, especially in ranking, likely due to pointwise attention and improved relative attention biases. Second, the gaps between the ablated HSTUs and HSTU confirm the effectiveness of our designs. Optimal learning rates are about 10x lower for Softmax-based HSTU and Transformer vs the rest due to training stability. Even with lower learning rates and pre-norm residual connections (Xiong et al., 2020), we encountered frequent loss explosions with standard Transformers in ranking. Finally, HSTU outperforms a popular Transformer variant used in LLMs, Transformer++ (Touvron et al., 2023a), which uses RoPE (Su et al., 2023), SwiGLU, etc. Overall, in this small-scale setting, HSTU shows better quality at 1.5x-2x faster wall-clock time and 50% less HBM usage. + +#### 4.2. Encoder Efficiency + +Stochastic Length. Figure 4 and Figure 5 (a) show the impact of stochastic length (SL) on model metrics. At $ \alpha = 1.6 $, a sequence of length 4096 is turned into a sequence of length 776 the majority of the time, or removing more than 80% of the tokens. Even after sparsity ratio increases to 64%–84%, the NEs we obtained for main tasks did not degrade by
Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations
+ + +
Table 4. Evaluations of methods on public datasets in multi-pass, full-shuffle settings.
+ + + +
MethodHR@10HR@50HR@200NDCG@10NDCG@200
ML-1MSASRec (2023).2853.5474.7528.1603.2498
HSTU.3097 (+8.6%).5754 (+5.1%).7716 (+2.5%).1720 (+7.3%).2606 (+4.3%)
HSTU-large.3294 (+15.5%).5935 (+8.4%).7839 (+4.1%).1893 (+18.1%).2771 (+10.9%)
ML-20MSASRec (2023).2906.5499.7655.1621.2521
HSTU.3252 (+11.9%).5885 (+7.0%).7943 (+3.8%).1878 (+15.9%).2774 (+10.0%)
HSTU-large.3567 (+22.8%).6149 (+11.8%).8076 (+5.5%).2106 (+30.0%).2971 (+17.9%)
BooksSASRec (2023).0292.0729.1400.0156.0350
HSTU.0404 (+38.4%).0943 (+29.5%).1710 (+22.1%).0219 (+40.6%).0450 (+28.6%)
HSTU-large.0469 (+60.6%).1066 (+46.2%).1876 (+33.9%).0257 (+65.8%).0508 (+45.1%)
+ +
Table 5. Evaluation of HSTU, ablated HSTU, and Transformers on industrial-scale datasets in one-pass streaming settings.
+ + + +
ArchitectureRetrieval log pplx.Ranking (NE)
E-TaskC-Task
Transformers4.069NaNNaN
HSTU ( $ -rab^{{p,t}} $, Softmax)4.024.5067.7931
HSTU ( $ -rab^{{p,t}} $)4.021.4980.7860
Transformer++4.015.4945.7822
HSTU (original rab)4.029.4941.7817
HSTU3.978.4937.7805
+ +
Image
+ + +
Image
+ + +
Figure 4. Impact of Stochastic Length (SL) on metrics. Left: n = 4096. Right: n = 8192. Full results can be found in Appendix F.
+ + +more than 0.002 (0.2%). This evidence supports that SL, for suitable $ \alpha $s, does not negatively impact model quality and allows for high sparsity to reduce training cost. We further verify in Appendix F.3 that SL significantly outperforms existing length extrapolation techniques. + +Encoder Efficiency. Figure 5 compares the efficiency of HSTU and Transformer encoders in training and inference settings. For Transformers, we use the state-of-the-art FlashAttention-2 (Dao, 2023) implementation. We consider sequence lengths ranging from 1,024 to 8,192 and apply Stochastic Length (SL) during training. In the evaluation, we use the same configuration for HSTU and Transformer ( $ d = 512 $, $ h = 8 $, $ d_{qk} = 64 $) and ablate relative attention bias considering HSTU outperforms Transformer without $ rab^{p,t} $, as demonstrated in Section 4.1.2. We compare the encoder-level performance in bfloat16 on NVIDIA H100 GPUs. Overall, HSTU is up to 15.2x and 5.6x more efficient than Transformers in training and inference, respectively. + +Additionally, the decrease in activation memory usage as discussed in Section 3.3 enables us to construct over 2x deeper networks with HSTUs compared to Transformers. + +
Table 6. Offline/Online Comparison of Retrieval Models.
+ + + +
MethodsOffline HR@KOnline metrics
K=100K=500E-TaskC-Task
DLRM29.0%55.5%+0%+0%
DLRM (abl. features)28.3%54.3%-
GR (content-based)11.6%18.8%-
GR (interactions only)35.6%61.7%-
GR (new source)36.9%62.4%+6.2%+5.0%
GR (replace source)+5.1%+1.9%
+ +
Table 7. Offline/Online Comparison of Ranking Models.
+ + + +
MethodsOffline NEsOnline metrics
E-TaskC-TaskE-TaskC-Task
DLRM.4982.7842+0%+0%
DLRM (DIN+DCN).5053.7899--
DLRM (abl. features).5053.7925--
GR (interactions only).4851.7903--
GR.4845.7645+12.4%+4.4%
+ +#### 4.3. Generative Recommenders vs DLRMs in Industrial-scale Streaming Settings + +Lastly, we compare the end-to-end performance of GRs against state-of-the-art DLRM baselines in industrial-scale streaming settings. Our GR implementation reflects a typical configuration used in production, whereas the DLRM settings reflect iterations of hundreds of people over multiple years. Given multiple generators are used in the retrieval stage of a recommendation system, we report both the online result for adding GR ("add source") and replacing existing main DLRM source ("replace source"). Table 6 and Table 7 show that GR not only significantly outperforms DLRMs offline, but also brings 12.4% wins in A/B tests. + +As discussed in Section 2, GRs build upon raw categorical engagement features, while DLRMs are typically trained with a significantly larger number of features, the majority of which are handcrafted from raw signals. If we give the same set of features used in GRs to DLRMs (“DLRM (abl. features)”), the performance of DLRMs is significantly degraded, which suggests GRs can meaningfully capture those features via their architecture and unified feature space. + +We further validate the GR formulation in Section 2.2 by comparing it with a traditional sequential recommender setup that only considers items user interacted with (Kang
Image
+ + +
(a) Training NE.
+ + +
Image
+ + +
(b) Training Speedup.
+ + +
Image
+ + +
(c) Inference Speedup.
+ + +
Figure 5. Encoder-level efficiency: HSTU vs FlashAttention2-based Transformers for Training (a, b) and Inference (c).
+ + +& McAuley, 2018) (“GR (interactions only)”). The results are significantly worse, with its ranking variant underperforming GRs by 2.6% in NE in the main consumption task. + +Considering the popularity of content-based methods (including LMs), we also include a GR baseline with only content features ("GR (content-based)")". The substantial gap in performance of content-based baselines and DLRMs/GRs underscores the significance of high cardinality user actions. + +We finally compare the efficiency of GRs with our production DLRMs in Figure 6. Despite the GR model being 285x more computationally complex, we achieved $ 1.50 \times /2.99x $ higher QPS when scoring 1024/16384 candidates, due to HSTU and the novel M-FALCON algorithm in Section 3.4. + +##### 4.3.1. SCALING LAW FOR RECOMMENDATION SYSTEMS + +It is commonly known that in large-scale industrial settings, DLRMs saturate in quality at certain compute and params + +
Image
+ + +
Figure 6. Comparison of inference throughput, in the most challenging ranking setup. Full results can be found in Appendix H.1. regimes (Zhao et al., 2023). We compare the scalability of GRs and DLRMs to better understand this phenomenon.
+ + +Since feature interaction layers are crucial for DLRM's performance (Mudigere et al., 2022), we experimented with Transformers (Vaswani et al., 2017), DHEN (Zhang et al., 2022), and a variant of DCN (Wang et al., 2021) augmented with residual connections (He et al., 2015) used in our production settings to scale up the DLRM baseline in the ranking setting. For the retrieval baseline, given our baseline used a residual setup, we scaled up hidden layer sizes, embedding dimensions, and number of layers. For HSTU-based Generative Recommenders (GRs), we scaled up the model by adjusting the hyperparameters for HSTU, including the number of residual layers, sequence length, embedding dimensions, number of attention heads, etc. We additionally adjust the number of negatives for retrieval. + +Results are shown in Figure 7. In the low compute regime, DLRMs might outperform GRs due to handcrafted features, corroborating the importance of feature engineering in traditional DLRMs. However, GRs demonstrate substantially better scalability with respect to FLOPs, whereas DLRM performance plateaus, consistent with findings in prior work. We also observe better scalability w.r.t. both embedding parameters and non-embedding parameters, with GRs leading to 1.5 trillion parameter models, whereas DLRMs performance saturates at about 200 billion parameters. + +Finally, all of our main metrics, including Hit Rate@100 and Hit Rate@500 for retrieval, and NE for ranking, empirically scale as a power law of compute used given appropriate hyperparameters. We observe this phenomenon across three orders of magnitude, up till the largest models we were able to test (8,192 sequence length, 1,024 embedding dimension, 24 layers of HSTU), at which point the total amount of compute we used (normalized over 365 days as we use a standard streaming training setting) is close to the total training compute used by GPT-3 (Brown et al., 2020) and LLaMA2 (Touvron et al., 2023b), as shown in Figure 1. Within a reasonable range, the exact model hyperparameters play less important roles compared to the total amount of training compute applied. In contrast to language modeling (Kaplan et al., 2020), sequence length play a significantly more important role in GRs, and it's important to scale up sequence
Image
+ + +
Image
+ + +
Image
+ + +
Figure 7. Scalability: DLRMs vs GRs in large-scale industrial settings across retrieval (top, middle) and ranking (bottom). +0.005 in HR and -0.001 in NE represent significant improvements.
+ + +length and other parameters in tandem. This is perhaps the most important advantage of our proposed method, as we've shown for the first time that scaling law from LLMs may also apply to large-scale recommendation systems. + +### 5. Related Work + +Prior work on sequential recommenders reduces user interactions to a single homogeneous sequence over items (Hidasi et al., 2016; Kang & McAuley, 2018). Industrial-scale applications of sequential approaches are primarily pairwise attention (Zhou et al., 2018) or sequential encoders as part of DLRMs (Chen et al., 2019; Xia et al., 2023). Multi-stage attention has been explored in lieu of self-attention to improve efficiency (Chang et al., 2023). Generative approaches that represent ids as a token series have been explored in retrieval (Zhuo et al., 2020). We give a more extensive discussion of prior work in Appendix B.1. + +Efficient attention has been a major research focus area due to self-attention's $ O(n^{2}) $ scaling factor, with major work like factorized attentions (Child et al., 2019), low-rank approximations (Katharopoulos et al., 2020), etc. Recently, alternative formulations for sequential transduction settings have been explored (Gu et al., 2022; Hua et al., 2022). HSTU's elementwise gating design, in particular, is inspired by FLASH (Hua et al., 2022). Recent hardware-aware formulations have been shown to significantly reduce memory usage (Rabe & Staats, 2021; Korthikanti et al., 2022; Zhai et al., 2023b) and give significantly better wallclock time results (Dao et al., 2022). Length extrapolation enables models trained on shorter sequences to generalize, though most work focuses on finetuning or improving bias mechanisms (Press et al., 2022). Our work instead introduces stochasticity in the length dimension, inspired by work on stochasticity in the depth dimension (Huang et al., 2016). + + + +Interests in large language models (LLMs) have motivated work to treat various recommendation tasks as in-context learning (Sileo et al., 2022), instruction tuning (Bao et al., 2023), or transfer learning (Li et al., 2023) on top of pretrained LLMs. World knowledge embedded in LLMs can be transferred to downstream tasks (Cui et al., 2022) and improve recommendations in zero-shot or few-shot cases. Textual representations of user behavior sequences have also demonstrated good scaling behaviors on medium-scale datasets (Shin et al., 2023). Most studies of LLMs for recommendation have been centered around low-data regimes; in large-scale settings, they have yet to outperform collaborative filtering on MovieLens (Hou et al., 2024). + +### 6. Conclusions + +We have proposed Generative Recommenders (GRs), a new paradigm that formulates ranking and retrieval as sequential transduction tasks, allowing them to be trained in a generative manner. This is made possible by the novel HSTU encoder design, which is 5.3x-15.2x faster than state-of-the-art Transformers on 8192 length sequences, and through the use of new training and inference algorithms such as M-FALCON. With GRs, we deployed models that are 285x more complex while using less inference compute. GRs and HSTU have led to 12.4% metric improvements in production and have shown superior scaling performance compared to traditional DLRMs. Our results corroborate that user actions represent an underexplored modality in generative modeling – to echo our title, “Actions speak louder than words”. + +The dramatic simplification of features in our work paves the way for the first foundation models for recommendations, search, and ads by enabling a unified feature space to be used across domains. The fully sequential setup of GRs also enables recommendation to be formulated in an end-to-end, generative setting. Both of these enable recommendation systems to better assist users holistically.## IMPACT STATEMENTS + +We believe that our work has broad positive implications. Reducing reliance of recommendation, search, and ads systems on the large number of heterogeneous features can make these systems much more privacy-friendly while improving user experiences. Enabling recommendation systems to attribute users' long-term outcomes to short-term decisions via fully sequential formulations could reduce the prevalence of content that do not serve users' long-term goals (including clickbaits and fake news) across the web, and better align incentives of platforms with user values. Finally, applications of foundation models and scaling law can help reduce carbon footprints incurred with model research and developments needed for recommendations, search, and related use cases. + +## Acknowledgements + +This work represents the joint efforts of hundreds of people, and would not be possible without work from the following contributors (alphabetical order): Adnan Akhundov, Bugra Akyildiz, Shabab Ayub, Alex Bao, Renqin Cai, Jennifer Cao, Guoqiang Jerry Chen, Lei Chen, Sean Chen, Xianjie Chen, Huihui Cheng, Weiwei Chu, Ted Cui, Shiyan Deng, Nimit Desai, Fei Ding, Francois Fagan, Lu Fang, Liang Guo, Liz Guo, Jeevan Gyawali, Yuchen Hao, Daisy Shi He, Samuel Hsia, Jie Hua, Yanzun Huang, Hongyi Jia, Rui Jian, Jian Jin, Rahul Kindi, Changkyu Kim, Yejin Lee, Fu Li, Hong Li, Shen Li, Wei Li, Zhijing Li, Xueting Liao, Emma Lin, Hao Lin, Jingzhou Liu, Xingyu Liu, Kai Londenberg, Liang Luo, Linjian Ma, Matt Ma, Yun Mao, Bert Maher, Matthew Murphy, Satish Nadathur, Min Ni, Jongsoo Park, Jing Qian, Lijing Qin, Alex Singh, Timothy Shi, Dennis van der Staay, Xiao Sun, Colin Taylor, Shin-Yeh Tsai, Ro-Han Varma, Omkar Vichare, Alyssa Wang, Pengchao Wang, Shengzhi Wang, Wenteng Wang, Xiaolong Wang, Zhiyong Wang, Wei Wei, Bin Wen, Carole-Jean Wu, Eric Xu, Bi Xue, Zheng Yan, Chao Yang, Junjie Yang, Zimeng Yang, Chunxing Yin, Daniel Yin, Yiling You, Keke Zhai, Yanli Zhao, Zhuoran Zhao, Hui Zhang, Jingjing Zhang, Lu Zhang, Lujia Zhang, Na Zhang, Rui Zhang, Xiong Zhang, Ying Zhang, Zhiyun Zhang, Charles Zheng, Erheng Zhong, Xin Zhuang. We would like to thank Shikha Kapoor, Rex Cheung, Lana Dam, Ram Ramanathan, Nipun Mathur, Bo Feng, Yanhong Wu, Zhaohui Guo, Hongjie Bai, Wen-Yun Yang, Zellux Wang, Arun Singh, Bruce Deng, Yisong Song, Haotian Wu, Meihong Wang for product support, and Joseph Laria, Ak-shay Hegde, Abha Jain, Raj Ganapathy for assistance with program management. Finally, we would like to thank Ajit Mathews, Shilin Ding, Hong Yan, Lars Backstrom for their leadership support, and insightful discussions with Andrew Tulloch, Liang Xiong, Kaushik Veeraraghavan, and Gaofeng Zhao. + +## References + +Bao, K., Zhang, J., Zhang, Y., Wang, W., Feng, F., and He, X. Tallrec: An effective and efficient tuning framework to align large language model with recommendation. In Proceedings of the 17th ACM Conference on Recommender Systems, RecSys '23. ACM, September 2023. doi: 10.1145/3604915.3608857. URL http://dx.doi.org/10.1145/3604915.3608857. + +Brown, T. B., Mann, B., Ryder, N., Subbiah, M., Kaplan, J., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., Agarwal, S., Herbert-Voss, A., Krueger, G., Henighan, T., Child, R., Ramesh, A., Ziegler, D. M., Wu, J., Winter, C., Hesse, C., Chen, M., Sigler, E., Litwin, M., Gray, S., Chess, B., Clark, J., Berner, C., McCandlish, S., Radford, A., Sutskever, I., and Amodei, D. Language models are few-shot learners. 2020. + +Chang, J., Zhang, C., Fu, Z., Zang, X., Guan, L., Lu, J., Hui, Y., Leng, D., Niu, Y., Song, Y., and Gai, K. Twin: Two-stage interest network for lifelong user behavior modeling in ctr prediction at kuaishou, 2023. + +Chen, Q., Zhao, H., Li, W., Huang, P., and Ou, W. Behavior sequence transformer for e-commerce recommendation in alibaba. In Proceedings of the 1st International Workshop on Deep Learning Practice for High-Dimensional Sparse Data, DLP-KDD '19, New York, NY, USA, 2019. Association for Computing Machinery. ISBN 9781450367837. doi: 10.1145/3326937.3341261. URL https://doi.org/10.1145/3326937.3341261. + +Chen, T., Kornblith, S., Norouzi, M., and Hinton, G. A simple framework for contrastive learning of visual representations. In Proceedings of the 37th International Conference on Machine Learning, ICML'20, 2020. + +Cheng, H.-T., Koc, L., Harmsen, J., Shaked, T., Chandra, T., Aradhye, H., Anderson, G., Corrado, G., Chai, W., Ispir, M., Anil, R., Haque, Z., Hong, L., Jain, V., Liu, X., and Shah, H. Wide & deep learning for recommender systems. In Proceedings of the 1st Workshop on Deep Learning for Recommender Systems, DLRS 2016, pp. 7–10, 2016. ISBN 9781450347952. + +Child, R., Gray, S., Radford, A., and Sutskever, I. Generating long sequences with sparse transformers. CoRR, abs/1904.10509, 2019. URL http://arxiv.org/abs/1904.10509. + +Covington, P., Adams, J., and Sargin, E. Deep neural networks for youtube recommendations. In Proceedings of the 10th ACM Conference on Recommender Systems, RecSys '16, pp. 191–198, 2016. ISBN 9781450340359.Cui, Z., Ma, J., Zhou, C., Zhou, J., and Yang, H. M6-rec: Generative pretrained language models are open-ended recommender systems, 2022. + +Dallmann, A., Zoller, D., and Hotho, A. A case study on sampling strategies for evaluating neural sequential item recommendation models. In Proceedings of the 15th ACM Conference on Recommender Systems, RecSys '21, pp. 505–514, 2021. ISBN 9781450384582. + +Dao, T. Flashattention-2: Faster attention with better parallelism and work partitioning, 2023. + +Dao, T., Fu, D. Y., Ermon, S., Rudra, A., and Ré, C. FlashAttention: Fast and memory-efficient exact attention with IO-awareness. In Advances in Neural Information Processing Systems, 2022. + +Devlin, J., Chang, M., Lee, K., and Toutanova, K. BERT: pre-training of deep bidirectional transformers for language understanding. In Burstein, J., Doran, C., and Solorio, T. (eds.), Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT 2019, Minneapolis, MN, USA, June 2-7, 2019, Volume 1 (Long and Short Papers), pp. 4171–4186. Association for Computational Linguistics, 2019. doi:10.18653/v1/n19-1423. URL https://doi.org/10.18653/v1/n19-1423. + +Eksombatchai, C., Jindal, P., Liu, J. Z., Liu, Y., Sharma, R., Sugnet, C., Ulrich, M., and Leskovec, J. Pixie: A system for recommending 3+ billion items to 200+ million users in real-time. In Proceedings of the 2018 World Wide Web Conference, WWW '18, pp. 1775–1784, 2018. ISBN 9781450356398. + +Elfwing, S., Uchibe, E., and Doya, K. Sigmoid-weighted linear units for neural network function approximation in reinforcement learning. CoRR, abs/1702.03118, 2017. URL http://arxiv.org/abs/1702.03118. + +Gao, W., Fan, X., Wang, C., Sun, J., Jia, K., Xiao, W., Ding, R., Bin, X., Yang, H., and Liu, X. Learning an end-to-end structure for retrieval in large-scale recommendations. In Proceedings of the 30th ACM International Conference on Information and Knowledge Management, CIKM '21, pp. 524–533, 2021. ISBN 9781450384469. + +Gillenwater, J., Kulesza, A., Fox, E., and Taskar, B. Expectation-maximization for learning determinantal point processes. In Proceedings of the 27th International Conference on Neural Information Processing Systems - Volume 2, NIPS'14, pp. 3149–3157, Cambridge, MA, USA, 2014. MIT Press. + +Gu, A., Goel, K., and Ré, C. Efficiently modeling long sequences with structured state spaces. In The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, April 25-29, 2022. OpenReview.net, 2022. URL https://openreview.net/forum?id=uYLFOz1vlAC. + +Guo, H., Tang, R., Ye, Y., Li, Z., and He, X. Deepfm: A factorization-machine based neural network for ctr prediction. In Proceedings of the 26th International Joint Conference on Artificial Intelligence, IJCAI'17, pp. 1725–1731, 2017. ISBN 9780999241103. + +Gupta, M. R., Bengio, S., and Weston, J. Training highly multiclass classifiers. J. Mach. Learn. Res., 15(1):1461–1492, Jan 2014. ISSN 1532-4435. + +He, K., Zhang, X., Ren, S., and Sun, J. Deep residual learning for image recognition. arXiv preprint arXiv:1512.03385, 2015. + +He, X., Pan, J., Jin, O., Xu, T., Liu, B., Xu, T., Shi, Y., Atallah, A., Herbrich, R., Bowers, S., and Candela, J. Q. Practical lessons from predicting clicks on ads at facebook. In ADKDD'14: Proceedings of the Eighth International Workshop on Data Mining for Online Advertising, New York, NY, USA, 2014. Association for Computing Machinery. ISBN 9781450329996. + +Hidasi, B., Karatzoglou, A., Baltrunas, L., and Tikk, D. Session-based recommendations with recurrent neural networks. In Bengio, Y. and LeCun, Y. (eds.), 4th International Conference on Learning Representations, ICLR 2016, San Juan, Puerto Rico, May 2-4, 2016, Conference Track Proceedings, 2016. URL http://arxiv.org/abs/1511.06939. + +Hou, Y., Zhang, J., Lin, Z., Lu, H., Xie, R., McAuley, J., and Zhao, W. X. Large language models are zero-shot rankers for recommender systems. In Advances in Information Retrieval - 46th European Conference on IR Research, ECIR 2024, 2024. + +Hua, W., Dai, Z., Liu, H., and Le, Q. V. Transformer quality in linear time. In Chaudhuri, K., Jegelka, S., Song, L., Szepesvári, C., Niu, G., and Sabato, S. (eds.), International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pp. 9099–9117. PMLR, 2022. URL https://proceedings.mlr.press/v162/hua22a.html. + +Huang, G., Sun, Y., Liu, Z., Sedra, D., and Weinberger, K. Deep networks with stochastic depth, 2016. + +Jegou, H., Douze, M., and Schmid, C. Product quantization for nearest neighbor search. IEEE Trans. Pattern Anal.Mach. Intell. 321. ISSN 0162-8828. + +doi ://doi. + +Kang, W.-C. and McAuley, J. Self-attentive sequential recommendation. In 2018 International Conference on Data Mining (ICDM), pp. 197–206, 2018. + +Kaplan, J., McCandlish, S., Henighan, T., Brown, T. B., Chess, B., Child, R., Gray, S., Radford, A., Wu, J., and Amodei, D. Scaling laws for neural language models. CoRR, abs/2001.08361, 2020. URL https://arxiv.org/abs/2001.08361. + +Katharopoulos, A., Vyas, A., Pappas, N., and Fleuret, F. Transformers are rnns: Fast autoregressive transformers with linear attention. In Proceedings of the 37th International Conference on Machine Learning, ICML'20. JMLR.org, 2020. + +Khudia, D., Huang, J., Basu, P., Deng, S., Liu, H., Park, J., and Smelyanskiy, M. Fbgemm: Enabling high-performance low-precision deep learning inference. arXiv preprint arXiv:2101.05615, 2021. + +Klenitskiy, A. and Vasilev, A. Turning dross into gold loss: is bert4rec really better than sasrec? In Proceedings of the 17th ACM Conference on Recommender Systems, RecSys '23, pp. 1120–1125, New York, NY, USA, 2023. Association for Computing Machinery. ISBN 9798400702419. doi: 10.1145/3604915.3610644. URL https://doi.org/10.1145/3604915.3610644. + +Korthikanti, V., Casper, J., Lym, S., McAfee, L., Andersch, M., Shoeybi, M., and Catanzaro, B. Reducing activation recomputation in large transformer models, 2022. + +Li, J., Wang, M., Li, J., Fu, J., Shen, X., Shang, J., and McAuley, J. Text is all you need: Learning language representations for sequential recommendation. In KDD, 2023. + +Li, C., Chang, E., Garcia-Molina, H., and Wiederhold, G. Clustering for approximate similarity search in high-dimensional spaces. IEEE Transactions on Knowledge and Data Engineering, 14(4):792–808, 2002. + +Liu, Z., Zou, L., Zou, X., Wang, C., Zhang, B., Tang, D., Zhu, B., Zhu, Y., Wu, P., Wang, K., and Cheng, Y. Monolith: Real time recommendation system with collisionless embedding table, 2022. + +Ma, J., Zhao, Z., Yi, X., Chen, J., Hong, L., and Chi, E. H. Modeling task relationships in multi-task learning with multi-gate mixture-of-experts. KDD '18, 2018. + +Mudigere, D., Hao, Y., Huang, J., Jia, Z., Tulloch, A., Sridharan, S., Liu, X., Ozdal, M., Nie, J., Park, J., Luo, + +L., Yang, J. A., Gao, L., Ivchenko, D., Basant, A., Hu, Y., Yang, J., Ardestani, E. K., Wang, X., Komuravelli, R., Chu, C.-H., Yilmaz, S., Li, H., Qian, J., Feng, Z., Ma, Y., Yang, J., Wen, E., Li, H., Yang, L., Sun, C., Zhao, W., Melts, D., Dhulipala, K., Kishore, K., Graf, T., Eisenman, A., Matam, K. K., Gangidi, A., Chen, G. J., Krishnan, M., Nayak, A., Nair, K., Muthiah, B., Khorashadi, M., Bhattacharya, P., Lapukhov, P., Naumov, M., Mathews, A., Qiao, L., Smelyanskiy, M., Jia, B., and Rao, V. Software-hardware co-design for fast and scalable training of deep learning recommendation models. In Proceedings of the 49th Annual International Symposium on Computer Architecture, ISCA '22, pp. 993–1011, New York, NY, USA, 2022. Association for Computing Machinery. ISBN 9781450386104. doi: 10.1145/3470496.3533727. URL https://doi.org/10.1145/3470496.3533727. + +Peng, B., Quesnelle, J., Fan, H., and Shippole, E. YaRN: Efficient context window extension of large language models. In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=wHBfxhZulu. + +Pope, R., Douglas, S., Chowdhery, A., Devlin, J., Bradbury, J., Levskaya, A., Heek, J., Xiao, K., Agrawal, S., and Dean, J. Efficiently scaling transformer inference, 2022. + +Press, O., Smith, N. A., and Lewis, M. Train short, test long: Attention with linear biases enables input length extrapolation. In The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, April 25-29, 2022. OpenReview.net, 2022. URL https://openreview.net/forum?id=R8sQPpGCv0. + +Rabe, M. N. and Staats, C. Self-attention does not need $ o(n^{2}) $ memory, 2021. + +Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W., and Liu, P. J. Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res., 21(1), jan 2020. ISSN 1532-4435. + +Rendle, S. Factorization machines. In 2010 IEEE International Conference on Data Mining (ICDM), pp. 995–1000, 2010. doi: 10.1109/ICDM.2010.127. + +Rendle, S., Krichene, W., Zhang, L., and Anderson, J. Neural collaborative filtering vs. matrix factorization revisited. In Fourteenth ACM Conference on Recommender Systems (RecSys'20), pp. 240–248, 2020. ISBN 9781450375832. + +Shazeer, N. Glu variants improve transformer, 2020.Shin, K., Kwak, H., Kim, S. Y., Ramström, M. N., Jeong, J., Ha, J.-W., and Kim, K.-M. Scaling law for recommendation models: towards general-purpose user representations. In Proceedings of the Thirty-Seventh AAAI Conference on Artificial Intelligence and Thirty-Fifth Conference on Innovative Applications of Artificial Intelligence and Thirteenth Symposium on Educational Advances in Artificial Intelligence, AAAI'23/IAAI'23/EAAI'23. AAAI Press, 2023. ISBN 978-1-57735-880-0. doi:10.1609/aaai.v37i4.25582. URL https://doi.org/10.1609/aaai.v37i4.25582. + +Shrivastava, A. and Li, P. Asymmetric lsh (alsh) for sublinear time maximum inner product search (mips). In Advances in Neural Information Processing Systems, volume 27, 2014. + +Sileo, D., Vossen, W., and Raymaekers, R. Zero-shot recommendation as language modeling. In Hagen, M., Verberne, S., Macdonald, C., Seifert, C., Balog, K., Nørvåg, K., and Setty, V. (eds.), Advances in Information Retrieval - 44th European Conference on IR Research, ECIR 2022, Stavanger, Norway, April 10-14, 2022, Proceedings, Part II, volume 13186 of Lecture Notes in Computer Science, pp. 223–230. Springer, 2022. doi: 10.1007/978-3-030-99739-7\_26. URL https://doi.org/10.1007/978-3-030-99739-7\_26. + +Su, J., Lu, Y., Pan, S., Murtadha, A., Wen, B., and Liu, Y. Roformer: Enhanced transformer with rotary position embedding, 2023. + +Sun, F., Liu, J., Wu, J., Pei, C., Lin, X., Ou, W., and Jiang, P. Bert4rec: Sequential recommendation with bidirectional encoder representations from transformer. In Proceedings of the 28th ACM International Conference on Information and Knowledge Management, CIKM '19, pp. 1441–1450, 2019. ISBN 9781450369763. + +Tang, H., Liu, J., Zhao, M., and Gong, X. Progressive layered extraction (ple): A novel multi-task learning (mtl) model for personalized recommendations. In Proceedings of the 14th ACM Conference on Recommender Systems, RecSys '20, pp. 269–278, New York, NY, USA, 2020. Association for Computing Machinery. ISBN 9781450375832. doi: 10.1145/3383313.3412236. URL https://doi.org/10.1145/3383313.3412236. + +Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Rozière, B., Goyal, N., Hambro, E., Azhar, F., Rodriguez, A., Joulin, A., Grave, E., and Lample, G. Llama: Open and efficient foundation language models, 2023a. + +Touvron, H., Martin, L., Stone, K., Albert, P., Almahairi, A., Babaei, Y., Bashlykov, N., Batra, S., Bhargava, P., + +Bhosale, S., Bikel, D., Blecher, L., Ferrer, C. C., Chen, M., Cucurull, G., Esiobu, D., Fernandes, J., Fu, J., Fu, W., Fuller, B., Gao, C., Goswami, V., Goyal, N., Hartshorn, A., Hosseini, S., Hou, R., Inan, H., Kardas, M., Kerkez, V., Khabsa, M., Kloumann, I., Korenev, A., Koura, P. S., Lachaux, M.-A., Lavril, T., Lee, J., Liskovich, D., Lu, Y., Mao, Y., Martinet, X., Mihaylov, T., Mishra, P., Molybog, I., Nie, Y., Poulton, A., Reizenstein, J., Rungta, R., Saladi, K., Schelten, A., Silva, R., Smith, E. M., Subramanian, R., Tan, X. E., Tang, B., Taylor, R., Williams, A., Kuan, J. X., Xu, P., Yan, Z., Zarov, I., Zhang, Y., Fan, A., Kambadur, M., Narang, S., Rodriguez, A., Stojnic, R., Edunov, S., and Scialom, T. Llama 2: Open foundation and fine-tuned chat models, 2023b. + +Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., and Polosukhin, I. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS'17, pp. 6000–6010, 2017. ISBN 9781510860964. + +Wang, R., Shivanna, R., Cheng, D., Jain, S., Lin, D., Hong, L., and Chi, E. Dcn v2: Improved deep & cross network and practical lessons for web-scale learning to rank systems. In Proceedings of the Web Conference 2021, WWW '21, pp. 1785–1797, New York, NY, USA, 2021. Association for Computing Machinery. ISBN 9781450383127. doi: 10.1145/3442381.3450078. URL https://doi.org/10.1145/3442381.3450078. + +Wang, Z., Zhao, L., Jiang, B., Zhou, G., Zhu, X., and Gai, K. Cold: Towards the next generation of pre-ranking system, 2020. + +Xia, X., Eksombatchai, P., Pancha, N., Badani, D. D., Wang, P.-W., Gu, N., Joshi, S. V., Farahpour, N., Zhang, Z., and Zhai, A. Transact: Transformer-based real-time user action model for recommendation at pinterest. In Proceedings of the 29th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, KDD '23, pp. 5249–5259, New York, NY, USA, 2023. Association for Computing Machinery. ISBN 9798400701030. doi: 10.1145/3580305.3599918. URL https://doi.org/10.1145/3580305.3599918. + +Xiao, J., Ye, H., He, X., Zhang, H., Wu, F., and Chua, T.-S. Attentional factorization machines: Learning the weight of feature interactions via attention networks. In Proceedings of the 26th International Joint Conference on Artificial Intelligence, IJCAI'17, pp. 3119–3125. AAAI Press, 2017. ISBN 9780999241103. + +Xiong, R., Yang, Y., He, D., Zheng, K., Zheng, S., Xing, C., Zhang, H., Lan, Y., Wang, L., and Liu, T.-Y. On layer normalization in the transformer architecture. In Proceedings of the 37th International Conference on Machine Learning, ICML'20. JMLR.org, 2020.Yang, J., Yi, X., Zhiyuan Cheng, D., Hong, L., Li, Y., Xiaoming Wang, S., Xu, T., and Chi, E. H. Mixed negative sampling for learning two-tower neural networks in recommendations. In Companion Proceedings of the Web Conference 2020, WWW '20, pp. 441–447, 2020. ISBN 9781450370240. + +Zhai, J., Lou, Y., and Gehrke, J. Atlas: A probabilistic algorithm for high dimensional similarity search. In Proceedings of the 2011 ACM SIGMOD International Conference on Management of Data, SIGMOD '11, pp. 997–1008, 2011. ISBN 9781450306614. + +Zhai, J., Gong, Z., Wang, Y., Sun, X., Yan, Z., Li, F., and Liu, X. Revisiting neural retrieval on accelerators. In Proceedings of the 29th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, KDD '23, pp. 5520–5531, New York, NY, USA, 2023a. Association for Computing Machinery. ISBN 9798400701030. doi: 10.1145/3580305.3599897. URL https://doi.org/10.1145/3580305.3599897. + +Zhai, Y., Jiang, C., Wang, L., Jia, X., Zhang, S., Chen, Z., Liu, X., and Zhu, Y. Bytetransformer: A high-performance transformer boosted for variable-length inputs. In 2023 IEEE International Parallel and Distributed Processing Symposium (IPDPS), pp. 344–355, Los Alamitos, CA, USA, May 2023b. IEEE Computer Society. doi: 10.1109/IPDPS54959.2023.00042. URL https://doi.ieeecomputersociety.org/10.1109/IPDPS54959.2023.00042. + +Zhang, B., Luo, L., Liu, X., Li, J., Chen, Z., Zhang, W., Wei, X., Hao, Y., Tsang, M., Wang, W., Liu, Y., Li, H., Badr, Y., Park, J., Yang, J., Mudigere, D., and Wen, E. Dhen: A deep and hierarchical ensemble network for large-scale click-through rate prediction, 2022. + +Zhao, X., Xia, L., Zhang, L., Ding, Z., Yin, D., and Tang, J. Deep reinforcement learning for page-wise recommendations. In Proceedings of the 12th ACM Conference on Recommender Systems, RecSys '18, pp. 95–103, New York, NY, USA, 2018. Association for Computing Machinery. ISBN 9781450359016. doi: 10.1145/3240323.3240374. URL https://doi.org/10.1145/3240323.3240374. + +Zhao, Z., Yang, Y., Wang, W., Liu, C., Shi, Y., Hu, W., Zhang, H., and Yang, S. Breaking the curse of quality saturation with user-centric ranking, 2023. + +Zhou, G., Zhu, X., Song, C., Fan, Y., Zhu, H., Ma, X., Yan, Y., Jin, J., Li, H., and Gai, K. Deep interest network for click-through rate prediction. KDD '18, 2018. + +Zhou, K., Wang, H., Zhao, W. X., Zhu, Y., Wang, S., Zhang, F., Wang, Z., and Wen, J.-R. S3-rec: Self-supervised learning for sequential recommendation with + +mutual information maximization. In Proceedings of the 29th ACM International Conference on Information & Knowledge Management, CIKM '20, pp. 1893–1902, New York, NY, USA, 2020. Association for Computing Machinery. ISBN 9781450368599. doi: 10.1145/3340531.3411954. URL https://doi.org/10.1145/3340531.3411954. + +Zhuo, J., Xu, Z., Dai, W., Zhu, H., Li, H., Xu, J., and Gai, K. Learning optimal tree models under beam search. In Proceedings of the 37th International Conference on Machine Learning, ICML'20. JMLR.org, 2020.### A. Notations + +We summarize key notations used in this paper in Table 8 and Table 9. + + +
SymbolDescription
$ \Psi_{k}(t_{j}) $The k-th training example (k is ordered globally) emitted by the feature logging system at time $ t_{j} $. In a typical DLRM recommendation system, after the user consumes some content $ \Phi_{i} $ (by responding with an action $ a_{i} $ such as skip, video completion and share), the feature logging system joins the tuple $ (\Phi_{i}, a_{i}) $ with the features used to rank $ \Phi_{i} $, and emits $ (\Phi_{i}, a_{i}) $ features for $ \Phi_{i} $ as a training example $ \Psi_{k}(t_{j}) $. As discussed in Section 2.3, DLRMs and GRs deal with different numbers of training examples, with the number of examples in GRs typically being 1-2 orders of magnitude smaller.
$ n_{c}(n_{c,i}) $Number of contents that user has interacted with (of user/sample i).
$ \Phi_{0}, \dots, \Phi_{n_{c}-1} $List of contents that a user has interacted with, in the context of a recommendation system. List of user actions corresponding to $ \Phi_{i} $s. When all predicted events are binary, each action can be considered a multi-hot vector over (atomic) events such as like, share, comment, image view, video initialization, video completion, hide, etc.
$ a_{0}, \dots, a_{n_{c}-1} $List of user actions corresponding to the value of $ a_{0} $, the value of $ a_{1} $, the value of $ a_{2} $, the value of $ a_{3} $, the value of $ a_{4} $, the value of $ a_{5} $, the value of $ a_{6} $, the value of $ a_{7} $, the value of $ a_{8} $, the value of $ a_{9} $, the value of $ a_{10} $, the value of $ a_{11} $, the value of $ a_{12} $, the value of $ a_{13} $, the value of $ a_{14} $, the value of $ a_{15} $, the value of $ a_{16} $, the value of $ a_{17} $, the value of $ a_{18} $, the value of $ a_{19} $, the value of $ a_{20} $, the value of $ a_{21} $, the value of $ a_{22} $, the value of $ a_{23} $, the value of $ a_{24} $, the value of $ a_{25} $, the value of $ a_{26} $, the value of $ a_{27} $, the value of $ a_{28} $, the value of $ a_{29} $, the value of $ a_{30} $, the value of $ a_{31} $, the value of $ a_{32} $, the value of $ a_{33} $, the value of $ a_{34} $, the value of $ a_{35} $, the value of $ a_{36} $, the value of $ a_{37} $, the value of $ a_{38} $, the value of $ a_{39} $, the value of $ a_{40} $, the value of $ a_{41} $, the value of $ a_{42} $, the value of $ a_{43} $, the value of $ a_{44} $, the value of $ a_{45} $, the value of $ a_{46} $, the value of $ a_{47} $, the value of $ a_{48} $, the value of $ a_{49} $, the value of $ a_{50} $, the value of $ a_{51} $, the value of $ a_{52} $, the value of $ a_{53} $, the value of $ a_{54} $, the value of $ a_{55} $, the value of $ a_{56} $, the value of $ a_{57} $, the value of $ a_{58} $, the value of $ a_{59} $, the value of $ a_{60} $, the value of $ a_{61} $, the value of $ a_{62} $, the value of $ a_{63} $, the value of $ a_{64} $, the value of $ a_{65} $, the value of $ a_{66} $, the value of $ a_{67} $, the value of $ a_{68} $, the value of $ a_{69} $, the value of $ a_{70} $, the value of $ a_{71} $, the value of $ a_{72} $, the value of $ a_{73} $, the value of $ a_{74} $, the value of $ a_{75} $, the value of $ a_{76} $, the value of $ a_{77} $, the value of $ a_{78} $, the value of $ a_{79} $, the value of $ a_{80} $, the value of $ a_{81} $, the value of $ a_{82} $, the value of $ a_{83} $, the value of $ a_{84} $, the value of $ a_{85} $, the value of $ a_{86} $, the value of $ a_{87} $, the value of $ a_{88} $, the value of $ a_{89} $, the value of $ a_{90} $, the value of $ a_{91} $, the value of $ a_{92} $, the value of $ a_{93} $, the value of $ a_{94} $, the value of $ a_{95} $, the value of $ a_{96} $, the value of $ a_{97} $, the value of $ a_{98} $, the value of $ a_{99} $, the value of $ a_{10} $, the value of $ a_{11} $, the value of $ a_{12} $, the value of $ a_{13} $, the value of $ a_{14} $, the value of $ a_{15} $, the value of $ a_{16} $, the value of $ a_{17} $, the value of $ a_{18} $, the value of $ a_{19} $, the value of $ a_{20} $, the value of $ a_{21} $, the value of $ a_{22} $, the value of $ a_{23} $, the value of $ a_{24} $, the value of $ a_{25} $, the value of $ a_{26} $, the value of $ a_{27} $, the value of $ a_{28} $, the value of $ a_{29} $, the value of $ a_{30} $, the value of $ a_{31} $, the value of $ a_{32} $, the value of $ a_{33} $, the value of $ a_{34} $, the value of $ a_{35} $, the value of $ a_{36} $, the value of $ a_{37} $, the value of $ a_{38} $, the value of $ a_{39} $, the value of $ a_{40} $, the value of $ a_{41} $, the value of $ a_{42} $, the value of $ a_{43} $, the value of $ a_{44} $, the value of $ a_{45} $, the value of $ a_{46} $, the value of $ a_{47} $, the value of $ a_{48} $, the value of $ a_{49} $, the value of $ a_{50} $, the value of $ a_{51} $, the value of $ a_{52} $, the value of $ a_{53} $, the value of $ a_{54} $, the value of $ a_{55} $, the value of $ a_{56} $, the value of $ a_{57} $, the value of $ a_{58} $, the value of $ a_{59} $, the value of $ a_{60} $, the value of $ a_{61} $, the value of $ a_{62} $, the value of $ a_{63} $, the value of $ a_{64} $, the value of $ a_{65} $, the value of $ a_{66} $, the value of $ a_{67} $, the value of $ a_{68} $, the value of $ a_{69} $, the value of $ a_{70} $, the value of $ a_{71} $, the value of $ a_{72} $, the value of $ a_{73} $, the value of $ a_{74} $, the value of $ a_{75} $, the value of $ a_{76} $, the value of $ a_{77} $, the value of $ a_{78} $, the value of $ a_{79} $, the value of $ a_{80} $, the value of $ a_{81} $, the value of $ a_{82} $, the value of $ a_{83} $, the value of $ a_{84} $, the value of $ a_{85} $, the value of $ a_{86} $, the value of $ a_{87} $, the value of $ a_{88} $, the value of $ a_{89} $, the value of $ a_{90} $, the value of $ a_{91} $, the value of $ a_{92} $, the value of $ a_{93} $, the value of $ a_{94} $, the value of $ a_{95} $, the value of $ a_{96} $, the value of $ a_{97} $, the value of $ a_{98} $, the value of $ a_{99} $, the value of $ a_{10} $, the value of $ a_{11} $, the value of $ a_{12} $, the value of $ a_{13} $, the value of $ a_{14} $, the value of $ a_{15} $, the value of $ a_{16} $, the value of $ a_{17} $, the value of $ a_{18} $, the value of $ a_{19} $, the value of $ a_{20} $, the value of $ a_{21} $, the value of $ a_{22} $, the value of $ a_{23} $, the value of $ a_{24} $, the value of $ a_{25} $, the value of $ a_{26} $, the value of $ a_{27} $, the value of $ a_{28} $, the value of $ a_{29} $, the value of $ a_{30} $, the value of $ a_{31} $, the value of $ a_{32} $, the value of $ a_{33} $, the value of $ a_{34} $, the value of $ a_{35} $, the value of $ a_{36} $, the value of $ a_{37} $, the value of $ a_{38} $, the value of $ a_{39} $, the value of $ a_{40} $, the value of $ a_{41} $, the value of $ a_{42} $, the value of $ a_{43} $, the value of $ a_{44} $, the value of $ a_{45} $, the value of $ a_{46} $, the value of $ a_{47} $, the value of $ a_{48} $, the value of $ a_{49} $, the value of $ a_{50} $, the value of $ a_{51} $, the value of $ a_{52} $, the value of $ a_{53} $, the value of $ a_{54} $, the value of $ a_{55} $, the value of $ a_{56} $, the value of $ a_{57} $, the value of $ a_{58} $, the value of $ a_{59} $, the value of $ a_{60} $, the value of $ a_{61} $, the value of $ a_{62} $, the value of $ a_{63} $, the value of $ a_{64} $, the value of $ a_{65} $, the value of $ a_{66} $, the value of $ a_{67} $, the value of $ a_{68} $, the value of $ a_{69} $, the value of $ a_{70} $, the value of $ a_{71} $, the value of $ a_{72} $, the value of $ a_{73} $, the value of $ a_{74} $, the value of $ a_{75} $, the value of $ a_{76} $, the value of $ a_{77} $, the value of $ a_{78} $, the value of $ a_{79} $, the value of $ a_{80} $, the value of $ a_{81} $, the value of $ a_{82} $, the value of $ a_{83} $, the value of $ a_{84} $, the value of $ a_{85} $, the value of $ a_{86} $, the value of $ a_{87} $, the value of $ a_{88} $, the value of $ a_{89} $, the value of $ a_{90} $, the value of $ a_{91} $, the value of $ a_{92} $, the value of $ a_{93} $, the value of $ a_{94} $, the value of $ a_{95} $, the value of $ a_{96} $, the value of $ a_{97} $, the value of $ a_{98} $, the value of $ a_{99} $, the value of $ a_{10} $, the value of $ a_{11} $, the value of $ a_{12} $, the value of $ a_{13} $, the value of $ a_{14} $, the value of $ a_{15} $, the value of $ a_{16} $, the value of $ a_{17} $, the value of $ a_{18} $, the value of $ a_{19} $, the value of $ a_{20} $, the value of $ a_{21} $, the value of $ a_{22} $, the value of $ a_{23} $, the value of $ a_{24} $, the value of $ a_{25} $, the value of $ a_{26} $, the value of $ a_{27} $, the value of $ a_{28} $, the value of $ a_{29} $, the value of $ a_{30} $, the value of $ a_{31} $, the value of $ a_{32} $, the value of $ a_{33} $, the value of $ a_{34} $, the value of $ a_{35} $, the value of $ a_{36} $, the value of $ a_{37} $, the value of $ a_{38} $, the value of $ a_{39} $, the value of $ a_{40} $, the value of $ a_{41} $, the value of $ a_{42} $, the value of $ a_{43} $, the value of $ a_{44} $, the value of $ a_{45} $, the value of $ a_{46} $, the value of $ a_{47} $, the value of $ a_{48} $, the value of $ a_{49} $, the value of $ a_{50} $, the value of $ a_{51} $, the value of $ a_{52} $, the value of $ a_{53} $, the value of $ a_{54} $, the value of $ a_{55} $, the value of $ a_{56} $, the value of $ a_{57} $, the value of $ a_{58} $, the value of $ a_{59} $, the value of $ a_{60} $, the value of $ a_{61} $, the value of $ a_{62} $, the value of $ a_{63} $, the value of $ a_{64} $, the value of $ a_{65} $, the value of $ a_{66} $, the value of $ a_{67} $, the value of $ a_{68} $, the value of $ a_{69} $, the value of $ a_{70} $, the value of $ a_{71} $, the value of $ a_{72} $, the value of $ a_{73} $, the value of $ a_{74} $, the value of $ a_{75} $, the value of $ a_{76} $, the value of $ a_{77} $, the value of $ a_{78} $, the value of $ a_{79} $, the value of $ a_{80} $, the value of $ a_{81} $, the value of $ a_{82} $, the value of $ a_{83} $, the value of $ a_{84} $, the value of $ a_{85} $, the value of $ a_{86} $, the value of $ a_{87} $, the value of $ a_{88} $, the value of $ a_{89} $, the value of $ a_{90} $, the value of $ a_{91} $, the value of $ a_{92} $, the value of $ a_{93} $, the value of $ a_{94} $, the value of $ a_{95} $, the value of $ a_{96} $, the value of $ a_{97} $, the value of $ a_{98} $, the value of $ a_{99} $, the value of $ a_{10} $, the value of $ a_{11} $, the value of $ a_{12} $, the value of $ a_{13} $, the value of $ a_{14} $, the value
+ +
Table 8. Table of Notations (continued on the next page).
+ + +### B. Generative Recommenders: Background and Formulations + +Many readers are likely more familiar with classical Deep Learning Recommendation Models (DLRMs) (Mudigere et al., 2022) given its popularity from YouTube DNN days (Covington et al., 2016) and its widespread usage in every single large online content and e-commerce platform (Cheng et al., 2016; Zhou et al., 2018; Wang et al., 2021; Chang et al., 2023; Xia et al., 2023; Zhai et al., 2023a). DLRMs operate on top of heterogeneous feature spaces using various neural
Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations
+ + + +
SymbolDescription
XInput to an HSTU layer. In standard terminology (before batching), $ X \in \mathbb{R}^{N \times d} $ assuming we have a input sequence containing N tokens.
$ Q(X) $, $ K(X) $, $ V(X) $Query, key, value in HSTU obtained for a given input X based on Equation (1). The definition is similar to Q, K, and V in standard Transformers. $ Q(X) $, $ K(X) \in \mathbb{R}^{h \times N \times d_{qk}} $, and $ V(X) \in \mathbb{R}^{h \times N \times d_v} $.
$ U(X) $HSTU uses $ U(X) $ to “gate” attention-pooled values ( $ V(X) $) in Equation (3), which together with $ f_2(\cdot) $, enables HSTU to avoid feedforward layers altogether. $ U(X) \in \mathbb{R}^{h \times N \times d_v} $.
$ A(X) $Attention tensor obtained for input X. $ A(X) \in \mathbb{R}^{h \times N \times N} $.
$ Y(X) $Output of a HSTU layer obtained for the input X. $ Y(X) \in \mathbb{R}^{d} $.
Split( $ \cdot $)The operation that splits a tensor into chunks. $ \phi_1(f_1(X)) \in \mathbb{R}^{N \times (2hd_{qk} + 2hd_v)} $ in Equation (1); we obtain $ U(X) $, $ V(X) $ (both of shape $ h \times N \times d_v $), $ Q(X) $, $ K(X) $ (both of shape $ h \times N \times d_{qk} $) by splitting the larger tensor (and permitting dimensions) with $ U(X) $, $ V(X) $, $ Q(X) $, $ K(X) = \text{Split}(\phi_1(f_1(X))) $.
$ \text{rab}^{p,t} $relative attention bias that incorporates both positional (Raffel et al., 2020) and temporal information (based on the time when the tokens are observed, $ t_0, \ldots, t_{n-1} $; one possible implementation is to apply some bucketization function to $ (t_j - t_i) $ for $ (i, j) $). In practice, we share $ \text{rab}^{p,t} $ across different attention heads within a layer, hence $ \text{rab}^{p,t} \in \mathbb{R}^{1 \times N \times N} $.
$ \alpha $Parameter controlling sparsity in the Stochastic Length algorithm used in HSTU (Section 3.2).
$ R $Register size on GPUs, in the context of the HSTU algorithm discussed in Section 3.2.
mNumber of candidates considered in a recommendation system's ranking stage.
$ b_m $Microbatch size, in the M-FALCON algorithm discussed in Section 3.4.
+ +
Table 9. Table of Notations (continued)
+ + +networks including feature interaction modules (Guo et al., 2017; Xiao et al., 2017; Wang et al., 2021), sequential pooling or target-aware pairwise attention modules (Hidasi et al., 2016; Zhou et al., 2018; Chang et al., 2023) and advanced multi-expert multi-task modules (Ma et al., 2018; Tang et al., 2020). We hence provided an overview of Generative Recommenders (GRs) by contrasting them with classical DLRMs explicitly in Section 2 and Section 3. In this section, we give the readers an alternative perspective starting from the classical sequential recommender literature. + +#### B.1. Background: Sequential Recommendations in Academia and Industry + +##### B.1.1. ACADEMIC RESEARCH (TRADITIONAL SEQUENTIAL RECOMMENDER SETTINGS) + +Recurrent neural networks (RNNs) were first applied to recommendation scenarios in GRU4Rec (Hidasi et al., 2016). Hidasi et al. (2016) considered Gated Recurrent Units (GRUs) and applied them over two datasets, RecSys Challenge 2015 $ ^{2} $ and VIDEO (a proprietary dataset). In both cases, only positive events (clicked e-commerce items or videos where users spent at least a certain amount of time watching) were kept as part of the input sequence. We further observe that in a classical industrial-scale two-stage recommendation system setup consisting of retrieval and ranking stages (Covington et al., 2016), the task that Hidasi et al. (2016) solved primarily maps to the retrieval task. + +Transformers, sequential transduction architectures, and their variants. Advances in sequential transduction architectures in later years, in particular Transformers (Vaswani et al., 2017), have motivated similar advancements in recommendation systems. SASRec (Kang & McAuley, 2018) first applied Transformers in an autoregressive setting. They considered the presence of a review or rating as positive feedback, thereby converting classical datasets like Amazon Reviews $ ^3 $ and MovieLens $ ^4 $ to sequences of positive items, similar to GRU4Rec. A binary cross entropy loss was employed, where positive target is defined as the next “positive” item (recall this is in essence just presence of a review or rating), and negative target is randomly sampled from the item corpus $ \mathbb{X} = \mathbb{X}_c $.Most subsequent research were built upon similar settings as GRU4Rec (Hidasi et al., 2016) and SASRec (Kang & McAuley, 2018) discussed above, such as BERT4Rec (Sun et al., 2019) applying bidirectional encoder setting from BERT (Devlin et al., 2019). S3Rec (Zhou et al., 2020) introducing an explicit pre-training stage, and so on. + +##### B.1.2. INDUSTRIAL APPLICATIONS AS PART OF DEEP LEARNING RECOMMENDATION MODELS (DLRMS) + +Sequential approaches, including sequential encoders and pairwise attention modules, have been widely applied in industrial settings due to their ability to enhance user representations as part of DLRMs. DLRMs commonly use relatively small sequence lengths, such as 20 in BST (Chen et al., 2019), 1,000 in DIN (Zhou et al., 2018), and 100 in TransAct (Xia et al., 2023). We observe that these are 1-3 orders of magnitude smaller compared with 8,192 in this work (Section 4.3). + +Despite using short sequence lengths, most DLRMs can successfully capture long-term user preferences. This can be attributed to two key aspects. First, precomputed user profiles/embeddings (Xia et al., 2023) or external vector stores (Chang et al., 2023) are commonly used in modern DLRMs, both of which effectively extend lookback windows. Second, a significant number of contextual-, user-, and item-side features were generally employed (Zhou et al., 2018; Chen et al., 2019; Chang et al., 2023; Xia et al., 2023) and various heterogeneous networks, such as FMs (Xiao et al., 2017; Guo et al., 2017), DCNs (Wang et al., 2021), MoEs, etc. are used to transform representations and combine outputs. + +In contrast to sequential settings discussed in Appendix B.1.1, all major industrial work defines loss over (user/request, candidate item) pairs. In the ranking setting, a multi-task binary cross-entropy loss is commonly used. In the retrieval setting, two tower setting (Covington et al., 2016) remains the dominant approach. Recent work has investigated representing the next item to recommend as a probability distribution over a sequence of (sub-)tokens, such as OTM (Zhuo et al., 2020), and DR (Gao et al., 2021) (note that in other recent work, the same setting is sometimes denoted as “generative retrieval”). They commonly utilize beam search to decode the item from sub-tokens. Advanced learned similarity functions, such as mixture-of-logits (Zhai et al., 2023a), have also been proposed and deployed as an alternative to two-tower setting and beam search given proliferation of modern accelerators such as GPUs, custom ASICs, and TPUs. + +From a problem formulation perspective, we consider all work discussed above part of DLRMs (Mudigere et al., 2022) given the model architectures, features used, and losses used differ significantly from academic sequential recommender research discussed in Appendix B.1.1. It's also worth remarking that there have been no successful applications of fully sequential ranking settings in industry, especially not at billion daily active users (DAU) scale, prior to this work. + +#### B.2. Formulations: Ranking and Retrieval as Sequential Transduction Tasks in Generative Recommenders (GRs) + +We next discuss three limitations in the traditional sequential recommender settings and DLRM settings, and how Generative Recommenders (GRs) address them from a problem formulation perspective. + +Ignorance of features other than user-interacted items. Past sequential formulations only consider contents (items) users explicitly interacted with (Hidasi et al., 2016; Kang & McAuley, 2018; Sun et al., 2019; Zhou et al., 2020), while industry-scale recommendation systems prior to GRs are trained over a vast number of features to enhance the representation of users and contents (Covington et al., 2016; Cheng et al., 2016; Zhou et al., 2018; Chen et al., 2019; Chang et al., 2023; Xia et al., 2023; Zhai et al., 2023a). GR addresses this limitation by a) compressing other categorical features and merging them with the main time series, and b) capturing numerical features through cross-attention interaction utilizing a target-aware formulation as discussed in Section 2.1 and Figure 2. We validate this by showing that the traditional “interaction-only” formulation that ignores such features degrades model quality significantly; experiment results can be found in the rows labeled “GR (interactions only)” in Table 7 and Table 6, where we show utilizing only interaction history led to a 1.3% decrease in hit rate@100 for retrieval and a 2.6% NE decrease in ranking (recall a 0.1% change in NE is significant, as discussed in Sections 4.1.2 and 4.3.1). + +User representations are computed in a target-independent setting. A second issue is most traditional sequential recommenders, including GRU4Rec (Hidasi et al., 2016), SASRec (Kang & McAuley, 2018), BERT4Rec (Sun et al., 2019), S3Rec (Zhou et al., 2020), etc. are formulated in a target-independent fashion where for a target item $ \Phi_i, \Phi_0, \Phi_1, \ldots, \Phi_{i-1} $ are used as encoder input to compute user representations, which is then used to provide predictions. In contrast, most major DLRM approaches used in industrial settings formulated the sequential modules used in a target-aware fashion, with the ability to incorporate “target” (ranking candidate) information into the user representations. These include DIN (Zhou et al., 2018) (Alibaba), BST (Chen et al., 2019) (Alibaba), TWIN (Chang et al., 2023) (Kwai), and TransAct (Xia et al., 2023) (Pinterest).
Generative Recommenders (GRs) combines the best of both worlds by interleaving the content and action sequences (Section 2.2) to enable applying target-aware attention in causal, autoregressive settings. We categorize and contrast prior work and this work in Table 10 $ ^{5} $.
+ + + +
Input for target item $ i $Expected output for target item $ i $ArchitectureTraining Procedure
GRs$ \Phi_0, a_0, \Phi_1, a_1, ..., \Phi_i $$ a_i $ (target-aware)Self-attention (HSTU)Causal autoregressive (streaming/single-pass)
GRU4Rec\nSASRec$ \Phi_0, \Phi_1, ..., \Phi_{i-1} $$ \Phi_i $RNNs (GRUs)\nSelf-attention (Transformers)Causal autoregressive (multi-pass)
BERT4Rec\nS3Rec$ \Phi_0, \Phi_1, ..., \Phi_{i-1} $\n(at inference time)$ \Phi_i $Self-attention (Transformers)Sequential multi-pass $ ^6 $
DIN\nBST\nTWIN\nTransAct$ \Phi_0, \Phi_1, ..., \Phi_i $\n $ (\Phi_0, a_0), ..., (\Phi_{i-1}, a_{i-1}), \Phi_i $$ a_i $ (target aware, implicitly as part of DLRMs)Pairwise attention\nSelf-attention (Transformers)\nTwo-stage pairwise attention\nSelf-attention (Transformers)Pointwise (generally streaming/single pass)
+ +Table 10. Comparison of prior work on sequential recommenders and GRs, in the ranking setting, with DLRMs included for completeness. + +Discriminative formulations restrict applicability of prior sequential recommender work to pointwise settings. Finally, traditional sequential recommenders are discriminative by design. Existing sequential recommender literature, including seminal work such as GRU4Rec and SASRec, model $ p(\Phi_i|\Phi_0, a_0, \ldots, \Phi_{i-1}, a_{i-1}) $, or the conditional distribution of the next item to recommend given users' current states. On the other hand, we observe that there are two probabilistic processes in standard recommendation systems, namely the process of the recommendation system suggesting a content $ \Phi_i $ (e.g., some photo or video) to the user, and the process of the user reacting to the suggested content $ \Phi_i $ via some action $ a_i $ (which can be a combination of like, video completion, skip, etc.). + +A generative approach needs to model the joint distribution over the sequence of suggested contents and user actions, or $p(\Phi_{0}, a_{0}, \Phi_{1}, a_{1}, \ldots, \Phi_{n_{c}-1}, a_{n_{c}-1})$, as discussed in Section 2.2. Our proposal of Generative Recommenders enables modeling of such distributions, as shown in Table 11 (Figure 8). Note that the next action token $(a_{i})$ prediction task is exactly the GR ranking setting discussed in Table 1, whereas the next content $(\Phi_{i})$ prediction task is similar to the retrieval setting adapted to the interleaved setting, with the target changed in order to learn the input data distribution. + + +
TaskSpecification (Inputs / Outputs / Length)
$ x_{i}s $$ \Phi_{0}, a_{0}, \Phi_{1}, a_{1}, ..., \Phi_{n_{c}-2}, a_{n_{c}-2}, \Phi_{n_{c}-1}, a_{n_{c}-1} $
$ y_{i}s $$ a_{0}, \varnothing, a_{1}, \varnothing, ..., a_{n_{c}-2}, \varnothing, a_{n_{c}-1}, \varnothing $
$ n $$ 2n_{c} $
$ x_{i}s $$ \Phi_{0}, a_{0}, \Phi_{1}, a_{1}, ..., \Phi_{n_{c}-2}, a_{n_{c}-2}, \Phi_{n_{c}-1}, a_{n_{c}-1} $
$ y_{i}s $$ \varnothing, \Phi_{1}, \varnothing, \Phi_{2}, ..., \varnothing, \Phi_{n_{c}-1}, \varnothing, \varnothing $
$ n $$ 2n_{c} $
+ +
Table 11. Generative modeling over $ p(\Phi_0, a_0, \ldots, \Phi_{n_c-1}, a_{n_c-1}) $. An illustration is provided in Figure 8.
+ + +Importantly, this formulation not only enables proper modeling of data distribution but further enables sampling sequences of items to recommend to the user directly via e.g., beam search. We hypothesize that this will lead to a superior approach compared with traditional listwise settings (e.g., DPP (Gillenwater et al., 2014) and RL (Zhao et al., 2018)), and we leave the full formulation and evaluation of such systems (briefly discussed in Section 6) as a future work. + +### C. Evaluation: Synthetic Data + +As previously discussed in Section 3.1, standard softmax attention, due to its normalization factor, makes it challenging to capture intensity of user preferences which is important for user representation learning. This aspect is important in recommendation scenarios as the system may need to predict the intensity of engagements (e.g., number of future positive responses).
Image
+ + +
Figure 8. Comparison of traditional sequential recommenders (left) and Generative Recommenders (right). We illustrate sequential recommenders in causal autoregressive settings and GRs without contextual features to facilitate comparison. On the left hand side, the action types $ a_{i} $s are either ignored or combined with item information $ \Phi_{i} $s using MLPs, before going into self-attention blocks.
+ + +actions on a particular topic) in addition to the relative ordering of items. + +To understand this behavior, we construct synthetic data following a Dirichlet Process that generates streaming data over a dynamic set of vocabulary. Dirichlet Process captures the behavior that ‘rich gets richer’ in user engagement histories. We set up the synthetic experiment as follows: + +• We randomly assign each one of 20,000 item ids to exactly one of 100 categories. + +• We generate 1,000,000 records of length 128 each, with the first 90% being used for training and the final 10% used for testing. To simulate the streaming training setting, we make the initial 40% of item ids available initially and the rest available progressively at equal intervals; i.e., at record 500,000, the maximum id that can be sampled is $ (40\% + 60\% \times 0.5) \times 20,000 = 14,000 $. + +• We randomly select up to 5 categories out of 100 for each record and randomly sample a prior $ H_{c} $ over these 5 categories. We sequentially sample category for each position following a Dirichlet process over possible categories as follows: + +- for n > 1: + + $ ^{*} $ with probability $ \alpha/(\alpha+n-1) $, draw category c from $ H_{c} $. + +* with probability $ n_{c}/(\alpha + n - 1) $, draw category c, where $ n_{c} $ is the number of previous items with category c. + + $ ^{*} $ randomly sample an assigned item matching category c subject to streaming constraints. + +where $ \alpha $ is uniformly sampled at random from (1.0, 500.0). + +The results can be found in Table 2. We always ablate $ rab^{p,t} $ for HSTU as this dataset does not have timestamps. We observe HSTU increasing Hit Rate@10 by more than 100% relative to standard Transformers. Importantly, replacing HSTU's pointwise attention mechanism with softmax ("HSTU w/ Softmax") also leads to a significant reduction in hit rate, verifying the importance of pointwise attention-like aggregation mechanisms. + +### D. Evaluation: Traditional Sequential Recommender Settings + +Our evaluations in Section 4.1.1 focused on comparing HSTU with a state-of-the-art Transformer baseline, SASRec, utilizing latest training recipe. In this section, we further consider two other alternative approaches. + +Recurrent neural networks (RNNs). We consider the classical work on sequential recommender, GRU4Rec (Hidasi et al., 2016), to help readers understand how self-attention models, including Transformers and HSTU, compare to traditional RNNs, when all the latest modeling and training improvements are fully incorporated. + +Self-supervised sequential approaches. We consider the most popular work, BERT4Rec (Sun et al., 2019), to understand how bidirectional self-supervision (leveraged in BERT4Rec via a Cloze objective) compares with unidirectional causal autoregressive settings, such as SASRec and HSTU.
Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations
+ + + +
MethodHR@10HR@50HR@200NDCG@10NDCG@200
ML-1MSASRec (2023).2853.5474.7528.1603.2498
BERT4Rec.2843 (-0.4%)--.1537 (-4.1%)-
GRU4Rec.2811 (-1.5%)--.1648 (+2.8%)-
HSTU.3097 (+8.6%).5754 (+5.1%).7716 (+2.5%).1720 (+7.3%).2606 (+4.3%)
HSTU-large.3294 (+15.5%).5935 (+8.4%).7839 (+4.1%).1893 (+18.1%).2771 (+10.9%)
ML-20MSASRec (2023).2906.5499.7655.1621.2521
BERT4Rec.2816 (-3.4%)--.1703 (+5.1%)-
GRU4Rec.2813 (-3.2%)--.1730 (+6.7%)-
HSTU.3252 (+11.9%).5885 (+7.0%).7943 (+3.8%).1878 (+15.9%).2774 (+10.0%)
HSTU-large.3567 (+22.8%).6149 (+11.8%).8076 (+5.5%).2106 (+30.0%).2971 (+17.9%)
BooksSASRec (2023).0292.0729.1400.0156.0350
HSTU.0404 (+38.4%).0943 (+29.5%).1710 (+22.1%).0219 (+40.6%).0450 (+28.6%)
HSTU-large.0469 (+60.6%).1066 (+46.2%).1876 (+33.9%).0257 (+65.8%).0508 (+45.1%)
+ +
Table 12. Evaluations of methods on public datasets in traditional sequential recommender settings (multi-pass, full-shuffle). Compared with Table 4, two other baselines (GRU4Rec and BERT4Rec) are included for completeness.
+ + +Results are presented in Table 12. We reuse BERT4Rec results and GRU4Rec results on ML-1M and ML-20M as reported by Klenitskiy & Vasilev (2023). Given a sampled softmax loss is used, we hold the number of negatives used constant (128 for ML-1M, ML-20M and 512 for Amazon Books) to ensure a fair comparison between methods. + +The results confirm that SASRec remains one of the most competitive approaches in traditional sequential recommendation settings when sampled softmax loss is used (Zhai et al., 2023a; Klenitskiy & Vasilev, 2023), while HSTU significantly outperforms evaluated transformers, RNNs, and self-supervised bidirectional transformers. + +### E. Evaluation: Traditional DLRM Baselines + +The DLRM baseline configurations used in Section 4 reflect continued iterations of hundreds of researchers and engineers over multiple years and a close approximation of production configurations on a large internet platform with billions of daily active users before HSTUs/GRs were deployed. We give a high level description of the models used below. + +Ranking Setting. The baseline ranking model, as described in (Mudigere et al., 2022), employs approximately one thousand dense features and fifty sparse features. We incorporated various modeling techniques such as Mixture of Experts (Ma et al., 2018), variants of Deep & Cross Network (Wang et al., 2021), various sequential recommendation modules including target-aware pairwise attention (one commonly used variant in industrial settings can be found in (Zhou et al., 2018)), and residual connection over special interaction layers (He et al., 2015; Zhang et al., 2022). For the low FLOPs regime in the scaling law section (Section 4.3.1), some modules with high computational costs were simplified and/or replaced with other state-of-the-art variants like DCNs to achieve desired FLOPs. + +While we cannot disclose the exact settings due to confidentiality considerations, to the best of our knowledge, our baseline represents one of the best known DLRM approaches when recent research are fully incorporated. To validate this claim and to facilitate readers' understanding, we report a typical setup based on identical features but only utilizing major published results including DIN (Zhou et al., 2018), DCN (Wang et al., 2021), and MMoE (Ma et al., 2018) ("DLRM (DIN+DCN)") in Table 7, with the combined architecture illustrated in Figure 9. This setup significantly underperformed our production DLRM setup by 0.71% in NE for the main E-Task and 0.57% in NE for the main C-Task (where 0.1% NE is significant). + +Retrieval Setting. The baseline retrieval model employs a standard two-tower neutral retrieval setting (Covington et al., 2016) with mixed in-batch and out-of-batch sampling. The input feature set consists of both high cardinality sparse features (e.g., item ids, user ids) and low cardinality sparse features (e.g. languages, topics, interest entities). A stack of feed forward layers with residual connections (He et al., 2015) is used to compress the input features into user and item embeddings. + +Features and Sequence Length. The features used in both of the DLRM baselines, including main user interaction history that is utilized by various sequential encoder/pairwise attention modules, are strict supersets of the features used in all GR candidates. This applies to all studies conducted in this paper, including those used in the scaling studies (Section 4.3.1).
Image
+ + +
Figure 9. A high level architecture of a baseline DLRM ranking model ("DLRM (DIN+DCN)" in Table 7) that utilizes major published work including DIN (Zhou et al., 2018), DCN (Wang et al., 2021), and MMoE (Ma et al., 2018).
+ + + +
Metric NameSelection Type
GreedyWeightedRandom
Main Engagement Metric (NE)0.4950.4940.495
Main Consumption Metric (NE)0.7920.7890.791
+ +
Table 13. Comparison of subsequence selection methods for Stochastic Length on model quality, measured by Normalized Entropy (NE).
+ + +### F. Stochastic Length + +#### F.1. Subsequence Selection + +In Equation (4), we select a subsequence of length L from the full user history in order to increase sparsity. Our empirical results indicate that careful design of the subsequence selection technique can improve model quality. We compute a metric $ f_{i}=t_{n}-t_{i} $ which corresponds to the amount of time elapsed since the user interacted with item $ x_{i} $. We conduct offline experiments with the following subsequence selection methods: + +• Greedy Selection – Selects L items with smallest values of $ f_{i} $ from S + +• Random Selection – Selects L items from S randomly + +• Feature-Weighted Selection – Selects L items from S according to a weighted distribution $ 1 - f_{n,i}/(\sum_{j=1}^{L}f_{j,i}) $ + +During our offline experiments, the feature-weighted subsequence selection method resulted in the best model quality, as shown in Table 13. + +#### F.2. Impact of Stochastic Length on Sequence Sparsity + +In Table 3, we show the impact of Stochastic Length on sequence sparsity for a representative industry-scale configuration with 30-day user engagement history. The sequence sparsity is defined as one minus the ratio of the average sequence length of all samples divided by the maximum sequence length. To better characterize the computational cost of sparse attentions, we also define $ s_{2} $, which is defined as one minus the sparsity of the attention matrix. For reference, we present the results for 60-day and 90-day user engagement history in Table 14 and Table 15, respectively. +
AlphaMax Sequence Length
1,0242,0484,0968,192
sparsitys2sparsitys2sparsitys2sparsitys2
1.671.5%89.4%75.8%92.3%79.4%94.7%83.8%97.3%
1.757.3%77.6%60.6%79.8%67.3%86.6%74.5%93.3%
1.837.5%56.2%42.6%62.1%51.9%74.2%62.6%85.5%
1.915.0%25.2%17.7%29.0%29.6%47.5%57.8%80.9%
2.01.2%1.7%2.5%3.5%18.9%30.8%57.6%80.6%
+ +
Table 14. Impact of Stochastic Length (SL) on sequence sparsity, over a 60d user engagement history.
+ + + +
AlphaMax Sequence Length
1,0242,0484,0968,192
sparsitys2sparsitys2sparsitys2sparsitys2
1.668.0%85.0%74.6%90.8%78.6%93.5%83.5%97.3%
1.756.3%76.1%61.2%80.6%67.5%87.0%74.3%93.3%
1.838.9%58.3%42.0%61.3%50.4%72.4%61.0%84.4%
1.916.2%27.3%17.3%28.6%27.2%44.4%54.3%77.8%
2.00.9%1.2%1.6%2.1%13.5%22.5%54.0%77.4%
+ +
Table 15. Impact of Stochastic Length (SL) on sequence sparsity, over a 90d user engagement history.
+ + +#### F.3. Comparisons Against Sequence Length Extrapolation Techniques + +We conduct additional studies to verify that Stochastic Length is competitive against existing techniques for sequence length extrapolation used in language modeling. Many existing methods perform sequence length extrapolation through modifications of RoPE (Su et al., 2023). To compare against existing methods, we train an HSTU variant (HSTU-RoPE) with no relative attention bias and rotary embeddings. + +We evaluate the following sequence length extrapolation methods on HSTU-RoPE: + +• Zero-Shot - Apply NTK-Aware RoPE (Peng et al., 2024) before directly evaluating the model with no finetuning; + +• Fine-tune - Finetune the model for 1000 steps after applying NTK-by-parts (Peng et al., 2024). + +We evaluate the following sequence length extrapolation methods on HSTU (includes relative attention bias, no rotary embeddings): + +- Zero-Shot - Clamp the relative position bias according to the maximum training sequence length, directly evaluate the model (Raffel et al., 2020; Press et al., 2022); + +Fine-tune - Clamp the relative position bias according to the maximum training sequence length, fine-tune the model for 1000 steps before evaluating the model. + +
Image
+ + +
Image
+ + +
Image
+ + +
Image
+ + +
Figure 10. Impact of Stochastic Length (SL) on ranking model metrics. Left to right: n = [1024, 2048, 4096, 8192] (n is after interleaving algorithm as discussed in Section 2.2 to enable target-aware cross attention in causal-masked settings).
+
Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations
+ + + +
Evaluation StrategyAverage NE Difference vs Full Sequence Baseline
Model Type2048 / 52% Sparsity4096 / 75% Sparsity
Zero-shotHSTU (Raffel et al., 2020)6.46%10.35%
HSTU-RoPE (Peng et al., 2024)7.51%11.27%
Fine-tuneHSTU (Raffel et al., 2020)1.92%2.21%
HSTU-RoPE (Peng et al., 2024)1.61%2.19%
Stochastic Length (SL)HSTU0.098%0.64%
+ +
Table 16. Comparisons of Stochastic Length (SL) vs existing Length Extrapolation methods.
+ + +In Table 16, we report the NE difference between models with induced data sparsity during training (Stochastic Length, zero-shot, fine-tuning) and models trained on the full data. We define the sparsity for zero-shot and fine-tuning techniques to be the average sequence length during training divided by the max sequence length during evaluation. All zero-shot and fine-tuned models are trained on 1024 sequence length data and are evaluated against 2048 and 4096 sequence length data. In order to find an appropriate Stochastic Length baseline for these techniques, we select Stochastic Length settings which result in the same data sparsity metrics. + +We believe that zero-shot and fine-tuning approaches to sequence length extrapolation are not well-suited for recommendation scenarios that deal with high cardinality ids. Empirically, we observe that Stochastic Length significantly outperforms fine-tuning and zero-shot approaches. We believe that this could be due to our large vocabulary size. Zero-shot and fine-tuning approaches fail to learn good representations for older ids, which could hurt their ability to fully leverage the information contained in longer sequences. + +### G. Sparse Grouped GEMMs and Fused Relative Attention Bias + +We provide additional information about the efficient HSTU attention kernel that was introduced in Section 3.2. Our approach builds upon Memory-efficient Attention (Rabe & Staats, 2021) and FlashAttention (Dao et al., 2022), and is a memory-efficient self-attention mechanism that divides the input into blocks and avoids materializing the large $ h \times N \times N $ intermediate attention tensors for the backward pass. By exploiting the sparsity of input sequences, we can reformulate the attention computation as a group of back-to-back GEMMs with different shapes. We implement efficient GPU kernels to accelerate this computation. The construction of the relative attention bias is also a bottleneck due to memory accesses. To address this issue, we have fused the relative bias construction and the grouped GEMMs into a single GPU kernel and managed to accumulate gradients using GPU's fast shared memory in the backward pass. Although our algorithm requires recomputing attention and relative bias in the backward pass, it is significantly faster and uses less memory than the standard approach used in Transformers.### H. Microbatched-Fast Attention Leveraging Cacheable OperationNs (M-FALCON) + +In this section, we provide a detailed description of the M-FALCON algorithm discussed in Section 3.4. We give pseudocode for M-FALCON in Algorithm 1. M-FALCON introduces three key ideas. + +
Image
+ + +
(a) GR's ranking model training (with $ n = 2n_{c} $ tokens), in causal autoregressive settings.
+ + +
Image
+ + +
(b) GR's ranking model inference utilizing the M-FALCON algorithm.
+ + +
Figure 11. Illustration of the M-FALCON algorithm. Top: model training in GR’s target-aware formulation. Bottom: model inference with $m$ candidates $\Phi'_0, \ldots, \Phi'_{m-1}$, divided into $\lceil m/b_m \rceil$ microbatches, where we show model inference for the first microbatch $\Phi'_0, \ldots, \Phi'_{b_{m-1}}$ (with $2n_c + b_m$ total tokens after $\Phi_0, a_0, \ldots, \Phi_{n_c-1}, a_{n_c-1}$ are taken into account) above the dotted line. Note that the self-attention algorithm is modified such that $\Phi'_i$ cannot attend to $\Phi'_j$ when $i \neq j$ - this is highlighted with “×” in the figure.
+ + +Batched inference can be applied to causal autoregressive settings. The ranking task in GR is formulated in a target aware fashion as discussed Section 2.2. Common wisdom suggests that in a target-aware setting, we need to perform inference for one item at a time, with a cost of $ O(mn^2d) $ for m candidates and a sequence length of n. Here we show that this is not the optimal solution; even with vanilla Transformers, we can modify the attention mask used in self-attention to batch such operations (“batched inference”) and reduce cost to $ O((n+m)^2d) = O(n^2d) $. + +An illustration is provided in Figure 11. Here, both Figure 11 (a) and (b) involve an attention mask matrix for causal autoregressive settings. The key difference is that Figure 11 (a) uses a standard lower triangular matrix of size $ 2n_{c} $ for causal autoregressive settings.training, whereas Figure 11 (b) modifies a lower triangular matrix of size $ 2n_c + b_m $ by setting entries for $ (i, j) $s where $ i, j \geq 2n_c $, $ i \neq j $ to False or $ -\infty $ to prevent target positions $ \Phi'_0, \ldots, \Phi_{b_{m-1}} $ from attending to each other. It is easy to see that by doing so, the output of the self-attention block for $ \Phi'_i $, $ a'_i $, only depends on $ \Phi_0 $, $ a_0 $, $ \ldots $, $ \Phi_{n_c-1} $, $ a_{n_c-1} $, but not on $ \Phi'_j $ ( $ i \neq j $). In other words, by making a forward pass over $ (2n_c + b_m) $ tokens using the modified attention mask, we can now obtain the same results for the last $ b_m $ tokens as if we've made $ b_m $ separate forward passes over $ (2n_c + 1) $ tokens, with $ \Phi'_i $ placed at the $ 2n_c $-th (0-based) position during the $ i $-th forward pass utilizing a standard causal attention mask. + +Microbatching scales batched inference to large candidate sets. Ranking stage may need to deal with a large number of ranking candidates, up to tens of thousands (Wang et al., 2020). We can divide the overall $m$ candidates into $\lceil m/b_m \rceil$ microbatches of size $b_m$ such that $O(b_m) = O(n)$, which retains the $O((n + m)^2 d) = O(n^2 d)$ running time previously discussed for most practical recommender settings, up to tens of thousands of candidates. + +Encoder-level caching enables compute sharing within and across requests. Finally, KV caching (Pope et al., 2022) can be applied both within and across requests. For instance, for the HSTU model presented in this work (Section 3), $ K(X) $ and $ V(X) $ are fully cachable across microbatches within and/or across requests. For a cached forward pass, we only need to compute $ U(X) $, $ Q(X) $, $ K(X) $, and $ V(X) $ for the last $ b_m $ tokens, while reusing cached $ K(X) $ and $ V(X) $ for the sequentialized user history containing n tokens. $ f_2(\text{Norm}(A(X)V(X)) \odot U(X)) $ similarly only needs to be recomputed for the $ b_m $ candidates. This reduces the cached forward pass's computational complexity to $ O(b_m d^2 + b_m nd) $, which significantly improves upon $ O((n + b_m)d^2 + (n + b_m)^2 d) $ by a factor of 2-4 even when $ b_m = n $. + +Algorithm 1 M-FALCON Algorithm. + +1: Input: Merged token series $ x_0, x_1, \ldots, x_{n-1} $ (can be e.g., $ (\Phi_0, a_0, \ldots, \Phi_{n_c-1}, a_{n_c-1}) $ where $ n = 2n_c $); m ranking candidates $ \Phi'_0, \ldots, \Phi'_{m-1} $; a b-layer h-heads self-attention model trained in causal autoregressive settings (e.g., HSTU or Transformers) $ f(X, cacheStates, attnMask) \to (X', updatedCacheStates) $ where $ X, X' \in \mathbb{R}^{N \times d} $, attnMask $ \in \mathbb{R}^{N \times N} $, and cachedStates, updatedCacheStates $ \in \mathbb{R}^{b \times h \times N \times d_{qk}} \times \mathbb{R}^{b \times h \times N \times d_{qk}} $ (due to caching $ K(X) $s and $ V(X) $s across b layers); microbatch size $ b_m $, where we assume m is a multiple of $ b_m $ for simplicity. + +2: Output: Predictions for all m ranking candidates, $ (a'_0, \ldots, a'_{m-1}) $. + +3: numMicrobatches = $ (m + b_m - 1) // b_m $ + +4: attnMask = $ L_{n+b_m} $ $ \{L_{n+b_m}\} $ represents a lower triangular matrix. Lower triangular entries are 0s, the rest are $ -\infty $. + +5: attnMask[i, j] = - $ \infty $ for i, j $ \geq n $, i $ \neq j $ $ \{This $ prevents the last $ b_m $ entries from attending to each other.\} + +6: $ (a'_0, a'_1, \ldots, a'_{b_m-1}) $, $ kvCache \leftarrow f(embLayer((x_0, x_1, \ldots, x_{n-1}, \Phi'_0, \ldots, \Phi'_{b_m-1})), \varnothing, attnMask) $ + +7: predictions = $ (a'_0, a'_1, \ldots, a'_{b_m-1}) $ + +8: i = 1 + +9: while i < numMicrobatches do + +10: $ (a'_{b_m, i}, a'_{b_m+1}, a'_{b_m(i+1)-1}), \ldots \leftarrow f(embLayer((x_0, x_1, \ldots, x_{n-1}, \Phi'_{b_m, i}, \ldots, \Phi'_{b_m(i+1)-1})), kvCache, attnMask) $ + +11: predictions $ \leftarrow $ predictions + $ (a'_{b_m, i}, a'_{b_m+1}, \ldots, a'_{b_m(i+1)-1}) $ + +12: i $ \leftarrow $ i + 1 + +13: end while + +14: return predictions + +Algorithm 1 is illustrated in Figure 11 to help with understanding. We remark that M-FALCON is not only applicable to HSTUs and GRs, but also broadly applicable as an inference optimization algorithm for other target-aware causal autoregressive settings based on self-attention architectures. + +#### H.1. Evaluation of Inference Throughput: Generative Recommenders (GRs) w/ M-FALCON vs DLRMs + +As discussed in Section 3.4, M-FALCON handles $ b_{m} $ candidates in parallel to amortize computation costs across all m candidates at inference time. To understand our design, we compare the throughput (i.e., the number of candidates scored per second, QPS) of GRs and DLRMs based on the same hardware setups. + +As shown in Figure 12 and Figure 13, GRs' throughput scales in a sublinear way based on the number of ranking-stage candidates (m), up to a certain region - m = 2048 in our case study - due to batched inference enabling cost amortization. This confirms the criticality of batched inference in causal autoregressive settings. Due to attention complexity scaling as $ O((n + b_m)^2) $, leveraging multiple microbatches by itself improves throughput. Caching further eliminates redundant linear and attention computations on top of microbatching. The two combined resulted in up to 1.99x additional speedups relativeto the $ b_{m} = m = 1024 $ baseline using a single microbatch, as shown in Figure 13. Overall, with the efficient HSTU encoder design and utilizing M-FALCON, HSTU-based Generative Recommenders outperform DLRMs in terms of throughput on a large-scale production setup by up to 2.99x, despite GRs being 285x more complex in terms of FLOPs. + +
Image
+ + +
Figure 12. End-to-end inference throughput: DLRMs vs GRs (w/ M-FALCON) in large-scale industrial settings. Note that this figure is the same as Figure 6, and is reproduced here to facilitate reading.
+ + +
Image
+ + +
Figure 13. End-to-end inference throughput: M-FALCON throughput scaling, on top of the 285x FLOPs GR model, in large batch settings where m (total number of ranking candidates) ranges from 1024 to 16384, and $ b_{m} = 1024 $.