A neural-symbolic combined knowledge graph reasoning method

CN118469012BActive Publication Date: 2026-09-04UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410402695.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-03
Publication Date
2026-09-04
Estimated Expiration
2044-04-03

AI Technical Summary

Technical Problem

[0005]针对现有技术中的上述不足,本发明提供的神经符合结合的知识图谱推理方法解决了现有的方法要么依赖于观察到的规则实例来支持规则挖掘,要么简单地嵌入规则头和规则体来从中学习,其不能充分利用逻辑规则中包含的丰富语义信息,并忽视了域内所有关系之间的内在相关性的问题

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118469012B_ABST
    Figure CN118469012B_ABST
Patent Text Reader

Abstract

The application discloses a kind of neural symbol combined knowledge graph reasoning method, comprising: S1, the semantics of the knowledge graph to be inferred is enriched, and the relationship embedding in relevant semantics is determined;S2, specified length closed path is sampled on the knowledge graph to be inferred based on random walk strategy, and then the possible rule set is constructed;S3, the semantics of each rule body in the possible rule set is learned using position embedding and semantic learner;S4, based on the semantic consistency of rule head and rule body in the possible rule set, each possible rule is evaluated, and high-confidence rules are selected;S5, according to the selected rules, the knowledge graph is inferred.The present application captures deeper semantic information in rules by allowing relationships to perceive each other and pay attention to logical sequence sensitivity, and uses the semantic consistency of rule head and rule body to mine rules, discarding the traditional method that relies heavily on observed rule instances.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of knowledge graph technology, specifically relating to a knowledge graph reasoning method that combines neural symbols. Background Technology

[0002] A knowledge graph is a structured method for representing the real world. Knowledge graphs, such as Family, UMLS, kinship, and wn-18rr, consist of nodes representing entities and edges representing relationships between entities. Knowledge graphs are composed of triples, in the form of (head entity, relation, tail entity). However, due to limitations in knowledge extraction algorithms, existing knowledge graphs are often incomplete. Knowledge graph reasoning, which predicts missing facts by inferring from existing facts, has become a popular research area in artificial intelligence.

[0003] The main methods for knowledge graph reasoning include embedding-based methods and rule-based methods. Embedding-based methods embed entities or relations into a vector space and seek the most suitable semantic representation; mining deeper semantics is the primary goal of embedding-based methods. Rule-based methods start with symbolic logic, which offers interpretability, but their effectiveness on large datasets is limited due to their large search space. In recent years, researchers have been exploring methods combining neural and symbolic approaches, with rule-learning methods being particularly outstanding. This is because they combine the superior performance of deep learning techniques with the interpretability of symbolic logic reasoning.

[0004] While deep learning demonstrates powerful performance capabilities, its black-box nature hinders its development in high-security fields such as military and medical applications. Furthermore, the high data quality requirements of knowledge graphs constrain the development of symbolic logic reasoning. Therefore, it is necessary to explore a neural symbolic reasoning method that efficiently utilizes existing knowledge within knowledge graphs and possesses a certain degree of interpretability. Summary of the Invention

[0005] To address the aforementioned shortcomings in existing technologies, the neural conformity-based knowledge graph reasoning method provided by this invention solves the problem that existing methods either rely on observed rule instances to support rule mining or simply embed rule heads and bodies to learn from them, which cannot fully utilize the rich semantic information contained in logical rules and ignore the inherent correlations between all relations within the domain.

[0006] To achieve the aforementioned objectives, the present invention employs the following technical solution: a knowledge graph reasoning method combining neural symbols, comprising the following steps:

[0007] S1. Enrich the semantics of the knowledge graph to be reasoned and determine the relational embeddings in its integrated internal related semantics;

[0008] S2. Sample closed paths of a specified length on the knowledge graph to be reasoned based on a random walk strategy, and then construct a set of possible rules.

[0009] S3. Use positional embedding and semantic learner to learn the semantics of each rule body in the possible rule set;

[0010] S4. Based on the semantic consistency between the rule header and rule body in the possible rule set, evaluate each possible rule and select high-confidence rules;

[0011] S5. Perform knowledge graph reasoning based on the selected rules.

[0012] Further, step S1 specifically includes:

[0013] S11. Extract all relations of triples from the knowledge graph to be reasoned, and remove duplicates to obtain the relation set.

[0014] S12, On sets of relations Each relation in Embedding yields the initial embedding matrix E of the relational knowledge graph to be reasoned about. r ;

[0015] S13, Analyze the set of relations The activity S(q) of each relation in the equation i (K), and sort them by relation activity;

[0016] S14. Based on the ranking results of relation activity, use the cross-attention mechanism to determine the most important relation for each relation and determine its probability distribution matrix θ.

[0017] S15. Multiply the probability distribution matrix θ by the initial embedding matrix of the relation Ε r The relation embedding E′ in the knowledge graph to be reasoned is obtained by integrating the inherent related semantics. r .

[0018] Further, step S13 specifically includes:

[0019] S13-1, Randomly from a set of relations Sampling alnL k The key matrix K is a relation used as the self-attention mechanism;

[0020] The matrix of the self-attention mechanism includes a query matrix Q, a key matrix K, and a value matrix V;

[0021] S13-2. Combine the key matrix K with all relations to form the inner product of the query matrix Q, resulting in alnL. k The activity score for each relationship is determined by subtracting the average value from the maximum weight value among the sampled relationships.

[0022] S13-3. Sort the relationships according to their activity level and select the one with the highest activity score, alnL. k The query matrix Q is used as the self-attention mechanism when updating relation embeddings;

[0023] In step S14, when determining the most important relation for each relation, a cross-attention mechanism is used to process the selected alanL. k Update active relationships and apply average processing to the remaining relationships.

[0024] Further, step S2 specifically includes:

[0025] S21. Select n triples T = (h, r, t) in the knowledge graph to be reasoned as anchor triples; where h is the head entity, r is the path, and t is the tail entity;

[0026] S22. Set the maximum walk length to m. For each anchor triple, use a random walk strategy, starting from the head entity h, to reach the tail entity t before the maximum walk length, forming a closed path. As a rule body r b Use the anchor triple as the rule header r h and add it to the possible rule set.

[0027] Where x is the head entity of the anchor triple, y is the tail entity of the anchor triple, z1 is the first entity that can be reached from the head entity using a random walk strategy through a certain relation, and the subscript n represents the number of hops of the random walk strategy starting from the head entity, i.e. the length of the relation path or rule body.

[0028] Further, step S3 specifically includes:

[0029] S31. For possible rule sets Each rule in the body r b The positional encoding of each relation in the rule body is used to obtain the positional embedding Ep, and then the positional embedding Ep is used in conjunction with the relational embedding representation of that rule body. The summation yields the relational embedding of the rule body, which incorporates positional encoding.

[0030] S32, based on By performing multiple rounds of semantic learning on the rule body using a semantic learner, a semantic representation of each rule body is obtained.

[0031] Further, in step S32, the semantic learner includes N layer There are N identical semantic learning layers, each consisting of a sequentially connected feedforward network, a multi-head cross-attention mechanism, and a residual-normalization layer; where N layer The value of is determined based on the length of the possible rules in the possible rule set.

[0032] Furthermore, in step S32, the method of performing multi-round semantic learning on the rule body using a semantic learner is specifically as follows:

[0033] S32-1. In the current round, two adjacent relationships in the rule body are processed through a feedforward network to obtain the embedding vectors of the two adjacent relationships. The query matrix Q serves as a multi-head cross-attention mechanism;

[0034] S32-2. Using all relations in the rule body as the key matrix K, use a multi-head cross-attention mechanism to query the semantically closest relation in the rule body. The relationship is used to obtain an attention weight matrix.

[0035] S32-3, The attention weight matrix of the multi-head cross-attention mechanism With all relation embedding representations E′ r Multiplying them yields a new round of embedding representations of the two adjacency relationships.

[0036] S32-4, will and Add them together and process them through a residual-normalization layer to obtain the result. As one of the two adjacent relations in the rule body during the next round of rule body semantic learning;

[0037] S32-5. Based on steps S32-1 to S32-5, perform multiple rounds of semantic learning on the rule body using a semantic learner to obtain the semantic representation of each rule body.

[0038] Further, step S4 specifically includes:

[0039] S41. The learned rule body semantics Mapping to one-hot vector v rh ;

[0040] S42. Based on the mapped one-hot vector v rh Maximize the score through the rule body The objective function evaluates possible rules;

[0041] S43. Sort the evaluation results according to confidence level, and select the top k rules for each relationship as the high-confidence rules.

[0042] Furthermore, in step S42, the rule body maximizes the score. The objective function is expressed as:

[0043]

[0044] In the formula, This represents a given set of sampling paths. Let |R| represent the attention learned from the sampling path z, and |R| represent the total number of relations.

[0045] The beneficial effects of this invention are as follows:

[0046] (1) This invention captures deeper semantic information in rules by allowing relations to perceive each other and paying attention to the sensitivity of logical sequences, and mines rules by utilizing the semantic consistency of rule heads and rule bodies, thus abandoning the traditional method that relies heavily on observing rule instances.

[0047] (2) Extensive experiments on link prediction tasks show that the present invention can learn higher quality rules and achieve state-of-the-art results on knowledge graph reasoning tasks. Attached Figure Description

[0048] Figure 1 A flowchart of the knowledge graph reasoning method for neural symbol sets provided by this invention.

[0049] Figure 2 A schematic diagram of the model framework for the neural symbol-based knowledge graph reasoning method provided by this invention. Detailed Implementation

[0050] The specific embodiments of the present invention are described below to enable those skilled in the art to understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.

[0051] This invention provides a knowledge graph reasoning method combining neural symbols, such as... Figure 1-2 As shown, it includes the following steps:

[0052] S1. Enrich the semantics of the knowledge graph to be reasoned and determine the relational embeddings in its integrated internal related semantics;

[0053] S2. Sample closed paths of a specified length on the knowledge graph to be reasoned based on a random walk strategy, and then construct a set of possible rules.

[0054] S3. Use positional embedding and semantic learner to learn the semantics of each rule body in the possible rule set;

[0055] S4. Based on the semantic consistency between the rule header and rule body in the possible rule set, evaluate each possible rule and select high-confidence rules;

[0056] S5. Perform knowledge graph reasoning based on the selected rules.

[0057] In step S1 of this embodiment of the invention, the knowledge graph to be reasoned is a family dataset. To complete the embedding representation and semantic enrichment of relations, firstly, all relations are extracted from the family dataset and deduplicated. An initial embedding representation is made for each relation, and the inherent semantic correlation between relations is mined using a relevance module incorporating the idea of ​​knowledge distillation and added to the embedding representation of the relations. Specifically, step S1 in this embodiment of the invention is as follows:

[0058] S11. Extract all relations of triples from the knowledge graph to be reasoned, and remove duplicates to obtain the relation set.

[0059] In this embodiment, pandas and numpy in Python are used to extract all relations in triples in the family knowledge graph;

[0060] S12, On sets of relations Each relation in Embedding yields the initial embedding matrix E of the relational knowledge graph to be reasoned about. r ;

[0061] S13, Analyze the set of relations The activity S(q) of each relation in the equation i (K), and sort them by relation activity;

[0062] S14. Based on the ranking results of relation activity, use the cross-attention mechanism to determine the most important relation for each relation and determine its probability distribution matrix θ.

[0063] S15. Multiply the probability distribution matrix θ by the initial embedding matrix of the relation Ε r The relation embedding E′ in the knowledge graph to be reasoned is obtained by integrating the inherent related semantics. r .

[0064] Step S13 in this embodiment is specifically as follows:

[0065] S13-1, Randomly from a set of relations Sampling alnL k The key matrix K is a relation used as the self-attention mechanism;

[0066] The matrix of the self-attention mechanism includes a query matrix Q, a key matrix K, and a value matrix V;

[0067] S13-2. Combine the key matrix K with all relations to form the inner product of the query matrix Q, resulting in alnL. k The activity score for each relationship is determined by subtracting the average value from the maximum weight value among the sampled relationships.

[0068] The activity score for each relationship is expressed as follows:

[0069]

[0070] In the formula, d represents the dimension of the embedding relationship, and L... k q represents the total number of relation types. i For an embedding representation of a certain relation, k j For a certain relation in the sampled key matrix K;

[0071] S13-3. Sort the relationships according to their activity level and select the one with the highest activity score, alnL. k The query matrix Q is a self-attention mechanism used when updating relation embeddings.

[0072] In step S14 of this embodiment, when determining the most important relation for each relation, a cross-attention mechanism is used, focusing only on the selected alanL. k Update active relationships and apply average processing to the remaining relationships.

[0073] In step S14 of this embodiment, the expression for the cross-attention mechanism is:

[0074]

[0075] Step S2 in this embodiment of the invention is specifically as follows:

[0076] S21. Select n triples T = (h, r, t) in the knowledge graph to be reasoned as anchor triples; where h is the head entity, r is the path, and t is the tail entity;

[0077] S22. Set the maximum walk length to m. For each anchor triple, use a random walk strategy, starting from the head entity h, to reach the tail entity t before the maximum walk length, forming a closed path. As a rule body r b Use the anchor triple as the rule header r hand add it to the possible rule set.

[0078] Where x is the head entity of the anchor triple, y is the tail entity of the anchor triple, z1 is the first entity that can be reached from the head entity using a random walk strategy through a certain relation, and the subscript n represents the number of hops of the random walk strategy starting from the head entity, i.e. the length of the relation path or rule body.

[0079] In this embodiment, the random walk strategy is expressed as:

[0080]

[0081] In the formula, |U(e i )| represents entity e i The neighborhood size; each time for the next entity x i After sampling, all direct connections between x0 and x... i Record all edges to construct a closed path if x0 and x n There is no direct connection between them; the rule headers of these rules are set at a certain ratio. h Setting it to 'null' improves generalization while ensuring that most sampling paths are associated with the observed head relationships.

[0082] Step S3 in this embodiment of the invention is specifically as follows:

[0083] S31. For possible rule sets Each rule in the body r b The positional encoding of each relation in the rule body is used to obtain the positional embedding Ep of the rule body, and then the positional embedding Ep is used to represent the relational embedding of the rule body. The summation yields the relational embedding of the rule body, which incorporates positional encoding.

[0084] Among them, sine and cosine functions are used to apply to the regular body r. b The positional encoding of each relation in the table;

[0085] Represented as:

[0086]

[0087] In the formula, emb([r i r j ,...,r k ]) represents the embedding corresponding to a specific rule body.

[0088] S32, based on By performing multiple rounds of semantic learning on the rule body using a semantic learner, a semantic representation of each rule body is obtained.

[0089] In step S32 of this embodiment, in Figure 2 In the model framework shown, the semantic learner includes N layer There are N identical semantic learning layers, each consisting of a sequentially connected feedforward network, a multi-head cross-attention mechanism, and a residual-normalization layer; where N layer The value of is determined based on the length of the possible rules in the possible rule set.

[0090] Based on the structure of the semantic learner, in step S32 of this embodiment, the method of performing multi-round semantic learning on the rule body through the semantic learner is as follows:

[0091] S32-1. In the current round, two adjacent relationships in the rule body are processed through a feedforward network to obtain the embedding vectors of the two adjacent relationships. The query matrix Q serves as a multi-head cross-attention mechanism;

[0092] The feedforward network consists of two linear transformation layers and one ReLU activation function layer.

[0093] S32-2. Using all relations in the rule body as the key matrix K, use a multi-head cross-attention mechanism to query the semantically closest relation in the rule body. The relationship is used to obtain the attention weight matrix θ;

[0094] S32-3, Integrate the attention weight matrix θ of the multi-head cross-attention mechanism with the all-relation embedding representation E′. r Multiplying them yields a new round of embedding representations of the two adjacency relationships.

[0095] S32-4, will and Add them together and process them through a residual-normalization layer to obtain the result. As one of the two adjacent relations in the rule body during the next round of rule body semantic learning;

[0096] S32-5. Based on steps S32-1 to S32-5, perform multiple rounds of semantic learning on the rule body using a semantic learner to obtain the semantic representation of each rule body.

[0097] Step S4 in this embodiment of the invention is specifically as follows:

[0098] S41. Learn the semantics of the rule body Mapping to one-hot vector v rh ;

[0099] S42. Based on the mapped one-hot vector v rh Maximize the score through the rule body The objective function evaluates possible rules;

[0100] S43. Sort the evaluation results according to confidence level, and select the top k rules for each relationship as the high-confidence rules.

[0101] In step S41 of this embodiment, As a one-hot vector, only one dimension can have a value of "1", and this dimension represents the relationship between semantic prediction and rule body. The corresponding rule header.

[0102] In step S42 of this embodiment, the rule body maximizes the score. The objective function is expressed as:

[0103]

[0104] In the formula, This represents a given set of sampling paths. Let |R| represent the attention learned from the sampling path z, and |R| represent the total number of relations.

[0105] Specifically, The anchor triple r represents the sampling point. h The regular body r obtained by directly closing the sampling can be... b The possibility of sampling unclosed paths in the knowledge graph is considered, and under the open-world assumption, to avoid the assumption that sampling unclosed paths in the knowledge graph is useless, therefore, in this embodiment, the sampling unclosed rules are evaluated using the r-value. h Set to 'null' and participate in training (not for generating rules) to improve generalization performance.

[0106] Specific embodiments have been used to illustrate the principles and implementation methods of this invention. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.

[0107] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific modifications and combinations based on the technical teachings disclosed in this invention without departing from the spirit of the invention, and these modifications and combinations are still within the scope of protection of this invention.

Claims

1. A knowledge graph reasoning method combining neural symbols, characterized in that, Includes the following steps: S1. Enrich the semantics of the knowledge graph to be reasoned and determine the relational embeddings in its integrated internal related semantics; S2. Sample closed paths of a specified length on the knowledge graph to be reasoned based on a random walk strategy, and then construct a set of possible rules. S3. Use positional embedding and semantic learner to learn the semantics of each rule body in the possible rule set; S4. Based on the semantic consistency between the rule header and rule body in the possible rule set, evaluate each possible rule and select high-confidence rules; S5. Perform knowledge graph reasoning based on the selected rules; Step S1 specifically involves: S11. Extract all relations of triples from the knowledge graph to be reasoned, and remove duplicates to obtain the relation set. ; S12, On sets of relations Each relation in The initial embedding matrix of the relationships in the knowledge graph to be reasoned is obtained. ; S13, Analyze the set of relations Activity of each relationship in And sort them by relationship activity; S14. Based on the relationship activity ranking results, use the cross-attention mechanism to determine the most important relationship for each relationship and determine its probability distribution matrix. ; S15, the probability distribution matrix Multiply with the initial embedding matrix of the relation The relation embeddings in the knowledge graph to be reasoned are obtained by integrating the inherent related semantics. .

2. The knowledge graph reasoning method combining neural symbols according to claim 1, characterized in that, Step S13 specifically involves: S13-1, Randomly from a set of relations sampling The key matrix K is a relation used as the self-attention mechanism; The matrix of the self-attention mechanism includes a query matrix Q, a key matrix K, and a value matrix V; S13-2. Combine the key matrix K with all relations to form the inner product of the query matrix Q, and obtain... The activity score for each relationship is determined by subtracting the average value from the maximum weight value among the sampled relationships. S13-3. Sort the relationships according to their activity level and select the one with the highest activity score. The query matrix Q is used as the self-attention mechanism when updating relation embeddings; In step S14, when determining the most important relationship for each relationship, a cross-attention mechanism is used to filter out... Update active relationships and apply average processing to the remaining relationships.

3. The knowledge graph reasoning method combining neural symbols according to claim 1, characterized in that, Step S2 specifically involves: S21. Select the knowledge graph to be reasoned from... n T = ( ) h,r,t ) as anchor triples; where, h For the head entity, r For path, t It is a tail entity; S22. Set the maximum walk length as a rule. m For each anchor triple, a random walk strategy is used to start from the beginning of the entity. h Starting from the point of departure, it will reach the tail entity before reaching the maximum travel distance. t The formed closed path As a rule body Use the anchor triple as the rule head and add it to the possible rule set. ; in, For the head entity of the anchor triple, For the tail entity of the anchor triple, Starting from the first entity, a random walk strategy is used to reach the first entity through a certain relation. The index is... n This represents the number of hops in a random walk strategy starting from the first entity, i.e., the length of the relation path or rule body.

4. The knowledge graph reasoning method combining neural symbols according to claim 1, characterized in that, Step S3 specifically involves: S31. For possible rule sets Each rule in The positional encoding of each relation in the rule body yields the positional embedding. And embed its relationship with the rule body into the representation. The summation yields the relational embedding of the rule body, which incorporates positional encoding. ; S32, based on By using a semantic learner to perform multiple rounds of semantic learning on the rule body, a semantic representation of each rule body is obtained. .

5. The knowledge graph reasoning method combining neural symbols according to claim 4, characterized in that, In step S32, the semantic learner includes Each semantic learning layer consists of three identical semantic learning layers, each comprising a sequentially connected feedforward network, a multi-head cross-attention mechanism, and a residual-normalization layer; wherein... The value of is determined based on the length of the possible rules in the possible rule set.

6. The knowledge graph reasoning method combining neural symbols according to claim 5, characterized in that, In step S32, the method of performing multi-round semantic learning on the rule body using a semantic learner is as follows: S32-1. In the current round, two adjacent relationships in the rule body are processed through a feedforward network to obtain the embedding vectors of the two adjacent relationships. The query matrix Q serves as a multi-head cross-attention mechanism; S32-2. Using all relations in the rule body as the key matrix K, use a multi-head cross-attention mechanism to query the semantically closest relation in the rule body. The relationship is used to obtain an attention weight matrix. ; S32-3, The attention weight matrix of the multi-head cross-attention mechanism With all relational embedding representations Multiplying them yields a new round of embedding representations of the two adjacency relationships. ; S32-4, will and Add them together and process them through a residual-normalization layer to obtain the result. As one of the two adjacent relations in the rule body during the next round of rule body semantic learning; S32-5. Based on steps S32-1 to S32-5, perform multiple rounds of semantic learning on the rule body using a semantic learner to obtain the semantic representation of each rule body. .

7. The knowledge graph reasoning method combining neural symbols according to claim 1, characterized in that, Step S4 specifically involves: S41. The learned rule body semantics Mapping to one-hot vector ; S42. Based on the one-hot vector of the mapping Maximize the score through the rule body The objective function evaluates possible rules; S43. Sort the evaluation results according to confidence level, and select the top k rules for each relationship as the high-confidence rules.

8. The knowledge graph reasoning method combining neural symbols according to claim 7, characterized in that, In step S42, the rule body maximizes the score. The objective function is expressed as: In the formula, This represents a given set of sampling paths. The attention obtained from learning the sampling path z. Indicates the total number of relations.

Citation Information

Patent Citations

  • Construction of graph convolution network learning model based on ontology semantics

    CN112633478A

  • Sequence generation type knowledge reasoning method and system based on Decision Transform

    CN115526322A