Knowledge graph induction reasoning method based on double-view learning
By introducing complementary learning of global graphs and local graphs into the knowledge graph, and using graph neural network to alternate iterations between local and global graphs, the problem that existing models cannot learn global semantic information is solved, and the performance of knowledge graph inductive reasoning and new entity reasoning capabilities are improved.
Patent Information
- Application Number
- CN202510538405.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-08-08
AI Technical Summary
The existing subgraph-based knowledge graph entity inductive reasoning model cannot learn global semantic information, resulting in poor inference results in dynamic scalable scenarios.
Using a dual-view learning method, a complementary learning model of local graphs and global graphs is constructed, and iterates alternately between local and global graphs through graph neural networks, and uses global graphs to learn global semantic information and supplement the shortcomings of local graphs.
Improve the performance of knowledge graph inductive reasoning, improve the reasoning ability of new entities, and solve the problem that existing models cannot learn global semantic information.
Smart Images

Figure CN120450007A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to knowledge graph reasoning technology, and specifically to a knowledge graph inductive reasoning method based on dual-view learning. Background Art
[0002] Data in a knowledge graph typically exists in the form of triples, specifically represented as (head entity, relationship, tail entity). A large number of triples form a vast network graph. Any object or concept in nature can be represented as an entity node in a knowledge graph, and any connection can be represented as an edge in the knowledge graph. For example, if a knowledge graph contains a triple (Socrates, born in, Athens), the semantics of this triple represent "Socrates was born in Athens," where "Socrates" and "Athens" are two entity nodes and "born in" is a relationship, together forming an edge in the graph structure.
[0003] Currently, knowledge graphs have become one of the primary data sources for many scientific research and application areas. For example, many existing natural language processing tasks, such as information retrieval, data mining, and data analysis, require knowledge graph data support. Knowledge graph applications have also spread across various industries, such as social networks, intelligent dialogue, personalized intelligent recommendations, intelligent question-and-answer (Q&A), and intelligent search, and are further applied in vertical fields such as finance, social security, medical services, and public opinion response. However, in actual applications, knowledge graph data automatically acquired through models or manually obtained is often redundant and incomplete, and may even contain abnormal and erroneous knowledge. This greatly reduces the usability of knowledge graph data in tasks, and the quality of the data directly affects the development and progress of related technologies.
[0004] The goal of knowledge graph reasoning is to infer missing facts based on existing facts in the graph. Currently, mainstream approaches primarily utilize representation learning techniques. These methods map complex objects and their corresponding relationships into a low-dimensional continuous vector space and measure the similarity between objects and relationships based on these vectors, effectively completing knowledge graphs. These methods have achieved promising results on dense, non-inductive datasets.
[0005] However, the aforementioned direct knowledge graph reasoning explicitly embeds each entity. When the reasoning stage encounters an entity not seen during training, the entity lacks a learned embedding, making reasoning impossible. In real-world scenarios, knowledge graphs dynamically expand with the constant addition of new entities. Compared to the aforementioned direct knowledge graph reasoning, knowledge graph entity inductive reasoning is more practical. Knowledge graph entity inductive reasoning involves reasoning about entities not seen during training.
[0006] The classic approach to inductive reasoning of entities in knowledge graphs is subgraph-based reasoning. Subgraph-based inductive reasoning in knowledge graphs attempts to construct a closed subgraph for each triple to be reasoned about. It uses the positional structure of the entities within the subgraph to initialize entity embeddings using dual-radius encoding, and then learns a graph neural network as an encoder to encode entities and relationships. However, because subgraphs focus only on local information, the model cannot learn global semantic information like full-graph learning models. Furthermore, during the subgraph construction process, some long-path dependencies are lost to ensure the closed subgraph property. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to propose a knowledge graph inductive reasoning method based on dual-view learning to solve the problem that the existing subgraph-based entity inductive reasoning model cannot learn global semantic information.
[0008] The technical solution adopted by the present invention to solve the above technical problems is:
[0009] A knowledge graph inductive reasoning method based on dual-view learning, the architecture of its knowledge graph inductive reasoning model includes the following steps:
[0010] A1. Based on the knowledge graph, construct the knowledge graph G and the global graph L(G);
[0011] The graph G = (V, E) is a directed graph, where V is a set of nodes representing entities contained in the knowledge graph, and E is a set of edges representing the relationships between entities contained in the knowledge graph;
[0012] The global graph L(G) is an undirected graph; the nodes contained in the global graph L(G) correspond one-to-one to the relations contained in the knowledge graph, and the relation embedding of the corresponding relations is used as the global node embedding of the corresponding nodes, and the relation embedding is a learnable parameter; if there is a common entity between the k1th relation and the k2th relation in the knowledge graph, then there is an edge between the nodes corresponding to the k1th relation and the k2th relation in the global graph L(G);
[0013] A2. Extract N triplets from the knowledge graph as positive samples for this round of training;
[0014] For each positive sample T p , respectively: extract positive samples T from graph G p n-hop closed subgraph; based on positive sample T p n-hop closed subgraph, construct positive sample T p Local graph; using double radius encoding, obtain positive sample T p The initial local node embedding of each node contained in the local graph of ;
[0015] A3. Using the first graph neural network, for each node in the global graph, update the global node embedding of each node using the global node embeddings of its neighboring nodes to obtain its updated global node embedding; that is, obtain the relational embeddings of each relation in the updated knowledge graph;
[0016] A4. For each positive sample T p For the local graph, respectively: based on the relationship between the edges in the local graph, use the relationship embedding obtained by the update in step A3 to obtain the current local edge embedding of each edge contained therein; then, using the second graph neural network, for each node contained in the local graph, use the local node embeddings of its neighboring nodes and the local edge embeddings between the node and its neighboring nodes to update its local node embedding;
[0017] A5. Determine whether the set number of iterations has been reached. If not, return to step A3; if reached, execute step A6.
[0018] A6. For each positive sample T p , respectively, using the local edge embeddings of the nodes corresponding to the entities contained in its local graph and the relation embeddings of the contained relations to obtain its score through the scoring network;
[0019] A7. Use the loss function to calculate the loss of each positive sample based on its score. Use step A2 to input the loss of each positive sample to obtain the total loss of this round of training, and perform a reverse update.
[0020] A8. Determine whether the training is completed. If so, end the training and obtain a trained knowledge graph inference model. Otherwise, return to step A2.
[0021] Using the trained knowledge graph to summarize the reasoning model, the reasoning process includes:
[0022] B1. Use the query head entity and query relationship, combined with the candidate tail entity set, to construct a set of triples to be inferred; or use the query head entity and query tail entity, combined with the candidate relationship set, to construct a set of triples to be inferred;
[0023] B2. For each triple to be inferred in the set of triples to be inferred, calculate its score according to the following steps:
[0024] B21. Construct a local graph of the triples to be inferred; use dual-radius encoding to obtain the local node embedding of each node in the local graph; based on the relationship between the edges in the local graph, use the relational embedding of the corresponding relationship to obtain the local edge embedding of each edge contained in it;
[0025] B22. Update the local graph using the second graph neural network according to the method of step A4 according to the set number of iterations;
[0026] B23. Using the local edge embeddings of the nodes corresponding to the entities contained in the triple to be inferred in its local graph, as well as the relation embeddings of the contained relations, obtain its score through the scoring network;
[0027] B3. Output the reasoning result based on the score of each triple to be inferred in the set of triples to be inferred.
[0028] Furthermore, in step A1, a graph G of the knowledge graph is constructed based on the knowledge graph, including:
[0029] First, based on the knowledge graph, construct the original graph G of the knowledge graph ′ ;
[0030] Then, we use the rule mining method of knowledge graph to mine the potential relationships hidden in the knowledge graph;
[0031] Afterwards, the triples corresponding to the potential relationships are added to the original graph G ′ , obtain the graph G of the knowledge graph;
[0032] In step A2, based on the positive sample T p n-hop closed subgraph, construct positive sample T p The local map includes:
[0033] Construct positive samples T respectively p The J-hop and J+1-hop n-hop closed subgraph;
[0034] Take the J-hop n-hop closed subgraph ε J and the n-hop closed subgraph ε of J+1 hops J+1 The difference of , constructs the candidate entity set;
[0035] From the candidate entity set, filter out the positive samples T p The entities whose shortest path distance to the head entity or tail entity does not exceed J constitute the supplementary entity set;
[0036] The entities contained in the supplementary entity set and the edges between them and the entities contained in the J-hop closed subgraph are added into the J-hop closed subgraph to obtain the positive sample T p A local graph of
[0037] In step A2, double-radius encoding is performed according to the following formula:
[0038]
[0039] Among them, d(i, head) represents the relationship between the i-th node in the local graph and the corresponding positive sample T in the local graph. p The shortest path between the nodes of the head entity, d(i, tail) represents the shortest path between the i-th node in the local graph and the corresponding positive sample T in the local graph. p The shortest path between the nodes of the tail entity; onehot means onehot encoding the shortest path. The dimension of the obtained onehot encoding is the maximum number of hops in the local graph. The encoding rule is to assign 1 to the position corresponding to the shortest path hop number and 0 to other positions. represents concatenation, and W is a learnable parameter matrix.
[0040] Furthermore, the calculation of the loss of the positive sample includes:
[0041] Based on positive sample T p The local graph contains nodes, and constructs positive samples T by randomly replacing the head entity or the tail entity. p Negative samples T n ; Using negative samples T n The local edge embeddings of the nodes corresponding to the included entities in the local graph, as well as the relational embeddings of the included relations, are used to obtain negative samples T through the scoring network. n score;
[0042] The loss is calculated according to the following formula:
[0043] L=max(0,η+score(T p )-score(T n ))
[0044] Among them, L is the positive sample T p The loss, η is the soft interval, score(T p ) is a positive sample T p score(T p ) is a positive sample T p Negative samples T n score;
[0045] The scoring network calculates the score according to the following formula:
[0046]
[0047] Among them, T represents the triplet currently evaluated by the rating network, and are the local node embeddings of the head entity and the tail entity of the current evaluation triple, rl T is the relation embedding of the relation in the current evaluation triple; MLP represents multi-layer perceptron, Indicates splicing.
[0048] Furthermore, in step A3, the first graph neural network is used to update the global node embedding of each node included in the global graph using the global node embeddings of its neighboring nodes to obtain its updated global node embedding, including:
[0049] First, the attention weight of each neighbor node is calculated through the attention mechanism
[0050] Then, the global node embedding of each neighboring node is updated based on the weighted sum of the global node embeddings as follows:
[0051]
[0052] Among them, N(i) is the set of neighbor nodes of the i-th node in the global graph, and denote the global node embedding of the i-th node in the global graph before and after the update in the t-th iteration respectively; is the global node embedding of the jth neighbor node of the i-th node in the global graph input to this step in the t-th iteration;
[0053] is the attention weight of the jth neighbor node of the i-th node in the global graph, calculated as follows;
[0054]
[0055] in, is the global edge embedding between the i-th node and its j-th neighbor node of the global graph input to this step in the t-th iteration; W1 is the learnable parameter matrix;
[0056] Model the latent semantics between entities and relations, and use the entity information embedding obtained by modeling to form a global edge embedding; or model the pattern information of relationship connections, and use the connection pattern embedding obtained by modeling to form a global edge embedding; or fuse entity information embedding and connection pattern embedding to form a global edge embedding.
[0057] Furthermore, according to the following formula, the entity information embedding and the connection pattern embedding are integrated to obtain the global edge embedding rg of the g-th edge g :
[0058]
[0059] Among them, W4 is the learnable parameter matrix, Indicates splicing; r ge is the entity information embedding of the g-th edge, r grEmbed the connection pattern of the g-th edge.
[0060] Furthermore, we can model the latent semantics between entities and relations and obtain entity information embedding by following the steps below:
[0061] First, the entity relationship matrix of the knowledge graph is constructed with the entities contained in the knowledge graph as rows and the contained relationships as columns. If the kth relationship exists in the triple containing the mth entity, the element value of the mth row and kth column in the entity relationship matrix is set to 1 or the frequency of the kth relationship in the triple containing the mth entity, otherwise it is set to 0.
[0062] Then, based on the column information of the entity relationship matrix, the feature vectors of each relationship contained in the knowledge graph are constructed;
[0063] Then, according to the following formula, based on the feature vectors of the relationship between the nodes at both ends of the g-th edge in the global graph, the entity information embedding r of the g-th edge is obtained by fusion ge :
[0064]
[0065] Among them, W2 is the learnable parameter matrix, Indicates splicing, and The feature vectors representing the relationship between the nodes at both ends of the g-th edge in the global graph.
[0066] Furthermore, based on the column information of the entity relationship matrix, the feature vectors of each relationship contained in the knowledge graph are constructed, including:
[0067] Perform singular value decomposition or truncated singular value decomposition on the entity relationship matrix;
[0068] Each column in the right singular matrix obtained by decomposition is used as the eigenvector of each relationship contained in the knowledge graph.
[0069] Furthermore, the pattern information of the relational connection is modeled according to the following steps to obtain the connection pattern embedding:
[0070] First, encode the connection model as follows:
[0071] According to the relationships r1 and r2 corresponding to the nodes at both ends of the g-th edge in the global graph, the common nodes of the relationships r1 and r2 are determined in the graph G to form the node set of the graph G of the g-th edge of the global graph; according to the edge e corresponding to the common nodes in the graph G r1 and edge e of the corresponding relation r2 r2 The outgoing and incoming directions define four connection modes of common nodes: 1. r1 and e r2Both are outgoing, which is a head-to-head mode; 2. e r1 and e r2 All are in the incoming direction, in tail-to-tail mode; III. r1 For the outgoing direction, e r2 In the inbound direction, it is a head-to-tail mode; IV. e r1 is the inbound direction, e r2 For the outgoing direction, it is a tail-to-head mode;
[0072] In the node set of the graph G of the g-th edge of the global graph, if there is a common node of the connection pattern, then in the encoding, the position corresponding to the connection pattern is assigned a value of 1 or the frequency of the connection pattern in the node set of the graph G of the g-th edge; if there is no common node of the connection pattern, then in the encoding, the position corresponding to the connection pattern is assigned a value of 0;
[0073] Then, the connection model embedding r of the g-th edge is calculated according to the following formula: gr
[0074] r gr =W3(C gr )
[0075] Among them, W3 is the learnable parameter matrix, C gr The encoding of the connection model.
[0076] Furthermore, in step A4, a second graph neural network is used to update the local node embedding of each node in the local graph using the local node embeddings of its neighboring nodes and the local edge embeddings between the node and its neighboring nodes according to the following formula:
[0077]
[0078] Among them, N l (i) is the set of neighbor nodes of the i-th node in the local graph, and all edges between the i-th node and its neighbor nodes are directed from the neighbor nodes to the i-th node; and denote the local node embedding of the i-th node of the local graph before and after the update in the t-th iteration respectively; The local node embedding of the jth neighbor node of the i-th node in the local graph input to this step in the t-th iteration; is the local edge embedding between the i-th node and its j-th neighbor node of the local graph input to this step in the t-th iteration; φ represents the fusion operation of entity embedding and relation embedding, and |·| represents the count;
[0079] is the local attention of the jth neighbor node of the i-th node in the local graph, calculated as follows:
[0080]
[0081] in, is a positive sample T p The relation embedding of the contained relation is the global node embedding of the relation after being updated by step A3 in the tth iteration; W5 is the learnable parameter matrix.
[0082] Furthermore, in step A4, analog attention weights are introduced and the local node embedding is updated according to the following formula:
[0083]
[0084] in, is the analog attention weight of the jth neighbor node of the i-th node in the local graph, calculated as follows:
[0085]
[0086] Among them, the triplet (h c ,r c ,t c ), and triples (h c ,r c ,t c ) is the inverse triplet of h c Represents a triple (h c ,r c ,t c )’s head entity, which is embedded as t c Represents a triple (h c ,r c ,t c ), whose embedding is and The values of are respectively the local node embeddings of the corresponding nodes in the local graph input to this step in the tth iteration; M c is a triplet (h c ,r c ,t c ) contains the relation r c The diagonal matrix of the relational embedding, is the inverse triple Contained inverse relationship The diagonal matrix of the relation embedding of c and inverse relationship The relation embeddings of are all learnable parameters; Represents Hadamard.
[0087] The beneficial effects of the present invention are:
[0088] The method of the present invention is based on the head and tail entities of the triple, samples the closed subgraph composed of its n-hop neighbors, and constructs a local graph; at the same time, it introduces a global graph as the second view. The global graph uses relationships as nodes and constructs edges based on whether there are common entities between relationships. While introducing global information, it ensures the controllability of the global graph scale and clearly shows the relationship between the edges in the graph of the knowledge graph.
[0089] The architecture first runs the global graph learning module, using a separate graph neural network to learn relational embeddings. The updated relational embeddings are then fed into the local graph learning module. Next, the shortest path distance between the head and tail entities of each entity triple is used as the initial entity encoding. The fed relational embeddings are used as the relational embeddings, and the local graph learning module is run to update the entity embeddings using the graph neural network. This process iteratively alternates between the two views until the model converges or a training epoch threshold is reached.
[0090] Therefore, the method of the present invention, by introducing a global graph and constructing complementary learning of local and global graphs, makes up for the defects of single-view learning, improves learning ability, enhances the performance of inductive reasoning, and solves the problem that the existing subgraph-based entity inductive reasoning model cannot learn global semantic information. BRIEF DESCRIPTION OF THE DRAWINGS
[0091] Figure 1 Schematic diagram of graph G of knowledge graph;
[0092] Figure 2 Schematic diagram of the global graph L(G) of the knowledge graph constructed using Scheme 1;
[0093] Figure 3 Schematic diagram of the global graph L(G) of the knowledge graph adopted in the present invention. DETAILED DESCRIPTION
[0094] The present invention aims to provide a knowledge graph inductive reasoning method based on dual-view learning. By constructing local graphs and global graphs for complementary learning, it makes up for the defects of single-view learning and solves the problem that the existing subgraph-based entity inductive reasoning model cannot learn global semantic information.
[0095] The architecture of its knowledge graph inductive reasoning model includes the following steps:
[0096] A1. Based on the knowledge graph, construct the knowledge graph G and the global graph L(G);
[0097] The graph G = (V, E) is a directed graph, where V is a set of nodes representing entities contained in the knowledge graph, and E is a set of edges representing the relationships between entities contained in the knowledge graph;
[0098] The global graph L(G) is an undirected graph; the nodes contained in the global graph L(G) correspond one-to-one to the relations contained in the knowledge graph, and the relation embedding of the corresponding relations is used as the global node embedding of the corresponding nodes, and the relation embedding is a learnable parameter; if there is a common entity between the k1th relation and the k2th relation in the knowledge graph, then there is an edge between the nodes corresponding to the k1th relation and the k2th relation in the global graph L(G);
[0099] A2. Extract N triplets from the knowledge graph as positive samples for this round of training;
[0100] For each positive sample T p , respectively: extract positive samples T from graph G p n-hop closed subgraph; based on positive sample T p n-hop closed subgraph, construct positive sample T p Local graph; using double radius encoding, obtain positive sample T p The initial local node embedding of each node contained in the local graph of ;
[0101] A3. Using the first graph neural network, for each node in the global graph, update the global node embedding of each node using the global node embeddings of its neighboring nodes to obtain an updated global node embedding; that is, obtain the relational embeddings of each relation in the updated knowledge graph;
[0102] A4. For each positive sample T p For the local graph, respectively: based on the relationship between the edges in the local graph, use the relationship embedding obtained by the update in step A3 to obtain the current local edge embedding of each edge contained therein; then, using the second graph neural network, for each node contained in the local graph, use the local node embeddings of its neighboring nodes and the local edge embeddings between the node and its neighboring nodes to update its local node embedding;
[0103] A5. Determine whether the set number of iterations has been reached. If not, return to step A3; if reached, execute step A6.
[0104] A6. For each positive sample T p , respectively, using the local edge embeddings of the nodes corresponding to the entities contained in its local graph and the relation embeddings of the contained relations to obtain its score through the scoring network;
[0105] A7. Use the loss function to calculate the loss of each positive sample based on its score. Use step A2 to input the loss of each positive sample to obtain the total loss of this round of training, and perform a reverse update.
[0106] A8. Determine whether the training is completed. If so, end the training and obtain a completed knowledge graph reasoning model; otherwise, return to step A2.
[0107] Using the trained knowledge graph to summarize the reasoning model, the reasoning process includes:
[0108] B1. Use the query head entity and query relationship, combined with the candidate tail entity set, to construct a set of triples to be inferred; or use the query head entity and query tail entity, combined with the candidate relationship set, to construct a set of triples to be inferred;
[0109] B2. For each triple to be inferred in the set of triples to be inferred, calculate its score according to the following steps:
[0110] B21. Construct a local graph of the triples to be inferred; use dual-radius encoding to obtain the local node embedding of each node in the local graph; based on the relationship between the edges in the local graph, use the relational embedding of the corresponding relationship to obtain the local edge embedding of each edge contained in it;
[0111] B22. Update the local graph using the second graph neural network according to the method of step A4 according to the set number of iterations;
[0112] B23. Using the local edge embeddings of the nodes corresponding to the entities contained in the triple to be inferred in its local graph, as well as the relation embeddings of the contained relations, obtain its score through the scoring network;
[0113] B3. Output the reasoning result based on the score of each triple to be inferred in the set of triples to be inferred.
[0114] The method of the present invention, based on the existing subgraph-based reasoning, introduces the global graph as the second view, and iterates alternately between the two views. Through the interaction of the two views, the model is allowed to learn information from the global graph that is different from the local graph to supplement it, thereby improving the learning ability and enhancing the performance of inductive reasoning.
[0115] For example Figure 1 In the graph G shown, circles represent nodes, the text inside the circles is the entity corresponding to the node, lines represent edges, and the text next to the lines is the relationship to which the edge belongs. Figure 1 As can be seen from the figure, the same relationship may appear multiple times in the graph G. Therefore, there are two different graph construction schemes depending on the different definitions of the nodes in the global graph:
[0116] First, each edge in the graph G is a node in the global graph, and the same relationship may correspond to multiple nodes in the global graph;
[0117] 2. Each relationship in the graph G is a node in the global graph, and the same relationship corresponds to only one node in the global graph. The relationship in the graph G and the nodes in the global graph form a bijection.
[0118] Using the global graph of solution 1, such as Figure 2 As shown in the figure, circles represent nodes of the global graph, the text inside the circles is the relationship corresponding to the nodes, lines represent edges of the global graph, and the text next to the lines is the entity corresponding to the edge. Figure 2 As can be seen from the figure, Solution 1 completely inherits the topological structure between all edges in the graph G and can fully learn the relationship information. However, in this solution, the number of nodes in the global graph is equal to the number of edges in the graph G, which leads to huge construction costs and computational overheads. In addition, how to scientifically aggregate all nodes belonging to the same relationship in the global graph will also be a difficult problem.
[0119] Using the global graph of solution 2, such as Figure 3 As shown in the figure, circles represent nodes of the global graph, the text inside the circles is the relationship corresponding to the nodes, lines represent edges of the global graph, and the text next to the lines is the entity set corresponding to the edges. Figure 3 As can be seen from the figure, in Scheme 2, the number of nodes in the global graph will be much smaller than that in Scheme 1. Therefore, the scale of the global graph is effectively controlled, the construction and computation efficiency are improved, and the necessary structural information is retained. Therefore, the present invention adopts Scheme 2 to construct the global graph.
[0120] Typically, during iterations of graph neural networks, an attention mechanism can be introduced to control the intensity of neighbor message transmission to improve computational efficiency. To incorporate more information into the attention calculation process, neighbor edge embeddings are often used. However, it should be noted that the global node embeddings of nodes in the global graph are assigned using the relational embeddings of the knowledge graph. Knowledge graph entities, on the other hand, lack a globally unified embedding representation and are initialized only in local graphs using a dual-radius encoding based on structural information. Therefore, it is necessary to model the global edge embeddings of edges in the global graph.
[0121] Optionally, the latent semantics between entities and relations are modeled, and the entity information obtained by modeling is embedded to form a global edge embedding; or, the pattern information of the relationship connection is modeled, and the connection pattern embedding obtained by modeling is embedded to form a global edge embedding; or, the entity information embedding and the connection pattern embedding are fused to form a global edge embedding.
[0122] To model the latent semantics between entities and relationships, any existing method can be used, such as mining the latent semantics between entities and relationships through an entity-relationship matrix. To model the pattern information of relationship connections, any existing method can also be used, such as encoding the distribution of connection patterns of shared entities contained in the edges of the global graph. Global edge embeddings constructed based on entity information embedding and / or connection pattern embedding are derived from inherent information in the knowledge graph and have no explicit textual meaning. They are only used for attention calculations in updating global node embeddings and do not require updating.
[0123] Different connection patterns represent different relational semantics and structural information. For example, head-to-tail and tail-to-head represent transitivity, while head-to-head and tail-to-tail do not pass messages in directed graphs but have symmetric structural properties. Therefore, in order to introduce the most information, the optimal method is to fuse entity information embedding and connection pattern embedding according to the following formula to obtain the global edge embedding rg of the g-th edge. g :
[0124]
[0125] Among them, W4 is the learnable parameter matrix, Indicates splicing; r ge is the entity information embedding of the g-th edge, r gr Embed the connection pattern of the g-th edge.
[0126] To ensure computational efficiency, an attention mechanism is also introduced in the iterative process of the local graph. At the same time, the inventors noticed that all paths in the local graph start from the head entity and end at the tail entity, so all relationship paths and target relationships constitute analogical reasoning relationships. Therefore, in order to better utilize this good property of the local graph, an analogical attention mechanism calculated according to the following formula is introduced in the graph neural network of the local graph:
[0127]
[0128] Among them, the triplet (h c ,r c ,t c ), and triples (h c ,r c ,t c ) is the inverse triplet of h c Represents a triple (h c ,r c ,t c )’s head entity, which is embedded as t c Represents a triple (h c ,rc ,t c ), whose embedding is and The values of are respectively the local node embeddings of the corresponding nodes in the local graph input to this step in the tth iteration; M c is a triple (h c ,r c ,t c ) contains the relation r c The diagonal matrix of the relational embedding, is the inverse triple Contained inverse relationship The diagonal matrix of the relation embedding of c and inverse relationship The relation embeddings of are all learnable parameters.
[0129] The following is further described with reference to the embodiments.
[0130] Example:
[0131] A knowledge graph inductive reasoning method based on dual-view learning includes the following steps:
[0132] A1. Build and initialize the global graph
[0133] In this step, a graph G = (V, E) of the knowledge graph is constructed based on the knowledge graph. The graph G is mainly used for sampling local graphs in subsequent steps. The graph G is a directed graph, where V is a set of nodes representing the entities contained in the knowledge graph, and E is a set of edges representing the relationships between the entities contained in the knowledge graph. The relational embeddings of each relationship contained in the knowledge graph are set as learnable parameters and initialized. Since the subsequent calculation introduces the inverse relationship, in this step, the relational embeddings of the inverse relationships of each relationship contained in the knowledge graph are also set as learnable parameters and initialized.
[0134] The local graph is constructed based on the n-hop closed subgraph. An n-hop closed subgraph is a subgraph extracted from a given graph that contains all nodes and the edges between them that can be reached from two target nodes u and v via at most n hops. Although some entities included in the n-hop closed subgraph belong to the n-order neighborhood of the head and tail entities, due to the presence of entities excluded by the n-hop closed subgraph on the path between the head and tail entities in which they participate, the long path in which they participate is broken. The n-hop closed subgraph will discard these neighbors and paths, making it impossible for the model to treat all n-order neighbor entities equally, resulting in information loss in the n-hop closed subgraph. Therefore, in order to complete the long path dependencies while maintaining the properties of the n-hop closed subgraph, in this step, the rule mining method in the knowledge graph is used to perform reliable completion of the topological relationship; in the subsequent local graph construction, the structure of the subgraph is also enriched by increasing the number of sampling hops.
[0135] The rules in the knowledge graph generally refer to Horn's rules, which are in the following form:
[0136]
[0137] Among them, the left side of the formula is the regular body, B n Represents the body atom, B n (x n ,x n+1 ) represents the entity x of the knowledge graph n and x n+1 Connected by a certain relationship. The right side of the formula represents the rule head, which represents the starting entity x1 and the ending entity x of the rule body. n+1 Connected by relation r. Rule mining of knowledge graph refers to extracting implicit rule knowledge from the knowledge graph. These rules can be applied to knowledge graph completion, for example: This means that Bob is John's father, and John is Alice's father, so it follows that Bob is Alice's grandfather.
[0138] In this embodiment, a graph G of the knowledge graph is constructed based on the knowledge graph, including:
[0139] First, based on the knowledge graph, construct the original graph G of the knowledge graph ′ ;
[0140] Then, we use the rule mining method of knowledge graph to mine the potential relationships hidden in the knowledge graph;
[0141] Afterwards, the triples corresponding to the potential relationships are added to the original graph G ′ , obtain the graph G of the knowledge graph.
[0142] Of course, this step can also directly use the original graph G ′ As a rule mining method for the knowledge graph G, any existing method can be used.
[0143] In this step, a global graph L(G) of the knowledge graph is constructed based on the knowledge graph. The global graph L(G) is an undirected graph. The nodes contained in the global graph L(G) correspond one-to-one to the relationships contained in the knowledge graph, and the relationship embedding of the corresponding relationship is used as the global node embedding of the corresponding node. The relationship embedding is a learnable parameter. If there is a shared entity between the k1th relationship and the k2th relationship in the knowledge graph, then there is an edge between the nodes corresponding to the k1th relationship and the k2th relationship in the global graph L(G). The global edge embedding of each edge contained in the global graph L(G) is obtained by fusing entity information embedding and connection pattern embedding.
[0144] In this embodiment, the entity information embedding and the connection pattern embedding are integrated according to the following formula to obtain the global edge embedding rg of the g-th edge: g :
[0145]
[0146] Among them, W4 is the learnable parameter matrix, Indicates splicing; r ge is the entity information embedding of the g-th edge, r gr Embed the connection pattern of the g-th edge.
[0147] In this embodiment, the following steps are used to model the latent semantics between entities and relationships and obtain entity information embedding:
[0148] First, the entity relationship matrix of the knowledge graph is constructed with the entities contained in the knowledge graph as rows and the contained relationships as columns. If the kth relationship exists in the triple containing the mth entity, the element value in the mth row and kth column of the entity relationship matrix is set to 1, otherwise it is set to 0.
[0149] Then, based on the column information of the entity relationship matrix, the feature vectors of each relationship contained in the knowledge graph are constructed;
[0150] Then, according to the following formula, based on the feature vectors of the relationship between the nodes at both ends of the g-th edge in the global graph, the entity information embedding r of the g-th edge is obtained by fusion ge :
[0151]
[0152] Among them, W2 is the learnable parameter matrix, Indicates splicing, and The feature vectors representing the relationship between the nodes at both ends of the g-th edge in the global graph.
[0153] In this embodiment, the element value in the entity relationship matrix only expresses whether it exists. In addition, the frequency of the kth relationship in the triple of the mth entity can be used to further enrich the information.
[0154] To compress the dimensionality of the feature vectors, the feature vectors for each relationship in the knowledge graph are constructed based on the column information of the entity relationship matrix. This involves performing singular value decomposition (SVD) or truncated SVD on the entity relationship matrix, with each column of the right singular matrix obtained as the feature vector for each relationship in the knowledge graph. To achieve maximum compression, this embodiment uses truncated SVD.
[0155] In this embodiment, the pattern information of the relational connection is modeled according to the following steps to obtain the connection pattern embedding:
[0156] First, encode the connection model as follows:
[0157] According to the relationships r1 and r2 corresponding to the nodes at both ends of the g-th edge in the global graph, the common nodes of the relationships r1 and r2 are determined in the graph G to form the node set of the graph G of the g-th edge of the global graph; according to the edge e corresponding to the common nodes in the graph G r1 and edge e of the corresponding relation r2 r2 The outgoing and incoming directions define four connection modes of common nodes: 1. r1 and e r2 Both are outgoing, which is a head-to-head mode; 2. e r1 and e r2 All are in the incoming direction, in tail-to-tail mode; III. r1 For the outgoing direction, e r2 In the inbound direction, it is a head-to-tail mode; IV. e r1 is the inbound direction, e r2 For the outgoing direction, it is a tail-to-head mode;
[0158] In the node set of graph G of the g-th edge of the global graph, if there is a common node of the connection pattern, then in the encoding, the position corresponding to the connection pattern is assigned a value of 1; if there is no common node of the connection pattern, then in the encoding, the position corresponding to the connection pattern is assigned a value of 0;
[0159] Then, the connection model embedding r of the g-th edge is calculated according to the following formula: gr
[0160] r gr =W3(C gr )
[0161] Among them, W3 is the learnable parameter matrix, C gr The encoding of the connection model.
[0162] In this embodiment, C gr In practice, onehot encoding is used. In addition, the frequency of occurrence of the connection pattern in the set of nodes in the graph G of the g-th edge can be used to further enrich the information.
[0163] A2. Input training samples and construct their local graphs
[0164] In this step, N triplets are extracted from the knowledge graph as positive samples for this round of training. p , respectively: extract positive samples T from graph G p n-hop closed subgraph; based on positive sample T p n-hop closed subgraph, construct positive sample T p Local graph; using double radius encoding, obtain positive sample T p The initial local node embeddings of each node contained in the local graph of .
[0165] The local graph can directly adopt n-hop closed subgraph, but as mentioned above, in this embodiment, the structure of the local graph is enriched by expanding the number of sampling hops. Specifically, based on the positive sample T p n-hop closed subgraph, construct positive sample T p The local map includes:
[0166] Construct positive samples T respectively p The J-hop and J+1-hop n-hop closed subgraph;
[0167] Take the J-hop n-hop closed subgraph ε J and the n-hop closed subgraph ε of J+1 hops J+1 The difference of , constructs the candidate entity set;
[0168] From the candidate entity set, filter out the positive samples T p The entities whose shortest path distance to the head entity or tail entity does not exceed J constitute the supplementary entity set;
[0169] The entities contained in the supplementary entity set and the edges between them and the entities contained in the J-hop closed subgraph are added into the J-hop closed subgraph to obtain the positive sample T p A partial diagram of .
[0170] In this embodiment, double-radius encoding is performed according to the following formula:
[0171]
[0172] Among them, d(i, head) represents the relationship between the i-th node in the local graph and the corresponding positive sample T in the local graph. p The shortest path between the nodes of the head entity, d(i, tail) represents the shortest path between the i-th node in the local graph and the corresponding positive sample T in the local graph. p The shortest path between the nodes of the tail entity; onehot means onehot encoding the shortest path. The dimension of the obtained onehot encoding is the maximum number of hops in the local graph. The encoding rule is to assign 1 to the position corresponding to the shortest path hop number and 0 to other positions. represents concatenation, and W is a learnable parameter matrix.
[0173] A3. Relation Embedding Update
[0174] The essence of this step is to update the learnable relation embeddings. Specifically, using the first graph neural network, for each node in the global graph, the global node embedding of its neighboring nodes is updated to obtain its updated global node embedding; that is, the relation embeddings of each relation in the updated knowledge graph are obtained.
[0175] In this embodiment, a first graph neural network is used to update the global node embedding of each node included in the global graph using the global node embeddings of its neighboring nodes to obtain its updated global node embedding, including:
[0176] First, the attention weight of each neighbor node is calculated through the attention mechanism
[0177] Then, the global node embedding of each neighboring node is updated based on the weighted sum of the global node embeddings as follows:
[0178]
[0179] Among them, N(i) is the set of neighbor nodes of the i-th node in the global graph, and denote the global node embedding of the i-th node in the global graph before and after the update in the t-th iteration respectively; is the global node embedding of the jth neighbor node of the i-th node in the global graph input to this step in the t-th iteration;
[0180] is the attention weight of the jth neighbor node of the i-th node in the global graph, calculated as follows;
[0181]
[0182] in, is the global edge embedding between the i-th node and its j-th neighbor node of the global graph input to this step in the t-th iteration; W1 is the learnable parameter matrix.
[0183] A4. Entity embedding update
[0184] The essence of this step is to update the entity embedding of the corresponding entity by updating the node embedding of the local graph. Specifically, the second graph neural network is used to update the local node embedding of each node in the local graph using the local node embeddings of its neighboring nodes and the local edge embeddings between the node and its neighboring nodes.
[0185] In this embodiment, a second graph neural network is used to update the local node embedding of each node in the local graph using the local node embeddings of its neighboring nodes and the local edge embeddings between the node and its neighboring nodes according to the following formula:
[0186]
[0187] Among them, N l (i) is the set of neighbor nodes of the i-th node in the local graph, and all edges between the i-th node and its neighbor nodes are directed from the neighbor nodes to the i-th node; and denote the local node embedding of the i-th node of the local graph before and after the update in the t-th iteration respectively; The local node embedding of the jth neighbor node of the i-th node in the local graph input to this step in the t-th iteration; is the local edge embedding between the i-th node and its j-th neighbor node of the local graph input to this step in the t-th iteration; φ represents the fusion operation of entity embedding and relation embedding, and |·| represents the count.
[0188] Considering that the local graph is semantically similar to the positive sample T p Therefore, the attention mechanism should be able to perceive the relationship between local structure and target relationship, so the local attention is introduced. Used to evaluate the semantic similarity between the current relation and the target relation.
[0189] is the local attention of the jth neighbor node of the i-th node in the local graph, calculated as follows:
[0190]
[0191] in, is a positive sample T pThe relation embedding of the contained relation is the global node embedding of the relation after being updated by step A3 in the tth iteration; W5 is the learnable parameter matrix.
[0192] In this embodiment, analog attention weights are introduced, and local node embeddings are updated according to the following formula:
[0193]
[0194] in, is the analog attention weight of the jth neighbor node of the i-th node in the local graph, calculated as follows:
[0195]
[0196] Among them, the triplet (h c ,r c ,t c ), and triples (h c ,r c ,t c ) is the inverse triplet of h c Represents a triple (h c ,r c ,t c )’s head entity, which is embedded as t c Represents a triple (h c ,r c ,t c ), whose embedding is and The values of are respectively the local node embeddings of the corresponding nodes in the local graph input to this step in the tth iteration; M c is a triplet (h c ,r c ,t c ) contains the relation r c The diagonal matrix of the relational embedding, is the inverse triple Contained inverse relationship The diagonal matrix of the relation embedding of c and inverse relationship The relation embeddings of are all learnable parameters; Represents Hadamard.
[0197] A5. Complete the iteration
[0198] In this step, it is determined whether the set number of iterations has been reached. If not, the process returns to step A3; if reached, the process proceeds to step A6.
[0199] A6. Score Calculation
[0200] In this step, for each positive sample T p , respectively, the local edge embeddings of the nodes corresponding to the entities contained in its local graph, as well as the relationship embeddings of the contained relationships, are input into the scoring network to obtain its score. The scoring network calculates the score according to the following formula:
[0201]
[0202] Among them, T represents the triplet currently evaluated by the rating network, and are the local node embeddings of the head entity and the tail entity of the current evaluation triple, rl T is the relation embedding of the relation in the current evaluation triple; MLP represents multi-layer perceptron, Indicates splicing.
[0203] To facilitate loss calculation, this step also includes: based on the positive sample T p The local graph contains nodes, and constructs positive samples T by randomly replacing the head entity or the tail entity. p Negative samples T n ; Using negative samples T n The local edge embeddings of the nodes corresponding to the included entities in the local graph, as well as the relational embeddings of the included relations, are used to obtain negative samples T through the scoring network. n score.
[0204] A7. Loss calculation and update
[0205] In this step, the loss function is used to calculate the loss of each positive sample based on its score. The loss of each positive sample is input into step A2 to obtain the total loss of this round of training, and then a reverse update is performed.
[0206] In this embodiment, the loss is calculated according to the following formula:
[0207] L=max(0,η+score(T p )-score(T n ))
[0208] Among them, L is the positive sample T p The loss, η is the soft interval, score(T p ) is a positive sample T p score(T p ) is a positive sample T p Negative samples T n score.
[0209] A8. Complete training
[0210] In this step, it is determined whether the training is completed. If so, the training is terminated to obtain a knowledge graph reasoning model that has completed the training; otherwise, return to step A2.
[0211] Using the trained knowledge graph to summarize the reasoning model, the reasoning process includes:
[0212] B1. Use the query head entity and query relationship, combined with the candidate tail entity set, to construct a set of triples to be inferred; or use the query head entity and query tail entity, combined with the candidate relationship set, to construct a set of triples to be inferred;
[0213] B2. For each triple to be inferred in the set of triples to be inferred, calculate its score according to the following steps:
[0214] B21. Construct a local graph of the triples to be inferred; use dual-radius encoding to obtain the local node embedding of each node in the local graph; based on the relationship between the edges in the local graph, use the relational embedding of the corresponding relationship to obtain the local edge embedding of each edge contained in it;
[0215] B22. Update the local graph using the second graph neural network according to the method of step A4 according to the set number of iterations;
[0216] B23. Using the local edge embeddings of the nodes corresponding to the entities contained in the triple to be inferred in its local graph, as well as the relation embeddings of the contained relations, obtain its score through the scoring network;
[0217] B3. Output the reasoning result based on the score of each triple to be inferred in the set of triples to be inferred.
[0218] We used the NELL-995-v2 dataset, a classic dataset for entity inductive reasoning, for the following tests. This training dataset includes 2,564 entities, 88 relations, and 10,109 triples.
[0219] Test 1:
[0220] Query header entity: concept:blog:twitter
[0221] Inquiry relationship: concept: competes with
[0222] Candidate tail entity set: concept:blog:myspace, concept:mammal:animals, concept:website:facebook
[0223] The three candidate tail entities constitute the three to-be-reasoned triples, and the scores are calculated and normalized respectively. The results are 0.99, 0, and 1. The results show that the tail entity concept:website:facebook has the highest score, so the triple (concept:blog:twitter, concept:competeswith, concept:website:facebook) has the highest probability of being true.
[0224] Test 2:
[0225] Query the head entity: concept:sportsteam:los_angeles_lakers
[0226] Query the end entity: concept:sportsteam:sonics
[0227] Candidate relationship set:
[0228] concept:teamplaysagainstteam
[0229] concept:subpartof
[0230] concept:atlocation
[0231] After training, the three candidate relations constituted by the three to-be-inferred triplets were scored and normalized, with the results being 1, 0.93, and 0.92. The results show that the relation concept:teamplaysagainstteam has the highest score, so the triplet (concept:sportsteam:los_angeles_lakers, concept:teamplaysagainstteam, concept:sportsteam:sonics) has the highest probability of being true.
[0232] Finally, it should be noted that the above embodiments are merely preferred implementations and are not intended to limit the present invention. It should be noted that those skilled in the art will be able to make modifications, equivalent substitutions, and improvements without departing from the spirit and scope of the present invention and the claims, all of which should be included within the scope of protection of the present invention.
Claims
1. A knowledge graph inductive reasoning method based on dual-view learning, characterized by: The architecture of its knowledge graph inductive reasoning model includes the following steps: A1. Based on the knowledge graph, construct the knowledge graph G and the global graph L(G); The graph G = (V, E) is a directed graph, where V is a set of nodes representing entities contained in the knowledge graph, and E is a set of edges representing the relationships between entities contained in the knowledge graph; The global graph L(G) is an undirected graph; the nodes contained in the global graph L(G) correspond one-to-one to the relations contained in the knowledge graph, and the relation embedding of the corresponding relations is used as the global node embedding of the corresponding nodes, and the relation embedding is a learnable parameter; if there is a common entity between the k1th relation and the k2th relation in the knowledge graph, then there is an edge between the nodes corresponding to the k1th relation and the k2th relation in the global graph L(G); A2. Extract N triplets from the knowledge graph as positive samples for this round of training; For each positive sample T p , respectively: extract positive samples T from graph G p n-hop closed subgraph; based on positive sample T p n-hop closed subgraph, construct positive sample T p Local graph; using double radius encoding, obtain positive sample T p The initial local node embedding of each node contained in the local graph of ; A3. Using the first graph neural network, for each node in the global graph, update the global node embedding of each node using the global node embeddings of its neighboring nodes to obtain its updated global node embedding; that is, obtain the relational embeddings of each relation in the updated knowledge graph; A4. For each positive sample T p For the local graph, respectively: based on the relationship between the edges in the local graph, use the relationship embedding obtained by the update in step A3 to obtain the current local edge embedding of each edge contained therein; then, using the second graph neural network, for each node contained in the local graph, use the local node embeddings of its neighboring nodes and the local edge embeddings between the node and its neighboring nodes to update its local node embedding; A5. Determine whether the set number of iterations has been reached. If not, return to step A3; if reached, execute step A6. A6. For each positive sample T p , respectively, using the local edge embeddings of the nodes corresponding to the entities contained in its local graph and the relation embeddings of the contained relations to obtain its score through the scoring network; A7. Use the loss function to calculate the loss of each positive sample based on its score. Use step A2 to input the loss of each positive sample to obtain the total loss of this round of training, and perform a reverse update. A8. Determine whether the training is completed. If so, end the training and obtain a trained knowledge graph inference model. Otherwise, return to step A2. Using the trained knowledge graph to summarize the reasoning model, the reasoning process includes: B1. Use the query head entity and query relationship, combined with the candidate tail entity set, to construct a set of triples to be inferred; or use the query head entity and query tail entity, combined with the candidate relationship set, to construct a set of triples to be inferred; B2. For each triple to be inferred in the set of triples to be inferred, calculate its score according to the following steps: B21. Construct a local graph of the triples to be inferred; use dual-radius encoding to obtain the local node embedding of each node in the local graph; based on the relationship between the edges in the local graph, use the relational embedding of the corresponding relationship to obtain the local edge embedding of each edge contained in it; B22. Update the local graph using the second graph neural network according to the method of step A4 according to the set number of iterations; B23. Using the local edge embeddings of the nodes corresponding to the entities contained in the triple to be inferred in its local graph, as well as the relation embeddings of the contained relations, obtain its score through the scoring network; B3. Output the reasoning result based on the score of each triple to be inferred in the set of triples to be inferred.
2. The knowledge graph inductive reasoning method based on dual-view learning according to claim 1, characterized in that: In step A1, a graph G of the knowledge graph is constructed based on the knowledge graph, including: First, based on the knowledge graph, construct the original graph G′ of the knowledge graph; Then, we use the rule mining method of knowledge graph to mine the potential relationships hidden in the knowledge graph; Afterwards, the triples corresponding to the potential relations are added to the original graph G′ to obtain the graph G of the knowledge graph; In step A2, based on the positive sample T p n-hop closed subgraph, construct positive sample T p The local map includes: Construct positive samples T respectively p The J-hop and J+1-hop n-hop closed subgraph; Take the J-hop n-hop closed subgraph ε J and the n-hop closed subgraph ε of J+1 hops J+1 The difference of , constructs the candidate entity set; From the candidate entity set, filter out the positive samples T p The entities whose shortest path distance to the head entity or tail entity does not exceed J constitute the supplementary entity set; The entities contained in the supplementary entity set and the edges between them and the entities contained in the J-hop closed subgraph are added into the J-hop closed subgraph to obtain the positive sample T p A local graph of In step A2, double-radius encoding is performed according to the following formula: Among them, d(i, head) represents the relationship between the i-th node in the local graph and the corresponding positive sample T in the local graph. p The shortest path between the nodes of the head entity, d(i, tail) represents the shortest path between the i-th node in the local graph and the corresponding positive sample T in the local graph. p The shortest path between the nodes of the tail entity; onehot means onehot encoding the shortest path. The dimension of the obtained onehot encoding is the maximum number of hops in the local graph. The encoding rule is to assign 1 to the position corresponding to the shortest path hop number and 0 to other positions. represents concatenation, and W is a learnable parameter matrix.
3. The knowledge graph inductive reasoning method based on dual-view learning according to claim 1, characterized in that: The calculation of the loss of the positive sample includes: Based on positive sample T p The local graph contains nodes, and constructs positive samples T by randomly replacing the head entity or the tail entity. p Negative samples T n ; Using negative samples T n The local edge embeddings of the nodes corresponding to the included entities in the local graph, as well as the relation embeddings of the included relations, are used to obtain negative samples T through the scoring network. n score; The loss is calculated according to the following formula: L=max(0,η+score(T p )-score(T n )) Among them, L is the positive sample T p The loss, η is the soft interval, score(T p ) is a positive sample T p score(T p ) is a positive sample T p Negative samples T n score; The scoring network calculates the score according to the following formula: Among them, T represents the triplet currently evaluated by the rating network, and are the local node embeddings of the head entity and the tail entity of the current evaluation triple, rl T is the relation embedding of the relation in the current evaluation triple; MLP represents multi-layer perceptron, Indicates splicing.
4. The knowledge graph inductive reasoning method based on dual-view learning according to claim 1, characterized in that: In step A3, the first graph neural network is used to update the global node embedding of each node in the global graph using the global node embeddings of its neighboring nodes to obtain its updated global node embedding, including: First, the attention weight of each neighbor node is calculated through the attention mechanism Then, the global node embedding of each neighboring node is updated based on the weighted sum of the global node embeddings as follows: Among them, N(i) is the set of neighbor nodes of the i-th node in the global graph, and denote the global node embedding of the i-th node in the global graph before and after the update in the t-th iteration respectively; is the global node embedding of the jth neighbor node of the i-th node in the global graph input to this step in the t-th iteration; is the attention weight of the jth neighbor node of the i-th node in the global graph, calculated as follows; in, is the global edge embedding between the i-th node and its j-th neighbor node of the global graph input to this step in the t-th iteration; W1 is the learnable parameter matrix; Model the latent semantics between entities and relations, and use the entity information embedding obtained by modeling to form a global edge embedding; or model the pattern information of relationship connections, and use the connection pattern embedding obtained by modeling to form a global edge embedding; or fuse entity information embedding and connection pattern embedding to form a global edge embedding.
5. The knowledge graph inductive reasoning method based on dual-view learning according to claim 4 is characterized in that: According to the following formula, the entity information embedding and the connection pattern embedding are integrated to obtain the global edge embedding rg of the g-th edge g : Among them, W4 is the learnable parameter matrix, Indicates splicing; r ge is the entity information embedding of the g-th edge, r gr Embed the connection pattern of the g-th edge.
6. The knowledge graph inductive reasoning method based on dual-view learning according to claim 4, characterized in that: Follow these steps to model the latent semantics between entities and relations and obtain entity information embedding: First, the entity relationship matrix of the knowledge graph is constructed with the entities contained in the knowledge graph as rows and the contained relationships as columns. If the kth relationship exists in the triple containing the mth entity, the element value of the mth row and kth column in the entity relationship matrix is set to 1 or the frequency of the kth relationship in the triple containing the mth entity, otherwise it is set to 0. Then, based on the column information of the entity relationship matrix, the feature vectors of each relationship contained in the knowledge graph are constructed; Then, according to the following formula, based on the feature vectors of the relationship between the nodes at both ends of the g-th edge in the global graph, the entity information embedding r of the g-th edge is obtained by fusion ge : Among them, W2 is the learnable parameter matrix, Indicates splicing, and The feature vectors representing the relationship between the nodes at both ends of the g-th edge in the global graph.
7. The knowledge graph inductive reasoning method based on dual-view learning according to claim 6, characterized in that: Based on the column information of the entity relationship matrix, the feature vectors of each relationship contained in the knowledge graph are constructed, including: Perform singular value decomposition or truncated singular value decomposition on the entity relationship matrix; Each column in the right singular matrix obtained by decomposition is used as the eigenvector of each relationship contained in the knowledge graph.
8. The knowledge graph inductive reasoning method based on dual-view learning according to claim 4, characterized in that: Follow the steps below to model the pattern information of relational connections and obtain connection pattern embedding: First, encode the connection model as follows: According to the relationships r1 and r2 corresponding to the nodes at both ends of the g-th edge in the global graph, the common nodes of the relationships r1 and r2 are determined in the graph G to form the node set of the graph G of the g-th edge of the global graph; according to the edge e corresponding to the common nodes in the graph G r1 and edge e of the corresponding relation r2 r2 The outgoing and incoming directions define four connection modes of common nodes:
1. r1 and e r2 Both are outgoing, which is a head-to-head mode; 2. e r1 and e r2 All are in the incoming direction, in tail-to-tail mode; III. r1 For the outgoing direction, e r2 In the inbound direction, it is a head-to-tail mode; IV. e r1 is the inbound direction, e r2 For the outgoing direction, it is a tail-to-head mode; In the node set of the graph G of the g-th edge of the global graph, if there is a common node of the connection pattern, then in the encoding, the position corresponding to the connection pattern is assigned a value of 1 or the frequency of the connection pattern in the node set of the graph G of the g-th edge; if there is no common node of the connection pattern, then in the encoding, the position corresponding to the connection pattern is assigned a value of 0; Then, the connection model embedding r of the g-th edge is calculated according to the following formula: gr : r gr =W3(C gr ) Among them, W3 is the learnable parameter matrix, C gr The encoding of the connection model.
9. A knowledge graph inductive reasoning method based on dual-view learning according to any one of claims 1 to 8, characterized in that: In step A4, the second graph neural network is used to update the local node embedding of each node in the local graph using the local node embeddings of its neighboring nodes and the local edge embeddings between it and its neighboring nodes according to the following formula: Among them, N l (i) is the set of neighbor nodes of the i-th node in the local graph, and all edges between the i-th node and its neighbor nodes are directed from the neighbor nodes to the i-th node; and denote the local node embedding of the i-th node of the local graph before and after the update in the t-th iteration respectively; The local node embedding of the jth neighbor node of the i-th node in the local graph input to this step in the t-th iteration; is the local edge embedding between the i-th node and its j-th neighbor node of the local graph input to this step in the t-th iteration; φ represents the fusion operation of entity embedding and relation embedding, and |·| represents the count; is the local attention of the jth neighbor node of the i-th node in the local graph, calculated as follows: in, is a positive sample T p The relation embedding of the contained relation is the global node embedding of the relation after being updated by step A3 in the tth iteration; W5 is the learnable parameter matrix.
10. The knowledge graph inductive reasoning method based on dual-view learning according to claim 9, characterized in that: In step A4, analog attention weights are introduced and local node embeddings are updated as follows: in, is the analog attention weight of the jth neighbor node of the i-th node in the local graph, calculated as follows: Among them, the triplet (h c ,r c ,t c ), and triples (h c ,r c ,t c ) is the inverse triplet of h c Represents a triple (h c ,r c ,t c )’s head entity, which is embedded as t c Represents a triple (h c ,r c ,t c ), whose embedding is and The values of are respectively the local node embeddings of the corresponding nodes in the local graph input to this step in the tth iteration; M c is a triple (h c ,r c ,t c ) contains the relation r c The diagonal matrix of the relational embedding, is the inverse triple Contained inverse relationship The diagonal matrix of the relation embedding of c and inverse relationship The relation embeddings of are all learnable parameters; Represents Hadamard.
Citation Information
Cited By
Knowledge graph completion method based on type constraint and relational memory enhancement network
CN122242668A