Comparative learning enhanced dynamic graph neural network recommendation method
By introducing contrastive learning and data enhancement technology into the dynamic graph neural network recommendation model, dynamically learning the embedding of users and project resources solves the shortcomings of existing models in dealing with dynamic recommendation data and data sparsity, achieving high quality and individuality the recommendation effect.
Patent Information
- Application Number
- CN202411316685.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2025-01-21
AI Technical Summary
Existing collaborative filtering models based on graph neural networks are difficult to accurately capture user interests and generate accurate recommendation results, especially when dealing with dynamic recommendation data and facing data sparsity and noise.
A dynamic graph neural network recommendation method enhanced by contrastive learning is proposed. By introducing timing processing mechanism and data enhancement technology, it dynamically learns the real-time embedding of users and project resources, and combines cross-view comparative learning of the main view and auxiliary view to enhance the recommendation model. performance.
It achieves high-quality dynamic recommendations, alleviates the problem of data sparseness, removes redundant historical interactions, and improves the accuracy and personalization of recommendations.
Smart Images

Figure CN119338544A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of recommendation systems, and in particular to a dynamic graph neural network recommendation method enhanced by contrastive learning. Background Art
[0002] Recommender systems play a crucial role in areas such as social media, streaming media, and e-commerce. In an era of information explosion, they help users find interesting content amidst vast amounts of information, improving information acquisition efficiency and maximizing information utilization. For businesses, recommendation systems can attract and retain users, increase engagement and conversion rates, and ultimately achieve sustainable growth in business goals.
[0003] For example, e-commerce recommendation systems can recommend personalized products based on a user's purchase history, browsing behavior, and personal preferences, thereby improving purchase conversion rates and user satisfaction. This demonstrates the importance of recommendation systems in our daily lives. Furthermore, in social media, online shopping sites, and streaming media, recommendation systems leverage historical interactions between users and items to predict items that users are likely to interact with in the future.
[0004] In the real world, user interests and item popularity can change over time. Using dynamic recommendation models to capture these dynamic changes in users and items in real time, update their embedding representations, and make accurate predictions is crucial. Furthermore, collaborative information has proven powerful in recommendations; users who interact with common items often have similar interests. Therefore, integrating user and item dynamics with collaborative information is a key task in dynamic recommendation systems.
[0005] Graph structures can explicitly integrate collaborative information. Graph models treat user-item interactions as a bipartite graph and leverage the high-order connectivity between users and items to encode collaborative information into the graph structure. However, most graph neural network recommendation models are unable to handle dynamic recommendation data and are only applicable to static scenarios, unable to leverage sequential dependencies and temporal information between items. Another issue facing graph neural network recommendation models is data sparsity and data noise. Many users only interact with a few items, making it difficult for recommendation models to predict users' potential interests. Furthermore, graph neural network recommendation models directly aggregate information from all interaction edges in the user-item interaction graph to update user and item representations, which not only introduces noise, but also amplifies the noisy information through multi-hop embedding propagation.
[0006] Therefore, existing collaborative filtering models based on graph neural networks may not be able to accurately capture user interests and generate accurate recommendation results. Summary of the Invention
[0007] In response to the above problems, the present invention proposes a dynamic graph neural network recommendation method enhanced by contrastive learning, which realizes personalized task recommendation in specific fields.
[0008] The contrastive learning enhanced dynamic graph neural network recommendation method has the following specific steps:
[0009] Step 1: Download the recommendation task dataset and divide it into test set and training set;
[0010] The data includes: user entity, project resource entity, and the interaction relationship between the two entities; the interaction relationship includes interaction time information.
[0011] Step 2: Use the training set to train the dynamic graph neural network recommendation model enhanced by contrastive learning. When the error between the output predicted recommendation result and the actual recommendation result is within a given threshold, the optimal learnable parameters of the trained recommendation model are obtained.
[0012] By calculating the overall loss of the recommendation task output by the dynamic graph neural network recommendation model and the actual comparative learning task, the model parameters are optimized and increased through backpropagation, and finally a trained recommendation model is obtained.
[0013] The overall loss is expressed as follows:
[0014] Loss=Loss bpr +λ1·Loss view +λ2·Loss ssl
[0015] Among them, Loss bpr is the recommendation loss, Loss view is the structural loss between views, Loss ssl is the contrast loss, λ1 and λ2 are the corresponding weight coefficients.
[0016] Among them, the recommendation loss is calculated as follows:
[0017] Loss bpr =∑(u,i,i′,t)∈O T -log σ(score(u,i,t)-score(u,i′,t))+λ||Θ||2 2
[0018] Among them O Trepresents the training set, σ(·) is the Sigmoid activation function, and Θ is the learnable parameter of the model. (u, i, i′, t) represents a randomly sampled negative sample of user u's interaction records in the training set. score(u, i, t) is the recommendation loss, which uses a multi-layer perceptron to calculate the recommendation score of user u's embedded representation. λ is the regularization parameter used to control model complexity and prevent overfitting. i and i′ are positive and negative sample pairs generated during training. Specifically, i represents a positive sample, i.e., an item with which the user has actually interacted, while i′ represents a negative sample, i.e., an item with which the user has not interacted.
[0019] The structure loss between views is calculated as follows:
[0020] Loss view =SIM(f e 1 , f e 2 )
[0021] where f e 1 For auxiliary viewing Figure 1 The probability of dropping each edge on the e 2 For auxiliary viewing Figure 2 The probability of discarding each edge on ;
[0022] Contrast loss ssl The calculation formula is as follows:
[0023]
[0024] v i is the constructed node, V is the set of all constructed nodes; e i ′,e i ″ represents node v i Embedded representations on different views, s(·) is the similarity calculation function, and τ is the temperature coefficient.
[0025] Step 3: Use the test set to test the trained dynamic graph neural network recommendation model to obtain the final dynamic graph neural network recommendation model.
[0026] Step 4: Use the final dynamic graph neural network recommendation model to predict the user's newly recommended items and return the prediction results to the current user.
[0027] The advantages of the present invention are:
[0028] This paper presents a dynamic graph neural network recommendation method enhanced by contrastive learning. By introducing a temporal processing mechanism into the graph neural network recommendation task, it dynamically learns the real-time embedding of users and project resources to achieve high-quality dynamic recommendations. It uses data augmentation and contrastive learning methods to enhance the capabilities of the graph neural network recommendation model. A graph data augmentation module is used to alleviate data sparsity and remove redundant historical interactions. This introduces high-quality training information to better explore and utilize users' potential interest in project resources. Cross-view contrastive learning between the primary and auxiliary views enhances the performance of the dynamic graph neural network recommendation model on the primary view. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 This is the overall flow chart of a dynamic graph neural network recommendation method enhanced by contrastive learning;
[0030] Figure 2 This is the model framework diagram of the present invention
[0031] Figure 3 Flowchart of edge-loss data enhancement based on learnable encoder
[0032] Figure 4 Flowchart for edge data enhancement based on user clustering interest discovery DETAILED DESCRIPTION
[0033] To facilitate understanding and implementation of the present invention by those skilled in the art, the present invention is further described below in detail with reference to the accompanying drawings and embodiments. It is apparent that the embodiments described are merely partial embodiments of the present invention, not all embodiments. All other embodiments derived by those skilled in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.
[0034] The present invention discloses a dynamic graph neural network recommendation method enhanced by contrastive learning, which combines temporal coding technology with contrastive learning mechanism to improve the recommendation performance of the graph neural network recommendation method. The present invention dynamically learns the real-time embedding of users and project resources to achieve high-quality dynamic recommendations by introducing position encoding and self-attention mechanism into the graph neural network representation update process. Data enhancement and contrastive learning methods are used to enhance the capabilities of the graph neural network recommendation model, and a graph topology data enhancement method for personalized recommendation tasks is proposed to alleviate the data sparsity problem and remove redundant historical interactions, introduce high-quality training information, and generate auxiliary user-project resource interaction views to better explore and utilize users' potential interest in project resources. Through the cross-view contrastive learning mechanism of the main view and the auxiliary view, the recommendation model performance on the main view is improved, and personalized project resource recommendations for users are achieved.
[0035] The contrastive learning enhanced dynamic graph neural network recommendation method, such as Figure 1 As shown, the steps include:
[0036] Step 1: Download the recommendation task dataset and divide it into test set and training set;
[0037] The dataset mainly includes MOOC, MovieLens-100K, Amazon Office Products, etc., which are constructed as a bipartite graph; the data includes: user entities, project resource entities, and the interaction relationship between the two entities; the interaction relationship includes interaction time information, and the interaction behavior is usually used as the target behavior; a part of the target behavior data is selected as the test set, and the rest of the data is used as the training set for model training.
[0038] Step 2: Use the training set to train the dynamic graph neural network recommendation model enhanced by contrastive learning. When the output predicted recommendation results are close to the actual recommendation results, the learnable parameters in the model are adjusted and optimized to obtain the optimal learnable parameters of the trained recommendation model.
[0039] The specific training process is:
[0040] Step 2.1, build a dynamic graph neural network recommendation model;
[0041] The overall architecture of the TGAR (Temporal Graph Augmentation Recommendation) model proposed in this invention is as follows: Figure 2 The model mainly consists of three parts: a graph attention layer for temporal information perception, information enhancement-assisted view generation, and inter-view contrastive learning loss optimization, corresponding to the three modules of dynamic graph neural network recommendation model, graph data enhancement, and contrastive learning.
[0042] The original graph data, after being enhanced by the data enhancement module, is subjected to comparative learning with the dynamic graph neural network module to obtain the inter-view comparative learning loss, which is finally input into the recommendation model.
[0043] First, construct the time information encoding function as follows:
[0044]
[0045] in Represents the encoding vector at time t, ω i is a trainable parameter, d T is the dimension of time embedding.
[0046] Then, time information encoding is introduced into the information transmission process of the graph neural network. The interaction time information between users and items is encoded through the time encoder and concatenated with the original user and item initial representation vectors to obtain user and item representations.
[0047] Afterwards, construct node v i The representation of the neighbor nodes with time sequence information of the l-1 layer network is as follows:
[0048]
[0049] in Represents v i Neighbor node v j The l-1 layer representation.
[0050] Represent the neighbor nodes with node v i The l-1 layer representation is mapped for subsequent attention calculation, and the formula is as follows:
[0051]
[0052] in is a weight matrix that captures the interaction between temporal encoding and node features.
[0053] Attention weight The calculation formula is as follows:
[0054]
[0055] The dot product attention weight and the corresponding rows of the neighbor representation matrix V(t) are summed row by row as the overall representation of the neighbors. The formula is as follows:
[0056]
[0057] The final node v in the lth layer i The embedding representation of is calculated as follows:
[0058]
[0059] in Represents node v i The embedded representation at time t in layer l, and is the learnable parameter shared by layer l.
[0060] Finally, the self-attention mechanism is applied to transfer and aggregate temporal information encoding to obtain the final embedded representation of users and items for recommendation;
[0061] When processing sequential data, the self-attention mechanism allows each element to be associated with other elements in the sequence, rather than just relying on elements in adjacent positions. This mechanism adaptively captures long-range dependencies between elements by calculating the relative importance between them.
[0062] The recommendation loss uses a multi-layer perceptron (MLP) to calculate the recommendation score for the embedded representation of the user and the embedded representation of the item. The formula is as follows:
[0063] score(u,i,t)=MLP(h u (l) (t)||h i (l) (t))
[0064] Where u represents the user, i represents the item, and t represents the time.
[0065] Then, through sampling technology, we sample the positive sample pairs of each real user-resource interaction and obtain negative sample pairs. We construct a scoring function to maximize the distance between the positive and negative sample pairs, and use this as the recommendation loss to backpropagate and optimize the recommendation model.
[0066] For each (u,i,t) in the training set, that is, a positive sample of the user's interaction with the project resource, a negative sample (u,i′,t) is randomly sampled based on the known interaction records of user u in the training set. The BPR loss is used to maximize the distance between the positive sample score and the negative sample score. This is used as the loss function and backpropagation is performed. The formula is as follows:
[0067] Loss bpr =∑(u,i,i′,t)∈O T -logσ(score(u,i,t)-score(u,i′,t))+λ||Θ||2 2
[0068] Among them O T represents the training set, which contains the (u, i, t) interactive positive sample pairs and the corresponding negative sample pairs (u, i′, t), σ(·) is the Sigmoid activation function, and Θ is the learnable parameter of the model.
[0069] Step 2.2: Build data augmentation auxiliary view.
[0070] Data enhancement is to generate auxiliary views by adding and subtracting interaction edges in the user-item interaction graph to optimize model performance. The overall framework diagram is as follows Figure 3 As shown in the figure, the original graph data is passed through the graph encoder to generate an auxiliary view, which is used to perform a contrastive loss on the graph structure. This view is then fed into the recommendation model to obtain a contrastive loss for representation learning. Edges are added and deleted in the auxiliary view.
[0071] The specific method is as follows:
[0072] 1) Construct a learnable encoder to characterize the importance of interaction edges in the user-item interaction graph, generate the drop probability of each interaction edge, and drop the interaction edges based on the drop probability;
[0073] The formula for the learnable encoder is as follows:
[0074] P e =Encoder(ε)
[0075] f e =GumbelSoftmax(P e )
[0076] View drop =AUG drop (ε,f e )
[0077] Where ε is the embedding representation of each interaction edge in the training set, which can be learned and updated as the recommendation task progresses. Encoder is a learnable encoder, such as an MLP or linear layer, which converts the edge embedding into a probability distribution. e The discard probability of each edge is generated, and the unique hot vector f of the edge index to be discarded is obtained through the GumbelSoftmax activation function e , and generate auxiliary view View based on it drop .
[0078] 2) Clustering users based on their embedded representations using a clustering algorithm, constructing item sets for users in the same cluster, and using the attention scores between users in the cluster and items in the item set to add edges between users and several items with the highest scores;
[0079] Based on the generated auxiliary views, we further perform data enhancement based on the discovery of users' potential interests. We cluster user groups using the K-means clustering algorithm based on their embedded representations. For each cluster, we construct a collection of past interaction items for all users within that cluster based on the training set data. We then calculate the scores between users and item entities in the collection. Based on the scores, we add edges between the top-K items and users to alleviate data sparsity. The formula is as follows:
[0080]
[0081] ε int ={(u,i,t)|i∈Top_k(A u* )for allu∈U}
[0082] Among them A u*Represents user u and all items to be selected i * The score between Top_k(A u* ) indicates that A u* Sort and take the top-K items, and finally generate the potential interest plus edge set ε int , perform data enhancement and generate the final data enhanced auxiliary view.
[0083] 3) Data augmentation is performed on the original user-item interaction data through edge addition and edge trimming operations to obtain data augmentation auxiliary views. By calculating the contrast loss between the structures of different views, the mutual information between different views is minimized, and backpropagation is performed to optimize the learnable encoder;
[0084] The formula is as follows:
[0085]
[0086] where f e 1 For auxiliary viewing Figure 1 The probability of dropping each edge on the e 2 For auxiliary viewing Figure 2 The probability of discarding each edge on is used, and the mean square error loss function MSE is used for loss calculation to obtain the structural loss between the generated auxiliary views.
[0087] Step 2.3: Construct a comparative learning task for different view nodes.
[0088] The recommendation model is trained on the main and auxiliary views for recommendation tasks. Comparative learning is used to constrain the consistency of the representations of the same entity nodes under different conditions, thereby optimizing the recommendation model. The recommendation model is trained on the main and auxiliary views for recommendation tasks. The embedding representations of the same entity nodes under different views are used as positive pairs, and the embedding representations of different entity nodes under different views are used as negative pairs. The loss function for positive pairs is minimized, and the loss function for negative pairs is maximized. This constrains the consistency of user and item representations under different views, thereby optimizing the recommendation model.
[0089] The loss function formula for the contrastive learning task of user and item embeddings between different views is as follows:
[0090]
[0091] where e′ i ,e″ i represents the embedding representation of node i in different views, s(·) is the similarity calculation function, and τ is the temperature coefficient.
[0092] Step 2.4: Combine the training losses of steps 2.1-2.3 to obtain the overall loss of the recommendation task and the contrastive learning task. Optimize and increase the model parameters through backpropagation, train on the training set data, and obtain a trained recommendation model.
[0093] The overall loss of the model is expressed as follows:
[0094] Loss=Loss bpr +λ1·Loss view +λ2·Loss ssl
[0095] Among them, Loss bpr is the recommendation loss, Loss view is the structural loss between views, Loss ssl is the contrast loss, λ1 and λ2 are weight coefficients.
[0096] Step 3: Use the test set to test the trained dynamic graph neural network recommendation model. By adjusting the hyperparameters in the recommendation model, the dynamic graph neural network recommendation model is further optimized to improve the model's recommendation evaluation indicators and obtain the final dynamic graph neural network recommendation model.
[0097] The hyperparameters are tuned as follows:
[0098] 1. Test and evaluate model performance:
[0099] The trained dynamic graph neural network recommendation model enhanced by contrastive learning was tested on the test set. The performance of the model was evaluated using the commonly used metrics in recommendation systems: recall and normalized discounted cumulative gain (NDCG@K).
[0100] 2. Recall:
[0101] Recall indicates the proportion of true positive samples found by the model in the recommendation list. The formula is as follows:
[0102]
[0103] u represents the user, R(u) represents the recommendation list generated by the recommendation model for user u, and T(u) represents the set of items that the user actually interacts with, that is, the true label.
[0104] Calculate the above formula for all users and take the average to get the recall rate of the recommendation model for the entire dataset. A higher recall rate indicates better recommendation results.
[0105] 3. Normalized Discounted Cumulative Gain (NDCG@K):
[0106] NDCG@K is used to evaluate the ranking quality of recommendation results, taking into account the order of recommendation results. The formula is as follows:
[0107]
[0108] Among them, rel i is the relevance score of the item at position i, where i is the item's rank. DCG@K stands for discounted cumulative gain, which combines the relevance and ranking quality of the items in the recommendation list. IDCG@K represents ideal DCG@K. Higher NDCG values indicate better recommendations.
[0109] 4. Hyperparameter Tuning:
[0110] During testing, we further optimized the model's performance by adjusting the hyperparameters in the recommendation model. This involves experimenting with different hyperparameter combinations to find the optimal settings for performance on evaluation metrics like recall and NDCG.
[0111] Step 4: Use the final dynamic graph neural network recommendation model to predict the user's newly recommended items and return the prediction results to the current user.
[0112] Example:
[0113] See also Figure 1 、 Figure 2 、 Figure 3 and Figure 4 , the dynamic graph neural network recommendation method enhanced by contrastive learning is applied to the course recommendation task, which specifically includes the following steps:
[0114] Step 1: Download and build the course recommendation task dataset, taking the MOOC dataset as an example.
[0115] The data primarily includes student user entities, course resource entities, and the user's registration-learning relationship with the course resource entity. The registration-learning relationship includes interaction time information, and the registration-learning behavior is used as the target behavior for prediction. A portion of the registration-learning behavior data is selected as the test set, and the remaining data is used as the training set for model training.
[0116] Step 2: Use the training data to train the dynamic graph neural network model enhanced by contrastive learning. Through training, the predicted recommendation results of the recommendation model are made close to the actual recommendation results, and then the learnable parameters in the model are adjusted and optimized to obtain a trained dynamic graph neural network recommendation model enhanced by contrastive learning.
[0117] Step 2.1: Build a dynamic graph neural network recommendation model.
[0118] Time information encoding is introduced into the information transmission process of the graph neural network. The time information of the interaction between the student user and the course resource is encoded through the time encoder and spliced with the original student user and course resource initial representation vector to obtain the student user and course resource representation;
[0119] The self-attention mechanism is applied to transmit and aggregate information on the graph to obtain the embedded representation of student users and course resources used for recommendation. Then, negative sample pairs are obtained through sampling technology, and a scoring function is constructed to maximize the distance between positive and negative sample pairs, which is used as the recommendation loss backpropagation to optimize the recommendation model.
[0120] Step 2.2 builds a dynamic graph neural network recommendation model by stacking dynamic information propagation and node embedding update layers.
[0121] The following example uses the course recommendation task to illustrate the model process.
[0122] The course recommendation data is a bipartite graph. The nodes are divided into two categories: student user nodes and course resource nodes. The connection between the two types of nodes represents that the user has registered to learn the course resource. The edge carries the registration learning time information. For the student user node v at time t i , the set of neighbor nodes of course resources that have interacted in the past is N(v i ,t)={v1,…,v N}, v i All past resource interactions are with neighbor v j ∈N(v i ,t) and occur at t j time.
[0123] The input of the dynamic information propagation and node embedding update layer is the embedding of the neighbor nodes of the course resources. and target user node v i Embedding with timestamp When l = 1, that is, for the first layer, the input is the initial node feature. After l layers, the target user node v at time t i The time-aware embedding of It can be iteratively passed to the next layer. Since it is more meaningful to describe the relative time between two interactions, t-t1,…,tt is used. j Instead of the actual interaction timestamp, the time information representation is generated.
[0124] Combined with the attention mechanism on the graph, we can get the neighbors The entity time information representation matrix is:
[0125]
[0126] The entity embedding representation and the time information representation are concatenated and then With user node v i The previous layer representation The preceding item is propagated to three linear maps to obtain Query, Key, and Value:
[0127]
[0128] in is a weight matrix that captures the interaction between temporal encoding and node features. Calculated by the following formula:
[0129]
[0130] Then, the above dot product attention weights are summed row by row with the corresponding rows of the course resource neighbor representation matrix V(t) as the overall representation of the course resource neighbors:
[0131]
[0132] In order to combine the course resource neighbor representation with the student user node past representation, the neighbor representation is concatenated with the student user node representation of the previous layer, and then passed to the feedforward neural network to generate the final l-th layer student user node v i Embedded representation of:
[0133]
[0134] in Represents student user node v i The embedded representation at time t in layer l, and is the learnable parameter shared by layer l.
[0135] The above example introduces the method of generating the embedded representation of student users from the user side. The method of generating the embedded representation of course resource entities is the same as above. It only requires changing the target central node to the course resource entity and the neighbor nodes to the corresponding student users.
[0136] By stacking multiple layers of information propagation and node embedding update, we can obtain embedding representations of learner users and course resource entities at different depths. Based on the representations output by the last layer, we update the recommendation loss and perform backpropagation.
[0137] In the recommendation part, a multi-layer perceptron (MLP) is used to calculate the recommendation score for the embedding representation of the learner user and the embedding representation of the course resource entity. The higher the score, the greater the user's interest in the course resource and the greater the possibility of subsequent interaction. The score calculation formula is as follows:
[0138]
[0139] In order to calculate the loss and perform backpropagation during the training phase, for each (u, i, t) in the training set, that is, a positive sample of the user interacting with the course resources, a negative sample (u, i′, t) is randomly sampled based on the known interaction records of user u in the training set. The BPR loss is used to maximize the distance between the positive sample score and the negative sample score. This is used as the loss function and backpropagation is performed. The formula is as follows:
[0140]
[0141] Among them O T represents the training set, which contains the (u, i, t) interactive positive sample pairs and the corresponding negative sample pairs (u, i′, t), σ(·) is the Sigmoid activation function, and Θ is the learnable parameter of the model.
[0142] Step 2.3: Build data augmentation auxiliary view.
[0143] A learnable encoder is used to characterize the importance of interaction edges in the student-user-course resource interaction graph, generating a drop probability for each interaction edge, and discarding interaction edges based on the drop probability. A clustering algorithm is used to cluster student users based on their embedded representations. A project set is constructed for users within the same cluster. The attention scores between users within the cluster and courses in the course resource set are used to add edges between users and the highest-scoring course resources. The original user-course resource interaction data is augmented through edge addition and edge pruning operations to obtain a data-augmented auxiliary view. The learnable encoder is optimized using a structural loss between views.
[0144] The learnable encoder enhances edge loss data. Based on the original training set data, the auxiliary view of student-course resource interaction is initialized. Then, during the recommendation task, the learnable encoder is used to learn and update the auxiliary view. Based on the embedded representation of the interaction edges between student users and course resources in the training data, the probability of discarding or retaining each interaction edge is generated, and the auxiliary view is updated. The formula is shown as follows:
[0145] P e =Encoder(ε)
[0146] f e =GumbelSoftmax(P e )
[0147] View drop =AUG drop (ε,f e )
[0148] Where ε is the embedding representation of each interaction edge in the training set, which can be learned and updated as the recommendation task progresses. Encoder is a learnable encoder, such as an MLP or linear layer, which converts the edge embedding into a probability distribution, P e The discard probability of each edge is generated, and the unique hot vector f of the edge index to be discarded is obtained through the GumbelSoftmax activation function e , and generate auxiliary view View based on it drop .
[0149] For the similarity contrast loss between views, by calculating the contrast loss of the structures between different views, minimizing the mutual information between different views, and performing backpropagation, we can prevent different auxiliary views from converging into one, thereby generating and utilizing richer information. The formula is as follows:
[0150]
[0151] in For auxiliary viewing Figure 1 The probability of dropping each edge on , For auxiliary viewing Figure 2 The probability of discarding each edge on is used, and the mean square error loss function MSE is used for loss calculation to obtain the structural loss between the generated auxiliary views.
[0152] Clustering and edge data enhancement uses the K-means clustering algorithm to cluster student user groups based on their embedded representations. For each cluster, a collection of past interactive course resources for all users within that cluster is constructed based on the training set data. The scores between users and course resource entities in the course resource collection are calculated, and based on the scores, edges are added between the top-K course resources and users to alleviate data sparsity issues, thereby achieving graph data enhancement based on user clustering and potential interest discovery. The formula is as follows:
[0153]
[0154] ε int ={(u,i,t)|i∈Top_k(A u* )for allu∈U}
[0155] Among them A u* Represents user u and all the course resources i to be selected * The score between Top_k(A u* ) indicates that A u*Sort and take the top-K course resources, and finally generate the potential interest plus edge set ε int .
[0156] Step 2.4: Construct a comparative learning task for nodes in different views. Use the recommendation model to train the recommendation task in the main view and auxiliary view. By treating the same entity node representations in different views as positive pairs and different entity node representations in different views as negative pairs, minimizing the loss of positive pairs and maximizing the loss of negative pairs, we can constrain the consistency of user and course resource representations in different views, thereby optimizing the recommendation model. The formula is as follows:
[0157]
[0158] where e′ i ,e″ i represents the embedding representation of node i in different views, s(·) is the similarity calculation function, and τ is the temperature coefficient.
[0159] Step 2.5: Combine the training losses of steps 2.2-2.4 to obtain the overall loss of the recommendation task and the contrastive learning task. Optimize and increase the model parameters through backpropagation, train on the training set data, and obtain a trained recommendation model.
[0160] The overall loss formula is as follows:
[0161] Loss=Loss bpr +λ1·Loss view +λ2·Loss ssl
[0162] Among them, Loss bpr is the recommendation loss, Loss view is the structural loss between views, Loss ssl is the contrast loss, λ1 and λ2 are weight coefficients.
[0163] Step 3. Use the test set to test the contrastive learning enhanced dynamic graph neural network recommendation model trained by the above process. Further optimize the trained contrastive learning enhanced dynamic graph neural network recommendation model by adjusting the hyperparameters in the recommendation model, improve the model's recommendation evaluation indicators, and obtain the final contrastive learning enhanced dynamic graph neural network recommendation model.
[0164] Step 4: Use the final contrastive learning enhanced dynamic graph neural network recommendation model to predict the user's recommended course items and return the prediction results to the current user. Use the trained model to generate representations of users and course resources. Use the multi-layer perceptron module MLP to calculate the recommendation score based on the embedding representation of the learner user and the embedding representation of the course resource entity. The higher the score, the greater the user's interest in the course resource. The formula is as follows:
[0165]
[0166] Finally, the course resources with the largest K scores are selected as the final recommended items for the current user, realizing the recommendation of Top-K course resources.
[0167] The specific embodiments described herein are merely illustrative of the spirit of the present invention. Persons skilled in the art may make various modifications, additions, or substitutions to the described specific embodiments without departing from the spirit of the present invention or exceeding the scope of the appended claims.
Claims
1. A dynamic graph neural network recommendation method enhanced by contrastive learning, characterized in that: The specific steps are as follows: Step 1: Download the recommendation task dataset and divide it into a test set and a training set; Step 2: Use the training set to train the dynamic graph neural network recommendation model enhanced by contrastive learning. When the error between the output predicted recommendation result and the actual recommendation result is within a given threshold range, the optimal learnable parameters of the trained recommendation model are obtained. By calculating the overall loss of the recommendation task output by the dynamic graph neural network recommendation model and the real comparative learning task, the model parameters are adjusted by back propagation optimization, and finally a trained recommendation model is obtained; The overall loss is expressed as follows: Loss=Loss bpr +λ1·Loss view +λ2·Loss ssl Among them, Loss bpr is the recommendation loss, Loss view is the structural loss between views, Loss ssl is the contrast loss, λ1 and λ2 are the corresponding weight coefficients; Among them, the recommended loss is calculated as follows: Loss bpr =∑(u,i,i′,t)∈oT-log σ(score(u,i,t)-score(u,i′,t))+λ||Θ||2 2 Among them, T represents the training set, σ(·) is the Sigmoid activation function, Θ is the learnable parameter of the model; (u, i, i′, t) represents the negative sample randomly sampled from the interaction records of user u in the training set; score(u, i, t) is the recommendation loss, which uses a multi-layer perceptron to recommend the embedding representation of user u, and λ is the regularization parameter; i and i′ refer to the positive and negative sample pairs generated during the training process; i represents a positive sample, i.e., the item that the user has actually interacted with, and i′ represents a negative sample, i.e., the item that the user has not interacted with; The structure loss between views is calculated as follows: Loss view =SIM(f e 1 ,f e 2 ) where f e 1 is the probability of dropping each edge on auxiliary view 1, f e 2 is the probability of discarding each edge on auxiliary view 2; Contrast loss ssl The calculation formula is as follows: v i is the constructed node, V is the set of all constructed nodes; e i ′,e i ″ represents node v i Embedding representation on different views, s(·) is the similarity calculation function, τ is the temperature coefficient; Step 3: Use the test set to test the trained dynamic graph neural network recommendation model to obtain the final dynamic graph neural network recommendation model; Step 4: Use the final dynamic graph neural network recommendation model to predict the user's newly recommended items and return the prediction results to the current user.
2. A contrastive learning enhanced dynamic graph neural network recommendation method as claimed in claim 1, characterized in that: In the step 1, the data includes: a user entity, a project resource entity, and an interaction relationship between the two entities; wherein the interaction relationship includes interaction time information.
3. The dynamic graph neural network recommendation method enhanced by contrastive learning as claimed in claim 1, characterized in that: In the step 2, the calculation formula of the recommendation score is as follows: score(u,i,t)=MLP(h u (l) (t)||h i (l) (t)) MLP() is a multi-layer perception function; h u (l) (t) is the l-layer representation of user u in the training set; h i (l) (t) is the l-layer representation of the positive sample.
4. The dynamic graph neural network recommendation method enhanced by contrastive learning as claimed in claim 1, characterized in that: In the step 2, in the structure loss between views, a learnable encoder is constructed to characterize the importance of the interaction edges in the user-item interaction graph, generate the discard probability of each interaction edge, and discard the interaction edge according to the discard probability; The formula for the learnable encoder is as follows: P e =Encoder(ε) f e =GumbelSoftmax(P e ) View drop =AUG drop (ε,f e ) Where ε is the embedded representation of each interaction edge in the training set, Encoder is a learnable encoder that converts the edge embedding into a probability distribution, and P e The discard probability of each edge is obtained by GumbelSoftmax activation function to obtain the unique hot vector f of the edge index to be discarded e , and generate auxiliary view View based on it drop .
5. The dynamic graph neural network recommendation method enhanced by contrastive learning as claimed in claim 1, characterized in that: In the step 2, based on the generated auxiliary view, data enhancement is further performed based on the discovery of user potential interests. According to the user's embedded representation, the user group is clustered using the K-means clustering algorithm. For each cluster, a set of past interaction items of all users in the cluster is constructed based on the training set data. Then, the scores between the user and the item entities in the item set are calculated, and the edges between the Top-K items and the user are added according to the size of the score to alleviate the data sparsity problem. The formula is as follows: ε int ={(u,i,t)|i∈Top_k(A u* )for all u∈U} Among them A u* Represents user u and all items to be selected i * The score between Top_k(A u* ) indicates that A u* Sort and take the top-K items, and finally generate the potential interest plus edge set ε int , perform data enhancement and generate the final data enhanced auxiliary view.
Citation Information
Patent Citations
Depolarization method of graph neural network based on comparative learning
CN115906922A
Multi-behavior socialized recommendation method and system based on graph neural network
CN117171448A
Comparative multi-view depth fusion clustering method based on dual-data enhancement
CN117934889A
Contrast learning method and system introducing hierarchical topology isomorphic knowledge
CN118520927A
Cross-domain recommendation via contrastive learning of user behaviors in attentive sequence models
US20240161165A1
Cited By
Education course session recommendation method and device, equipment and storage medium
CN120525693A