Self-supervised sequence recommendation method based on random self-attention and momentum contrast learning
By introducing random self-attention and momentum comparison learning in the sequence recommendation method, the problems of sparse data and overfitting in sequence recommendation are solved, and higher recommendation accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202411131063.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-10
AI Technical Summary
Existing sequence recommendation methods rely on a large amount of labeled data to be difficult to obtain, and when processing long sequences, it is easy to fall into data sparseness and overfitting problems, resulting in unsatisfactory recommendations, especially under unsupervised or self-supervised conditions, which is difficult to effectively recommend sequences.
Using a self-supervised sequence recommendation method based on random self-attention and momentum comparison learning, the user sequence is embedded into an elliptical Gaussian distribution through a random embedding layer, and the dot product operation in the attention mechanism is replaced by a self-attention encoder of Wasserstein distance, and Expand negative sample selection range and weighted sampling technology through momentum comparison learning mechanism to reduce the impact of false negative samples.
It effectively alleviates the dynamic uncertainty and sampling offset problems of sequence data, significantly improves the accuracy and robustness of the recommendation system, and is better than the baseline method on multiple evaluation indicators.
Smart Images

Figure CN119106290A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning. Background Art
[0002] Existing sequence recommendation methods rely on a large amount of labeled data, which is often difficult to obtain in practical applications. At the same time, existing methods are prone to data sparsity and overfitting problems when processing long sequences, resulting in unsatisfactory recommendation results. How to effectively perform sequence recommendation under unsupervised or self-supervised conditions has become a hot topic in current research. Summary of the invention
[0003] The present invention proposes a self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning, which effectively improves the performance of sequence recommendation by introducing a random embedding layer, a self-attention encoder based on Wasserstein distance and a momentum contrastive learning mechanism.
[0004] The technical solution of the present invention: a self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning, comprising the following steps:
[0005] Step 1: Through the random embedding layer, the user sequence is embedded into the homogeneity and covariance of the elliptical Gaussian distribution, and the elliptical Gaussian distribution is regarded as the embedding of the user sequence;
[0006] Step 2: Use a random self-attention encoder based on Wasserstein distance to replace the dot product operation in the attention mechanism to measure the distance between the two distributions and improve the stability of training;
[0007] Step 3: Adopt an encoder based on momentum contrastive learning and introduce a memory queue to expand the selection range of negative samples from within the batch to the entire dataset, thereby expanding the number of available negative samples.
[0008] Step 4: For the false negative sample sequences that may exist in the memory queue, weighted sampling technology is used to reduce the weight of the false negative samples in the memory queue, reduce the impact of false negative samples in contrastive learning, and alleviate the sampling offset problem.
[0009] Furthermore, the specific steps of Step 1 are:
[0010] Step 1.1, through the random embedding layer, the original user sequence data is mapped to a high-dimensional space to form an elliptical Gaussian distribution representation, and the elliptical Gaussian distribution is regarded as the embedding of the user sequence;
[0011]
[0012] Step 1.2. Calculate the mean and covariance of the elliptical Gaussian distribution and use it as the embedding representation of the user sequence for subsequent sequence recommendation model training.
[0013] Furthermore, the specific steps of Step 2 are:
[0014] Step 2.1, input the user sequence embedding representation into the random self-attention encoder based on Wasserstein distance;
[0015] Step 2.2, by replacing the dot product operation in the attention mechanism with the Wasserstein distance, calculate the distance between the embedding representations of different user sequences;
[0016]
[0017] Step 2.3: Use the calculated Wasserstein distance to update the attention weights to better capture the relationship between user sequences and improve the stability of model training.
[0018] Furthermore, the specific steps of Step 3 are:
[0019] Step 3.1, use momentum contrastive learning method to train the encoder and initialize positive and negative samples for the user sequences in the current batch;
[0020] Step 3.2, introduce a dynamically updated memory queue to save the encoding representation in the previous batch;
[0021] Step 3.3, select negative samples from the memory queue, expand the selection range of negative samples to the entire data set, and increase the number of negative samples;
[0022] Step 3.4: Use these negative samples to train the sequence recommendation model to improve the effect of contrastive learning.
[0023] Furthermore, the specific steps of Step 4 are:
[0024] Step 4.1. Regularly detect and identify false negative samples in the memory queue; the core of momentum contrastive learning is to keep a queue of data samples so that the model can reuse the keys encoded in the previous mini-batches. Once the queue is established, its size no longer depends on the size of the mini-batch. The size of the queue is a hyperparameter that can be adjusted independently and dynamically, which means that the capacity of the queue can far exceed the normal mini-batch size. During the training of the sequence recommendation model, the samples in the queue are replaced by randomly selected sequence enhancements; mini-batches are added to the queue in sequence, and the latest mini-batch will replace the oldest mini-batch;
[0025] Step 4.2: For the identified false negative samples, adjust their weights in the sequence recommendation model training; use a momentum update mechanism to update the gradient; set θ k is the parameter of f, θ q f m The parameter θ k The update method is as follows:
[0026] θ k ←mθ k +(1-m)θ q ,
[0027] Where m∈[0,1] is the momentum coefficient. In practice, m takes a value close to 1 (such as 0.99) to ensure that f m can be updated slowly; f is the query encoder f, i.e., a random self-attention encoder based on Wasserstein distance, f m is a key encoder, i.e., an encoder based on contrastive learning with momentum;
[0028] Step 4.3: Use weighted sampling technology to make the sequence recommendation model pay more attention to real negative samples during training, reduce the interference of false negative samples on training results, and use a negative sample weighting method to punish false negatives. Consider a positive sample h q and a set of negative samples The weights are generated as:
[0029]
[0030] where φ is a negative sample weighted threshold hyperparameter, As a similarity score, the negative sample with the highest similarity to the positive sample will be regarded as a false negative sample and will be penalized with a weight of 0. This processing method can alleviate the sampling offset problem and improve the accuracy and effect of contrastive learning;
[0031] The beneficial effects of the present invention are as follows: the present invention effectively alleviates the dynamic uncertainty and sampling offset problems of sequence data, and greatly improves the accuracy and robustness of the recommendation system by expanding the negative sample selection range and reducing the weight of false negative samples; BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is the overall framework of the self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning proposed in this paper DETAILED DESCRIPTION
[0033] Embodiment 1, as Figure 1As shown, a self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning comprises the following steps:
[0034] Step 1: Through the random embedding layer, the user sequence is embedded into the homogeneity and covariance of the elliptical Gaussian distribution, and the elliptical Gaussian distribution is regarded as the embedding of the user sequence;
[0035] The specific steps of Step 1 are:
[0036] Step 1.1, through the random embedding layer, the original user sequence data is mapped to a high-dimensional space to form an elliptical Gaussian distribution representation, and the elliptical Gaussian distribution is regarded as the embedding of the user sequence;
[0037]
[0038] Step 1.2. Calculate the mean and covariance of the elliptical Gaussian distribution and use it as the embedding representation of the user sequence for subsequent sequence recommendation model training.
[0039] Step 2: Use a random self-attention encoder based on Wasserstein distance to replace the dot product operation in the attention mechanism to measure the distance between the two distributions and improve the stability of training;
[0040] The specific steps of Step 2 are:
[0041] Step 2.1, input the user sequence embedding representation into the random self-attention encoder based on Wasserstein distance;
[0042] Step 2.2, by replacing the dot product operation in the attention mechanism with the Wasserstein distance, calculate the distance between the embedding representations of different user sequences;
[0043]
[0044] Step 2.3: Use the calculated Wasserstein distance to update the attention weights to better capture the relationship between user sequences and improve the stability of model training.
[0045] Step 3: Adopt an encoder based on momentum contrastive learning and introduce a memory queue to expand the selection range of negative samples from within the batch to the entire dataset, thereby expanding the number of available negative samples.
[0046] The specific steps of Step 3 are:
[0047] Step 3.1, use momentum contrastive learning method to train the encoder and initialize positive and negative samples for the user sequences in the current batch;
[0048] Step 3.2, introduce a dynamically updated memory queue to save the encoding representation in the previous batch;
[0049] Step 3.3, select negative samples from the memory queue, expand the selection range of negative samples to the entire data set, and increase the number of negative samples;
[0050] Step 3.4: Use these negative samples to train the sequence recommendation model to improve the effect of contrastive learning.
[0051] Step 4: For the false negative sample sequences that may exist in the memory queue, weighted sampling technology is used to reduce the weight of the false negative samples in the memory queue, reduce the impact of false negative samples in contrastive learning, and alleviate the sampling offset problem.
[0052] The specific steps of Step 4 are:
[0053] Step 4.1. Regularly detect and identify false negative samples in the memory queue; the core of momentum contrastive learning is to keep a queue of data samples so that the model can reuse the keys encoded in the previous mini-batches. Once the queue is established, its size no longer depends on the size of the mini-batch. The size of the queue is a hyperparameter that can be adjusted independently and dynamically, which means that the capacity of the queue can far exceed the normal mini-batch size. During the training of the sequence recommendation model, the samples in the queue are replaced by randomly selected sequence enhancements; mini-batches are added to the queue in sequence, and the latest mini-batch will replace the oldest mini-batch;
[0054] Step 4.2: For the identified false negative samples, adjust their weights in the sequence recommendation model training; use a momentum update mechanism to update the gradient; set θ k is the parameter of f, θ q f m The parameter θ k The update method is as follows:
[0055] θ k ←mθ k +(1-m)θ q ,
[0056] Where m∈[0,1] is the momentum coefficient. In practice, m takes a value close to 1 (such as 0.99) to ensure that f m can be updated slowly; f is the query encoder f, i.e., a random self-attention encoder based on Wasserstein distance, f mis a key encoder, i.e., an encoder based on contrastive learning with momentum;
[0057] Step 4.3: Use weighted sampling technology to make the sequence recommendation model pay more attention to real negative samples during training, reduce the interference of false negative samples on training results, and use a negative sample weighting method to punish false negatives. Consider a positive sample h q and a set of negative samples The weights are generated as:
[0058]
[0059] where φ is a negative sample weighted threshold hyperparameter, As a similarity score, the negative sample with the highest similarity to the positive sample will be regarded as a false negative sample and will be penalized with a weight of 0. This processing method can alleviate the sampling offset problem and improve the accuracy and effect of contrastive learning;
[0060] To illustrate the effect of the present invention, the proposed self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning is compared with seven baseline methods. The experiment is conducted on three Amazon review datasets: Beauty, Office, and Toy. The main evaluation indicators include HR@1, HR@5, HR@10, NDCG@5, NDCG@10, and MRR.
[0061] Table 1 Performance comparison of different methods
[0062]
[0063]
[0064] As shown in the table, we can conclude that our method outperforms all baseline methods in all indicators. In terms of HR@1, HR@5, HR@10, NDCG@5, NDCG@10 and MRR indicators, our method improves by 12.08%, 5.02%, 4.38%, 10.61%, 12.27% and 10.07% respectively. We have the following view: The method based on random self-attention and momentum contrastive learning effectively alleviates the dynamic uncertainty and sampling offset problems of sequence data, and greatly improves the accuracy and robustness of the recommendation system by expanding the range of negative sample selection and reducing the weight of false negative samples.
[0065] The specific implementation modes of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above implementation modes, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.
Claims
1. A self-supervised sequence recommendation method based on stochastic self-attention and momentum contrastive learning, It is characterized in that The following steps are involved: Step 1: Through the random embedding layer, the user sequence is embedded into the homogeneity and covariance of the elliptical Gaussian distribution, and the elliptical Gaussian distribution is regarded as the embedding of the user sequence; Step 2: Use a random self-attention encoder based on Wasserstein distance to measure the distance between the two distributions by replacing the dot product operation in the attention mechanism with Wasserstein distance. Step 3: Adopt an encoder based on momentum contrastive learning and introduce a memory queue to expand the selection range of negative samples from within the batch to the entire dataset. Step 4: For the false negative sample sequences that may exist in the memory queue, use weighted sampling technology to reduce the weight of the false negative samples in the memory queue.
2. The self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning according to claim 1, Features: The specific steps of Step 1 are: Step 1.1, through the random embedding layer, the original user sequence data is mapped to a high-dimensional space to form an elliptical Gaussian distribution representation, and the elliptical Gaussian distribution is regarded as the embedding of the user sequence; Step 1.
2. Calculate the mean and covariance of the elliptical Gaussian distribution and use it as the embedding representation of the user sequence for subsequent sequence recommendation model training.
3. The self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning according to claim 1, Features: The specific steps of Step 2 are: Step 2.1, input the user sequence embedding representation into the random self-attention encoder based on Wasserstein distance; Step 2.2, by replacing the dot product operation in the attention mechanism with the Wasserstein distance, calculate the distance between the embedding representations of different user sequences; Step 2.3: Use the calculated Wasserstein distance to update the attention weight.
4. The self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning according to claim 1, Features: The specific steps of Step 3 are: Step 3.1, use momentum contrastive learning method to train the encoder and initialize positive and negative samples for the user sequences in the current batch; Step 3.2, introduce a dynamically updated memory queue to save the encoding representation in the previous batch; Step 3.3, select negative samples from the memory queue, expand the selection range of negative samples to the entire data set, and increase the number of negative samples; Step 3.4: Use these negative samples to train the sequence recommendation model.
5. The self-supervised sequence recommendation method based on random self-attention and momentum contrastive learning according to claim 1, Features: The specific steps of Step 4 are: Step 4.
1. Regularly detect and identify false negative samples in the memory queue. During the training of the sequence recommendation model, the samples in the queue are replaced by randomly selected sequence enhancements. Small batches are added to the queue in sequence, and the latest small batch will replace the oldest small batch. Step 4.2: For the identified false negative samples, adjust their weights in the sequence recommendation model training; use a momentum update mechanism to update the gradient; set θ k is the parameter of f, θ q f m The parameter θ k The update method is as follows: i k ←mθ k +(1-m)θ q , Where m∈[0,1] is the momentum coefficient. In practice, m takes a value close to 1 (such as 0.99) to ensure that f m Ability to update slowly; f is the query encoder f, i.e., a random self-attention encoder based on Wasserstein distance, f m is a key encoder, i.e., an encoder based on contrastive learning with momentum; Step 4.3: Use weighted sampling technology to make the sequence recommendation model pay more attention to real negative samples during training, reduce the interference of false negative samples on training results, and use a negative sample weighting method to punish false negatives. Consider a positive sample h q and a set of negative samples The weights are generated as: where φ is a negative sample weighted threshold hyperparameter, is considered as a similarity score, so the negative sample with the highest similarity to the positive sample will be considered a false negative sample and will be penalized with a weight of 0.
Citation Information
Cited By
Power load cold start prediction method and system based on pre-training-fine tuning
CN119740697A
