iTranslated by AI
Paper Review: LongRetriever - Integrating Ultra-Long History into the Retrieval Phase for Recommendation
In this article, I will explain the latest research paper from ByteDance: LongRetriever - Towards Ultra-Long Sequence based Candidate Retrieval for Recommendation.
This paper successfully achieves the practical application of ultra-long sequence user behavior history and appropriate user vector representations based on candidate items in the retrieval (candidate generation) phase of recommendation systems, which has previously been considered difficult due to computational cost constraints.
- Note: The images in this article are cited from the figures in the paper.
This article is for December 9th of the arXiv Advent Calendar 2025.
Why this paper is remarkable
The notable points of this research can be summarized into the following three aspects:
-
Utilization of long-term history and candidate-aware user vector representation in the retrieval phase:
The authors proposed an architecture that enables the use of a user's entire behavior history, which was previously difficult due to computational cost constraints in the retrieval phase. This realizes dynamic user vector generation based on candidate items (context) during the retrieval stage. -
Consistency between training and inference via In-Context Training:
They introduced In-Context Training and Multi-Context Retrieval to prevent data leakage (the leakage of target information during training), which is a challenge for history-based retrieval models, while ensuring consistency with inference. -
Validation in large-scale commercial environments:
In A/B tests on ByteDance's large-scale e-commerce platform (serving hundreds of millions of users), they achieved significant improvements in key business metrics (CVR and CTR), and this method has already been deployed to the actual platform.
Why I chose this paper
I was strongly drawn to this paper mainly for the following three reasons:
-
Practical track record and large-scale deployment at ByteDance:
It does not stop at theoretical proposals; it has achieved significant results on a massive platform like ByteDance and is already deployed in production. -
Breaking away from uniform user representations in the retrieval phase:
In the ranking phase, it is common to create user representations tailored to the target item using techniques like Target Attention. However, in Two-Tower models for candidate retrieval, user representations are forced to be uniform (a single vector) due to computational cost constraints, and the limitations of expressive power have led to performance degradation. I was interested in how this paper solved this structural challenge. -
Noise processing methods for long-term sequence data:
In sequential recommendation, as the behavior history sequence becomes longer, it is common to include unrelated and noisy interaction data. I wanted to know how this paper eliminates noise and extracts and utilizes only useful signals when dealing with ultra-long-term data.
Paper Review
In this section, I will explain the technical details and experimental results of how LongRetriever realizes "ultra-long-term history utilization in the retrieval phase."
Abstract
While utilizing "ultra-long-term behavior sequences" is essential to accurately capture user interests, existing approaches have mainly focused on the ranking stage, and research in the retrieval stage has been insufficient.
In this paper, we propose LongRetriever, a practical framework for leveraging long-term sequences in the retrieval phase. Specifically, by introducing In-Context Training and Multi-Context Retrieval, we realize tight interaction between user history and candidate items, while ensuring consistency in learning and inference in a retrieval-based setting.
Online A/B test results on a large-scale e-commerce platform confirm statistically significant performance improvements, and it is now actually deployed at a scale affecting hundreds of millions of users.
Existing Research and Positioning of This Paper (Introduction / Related Work)
I will organize the background on why utilizing long-term history in the retrieval phase has been difficult, and the position of this research.
-
Two-stage configuration of recommendation systems:
Industrial recommendation systems are typically composed of two stages: Retrieval and Ranking. In the retrieval phase, lightweight models (such as Two-Tower models) are employed to narrow down candidates from a massive item pool, while high-compute models that prioritize accuracy are used in the ranking phase. -
Utilizing long-term history in ranking models:
In the field of ranking models, the advent of methods like DIN and SIM has evolved technologies (such as Target Attention) that extract user behaviors related to target items from long-term history, realizing dramatic improvements in prediction accuracy. -
Structural constraints of retrieval models:
On the other hand, retrieval models (Embedding-based Retrieval: EBR) require pre-indexing item vectors to achieve fast approximate nearest neighbor (ANN) search. For this reason, user encoders and item encoders must be calculated independently, making it difficult to dynamically change user representations according to candidate items, as is done in ranking models. As a result, there has been a constraint that only recent, short history can be handled in the retrieval phase. -
Approach of this paper:
LongRetriever resolves the aforementioned challenges by adopting an approach that extracts related parts from long-term history using item context (category, etc.) as keys, while complying with the encoder independence constraint of EBR.
Proposed Method (Methodology)
I will explain the details of the architecture that is the core technology of LongRetriever, as well as the In-Context learning and retrieval process.
Concept of the Method
Before diving into the mathematical details, I will explain the basic concept of this method.
The first key point is using context (category) rather than the target item itself. In standard EBR, since candidate items are unknown at inference time, item information cannot be used to generate user vectors. Therefore, in LongRetriever, we extract only the behaviors related to the context that the user is interested in (e.g., food) from the user's entire behavior history, and generate a user vector in a state where the user is interested in that category. This enables the utilization of long-term history while keeping inference computational costs low.
The second point is preventing data leakage during training. If one simply uses history filtered by a specific category for training, the model may only learn to distinguish whether the category of the history matches the category of the item, risking the loss of learning about the preferences for the items themselves. To prevent this, "In-Context Training," which devises the composition of training data, is introduced.
The third point is ensuring diversity at inference time. Since a user's interests are diverse, we do not perform retrieval with just a single context; instead, we select multiple contexts that the user is likely interested in based on their past behavior, and perform parallel retrieval (Multi-Context Retrieval). Furthermore, if one only selects contexts with high scores, it may lead to recommending only strong interests, potentially resulting in a filter bubble. To prevent this, we adopt a method of randomly selecting from the top-scoring context group (Random in Top) to achieve retrieval that considers diversity.
Symbols and Notation
The definitions of the main mathematical symbols used in this article are as follows:
-
: Set of all usersU -
: Set of all itemsI -
: User (u )u \in U -
: Target item (v )v \in I -
: Full behavior history sequence of userB_u (u )=[b_1^u, b_2^u, \dots, b_T^u] -
: User base features (profiles, context information, etc.)P_u -
: Behavior history subsequence filtered fromS_u based on the context of the target itemB_u -
: User vector (output of User Encoder)e_u -
: Item vector (output of Item Encoder)e_v
Method Details
The specific model structure and explanation using mathematical formulas are as follows:
1. Model Architecture and Input
For the LongRetriever User Encoder, a Pre-Layer Normalization Transformer is adopted to enhance training stability. Taking the subsequence
By filtering the long-term history with the target product's context (category), a user vector suitable for the target product is generated. Additionally, it eliminates the need to consider interactions with products unrelated to the target product, effectively excluding noise.
The input tokens to the Transformer consist of the following three types, which are integrated and processed:
-
[CLS] Token:
A special token used to aggregate information across the entire sequence. The vector of this token in the final Transformer output is adopted as the user representation .e_u -
User Profile Features (
):P_u
tokens (K ) derived from attribute information such as user ID, gender, and age. This allows the consideration of user attributes in addition to behavior history.p_1^u, \dots, p_K^u -
Filtered Behavior History (
):S_u
A subsequence ( ) extracted from the user's full behavior historys_1^u, \dots, s_M^u that matches the target item's context (category). Here,B_u is set as the maximum length (e.g., the most recentM items).L
Learnable Positional Encodings and Token Type Embeddings are added to these tokens before they are fed into the Transformer layers.

Figure 1-a
2. In-Context Training (Learning Phase)
In typical EBR training, an In-batch Contrastive Loss (a loss function that uses other items in the batch as negative samples) is used to maximize the similarity
What is crucial here is the composition of the negative sample set
In EBR, items in the same batch are typically used as negative samples (In-Batch Negative Sampling). In this method, since items in the behavior history are filtered by the same context (category) as the ground-truth item, the Transformer output vector
Therefore, in In-Context Training, the negative samples
3. Multi-Context Retrieval (Inference Phase)
Since the target item is unknown during inference, it is not trivial which context (category) should be used for retrieval. Therefore, the following procedure is adopted:
-
- Interest Selection:
Based on the user's full history, categories with a high probability of current interest are selected. The score for each category is calculated by considering time decay on past interactions.c
Here, is the indicator function and\mathbb{I}(\cdot) represents the number of days elapsed since actiont_{b_i} . Categories contacted more recently have higher scores. To ensure diversity,b_i categories are randomly selected from the top-scoring categories (Top M) (the "Random in Top" strategy).N
- Interest Selection:
-
- Parallel Search:
For each selected category, the corresponding history is extracted to generate the user vectorS_u , and items are retrieved from the index dedicated to that category.e_u
- Parallel Search:

Figure 1 - b
Experiments and Results
To verify the effectiveness of the proposed method, large-scale experiments were conducted within ByteDance's shopping mall platform. For comparison, "MIND," a multi-interest model that is one of the industry standards, was adopted.
Experimental Setup and Evaluation Metrics
The experiments utilized an extremely large-scale dataset consisting of 900 million users, 150 million items, and 10 billion samples, with an average user behavior history length exceeding 20,000 interactions. The experiment used LongRetriever (with the "Random 5 in Top 20" strategy) and compared it against MIND.
The main metrics used for evaluation are as follows:
-
Business Metrics:
- PV (Page Views): Number of views for product detail pages.
- UV CTR (Unique Visitor Click-Through Rate): Click-through rate per unique user. This indicates the degree of user interest.
- UV CVR (Unique Visitor Conversion Rate): Conversion (purchase) rate per unique user. This measures the direct contribution to purchase behavior.
- Orders Per User: Average number of orders per user. This is a key metric indicating the impact on revenue.
-
Retrieval Metrics:
- AER (All Exposure Ratio): A metric measuring the degree of preference for all items retrieved by the model. A lower value suggests that the model is not exploring a wide range of items unnecessarily (like popular items) but is instead efficiently extracting candidates by narrowing down to specific contexts.
- UER (Unique Exposure Ratio): The ratio of items that were uniquely retrieved by the target model. A higher value indicates that the model is supplying new (unique) items to the existing system, contributing to the diversity of the entire recommendation list.
Results and Discussion
- Significant Improvement in Business Metrics:
According to the results in Table 1, improvements of UV CVR: +1.33% and Orders Per User: +1.70% were confirmed compared to MIND. In a service with a scale of hundreds of millions of users, this magnitude of improvement has a significant business impact.

Table 1
-
Changes in Retrieval Quality (Table 2):
- Decrease in AER (31.82% → 18.72%): The value was significantly lower than MIND. This means that while MIND explores broadly from the entire item pool, LongRetriever narrows the exploration to specific contexts, thereby increasing exploration efficiency.
- Increase in UER (4.58% → 9.29%): Improved by +4.71%, nearly doubling the figure. This strongly suggests that LongRetriever uniquely discovers niche items that were buried in existing methods but are appealing to specific users, and delivers them to those users.

Table 2
- Ablation Study (Verification of components):
A detailed analysis of the effectiveness of each element of the proposed method was also conducted.- Importance of Long-term Sequences (Table 4):
When long-term sequences (lifelong behavior) were excluded, CTR × CVR plummeted from 7.92% to 5.33%. Since In-Context Training tasks the model with the difficult challenge of "distinguishing items within the same category," a long-term, rich information set is essential for training. - Importance of the In-Context Mechanism (Table 5):
When In-Context Training/Retrieval was excluded, although apparent diversity (AER/UER) increased, accuracy metrics (CTR × CVR) dropped to 5.61%. This is because, without considering context, data leakage (identifying the correct answer solely by category matching) occurs, leading to insufficient practical learning. - Interest Selection Strategy (Table 3):
When selecting interest categories during inference, it was confirmed that selecting 5 random categories out of the top 20 (Random 5 in Top 20) yields higher UER (uniqueness) and contributes more to the health of the ecosystem than fixing the selection to the top 5 (Top 5).
- Importance of Long-term Sequences (Table 4):

Table 3

Table 4

Table 5
Conclusion and Future Outlook (Discussion / Conclusion)
LongRetriever achieved interaction between users and candidate items during the retrieval phase through In-Context Training and Multi-Context Retrieval. This successfully extended the benefits of long-term history, previously utilized only in the ranking phase, to the retrieval phase.
As for future prospects, it is suggested that Large Language Models (LLMs) could be utilized for category assignment or interest extraction to perform more sophisticated context generation.
Author's Perspective and Practical Application
Here are the author's own insights from reading this paper.
1. Balancing Filter Bubbles and Short-term Metrics
Looking at the experimental results in the paper (Table 3), we can see the following trade-off:
- Pure Accuracy: The Top 5 strategy has a higher CTR × CVR than the proposed Random 5 in Top 20 strategy (8.29% vs 7.92%).
- Diversity and Health: On the other hand, the Top 5 strategy has a higher AER (30.43%) and lower UER (7.23%). This means it mainly recommends popular products that are easily recommended by other models, leading to lower diversity and promoting filter bubbles.
In practice, this trade-off is a very difficult problem. It presents a dilemma: "If you want to maximize short-term sales (CVR), choose Top 5," but "If you want to maintain platform diversity and health (UER), choose Random in Top." Determining which to prioritize is not just an algorithmic issue, but a strategic decision to be made in consensus with management after investigating the relationship between LTV and diversity.
2. Deep Dive into Interests and Exploration Limits
This method uses categories present in the user's past behavior history as a hook for retrieval.
- What it is good at: Deepening (exploitation) of categories the user has already shown interest in.
- What it is bad at: Discovering (exploration) of categories the user may find appealing but has not yet recognized.
This weakness is not simply a matter of low model accuracy. Categories that the user is unaware of do not, by definition, exist in their past behavior sequences (history). Since LongRetriever is a mechanism that uses past behavior as a key to search for contexts, it is structurally difficult to explore unknown categories that are not in the history.
Therefore, when operating in practice, it is essential not to rely solely on this model, but to design a system that complements serendipity for unknown categories by using other methods such as popularity rankings, collaborative filtering-based approaches, or bandit algorithms.
3. Potential for Practical Application
In conclusion, I feel the potential for practical application is very high.
- Utilization of existing assets: If you already have a search index (Faiss or HNSW) environment, you can handle this simply by partitioning the index by category (or using filtered search).
- Realistic latency: While processing a user's entire history in real-time is too heavy, the design is such that inputting only the subsequence related to the category into the Transformer keeps inference latency within an acceptable range.
Summary
LongRetriever is a retrieval method that creates appropriate user vectors for each target product using ultra-long-term histories. By combining filtering history by category (search-based) with learning differentiation within that category (in-context), it resolves the trade-off between computational cost and accuracy.
On the other hand, since it only considers known categories, it is necessary to use separate methods such as popularity rankings, collaborative filtering-based methods, or bandit algorithms to complement serendipity for unknown categories.
As a method, it is very simple and easy to implement, so I believe it is highly worth verifying.
References and Recommended Reading
- This Paper:
- Related Key Papers:
- MIND: Multi-Interest Network with Dynamic Routing (CIKM 2019) - A multi-interest model used for comparison.
- SIM: Search-based User Interest Modeling (CIKM 2020) - A study that established search-based approaches in the ranking phase. One of the inspirations for LongRetriever.
- DIN: Deep Interest Network (KDD 2018) - The foundation of user interest modeling using attention mechanisms.
Discussion