Film recommendation method based on neighbor aggregation heterogeneous graph neural network
By constructing a user-movie heterogeneous graph and optimizing node embedding using graph self-attention and multi-head attention mechanisms, the problems of information redundancy and low accuracy in existing technologies are solved, achieving high-quality user and movie node representation and high-precision movie recommendation.
Patent Information
- Application Number
- CN202511517718.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-23
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-10-23
AI Technical Summary
Existing heterogeneous graph neural network-based movie recommendation methods based on metapaths suffer from low accuracy and performance, mainly due to information redundancy and neglect of potential structural information during node aggregation.
We employ a neighborhood-aggregated heterogeneous graph neural network approach. By constructing a user-movie heterogeneous graph, we obtain initial node embedding vectors using random walks, optimize adaptive attention weights by combining graph self-attention and multi-head attention mechanisms, aggregate node embedding vectors, and finally use a multilayer perceptron for recommendation.
It effectively reduces information loss, improves the quality of user and movie node representations, and achieves high-precision movie recommendations.
Smart Images

Figure CN120994872A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to a movie recommendation method based on neighbor aggregation heterogeneous graph neural network. BACKGROUND With the development of digital entertainment, movies have gradually become a way of mass entertainment consumption. In recent years, the film industry has developed rapidly, and the number of movies on the market has increased exponentially, making it difficult for users to find their favorite films from such a vast amount of movie resources. Movie recommendation methods not only help users quickly find their favorite movies, but also bring huge commercial value to enterprises.
[0002] The existing movie recommendation method based on meta-path heterogeneous graph neural network has low precision and low performance. This is because the method using meta-path will aggregate a large amount of repeated node information in the process of aggregating neighbor nodes, resulting in too many additional learnable parameters when aggregating nodes, thereby producing information redundancy and reducing learning performance. For example, selecting "user-movie" and "user-movie-user" as meta-paths, in the process of aggregating neighbor nodes using these two meta-paths, the same movie node may be repeatedly aggregated, resulting in information redundancy and reducing learning performance. In addition, directly using attention mechanism in the process of node aggregation may ignore important potential structural information such as the number of paths between nodes, which can be utilized to improve node representation learning. SUMMARY
[0003] In view of this, the present application provides a movie recommendation method based on neighbor aggregation heterogeneous graph neural network to solve the problem of low precision and low performance of the prior art.
[0004] A movie recommendation method based on neighbor aggregation heterogeneous graph neural network, comprising: Step S1, reading a user-movie database, constructing a user-movie heterogeneous graph, and constructing a corresponding homogeneous subgraph for each node according to the distance between nodes of the same type in the heterogeneous graph; Step S2, using random walk on the heterogeneous graph to obtain a node sequence set, and inputting the node sequence set into a skip-gram model to obtain initial embedding vectors of each node; Step S3, based on the initial embedding vectors of each node, embedding different types of nodes into the same vector space to obtain vectors after projecting the features of each node; Step S4, based on the vectors after projecting the features of each node, using graph self-attention mechanism on neighbor nodes in the homogeneous subgraph corresponding to the node to calculate adaptive attention weights; In step S5, the adaptive attention weight is optimized by using the path instance quantity between the node pairs in the heterogeneous graph as an auxiliary weight for aggregating the same type nodes, the optimized adaptive attention weight is weighted and aggregated with the neighbor initial embedding vector in the homogeneous subgraph to obtain a same type node embedding vector; In step S6, the multi-head attention mechanism is used to aggregate the direct neighbors of the nodes in the heterogeneous graph to obtain a cross type node embedding vector, the same type node embedding vector and the cross type node embedding vector are spliced to form a final node embedding vector, the final node embedding vector is divided into a user node embedding vector and a movie node embedding vector according to different node types, the user node embedding vector and the movie node embedding vector are spliced and input into a multi-layer perception to obtain a recommendation value, and the user is recommended a movie according to the recommendation value.
[0005] According to the movie recommendation method based on the neighbor aggregated heterogeneous graph neural network provided by the application, the following beneficial effects are obtained: (1) The modeling information loss is small: the traditional modeling method models the movie network as a homogeneous network, ignores the heterogeneity of node types and node relationships, and causes a large amount of information loss. The application fully considers the above characteristics, and models the movie network as a heterogeneous graph, thereby retaining rich semantic information.
[0006] (2) High-quality user and movie node representation: the heterogeneous graph has a large number of different types of nodes, and direct aggregation of the nodes can easily lose important information, resulting in low-quality user and movie node representation vectors. In addition, using meta-paths to extract information can easily extract repeated node information, causing information redundancy. The application splices the same type node embedding vector obtained by aggregating the neighbor nodes of the homogeneous subgraph and the cross type node embedding vector obtained by aggregating the direct neighbors of the heterogeneous graph to obtain a final node embedding vector, avoids aggregating redundant nodes, and can obtain high-quality user and movie node representation, thereby effectively improving the learning performance.
[0007] (3) High-precision movie recommendation: the application uses the graph neural network and the multi-layer perception to calculate the recommendation value between the user and the movie, better combines the heterogeneous graph topological structure information and the downstream task, and thus the recommendation value between the user and the movie is more accurate, and high-precision movie recommendation is realized. DETAILED DESCRIPTION
[0008] Figure 1 The flowchart of the movie recommendation method based on the neighbor aggregated heterogeneous graph neural network provided by the embodiment of the application is shown. DETAILED DESCRIPTION
[0009] Embodiments of the present application are described below in the following detailed description and illustrated in the accompanying drawings by which like or similar elements are referred to with like or similar references throughout. The embodiments described below are exemplary of the present application and are not intended to be limiting of the present application unless otherwise specified.
[0010] Referring to Figure 1 , the embodiments of the present application provide a movie recommendation method based on neighbor aggregated heterogeneous graph neural network, comprising steps S1-S6: Step S1, read the user-movie database, construct the user-movie heterogeneous graph, and construct the corresponding homogeneous subgraph for each node according to the distance between nodes of the same type in the heterogeneous graph.
[0011] Among them, step S1 specifically includes: Step S11, read the user-movie database, construct the user-movie heterogeneous graph , Among them, represents a set of nodes, The nodes in the set represent users or movies, represents a set of edges, The edges in the set represent the relationship between nodes, represents a set of node types, including user node types and movie node types, represents a set of edge types.
[0012] Step S12, use the breadth-first search method to find all neighbor nodes within the distance of from node , and construct the corresponding homogeneous subgraph for node Step S13, construct the edge set for the homogeneous subgraph The node set is expressed as:
[0013] Among them, represents the node set of the homogeneous subgraph, and respectively represent the node type of node and node , and represents the distance between node and node ; is a hyperparameter, representing the order of extracting the subgraph; Step S13, construct the edge set for the homogeneous subgraph , which is divided into two parts, the first part is to retain the edges between nodes of the same type in the heterogeneous graph to form the edge set , which is expressed as:
[0014] wherein, is an edge between node and node ; The second part is for nodes and node in the homogeneous subgraph , if there is a path between the two nodes in the heterogeneous graph, and , represents the shortest path length between node and node , and the shortest path length between node and node is added between the two nodes, thereby forming an edge set , the expression is:
[0015] The edge set of the homogeneous subgraph is composed of the union of and , the expression is: .
[0016] Step S2, using random walk on the heterogeneous graph to get a node sequence set, input into the skip-gram model to get the initial embedding vector of each node.
[0017] Wherein, step S2 specifically includes: First, the random walk is used to sample the nodes of the heterogeneous graph to extract the context structure of each node, wherein each node in the heterogeneous graph is sequentially taken as a starting node, and a neighbor is randomly sampled as a next walk node, the expression is:
[0018] Wherein, represents a node sequence set obtained by random walk sampling, represents a random walk sampling operation, represents the starting node of the random walk, represents the length of the random walk; Then, input the node sequence set obtained by random walk sampling into the skip-gram model to get the initial embedding vector of the node, the expression is:
[0019] Wherein, represents an embedding matrix composed of the initial embedding vectors of all nodes, denotes the total number of nodes in the heterogeneous graph, , , denote the initial embedding vectors of node 1, node 2, node , respectively, denotes the transpose, denotes the skip-gram model.
[0020] Step S3, based on the initial embedding vectors of each node, embedding different types of nodes into the same vector space to obtain the projected vectors of each node feature.
[0021] Specifically, step S3 includes: Based on the initial embedding vectors of each node, a learnable parameter matrix is constructed for each node type in the heterogeneous graph for feature projection, so as to embed different types of nodes into the same vector space. For a node of node type , the expression of feature projection is:
[0022] wherein, is the projected vector of node , is the initial embedding vector of node , is the learnable parameter matrix of linear transformation of node type .
[0023] Step S4, based on the projected vectors of each node feature, using graph self-attention mechanism to calculate adaptive attention weight for neighbor nodes in the homogenous subgraph corresponding to the node.
[0024] Specifically, step S4 includes: Based on the projected vectors of node , using graph self-attention mechanism to calculate the adaptive attention weight of node to node in the homogenous subgraph corresponding to node , the expression is:
[0025]
[0026] wherein, denotes the attention score between the node belonging to node type and the node belonging to node type , It is a linear rectified function. Indicates node type The corresponding learnable parameter vector is used to perform linear transformations on the features to calculate the attention score; Indicates node type The corresponding learnable parameter matrix is used to project node features into the same dimensional space; Represents a node The vector after feature projection This indicates a splicing operation. Represents a node For nodes Adaptive attention weights Indicates belonging to node type nodes and belongs to node type nodes Attention scores between them.
[0027] Step S5: Use the number of path instances between node pairs in the heterogeneous graph as an auxiliary weight for aggregating nodes of the same type, optimize the adaptive attention weight, and weight and aggregate the optimized adaptive attention weight with the initial embedding vector of the neighbor in the homogeneous subgraph to obtain the embedding vector of the same type of node.
[0028] Specifically, step S5 includes: First, calculate the length between node pairs. Weighted adjacency matrix The expression is:
[0029] in, For node type indexing, Indicates that all nodes are of type 1 and The adjacency matrix between nodes, Indicates the cumulative multiplication symbol; Then, compute the nodes. and nodes Total number of path instances between The expression is:
[0030] in, Weighted adjacency matrix The Middle Line 1 The elements of the column, specifically representing the nodes in the heterogeneous graph. To the node Length is The number of path instances; Then, the auxiliary weight is obtained by normalizing the through a softmax function The expression is as follows:
[0031] wherein, the total number of path instances between the node and the node is represented by Based on the auxiliary weight and the adaptive attention weight, the optimized adaptive attention weight is calculated, and the expression is as follows:
[0032] wherein, the adaptive attention weight of the optimized node to the node is represented by is a control parameter, which is used to control how much structural information is added to the attention weight; Finally, the optimized adaptive attention weight is weighted and aggregated with the initial embedding vector of the neighbor in the homogeneous subgraph to obtain the same type node embedding vector, and the expression is as follows:
[0033] wherein, the same type node embedding vector obtained by aggregating the node is represented by is an activation function.
[0034] Step S6, the direct neighbors of the nodes in the heterogeneous graph are aggregated using the multi-head attention mechanism to obtain the cross-type node embedding vector, the same type node embedding vector and the cross-type node embedding vector are spliced to form the final node embedding vector, the final node embedding vector is divided into user node embedding vector and movie node embedding vector according to different node types, the user node embedding vector and the movie node embedding vector are spliced, and then input into a multi-layer perception machine to obtain a recommendation value, and the user is recommended a movie according to the recommendation value.
[0035] wherein, step S6 specifically includes: Step S61, the direct neighbors of the node in the heterogeneous graph are aggregated using the multi-head attention mechanism to obtain the cross-type node embedding vector, and the expression is as follows:
[0036]
[0037]
[0038] in, Represents a node Its direct neighbor nodes Attention scores between and These are a learnable parameter vector and a parameter matrix, respectively. Represents a node Embedding vectors of nodes of the same type obtained through intra-type aggregation. Represents a node For nodes The normalized attention weights, Represents a node Its direct neighbor nodes Attention scores between In a heterogeneous graph, nodes represent nodes. The set of direct neighbors centered on the center Indicates the first The attention mechanism of the head calculates the nodes and nodes Attention weights between them The number of heads representing multi-head attention. Represents a node The cross-type node embedding vector obtained after type aggregation; Step S62: Concatenate the embedding vectors of nodes of the same type and the embedding vectors of nodes of different types to form the final node embedding vector, the expression of which is:
[0039] in, node The final node embedding vector obtained after concatenation will be used to embed nodes of different types. It can be divided into user node embedding vectors and movie node embedding vector ; Step S63: Embed the user node into the vector. and movie node embedding vector Concatenate the vectors to obtain the user-movie node pair representation vector. ,Will The input is fed into a multilayer perceptron to obtain the recommended value. The expression is:
[0040] in, and Let these represent the learnable parameter matrix and bias vector of the first layer of the multilayer perceptron, respectively. and respectively represent the learnable parameter matrix and bias vector of the second layer of the multi-layer perceptron, represents a RELU activation function, represents a Sigmoid activation function, which can map the recommendation value between (0, 1); Step S64, making movie recommendation for the user according to the recommendation value.
[0041] Specifically, in step S63, the recommendation value is obtained After that, the method further comprises: The loss value is calculated by using a binary cross-entropy loss function, and all learnable parameters are adjusted by using a backpropagation mechanism, and the expression of the loss value is
[0042]
[0043] wherein, represents the probability that there exists an edge between the user node and ; represents the probability that there exists an edge between the user node and the movie node ; represents the real label of the edge , if the edge exists, then , otherwise ; is a learnable parameter matrix for the edge type .
[0044] In summary, according to the movie recommendation method based on neighbor aggregation heterogeneous graph neural network according to the above embodiment, the following beneficial effects are obtained: (1) The modeling information loss is small: the traditional modeling method models the movie network as a homogeneous network, ignoring the heterogeneity of node types and the relationship between nodes, resulting in a large information loss. However, the present application fully considers the above characteristics, and models the movie network as a heterogeneous graph, thereby retaining rich semantic information.
[0045] (2) High-quality user and movie node representation: There are a large number of different types of nodes on the heterogeneous graph, and direct aggregation of them is easy to lose important information, resulting in low-quality user and movie node representation vectors. In addition, using meta-paths to extract information is easy to extract repeated node information, causing information redundancy. The application avoids aggregation redundancy by splicing the final node embedding vector obtained by embedding the same type of node obtained by aggregating the homogeneous subgraph neighbor nodes and the cross-type node embedding vector obtained by aggregating the direct neighbor of the heterogeneous graph, and can obtain high-quality user and movie node representation, effectively improving the learning performance.
[0046] (3) High-precision movie recommendation: The application uses a graph neural network and a multilayer perceptron to calculate the recommendation value between users and movies, better combines the heterogeneous graph topology structure information and the downstream task, and thus the recommendation value between users and movies is more accurate, realizing high-precision movie recommendation.
[0047] The above-described embodiments only express several embodiments of the application, and the description is more specific and detailed, but it cannot be understood as limiting the scope of the patent. It should be noted that for ordinary skilled persons in the art, without departing from the concept of the application, a number of modifications and improvements can be made, which are all within the protection scope of the application. Therefore, the protection scope of the patent of the application should be subject to the appended claims.
Claims
1. A movie recommendation method based on neighbor aggregation heterogeneous graph neural network, characterized in that, The method comprises the following steps: Step S1, reading a user-movie database, constructing a heterogeneous graph of user-movie, and constructing a corresponding homogeneous subgraph for each node according to the distance between nodes of the same type in the heterogeneous graph; Step S2, using random walk on the heterogeneous graph to obtain a set of node sequences, and inputting the set of node sequences into a skip-gram model to obtain an initial embedding vector of each node; Step S3, based on the initial embedding vector of each node, embedding different types of nodes into the same vector space to obtain a vector after projecting the feature of each node; Step S4, based on the vector after projecting the feature of each node, using a graph self-attention mechanism to calculate an adaptive attention weight for the neighbor nodes in the homogeneous subgraph corresponding to the node; Step S5, using the number of path instances between node pairs in the heterogeneous graph as an auxiliary weight for aggregating nodes of the same type, optimizing the adaptive attention weight, and weighting and aggregating the optimized adaptive attention weight and the initial embedding vector of the neighbor nodes in the homogeneous subgraph to obtain a same-type node embedding vector; Step S6, using a multi-head attention mechanism to aggregate the direct neighbors of the nodes in the heterogeneous graph to obtain a cross-type node embedding vector, concatenating the same-type node embedding vector and the cross-type node embedding vector to form a final node embedding vector, dividing the final node embedding vector into a user node embedding vector and a movie node embedding vector according to different node types, inputting the user node embedding vector and the movie node embedding vector after concatenation into a multi-layer perception machine to obtain a recommendation value, and performing movie recommendation for the user according to the recommendation value.
2. The movie recommendation method based on neighbor aggregated heterogeneous graph neural network according to claim 1, wherein, Step S1 specifically comprises: Step S11, reading the user-movie database, constructing a user-movie heterogeneous graph , wherein, denotes a set of nodes, denotes a set of edges, denotes a set of node types, denotes a set of edge types; Step S12: Use breadth-first search to find the node. The distance is All neighboring nodes within it are nodes. Corresponding isoproton diagram Construct a node set using the following expression: wherein, denotes a set of nodes of the homoproton graph, and denote a node type of the node and the node respectively, denotes a distance between the node and the node ; is a hyperparameter denoting an order of extracting subgraphs; Step S13, for the same proton map The edge set is constructed and divided into two parts. The first part is the edge set reserved in the heterogeneous graph between nodes of the same type The expression is: wherein, is an edge between nodes and nodes ; The second part is for the nodes in the homogeneous graph and the nodes , if there is a path between the two nodes in the heterogeneous graph, and , , denotes the set of the same type of nodes that have a path with the node in the heterogeneous graph, and the path length is the shortest, then an edge is added between the node and the node , thereby forming an edge set , and the expression is: homogeneous graph of the edge set by and the union of which is expressed by 。 3. The movie recommendation method based on neighbor aggregated heterogeneous graph neural network according to claim 2, characterized in that, Step S2 specifically comprises: First, the context structure of each node is extracted by using random walk to sample nodes in the heterogeneous graph, wherein each node in the heterogeneous graph is sequentially taken as a starting node, and a node is randomly sampled from the neighbors of the starting node as a next walk node, and the expression is as follows: wherein, represents a set of node sequences obtained by random walk sampling, represents a random walk sampling operation, represents a starting node of a random walk, represents a length of a random walk; Then, the node sequence set sampled by random walk is input into the skip-gram model to obtain the initial embedding vector of the node, expression: wherein, represents an embedding matrix consisting of initial embedding vectors of all nodes, represents the total number of nodes in the heterogeneous graph, , , respectively represent initial embedding vectors of node 1, node 2, node , represents a transpose, represents a skip-gram model.
4. The movie recommendation method based on neighbor aggregated heterogeneous graph neural network according to claim 3, characterized in that, Step S3 specifically comprises: Based on the initial embedding vectors of each node, a learnable parameter matrix is constructed for each node type in the heterogeneous graph for feature projection, so as to map different types of node embeddings to the same vector space. For a node of a node type , the expression of the feature projection is: wherein, is a node characteristic projection vector, is a node initial embedding vector of the node is a learnable parameter matrix of the linear transformation of the type node.
5. The movie recommendation method based on neighbor aggregated heterogeneous graph neural network according to claim 4, characterized in that, Step S4 specifically comprises: based on the node the vector after feature projection, at the node the corresponding homogeneous subgraph In this way, the graph self-attention mechanism is used to calculate the adaptive attention weight of the node to the node , and the expression is: wherein, denotes the attention score between a node of node type and a node of node type , is a linear rectification function, denotes the corresponding learnable parameter vector for node type , denotes the corresponding learnable parameter matrix for node type , denotes the vector after feature projection of node , denotes the concatenation operation, denotes the adaptive attention weight of node for node , denotes the attention score between a node of node type and a node of node type .
6. The movie recommendation method based on neighbor aggregated heterogeneous graph neural network according to claim 5, characterized in that, Step S5 specifically comprises: First, the weighted adjacency matrix between pairs of computing nodes of length is computed, expressed as: wherein, is an index of a node type, represents an adjacency matrix between nodes of all node types and represents a multiplication symbol; Then, the total number of path instances between the computing node and the node is calculated , expressed as: wherein is a weighted adjacency matrix in the row in the column element; Then, the auxiliary weight is obtained by normalizing the softmax function on , and the expression is as follows: wherein, represents the total number of path instances between the node and the node . Based on auxiliary weights With adaptive attention weights, the optimized adaptive attention weights are calculated, and the expression is: wherein, represents the optimized node adaptation attention weights of the node is a control parameter; Finally, the optimized adaptive attention weight is weighted and aggregated with the initial embedding vector of the neighbor nodes in the homogeneous subgraph to obtain a same-type node embedding vector, and the expression is as follows: wherein, representing a node a same-type node embedding vector obtained by aggregating within a type, represents an activation function.
7. The movie recommendation method based on neighbor aggregated heterogeneous graph neural network according to claim 6, characterized in that, Step S6 specifically comprises: Step S61, for each node The cross-type node embedding vector is obtained by aggregating its direct neighbors in the heterogeneous graph using the multi-head attention mechanism, and the expression is as follows: wherein, denotes the attention score between a node and its direct neighbor node , and are a learnable parameter vector and parameter matrix respectively, denotes the same-type node embedding vector of a node obtained through intra-type aggregation, denotes the normalized attention weight of a node to a node , denotes the attention score between a node and its direct neighbor node , denotes the direct neighbor set centered on a node in a heterogeneous graph, denotes the attention weight between a node and a node calculated by the attention mechanism of the th head, denotes the number of heads of multi-head attention, denotes the cross-type node embedding vector of a node obtained through inter-type aggregation; Step S62, concatenating the same-type node embedding vector and the cross-type node embedding vector to form a final node embedding vector, and the expression is as follows: wherein, nodes The final node embedding vectors obtained by concatenation are divided into user node embedding vectors and movie node embedding vectors according to different node types. ; Step S63, embedding the user node into a vector and the movie node into a vector Concatenating, obtaining a user-movie node pair representation vector , Inputting into a multi-layer perception to obtain a recommendation value , the expression is: wherein, and respectively represent the learnable parameter matrix and bias vector of the first layer of the multi-layer perceptron, and respectively represent the learnable parameter matrix and bias vector of the second layer of the multi-layer perceptron, represents a RELU activation function, represents a Sigmoid activation function; Step S64, performing movie recommendation for the user according to the recommendation value. 8.The movie recommendation method based on neighbor aggregated heterogeneous graph neural network according to claim 7, characterized in that, In step S63, a recommended value is obtained After that, the method further comprises: The loss value is calculated using a binary cross-entropy loss function, and all learnable parameters are adjusted using a backpropagation mechanism. The loss value is expressed as: wherein, denotes the probability that there exists an edge of type between user nodes and , denotes the set of edges used in the model training process, denotes the true label of edge , is a learnable parameter matrix for edge type .
Citation Information
Patent Citations
Heterogeneous graph classification method based on double-layer attention mechanism
CN112381179A
Android malicious application detection method and system based on heterogeneous network
CN112487421A
Movie recommendation method based on attribute heterogeneous information network embedding
CN112948625A
Self-adaptive recommendation method and device based on graph attention network
CN115309989A
Recommendation method of lightweight graph convolutional neural network based on pre-training
CN115880024A