A movie 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
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-23
- Publication Date
- 2026-02-10
- 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.
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, combine graph self-attention and multi-head attention mechanisms, optimize adaptive attention weights, aggregate node embedding vectors, and utilize the heterogeneous graph topology information for movie recommendation.
It effectively reduces information loss, improves the quality of user and movie node representations, and achieves high-precision movie recommendations.
Smart Images

Figure CN120994872B_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
[0002] 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.
[0003] 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, in the process of node aggregation, directly using attention mechanism may ignore important potential structural information such as the number of paths between nodes, which can be utilized to improve node representation learning. SUMMARY
[0004] 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.
[0005] A movie recommendation method based on neighbor aggregation heterogeneous graph neural network, comprising:
[0006] 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;
[0007] 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 initial embedding vectors of each node;
[0008] 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;
[0009] 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;
[0010] Step S5, using the number of path instances between node pairs in the heterogeneous graph as an auxiliary weight for aggregating the same type of nodes, optimizing the adaptive attention weight, and weighting and aggregating the optimized adaptive attention weight and the neighbor initial embedding vector in the homogeneous subgraph to obtain the same type of node embedding vector;
[0011] 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 of 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.
[0012] The movie recommendation method based on neighbor aggregation heterogeneous graph neural network provided by the application has the following beneficial effects:
[0013] (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 node relationships, resulting in a large amount of information loss. The application fully considers the above characteristics, and models the movie network as a heterogeneous graph, retaining rich semantic information.
[0014] (2) High-quality user and movie node representation: the heterogeneous graph has a large number of different types of nodes, and direct aggregation of them 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 concatenates the same type of node embedding vector obtained by aggregating the neighbor nodes in the homogeneous subgraph and the cross-type node embedding vector obtained by aggregating the direct neighbors in the heterogeneous graph to obtain the final node embedding vector, avoiding aggregation of redundant nodes, and obtaining high-quality user and movie node representation, effectively improving the learning performance.
[0015] (3) High-precision movie recommendation: the application uses a graph neural network and a multi-layer perception machine to calculate the recommendation value between users and movies, better combining the heterogeneous graph topological structure information and the downstream task, so that the recommendation value between users and movies is more accurate, and high-precision movie recommendation is realized. BRIEF DESCRIPTION OF DRAWINGS
[0016] Figure 1 The flowchart of the movie recommendation method based on neighbor aggregation heterogeneous graph neural network provided by the embodiment of the application is shown. DETAILED DESCRIPTION
[0017] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain embodiments of the present invention, and should not be construed as limiting the present invention.
[0018] Please see Figure 1 The embodiments of the present invention provide a movie recommendation method based on a neighbor-aggregated heterogeneous graph neural network, including steps S1-S6:
[0019] Step S1: Read the user-movie database, construct a heterogeneous graph of user-movies, and construct a corresponding homogeneous subgraph for each node based on the distance between nodes of the same type in the heterogeneous graph.
[0020] Specifically, step S1 includes:
[0021] Step S11: Read the user-movie database and construct a heterogeneous graph of user-movies. , ,in, Represents a set of nodes. The nodes in the text represent users or movies. Describe the set of edges. The edges in the diagram represent the relationships between nodes. This represents a collection of node types, including user node types and movie node types. A set representing edge types.
[0022] 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:
[0023]
[0024] in, Represents the set of nodes in a homoprotic subgraph. and Representing nodes respectively and nodes Node type, Represents a node and nodes The distance between them; It is a hyperparameter that represents the order of the extracted subgraph;
[0025] Step S13 is the isoproton diagram. The construction of the edge set consists of two parts. The first part is to preserve the edges between nodes of the same type in the heterogeneous graph to form the edge set. The expression is:
[0026]
[0027] in, It is a node and nodes The edges connecting them;
[0028] The second part concerns the isoproton diagram. Nodes in and nodes If there is a path between these two nodes in a heterogeneous graph, and , Represents nodes In a heterogeneous graph, if a path exists and the set of nodes of the same type with the shortest path length is found, then the node is assigned a unique identifier. and nodes Adding edges between them forms an edge set. The expression is:
[0029]
[0030] Homoproton diagram edge set Depend on and The union of the sets is expressed as:
[0031] .
[0032] Step S2: Use random walk on the heterogeneous graph to obtain a set of node sequences, and input them into the jump word model to obtain the initial embedding vector of each node.
[0033] Specifically, step S2 includes:
[0034] First, a random walk approach is used to sample nodes in the heterogeneous graph to extract the context structure of each node. Each node in the heterogeneous graph is used as the starting node, and its neighbors are randomly sampled as the next node to be walked. The expression is as follows:
[0035]
[0036] in, This represents the set of node sequences obtained from random walk sampling. This indicates a random walk sampling operation. This represents the starting node of the random walk. Indicates the length of the random walk;
[0037] Then, the set of node sequences obtained from the random walk sampling Inputting this into the jump character model yields the initial embedding vector for each node, expressed as:
[0038]
[0039] in, Let represent the embedding matrix consisting of the initial embedding vectors of all nodes. This represents the total number of nodes in a heterogeneous graph. , , Representing node 1, node 2, and node respectively. The initial embedding vector, Indicates transpose. This represents the jump character model.
[0040] Step S3: Based on the initial embedding vector of each node, the embeddings of different types of nodes are mapped to the same vector space to obtain the vector after feature projection of each node.
[0041] Specifically, step S3 includes:
[0042] 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, thereby mapping the embeddings of different node types to the same vector space. For node types of nodes The expression for feature projection is:
[0043]
[0044] in, It is a node The vector after feature projection It is a node The initial embedding vector, yes The learnable parameter matrix of the linear transformation of type nodes.
[0045] Step S4: Based on the vectors projected from the features of each node, the adaptive attention weights are calculated for the neighboring nodes in the homogeneous subgraph corresponding to the node using the graph self-attention mechanism.
[0046] Specifically, step S4 includes:
[0047] Based on nodes The vector after feature projection, at the node The corresponding isoproton diagram In the process, a graph self-attention mechanism is used to compute nodes. For nodes The adaptive attention weights are expressed as follows:
[0048]
[0049]
[0050] in, Indicates belonging to node type nodes and belongs to node type nodes Attention scores between 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.
[0051] 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.
[0052] Specifically, step S5 includes:
[0053] First, calculate the length between node pairs. Weighted adjacency matrix The expression is:
[0054]
[0055] in, For node type indexing, Indicates that all nodes are of type 1 and The adjacency matrix between nodes, Indicates the cumulative multiplication symbol;
[0056] Then, compute the nodes. and nodes Total number of path instances between The expression is:
[0057]
[0058] in, Weighted adjacency matrix The Middle Line number The elements of the column, specifically representing the nodes in the heterogeneous graph. To the node Length is The number of path instances;
[0059] Next, the softmax function is used to... Auxiliary weights are obtained by normalization. The expression is:
[0060]
[0061] in, Represents a node and nodes The total number of path instances between them;
[0062] Based on auxiliary weights The optimized adaptive attention weights are calculated using the adaptive attention weights, and the expression is:
[0063]
[0064] in, Represents the optimized node For nodes Adaptive attention weights These are control parameters used to control how much structural information is added to the attention weights;
[0065] Finally, the optimized adaptive attention weights are weighted and aggregated with the initial embedding vectors of neighbors in the homogeneous subgraph to obtain the embedding vectors of nodes of the same type, as expressed in the following expression:
[0066]
[0067] in, Represents a node Embedding vectors of nodes of the same type obtained through intra-type aggregation. This represents the activation function.
[0068] Step S6: Use a multi-head attention mechanism to aggregate the direct neighbors of nodes in the heterogeneous graph to obtain cross-type node embedding vectors. Concatenate the same-type node embedding vectors and cross-type node embedding vectors to form the final node embedding vector. According to different node types, the final node embedding vector is divided into user node embedding vectors and movie node embedding vectors. After concatenating the user node embedding vectors and movie node embedding vectors, input them into a multilayer perceptron to obtain recommendation values. Based on the recommendation values, movie recommendations are made for users.
[0069] Specifically, step S6 includes:
[0070] Step S61, for nodes The cross-type node embedding vector is obtained by aggregating its direct neighbors in the heterogeneous graph using a multi-head attention mechanism, as expressed by:
[0071]
[0072]
[0073]
[0074] 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;
[0075] 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:
[0076]
[0077] 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 ;
[0078] 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:
[0079]
[0080] in, and Let these represent the learnable parameter matrix and bias vector of the first layer of the multilayer perceptron, respectively. and Let these represent the learnable parameter matrix and bias vector of the second layer of the multilayer perceptron, respectively. Represents the ReLU activation function. This represents the Sigmoid activation function, which maps recommended values to the range (0,1).
[0081] Step S64: Recommend movies to users based on the recommendation value.
[0082] Specifically, the recommended value is obtained in step S63. Subsequently, the method further includes:
[0083] The loss value is calculated using a binary cross-entropy loss function, and all learnable parameters are adjusted using a backpropagation mechanism. The expression is:
[0084]
[0085]
[0086] in, Represents user node and There are Type of edge The probability of; This represents the set of edges used during model training, including various types of edges used for training. Representing an edge The true label, if the edge If it exists, then ,otherwise ; It is for edge type The learnable parameter matrix.
[0087] In summary, the movie recommendation method based on a neighbor-aggregated heterogeneous graph neural network according to the above embodiments has the following beneficial effects:
[0088] (1) Less information loss in modeling: Traditional modeling methods model the movie network as a homogeneous network, ignoring the heterogeneity of node types and relationships between nodes, resulting in significant information loss. In contrast, this invention fully considers the above characteristics and models the movie network as a heterogeneous graph, thus preserving rich semantic information.
[0089] (2) High-quality user and movie node representations: Heterogeneous graphs contain a large number of nodes of different types. Direct aggregation of these nodes can easily lead to the loss of important information, resulting in low-quality user and movie node representation vectors. Furthermore, using meta-paths for information extraction can easily extract duplicate node information, causing information redundancy. This invention avoids the aggregation of redundant nodes by concatenating the embedding vectors of the same type of nodes obtained by aggregating the neighboring nodes of the coproton graph with the embedding vectors of cross-type nodes obtained by aggregating the direct neighbors of the heterogeneous graph. This results in high-quality user and movie node representations and effectively improves learning performance.
[0090] (3) High-precision movie recommendation: This invention uses graph neural networks and multilayer perceptrons to calculate the recommendation value between users and movies, which better combines the information of heterogeneous graph topology with downstream tasks, so that the recommendation value between users and movies is more accurate, thus achieving high-precision movie recommendation.
[0091] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.
Claims
1. A movie recommendation method based on a neighbor-aggregated heterogeneous graph neural network, characterized in that, include: Step S1: Read the user-movie database, construct a heterogeneous graph of user-movies, and construct a corresponding homogeneous subgraph for each node based on the distance between nodes of the same type in the heterogeneous graph. Step S2: Use random walk on the heterogeneous graph to obtain a set of node sequences, and input them into the jump word model to obtain the initial embedding vector of each node; Step S3: Based on the initial embedding vector of each node, the embeddings of different types of nodes are mapped to the same vector space to obtain the vector after feature projection of each node; Step S4: Based on the vectors projected from the features of each node, use the graph self-attention mechanism to calculate the adaptive attention weights for the neighboring nodes in the homogeneous subgraph corresponding to the node. 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. Step S6: Use a multi-head attention mechanism to aggregate the direct neighbors of nodes in the heterogeneous graph to obtain cross-type node embedding vectors. Concatenate the same-type node embedding vectors and cross-type node embedding vectors to form the final node embedding vector. According to different node types, the final node embedding vector is divided into user node embedding vectors and movie node embedding vectors. After concatenating the user node embedding vectors and movie node embedding vectors, input them into a multilayer perceptron to obtain recommendation values. Based on the recommendation values, movie recommendations are made for users. Step S1 specifically includes: Step S11: Read the user-movie database and construct a heterogeneous graph of user-movies. , ,in, Represents a set of nodes. Describe the set of edges. A collection representing node types. A set representing the edge type; 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: in, Represents the set of nodes in a homoprotic subgraph. and Representing nodes respectively and nodes Node type, Represents a node and nodes The distance between them; It is a hyperparameter that represents the order of the extracted subgraph; Step S13 is the isoproton diagram. The construction of the edge set consists of two parts. The first part is to preserve the edges between nodes of the same type in the heterogeneous graph to form the edge set. The expression is: in, It is a node and nodes The edges connecting them; The second part concerns the isoproton diagram. Nodes in and nodes If there is a path between these two nodes in a heterogeneous graph, and , Represents nodes In a heterogeneous graph, if a path exists and the set of nodes of the same type with the shortest path length is found, then the node is assigned a unique identifier. and nodes Adding edges between them forms an edge set. The expression is: Homoproton diagram edge set Depend on and The union of the sets is expressed as: 。 2. The movie recommendation method based on a neighbor-aggregated heterogeneous graph neural network according to claim 1, characterized in that, Step S2 specifically includes: First, a random walk approach is used to sample nodes in the heterogeneous graph to extract the context structure of each node. Each node in the heterogeneous graph is used as the starting node, and its neighbors are randomly sampled as the next node to be walked. The expression is as follows: in, This represents the set of node sequences obtained from random walk sampling. This indicates a random walk sampling operation. This represents the starting node of the random walk. Indicates the length of the random walk; Then, the set of node sequences obtained from the random walk sampling Inputting this into the jump character model yields the initial embedding vector for each node, expressed as: in, Let represent the embedding matrix consisting of the initial embedding vectors of all nodes. This represents the total number of nodes in a heterogeneous graph. , , Representing node 1, node 2, and node respectively. The initial embedding vector, Indicates transpose. This represents the jump character model.
3. The movie recommendation method based on a neighbor-aggregated heterogeneous graph neural network according to claim 2, characterized in that, Step S3 specifically 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, thereby mapping the embeddings of different node types to the same vector space. For node types of nodes The expression for feature projection is: in, It is a node The vector after feature projection It is a node The initial embedding vector, yes The learnable parameter matrix of the linear transformation of type nodes.
4. The movie recommendation method based on a neighbor-aggregated heterogeneous graph neural network according to claim 3, characterized in that, Step S4 specifically includes: Based on nodes The vector after feature projection, at the node The corresponding isoproton diagram In the process, a graph self-attention mechanism is used to compute nodes. For nodes The adaptive attention weights are expressed as follows: in, Indicates belonging to node type nodes and belongs to node type nodes Attention scores between It is a linear rectified function. Indicates node type The corresponding learnable parameter vector, Indicates node type The corresponding learnable parameter matrix, 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.
5. The movie recommendation method based on a neighbor-aggregated heterogeneous graph neural network according to claim 4, characterized in that, Step S5 specifically includes: First, calculate the length between node pairs. Weighted adjacency matrix The expression is: 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: in, Weighted adjacency matrix The Middle Line number Column elements; Next, the softmax function is used to... Auxiliary weights are obtained by normalization. The expression is: in, Represents a node and nodes The total number of path instances between; Based on auxiliary weights The optimized adaptive attention weights are calculated using the adaptive attention weights, and the expression is: in, Represents the optimized node For nodes Adaptive attention weights For control parameters; Finally, the optimized adaptive attention weights are weighted and aggregated with the initial embedding vectors of neighbors in the homogeneous subgraph to obtain the embedding vectors of nodes of the same type, as expressed in the following expression: in, Represents a node Embedding vectors of nodes of the same type obtained through intra-type aggregation. This represents the activation function.
6. The movie recommendation method based on a neighbor-aggregated heterogeneous graph neural network according to claim 5, characterized in that, Step S6 specifically includes: Step S61, for nodes The cross-type node embedding vector is obtained by aggregating its direct neighbors in the heterogeneous graph using a multi-head attention mechanism, as expressed by: 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: in, node The final node embedding vector obtained after concatenation will be used to embed nodes of different types. 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: in, and Let these represent the learnable parameter matrix and bias vector of the first layer of the multilayer perceptron, respectively. and Let these represent the learnable parameter matrix and bias vector of the second layer of the multilayer perceptron, respectively. Represents the ReLU activation function. This represents the Sigmoid activation function; Step S64: Recommend movies to users based on the recommendation value.
7. The movie recommendation method based on a neighbor-aggregated heterogeneous graph neural network according to claim 6, characterized in that, The recommended value is obtained in step S63. Subsequently, the method further includes: The loss value is calculated using a binary cross-entropy loss function, and all learnable parameters are adjusted using a backpropagation mechanism. The expression is: in, Represents user node and There are Type of edge The probability, This represents the set of edges used during model training. Representing an edge The true label, It is for edge type The learnable parameter matrix.
Citation Information
Patent Citations
Heterogeneous graph classification method based on double-layer attention mechanism
CN112381179A
Self-adaptive recommendation method and device based on graph attention network
CN115309989A