Sequence recommendation method based on diffusion model and contrast learning

By combining the diffusion model and contrastive learning method, combined with the attention neural process and the temporal convolutional network, the user's long-term interest and short-term interest are distinguished, which solves the problem of difficulty in combining long-term interest and short-term interest in the existing technology, and achieves more accurate User behavior prediction and personalized recommendations.

CN118626718APending Publication Date: 2024-09-10COLLEGE OF SCI & TECH NINGBO UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410794224.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-09-10

Smart Images

  • Figure CN118626718A
    Figure CN118626718A
Patent Text Reader

Abstract

The invention discloses a sequence recommendation method based on a diffusion model and contrast learning. And for the historical interaction sequence of the user, learning the long-term interest of the user by using the attention nerve process and learning the short-term interest of the user by using the time domain convolutional network. And then using a diffusion model to recover a target item based on the long-term and short-term interests of the user, namely a next item which may be interacted by the user. The model is trained by using a comparative learning method, so that the similarity between long-term interest codes and pseudo labels is higher than that between short-term interest codes and pseudo labels, and the long-term interest and the short-term interest of the user are distinguished. And finally, performing project prediction by utilizing the trained model, and generating a recommended project list of the specified user. According to the method, the overall interest preference of the user is considered, the dynamic interest preference of the user is combined, hole convolution is introduced for discontinuous behaviors in user interaction, and therefore more accurate prediction and recommendation are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data analysis, relates to a recommendation system and machine learning, and specifically relates to a sequence recommendation method based on diffusion model and contrastive learning. Background Art

[0002] With the rapid development of the digital age, the amount of information on the Internet has increased dramatically, and the difficulty of finding specific information has also increased. The problem of information overload has become increasingly prominent. In this context, how to effectively filter out information that is truly valuable to users from the huge sea of ​​data has become particularly critical.

[0003] Recommendation systems came into being, which analyze user preferences and accurately select content that users may be interested in from a large amount of data. Sequential recommendation is a common method used in recommendation systems, which aims to predict users' future behaviors or preferences by analyzing their behavior sequences. Unlike traditional recommendation systems, sequential recommendation systems pay special attention to the temporal dynamics and sequentiality of user behaviors, and provide personalized recommendations by capturing the temporal relationship between behaviors. Previous recommendation systems often only focused on users' overall interests and preferences. For example, the more classic collaborative filtering algorithm made recommendations based on the similarity between users or between items. Classic work in this area includes the matrix decomposition algorithm proposed in the 2006 Netflix-Reward competition, and the subsequent NGCF algorithm combined with neural networks.

[0004] With the development of technology, the changes in user interests have attracted more and more attention. Sequential recommendation methods using Markov chain modeling have gradually become a hot research direction. This method is based on the Markov chain model and assumes that the next item a user interacts with is only related to the last few items that they interacted with. However, in reality, the next item a user interacts with is driven by both long-term and short-term interests. For example, if a user has long liked war movies and has recently started to like romance movies, it is reasonable to infer that the user will watch a movie that contains both romance and war elements under the combined influence of long-term and short-term interests. However, the existing technology has not yet proposed an effective solution for this situation. Summary of the invention

[0005] In view of the shortcomings of the prior art, the present invention proposes a sequence recommendation method based on diffusion model and contrastive learning, combines the long-term and short-term interests of users, introduces deep learning methods, and realizes sequence recommendation with high accuracy.

[0006] A sequence recommendation method based on diffusion model and contrastive learning includes the following steps:

[0007] Step 1: Collect the historical interaction data of each user, map the project ID to a vector, and finally store the project vectors that all users have interacted with in the matrix R.

[0008] Step 2: Extract the item vectors that have interacted with the current user u from the matrix R, and add corresponding position information to the item vectors according to the time sequence of the interaction.

[0009] Step 3: Interaction sequence S for user u u ={x1,x2,x3,…,x n}, using the attention neural process to learn the user's long-term interests and obtain a Gaussian distribution User long-term interest representation U l , μ g , denote the mean and variance of the decoder output in the attention neural process, respectively.

[0010] Step 4: Consider the last L items in the interaction sequence as short-term interests, use the time-domain convolutional network to extract the user's short-term interests at different scales, then concatenate the short-term interests at different scales into vectors, and fuse them through the multi-head attention mechanism to obtain the user's final short-term interest representation U s .

[0011] Step 5: Combine the long-term interests and short-term interests learned in the previous step and use the diffusion model to restore the target item.

[0012] Step 6: Set the contrastive learning loss function Let the similarity between the long-term interest encoding and pseudo-label be higher than that between the short-term interest encoding and pseudo-label to distinguish the user's long-term interests from short-term interests:

[0013]

[0014] Among them, L bpr U represents the BPR loss function. l 、p l Represent the user’s long-term interests and pseudo labels of the user’s long-term interests, U s 、p s They represent the user’s short-term interests and short-term interest pseudo-labels respectively. The pseudo-label of long-term interests is the mean of all vectors that the user has interacted with, and the pseudo-label of short-term interests is the mean of the vectors of the L items that the user has recently interacted with.

[0015] Step 7: Introduce the cross entropy loss function to the approximator f θ To train:

[0016]

[0017] ej represents the embedding vector of the jth item, It represents the probability of this item being clicked at the next moment, and m represents the number of items.

[0018] The total loss function of the approximator is

[0019]

[0020] in, Represents a collection of users, Represents the number of users in the set. Use the gradient descent method to adjust the hyperparameters and optimize Use the trained model to predict the user's next interactive item based on the user's long-term and short-term interests, and generate a list of recommended items.

[0021] The present invention has the following beneficial effects:

[0022] This method not only takes into account the user's overall interest preferences, but also combines the user's dynamic interest preferences. It also introduces hole convolution for some discontinuous behaviors in user interactions, and uses the attention neural process to obtain more precise feature vectors, thereby providing more accurate predictions. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 This is a flow chart of the sequence recommendation method based on diffusion model and contrastive learning;

[0024] Figure 2 Schematic diagram of the time domain convolutional network structure. DETAILED DESCRIPTION

[0025] The present invention will be further explained below with reference to the accompanying drawings;

[0026] like Figure 1 As shown, a sequence recommendation method based on diffusion model and contrastive learning includes the following steps:

[0027] Step 1: Collect the historical interaction data of each user, use the Embeding layer to map the project ID to a vector of dimension l, and finally store the vectors corresponding to all projects in the matrix R m×l , where m represents the number of items.

[0028] Step 2: From the matrix R m×n Extract the item vectors that have interacted with the current user, and add the corresponding position information to the item vectors according to the time sequence of the interaction.

[0029] Step 3: Use attention neural processes to learn users’ long-term interests and convert complex and rich users’ long-term interests into a distribution representation. Attention neural processes (ANP) are a kind of neural network architecture. By combining attention mechanism and neural processes, they focus on key features in the data and can more flexibly learn and predict the potential distribution of complex data. This improves the accuracy of prediction and the generalization ability of the model, and is particularly suitable for processing sequence data and performing conditional prediction tasks.

[0030] Taking the extraction of user’s long-term interests as an example, we use S u ={x1,x2,x3,…,x n} to represent the interaction sequence of user u, where n represents the length of the user interaction sequence, that is, the number of items that user u has interacted with. The attention neural process is as follows:

[0031] s3.1, Data representation: Randomly select a value Num from (n / 2)~n, and divide the input sequence Su into a context point set C=(x c ,y c ) and the target point set G = {(x g ,y g )}. Where c = 1, 2, ... Num, g = Num + 1, Num + 2, ... n. The context point set C provides information for model training, while the target point set G is the point that the model needs to predict. c =Mean(x1,x2,x3,…,x c ), y g =Mean(x1,x2,x3,……,x g ).

[0032] s3.2, Encoder: For each context point, use encoder H to generate a representation r c =H(x c ,y c ). In this embodiment, the encoder H is an LSTM network. In ANPs, the encoder uses an attention mechanism to determine the weight of each context point's importance to the predicted target point, so that the model can pay more attention to the points that have a greater impact on the prediction results:

[0033]

[0034] Wherein, k is a compatibility function, and in this embodiment, a dot product function is used. t is the target point x t exp represents the exponential function with natural logarithm as the base.

[0035] s3.3, Aggregate context information: Use the attention mechanism to aggregate the context point representations to form a global representation. This captures the key information needed for target point prediction:

[0036]

[0037] s3.4, decoder: Use the decoder to predict the output of each target point based on the aggregated global representation:

[0038]

[0039] Where D represents the neural network of the decoder, and in this embodiment, a linear network is selected. The output of the decoder includes the mean μ g and variance The model can not only make predictions but also estimate the uncertainty of predictions. The user’s long-term interest representation U l Obey Gaussian distribution

[0040] Step 4: Treat the last L items in the interaction sequence as short-term interests and use Figure 2 The time domain convolutional network shown in the figure extracts the user's short-term interests at different scales, then concatenates the short-term interests at different scales into vectors, and fuses them through a multi-head attention mechanism to obtain the final short-term interest representation of the user. It includes the following steps:

[0041] s4.1. Create multiple convolution kernels for the L items x that the user has recently interacted with. n-L+1:n For short-term interest extraction, the expansion coefficient of each convolution kernel is different:

[0042] s (d) =f cnn (x n-L+1:n ,dilate=d)

[0043] Among them, s (d) The expansion coefficient of the convolution kernel is d, which is the extracted feature vector, d = 1, 2, 3... Using convolution kernels with different expansion coefficients to obtain the representation of users' short-term interests at different scales can overcome the impact of discontinuous user behavior. For example, for the user's recent interaction sequence {ipone15->NikeZoom->Xiaomi13->SamsungS23->google pixel}, the convolution kernel with a dilation coefficient of 0 will extract the features of all items. The convolution kernel with a dilation coefficient of 1 will extract every other item, and will extract the features of {ipone15->Xiaomi 13->google pixel}, thereby ignoring the item Nike Zoom that does not belong to the user's short-term interest.

[0044] s4.2. Features s at different scales (d) To splice:

[0045] F s =||s (d)

[0046] || represents a vector concatenation operation.

[0047] s4.3, the concatenated vector F s Input into a multi-head attention mechanism to obtain the final user short-term interest representation U s :

[0048]

[0049] Among them, N h represents the number of outputs in the multi-head attention mechanism, r h Represents the output features of the h-th attention mechanism.

[0050] Step 5. The diffusion model is to restore the original image from a path sequence formed by a bunch of noisy images. It has many similarities with sequence recommendation, for example, they both need to process sequence data and capture dynamic changes in the sequence. Using the characteristics of the diffusion model and combining long-term interest coding and short-term interest coding, the prediction process of sequence recommendation is simulated: the target item, that is, the user's interactive item at the next time point, is taken as the item that needs to be restored, and noise is continuously added to it until it becomes a piece of pure Gaussian noise. Then, from this piece of pure noise, combined with the previously learned long-term interest and short-term interest, the target item is continuously restored, including the diffusion stage and the reverse stage:

[0051] s5.1, Diffusion stage:

[0052] Use Markov chain to model, that is, the current state is only related to the state at the previous time point:

[0053]

[0054] in is a value with a mean of (1-β t ), the variance is β t Gaussian distribution, β t is a pre-set hyperparameter, I represents the identity matrix. The initial value X0 is the vector representation of the target item. t Represents the result after t times of diffusion, t represents the time step, and the maximum diffusion step is set to 32, then t=1,2,…32.

[0055] s5.2, Reverse stage:

[0056] In the inverse phase, the initial value X0 is unknown and an approximator f is used θ According to the long-term interest representation and short-term interest representation U l , U s Make predictions:

[0057]

[0058] α t =1-β t

[0059]

[0060] Here, ∈′ is a standard Gaussian distribution with mean 0 and variance 1.

[0061] s5.3, Repeat the diffusion and reverse process to update the approximator f θ , until the inverse process derives the estimated value of X0 and the output of the approximator The error is less than the set threshold.

[0062] Step 6: Use contrastive learning to better distinguish users’ long-term interests from short-term interests.

[0063] First, a minimum sequence length is set as the threshold for contrastive learning. Only sequences with a length greater than this threshold need to be contrastively learned to untie and distinguish long-term interests from short-term interests. The following contrastive learning loss function is used. The goal is to make the similarity between the encoding and pseudo-label of long-term interests higher than that of short-term interests, and vice versa for short-term interests:

[0064]

[0065] Among them, L bpr represents the Bayesian Personalized Ranking (BPR) loss function. l 、p l Represent the user’s long-term interests and pseudo labels of the user’s long-term interests, U s 、p s They represent the user's short-term interests and short-term interest pseudo labels respectively. The pseudo label of long-term interests is the mean of all vectors that the user has interacted with, and the pseudo label of short-term interests is the mean of the vectors of the L items that the user has recently interacted with:

[0066]

[0067] The purpose of the contrastive learning loss function can be expressed using the following formula:

[0068] sim(U l ,pl )>sim(U l ,p s )

[0069] sim(p l ,U l )>sim(p l ,U s )

[0070] sim(U s ,p s )>sim(U s ,p l )

[0071] sim(p s ,U s )>sim(p s ,U l )

[0072] Where sim represents the similarity between two vectors. The brackets represent the dot product and inner product operations of two vectors.

[0073] Step 7: Introduce the cross entropy loss function to the approximator f θ To train:

[0074]

[0075] e j represents the embedding vector of the jth item, Indicates the probability of this item being clicked at the next moment.

[0076] The total loss function of the approximator is

[0077]

[0078] in, Represents a collection of users, Represents the number of users in the set. Using the gradient descent method, adjust the hyperparameters and optimize The value of is used to continuously improve the performance of the recommendation algorithm.

[0079] Step 8: Predict the user’s next interaction item using the trained model

[0080] We use two real-world datasets, Movie-Lens and Amazon-beauty, to verify the recommendation performance. Movie-Lens is a movie sharing website that provides a large amount of movie rating data. Amazon Beauty is a review dataset of beauty and personal care products on Amazon, which provides a large amount of user reviews and ratings of beauty products. The statistical information of the datasets is shown in Table 2, which shows that these datasets are sparse in nature.

[0081] Table 2 Statistics of the dataset

[0082] Dataset Moive-Lens Amazon-beauty user 2,013 22,363 project 3,706 12,101 Average interaction length 8.87 169.90

[0083] Use leave-one-out as the training method, that is, use the last item of the interaction as the validation set, and then use the second to last item as the validation set. And use hit rate HR (HIT RATE), MRR score (Mean Reciprocal Rank) and NDCG (Normalized Discounted Cumulative Gain) as the evaluation criteria. Similar to most recommendation systems, the candidate items are sorted by score and the top N items are recommended. For user u, define HR@N, MRR@N and NDCG@N as:

[0084]

[0085] Among them, R N (u) represents a list of N items recommended to user u, I u represents the set of items that user u is really interested in, p i Indicates the position of the items that the user is actually interested in in the recommendation list.

[0086] The experiment selected five existing recommendation methods for comparison with this method, including LightGCN, SASRec, FPMC, GRU4REC and NextItNet. For the Moive-Lens and Amazon-beauty datasets, the comparative experimental results are shown in Table 3:

[0087] Table 3

[0088]

[0089]

[0090] Experimental results show that the proposed method is superior to other methods in HITRATE, MRR and NDCG under different N values. It can be proved that the proposed sequential recommendation method based on diffusion model and contrastive learning can better optimize the implicit variables of users and projects, improve the reliability of prediction and the accuracy of recommendation system.

[0091] The preferred embodiments of the present invention are described in detail above in conjunction with the accompanying drawings. However, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, a variety of simple modifications can be made to the technical solution of the present invention, and these simple modifications all belong to the protection scope of the present invention.

Claims

1. A sequence recommendation method based on diffusion model and contrastive learning, characterized by: The specific steps include: Step 1: Collect the historical interaction data of each user, map the project ID into a vector and store it in the matrix R; Step 2: Extract the item vectors that have interacted with the current user u from the matrix R, and add the corresponding position information to the item vectors according to the time sequence of the interaction; Step 3: Interaction sequence S for user u u ={x1,x2,x3,…,x n }, using the attention neural process to learn the user's long-term interest representation U l ; Step 4: Consider the last L items in the interaction sequence as short-term interests, use the time domain convolutional network to extract the user's short-term interests at different scales, and then concatenate and fuse them through the multi-head attention mechanism to obtain the user's short-term interest representation U s ; Step 5: Based on the user's long-term and short-term interests, use the diffusion model to predict the next item the user will interact with; Step 6: Use contrastive learning methods to improve the similarity between long-term interest coding, short-term interest coding and corresponding pseudo labels, and untie and distinguish long-term interests from short-term interests; Step 7: Introduce the cross entropy loss function, which together with the loss function in contrastive learning constitutes the total loss function; complete model training by optimizing the value of the total loss function; use the trained model to predict the user's next interactive item based on the user's long-term and short-term interests, and generate a list of recommended items.

2. The sequence recommendation method based on diffusion model and contrastive learning as claimed in claim 1, characterized in that: Use the Embeding layer to map the project ID.

3. The sequence recommendation method based on diffusion model and contrastive learning as claimed in claim 1, characterized in that: Learn the user’s long-term interest representation U l The specific method is: s3.

1. Randomly select a value Num from (n / 2)~n, and divide the input sequence Su into the context point set C=(x c ,y c ) and the target point set G = {(x g ,y g )}; where c=1,2,…Num, g=Num+1,Num+2,…n,y c =Mean(x1,x2,x3,…,x c ), y g =Mean(x1,x2,x3,……,x g ); s3.

2. For each context point, use the encoder H to generate a representation r c =H(x c ,y c ), and then use the attention mechanism to generate weights: Among them, k is a compatibility function, q t is the target point x t The query vector of , exp represents the exponential function with natural logarithm as the base; s3.

3. Aggregate the context point representations to form a global representation r g : s3.

4. Using the decoder based on the aggregated global representation r g To predict the output for each target point: Where D represents the neural network of the decoder, and the user’s long-term interest is represented by U l Obey Gaussian distribution μ g is the mean, is the variance.

4. The sequence recommendation method based on diffusion model and contrastive learning as claimed in claim 3, characterized in that: The encoder H is an LSTM network, and the decoder D is a linear network.

5. The sequence recommendation method based on diffusion model and contrastive learning as claimed in claim 3, characterized in that: The compatibility function uses a dot product function form.

6. The sequence recommendation method based on diffusion model and contrastive learning as claimed in claim 1, characterized in that: Get the user's short-term interest representation U s The specific method is: s4.

1. Create multiple convolution kernels for the L items x that the user has recently interacted with. n-L+1:n Perform short-term interest extraction: s (d) =f cnn (x n-L+1:n ,dilate=d) Among them, s (d) The expansion coefficient of the convolution kernel is d, which is the extracted feature vector, d = 1, 2, 3...; s4.

2. Features s at different scales (d) To splice: F s =||s (d) || represents vector concatenation operation; s4.3, the concatenated vector F s Input into a multi-head attention mechanism to obtain the final user short-term interest representation U s : Among them, N h represents the number of outputs in the multi-head attention mechanism, r h Represents the output features of the h-th attention mechanism.

7. The sequence recommendation method based on diffusion model and contrastive learning as claimed in claim 1, characterized in that: The method of using the diffusion model to predict the next item that the user interacts with is: s5.1, Diffusion stage: Use Markov chain to model: in is a value with a mean of (1-β t ), the variance is β t Gaussian distribution, β t is a pre-set hyperparameter, I represents the unit matrix; the initial value X0 is the vector representation of the target item; X t It represents the result after t times of diffusion, t represents the time step, and the maximum diffusion step is set to 32, then t=1,2,…32; s5.2, Reverse stage: In the inverse phase, the initial value X0 is unknown and an approximator f is used. θ According to the long-term interest representation and short-term interest representation U l , U s Make predictions: α t =1-β t Among them, ∈′ is a standard Gaussian distribution with mean 0 and variance 1; s5.3, Repeat the diffusion and reverse process to update the approximator f θ , until the inverse process derives the estimated value of X0 and the output of the approximator The error is less than the set threshold.

8. The sequence recommendation method based on diffusion model and contrastive learning as claimed in claim 7, characterized in that: The goals of contrastive learning are: yes(U l ,p l )>yes(U l ,p s ) yes(p l ,U l )>yes(p l ,U s ) yes(U s ,p s )>yes(U s ,p l ) yes(p s ,U s )>yes(p s ,U l ) Where sim represents the similarity between two vectors; brackets represent the dot product and inner product operations of two vectors; U l 、p l Represent the user’s long-term interests and pseudo labels of the user’s long-term interests, U s 、p s Represent the user’s short-term interests and short-term interest pseudo labels respectively.

9. The sequence recommendation method based on diffusion model and contrastive learning as claimed in claim 1 or 8, characterized in that: Construct the following contrastive learning loss function: Among them, L bpr represents the Bayesian Personalized Ranking (BPR) loss function; U l 、p l Represent the user’s long-term interests and pseudo labels of the user’s long-term interests, U s 、p s Represent the user's short-term interests and short-term interest pseudo labels respectively; Introduce the cross entropy loss function for the approximator f θ To train: e j represents the embedding vector of the jth item, Indicates the probability of this item being clicked at the next moment; The total loss function of the approximator is in, Represents a collection of users, Represents the number of users in the set; use the gradient descent method to adjust the model hyperparameters.

10. The sequence recommendation method based on diffusion model and contrastive learning as claimed in claim 9, characterized in that: The pseudo label of long-term interest is the vector mean of all the user's interactions, and the pseudo label of short-term interest is the vector mean of the user's most recent L items:

Citation Information

Cited By

  • Contrast learning depolarization intelligent recommendation method based on diffusion model

    CN119988739A