Knowledge graph relation prediction method based on sub-graph relation information
Through the combination of information enhancement analysis of knowledge graph subgraphs and the biased random walk method, the robustness problem of sparse subgraphs in knowledge graph relationship prediction is solved, the prediction accuracy and efficiency are improved, and the model's tolerance to sparseness is enhanced. Processing capabilities of subgraphs.
Patent Information
- Application Number
- CN202410836652.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-27
AI Technical Summary
Existing knowledge graph relationship prediction methods based on subgraphs have poor robustness when faced with sparse subgraphs and cannot effectively mine valuable reasoning information in subgraphs. This is especially true when learning capabilities are affected when semantic types are rich.
By analyzing the relationship links of entity data, we obtain knowledge graph subgraphs, fuse entity location features and neighborhood relationship features, input the representation feature prediction model, combine with the biased random walk method to obtain path features, and use the triplet scoring function to perform Comprehensive calculations enhance the accuracy and robustness of prediction results.
It improves the prediction accuracy and robustness of sparse subgraphs, obtains richer feature representations, learns the most valuable reasoning information through the attention mechanism, and improves the accuracy and efficiency of relationship prediction.
Smart Images

Figure CN118709762A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine learning technology, and in particular to a knowledge graph relationship prediction method based on subgraph relationship information. Background Art
[0002] The subgraph-based knowledge graph relationship prediction method aims to mine entity information and triple topological structure information from the subgraph of the knowledge graph, so as to learn the reasoning clues contained in the subgraph. However, the existing methods have poor robustness to sparse knowledge graph subgraphs. Such methods generally include three steps: sampling surrounding subgraphs, initializing entity and relationship features, and updating features of graph neural networks. Due to the uncertainty of the topological structure and amount of knowledge in the knowledge graph, the state of the knowledge graph subgraph extracted based on the target head entity and tail entity is also unknown. In the absence of auxiliary information outside the graph, the sparse knowledge graph subgraph may cause the relationship prediction system to be unable to mine sufficient reasoning information.
[0003] In order to solve the problem of poor robustness in the face of sparse subgraphs, existing technologies usually focus on extracting and mining the relationship paths between two entities and learning their rule structures. However, these methods only focus on the rule information contained in the subgraph paths, but ignore the fact that not all relationship paths in the subgraphs are conducive to the relationship prediction task. Some relationship sequences are noisy. Therefore, when the semantic types in the graph are very rich, the learning ability of such methods will be greatly affected. For subgraph-based knowledge graph relationship prediction tasks, it is also a daunting challenge to increase the robustness in the face of sparse subgraphs and to maximize the mining of valuable reasoning information in the subgraphs. Existing subgraph-based knowledge graph relationship prediction methods usually model each relationship path and integrate the learned relationship sequence features to perform relationship prediction tasks. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a knowledge graph relationship prediction method based on subgraph relationship information, which solves the problem that the existing subgraph-based prediction model has poor robustness in the face of sparse subgraphs.
[0005] In order to achieve the above-mentioned invention object, the technical solution adopted by the present invention is: a knowledge graph relationship prediction method based on subgraph relationship information, comprising:
[0006] S1: By analyzing the relationship links of entity data, a knowledge graph subgraph is obtained;
[0007] S2: Based on the knowledge graph subgraph, the location features of the entity and the neighborhood relationship features of the entity are analyzed and integrated to obtain information-enhanced initial representation feature data;
[0008] S3: inputting the initial representation feature data into a representation feature prediction model to obtain representation feature data; the representation feature prediction model is obtained through training;
[0009] S4: Perform path analysis on the knowledge graph subgraph using a biased random walk method to obtain path feature data of the knowledge graph subgraph;
[0010] S5: Based on the entity data, the representation feature data and the path feature data, a triple scoring function is used to perform comprehensive calculations to obtain a knowledge graph relationship prediction result, thereby completing the prediction of the knowledge graph relationship.
[0011] The beneficial effects of the present invention are as follows: the processor obtains the knowledge graph relationship prediction result by performing information enhancement analysis on the knowledge graph subgraph. (1) By utilizing the relationship information in the knowledge graph subgraph, the prediction accuracy and robustness in the face of sparse subgraphs are improved; (2) By representing the feature prediction model, the interactive information of entities and relationships is increased to obtain a richer representation of features; (3) The biased random walk method is used to further filter information, and the most valuable reasoning information is learned through the attention mechanism to improve the efficiency and accuracy of obtaining prediction results; (4) By constructing a directed surrounding subgraph of the target triple, the entity, relationship, relationship path, and subgraph are explicitly analyzed, and the most valuable relationship path in the subgraph is further mined, which enhances the robustness of the model in the face of sparse subgraphs, thereby improving the accuracy of relationship prediction.
[0012] Furthermore, the S1 includes:
[0013] Based on the relationship links of the entity data, the output path of the acquired head entity and the input path of the tail entity are fused to construct a knowledge graph subgraph; the entity data includes the head entity and the tail entity, and the knowledge graph subgraph is a directed target graph including entity adjacent relationships.
[0014] Further, the S2 includes:
[0015] S210: Based on the knowledge graph subgraph, the distance between the head entity and the tail entity is analyzed to obtain the location feature of the entity;
[0016] S220: Using the entity adjacency relationship in the knowledge graph subgraph, information is transferred and aggregated on the entity to obtain the neighborhood relationship feature of the entity;
[0017] S230: Fusing the location feature of the entity and the neighborhood relationship feature of the entity, and mapping them to an embedding space with the same relationship, to obtain information-enhanced initial representation feature data:
[0018]
[0019] in, represents the initial representation feature data of information enhancement, W0 represents the coefficient matrix, Represents the neighborhood relationship characteristics of the entity, It represents the location feature of the entity, and ⊕ represents the vector concatenation operation.
[0020] Furthermore, the expression of the position feature of the entity is:
[0021]
[0022] in, It represents the position feature of the entity, one-hot represents the unique hot encoding method, d(i,u) represents the shortest distance from the entity to the head entity, d(i,v) represents the shortest distance from the entity to the tail entity, i represents the target entity, u represents the head entity, and v represents the tail entity.
[0023] Furthermore, the expression of the neighborhood relationship feature of the entity is:
[0024]
[0025] in, Represents the neighborhood relationship characteristics of the entity, α r Indicates that in the target relation r t The attention weight of the next neighboring relation r on entity i, e r The eigenvector representing the neighbor relationship of r, Represents the target relationship r t The eigenvector of r represents the adjacent relationship r, r t Represents the target relationship r t , N r (i) represents the set of relations related to entity i, and softmax represents α r Attention weight calculation function, e r The relation embedding vector representing the r adjacent relations, Represents the target relationship r t The relationship embedding vector of , exp represents the exponential function with natural constant as the base, The transpose of the eigenvector representing the neighbor relationship of r, The transpose of the eigenvector representing the neighbor relation of r', r' represents the neighbor relation of r'.
[0026] Further, the S3 includes:
[0027] S310: Input the initial representation feature data into the representation feature prediction model to obtain the entity representation features output at each level; wherein the adjacent relationship feature vector of each level is obtained by mapping the adjacent relationship feature vector of the previous level:
[0028]
[0029] α i,r =σ2(W2c i,r +b2);
[0030]
[0031] in, represents the representation feature of entity i output by the kth layer of the feature prediction model, α i,r represents the attention weight of edge (i,r,j), represents the transformation matrix of the adjacent relationship r, φ represents the fusion function, represents the k-1th level feature vector of the neighboring relation r, represents the feature vector of entity j at the k-1th layer, r represents the adjacent relationship r, R represents the type set of all relationships, j represents entity j, N r (i) represents the neighbor entity set of entity i under the neighbor relationship r, σ2 represents the second Sigmoid function, W2 represents the second weight matrix, c i,r represents the context vector, b2 represents the second bias term, σ1 represents the first Sigmoid function, W1 represents the first weight matrix, represents the feature vector of entity i at level k-1, Represents the target relationship r t The k-1th layer feature vector of , b1 represents the first bias term, k represents the kth layer of the feature prediction model, represents the k-th level feature vector of the neighboring relation r, A mapping matrix representing the neighbor relationship;
[0032] S320: Based on the entity representation features of the last layer of the representation feature prediction model, the representation feature data is obtained by calculation:
[0033]
[0034] Among them, h G Represents characteristic data, V G represents all entities in the knowledge graph subgraph, Represents the entity representation features of the last layer.
[0035] Further, the S4 includes:
[0036] S410: Using the biased random walk method, we explore the paths between the nodes of the knowledge graph subgraph based on the probability of neighbor entity selection and obtain the path relationship matrix:
[0037]
[0038] Among them, p represents the path relationship matrix, p represents the path relationship vector, GRU represents the gated recurrent unit, Represents the target relationship r u The characteristic vector of Represents the target relationship r t The characteristic vector of Represents the target relationship r v The characteristic vector of i represents the probability of neighbor entity selection, w vi represents the edge weight from entity v to neighbor entity i, w vj represents the edge weight from entity v to neighbor entity j;
[0039] S420: Based on the path weight, the path relationship matrix is fused to obtain the path feature data of the knowledge graph subgraph:
[0040]
[0041] Among them, p G Represents the path feature data of the knowledge graph subgraph, β p represents the path weight, P represents the path set, exp represents the exponential function with the natural constant as the base, and p · represents the transpose of the path relationship matrix, represents the transpose of the p' path relationship matrix, and p' represents the path set P (u,v) A path in P (u,v) Represents the set of all paths from entity u to entity v.
[0042] Further, the S5 includes:
[0043] S510: Combining the representation feature data and the path feature data, and obtaining the final feature data of the knowledge graph subgraph by vector concatenation:
[0044] s G =[h G ⊕p G ];
[0045] Among them, s G Represents the final feature data of the knowledge graph subgraph, h G Represents the characteristic data, p G Represents path feature data, ⊕ represents vector concatenation operation;
[0046] S520: Using the triple scoring function, a comprehensive analysis is performed on the head entity, the tail entity, and the entity adjacent relationship of the knowledge graph subgraph to obtain the knowledge graph relationship prediction result, thereby completing the prediction of the knowledge graph relationship:
[0047]
[0048] Among them, f(u,v t ,r) represents the knowledge graph relationship prediction result, W s represents the parameter matrix, The feature vector representing the head entity, The feature vector representing the tail entity, A feature vector representing a candidate target relation. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] This specification will be further described in the form of exemplary embodiments, which will be described in detail by the accompanying drawings. These embodiments are not restrictive, and in these embodiments, the same number represents the same structure, wherein:
[0050] Figure 1 It is a module schematic diagram of a knowledge graph relationship prediction system based on subgraph relationship information according to some embodiments of this specification;
[0051] Figure 2 This is an exemplary flowchart of a knowledge graph relationship prediction method based on subgraph relationship information according to some embodiments of this specification. DETAILED DESCRIPTION
[0052] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
[0053] Embodiment 1
[0054] Figure 1 It is a module diagram of a knowledge graph relationship prediction system based on sub-graph relationship information according to some embodiments of this specification.
[0055] In some embodiments, the knowledge graph relationship prediction system based on subgraph relationship information may include an acquisition module, an initial feature extraction module, a representation feature extraction module, a path feature extraction module and a prediction module.
[0056] The acquisition module is used to obtain the knowledge graph subgraph by analyzing the relationship links of entity data; for more details about the knowledge graph subgraph, see Figure 2 and its related description.
[0057] The initial feature extraction module is used to analyze and fuse the location features of the entity and the neighborhood relationship features of the entity based on the knowledge graph subgraph to obtain information-enhanced initial representation feature data; for more details about the information-enhanced initial representation feature data, please refer to Figure 2 and its related description.
[0058] The representation feature extraction module is used to input the initial representation feature data into the representation feature prediction model to obtain the representation feature data; the representation feature prediction model is obtained through training; for more details about the representation feature data, please refer to Figure 2 and its related description.
[0059] The path feature extraction module is used to perform path analysis on the knowledge graph subgraph using a biased random walk method to obtain the path feature data of the knowledge graph subgraph. For more details about the path feature data of the knowledge graph subgraph, please refer to Figure 2 and its related description.
[0060] The prediction module is used to perform comprehensive calculations based on the entity data, the representation feature data and the path feature data using the triple scoring function to obtain the knowledge graph relationship prediction results and complete the prediction of the knowledge graph relationship. For more details about the knowledge graph relationship prediction results, please refer to Figure 2 and its related description.
[0061] In some embodiments, a knowledge graph relationship prediction system based on subgraph relationship information can be used to execute a knowledge graph relationship prediction method based on subgraph relationship information, including S1: obtaining a knowledge graph subgraph by analyzing the relationship links of entity data; S2: based on the knowledge graph subgraph, analyzing and fusing position features and neighborhood relationship features to obtain information-enhanced initial representation feature data; S3: inputting the initial representation feature data into a representation feature prediction model to obtain representation feature data; the representation feature prediction model is obtained through training; S4: performing path analysis on the knowledge graph subgraph using a biased random walk method to obtain path feature data of the knowledge graph subgraph; S5: based on the entity data, the representation feature data and the path feature data, using a triple scoring function for comprehensive calculation to obtain a knowledge graph relationship prediction result, thereby completing the prediction of the knowledge graph relationship.
[0062] In some embodiments of the present specification, the processor uses a knowledge graph relationship prediction system based on subgraph relationship information to execute a knowledge graph relationship prediction system based on subgraph relationship information. (1) By using the relationship information in the knowledge graph subgraph, the prediction accuracy and robustness in the face of sparse subgraphs are improved; (2) By representing the feature prediction model, the interactive information of entities and relationships is increased to obtain a richer representation of features; (3) The biased random walk method is used to further filter information, and the most valuable reasoning information is learned through the attention mechanism to improve the efficiency and accuracy of obtaining prediction results; (4) By constructing a directed surrounding subgraph of the target triple, the entity, relationship, relationship path, and subgraph are explicitly analyzed to further explore the most valuable relationship path in the subgraph, thereby enhancing the robustness of the model in the face of sparse subgraphs, thereby improving the accuracy of relationship prediction.
[0063] Embodiment 2
[0064] Figure 2 is an exemplary flow chart of a knowledge graph relationship prediction method based on subgraph relationship information according to some embodiments of this specification. Figure 2 As shown, the process includes the following steps. In some embodiments, the process can be executed by a processor.
[0065] S1: By analyzing the relationship links of entity data, a knowledge graph subgraph is obtained.
[0066] Entity data is text data with connections between data. For example, entity data can include text data such as couples, places of occurrence, friends, time of occurrence, and cooperative relationships in the fields of news, broadcasting, blogs, finance, and justice.
[0067] In some embodiments, the processor may obtain entity data based on text data uploaded by the user.
[0068] A knowledge graph subgraph is a knowledge graph composed of partial entity data with relationship.
[0069] In some embodiments, the processor may fuse the obtained output path of the head entity and the input path of the tail entity based on the relationship links of the entity data to construct a knowledge graph subgraph.
[0070] The head entity is the entity that is the beginning of the connection relationship. For example, the head entity may be the entity at position (0,1).
[0071] The tail entity is the entity that ends the connection relationship. For example, the tail entity may be the entity at position (1,0).
[0072] In some embodiments, the processor may detect the paths of the head entity and the tail entity to obtain the corresponding output path of the head entity and the input path of the tail entity.
[0073] S2: Based on the knowledge graph subgraph, the location features of the entity and the neighborhood relationship features of the entity are analyzed and integrated to obtain information-enhanced initial representation feature data.
[0074] The location feature of an entity is feature data that reflects the corresponding position of the entity in the knowledge graph subgraph.
[0075] The neighborhood relationship feature of an entity is the feature data that reflects the link relationship between the entity and the surrounding entities.
[0076] The information-enhanced initial representation feature data is the initial information-enhanced feature data reflecting the entity location and surrounding link relationships.
[0077] In some embodiments, the processor may implement S2 based on the following steps.
[0078] S210: Based on the knowledge graph subgraph, the distance between the head entity and the tail entity is analyzed to obtain the location features of the entity.
[0079] In some embodiments, the expression of the location feature of an entity may be:
[0080]
[0081] in, It represents the position feature of the entity, one-hot represents the unique hot encoding method, d(i,u) represents the shortest distance from the entity to the head entity, d(i,v) represents the shortest distance from the entity to the tail entity, i represents the target entity, u represents the head entity, and v represents the tail entity.
[0082] S220: Utilize the entity adjacency relationship in the knowledge graph subgraph to transfer and aggregate information on the entity to obtain the neighborhood relationship features of the entity.
[0083] In some embodiments, the expression of the neighborhood relationship feature of an entity may be:
[0084]
[0085] in, Represents the neighborhood relationship characteristics of the entity, α r Indicates that in the target relation r t The attention weight of the next neighboring relation r on entity i, e r The eigenvector representing the neighbor relationship of r, Represents the target relationship r t The eigenvector of r represents the adjacent relationship r, r t Represents the target relationship r t , N r(i) represents the set of relations related to entity i, and softmax represents α r Attention weight calculation function, e r The relation embedding vector representing the r adjacent relations, Represents the target relationship r t The relationship embedding vector of , exp represents the exponential function with natural constant as the base, The transpose of the eigenvector representing the neighbor relationship of r, The transpose of the eigenvector representing the neighbor relation of r', r' represents the neighbor relation of r'.
[0086] S230: Fusing the location feature of the entity and the neighborhood relationship feature of the entity, and mapping them to an embedding space with the same relationship to obtain information-enhanced initial representation feature data.
[0087] In some embodiments, the expression of the initial representation feature data of information enhancement may be:
[0088]
[0089] in, represents the initial representation feature data of information enhancement, W0 represents the coefficient matrix, Represents the neighborhood relationship characteristics of the entity, It represents the location feature of the entity, and ⊕ represents the vector concatenation operation.
[0090] S3: Inputting the initial representation feature data into a representation feature prediction model to obtain representation feature data; the representation feature prediction model is obtained through training.
[0091] The representation feature data is the final representation feature in the form of entity and relationship vectors.
[0092] The representation feature prediction model is a neural network model for obtaining representation feature data. For example, the representation feature prediction model may include a graph neural network model.
[0093] In some embodiments, the representation feature prediction model can be obtained by training multiple labeled training samples. For example, multiple labeled training samples can be input into the initial representation feature prediction model, and a loss function can be constructed by using the labels and the results of the initial representation feature prediction model. The parameters of the initial representation feature prediction model can be iteratively updated by gradient descent or other methods based on the marginal loss function, so that the score of the representation feature prediction model on the positive sample exceeds the score of the negative sample as much as possible. When the preset conditions are met, the model training is completed, and a trained representation feature prediction model is obtained. Among them, the preset conditions can be that the loss function converges, the number of iterations reaches a threshold, etc.
[0094] In some embodiments, the training sample may include historical initial representation feature data. The label may be the corresponding representation feature data. The label may be manually annotated.
[0095] In some embodiments, the processor may implement S3 based on the following steps.
[0096] S310: Inputting the initial representation feature data into a representation feature prediction model to obtain entity representation features output at each level; wherein the adjacent relationship feature vectors at each level are obtained by mapping the adjacent relationship feature vectors at the previous level.
[0097] In some embodiments, the expression of the entity representation feature output at each level may be:
[0098]
[0099] α i,r =σ2(W2c i,r +b2);
[0100]
[0101] in, represents the representation feature of entity i output by the kth layer of the feature prediction model, α i,r represents the attention weight of edge (i,r,j), represents the transformation matrix of the adjacent relationship r, φ represents the fusion function, represents the k-1th level feature vector of the neighboring relation r, represents the feature vector of entity j at the k-1th layer, r represents the adjacent relationship r, R represents the type set of all relationships, j represents entity j, N r (i) represents the neighbor entity set of entity i under the neighbor relationship r, σ2 represents the second Sigmoid function, W2 represents the second weight matrix, c i,r represents the context vector, b2 represents the second bias term, σ1 represents the first Sigmoid function, W1 represents the first weight matrix, represents the feature vector of entity i at level k-1, Represents the target relationship r t The k-1th layer feature vector of , b1 represents the first bias term, k represents the kth layer of the feature prediction model, represents the k-th level feature vector of the neighboring relation r, A mapping matrix representing adjacency relations.
[0102] S320: Obtain the representation feature data through calculation based on the entity representation features of the last layer of the representation feature prediction model.
[0103] In some embodiments, the expression representing the characteristic data may be:
[0104]
[0105] Among them, h G Represents characteristic data, V G represents all entities in the knowledge graph subgraph, Represents the entity representation features of the last layer.
[0106] S4: Use a biased random walk method to perform path analysis on the knowledge graph subgraph to obtain path feature data of the knowledge graph subgraph.
[0107] The biased random walk method is a method of performing random walks based on the weights between nodes to explore paths between nodes.
[0108] The path feature data of the knowledge graph subgraph is the feature data of each path obtained by integrating biased random walk.
[0109] In some embodiments, the processor may learn the relationship feature data in the paths in sequence to obtain feature data of each path.
[0110] In some embodiments, the processor may implement S4 based on the following steps.
[0111] S410: Using the biased random walk method, the paths between the nodes of the knowledge graph subgraph are explored based on the neighbor entity selection probability to obtain the path relationship matrix.
[0112] The neighbor entity selection probability is the probability data of selecting surrounding entities when the processor explores the knowledge graph subgraph path.
[0113] In some embodiments, the expression of the neighbor entity selection probability may be:
[0114]
[0115] Among them, p i represents the probability of neighbor entity selection, w vi represents the edge weight from entity v to neighbor entity i, w vj represents the edge weight from entity v to its neighbor entity j.
[0116] In some embodiments, the expression of the path relationship matrix may be:
[0117]
[0118] Among them, p represents the path relationship matrix, p represents the path relationship vector, GRU represents the gated recurrent unit, Represents the target relationship ru The characteristic vector of Represents the target relationship r t The characteristic vector of Represents the target relationship r v The feature vector of .
[0119] S420: Based on the path weight, the path relationship matrix is fused to obtain the path feature data of the knowledge graph subgraph.
[0120] Path weight is data that reflects the importance of each path in a knowledge graph subgraph.
[0121] In some embodiments, the processor may analyze the importance of the path based on the probability of neighbor entity selection to obtain the corresponding path weight. For example, the processor may obtain the similarity between the path feature vector and the path relationship vector through dot product calculation, and then convert the similarity value into a non-negative number through an exponential function to obtain the path weight; wherein the sum of the weights of all paths is 1.
[0122] In some embodiments, the expression of the path feature data of the knowledge graph subgraph can be:
[0123]
[0124] Among them, p G Represents the path feature data of the knowledge graph subgraph, β p represents the path weight, P represents the path set, exp represents the exponential function with the natural constant as the base, and p · represents the transpose of the path relationship matrix, represents the transpose of the p' path relationship matrix, and p' represents the path set P (u,v) A path in P (u,v) Represents the set of all paths from entity u to entity v.
[0125] S5: Based on the entity data, the representation feature data and the path feature data, a triple scoring function is used to perform comprehensive calculations to obtain a knowledge graph relationship prediction result, thereby completing the prediction of the knowledge graph relationship.
[0126] The knowledge graph relationship prediction result is a result that reflects the possibility that the candidate relationship is the true relationship between two entities.
[0127] In some embodiments, the processor may implement S5 based on the following steps.
[0128] S510: Combine the representation feature data and the path feature data to obtain final feature data of the knowledge graph subgraph through vector concatenation.
[0129] The final feature data of the knowledge graph subgraph is the feature data that reflects the position and relationship of each entity in the knowledge graph subgraph.
[0130] In some embodiments, the expression of the final feature data of the knowledge graph subgraph can be:
[0131] s G =[h G ⊕p G ];
[0132] Among them, s G Represents the final feature data of the knowledge graph subgraph, h G Represents the characteristic data, p G Represents path feature data, and ⊕ represents a vector concatenation operation.
[0133] S520: Using the triple scoring function, a comprehensive analysis is performed on the head entity, the tail entity and the entity adjacent relationship of the knowledge graph subgraph to obtain the knowledge graph relationship prediction result, thereby completing the prediction of the knowledge graph relationship.
[0134] In some embodiments, the expression of the knowledge graph relationship prediction result can be:
[0135]
[0136] Among them, f(u,v t ,r) represents the knowledge graph relationship prediction result, W s represents the parameter matrix, The feature vector representing the head entity, The feature vector representing the tail entity, A feature vector representing a candidate target relation.
[0137] In some embodiments of the present specification, the processor obtains the knowledge graph relationship prediction result by performing information enhancement analysis on the knowledge graph subgraph. (1) By utilizing the relationship information in the knowledge graph subgraph, the prediction accuracy and robustness when facing sparse subgraphs are improved; (2) By representing the feature prediction model, the interactive information of entities and relationships is increased to obtain a more feature-rich representation; (3) The biased random walk method is used to further filter information, and the most valuable reasoning information is learned through the attention mechanism to improve the efficiency and accuracy of obtaining prediction results; (4) By constructing a directed surrounding subgraph of the target triple, the entity, relationship, relationship path, and subgraph are explicitly analyzed to further explore the most valuable relationship path in the subgraph, thereby enhancing the robustness of the model in the face of sparse subgraphs, thereby improving the accuracy of relationship prediction.
[0138] Embodiment 3
[0139] In order to solve the problem of poor robustness in the face of sparse subgraphs of family members, existing technologies usually focus on extracting and mining the relationship paths between two family member entities and learning their rule structures. However, these methods only focus on the rule information contained in the family member subgraph paths, but ignore the fact that not all relationship paths in the family member subgraphs are conducive to the relationship prediction task, and some relationship sequences are noisy. Therefore, when the semantic types in the family member graph are very rich, the learning ability of such methods will be greatly affected. For the family member knowledge graph relationship prediction task based on subgraphs, it is also a daunting challenge to increase the robustness in the face of sparse subgraphs and to maximize the mining of valuable reasoning information in the family member subgraph. Existing family member knowledge graph relationship prediction methods based on subgraphs usually model each relationship path and integrate the learned relationship sequence features to perform family member relationship prediction tasks.
[0140] In some embodiments, a knowledge graph relationship prediction method based on subgraph relationship information includes:
[0141] S1: By analyzing the relationship links of family member entity data, a family member knowledge graph subgraph is obtained;
[0142] S2: Based on the family member knowledge graph subgraph, the location features of the entity and the neighborhood relationship features of the entity are analyzed and integrated to obtain information-enhanced initial representation feature data;
[0143] S3: inputting the initial representation feature data into a representation feature prediction model to obtain representation feature data; the representation feature prediction model is obtained through training;
[0144] S4: Perform path analysis on the knowledge graph subgraph using a biased random walk method to obtain path feature data of the knowledge graph subgraph;
[0145] S5: Based on the entity data, the representation feature data and the path feature data, a triple scoring function is used to perform comprehensive calculations to obtain family member knowledge graph relationship prediction results, thereby completing the prediction of family member knowledge graph relationships.
[0146] In some embodiments, the S1 includes:
[0147] Based on the relationship links of the family member entity data, the output path of the acquired head entity and the input path of the tail entity are fused to construct a family member knowledge graph subgraph; the entity data includes the head entity and the tail entity, and the family member knowledge graph subgraph is a directed target graph including entity adjacent relationships.
[0148] In some embodiments, the S2 includes:
[0149] S210: Based on the family member knowledge graph subgraph, the distance between the head entity and the tail entity is analyzed to obtain the location feature of the entity;
[0150] S220: Using the entity neighbor relationship in the family member knowledge graph subgraph, information is transferred and aggregated to obtain the neighborhood relationship features of the entity;
[0151] S230: Fusing the location feature of the entity and the neighborhood relationship feature of the entity, and mapping them to an embedding space with the same relationship, to obtain information-enhanced initial representation feature data:
[0152]
[0153] in, represents the initial representation feature data of information enhancement, W0 represents the coefficient matrix, Represents the neighborhood relationship characteristics of the entity, It represents the location feature of the entity, and ⊕ represents the vector concatenation operation.
[0154] In some embodiments, the expression of the location feature of the entity is:
[0155]
[0156] in, It represents the position feature of the entity, one-hot represents the unique hot encoding method, d(i,u) represents the shortest distance from the entity to the head entity, d(i,v) represents the shortest distance from the entity to the tail entity, i represents the target entity, u represents the head entity, and v represents the tail entity.
[0157] In some embodiments, the expression of the neighborhood relationship feature of the entity is:
[0158]
[0159] in, Represents the neighborhood relationship characteristics of the entity, α r Indicates that in the target relation r t The attention weight of the next neighboring relation r on entity i, e r The eigenvector representing the neighbor relationship of r, Represents the target relationship r t The eigenvector of r represents the adjacent relationship r, r t Represents the target relationship r t , N r ( i ) represents the set of relations related to entity i, and softmax represents α r Attention weight calculation function, e rThe relation embedding vector representing the r adjacent relations, Represents the target relationship r t The relationship embedding vector of , exp represents the exponential function with natural constant as the base, The transpose of the eigenvector representing the neighbor relationship of r, The transpose of the eigenvector representing the neighbor relation of r', r' represents the neighbor relation of r'.
[0160] In some embodiments, the S3 includes:
[0161] S310: Input the initial representation feature data into the representation feature prediction model to obtain the entity representation features output at each level; wherein the adjacent relationship feature vector of each level is obtained by mapping the adjacent relationship feature vector of the previous level:
[0162]
[0163] in, represents the representation feature of entity i output by the kth layer of the feature prediction model, α i,r represents the attention weight of edge (i,r,j), represents the transformation matrix of the adjacent relationship r, φ represents the fusion function, represents the k-1th level feature vector of the neighboring relation r, represents the feature vector of entity j at the k-1th layer, r represents the adjacent relationship r, R represents the type set of all relationships, j represents entity j, N r (i) represents the neighbor entity set of entity i under the neighbor relationship r, σ2 represents the second Sigmoid function, W2 represents the second weight matrix, c i,r represents the context vector, b2 represents the second bias term, σ1 represents the first Sigmoid function, W1 represents the first weight matrix, represents the feature vector of entity i at level k-1, Represents the target relationship r t The k-1th layer feature vector of , b1 represents the first bias term, k represents the kth layer of the feature prediction model, represents the k-th level feature vector of the neighboring relation r, A mapping matrix representing the neighbor relationship;
[0164] S320: Based on the entity representation features of the last layer of the representation feature prediction model, the representation feature data is obtained by calculation:
[0165]
[0166] Among them, h G Represents characteristic data, V Grepresents all entities in the knowledge graph subgraph, Represents the entity representation features of the last layer.
[0167] In some embodiments, the S4 includes:
[0168] S410: Using the biased random walk method, we explore the paths between the nodes of the knowledge graph subgraph based on the probability of neighbor entity selection and obtain the path relationship matrix:
[0169]
[0170]
[0171] Among them, p represents the path relationship matrix, p represents the path relationship vector, GRU represents the gated recurrent unit, Represents the target relationship r u The characteristic vector of Represents the target relationship r t The characteristic vector of Represents the target relationship r v The characteristic vector of i represents the probability of neighbor entity selection, w vi represents the edge weight from entity v to neighbor entity i, w vj represents the edge weight from entity v to neighbor entity j;
[0172] S420: Based on the path weight, the path relationship matrix is fused to obtain the path feature data of the knowledge graph subgraph:
[0173]
[0174] Among them, p G Represents the path feature data of the family member knowledge graph subgraph, β p represents the path weight, P represents the path set, exp represents the exponential function with the natural constant as the base, and p · represents the transpose of the path relationship matrix, Represents the transpose of the p' path relationship matrix, p' represents a path in the path set P(u,v), and P(u,v) represents the set of all paths from entity u to entity v.
[0175] In some embodiments, the S5 includes:
[0176] S510: Combine the representation feature data and the path feature data, and obtain the final feature data of the family member knowledge graph subgraph through vector concatenation:
[0177] s G =[h G ⊕pG ];
[0178] Among them, s G represents the final feature data of the family member knowledge graph subgraph, h G Represents the characteristic data, p G Represents path feature data, ⊕ represents vector concatenation operation;
[0179] S520: Using the triple scoring function, a comprehensive analysis is performed on the head entity, tail entity, and entity adjacent relationship of the family member knowledge graph subgraph to obtain a knowledge graph relationship prediction result, thereby completing the prediction of the family member knowledge graph relationship:
[0180]
[0181] Among them, f(u,v t ,r) represents the prediction result of the knowledge graph relationship of family members, W s represents the parameter matrix, The feature vector representing the head entity, The feature vector representing the tail entity, A feature vector representing a candidate target relation.
Claims
1. A knowledge graph relationship prediction method based on subgraph relationship information, characterized in that: include: S1: By analyzing the relationship links of entity data, a knowledge graph subgraph is obtained; S2: Based on the knowledge graph subgraph, the location features of the entity and the neighborhood relationship features of the entity are analyzed and integrated to obtain information-enhanced initial representation feature data; S3: inputting the initial representation feature data into a representation feature prediction model to obtain representation feature data; the representation feature prediction model is obtained through training; S4: Perform path analysis on the knowledge graph subgraph using a biased random walk method to obtain path feature data of the knowledge graph subgraph; S5: Based on the entity data, the representation feature data and the path feature data, a triple scoring function is used to perform comprehensive calculations to obtain a knowledge graph relationship prediction result, thereby completing the prediction of the knowledge graph relationship.
2. The knowledge graph relationship prediction method based on subgraph relationship information according to claim 1 is characterized in that: The S1 includes: Based on the relationship links of the entity data, the output path of the acquired head entity and the input path of the tail entity are fused to construct a knowledge graph subgraph; the entity data includes the head entity and the tail entity, and the knowledge graph subgraph is a directed target graph including entity adjacent relationships.
3. The knowledge graph relationship prediction method based on subgraph relationship information according to claim 2 is characterized in that: The S2 includes: S210: Based on the knowledge graph subgraph, the distance between the head entity and the tail entity is analyzed to obtain the location feature of the entity; S220: Using the entity adjacency relationship in the knowledge graph subgraph, information is transferred and aggregated to obtain the neighborhood relationship features of the entity; S230: Fusing the location feature of the entity and the neighborhood relationship feature of the entity, and mapping them to an embedding space with the same relationship, to obtain information-enhanced initial representation feature data: in, represents the initial representation feature data of information enhancement, W0 represents the coefficient matrix, Represents the neighborhood relationship characteristics of the entity, Represents the location characteristics of the entity, Represents a vector concatenation operation.
4. The knowledge graph relationship prediction method based on subgraph relationship information according to claim 3 is characterized in that: The expression of the position feature of the entity is: in, It represents the position feature of the entity, one-hot represents the unique hot encoding method, d(i,u) represents the shortest distance from the entity to the head entity, d(i,v) represents the shortest distance from the entity to the tail entity, i represents the target entity, u represents the head entity, and v represents the tail entity.
5. The knowledge graph relationship prediction method based on subgraph relationship information according to claim 3 is characterized in that: The expression of the neighborhood relationship feature of the entity is: in, Represents the neighborhood relationship characteristics of the entity, α r Indicates that in the target relation r t The attention weight of the next neighboring relation r on entity i, e r The eigenvector representing the neighbor relationship of r, Represents the target relationship r t The eigenvector of r represents the adjacent relationship r, r t Represents the target relationship r t , N r ( i ) represents the set of relations related to entity i, and softmax represents α r Attention weight calculation function, e r The relation embedding vector representing the r adjacent relations, Represents the target relationship r t The relationship embedding vector of , exp represents the exponential function with natural constant as the base, The transpose of the eigenvector representing the neighbor relationship of r, The transpose of the eigenvector representing the neighbor relation of r', r' represents the neighbor relation of r'.
6. The knowledge graph relationship prediction method based on subgraph relationship information according to claim 1, characterized in that: The S3 includes: S310: Input the initial representation feature data into the representation feature prediction model to obtain the entity representation features output at each level; wherein the adjacent relationship feature vector of each level is obtained by mapping the adjacent relationship feature vector of the previous level: a i,r =σ2(W2c i,r +b2); in, represents the representation feature of entity i output by the kth layer of the feature prediction model, α i,r represents the attention weight of edge (i,r,j), represents the transformation matrix of the adjacent relationship r, φ represents the fusion function, represents the k-1th level feature vector of the neighboring relation r, represents the feature vector of entity j at the k-1th layer, r represents the adjacent relationship r, R represents the type set of all relationships, j represents entity j, N r (i) represents the neighbor entity set of entity i under the neighbor relationship r, σ2 represents the second Sigmoid function, W2 represents the second weight matrix, c i,r represents the context vector, b2 represents the second bias term, σ1 represents the first Sigmoid function, W1 represents the first weight matrix, represents the feature vector of entity i at level k-1, Represents the target relationship r t The k-1th layer feature vector of , b1 represents the first bias term, k represents the kth layer of the feature prediction model, represents the k-th level feature vector of the neighboring relation r, A mapping matrix representing the neighbor relationship; S320: Based on the entity representation features of the last layer of the representation feature prediction model, the representation feature data is obtained by calculation: Among them, h G Represents characteristic data, V G represents all entities in the knowledge graph subgraph, Represents the entity representation features of the last layer.
7. The knowledge graph relationship prediction method based on subgraph relationship information according to claim 1, characterized in that: The S4 includes: S410: Using the biased random walk method, we explore the paths between the nodes of the knowledge graph subgraph based on the probability of neighbor entity selection and obtain the path relationship matrix: Among them, p represents the path relationship matrix, p represents the path relationship vector, GRU represents the gated recurrent unit, Represents the target relationship r u The characteristic vector of Represents the target relationship r t The characteristic vector of Represents the target relationship r v The characteristic vector of i represents the probability of neighbor entity selection, w vi represents the edge weight from entity v to neighbor entity i, w vj represents the edge weight from entity v to neighbor entity j; S420: Based on the path weight, the path relationship matrix is fused to obtain the path feature data of the knowledge graph subgraph: Among them, p G Represents the path feature data of the knowledge graph subgraph, β p represents the path weight, P represents the path set, exp represents the exponential function with the natural constant as the base, represents the transpose of the path relationship matrix, represents the transpose of the p' path relationship matrix, and p' represents the path set P (u,v) A path in P (u,v) Represents the set of all paths from entity u to entity v.
8. The knowledge graph relationship prediction method based on subgraph relationship information according to claim 2, characterized in that: The S5 includes: S510: Combining the representation feature data and the path feature data, and obtaining the final feature data of the knowledge graph subgraph by vector concatenation: Among them, s G represents the final feature data of the knowledge graph subgraph, h G Represents the characteristic data, p G Represents path feature data, Represents a vector concatenation operation; S520: Analyze the head entity, tail entity and entity adjacent relationship of the knowledge graph subgraph by using the triple scoring function to obtain the knowledge graph relationship prediction result, and complete the prediction of the knowledge graph relationship: Among them, f(u,v t ,r) represents the knowledge graph relationship prediction result, W s represents the parameter matrix, The feature vector representing the head entity, The feature vector representing the tail entity, A feature vector representing a candidate target relation.
Citation Information
Patent Citations
Knowledge graph link prediction method
CN116757283A
Cited By
Wind and light storage scheduling knowledge graph reasoning method and system based on local and global information
CN119294492A
