Sequence recommendation method for time interval perception double-branch attention modeling
By employing a time-interval-aware bi-branch attention modeling method, the problem of the inability to effectively utilize time information in existing technologies is solved, enabling accurate characterization of user interests and improvement of recommendation models, resulting in more accurate recommendation results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANXI UNIV
- Filing Date
- 2026-03-23
- Publication Date
- 2026-05-15
AI Technical Summary
Existing sequence recommendation methods struggle to effectively utilize time information and cannot distinguish user interests and preferences across different time intervals, thus limiting the model's ability to express user interests.
We employ a time-interval-aware bi-branch attention modeling method to construct short-term and long-term interest representations by calculating the time intervals between items. We then fuse these interest representations using self-attention and gating mechanisms, while introducing a contrastive learning mechanism for consistency constraints.
It improves the ability to express user interests, enhances the accuracy and ranking quality of sequence recommendations, and can more accurately depict user behavior sequences to generate more reasonable recommendation results.
Smart Images

Figure CN122048488A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of user behavior sequence recommendation technology, specifically relating to a sequence recommendation method based on time interval-aware dual-branch attention modeling. Background Technology
[0002] With the rapid development of e-commerce platforms and online content services, a vast amount of user behavior data has accumulated on internet platforms. These behaviors, arranged chronologically, form user behavior sequences. By modeling these sequences, user interests can be effectively mined, leading to personalized recommendations. However, in real-world sequence recommendation scenarios, user behavior not only manifests as an ordered arrangement of items but also exhibits significant differences in time intervals. For example, a user's continuous browsing or purchase of a particular type of product within a short time interval may reflect their short-term interests; while interactions occurring after a longer time interval may reflect their relatively stable long-term interests. Therefore, the time interval information within user behavior sequences has a significant impact on characterizing user interests and is an essential factor in improving the accuracy of sequence recommendations.
[0003] Most existing sequence recommendation methods are primarily based on behavioral sequence modeling, with limited utilization of temporal information. While some methods incorporate temporal information, they merely treat it as an additional feature for simple fusion, failing to differentiate user interests through a robust modeling mechanism. This is particularly problematic when using a single attention branch to uniformly model the entire behavioral sequence, where interest preferences across different time intervals can easily become mixed, limiting the model's ability to express user interests. This invention addresses this by introducing timestamp information from the user's behavioral sequence to construct time intervals between items, and then employing a time-interval-aware dual-branch attention model to effectively characterize user interests and improve the accuracy of sequence recommendations. Summary of the Invention
[0004] To address the problems of existing sequence recommendation methods failing to effectively utilize time information and distinguishing interest patterns across different time intervals, this invention proposes a time interval-aware dual-branch attention modeling sequence recommendation method.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] A sequence recommendation method based on time interval-aware bi-branch attention modeling includes the following steps:
[0007] Step S1: Based on the user's historical behavior sequence data, construct an initial representation of the item by the item ID, calculate the time interval between adjacent item behaviors using the item timestamp, and construct the time interval representation corresponding to the item.
[0008] Furthermore, the specific steps of step S1 are as follows:
[0009] Step 1.1: Obtain the historical behavior sequences of all users to form a set of user historical behavior sequences, denoted as user sequence, and the user historical behavior sequence includes item ID identifier and corresponding behavior timestamp information.
[0010] Step 1.2, based on the user sequence The item ID at each location in the table constructs the initial representation of the item:
[0011] (1)
[0012] In formula (1), Represents user sequence The Middle The item at each location has a value that is the item ID. Indicates the embedding of mapping functions;
[0013] Step 1.3, based on the user sequence The historical behavior timestamp information is used to calculate the time interval between two adjacent behaviors, and the time interval is processed to obtain a representation of the time interval:
[0014] (2)
[0015] In formula (2), The parameter matrix representing the time interval transformation. Indicates the first in the sequence The time interval corresponding to each item.
[0016] Step S2: Fuse the initial representation of items and the time interval representation of items, characterize the representation ability of short-term and long-term interests based on the size of the time interval, construct the initial representation of adaptive short-term and long-term interests, and calculate the branch representation of all items corresponding to different interests based on the self-attention mechanism to establish a time interval-aware sequence recommendation model.
[0017] Furthermore, the specific steps of step S2 are as follows:
[0018] Step 2.1, based on user sequence The weighting coefficient is calculated for the time interval corresponding to each item:
[0019] (3)
[0020] In formula (3), The time decay coefficient, Indicates the first position in the sequence The weighting coefficient of the time interval corresponding to each item;
[0021] Step 2.2, user sequence The Middle The representation of an item and the representation of a time interval are weighted and fused according to a time interval weight coefficient, and the adaptive short-term interest representation capability and long-term interest representation capability of the item are calculated separately. The bi-branch representation is as follows:
[0022] (4)
[0023] In formula (4), The initial representation of item branches for adaptive short-term interests. Initial representation of item branches for adaptive long-term interest;
[0024] Step 2.3, in the user sequence In different interest branches, the interest correlation between items within the sequence is calculated using a self-attention mechanism. For interest branches First, construct the query matrix. Key matrix Sum matrix :
[0025] (5)
[0026] In formula (5), For user sequence Adaptive Interest The initial representation of the item branches, For user sequence All items in the initial representation, For user sequence Length, For query matrix The corresponding parameter matrix, Key matrix The corresponding parameter matrix, Value matrix The corresponding parameter matrix;
[0027] Step 2.4, User Sequence In the middle, interest branches The corresponding self-attention score is calculated as follows:
[0028] (6)
[0029] In formula (6), For the embedded dimension;
[0030] Step 2.5: Calculate interest branches based on self-attention mechanism The corresponding item branches are represented as follows:
[0031] (7)
[0032] In formula (7), For the normalization function, when for hour, For user sequence All short-term interest item branch representations obtained through self-attention mechanism learning, when for hour, For user sequence All long-term interest item branch representations obtained through self-attention mechanism learning.
[0033] Step S3: Gated fusion of the item branch representations of short-term and long-term interests is performed to adaptively adjust the role of the two types of interest representations and obtain the fused time-interval-aware user sequence representation.
[0034] Furthermore, the specific steps of step S3 are as follows:
[0035] Step 3.1, in the user sequence Short-term interest item branch representation Branch representation of long-term interest items Above, take the first one respectively Items and As a user sequence The user sequence representations of the short-term and long-term interest branches are concatenated to obtain:
[0036] (8)
[0037] In formula (8), Indicates splicing, This indicates retrieving the last line of the user's sequence item branch representation;
[0038] Step 3.2, introduce a gating mechanism to calculate the gating weight vector as follows:
[0039] (9)
[0040] In formula (9), Represents the parameter matrix Represents the bias matrix;
[0041] Step 3.3: Fuse user sequences based on gating weight vectors The user sequence representation of short-term and long-term interest branches is used to obtain the user sequence. The fused time-interval-aware user sequence representation:
[0042] (10)
[0043] In formula (10), This indicates element-wise multiplication.
[0044] Step S4: Compare and learn the initial representations of user sequences from different interest branches with the fused time-interval-aware user sequence representations.
[0045] Furthermore, the specific steps of step S4 are as follows:
[0046] Step 4.1, user sequence The adaptive short-term interest item branch representations of all items are average-pooled to obtain the user sequence. The initial representation of the user sequence of adaptive short-term interests is:
[0047] (11)
[0048] In formula (11), For user sequence Length;
[0049] Step 4.2, user sequence The time interval-aware representation after fusion With user sequence Initial representation of adaptive short-term interest As a positive sample pair, Other user sequences Initial representation of adaptive short-term interest As negative sample pairs, the contrastive learning loss function is constructed as follows:
[0050] (12)
[0051] In formula (12), For temperature coefficient, Cosine similarity;
[0052] Step 4.3, user sequence The adaptive long-term interest item branch representations of all items are average-pooled to obtain the user sequence. The initial representation of the user sequence of adaptive long-term interest is:
[0053] (13)
[0054] Step 4.4, user sequence The time interval-aware representation after fusion With user sequence Initial representation of adaptive long-term interest As a positive sample pair, Other user sequences Initial representation of adaptive long-term interest As negative sample pairs, the contrastive learning loss function is constructed as follows:
[0055] (14)
[0056] Step S5, based on the previous items in the user's historical behavior sequence... Calculate the time interval relationship between each neighbor and the current item, and construct a soft tag with time-relative location extension;
[0057] Furthermore, the specific steps of step S5 are as follows:
[0058] Step 5.1, Obtain the user sequence The previous item in the middle a neighbor ,according to Items in In sequence The position in the middle Calculate the relative positional relevance weights:
[0059] (15)
[0060] In formula (15), The attenuation coefficient controls the rate of attenuation of the distance between the positions. For user sequence Length;
[0061] Step 5.2, according to Items in Calculate the time relevance weight between the current item and the time interval:
[0062] (16)
[0063] In formula (16), The decay coefficient controls the decay rate over time.
[0064] Step 5.3: Obtain the item based on the location relevance weight and the time relevance weight. Overall relevance weights:
[0065] (17)
[0066] Step 5.4, Calculate items The time-relative position extended soft tag is:
[0067] (18)
[0068] Step S6: Calculate the user's predicted score for the current item based on the fused time-interval-aware user sequence representation, calculate the recommendation loss based on the time-relative location extended soft label, and optimize the model;
[0069] Furthermore, the specific steps of step S6 are as follows:
[0070] Step 6.1, based on user sequence Merged user sequence representation Calculate the user's opinion on the current item The predicted scores are obtained, and the predicted distribution is obtained by using the softmax normalization function:
[0071] (19)
[0072] In formula (19), It is an item Vector representation of;
[0073] Step 6.2, for the user sequence The prediction loss is calculated using the cross-entropy loss function, and its formula is as follows:
[0074] (20)
[0075] In formula (20), For all items;
[0076] Step 6.3, in the set of all user historical behavior sequences The total prediction loss is obtained from the above, and its formula is:
[0077] (twenty one)
[0078] Step 6.4: Jointly optimize the model using the obtained cross-entropy loss function and contrastive learning loss function. The overall model loss function is:
[0079] (twenty two)
[0080] In formula (22), and These are the contrastive learning balance coefficients for short-term and long-term interest branches, respectively.
[0081] Step S7: Calculate the predicted scores of the user behavior sequence for the candidate items based on the optimized model, sort the candidate items according to the predicted scores, and generate a Top-K recommendation result list.
[0082] Furthermore, the specific steps of step S7 are as follows:
[0083] Step 7.1, user sequence Input the optimized sequence recommendation model and calculate the recommendations for candidate items. Predicted score for:
[0084] (twenty three)
[0085] Step 7.2: Calculate the predicted scores for all candidate items, sort all candidate items from highest to lowest according to the predicted scores, select the top K items with the highest scores as the recommendation results, and generate a Top-K item recommendation list.
[0086] Compared with the prior art, the present invention has the following advantages:
[0087] This invention proposes a time-interval-aware dual-branch attention modeling sequence recommendation method. By introducing temporal information and a structure enhancement mechanism during sequence modeling, it improves the expressive power of user interests. This method characterizes the representational power of short-term and long-term interests based on the magnitude of the time interval, and calculates the branch representations of all items corresponding to different interests based on a self-attention mechanism. Finally, a gating mechanism is used to fuse the two types of interest representations to obtain a fused time-interval-aware user sequence representation. Simultaneously, this invention constructs soft labels with time-relative position extensions to characterize the relative correlations between candidate items. Furthermore, by introducing a contrastive learning mechanism, this invention applies consistency constraints between the initial user sequence representations of different interest branches and the fused time-interval-aware user sequence representation, allowing temporal information to be more effectively integrated into the sequence representation learning process. Through the collaborative design of the above-mentioned structural modeling and supervised optimization, this invention can more accurately characterize user interests, improve the recommendation model's ability to model user behavior sequences, and thus enhance the accuracy and ranking quality of recommendation results. Attached Figure Description
[0088] Figure 1 This is a schematic diagram of the overall model architecture of the present invention. Detailed Implementation
[0089] To gain a deeper understanding of this invention, we will provide a comprehensive and detailed description. However, this invention has various implementations and is not limited to the specific examples listed herein. These examples are presented to enhance a full understanding of the disclosure of this invention.
[0090] The sequence recommendation method based on time interval-aware bi-branch attention modeling described in this invention is implemented through a computer program. The specific implementation methods of the technical solution proposed in this invention will be detailed below according to the flowchart.
[0091] like Figure 1 As shown, the present invention provides a sequence recommendation method based on time interval-aware bi-branch attention modeling, comprising the following steps:
[0092] Step S1: Based on the user's historical behavior sequence data, construct an initial representation of the item by the item ID, calculate the time interval between adjacent item behaviors using the item timestamp, and construct the time interval representation corresponding to the item.
[0093] Furthermore, the specific steps of step S1 are as follows:
[0094] Step 1.1: Obtain the historical behavior sequences of all users to form a set of user historical behavior sequences, denoted as user sequence, and the user historical behavior sequence includes item ID identifier and corresponding behavior timestamp information.
[0095] Step 1.2, based on the user sequence The item ID at each location in the table constructs the initial representation of the item:
[0096] (1)
[0097] In formula (1), Represents user sequence The Middle The item at each location has a value that is the item ID. Indicates the embedding of mapping functions;
[0098] Step 1.3, based on the user sequence The historical behavior timestamp information is used to calculate the time interval between two adjacent behaviors, and the time interval is processed to obtain a representation of the time interval:
[0099] (2)
[0100] In formula (2), The parameter matrix representing the time interval transformation. Indicates the first position in the sequence The time interval corresponding to each item.
[0101] Step S2: Fuse the initial representation of items and the time interval representation of items, characterize the representation ability of short-term and long-term interests based on the size of the time interval, construct the initial representation of adaptive short-term and long-term interests, and calculate the branch representation of all items corresponding to different interests based on the self-attention mechanism to establish a time interval-aware sequence recommendation model.
[0102] Furthermore, the specific steps of step S2 are as follows:
[0103] Step 2.1, based on user sequence The weighting coefficient is calculated for the time interval corresponding to each item:
[0104] (3)
[0105] In formula (3), The time decay coefficient, Indicates the first position in the sequence The weighting coefficient of the time interval corresponding to each item;
[0106] Step 2.2, user sequence The Middle The representation of an item and the representation of a time interval are weighted and fused according to a time interval weight coefficient, and the adaptive short-term interest representation capability and long-term interest representation capability of the item are calculated separately. The bi-branch representation is as follows:
[0107] (4)
[0108] In formula (4), The initial representation of item branches for adaptive short-term interests. Initial representation of item branches for adaptive long-term interest;
[0109] Step 2.3, in the user sequence In different interest branches, the interest correlation between items within the sequence is calculated using a self-attention mechanism. For interest branches First, construct the query matrix. Key matrix Sum matrix :
[0110] (5)
[0111] In formula (5), For user sequence Adaptive Interest The initial representation of the item branches, For user sequence All items in the initial representation, For user sequence Length, For query matrix The corresponding parameter matrix, Key matrix The corresponding parameter matrix, Value matrix The corresponding parameter matrix;
[0112] Step 2.4, User Sequence In the middle, interest branches The corresponding self-attention score is calculated as follows:
[0113] (6)
[0114] In formula (6), For the embedded dimension;
[0115] Step 2.5: Calculate interest branches based on self-attention mechanism The corresponding item branches are represented as follows:
[0116] (7)
[0117] In formula (7), For the normalization function, when for hour, For user sequence All short-term interest item branch representations obtained through self-attention mechanism learning, when for hour, For user sequence All long-term interest item branch representations obtained through self-attention mechanism learning.
[0118] Step S3: Gated fusion of the item branch representations of short-term and long-term interests is performed to adaptively adjust the role of the two types of interest representations and obtain the fused time-interval-aware user sequence representation.
[0119] Furthermore, the specific steps of step S3 are as follows:
[0120] Step 3.1, in the user sequence Short-term interest item branch representation Branch representation of long-term interest items Above, take the first one respectively Items and As a user sequence The user sequence representations of the short-term and long-term interest branches are concatenated to obtain:
[0121] (8)
[0122] In formula (8), Indicates splicing, This indicates retrieving the last line of the user's sequence item branch representation;
[0123] Step 3.2, introduce a gating mechanism to calculate the gating weight vector as follows:
[0124] (9)
[0125] In formula (9), Represents the parameter matrix Represents the bias matrix;
[0126] Step 3.3: Fuse user sequences based on gating weight vectors The user sequence representation of short-term and long-term interest branches is used to obtain the user sequence. The fused time-interval-aware user sequence representation:
[0127] (10)
[0128] In formula (10), This indicates element-wise multiplication.
[0129] Step S4: Compare and learn the initial representations of user sequences from different interest branches with the fused time-interval-aware user sequence representations.
[0130] Furthermore, the specific steps of step S4 are as follows:
[0131] Step 4.1, user sequence The adaptive short-term interest item branch representations of all items are average-pooled to obtain the user sequence. The initial representation of the user sequence of adaptive short-term interests is:
[0132] (11)
[0133] In formula (11), For user sequence Length;
[0134] Step 4.2, user sequence The time interval-aware representation after fusion With user sequence Initial representation of adaptive short-term interest As a positive sample pair, Other user sequences Initial representation of adaptive short-term interest As negative sample pairs, the contrastive learning loss function is constructed as follows:
[0135] (12)
[0136] In formula (12), For temperature coefficient, Cosine similarity;
[0137] Step 4.3, user sequence The adaptive long-term interest item branch representations of all items are average-pooled to obtain the user sequence. The initial representation of the user sequence of adaptive long-term interest is:
[0138] (13)
[0139] Step 4.4, user sequence The time interval-aware representation after fusion With user sequence Initial representation of adaptive long-term interest As a positive sample pair, Other user sequences Initial representation of adaptive long-term interest As negative sample pairs, the contrastive learning loss function is constructed as follows:
[0140] (14)
[0141] Step S5, based on the previous items in the user's historical behavior sequence... Calculate the time interval relationship between each neighbor and the current item, and construct a soft tag with time-relative location extension;
[0142] Furthermore, the specific steps of step S5 are as follows:
[0143] Step 5.1, Obtain the user sequence The previous item in the middle a neighbor ,according to Items in In sequence The position in the middle Calculate the relative positional relevance weights:
[0144] (15)
[0145] In formula (15), The attenuation coefficient controls the rate of attenuation of the distance between the positions. For user sequence Length;
[0146] Step 5.2, according to Items in Calculate the time relevance weight between the current item and the time interval:
[0147] (16)
[0148] In formula (16), The decay coefficient controls the decay rate over time.
[0149] Step 5.3: Obtain the item based on the location relevance weight and the time relevance weight. Overall relevance weights:
[0150] (17)
[0151] Step 5.4, Calculate items The time-relative position extended soft tag is:
[0152] (18)
[0153] Step S6: Calculate the user's predicted score for the current item based on the fused time-interval-aware user sequence representation, calculate the recommendation loss based on the time-relative location extended soft label, and optimize the model;
[0154] Furthermore, the specific steps of step S6 are as follows:
[0155] Step 6.1, based on user sequence Merged user sequence representation Calculate the user's opinion on the current item The predicted scores are obtained, and the predicted distribution is obtained by using the softmax normalization function:
[0156] (19)
[0157] In formula (19), It is an item Vector representation of;
[0158] Step 6.2, for the user sequence The prediction loss is calculated using the cross-entropy loss function, and its formula is as follows:
[0159] (20)
[0160] In formula (20), For all items;
[0161] Step 6.3, in the set of all user historical behavior sequences The total prediction loss is obtained from the above, and its formula is:
[0162] (twenty one)
[0163] Step 6.4: Jointly optimize the model using the obtained cross-entropy loss function and contrastive learning loss function. The overall model loss function is:
[0164] (twenty two)
[0165] In formula (22), and These are the contrastive learning balance coefficients for short-term and long-term interest branches, respectively.
[0166] Step S7: Calculate the predicted scores of the user behavior sequence for the candidate items based on the optimized model, sort the candidate items according to the predicted scores, and generate a Top-K recommendation result list.
[0167] Furthermore, the specific steps of step S7 are as follows:
[0168] Step 7.1, user sequence Input the optimized sequence recommendation model and calculate the recommendations for candidate items. Predicted score for:
[0169] (twenty three)
[0170] Step 7.2: Calculate the predicted scores for all candidate items, sort all candidate items from highest to lowest according to the predicted scores, select the top K items with the highest scores as the recommendation results, and generate a Top-K item recommendation list.
[0171] To verify the effectiveness of the method, experiments were conducted on the Beauty dataset (https: / / jmcauley.ucsd.edu / data / amazon / index_2014.html), which covers real user behavior records on the Amazon e-commerce platform, and each interaction data includes accurate timestamp information. Dataset information is shown in Table 1:
[0172] Table 1 Dataset Information
[0173]
[0174] This invention uses HR and NDCG as evaluation indicators to assess the recommendation performance of the proposed method. To verify the effectiveness and superiority of the technical solution of this invention, existing sequence recommendation models such as TiSASRec, TCPSRec, TiCoSeRec, Mstein, TiM4Rec, and HM4SR were selected as comparative methods for experimental analysis. The relevant experimental results are shown in Table 2.
[0175] Table 2 Experimental Results
[0176]
[0177] As can be seen from the experimental results in Table 2, the method proposed in this invention achieves optimal performance across all evaluation metrics. Specifically, it improves performance by an average of 10.96% and 20.06% compared to the suboptimal model in terms of HR and NDCG. These results demonstrate that the method of this invention can more accurately predict the next item a user might interact with and provides a more reasonable ranking in the recommendation list, thus validating the effectiveness of the technical solution of this invention.
[0178] Contents not described in detail in this specification are prior art known to those skilled in the art. The above descriptions are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. For those skilled in the art, all modifications, equivalent substitutions, or improvements made without departing from the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A sequence recommendation method based on time-interval-aware bi-branch attention modeling, characterized in that, Includes the following steps: Step S1: Obtain the historical behavior sequence of all users. Based on the user historical behavior sequence data, construct the initial representation of the item by the item ID. Calculate the time interval between adjacent item behaviors using the item timestamp and construct the time interval representation corresponding to the item. Step S2: Fuse the initial representation of items and the time interval representation of items, characterize the representation ability of short-term and long-term interests based on the size of the time interval, construct the initial representation of adaptive short-term and long-term interests, and calculate the branch representation of all items corresponding to different interests based on the self-attention mechanism to establish a time interval-aware sequence recommendation model. Step S3: Gated fusion of the item branch representations of short-term and long-term interests is performed to adaptively adjust the role of the two types of interest representations and obtain the fused time-interval-aware user sequence representation. Step S4: Compare and learn the initial representations of user sequences with the fused time-interval-aware user sequence representations for different interests. Step S5, based on the previous items in the user's historical behavior sequence... Calculate the time interval relationship between each neighbor and the current item, and construct a soft tag with time-relative location extension; Step S6: Calculate the user's predicted score for the current item based on the fused time-interval-aware user sequence representation, calculate the recommendation loss based on the time-relative location extended soft label, and optimize the model; Step S7: Calculate the predicted scores of the user behavior sequence for the candidate items based on the optimized model, sort the candidate items according to the predicted scores, and generate a Top-K item recommendation list.
2. The sequence recommendation method based on time interval-aware bi-branch attention modeling according to claim 1, characterized in that, In step S1, the historical behavior sequences of all users are obtained. Based on the user historical behavior sequence data, an initial representation of the item is constructed using the item ID. The time interval between adjacent item behaviors is calculated using the item timestamp. The specific steps for constructing the time interval representation corresponding to the item are as follows: Step 1.1: Obtain the historical behavior sequences of all users to form a set of user historical behavior sequences. For the current user's historical behavior sequence, let it be denoted as the user sequence. The user's historical behavior sequence includes an item ID and the corresponding behavior timestamp information; Step 1.2, based on the user sequence The item ID at each location in the table constructs the initial representation of the item: (1); In formula (1), Represents user sequence The Middle The item at each location has a value that is the item ID. Indicates the embedding of mapping functions; Step 1.3, based on the user sequence The historical behavior timestamp information is used to calculate the time interval between two adjacent behaviors, and the time interval is processed to obtain a representation of the time interval: (2); In formula (2), The parameter matrix representing the time interval transformation. Indicates the first position in the sequence The time interval corresponding to each item.
3. The sequence recommendation method based on time interval-aware bi-branch attention modeling according to claim 2, characterized in that, In step S2, the initial representation of an item and the time interval representation corresponding to the item are fused. The representational power of short-term and long-term interests is characterized based on the size of the time interval. Adaptive initial representations of short-term and long-term interests are constructed. The specific steps for calculating the branch representations of all items corresponding to different interests based on the self-attention mechanism are as follows: Step 2.1, based on user sequence The weighting coefficient is calculated for the time interval corresponding to each item: (3); In formula (3), The time decay coefficient, Indicates the first in the user sequence The weighting coefficient of the time interval corresponding to each item; Step 2.2, user sequence The Middle The representation of an item and the representation of a time interval are weighted and fused according to a time interval weight coefficient, and the adaptive short-term interest representation capability and long-term interest representation capability of the item are calculated separately. The bi-branch representation is as follows: (4); In formula (4), The initial representation of item branches for adaptive short-term interests. Initial representation of item branches for adaptive long-term interest; Step 2.3, in the user sequence In different interest branches, the interest correlation between items within the sequence is calculated using a self-attention mechanism. For interest branches First, construct the query matrix. Key matrix Sum matrix : (5); In formula (5), For user sequence Adaptive Interest The initial representation of the item branches, For user sequence All items in the initial representation, For user sequence Length, For query matrix The corresponding parameter matrix, Key matrix The corresponding parameter matrix, Value matrix The corresponding parameter matrix; Step 2.4, User Sequence In the middle, interest branches The corresponding self-attention score is calculated as follows: (6); In formula (6), For the embedded dimension; Step 2.5: Calculate interest branches based on self-attention mechanism The corresponding item branches are represented as follows: (7); In formula (7), For the normalization function, when for hour, For user sequence All short-term interest item branch representations obtained through self-attention mechanism learning, when for hour, For user sequence All long-term interest item branch representations obtained through self-attention mechanism learning.
4. The sequence recommendation method based on time interval-aware bi-branch attention modeling according to claim 3, characterized in that, The specific steps in step S3 to perform gating fusion of the item branch representations of short-term and long-term interests, adaptively adjusting the roles of the two types of interest representations, and obtaining the fused time-interval-aware user sequence representation are as follows: Step 3.1, in the user sequence Short-term interest item branch representation Branch representation of long-term interest items Above, take the first one respectively Items and As a user sequence The user sequence representations of the short-term and long-term interest branches are concatenated to obtain: (8); In formula (8), Indicates splicing, This indicates retrieving the last line of the user's sequence item branch representation; Step 3.2: Introduce a gating mechanism to calculate the gating weight vector, using the following formula: (9); In formula (9), Represents the parameter matrix Represents the bias matrix; Step 3.3: Fuse user sequences based on gating weight vectors The user sequence representation of short-term and long-term interest branches is used to obtain the user sequence. The fused time-interval-aware user sequence representation: (10); In formula (10), This indicates element-wise multiplication.
5. The sequence recommendation method based on time interval-aware bi-branch attention modeling according to claim 4, characterized in that, The specific steps in step S4 of comparing and learning the initial representations of user sequences from different interest branches with the fused time-interval-aware user sequence representations are as follows: Step 4.1, user sequence The adaptive short-term interest item branch representations of all items are average-pooled to obtain the user sequence. The initial representation of the user sequence of adaptive short-term interests is: (11); In formula (11), For user sequence Length; Step 4.2, user sequence The time interval-aware representation after fusion With user sequence Initial representation of adaptive short-term interest As a positive sample pair, Other user sequences Initial representation of adaptive short-term interest As negative sample pairs, the contrastive learning loss function is constructed as follows: (12); In formula (12), For temperature coefficient, Cosine similarity; Step 4.3, user sequence The adaptive long-term interest item branch representations of all items are average-pooled to obtain the user sequence. The initial representation of the user sequence of adaptive long-term interest is: (13); Step 4.4, user sequence The time interval-aware representation after fusion With user sequence Initial representation of adaptive long-term interest As a positive sample pair, Other user sequences Initial representation of adaptive long-term interest As negative sample pairs, the contrastive learning loss function is constructed as follows: (14)。 6. The sequence recommendation method based on time interval-aware bi-branch attention modeling according to claim 5, characterized in that, In step S5, the current item is identified based on the user's historical behavior sequence. The specific steps for constructing a time-relative location extended soft tag, based on the relationships between each neighbor and the current item, are as follows: Step 5.1, Obtain the user sequence The previous item in the middle a neighbor ,according to Items in In sequence The first in Calculate the relative positional relevance weights for each item's location: (15); In formula (15), The attenuation coefficient controls the rate of attenuation of the distance between the positions. For user sequence Length; Step 5.2, according to Items in Calculate the time relevance weight between the current item and the time interval: (16); In formula (16), The attenuation coefficient controls the decay rate over time. Step 5.3: Obtain the item based on the location relevance weight and the time relevance weight. Overall relevance weights: (17); Step 5.4, Calculate items The time-relative position extended soft tag is: (18)。 7. The sequence recommendation method based on time interval-aware bi-branch attention modeling according to claim 6, characterized in that, The specific steps in step S6, which involve calculating the user's predicted score for the current item based on the fused time-interval-aware user sequence representation, calculating the recommendation loss based on the time-relative location-extended soft label, and optimizing the model, are as follows: Step 6.1, based on user sequence Merged user sequence representation Calculate the user's opinion on the current item The predicted scores are obtained, and the predicted distribution is obtained by using the softmax normalization function: (19); In formula (19), It is an item Vector representation of; Step 6.2, for the user sequence The prediction loss is calculated using the cross-entropy loss function, and its formula is as follows: (20); In formula (20), For all items; Step 6.3, in the set of all user historical behavior sequences The total prediction loss is obtained from the above, and its formula is: (21); Step 6.4: Jointly optimize the model using the obtained cross-entropy loss function and contrastive learning loss function. The overall model loss function is: (22); In formula (22), and These are the contrastive learning balance coefficients for short-term and long-term interest branches, respectively.
8. The sequence recommendation method based on time interval-aware bi-branch attention modeling according to claim 7, characterized in that, The specific steps in step S7, which involve calculating the predicted scores of candidate items based on the optimized model using the user behavior sequence and sorting the candidate items according to their predicted scores to generate a Top-K recommendation result list, are as follows: Step 7.1, user sequence Input the optimized sequence recommendation model and calculate the recommendations for candidate items. Predicted score for: (23); Step 7.2: Calculate the predicted scores for all candidate items, sort all candidate items from highest to lowest according to the predicted scores, select the top K items with the highest scores as the recommendation results, and generate a Top-K item recommendation list.