Project relationship attention mechanism and convolutional method for constructing a sequence recommendation model
By constructing a sequence recommendation model using an item relationship attention mechanism and convolution, this technology addresses the problem of failing to effectively distinguish between users' short-term and long-term preferences and ignoring item relationships in existing technologies, achieving more accurate personalized recommendations, especially with improvements in sparse data and cold start scenarios.
Patent Information
- Application Number
- CN202410757665.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2044-06-13
AI Technical Summary
Existing sequence recommendation models fail to effectively distinguish between users' long-term and short-term preferences and ignore item relationships, resulting in low recommendation accuracy, especially when facing sparse data and cold start problems.
A sequential recommendation model is constructed using an item relationship attention mechanism and convolution. Item relationships are used as attention heads to build long-term preferences, and convolution is used to form short-term preferences. The long-term and short-term preferences are then merged to generate the final recommendation result.
It improves the accuracy of sequence recommendation, effectively alleviates the cold start problem, and provides more accurate personalized recommendations under sparse data conditions.
Smart Images

Figure CN118797154B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of sequence recommendation technology, and in particular to a method for constructing a sequence recommendation model using an item relationship attention mechanism and a convolutional approach. Background Technology
[0002] Sequential recommendation generates the next item a user will interact with based on their continuous interaction history. It is widely used in real-world applications and has become one of the important research directions in the field of recommender systems. In real life, continuous sequential user behavior is very common, and most subsequent user behaviors are influenced by previous consecutive behaviors; therefore, conducting research on sequential recommendation is of great significance.
[0003] In the real world, tens of thousands of new pieces of information are generated every day, which can overwhelm users. Therefore, when recommending information to users, it's not about presenting all generated information, but rather collecting information that is relevant to or of interest to the user and recommending it accordingly. Thus, when modeling users, it's crucial to fully consider their long-term preferences, which represent their long-term and stable interests. Recent user behaviors must also be taken into account, as their next interaction may be influenced by these recent actions. Therefore, a sound modeling of both long-term and short-term user preferences is necessary to capture user interests and make more accurate recommendations.
[0004] Existing sequence recommendation models use many neural network models, including recurrent neural networks, graph neural networks, convolutional neural networks, and combinations thereof. However, they mostly focus on the user's historical interaction sequences, lacking attention to item relationships and ignoring the user's short-term preferences, resulting in low recommendation accuracy.
[0005] Application number CN202211284644.9, entitled "Training Method and Apparatus for Sequence Recommendation Model," discloses a method for a sequence recommendation model. The method includes: acquiring historical behavior sequences of related object recommendation services; generating original interest representations based on historical objects contained in the historical behavior sequences; generating original interest representations for each historical object; calculating object similarity between each historical object and a benchmark preference object based on attention influence parameters in at least one dimension for each historical object; determining target historical objects in the historical behavior sequences based on object similarity; generating counterfactual interest representations based on the target historical objects; generating optimized parameter pairs based on the original interest representations, the benchmark preference representations corresponding to the benchmark preference objects, and the counterfactual interest representations; and training a sequence recommendation model for related object recommendation services based on the optimized parameter pairs. This invention does not explicitly model users' long-term and short-term preferences, cannot accurately generate personalized recommendations, and does not fully utilize the application of item relationships in sequence recommendation. Its recommendation performance is not ideal when facing cold start problems or sparse data.
[0006] The aforementioned recommendation methods often fail to effectively distinguish between long-term and short-term user preferences. Most only capture long-term preferences while ignoring changes in short-term preferences, resulting in recommendations that don't reflect users' latest interests in a timely manner. When dealing with sparse data, the limited interaction data between users and items makes it difficult for traditional recommendation algorithms to accurately capture user preferences. Furthermore, when facing the cold start problem, the lack of sufficient data hinders effective recommendations from traditional methods. Summary of the Invention
[0007] The purpose of this invention is to address the shortcomings of the existing technology by providing a method for constructing a sequence recommendation model using an item relationship attention mechanism and convolutional method, thereby solving the problem of low recommendation accuracy in the existing technology.
[0008] The present invention adopts the following technical solution:
[0009] Methods for constructing sequence recommendation models using project relationship attention mechanisms and convolutional methods include:
[0010] S1. Obtain the user's historical behavior and interaction sequence.
[0011] S2. Obtain the project relationships in the project based on the user's historical behavior interaction sequence. The project relationships are divided into intra-sequence project relationships and inter-sequence project relationships. For example, two projects may be of the same brand, the same color, or the same category.
[0012] S3. Construct users' long-term preferences based on item relationships as attention heads, and construct users' short-term preferences based on interaction items of historical behavior.
[0013] S4. The user's long-term and short-term preferences are fused, and the corresponding recommendation results are obtained using the fused final representation.
[0014] Furthermore, in S3, inputting the embedding matrix into the attention module includes:
[0015]
[0016] A = LN(E) Emb +Dropout(IRA(E Emb )))
[0017] F = LN(A + Dropout(FFN(A)))
[0018] IRA (B) =IRA(F (B-1 )
[0019] A (B) =LN(F (B-1) +Dropout(IRA(F (B-1) )))
[0020] F (B) =LN(A (B) +Dropout(FFN(A (B) )))
[0021] Among them, Q E For queries embedded in a matrix, K E V is the key of the embedded matrix. E K represents the value of the embedding matrix. Rel As the key of the project relationship matrix, For each head dimension, IRA(E) Emb ) represents the project relationship attention score, LN represents layer normalization, Dropout represents the dropout operation, and A represents the IRA(E) score. Emb The value after discarding, residual connection, and layer normalization operations, F is the value of A after discarding, residual connection, and layer normalization operations, FFN is the feedforward neural network, and IRA(F) is the value of A after discarding, residual connection, and layer normalization operations. (B-1) When B > 1, the input matrix is the output of the previous layer, IRA. (B) A (B) F (B) All values are from layer B. The last layer of the project relationship attention layer is represented as e. (IRA) .
[0022] Furthermore, in S3, inputting the embedded matrix into the convolution module includes:
[0023] X(E Emb=LN(Dropout(Linear(E)) Emb )))
[0024]
[0025] Conv k=5 (X) = LN(Dropout([Conv k=5 (X)1, Conv k=5 (X)2, ..., Conv k=5 (X) L ]))
[0026] G = ReLU(Conv) k=5 (X))
[0027]
[0028] Where Linear is a linear transformation, Dropout is a dropout operation, LN is layer normalization, and X(E) is a linear transformation. Emb X is the matrix obtained after linear transformation, discarding operation, and layer normalization of the embedding matrix, with ReLU as the activation function. i:i+k-1 To allow sliding within a certain interval, F is a filter, F f For the f-th filter, The value at position i after being processed by the f-th filter, corresponding to Let represent the values at position i after processing by the 1st, 2nd, ..., mth filters, respectively. Conv represents the convolution operation, k is the kernel size, Concat is the concatenation operation, and X represents X(E). Emb ), G is the value of X after convolution and ReLU activation function, Conv (D) G (D) All values are from the D-th layer. The last layer of the convolutional layer is represented as e. (Conv) .
[0029] Furthermore, S4 includes fusing long-term preferences formed by project relationship attention with short-term preferences formed by convolutional methods, including:
[0030] e (Final) =λ*e (Conv) +(1-λ)*e (IRA)
[0031] Where λ is the fusion parameter, e (IRA) e represents the final representation of long-term preferences formed by attentional heads in project relationships. (Conv) For the final representation of short-term preferences formed by convolution, e (Final) This is the final representation after the fusion of long-term and short-term preferences.
[0032] Furthermore, S4 also includes using the final representation to form the recommended score for the next item:
[0033]
[0034] in, Let e be the most recent interaction sequence of user u with length L. (Final) v is the final representation of the fusion of long-term and short-term preferences. ο For all candidate projects, A matrix formed for candidate projects, Scores for all candidate items.
[0035] Furthermore, S4 also includes the loss function for the sequence recommendation model:
[0036]
[0037] in, The loss function for project prediction. Let Θ be the loss function for the project relationship, Θ be all learnable parameters, and μ be the hyperparameter.
[0038] The beneficial effects of this invention are:
[0039] By using item relationships as attention heads to form long-term preferences and convolutional methods to form short-term preferences, the final preference representation of users is modeled by fusing long-term and short-term preferences, thereby improving the performance of sequence recommendation.
[0040] Compared with the prior art, the model of this invention uses the relationship between items as the attention head to calculate attention, which can effectively model users' long-term preferences and alleviate the cold start problem. Attached Figure Description
[0041] Figure 1 A flowchart of the method provided by the present invention;
[0042] Figure 2 A method framework diagram provided for this invention;
[0043] Figure 3 This is for creating a sequence recommendation graph based on project relationships. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention are described clearly and completely below. Obviously, the described embodiments are only some embodiments of this invention, not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0045] Currently, most sequential recommendation models only consider users' long-term preferences, neglecting the importance of item relationships and users' short-term preferences. To address this issue, this invention proposes a sequential recommendation model that combines item relationships and users' short-term preferences. Item relationships are used as attention heads for attention calculation to obtain long-term preferences, and convolutional methods are used to obtain short-term preferences. Finally, the long-term and short-term preferences are fused, and the fused final representation is used to form the prediction result for the next item.
[0046] like Figure 1 , Figure 2 As shown, the method for constructing a sequence recommendation model using the item relationship attention mechanism and convolutional method includes...
[0047] S1. Obtain the user's historical behavior and interaction sequence.
[0048] The datasets used are Amazon_office and Amazon_Beauty, which include user information, item information, user's historical interaction items, and interaction times. These two datasets will be preprocessed; specifically, to ensure the rationality of the modeling, all items and users with fewer than 5 interactions will be removed, resulting in the desired user sequence.
[0049] S2. Obtain the project relationships in the project based on the user's historical behavior interaction sequence. The project relationships are divided into intra-sequence project relationships and inter-sequence project relationships. For example, two projects may be of the same brand, the same color, or the same category.
[0050] S3. Construct users' long-term preferences based on item relationships as attention heads, and construct users' short-term preferences based on interaction items of historical behavior.
[0051] Specifically, U = {u1, u2, ..., u} |U|} represents all users, V = {ν1, ν2, ..., ν} |ν|} represents all projects. The user's interaction sequence is represented by the user embedding matrix, which is combined with the position embedding matrix to form the final embedding matrix:
[0052]
[0053] Specifically, attention is calculated by using project relationships as the attention head to form users' long-term preferences, using the following formula:
[0054]
[0055] A = LN(E) Emb +Dropout(IRA(E Emb )))
[0056] F = LN(A + Dropout(FFN(A)))
[0057] IRA (B) =IRA(F (B-1) )
[0058] A (B) =LN(F (B-1) +Dropout(IRA(F (B-1 )))
[0059] F (B) =LN(A (B) +Dropout(FFN(A (B) )))
[0060] Among them, Q E For queries embedded in a matrix, K E V is the key of the embedded matrix. E K represents the value of the embedding matrix. Rel As the key of the project relationship matrix, For each head dimension, IRA(E) Emb ) represents the project relationship attention score, LN represents layer normalization, Dropout represents the dropout operation, and A represents the IRA(E) score. Emb The value after discarding, residual connection, and layer normalization operations, F is the value of A after discarding, residual connection, and layer normalization operations, FFN is the feedforward neural network, and IRA(F) is the value of A after discarding, residual connection, and layer normalization operations. (B-1) When B > 1, the input matrix is the output of the previous layer, IRA. (B) A (B) F (B) All values are from layer B. The last layer of the project relationship attention layer is represented as e. (IRA) .
[0061] Specifically, short-term user preferences are formed using convolution, with the following formula:
[0062] X(E Emb =LN(Dropout(Linear(E)) Emb )))
[0063]
[0064] Conv k=5 (X) = LN(Dropout([Conv k=5 (X)1,Conv k=5 (X)2,...,Conv k=5 (X) L ]))
[0065] G = ReLU(Conv) k=5 (X))
[0066]
[0067] Where Linear is a linear transformation, Dropout is a dropout operation, LN is layer normalization, and X(E) is a linear transformation. Emb X is the matrix obtained after linear transformation, discarding operation, and layer normalization of the embedding matrix, with ReLU as the activation function. i:i+k-1 To allow sliding within a certain interval, F is a filter, F f For the f-th filter, The value at position i after being processed by the f-th filter, corresponding to Let represent the values at position i after processing by the 1st, 2nd, ..., mth filters, respectively. Conv represents the convolution operation, k is the kernel size, Concat is the concatenation operation, and X represents X(E). Emb ), G is the value of X after convolution and ReLU activation function, Conv (D) G (D) All values are from the D-th layer. The last layer of the convolutional layer is represented as e. (Conv) .
[0068] S4. The user's long-term and short-term preferences are fused, and the corresponding recommendation results are obtained using the fused final representation.
[0069] Specifically, after obtaining users' long-term and short-term preferences, these preferences will be merged using the following formula:
[0070] e (Final) =λ*e (Conv) +(1-λ)*e (IRA)
[0071] Where λ is the fusion parameter, e (IRA) e represents the final representation of long-term preferences formed by attentional heads in project relationships. (Conv) For the final representation of short-term preferences formed by convolution, e (Final)This is the final representation after the fusion of long-term and short-term preferences.
[0072] Specifically, this ultimately translates to the recommended score for the next project:
[0073]
[0074] in, Let e be the most recent interaction sequence of user u with length L. (Final) v is the final representation of the fusion of long-term and short-term preferences. ο All candidate projects, A matrix formed for candidate projects, Scores for all candidate items.
[0075] Specifically, the prediction loss function used is the cross-entropy loss function:
[0076]
[0077] Where σ is the sigmoid function, Let t be the true value at step t. Since the project involves user interaction, the total loss function of this sequence recommendation model is:
[0078] The loss function for the sequence recommendation model is:
[0079]
[0080] in, The loss function for project prediction. Let Θ be the loss function for the project relationship, Θ be all learnable parameters, and μ be the hyperparameter.
[0081] Example
[0082] like Figure 3As shown, on an e-commerce shopping platform, User 1's interaction sequence is (phone, tablet, charger, data cable a, mouse a, monitor, short-sleeved shirt), User 2's interaction sequence is (hoodie, shorts, phone, data cable a, mouse b), and User 3's interaction sequence is (basketball, glove, keyboard, monitor, computer case). The goal is to recommend the next item to User 2. The user interaction sequences are then input into an attention model. From a long-term preference perspective, clothing might score relatively high, while electronic products might score relatively low. However, due to item relationships—phone and data cable a are used together, mouse a and mouse b are from the same brand, and keyboard and mouse b are from the same store—electronic products related to the monitor score relatively high. Then, the user interaction sequences are input into a convolutional model, resulting in higher scores for electronic products. Therefore, the next item recommended to User 2 might be a monitor or a product related to the monitor.
[0083] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for constructing a sequence recommendation model using an item relationship attention mechanism and convolutional methods, characterized in that, include S1. Obtain the user's historical behavior and interaction sequence. The datasets used are Amazon_office and Amazon_Beauty. The datasets include user information, project information, user's historical interaction with projects, and the time of interaction. S2. Obtain the project relationships in the project based on the user's historical behavior interaction sequence. The project relationships are divided into intra-sequence project relationships and inter-sequence project relationships. S3. Construct a long-term user preference matrix based on item relationships as attention points and the interaction items formed by historical behavior. Developing users' short-term preferences; The short-term preferences of users are formed using convolution, and the specific formula is as follows: ; ; ; ; ; ; ; in, For linear transformation, For the discard operation, For layer normalization, The matrix is the result of linear transformation, discarding operation, and layer normalization of the embedded matrix. For activation function, To slide within a certain interval, For filters, For the first One filter, For the first The position passed the first The value processed by each filter, corresponding to , , ..., The first The position passes through the 1st, 2nd, ..., The value after processing by each filter For convolution operations, For the size of the core, For the splicing operation, X is G is the value of X after convolution and ReLU activation. , All values are from the D-th layer. The last layer of the convolutional layer is represented as... ; Also includes: This represents all users. This represents all projects. Indicates user The interaction sequence is used to combine the user embedding matrix with the location embedding matrix to form the final embedding matrix: ; Attention is calculated by using project relationships as the attention head to form long-term user preferences. The specific formula is as follows: ; ; ; ; ; ; in, For queries embedded in a matrix, For the keys of the embedded matrix, The value of the embedding matrix, As the key of the project relationship matrix, For each head dimension, Project relationship attention score, For layer normalization, For the discard operation, A is The value after discarding, residual joining, and layer normalization operations, F is the value of A after discarding, residual joining, and layer normalization operations. It is a feedforward neural network. When B > 1, the input matrix is the output of the previous layer. , , All values are from layer B. The last layer of the project relationship attention layer is represented as... ; S4. Merge users' long-term and short-term preferences, and use the final fused representation to obtain the corresponding recommendation results; Specifically, after obtaining users' long-term and short-term preferences, these preferences will be merged using the following formula: ; in, For fusion parameters, The final representation of long-term preferences formed by attention heads in project relationships. This is the final representation of short-term preferences formed by convolution. This is the final representation after the fusion of long-term and short-term preferences.
2. The method according to claim 1, characterized in that, Preprocess the datasets Amazon_office and Amazon_Beauty by removing all items and users with fewer than 5 interactions to obtain the desired user sequence.
3. The method according to claim 1, S4 further includes a final recommendation score representing the next item: ; in, For users The length is The most recent interaction sequence, This is the final representation after fusing long-term and short-term preferences. All candidate projects, A matrix formed for candidate projects, Scores for all candidate items; The prediction loss function used is the cross-entropy loss function: ; in, For the sigmoid function, Let be the true value at step t. For user-interactive projects, the total loss function of the sequence recommendation model is: The loss function for the sequence recommendation model is: ; in, The loss function for project prediction. Let be the loss function for project relationships. For all learnable parameters, This is a hyperparameter.
Citation Information
Patent Citations
Training method and device of sequence recommendation model
CN115564532A
Scoring sequence recommendation method based on lightweight graph convolution self-attention model
CN116662661A
Article recommendation method based on heterogeneous time sequence diagram attention network
CN117495481A
