WorksComputer Science
MoR4Rec: Mixture-of-Recursion for Sequential Recommendation
Abstract
Sequential recommender systems aim to predict a user's next interaction by modeling temporal dependencies in historical behavior sequences. To capture such dependencies, recent approaches increasingly rely on attention-based architectures, particularly transformers. While effective at modeling long-range sequential patterns, these models apply a fixed computation depth to all interaction items, treating them as equally complex. However, user behavior is inherently heterogeneous, with many interactions following simple repetitive patterns, whereas others require modeling higher-order dependencies. This mismatch leads to inefficient utilization of model capacity and unnecessary computational overhead, particularly in deep transformer-based architectures. To address this issue, we propose MoR4Rec, a sequential recommendation framework based on a Mixture-of-Recursion paradigm, which enables item-wise adaptive computation through a shared transformer backbone. A learned routing mechanism dynamically assigns each item to an appropriate recursion depth, allocating deeper computation to complex interactions while processing simpler patterns more efficiently. To improve computational efficiency, we develop a cascade-based strategy with key-value sharing across recursion steps. We further introduce a gated attention mechanism that adaptively regulates contextual information during recursive sequence modeling. Extensive experiments on three benchmark datasets show that MoR4Rec consistently outperforms strong transformer-based baselines, achieving average gains of 2.28% in Recall@5, 2.50% in NDCG@5, and 2.0% in MRR@5 over the strongest baseline. The improvements remain consistent across top-10 and top-20 recommendation cutoffs, while comparisons with vanilla transformers demonstrate the computational efficiency of adaptive recursive processing.
Introduction
Sequential recommender systems (SRS) are essential for delivering personalized digital experiences across a wide range of platforms, such as e-commerce, travel, and social networks [4, 39]. These systems aim to predict a user’s future interactions by learning a mapping from historical behavioral logs to a probability distribution over candidate items. However, learning such a mapping is inherently challenging because user preferences are heterogeneous and non-stationary. A single interaction sequence often reflects multiple underlying behavioral dynamics, including short-term intent reflecting immediate needs, recurring consumption patterns shaped by habitual preferences, and long-term interests that evolve gradually over time. To model such behavioral diversity, attention-based architectures have become a primary focus in sequential recommendation research [19, 32]. Among these, transformer architectures have emerged as the de facto standard due to their ability to model complex, long-range dependencies in user interaction sequences [14, 27, 8, 25, 18].
Transformer-based models usually process histories as time-ordered item embeddings, which are then processed through multiple encoding layers, where dependencies across interactions are captured via self-attention to produce contextualized representations. Though effective, these models typically use a fixed computation depth, processing every interaction through the same stack of layers regardless of its complexity. This can be suboptimal in real-world recommendation scenarios, as user interaction sequences are often highly heterogeneous. For example, repetitive or habitual interactions may require only shallow reasoning, whereas interactions that signal shifts in user preference may benefit from deeper contextual modeling. Consequently, there is a need for models that can dynamically adapt their computational depth to the complexity of individual interactions while maintaining a unified representation framework.
Recent research on transformer efficiency has largely focused on two complementary strategies, namely parameter sharing to reduce memory footprint [15] and adaptive computation to modulate processing depth [28]. Parameter efficiency is usually achieved through layer tying, where weights are reused across layers to reduce model size while preserving expressiveness. In parallel, adaptive computation methods, such as early exiting, allocate computation dynamically by processing simpler inputs with fewer layers. However, these paradigms have largely been developed in isolation. Recursive transformers offer a natural framework for unifying parameter sharing and adaptive computation [24]. Yet most existing recursive transformers keep the recursion depth fixed, as dynamic recursion often requires specialized training procedures and remains challenging to deploy efficiently. Mixture-of-Recursions (MoR) [2] introduces adaptive computation by allowing different items to undergo different numbers of recursive transformations within a shared transformer architecture. A learned router determines the recursion depth for each item, so items that can be adequately represented with fewer transformations receive shallow computation, while items requiring more complex contextual modeling are processed through additional recursive steps.
Despite these advances, the adoption of such adaptive computation paradigms in sequential recommendation remains limited. In particular, existing models largely rely on uniform computation across interactions, failing to account for the varying complexity of user behavior. ior sequences. To address this limitation, we propose MoR4Rec, a novel transformer-based framework that enables item-wise adaptive computation through a Mixture-of-Recursion mechanism [2]. By dynamically adjusting the computational depth for each interaction within a shared recursive architecture, MoR4Rec effectively captures heterogeneous user behavior while maintaining parameter efficiency. To further improve efficiency and representation learning, the proposed framework inherits the recursion-aware key-value sharing of MoR and further introduces a gated attention mechanism that adaptively regulates contextual signals during sequence modeling. The key contributions are summarized as follows:
A novel sequential framework (MoR4Rec) that dynamically routes each interaction to an appropriate recursion depth within a shared transformer architecture to enable item-level adaptive depth modeling.
A recursion-aware key-value (KV) sharing mechanism to reuse attention states across recursive steps, reducing the redundant computation substantially while preserving modeling capacity.
A lightweight gated mechanism that adaptively regulates the role of contextual signals to improve representation quality.
A set of auxiliary regularization objectives to ensure balanced and stable routing across recursion depths and prevent degenerate solutions.
Extensive experiments on three benchmark datasets against ten competitive baselines demonstrate that MoR4Rec consistently achieves state-of-the-art performance.
The remainder of this paper is organized as follows. § 2 reviews the relevant literature on sequential recommendation. § 3 presents the proposed MoR4Rec framework. § 4 describes the experimental setup. The results and analysis are discussed in § 5. Finally, § 6 concludes the paper and outlines potential directions for future work.
Related Work
Sequential recommendation has evolved significantly with the advancement of deep learning techniques. Early approaches primarily relied on feed-forward and MLP-based architectures to model user behavior patterns [5, 31, 11]. These models capture feature interactions and co-occurrence relationships but lack an explicit mechanism for modeling temporal dependencies. To address this limitation, recurrent neural network (RNN)-based methods, particularly those built on LSTM and GRU architectures, were introduced to model sequential dynamics [20, 7]. Additionally, convolutional architectures have been employed to capture local transition patterns within interaction sequences [30, 31]. While these methods improve temporal modeling, their inherently sequential nature limits parallelization and restricts their ability to capture long-range dependencies effectively.
Transformer-based models address these limitations by using self-attention to model global dependencies in parallel. SASRec [14] introduced unidirectional self-attention for autoregressive sequential recommendation, enabling selective attention over past interactions. BERT4Rec [27] extended this to bidirectional attention with masked item prediction for richer contextual representations. TiSASRec [18] incorporated time intervals into attention to capture temporal dynamics beyond positional ordering. Subsequent work has explored representation quality and efficiency. BSARec [25] uses Fourier-based inductive bias to mitigate oversmoothing by disentangling low- and high-frequency components. DuoRec [22] addresses representation degeneration through dual contrastive learning with dropout augmentation and supervised sampling. STRec [16] employs sparse attention to reduce redundant item-pair interactions, while ScaleRec [17] captures multi-scale temporal dynamics through dual attention across intra- and inter-patch granularities.
Improving computational efficiency is increasingly important in transformer-based sequential recommendation as longer interaction sequences raise computational and memory costs. LinRec [19] reduces self-attention complexity from quadratic to linear by reordering dot-product computation, while FMLPRec [38] replaces self-attention with frequency-domain filtering via Fast Fourier Transformation. LRURec [33] employs linear recurrent units (LRU) for parallelizable, stable long-range modeling at sub-quadratic cost. LightSANs [9] uses low-rank decomposed self-attention to reduce parameters while preserving sequence modeling capacity. More recently, state space models, particularly Mamba-based architectures [12], have emerged as efficient alternatives for long-sequence modeling. SSD4Rec [36] adopts structured state-space duality for efficient contextual modeling, while MaTrRec [35] combines Mamba with transformer attention in a hybrid pipeline. Other works integrate Mamba with graph encoders [37] or develop lightweight bidirectional methods like SIGMA [21] for long-tail user scenarios.
Although these approaches improve efficiency and scalability, they still use fixed-depth architectures that apply uniform computation across interactions. This can incur unnecessary overhead for interactions requiring only shallow reasoning. To address this, we propose MoR4Rec, the first framework to introduce the Mixture-of-Recursion paradigm to sequential recommendation. Its core idea is that interactions within a user sequence require different computational depths. By routing tokens across recursion depths, MoR4Rec allocates more computation to complex interactions while processing simpler ones efficiently.
Proposed Approach
In this section, we describe the proposed MoR4Rec framework in detail. The proposed framework processes a user interaction sequence through five sequential stages as, (i) item sequence encoding, (ii) an initial transformer encoding layer for contextual feature extraction, (iii) a shared recursive middle block with recursion-wise KV sharing, (iv) a token router that assigns each item a recursion depth, and (v) a final transformer refinement layer followed by next-item prediction. The overall pipeline of MoR4Rec is illustrated in Figure 1. We begin by formulating the problem, followed by a detailed description of each component in the subsequent sections.

Figure 1. Overview of MoR4Rec.
Problem Definition
Let denote the set of users and denote the set of items, where and represent the numbers of users and items, respectively. Each user has a chronologically ordered interaction history , where is the item interacted by user at timestep and is the sequence length. The objective of sequential recommendation is to predict the next item by maximizing a scoring function over all candidate items:
Item Sequence Encoding
We begin by constructing input representations for the user interaction sequence, which serve as inputs to the subsequent recursive transformer architecture. Each item is associated with a learnable global embedding . Given the interaction sequence , input representations are formed by normalizing and regularizing each item embedding as:
yielding the input matrix . Notably, no absolute positional vectors are added at this stage. Sequential order is instead injected directly into the attention layers via Rotary Positional Embeddings (RoPE), described in the next section.
Backbone Transformer Encoder
The backbone of MoR4Rec is a transformer encoder composed of a recursively reusable transformer block. Each block follows a pre-normalization residual architecture [29], consisting of a multi-head self-attention (MHSA) module and a position-wise SwiGLU feed-forward network (FFN) [23]. Given the input representation at layer index , the transformer block is defined as
Here, denote the hidden representations of the items at layer index , where is the hidden dimension.
Self-Attention with RoPE: At layer index , the MHSA module operates on the normalized hidden representations
The query, key, and value representations are then obtained through learnable linear projections:
where are the query, key, and value matrices, respectively, and are the corresponding learnable projection matrices. We denote the -th rows of these matrices by , , and , respectively, where , .
Since absolute positional embeddings are added to hidden representations, repeatedly injecting them across recursion steps may interfere with representation reuse. We therefore adopt Rotary Positional Embeddings (RoPE) [26], which encodes position directly in the query and key representations without modifying the hidden states. Specifically, RoPE divides each query and key vector into two-dimensional sub-vectors and rotates the -th sub-vector at position by , where and . The corresponding rotation matrix is defined as .
Applying these rotations to all two-dimensional sub-vectors gives the position-dependent query and key representations:
where is a block-diagonal rotation matrix whose -th diagonal block is . The key property of RoPE is that the interaction between a query at position and a key at position depends on their relative positional offset. Specifically,
Thus, the position-aware interaction can be expressed as
where denotes the interaction function between the query and key representations conditioned on their relative positional offset.
The use of RoPE is naturally compatible with our KV caching strategy (§ 3.3), as the positional rotation is applied before the key representations are stored in the cache, allowing the cached keys to retain their position-specific information across recursion depths without recomputation. The rotated queries and keys are then used to compute causal self-attention. Let and denote the numbers of query and key-value heads, respectively, with , and let denote the per-head dimension. The attention output is computed as .
For each query head, the attention output is computed as
where is the causal attention mask, with for and for , ensuring that the item at position can attend only to itself and preceding items. We additionally employ Grouped Query Attention (GQA) [1], which uses fewer key-value heads than query heads to reduce the KV cache footprint during inference.
Feed-Forward Network: The FFN employs a SwiGLU activation [23]. Given an individual item representation , the FFN is defined as:
where , and are learnable weight matrices. The gating mechanism in SwiGLU allows the FFN to selectively activate features, providing expressive nonlinear transformation with a compact parameter count.
Middle-Cycle Parameter Sharing
organizes its transformer layers into three groups: a unique input layer , a shared recursive middle block , and a unique output layer . Let be the total number of logical (unrolled) layers and the number of recursion steps. The base depth of the shared block is , with divisible by . The fully unrolled hidden state evolution over the stack is:
where denotes the hidden representation of the item at position after logical layer , denotes a transformer encoder layer parameterized by , and indexes the logical layer in the unrolled network. Parameters are shared across recursion: the middle block is instantiated once and reused at every step, so all passes read from and accumulate gradients into one physical set of parameters, keeping the budget at while effective depth scales with . This recurrence defines the deepest path, while routing assigns each token a depth so it traverses the shared block times. The key property of this design is that the total parameter count is regardless of , where is the per-layer parameter count. Thus, the model does not grow with the number of recursion steps. The unique input and output layers serve as domain-specific adapters. contextualizes raw item embeddings before routing, and refines aggregated representations before prediction.
Token-Level Routing and Adaptive Computation
The central contribution of MoR4Rec is a token-level router that assigns each item in the sequence an adaptive recursion depth, operationalizing the hypothesis that different items require different amounts of contextual processing.
Router: After the unique input layer , the router takes the contextualized representation of each item and predicts a distribution over the available recursion levels. For user ’s interaction at sequence position , let denote its contextualized representation after the input layer. The routing distribution is computed as
where contains the routing probabilities over the recursion levels. The assigned recursion depth is then determined by the level with the highest routing probability:
The items with recursive depth 1 pass through the shared block once, while those with recursive depth pass through it times.
Cascading Token Selection: At each recursion level , only items whose assigned recursion depth is at least participate in the forward pass through the shared block. Specifically, the active set at level is defined as
where denotes the recursion depth assigned to the -th item of user . The active items in are extracted from the full sequence tensor using vectorized gather operations, processed through the shared layers, and then written back to their original positions using scatter. Items whose assigned depth is exactly exit after completing this recursion pass. Their resulting representations are weighted by the corresponding router probability and accumulated with the initial representations:
where denotes the router probability assigned to recursion level for the -th item of user . This residual formulation preserves a direct path from the initial representation to the final output, while the differentiable weighting factor provides a learning signal to the router despite the non-differentiable depth selection.
Adaptive KV Sharing Across Recursion Steps
A key observation enabling efficient recursive processing is that every non-padding item participates in the first recursion step, i.e., contains all valid interactions in the sequence. We therefore compute and cache the rotated key and value representations during the first recursion step and reuse them across subsequent steps. For user , the initial KV cache is given by
where represent the cached key and value matrices for the full interaction sequence of user .
At each subsequent recursion level , the cached key-value representations are selectively updated only for active items in . Specifically,
and
Thus, active items progressively refine their key-value representations across recursion steps, whereas inactive items retain their most recently computed states. At recursion level , queries are computed only for the active items. The resulting attention output is
where contains the rotated queries of active items, while store cached key-value representations for the full sequence. The causal mask restricts each active query at position to positions . As decreases with , deeper recursion levels require fewer query computations, while active items retain full sequence context through cached keys and values. This selective KV update avoids redundant computation for inactive items while preserving contextual access for active ones.
Gated Attention Mechanism (G1)
Standard attention computes a weighted sum over values and immediately projects the result to the output space. To allow the model to dynamically suppress less informative contextual signals on a per-item basis, we introduce a gating mechanism at position , applied to the attention output before the output projection . We study two variants that trade off granularity against parameter cost.
Headwise Gating: This variant appends one extra scalar dimension per attention head to the query projection, producing a gate for each item and head at recursion level :
where is the query projection matrix. The extra dimensions, one per head, carry the gate scalars , which are extracted after reshaping, and denotes the sigmoid function. This enables the model to amplify or suppress the contribution of entire attention heads for each item, at the cost of additional output dimensions in the query projection.
Elementwise Gating: This variant doubles the query projection to produce a full -dimensional gate vector per item, enabling feature-level modulation:
where is the gate tensor obtained by splitting the second half of the query projection output, denotes the hidden states of active items at recursion level , and denotes elementwise multiplication. Elementwise gating allows fine-grained, dimension-level control over the attention output. This strategy is particularly beneficial in the presence of noisy or incidental interactions in sparse user histories. The trade-off is a increase in query projection output dimensions. We evaluate these variants against vanilla attention in § 5.2.
Prediction and Learning Objective
Prediction: Given the final fused representation at timestep , the preference score for a candidate item is computed as:
where is the learnable embedding of item .
Prediction Loss: Let denote the set of valid prediction positions. For each , the probability assigned to the ground-truth next item is:
The cross-entropy prediction loss over all valid positions is:
Load Balancing Loss: Since hard top-1 routing via arg max is non-differentiable, it is susceptible to routing collapse, where all items are assigned to the same recursion level , eliminating adaptive computation entirely. To prevent this, we introduce a load-balancing loss following [10] that encourages uniform utilization across all recursion levels. For a batch of sequences each of length , let be the mean routing probability assigned to level and the empirical fraction of items hard-routed to level :
where is the router probability for item at recursion level and is the hard routing decision. The load-balancing loss is then:
Since is non-differentiable, gradients flow only through , providing a soft signal that pushes the router toward uniform dispatch without requiring straight-through estimators.
Total Training Objective: The full training objective combines the next-item prediction loss with the auxiliary balancing term:
Experimental Setup
We conduct extensive experiments to systematically evaluate MoR4Rec against competitive baselines and ablated variants. Specifically, we aim to answer the following research questions:
Research Questions
Our experiments address the following research questions:
RQ1: How does MoR4Rec compare against state-of-the-art sequential recommendation models in terms of recommendation accuracy across diverse datasets? (§ 5.1)
RQ2: How do the gated attention variants affect model performance? (§ 5.2)
RQ3: What recursion depth does the router assign to each token? (§ 5.3)
RQ4: Does MoR4Rec’s adaptive per-token recursion lower computational cost without adding parameters? (§ 5.4)
RQ5: Are the performance gains of MoR4Rec statistically significant across datasets? (§ 5.5)
Datasets
We evaluate on three publicly available benchmark datasets from two well-established repositories, Amazon1 and GroupLens2. From Amazon, we utilize the Video Games and Industrial & Scientific product review datasets, representing sparse and long-tail interaction patterns. From GroupLens, we adopt the relatively dense MovieLens 1M movie rating dataset. Detailed statistics for each dataset are summarized in Table 1.
| Dataset | # Users | # Items | # Interactions | Sparsity (%) |
| ML-1M | 6040 | 3416 | 999611 | 95.16 |
| Video Games | 94762 | 25612 | 814586 | 99.96 |
| Industrial & Scientific | 50985 | 25848 | 412947 | 99.96 |
Table 1. Statistics of the considered datasets.
We apply standard 5-core filtering, retaining users and items with at least five interactions. Following [33], we fix the maximum sequence length to ; longer sequences are split into subsequences, while shorter ones are left-padded with [PAD]. We set , consistent with most baselines. For data splitting, we use the leave-one-out protocol [14], holding out each user’s most recent interaction for testing, the second most recent for validation, and the remainder for training. At test time, training and validation interactions are used as context for predicting the test item.
Evaluation Metrics. We evaluate recommendation quality using three standard ranking metrics: Recall@, Normalized Discounted Cumulative Gain (NDCG@), and Mean Reciprocal Rank (MRR@), at cutoffs . Recall@ measures the fraction of relevant items retrieved in the top- list, while NDCG@ accounts for ranking position by assigning higher scores to relevant items appearing earlier. MRR@ measures the position of the first relevant item in the ranked list. Higher values indicate better performance for all three metrics.
Baselines
To showcase the superiority of the proposed approach, we compare it against the following competitive baselines spanning RNN-based, MLP-based, attention-based, contrastive, linear, and state-space approaches:
GRU4Rec [13]: Session-based recommendation using gated recurrent units, modeling sequential patterns via hidden state transitions.
BERT4Rec [27]: Bidirectional transformer for sequential recommendation with masked item prediction pre-training.
LightSANs [9]: Low-rank decomposed self-attention to reduce the computational cost of next-item prediction.
//
FMLPRec [38]: All-MLP model using frequency-domain filtering via fast fourier transform as a drop-in replacement for self-attention.
LinRec [19]: Linear attention mechanism reducing self-attention complexity from to .
BSARec [25]: Fourier-based attentive inductive bias to mitigate oversmoothing in deep self-attention.
LRURec [33]: Parallelizable linear recurrent units for stable long-range dependency modeling.
GLINT-RU [34]: Gated lightweight intelligent recurrent units for efficient sequential recommendation.
MUFFIN [3]: Mixture of user-adaptive frequency filtering for sequential recommendation.
SIGMA [21]: Selective gated Mamba for sequential recommendation.
Parameter Configuration
To ensure a fair comparison, we perform extensive hyperparameter tuning for all competing methods. All models are implemented in PyTorch. The embedding dimension is fixed at , consistent across all experiments. For MoR4Rec, the transformer backbone uses unrolled layers with recursion steps and attention heads with grouped query attention (2 key-value heads). The router is a single linear layer with softmax activation. We employ the middle-cycle KV sharing strategy with cache update enabled. The gating variant (: vanilla, headwise, or elementwise) is selected by validation performance. The hyperparameters for baseline approaches are tuned within the ranges reported in their respective papers. For all comparing algorithms, dropout and attention dropout rates are searched in .
Models are optimized with AdamW (learning rate , weight decay 0.01) with a batch size of 256, for up to 200 epochs. Early stopping is applied based on validation Recall@10 (patience = 10). The optimal configuration is selected based on the average of Recall@10 and MRR@10 on the validation set.
Results and Discussion
In this section, we present the experimental results and answer each of the research questions defined in § 4.1.
Overall Performance (RQ1)
Table 2 compares MoR4Rec with recent state-of-the-art baselines across three benchmark datasets. MoR4Rec consistently achieves superior or competitive performance across all metrics, with gains at each cutoff demonstrating its ability to capture both precise top-ranked recommendations and broader relevant-item coverage. The consistent improvements, particularly in MRR@10 (Figure 2), indicate that MoR4Rec ranks relevant items earlier in the recommendation list. As MRR rewards the position of the first relevant item, this advantage suggests that MoR4Rec not only retrieves relevant items but places them higher in the list, which is particularly important in practical top-ranked recommendations. These gains support our central hypothesis that interactions require different computational depths: routine interactions can be processed shallowly, while preference shifts or long-range dependencies benefit from deeper recursive refinement. By dynamically allocating computation through routing, MoR4Rec uses model capacity more effectively, improving representation quality and recommendation performance.
| Dataset | Metric | GRU4Rec [13] | BERT4Rec [27] | LightSANs [9] | FMLPRec [38] | LinRec [19] | BSARec [25] | LRURec [33] | GLINT-RU [34] | MUFFIN [3] | SIGMA [21] | MoR4Rec (Proposed) | Improv. (%) | |||||||||||
| Score | Mean rank | Score | Mean rank | Score | Mean rank | Score | Mean rank | Score | Mean rank | Score | Mean rank | Score | Mean rank | Score | Mean rank | Score | Mean rank | Score | Mean rank | Score | Mean rank | |||
| MovieLens 1M | Recall@5 | 0.2085 | 4 | 0.1274 | 6 | 0.1075 | 7 | 0.0898 | 10 | 0.1443 | 5 | 0.2185 | 3 | 0.2268 | 2 | 0.0843 | 11 | 0.0963 | 8 | 0.0949 | 9 | 0.2377 | 1 | 4.8060 |
| Recall@10 | 0.2941 | 4 | 0.2019 | 6 | 0.1622 | 7 | 0.1449 | 9 | 0.2223 | 5 | 0.3077 | 3 | 0.3134 | 2 | 0.1356 | 11 | 0.1459 | 8 | 0.1416 | 10 | 0.3219 | 1 | 2.7122 | |
| Recall@20 | 0.3939 | 4 | 0.2975 | 6 | 0.2415 | 7 | 0.2146 | 8 | 0.3251 | 5 | 0.4113 | 3 | 0.4129 | 2 | 0.2132 | 9 | 0.2103 | 10 | 0.2069 | 11 | 0.4239 | 1 | 2.6641 | |
| NDCG@5 | 0.1434 | 4 | 0.0834 | 6 | 0.0708 | 7 | 0.0586 | 10 | 0.0953 | 5 | 0.1514 | 3 | 0.1581 | 2 | 0.0534 | 11 | 0.0652 | 8 | 0.0618 | 9 | 0.1658 | 1 | 4.8703 | |
| NDCG@10 | 0.1710 | 4 | 0.1076 | 6 | 0.0884 | 7 | 0.0763 | 10 | 0.1204 | 5 | 0.1800 | 3 | 0.1860 | 2 | 0.0698 | 11 | 0.0812 | 8 | 0.0769 | 9 | 0.1929 | 1 | 3.7097 | |
| NDCG@20 | 0.1963 | 4 | 0.1317 | 6 | 0.1084 | 7 | 0.0937 | 9 | 0.1463 | 5 | 0.2061 | 3 | 0.2110 | 2 | 0.0893 | 11 | 0.0975 | 8 | 0.0934 | 10 | 0.2186 | 1 | 3.6019 | |
| Industrial & Scientific | Recall@5 | 0.0235 | 4 | 0.0233 | 6 | 0.0177 | 9 | 0.0146 | 10 | 0.0234 | 5 | 0.0320 | 2 | 0.0305 | 3 | 0.0217 | 7 | 0.0214 | 8 | 0.0143 | 11 | 0.0321 | 1 | 0.3125 |
| Recall@10 | 0.0376 | 4 | 0.0346 | 6 | 0.0257 | 9 | 0.0215 | 10 | 0.0358 | 5 | 0.0461 | 2 | 0.0448 | 3 | 0.0317 | 7 | 0.031 | 8 | 0.0213 | 11 | 0.0465 | 1 | 0.8677 | |
| Recall@20 | 0.0574 | 4 | 0.0501 | 6 | 0.0367 | 9 | 0.0304 | 11 | 0.0523 | 5 | 0.0663 | 2 | 0.0647 | 3 | 0.0460 | 7 | 0.0446 | 8 | 0.0309 | 10 | 0.0669 | 1 | 0.9050 | |
| NDCG@5 | 0.0151 | 8 | 0.0161 | 5 | 0.0125 | 9 | 0.0097 | 11 | 0.0163 | 4 | 0.0221 | 2 | 0.0211 | 3 | 0.0152 | 6 | 0.0152 | 7 | 0.0100 | 10 | 0.0223 | 1 | 0.9050 | |
| NDCG@10 | 0.0196 | 6 | 0.0197 | 5 | 0.0151 | 9 | 0.0119 | 11 | 0.0203 | 4 | 0.0267 | 2 | 0.0257 | 3 | 0.0184 | 7 | 0.0183 | 8 | 0.0122 | 10 | 0.0268 | 1 | 0.3745 | |
| NDCG@20 | 0.0245 | 4 | 0.0236 | 6 | 0.0179 | 9 | 0.0142 | 11 | 0.0244 | 5 | 0.0318 | 2 | 0.0307 | 3 | 0.022 | 7 | 0.0217 | 8 | 0.0146 | 10 | 0.0319 | 1 | 0.3145 | |
| Video Games | Recall@5 | 0.0582 | 4 | 0.0519 | 6 | 0.0471 | 8 | 0.0349 | 11 | 0.0481 | 7 | 0.0684 | 3 | 0.0700 | 2 | 0.0433 | 9 | 0.0528 | 5 | 0.0403 | 10 | 0.0712 | 1 | 1.7143 |
| Recall@10 | 0.0881 | 4 | 0.0791 | 5 | 0.0691 | 8 | 0.0541 | 11 | 0.0725 | 7 | 0.0991 | 3 | 0.1036 | 2 | 0.0667 | 9 | 0.0776 | 6 | 0.0605 | 10 | 0.1046 | 1 | 0.9653 | |
| Recall@20 | 0.1286 | 4 | 0.117 | 5 | 0.0994 | 8 | 0.0808 | 11 | 0.1066 | 7 | 0.1402 | 3 | 0.1474 | 2 | 0.0982 | 9 | 0.1113 | 6 | 0.0876 | 10 | 0.1492 | 1 | 1.2211 | |
| NDCG@5 | 0.0384 | 4 | 0.0345 | 6 | 0.0321 | 8 | 0.0228 | 11 | 0.0323 | 7 | 0.0467 | 3 | 0.0474 | 2 | 0.0288 | 9 | 0.0357 | 5 | 0.0272 | 10 | 0.0482 | 1 | 1.6888 | |
| NDCG@10 | 0.0480 | 4 | 0.0433 | 6 | 0.0392 | 8 | 0.0290 | 11 | 0.0401 | 7 | 0.0566 | 3 | 0.0583 | 2 | 0.0363 | 9 | 0.0437 | 5 | 0.0337 | 10 | 0.0589 | 1 | 1.0292 | |
| NDCG@20 | 0.0582 | 4 | 0.0528 | 5 | 0.0468 | 8 | 0.0357 | 11 | 0.0486 | 7 | 0.0669 | 3 | 0.0693 | 2 | 0.0442 | 9 | 0.0521 | 6 | 0.0405 | 10 | 0.0702 | 1 | 1.2987 |
Table 2. Recommendation performance comparison on three datasets. Mean rank is shown alongside each score. The best baseline result is underlined. Imp.(%) is the relative improvement of MoR4Rec over the best baseline.

Figure 2. Performance of comparing algorithms in terms of .
Effect of Gated Attention Variants (RQ2)
We compare the three gated attention strategies within the MoR4Rec framework: (i) vanilla (standard attention, no gating), (ii) headwise (one sigmoid gate per attention head), and (iii) elementwise (one sigmoid gate per feature dimension). Figure 3 reports the results in terms of Recall@10, MRR@10, and NDCG@10 across all three datasets. On denser datasets, elementwise gating () achieves a consistent marginal advantage, as fine-grained feature-level modulation better exploits the richer interaction context available. On sparser datasets, vanilla attention proves more competitive, suggesting that additional gating parameters risk overfitting to noisy interaction patterns in low-signal regimes. Headwise gating () occupies a middle ground in both settings. Overall, elementwise gating is preferred for interaction-rich datasets, while vanilla attention provides a stronger default under data scarcity.

Figure 3. Ablation of gating variants across three datasets on Recall@10, MRR@10, and NDCG@10.
Per-Token Recursion Depth Analysis (RQ3)
Figure 4 shows the recursion depth the router picks for each token. We trace one random user sequence at test time under a budget of . A few things stand out. Every token is computed at . So each position recurses at least once. The number of computed tokens then drops at . A token routed to depth is recursed at levels to and skipped after that. This gives the nested shape we see in the figure. The choice is also token specific. Some tokens exit after the first recursion. Others are carried to the deeper level. This tells us the router learns where to spend compute. It does not apply a fixed depth to the whole sequence. We also see recent positions kept at the deeper level more often. That fits the idea that recent items matter more for the next-item prediction.

Figure 4. Per-token recursion depth for a random user with .
Does Adaptive Recursion Reduce Computational Cost? (RQ4)
We compare MoR4Rec with a vanilla transformer encoder for sequential recommendation. Both models use four layers () and the same scoring term, providing a controlled setting to isolate the backbone effect. As shown in Table 3, MoR4Rec remains more computationally efficient despite not being a stripped-down encoder. Its recursive block includes a sigmoid gating mechanism that adds some compute to the shared weights. Even with this gate, MoR4Rec reduces computational and parameter costs across all three datasets. On
| Dataset | Model | MFLOPs | Parameter | Train | Infer |
| MovieLens 1M | Vanilla Transformer | 44.10 | 422.0 | 647.1 | 0.0004 |
| MovieLens 1M | MoR4Rec | 42.76 | 380.5 | 643.7 | 0.0003 |
| Industrial & Scientific | Vanilla Transformer | 187.66 | 1857.66 | 897.26 | 0.0002 |
| Industrial & Scientific | MoR4Rec | 184.48 | 1803.84 | 1070.64 | 0.0002 |
| Video Games | Vanilla Transformer | 186.15 | 1842.56 | 2339.53 | 0.0002 |
| Video Games | MoR4Rec | 182.78 | 1788.86 | 2302.33 | 0.0002 |
Table 3. Computational cost across datasets. MFLOPs, parameters, training time, and inference time are reported per user forward pass.
MovieLens 1M, it requires 42.76 MFLOPs versus 44.10 MFLOPs and uses 380.5K parameters versus 422.0K for the vanilla transformer. Similar reductions are observed on Industrial & Scientific and Video Games. Training time is lower for MoR4Rec on MovieLens 1M and Video Games, while it is higher on Industrial & Scientific. Inference is faster on MovieLens 1M and comparable on the other two datasets. Overall, under a matched architecture and scoring budget, MoR4Rec is lighter in computation and parameter count, while maintaining comparable inference efficiency. These results indicate that adaptive per-token recursion uses the computational budget more effectively than a fixed-depth encoder.
Statistical Significance Analysis (RQ5)
To rigorously validate observed performance gains, we conduct nonparametric statistical significance testing following the protocol of Demšar [6]. We apply the Friedman test over competing methods and datasets, testing whether all models perform equivalently. Table 4 reports the Friedman statistic alongside the critical value at .
| Metric | Crit. Val. () | CD | ||||
| Recall@5 | 27.1177 | |||||
| NDCG@5 | 15.3684 | 2.3479 | 3.2190 | 3 | 11 | 8.7171 |
| MRR@5 | 24.4000 |
Table 4. Friedman and Nemenyi statistical analysis summary.
For all three metrics, substantially exceeds the critical value, leading to rejection of the null hypothesis that all models perform equivalently (). We then apply the post-hoc Nemenyi test to perform pairwise comparisons. The critical difference is
, where for at . As illustrated in Figure 5, achieves a statistically superior average rank compared to all competing baselines, with rank differences exceeding , confirming the robustness and consistency of its performance improvements.

Figure 5. Critical difference (CD) diagrams for Recall@5, NDCG@5, and MRR@5.
Conclusion
We presented , a sequential recommendation framework that introduces interaction-level adaptive computation through a Mixture-of-Recursion paradigm. Motivated by the observation that interactions within a user sequence may require different levels of contextual reasoning, dynamically allocates computation across recursion depths while maintaining efficiency through shared recursive modeling and key–value reuse. A gated attention mechanism further improves the modeling of contextual dependencies, while auxiliary routing objectives support stable training. Experiments on three benchmark datasets against fifteen competitive baselines show that consistently achieves strong performance and favorable efficiency–accuracy trade-offs, with ablation studies further validating the contribution of its core components.
These results highlight the promise of adaptive recursion for sequential recommendation. Future work includes improving the interpretability of learned routing behavior and extending the framework to more challenging settings such as multi-modal and cross-domain recommendation settings, where behavioral heterogeneity is even more pronounced.
References
- [1]Ainslie, J., Lee-Thorp, J., De Jong, M., Zemlyansky, Y., Lebrón, F., and Sanghai, S. Gqa: Training generalized multi-query transformer models from multi-head checkpoints. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing (2023), pp. 4895–4901.
- [2]Bae, S., Kim, Y., Bayat, R., Kim, S., Ha, J., Schuster, T., Fisch, A., Harutyunyan, H., Ji, Z., Courville, A., and Yun, S.-Y. Mixture-of-recursions: Learning dynamic recursive depths for adaptive token-level thinking. In ES-FoMo III: 3rd Workshop on Efficient Systems for Foundation Models (2025).
- [3]Baek, I., Yoon, M., Park, S., and Lee, J. Muffin: Mixture of user-adaptive frequency filtering for sequential recommendation. In Proceedings of the 34th ACM International Conference on Information and Knowledge Management (2025), pp. 119–128.arxiv.org/abs/2508.13670
- [4]Boka, T. F., Niu, Z., and Neupane, R. B. A survey of sequential recommendation systems: Techniques, evaluation, and future directions. Information Systems 125 (2024), 102427.DOI
- [5]Cui, Q., Wu, S., Liu, Q., Zhong, W., and Wang, L. Mv-rnn: A multi-view recurrent neural network for sequential recommendation. IEEE Transactions on Knowledge and Data Engineering 32, 2 (2018), 317–331.arxiv.org/abs/1611.06668
- [6]Demšar, J. Statistical comparisons of classifiers over multiple data sets. The Journal of Machine learning research 7 (2006), 1–30.DOI
- [7]Donkers, T., Loepp, B., and Ziegler, J. Sequential user-based recurrent neural network recommendations. In Proceedings of the eleventh ACM conference on recommender systems (2017), pp. 152–160.DOI
- [8]Du, X., Yuan, H., Zhao, P., Qu, J., Zhuang, F., Liu, G., Liu, Y., and Sheng, V. S. Frequency enhanced hybrid attention network for sequential recommendation. In Proceedings of the 46th International ACM SIGIR conference on research and development in information retrieval (2023), pp. 78–88.arxiv.org/abs/2304.09184
- [9]Fan, X., Liu, Z., Lian, J., Zhao, W. X., Xie, X., and Wen, J.-R. Lighter and better: low-rank decomposed self-attention networks for next-item recommendation. In Proceedings of the 44th international ACM SIGIR conference on research and development in information retrieval (2021), pp. 1733–1737.DOI
- [10]Fedus, W., Zoph, B., and Shazeer, N. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. Journal of Machine Learning Research 23, 120 (2022), 1–39.arxiv.org/abs/2101.03961
- [11]Gao, J., Zhao, X., Li, M., Zhao, M., Wu, R., Guo, R., Liu, Y., and Yin, D. Smlp4rec: an efficient all-mlp architecture for sequential recommendations. ACM Transactions on Information Systems 42, 3 (2024), 1–23.DOI
- [12]Gu, A., and Dao, T. Mamba: Linear-time sequence modeling with selective state spaces. In First conference on language modeling (2024).arxiv.org/abs/2312.00752
- [13]Hidasi, B., Karatzoglou, A., Baltrunas, L., and Tikk, D. Session-based recommendations with recurrent neural networks. arXiv preprint arXiv:1511.06939 (2015).arxiv.org/abs/1511.06939
- [14]Kang, W.-C., and McAuley, J. Self-attentive sequential recommendation. In 2018 IEEE international conference on data mining (ICDM) (2018), IEEE, pp. 197–206.
- [15]Lan, Z., Chen, M., Goodman, S., Gimpel, K., Sharma, P., and Soricut, R. Albert: A lite bert for self-supervised learning of language representations. arXiv preprint arXiv:1909.11942 (2019).arxiv.org/abs/1909.11942
- [16]Li, C., Wang, Y., Liu, Q., Zhao, X., Wang, W., Wang, Y., Zou, L., Fan, W., and Li, Q. Strec: Sparse transformer for sequential recommendations. In Proceedings of the 17th ACM conference on recommender systems (2023), pp. 101–111.DOI
- [17]Li, H., Yang, Y., Zeng, J., Gao, M., and Wen, J. Multi-scale transformers with dual attention and adaptive masking for sequential recommendation. Information Processing & Management 63, 1 (2026), 104318.
- [18]Li, J., Wang, Y., and McAuley, J. Time interval aware self-attention for sequential recommendation. In Proceedings of the 13th International Conference on Web Search and Data Mining (New York, NY, USA, 2020), WSDM ’20, Association for Computing Machinery, p. 322–330.DOI
- [19]Liu, L., Cai, L., Zhang, C., Zhao, X., Gao, J., Wang, W., Lv, Y., Fan, W., Wang, Y., He, M., et al. Linrec: Linear attention mechanism for long-term sequential recommender systems. In Proceedings of the 46th International ACM SIGIR Conference on Research and Development in Information Retrieval (2023), pp. 289–299.DOI
- [20]Liu, Q., Wu, S., Wang, D., Li, Z., and Wang, L. Context-aware sequential recommendation. In 2016 IEEE 16th International Conference on Data Mining (ICDM) (2016), IEEE, pp. 1053–1058.arxiv.org/abs/1609.05787
- [21]Liu, Z., Liu, Q., Wang, Y., Wang, W., Jia, P., Wang, M., Liu, Z., Chang, Y., and Zhao, X. Sigma: selective gated mamba for sequential recommendation. In Proceedings of the AAAI conference on artificial intelligence (2025), vol. 39, pp. 12264–12272.arxiv.org/abs/2408.11451
- [22]Qiu, R., Huang, Z., Yin, H., and Wang, Z. Contrastive learning for representation degeneration problem in sequential recommendation. In Proceedings of the fifteenth ACM international conference on web search and data mining (2022), pp. 813–823.DOI
- [23]Shazeer, N. Glu variants improve transformer. arXiv preprint arXiv:2002.05202 (2020).arxiv.org/abs/2002.05202
- [24]Shen, Z., Liu, Z., and Xing, E. Sliced recursive transformer. In European Conference on Computer Vision (2022), Springer, pp. 727–744.arxiv.org/abs/2111.05297
- [25]Shin, Y., Choi, J., Wi, H., and Park, N. An attentive inductive bias for sequential recommendation beyond the self-attention. In Proceedings of the AAAI Conference on Artificial Intelligence (2024), vol. 38, pp. 8984–8992.
- [26]Su, J., Ahmed, M., Lu, Y., Pan, S., Bo, W., and Liu, Y. Roformer: Enhanced transformer with rotary position embedding. Neurocomputing 568 (2024), 127063.arxiv.org/abs/2104.09864
- [27]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 (2019), pp. 1441–1450.arxiv.org/abs/1904.06690
- [28]Xin, J., Tang, R., Lee, J., Yu, Y., and Lin, J. Deebert: Dynamic early exiting for accelerating bert inference. In Proceedings of the 58th annual meeting of the association for computational linguistics (2020), pp. 2246–2251.arxiv.org/abs/2004.12993
- [29]Xiong, R., Yang, Y., He, D., Zheng, K., Zheng, S., Xing, C., Zhang, H., Lan, Y., Wang, L., and Liu, T. On layer normalization in the transformer architecture. In International conference on machine learning (2020), PMLR, pp. 10524–10533.arxiv.org/abs/2002.04745
- [30]Xu, C., Zhao, P., Liu, Y., Xu, J., Sheng, V. S. S., Cui, Z., Zhou, X., and Xiong, H. Recurrent convolutional neural network for sequential recommendation. In The world wide web conference (2019), pp. 3398–3404.DOI
- [31]Yan, A., Cheng, S., Kang, W.-C., Wan, M., and McAuley, J. Cosrec: 2d convolutional neural networks for sequential recommendation. In Proceedings of the 28th ACM international conference on information and knowledge management (2019), pp. 2173–2176.arxiv.org/abs/1908.09972
- [32]Yuan, W., Wang, H., Yu, X., Liu, N., and Li, Z. Attention-based context-aware sequential recommendation model. Information Sciences 510 (2020), 122–134.DOI
- [33]Yue, Z., Wang, Y., He, Z., Zeng, H., McAuley, J., and Wang, D. Linear recurrent units for sequential recommendation. In Proceedings of the 17th ACM international conference on web search and data mining (2024), pp. 930–938.arxiv.org/abs/2310.02367
- [34]Zhang, S., Wang, M., Wang, W., Gao, J., Zhao, X., Yang, Y., Wei, X., Liu, Z., and Xu, T. Glint-ru: Gated lightweight intelligent recurrent units for sequential recommender systems. In Proceedings of the 31st ACM SIGKDD Conference on Knowledge Discovery and Data Mining V. 1 (2025), pp. 1948–1959.arxiv.org/abs/2406.10244
- [35]Zhang, S., Zhang, R., Yin, Z., and Yang, Z. Matrec: A mamba-transformer framework for robust sequential recommendation. In International Conference on Intelligent Computing (2025), Springer, pp. 448–459.DOI
- [36]Zhang, Y., Qu, H., Ning, L., Fan, W., and Li, Q. Ssd4rec: A structured state space duality model for efficient sequential recommendation. ACM Transactions on Information Systems 44, 2 (2025), 1–26.arxiv.org/abs/2409.01192
- [37]Zhang, Z., Yang, B., and Lu, Y. A local context enhanced consistency-aware mamba-based sequential recommendation model. Information Processing & Management 62, 3 (2025), 104076.DOI
- [38]Zhou, K., Yu, H., Zhao, W. X., and Wen, J.-R. Filter-enhanced mlp is all you need for sequential recommendation. In Proceedings of the ACM web conference 2022 (2022), pp. 2388–2399.DOI
- [39]Zhu, F., Chen, Z., Zhang, F., Lou, J., Wen, H., Liu, S., Rao, Q., Yuan, T., Ni, S., Hu, J., et al. Sasnet: Stage-aware sequential matching for online travel recommendation. In Proceedings of the 31st ACM international conference on information & knowledge management (2022), pp. 3725–3734.DOI