Knowledge graph high-order relationship prediction method and system based on multi-view decoder
The multi-view decoder method is used to reconstruct the meta-path view of the knowledge graph, which solves the shortcomings of the existing technology in processing multiple types of node relationships, realizes the prediction of high-order relationships in the knowledge graph, and improves the completion ability of the knowledge graph. .
Patent Information
- Application Number
- CN202311175115.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-13
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2043-09-13
AI Technical Summary
Existing knowledge graph representation learning methods have problems when dealing with one-to-many, many-to-one and many-to-many relationships, and ignore the importance of high-order link relationships, and cannot effectively predict high-order relationships between multiple types of nodes.
The multi-view decoder method is used to reconstruct multiple link probability matrices based on meta-paths through the data processing module, knowledge graph encoder and multi-view decoder, and the TransE model is used for node vector initialization, combined with double-layer heterogeneous graph attention. The neural network generates node embeddings and updates model parameters through multi-view decoder projections and loss calculations, enabling high-order relationship predictions.
It can effectively predict high-order relationships between multiple types of nodes, improve the completion ability of knowledge graphs, and be able to predict first-order and high-order link relationships.
Smart Images

Figure CN117196025B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graph technology, and specifically to a knowledge graph high-order relationship prediction method and system based on a multi-view decoder. Background Art
[0002] Knowledge graphs represent a knowledge base as a directed graph, where nodes and edges represent entities and relationships between entities, respectively. Knowledge graphs have many applications, such as semantic search, dialog generation, and question-answering systems. However, even the most advanced knowledge graphs are incomplete. Relation prediction, which is the task of predicting missing relationships between entities based on the existing knowledge information in the knowledge graph, is a promising and widely studied task aimed at addressing the incompleteness of knowledge graphs.
[0003] Existing methods use knowledge graph representation learning methods to vectorize nodes and relationships and then perform reasoning. The purpose of representation learning is to map entities and relationships in the knowledge graph to a low-dimensional dense vector space, transforming traditional logic and symbol-based operations into numerical vector calculations. Models based on representation learning have achieved good results in tasks such as link prediction and node classification due to their simplicity and efficiency, and are widely used in fields such as knowledge graph completion and entity alignment.
[0004] At present, the commonly used representation learning model based on transfer distance in knowledge graph representation learning is represented by the TransE model, which regards the relationship in the triple as a translation operation between the head entity and the tail entity. The basic assumption is that the established fact triple (h, r, t) should satisfy the equation h+r=t. TransE is very effective for one-to-one relationships, but there are certain problems when dealing with one-to-many, many-to-one and many-to-many problems. Many models have improved TransE, but only consider the triple structure information in the knowledge graph. There is still a lot of other information related to entities and relationships that has not been effectively applied, resulting in unclear semantic information of entities and relationships. In addition, using graph neural networks for embedded representation of knowledge graphs and applying them to knowledge graph tasks is a very popular method at present.
[0005] However, in the existing research on knowledge graph relationship prediction based on representation learning, on the one hand, most of the existing methods learn the representation of features of multiple types of nodes, and then predict different relationships in the same semantic space, which cannot effectively predict multiple relationships; on the other hand, the existing methods focus more on the prediction of first-order link relationships, ignoring the importance of predicting high-order link relationships. The first-order relationship refers to the direct connection relationship between entities defined by the knowledge graph ontology, while the high-order link relationship refers to the multi-hop relationship between entities, that is, a hidden path connects two entities. Summary of the invention
[0006] The purpose of the present invention is to provide a knowledge graph high-order relationship prediction method and system based on a multi-view decoder to solve the problems raised in the above background technology.
[0007] To achieve the above object, the present invention provides the following technical solution: a knowledge graph high-order relationship prediction method based on a multi-view decoder, specifically comprising the following steps:
[0008] S1: Import the knowledge graph to be predicted into the knowledge graph high-order relationship prediction model. After processing, reconstruct multiple link probability matrices based on meta-path views;
[0009] The knowledge graph high-order relationship prediction model includes a data processing module, a knowledge graph encoder, and a multi-view decoder. The data processing method of the knowledge graph high-order relationship prediction model specifically includes the following steps:
[0010] S11: input the knowledge graph to be predicted into the data processing module for processing, and generate multiple meta-path-based views and initialization vector representations of nodes;
[0011] S12: the knowledge graph encoder processes the initialization vector representation of the node to generate a node embedding;
[0012] S13: a multi-view decoder processes the node embedding and the multiple meta-path-based views to reconstruct multiple link probability matrices based on meta-path views;
[0013] S2: Filter the reconstructed multiple meta-path view-based link probability matrices using a threshold and a mask matrix, and output a prediction result.
[0014] Preferably, the working mode of the data processing module in step S11 is specifically as follows:
[0015] Step 1: Define the high-order relations and other link relations of the knowledge graph to be predicted as p meta-paths, and reconstruct the sub-graph of the knowledge graph to be predicted according to the defined p meta-paths, generate p meta-path-based views, and obtain the link matrix between the nodes in the view as {A i |i=1…p};
[0016] Step 2: Use the TransE model to initialize the vectors of the triples in the knowledge graph to be predicted, and obtain the initialization vector representation of the nodes in the knowledge graph;
[0017] Where, p is the number of meta-paths.
[0018] Preferably, the working mode of the knowledge graph encoder in step S12 is specifically to use a two-layer heterogeneous graph attention neural network to hierarchically aggregate the initialization vector representation of the input node through the neighborhood features based on the meta-path to generate a node embedding;
[0019] The node is embedded into a new node feature representation matrix Z.
[0020] Preferably, the working mode of the multi-view decoder in step S13 is:
[0021] Step 1: Based on the meta-path defined by the knowledge graph data processing module and the link matrix based on the meta-path view {A i |i=1…p}, the new node feature representation matrix Z is divided into node representation matrices {Z based on p views i |i=1…p};
[0022] Step 2: Through p trainable meta-path mapping matrices {W i |i=1…p}, the node representation matrix {Z i |i=1…p} is projected into the corresponding meta-path space as the node representation matrix {Z′ i |i=1…p};
[0023] Step 3: Use vector inner product and Sigmoid activation function to represent the matrix {Z′ i |i=1…p} to obtain the link probability matrix represented by the node vector in the i-element path space
[0024] Preferably, before step S2, the node vector is used to represent the link probability matrix in the i-element path space. Link matrix based on meta-path view i |i=1…p} to calculate the loss. If the loss value does not meet the standard, the gradient descent algorithm is used to update the parameters of the knowledge graph high-order relationship prediction model and re-obtain the link probability matrix represented by the node vector in the i-element path space. The loss value is calculated until the loss value reaches the standard. If the loss value reaches the standard, step S2 is performed.
[0025] Preferably, the loss calculation formula is:
[0026] Where: y i Represents the meta-path link matrix A i The elements in are either 0 or 1. Represents the reconstructed meta-path link matrix obtained by decoder i The elements in and the value range is between (0, 1);
[0027] Among them, the comprehensive loss of all meta-path based views is:
[0028] Where: i is the hyperparameter of the loss function based on the view of meta-path i, and let
[0029] Preferably, the mask matrix in step S2 is a link matrix between nodes in the view {A i |i=1…p} is generated.
[0030] Preferably, a knowledge graph high-order relationship prediction system based on a multi-view decoder is used to implement a knowledge graph high-order relationship prediction method based on a multi-view decoder, including: a data processing module for processing a knowledge graph to be predicted, a knowledge graph encoder module for processing output data of the data processing module, a multi-view decoder module for processing output data of the knowledge graph encoder module, and a prediction module for calculating prediction results based on the output data of the multi-view decoder module.
[0031] Compared with the prior art, the beneficial effects of the present invention are as follows: in this application, the TransE model is used to initialize the node vectors of the triples in the knowledge graph, and then the high-order relationships and other link relationships are defined as multiple meta-paths, and multiple meta-path-based views are divided; a two-layer heterogeneous graph attention neural network is used to perform hierarchical aggregation through meta-path-based neighborhood features to generate new node embeddings; in the multi-view decoder, the mapping matrix first projects the node representation into a specific meta-path space, and then reconstructs multiple link probability matrices based on meta-path views; the reconstructed link probability matrix based on the meta-path view and the true link matrix are used to calculate the loss, and the gradient descent algorithm is used to update the model parameters; finally, the threshold and mask matrix are used to filter the link probability matrix of the view to realize the prediction of high-order relationships between nodes of various types, and the knowledge graph is completed by predicting the high-order relationships between entities in the knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is a schematic diagram of the structure of the knowledge graph high-order relationship prediction model of the present invention;
[0033] Figure 2 It is a schematic diagram of the process flow of the knowledge graph high-order relationship prediction method of the present invention;
[0034] Figure 3 This is a schematic diagram of the knowledge graph data processing flow of the present invention;
[0035] Figure 4Schematic diagram of the prediction system structure of the present invention. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] Example 1
[0038] The method for predicting high-order relations in a knowledge graph based on a multi-view decoder specifically comprises the following steps: importing the knowledge graph to be predicted into a knowledge graph high-order relation prediction model, and after processing, reconstructing multiple link probability matrices based on meta-path views;
[0039] Among them, see Figure 1 ,The knowledge graph high-order relationship prediction model includes a data processing module, a knowledge graph encoder, and a multi-view decoder.
[0040] See also Figure 2 , Knowledge graph data processing: The content of knowledge graph data processing includes the following aspects:
[0041] (1) Define multiple meta-paths based on the high-order relationships that need to be predicted and the knowledge graph schema;
[0042] (2) The knowledge graph required by the model is reconstructed into subgraphs according to the defined meta-paths, p meta-path-based views are generated, and the link matrix between the nodes in the views is obtained as {A i |i=1…p}, where p is the number of meta-paths.
[0043] (3) Use the TransE model to initialize the knowledge tuples in the knowledge graph and obtain the initialization vector representation of the nodes in the knowledge graph.
[0044] See also Figure 1 and Figure 2 , Knowledge Graph Encoder:
[0045] (1) A two-layer heterogeneous graph attention neural network (HAN) is used to hierarchically aggregate the input knowledge graph data through meta-path-based neighborhood features to generate node embeddings and obtain a new node feature representation matrix Z.
[0046] See also Figure 1 , multi-view decoder:
[0047] The decoder module uses p decoders to reconstruct the link relationship between nodes in p views constructed based on p meta-paths defined by the knowledge graph data. The specific operations are:
[0048] (1) According to the meta-path defined by the knowledge graph data processing module and the link matrix based on the meta-path view {A i |i=1…p}, the feature representation matrix Z obtained by the encoder is divided into node representation matrices {Z i |i=1…p}.
[0049] (2) Through p trainable meta-path mapping matrices {W i |i=1…p}, the node represents the matrix {Z i |i=1…p} is projected into the corresponding meta-path space as the node representation matrix {Z′ i |i=1…p}.
[0050] (3) Obtain the link probability matrix of the node vector representation in the i-element path space through vector inner product and Sigmoid activation function
[0051] See also Figure 1 , loss function design:
[0052] The ultimate goal of the model is to reconstruct the p views generated by the input knowledge graph data based on the meta-path, that is, to reconstruct the link matrix {A i |i=1…p}; therefore, the loss function is used to evaluate the true meta-path link matrix {A i |i=1…p) and the meta-path link probability matrix reconstructed by p decoders The difference between.
[0053] It should be noted that if the difference does not meet the standard, the gradient descent algorithm is used to update the parameters of the knowledge graph high-order relationship prediction model and re-obtain the link probability matrix represented by the node vector in the i-element path space. Calculate the loss value until the difference meets the standard. If the loss value meets the standard, proceed to the next step.
[0054] Therefore, the loss of a single view decoder can be calculated using the cross entropy function, as follows:
[0055]
[0056] Among them, y i Represents the meta-path link matrix A i An element in (0 or 1), Represents the reconstructed meta-path link matrix obtained by decoder i The elements in and the value range is between (0, 1). The comprehensive loss of all meta-path-based views is:
[0057]
[0058] λ i is the hyperparameter of the loss function based on the view of meta-path i, and let
[0059] Relationship prediction:
[0060] By reconstructing the meta-path based view using the multi-view decoder, we can get the link probability matrix between nodes based on a specific meta-path. By setting a threshold for filtering, and using the link matrix of the real meta-path view to generate a mask matrix for filtering again, we can get the link probability between nodes, and then we can get the link relationship by matching it with the corresponding meta-path view. The formula is:
[0061]
[0062] masked(A i ) function converts the matrix A i The element at position 1 is set to 0 and the element at position 0 is set to 1. The function converts the matrix The element is less than α i is set to 0 and greater than α i The original information is retained. F1ementwise() is an element-wise product operation, that is, the corresponding elements of the two matrices are multiplied.
[0063] {α i |i=1…p} are hyperparameters, which are the filtering thresholds of the p reconstructed link probability matrices based on the meta-path view.
[0064] Relationship prediction matrix Q i The non-zero position of the element in represents the link probability between the corresponding nodes through the meta-path i. By defining the meta-path, the relationship prediction matrix Q is obtained i It can not only predict first-order link relationships, but also predict high-order link relationships.
[0065] See also Figure 4 A knowledge graph high-order relationship prediction system based on a multi-view decoder is used to implement a knowledge graph high-order relationship prediction method based on a multi-view decoder, including: a data processing module, a knowledge graph encoder module, a multi-view decoder module and a prediction module; the data processing module processes the knowledge graph to be predicted, and the data generated by the processing is processed by the knowledge graph encoder module and the multi-view decoder module in turn, and then imported into the prediction module to output the prediction result.
[0066] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. Knowledge graph high-order relationship prediction method based on multi-view decoder, Features: The specific steps include: S1: Import the knowledge graph to be predicted into the knowledge graph high-order relationship prediction model, and after processing, reconstruct multiple link probability matrices based on meta-path views. The knowledge graph is used for semantic search, dialogue generation, and question-answering systems. The knowledge graph high-order relationship prediction model includes a data processing module, a knowledge graph encoder, and a multi-view decoder. The data processing method of the knowledge graph high-order relationship prediction model specifically includes the following steps: S11: input the knowledge graph to be predicted into the data processing module for processing, and generate multiple meta-path-based views and initialization vector representations of nodes; S12: the knowledge graph encoder processes the initialization vector representation of the node to generate a node embedding; S13: a multi-view decoder processes the node embedding and the multiple meta-path-based views to reconstruct multiple link probability matrices based on meta-path views; S2: filtering the reconstructed multiple link probability matrices based on meta-path views using a threshold and a mask matrix, and outputting a prediction result; The working mode of the data processing module in step S11 is specifically as follows: Step 1: Define the high-order relations and other link relations of the knowledge graph to be predicted as p meta-paths, and reconstruct the subgraph of the knowledge graph to be predicted according to the defined p meta-paths, generate p meta-path-based views, and obtain the link matrix between the nodes in the view as ; Step 2: Use the TransE model to initialize the vectors of the triples in the knowledge graph to be predicted, and obtain the initialization vector representation of the nodes in the knowledge graph; Among them, p is the number of meta-paths; The working method of the knowledge graph encoder in step S12 is specifically to use a two-layer heterogeneous graph attention neural network to hierarchically aggregate the initialization vector representation of the input node through the neighborhood features based on the meta-path to generate a node embedding; Wherein, the node embedding is a new node feature representation matrix Z; The working mode of the multi-view decoder in step S13 is: Step 1: Based on the meta-path defined by the knowledge graph data processing module and the link matrix based on the meta-path view , the new node feature representation matrix Z is divided into node representation matrices based on p views ; Step 2: Mapping matrices through p trainable meta-paths , the node representation matrix Projected into the corresponding meta-path space as a node representation matrix ; Step 3: Represent the matrix of the node through vector inner product and Sigmoid activation function Processing is performed to obtain the link probability matrix of the node vector representation in the i-element path space .
2. According to claim 1, the knowledge graph high-order relationship prediction method based on multi-view decoder, Features: Before step S2, the node vector is used to represent the link probability matrix in the i-element path space. Link matrix with meta-path based view Perform loss calculation. If the loss value does not meet the standard, use the gradient descent algorithm to update the parameters of the knowledge graph high-order relationship prediction model and re-obtain the link probability matrix represented by the node vector in the i-element path space. The loss value is calculated until the loss value reaches the standard. If the loss value reaches the standard, step S2 is performed.
3. The knowledge graph high-order relationship prediction method based on multi-view decoder according to claim 2, Features: The formula for calculating the loss is: ; Where: Represents the meta-path link matrix The elements in are either 0 or 1. Indicates that the decoder The resulting reconstructed meta-path link matrix The elements in and the value range is between (0, 1); Among them, the comprehensive loss of all meta-path based views is: ; Where: Based on meta path The hyperparameters of the loss function of the view, and let .
4. The knowledge graph high-order relationship prediction method based on multi-view decoder according to claim 3, Features: The mask matrix in step S2 is composed of the link matrix between nodes in the view: generate.
5. A knowledge graph high-order relationship prediction system based on a multi-view decoder, used to implement the knowledge graph high-order relationship prediction method based on a multi-view decoder as described in any one of claims 1 to 4, Features: include: A data processing module for processing the knowledge graph to be predicted, a knowledge graph encoder module for processing the output data of the data processing module, a multi-view decoder module for processing the output data of the knowledge graph encoder module, and a prediction module for calculating the prediction result based on the output data of the multi-view decoder module.
