A sequence recommendation method for e-commerce platforms based on sampling reconstruction contrastive learning
By adopting a sampling reconstruction comparison learning method in the sequence recommendation system of e-commerce platform, the sparseness and noise of user behavior data are handled, the accuracy and personalization of recommendations are improved, the problems of data sparseness and noise are solved, and better recommendation results are achieved.
Patent Information
- Application Number
- CN202510060711.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2045-01-15
AI Technical Summary
The existing e-commerce platform serial recommendation system faces data sparse and noise problems when processing user behavior data, resulting in a decrease in the accuracy and personalization of recommendation results.
The method of sampling reconstruction based on comparison learning is adopted to calculate the similarity between user sequences, identify and process false negative samples, improve the comparison learning effect, and improve the representation ability of the model through multi-head self-attention mechanism and data enhancement technology.
It improves the accuracy and personalization of product sequence recommendations in e-commerce platforms, effectively alleviates the problems of data sparseness and noise, and improves the robustness and generalization capabilities of the model.
Smart Images

Figure CN119477488B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of sequence recommendation systems, and in particular to an e-commerce platform sequence recommendation method based on sampling reconstruction contrast learning. Background Art
[0002] In today's era of information explosion, information overload is becoming increasingly serious. Recommendation systems have become an important tool for users to filter personalized content from massive amounts of information. Recommendation systems are information filtering systems that mine user preferences based on user historical behavior, social relationships, interests, and contextual information to determine the items or services that users currently need or are interested in.
[0003] In e-commerce platforms, user behaviors, such as clicks, purchases, and reviews, are naturally arranged in chronological order, forming a user behavior sequence. These time series information can record user behaviors at different time points, thereby revealing the evolution of user interests. By analyzing the user's behavior sequence, the sequential recommendation system can capture the changes in user interests and adjust the recommendation strategy accordingly to provide product recommendations that are more in line with the user's current interests.
[0004] However, the sequential recommendation system based on the analysis of user behavior data on e-commerce platforms faces problems such as data sparsity and noise. Since user behavior data is often limited and unevenly distributed, it is difficult for the recommendation system to extract sufficient contextual information from the sparse data, which affects the accuracy and personalization of product recommendations. In addition, user behavior data may contain misclicks or malicious reviews. These noisy data not only interfere with the learning process of the recommendation model, but also may lead the model to produce wrong recommendation results. Summary of the invention
[0005] In order to overcome the shortcomings of the prior art, the present invention proposes an e-commerce platform sequence recommendation method based on sampling reconstruction contrastive learning, which identifies and processes misjudged false negative samples by calculating the similarity between user sequences, in view of the problem that the existing contrastive learning method easily misjudges sequences with similar user interests as negative samples when generating negative samples.
[0006] The technical solution of the present invention is:
[0007] An e-commerce platform sequence recommendation method based on sampling reconstruction contrastive learning includes the following steps:
[0008] Step 1: Load the data set and preprocess the data set;
[0009] Step 2: Convert the original sequence Retain the core semantics and use three data augmentation methods to change certain features of the sequence, thereby providing the model with richer training signals;
[0010] Step 3: Create a product representation matrix for each product Each corresponds to a representation vector; introduce a learnable position representation matrix Represents the position information of the sequence; the user's input representation matrix It is composed of the sum of the product representation and position representation of all products in the user sequence;
[0011] Step 4: Use multi-head self-attention to extract information from different subspaces at the same location;
[0012] Step 5: Introduce false negative samples into contrastive learning to improve the effect of the sequence recommendation algorithm. When constructing the contrastive loss, not only the enhanced views from the same user sample are regarded as positive samples, but also the K most similar users are found for each user as their positive samples by calculating the similarity between users.
[0013] Step 6: For any user sequence as an anchor node , given its two augmented views and Characterization and , and the representation of its K positive samples , , using two loss functions and Optimize the backbone recommendation model and work independently;
[0014] Step 7: A multi-task strategy is adopted to jointly optimize the main sequence prediction task and the additional contrastive learning task to utilize the self-supervisory signal from the unlabeled raw data to improve the performance of sequence recommendation.
[0015] Furthermore, in step 1, all users in the system are defined The set of interaction sequences is ,in Indicates user The items that interact at time step t, Indicates the length of the user interaction sequence; Indicates user Subsequence of items that interacted before time step t+1;
[0016] By designing a sequence recommendation algorithm, predicting user At time step | |+1The most likely interactive item, the problem is formalized as,
[0017] ;
[0018] in, Indicates user At time step | |+1 and goods The conditional probability of interaction, is the prediction result, that is, the most likely At time step | |+1 Interactive product.
[0019] Furthermore, the process of step 2 is as follows:
[0020] Cropping: Randomly crop a part of the sequence to retain the core information, in order to simulate the scenario where some information is missing in user behavior;
[0021] Mask: Randomly mask some items in the sequence so that the model can learn to capture contextual information and enhance the robustness of the model;
[0022] Reorder: Partially reorder the items in the sequence, change the order of the items, and simulate the diversity of user interaction order;
[0023] In the present invention, each data augmentation method can randomly transform a user sequence into two related instances, and obtain two enhanced views of the sequence, which are represented as and .
[0024] Furthermore, in step 3, a product characterization matrix is established. , each product Each corresponds to a representation vector , where d is the vector dimension; introduce a learnable position representation matrix Represents the position information of the sequence; the user's input representation matrix It is composed of the sum of the product representation and position representation of all products in the user sequence.
[0025] ;
[0026] Where T is the length of the user behavior sequence, that is, the number of items that the user has interacted with historically. For users Items that interact at time step t The representation of is the position representation corresponding to time step t, t∈{1,2,…,T}.
[0027] In step 4, different linear projections are used to project the input representation onto the sub In the subspace, the self-attention mechanism is applied to each head, the outputs of each head are concatenated and fused through a linear layer, and the calculation is as follows:
[0028] ;
[0029] ;
[0030] in, , is the weight matrix, where It is The input of the layer, the attention mechanism is implemented through dot product,
[0031] ;
[0032] In sequence recommendation, when predicting the next item Only time steps can be used Therefore, the mask operation is applied to the attention mechanism if , then ignore and This masking ensures that each position Focus only on the position in the sequence and earlier positions, thereby preserving the autoregressive properties of the model;
[0033] Representation of each position of the multi-head self-attention layer output Next, it is fed into a position feedforward network, which performs a nonlinear transformation on the representation of each position to further refine the feature representation.
[0034] ;
[0035] ;
[0036] in, and is the weight matrix, and is the bias vector, this feed-forward network enhances the model’s ability to capture complex patterns and interactions within the sequence;
[0037] The model obtains more accurate representation by stacking multiple self-attention layers and feedforward networks. In order to stabilize and accelerate the training of the model, the model superimposes Dropout and layer normalization after each self-attention layer and feedforward network. The output of the Lth layer of the Transformer encoder is expressed as,
[0038] ;
[0039] ;
[0040] The output of the last layer of the Transformer encoder is used as the representation of the user at different time steps t; since the task of sequence recommendation is to predict each user In its historical interaction sequence After the product, the user The final representation of is set to the preference representation at time step T, i.e., the last row of the encoder output matrix,
[0041] ;
[0042] Among them, is the number of stacked Transformer layers;
[0043] Based on user preference representation , predict each product by calculating the vector inner product As a user The probability of the next item,
[0044] .
[0045] In step 5, for any two users and , and get their embedded representations through the user sequence encoder and After that, their similarity is calculated by the inner product of the representation vectors, that is,
[0046] ;
[0047] The similarity of all users constitutes a similarity matrix. According to the similarity between users, the K nearest neighbors of each user are selected to form the false negative sample set of the user. , as the positive sample of this user.
[0048] In step 6, the following two loss functions are used: and Optimize the backbone recommendation model and work independently; the corresponding equation is as follows:
[0049] ;
[0050] and
[0051] ;
[0052] Among them, the set of false negative samples The number of samples is predefined by K; although and These two loss functions look similar, but they play different roles in weighing the importance of different types of positive examples.
[0053] In step 7, the negative log-likelihood with binary cross entropy is used as the The main loss function at each time step t+1 is,
[0054] ;
[0055] in, , and Respectively represent users At time step t, the representation of user The representation of the interacted items at time step t and the representation of the randomly negatively sampled items at time step t+1; the total loss function is the linear weighted sum of the main loss function and the contrast loss function, as shown below,
[0056] ;
[0057] ;
[0058] in, It is a hyperparameter used to balance the importance of the two loss functions.
[0059] The technical concept of the present invention is that based on the potential correlation between users in the e-commerce platform, some user behavior sequences with high correlation may be mistakenly regarded as negative samples in contrastive learning. This will cause the model to be misled during the optimization process because it attempts to regard samples that are actually similar as different categories.
[0060] The beneficial effects of the present invention are: by identifying false negative samples and using them as positive samples to calculate the contrastive learning loss, the accuracy of product sequence recommendation in the e-commerce platform is improved. This method optimizes the positioning of all node representations in the representation space, and while obtaining uniformly distributed node representations, it makes the anchor nodes and false negative sample nodes as close as possible, and reduces the spatial distance between similar user representations of the contrastive learning model, thereby improving the model's representation ability and recommendation accuracy. The present invention has also been experimentally verified on multiple public e-commerce platform data sets, and the results show that the present invention can improve the accuracy of product sequence recommendation and has high application value. . BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 Flowchart of the e-commerce platform sequence recommendation method based on sampling reconstruction contrastive learning. DETAILED DESCRIPTION
[0062] The present invention will be further described below in conjunction with the accompanying drawings.
[0063] Reference Figure 1, an e-commerce platform sequence recommendation method based on sampling reconstruction contrastive learning, the method comprising the following steps:
[0064] Step 1: Load the data set and preprocess the data set. The process is as follows:
[0065] Define all users in the e-commerce platform system The interactive product sequence set is ,in Indicates user The items that interact at time step t, Indicates the length of the user interaction sequence; Indicates user Subsequence of items that interacted before time step t+1;
[0066] By designing a sequence recommendation algorithm, predicting users At time step | |+1The most likely interactive item, the problem is formalized as,
[0067] ;
[0068] in, Indicates user At time step | |+1 and goods The conditional probability of interaction, is the prediction result, that is, the most likely At time step | |+1 interactive products;
[0069] Step 2: Convert the original sequence Retain the core semantics and use three data augmentation methods to change certain features of the sequence to provide the model with richer training signals; the process is as follows:
[0070] Cropping: Randomly crop part of the sequence to retain the core information, in order to simulate the scenario where some information is missing in user behavior;
[0071] Mask: Randomly mask some items in the sequence so that the model can learn to capture contextual information and enhance the robustness of the model;
[0072] Reorder: Partially reorder the items in the sequence, change the order of the items, and simulate the diversity of user interaction order;
[0073] In the present invention, each data augmentation method can randomly transform a user sequence into two related instances, and obtain two enhanced views of the sequence, which are represented as and ;
[0074] Step 3: Establish a product representation matrix. , each product Each corresponds to a representation vector , where d is the vector dimension; introduce a learnable position representation matrix Represents the position information of the sequence; the user's input representation matrix It is composed of the sum of the product representation and position representation of all products in the user sequence.
[0075] ;
[0076] Where T is the length of the user behavior sequence, that is, the number of items that the user has interacted with historically. For users Items that interact at time step t The representation of is the position representation corresponding to time step t, t∈{1,2,…,T}.
[0077] Step 4: Use multi-head self-attention to extract information from different subspaces at the same position, and use different linear projections to project the input representation into the subspaces. In the subspace, the self-attention mechanism is applied to each head, the outputs of each head are concatenated and fused through a linear layer, and the calculation is as follows:
[0078] ;
[0079] ;
[0080] in, , is the weight matrix, where It is The input of the layer, the attention mechanism is implemented through dot product,
[0081] ;
[0082] In sequence recommendation, when predicting the next item Only time steps can be used Therefore, the mask operation is applied to the attention mechanism if , then ignore and This masking ensures that each position Focus only on the position in the sequence and earlier positions, thereby preserving the autoregressive properties of the model;
[0083] Representation of each position of the multi-head self-attention layer output Next, it is fed into a position feedforward network, which performs a nonlinear transformation on the representation of each position to further refine the feature representation.
[0084] ;
[0085] ;
[0086] in, and is the weight matrix, and is the bias vector, this feed-forward network enhances the model’s ability to capture complex patterns and interactions within the sequence;
[0087] The model obtains more accurate representation by stacking multiple self-attention layers and feedforward networks. In order to stabilize and accelerate the training of the model, the model superimposes Dropout and layer normalization after each self-attention layer and feedforward network. The output of the Lth layer of the Transformer encoder is expressed as,
[0088] ;
[0089] ;
[0090] The output of the last layer of the Transformer encoder is used as the representation of the user at different time steps t; since the task of sequence recommendation is to predict each user In its historical interaction sequence After the product, the user The final representation of is set to the preference representation at time step T, i.e., the last row of the encoder output matrix,
[0091] ;
[0092] Among them, is the number of stacked Transformer layers;
[0093] Based on user preference representation , predict each product by calculating the vector inner product As a user The probability of the next item,
[0094] ;
[0095] Step 5. In traditional contrastive learning, if two enhanced views come from the same sample, they are regarded as a positive pair, and if they come from different sample transformations, they are regarded as a negative pair; however, due to the potential correlation between users, the behavior sequences of some highly correlated users may be mistakenly regarded as negative samples; introduce false negative samples into contrastive learning to improve the effect of sequence recommendation algorithm; when constructing contrastive loss, not only the enhanced views from the same user sample are regarded as positive samples, but also by calculating the similarity between users, find the K other users who are most similar to each user as their positive samples;
[0096] For any two users and , and get their embedded representations through the user sequence encoder and After that, their similarity is calculated by the inner product of the representation vectors, that is,
[0097] ;
[0098] The similarity of all users constitutes a similarity matrix. According to the similarity between users, the K nearest neighbors of each user are selected to form the false negative sample set of the user. , as the positive sample of the user;
[0099] Step 6: For any user sequence as an anchor node , given its two augmented views and Characterization and , and the representation of its nearest neighbors , , using the following two loss functions and Optimize the backbone recommendation model and work independently; the corresponding equation is as follows:
[0100] ;
[0101] and
[0102] ;
[0103] Among them, the set of false negative samples The number of samples is predefined by K; although and These two loss functions look similar, but they play different roles in weighing the importance of different types of positive samples;
[0104] Step 7: A multi-task strategy is adopted to jointly optimize the main sequence prediction task and the additional contrastive learning task to improve the performance of sequence recommendation by utilizing the self-supervisory signal from the unlabeled raw data;
[0105] The negative log-likelihood with binary cross entropy is used as the probability distribution of each user. The main loss function at each time step t+1 is,
[0106] ;
[0107] in, , and Respectively represent users At time step t, the representation of user The representation of the interacted items at time step t and the representation of the randomly negatively sampled items at time step t+1; the total loss function is the linear weighted sum of the main loss function and the contrast loss function, as shown below,
[0108] ;
[0109] ;
[0110] in, It is a hyperparameter used to balance the importance of the two loss functions; The larger it is, the greater the role of contrast loss in the training stage.
[0111] The solution of this embodiment, in order to solve the misjudgment problem that may be caused by the selection of negative samples, proposes an e-commerce platform sequence recommendation method based on contrastive learning and reconstruction of data sampling structure, and proposes three data enhancement methods (cropping, masking, and reordering) to simulate data missing, uncertainty, and sequence changes in user behavior; in traditional contrastive learning, high similarity between sequences may lead to false negative sample misjudgment; this method calculates the similarity between users and dynamically introduces highly correlated user sequences as positive samples to improve the contrastive learning effect; adopts a multi-head self-attention mechanism, divides the input representation into multiple subspaces through linear projection, captures the features in the sequence from different perspectives, and adds a masking mechanism to ensure that only historical information is used in prediction; introduces two contrastive learning loss functions and , respectively optimize the similarity of different types of positive samples to improve model performance; combine the main sequence prediction task and contrastive learning task, and improve the robustness and generalization ability of the model through self-supervision signals.
[0112] Experiments on the public dataset of the Amazon e-commerce platform show that compared with the traditional baseline model, the recommendation performance is significantly improved, the data sparsity and noise problems can be effectively alleviated, and more accurate recommendation results can be provided in practical applications.
[0113] The contents described in the embodiments of this specification are merely an enumeration of the implementation forms of the inventive concept and are for illustrative purposes only. The protection scope of the present invention should not be considered to be limited to the specific forms described in this embodiment, and the protection scope of the present invention also extends to equivalent technical means that can be thought of by ordinary technicians in this field based on the inventive concept.
Claims
1. A sequence recommendation method for an e-commerce platform based on sampling reconstruction contrastive learning, characterized in that: The method comprises the following steps: Step 1: Load the data set and preprocess the data set; Step 2: Convert the original sequence Retain the core semantics and use three data augmentation methods to change certain features of the sequence, thereby providing the model with richer training signals; Step 3: Create a product representation matrix for each product Each corresponds to a representation vector; introduce a learnable position representation matrix Represents the position information of the sequence; the user's input representation matrix It is composed of the sum of the product representation and position representation of all products in the user sequence; Step 4: Use multi-head self-attention to extract information from different subspaces at the same location; Step 5: Introduce false negative samples into contrastive learning to improve the effect of the sequence recommendation algorithm. When constructing the contrastive loss, not only the enhanced views from the same user sample are regarded as positive samples, but also the K most similar users are found for each user as their positive samples by calculating the similarity between users. Step 6: For any user sequence as an anchor node , given its two augmented views and Characterization and , and the representation of its K positive samples , , using two loss functions and Optimize the backbone recommendation model and work independently; Step 7: A multi-task strategy is adopted to jointly optimize the main sequence prediction task and the additional contrastive learning task to improve the performance of sequence recommendation by utilizing the self-supervisory signal from the unlabeled raw data; In step 1, all users in the e-commerce platform system are defined The set of interaction sequences is ,in Indicates user The items that interact at time step t, Indicates the length of the user interaction sequence; Indicates user Subsequence of items that interacted before time step t+1; By designing a sequence recommendation algorithm, predicting user At time step | |+1The most likely interactive item, the problem is formalized as, ; in, Indicates user At time step | |+1 and goods The conditional probability of interaction, is the prediction result, that is, the most likely At time step | |+1 Interactive product.
2. The e-commerce platform sequence recommendation method based on sampling reconstruction contrastive learning as claimed in claim 1, characterized in that: The process of step 2 is as follows: Cropping: Randomly crop a part of the sequence to retain the core information, in order to simulate the scenario where some information is missing in user behavior; Mask: Randomly mask some items in the sequence so that the model can learn to capture contextual information and enhance the robustness of the model; Reorder: Partially reorder the items in the sequence, change the order of items, and simulate the diversity of user interaction orders.
3. The e-commerce platform sequence recommendation method based on sampling reconstruction contrastive learning as claimed in claim 1, characterized in that: In step 3, a commodity characterization matrix is established. , each product Each corresponds to a representation vector , where d is the vector dimension; introduce a learnable position representation matrix Represents the position information of the sequence; the user's input representation matrix It is composed of the sum of the product representation and position representation of all products in the user sequence. ; Where T is the length of the user behavior sequence, that is, the number of items that the user has interacted with historically. For users Items that interact at time step t The representation of is the position representation corresponding to time step t, t∈{1,2,…,T}.
4. The e-commerce platform sequence recommendation method based on sampling reconstruction contrastive learning as claimed in claim 1, characterized in that: In step 4, different linear projections are used to project the input representation onto the sub In the subspace, the self-attention mechanism is applied to each head, the outputs of each head are concatenated and fused through a linear layer, and the calculation is as follows: ; ; in, , is the weight matrix, where It is The input of the layer, the attention mechanism is implemented through dot product, ; In sequence recommendation, when predicting the next item Only time steps can be used Therefore, the mask operation is applied to the attention mechanism if , then ignore and This masking ensures that each position Focus only on the position in the sequence and earlier positions, thereby preserving the autoregressive properties of the model; Representation of each position of the multi-head self-attention layer output Next, it is sent to a position feedforward network, which performs a nonlinear transformation on the representation of each position and refines the feature representation. ; ; in, and is the weight matrix, and is the bias vector, this feed-forward network enhances the model’s ability to capture complex patterns and interactions within the sequence; The model obtains more accurate representation by stacking multiple self-attention layers and feedforward networks. In order to stabilize and accelerate the training of the model, the model superimposes Dropout and layer normalization after each self-attention layer and feedforward network. The output of the Lth layer of the Transformer encoder is expressed as, ; ; The output of the last layer of the Transformer encoder is used as the representation of the user at different time steps t; since the task of sequence recommendation is to predict each user In its historical interaction sequence After the product, the user The final representation of is set to the preference representation at time step T, i.e., the last row of the encoder output matrix, ; Among them, is the number of stacked Transformer layers; Based on user preference representation , predict each product by calculating the vector inner product As a user The probability of the next item, 。 5. The e-commerce platform sequence recommendation method based on sampling reconstruction contrast learning as claimed in claim 1, characterized in that: In step 5, for any two users and , and get their embedded representations through the user sequence encoder and After that, their similarity is calculated by the inner product of the representation vectors, that is, ; The similarity of all users constitutes a similarity matrix. According to the similarity between users, the K nearest neighbors of each user are selected to form the false negative sample set of the user. , as the positive sample of this user.
6. The e-commerce platform sequence recommendation method based on sampling reconstruction contrastive learning as claimed in claim 1, characterized in that: In step 6, the following two loss functions are used: and Optimize the backbone recommendation model and work independently; the corresponding equation is as follows: ; and ; Among them, the set of false negative samples The number of samples is predefined by K; although and These two loss functions look similar, but they play different roles in weighing the importance of different types of positive examples.
7. The e-commerce platform sequence recommendation method based on sampling reconstruction contrastive learning as claimed in claim 1, characterized in that: In step 7, the negative log-likelihood with binary cross entropy is used as the The main loss function at each time step t+1 is, ; in, , and Respectively represent users At time step t, the representation of user The representation of the interacted items at time step t and the representation of the randomly negatively sampled items at time step t+1; the total loss function is the linear weighted sum of the main loss function and the contrast loss function, as shown below, ; ; in, It is a hyperparameter used to balance the importance of the two loss functions.
Citation Information
Patent Citations
Method for enhancing recommendation algorithm framework based on multi-level comparative learning of knowledge graph
CN118503445A
Personalized commodity recommendation method based on reliable virtual hard negative sampling under e-commerce platform
CN119107142A