Multi-hop reasoning method and system based on type perception aggregation

By introducing a type-aware aggregation mechanism and query embedding strategy in the multi-hop inference technology, the problem of semantic information loss is solved, and more reliable and efficient multi-hop inference results are achieved.

CN119476478APending Publication Date: 2025-02-18HUBEI UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411478456.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

There is a problem of semantic information loss in existing multi-hop inference techniques, which affects the reliability of inference results.

Method used

A multi-hop inference method based on type-aware aggregation is adopted to build a type-aware aggregation mechanism to improve the representation extraction of entity and relationship types, and combine query embedding and dual sampling strategies to achieve effective aggregation and fusion of entity and relationship type information.

Benefits of technology

It effectively avoids the loss of semantic information during the inference process, improves the reliability of the inference results, and reduces the computational complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119476478A_ABST
    Figure CN119476478A_ABST
Patent Text Reader

Abstract

The invention discloses a multi-hop reasoning method and system based on type perception aggregation. Semantic information is achieved by constructing a type perception aggregation mechanism, expression extraction of entities and relation types is improved, and semantic content of an original knowledge graph is enriched. And by adopting a novel fusion mechanism, the representations of the entities and the relationship types are fused together more effectively, and the effectiveness of feature learning is further improved. In order to emphasize relation characterization highly related to the process, an enhanced relation attention mechanism is introduced, the relation characterization is amplified through Heo, Hso and Hro together, relation information can be aggregated in the node interaction process, therefore, updated node embedding has rich information, semantic information loss in the reasoning process is avoided, and the reliability of the system is improved. And the reliability of the reasoning result is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of multi-hop reasoning technology, and in particular to a multi-hop reasoning method and system based on type-aware aggregation. Background Art

[0002] Knowledge graphs (KGs) are semantic networks consisting of entities and relations, where nodes represent entities and edges represent relations between entities. As one of the important research directions of knowledge graphs, knowledge graph reasoning (KGR) aims to solve various logical reasoning tasks by inferring new knowledge from existing datasets. Knowledge graph reasoning has been widely used in many fields in society, including but not limited to question-answering systems, social networks, relation extraction, and recommendation systems.

[0003] The process of reasoning on knowledge graphs is usually divided into two paradigms: single-hop reasoning (SHR) and multi-hop reasoning (MHR). Among them, SHR involves relatively direct reasoning, that is, inferring the third element based on any two elements in the triple in the knowledge graph. More complex than SHR, MHR usually refers to reasoning and inference across multiple entities and relations, which is more in line with the requirements of the real world. Recently, MHR has become a research hotspot in knowledge graph reasoning because it can capture more complex associations between entities beyond directly connected relationships. By traversing the reasoning chain over multiple steps, MHR is able to discover deeper associations, thereby achieving more accurate and comprehensive reasoning and inference.

[0004] However, the main shortcomings of multi-hop reasoning are:

[0005] Loss of semantic information during reasoning. Traditional methods also face problems such as loss of semantic information and unexpected semantic recognition during long path reasoning, which affects the reliability of reasoning results. Summary of the invention

[0006] The present invention solves the technical problem of loss of semantic information in the reasoning process in the prior art by providing a multi-hop reasoning method and system based on type-aware aggregation, and achieves the technical effect of ensuring the reliability of the reasoning result.

[0007] The present invention provides a multi-hop reasoning method based on type-aware aggregation, comprising:

[0008] Knowledge Figure 3 The entity in the tuple is input into the hidden layer to obtain the entity feature H after i+1 iterations. s i+1 , whose expression is H s i+1 =g*(W i ′H s i +b i′)+(1-g)*H s i ;in, is the entity feature after i iterations, σ is the sigmoid function, W i is the learnable matrix of weights after the i-th iteration in the hidden layer, W i ′ is the learnable matrix of weights after the i-th iteration in g, b i is the learnable bias matrix after the i-th iteration in the hidden layer, b i ′ is the bias learnable matrix after the i-th iteration in g;

[0009] H s i+1 After K iterations, we get the entity features after K iterations.

[0010] Will Input the linear layer to get the entity type representation after linear transformation Its expression is Among them, W is the matrix of weight learnability, and b is the matrix of bias learnability;

[0011] Will With the initial entity Connect them in series to enhance the representation and get the final entity representation H e , whose expression is Among them, W′ is a learnable parameter of weight, and b′ is a learnable parameter of bias;

[0012] The knowledge Figure 3 The relationship in the tuple is input into the multi-layer perception network to obtain a relationship type graph, which is expressed as in, is the relationship feature after i iterations, is the relationship feature after j iterations, a i is a positive weight vector;

[0013] A i and Input to the attention layer to aggregate and obtain the vector H of the aggregated type information s , whose expression is

[0014] H e , H s and the initial relationship feature H r Projected into a unified dimensional space, the entities, types, and initial relations are embedded after nonlinear transformation. and Its expression is Among them, f1 represents the nonlinear activation function used to enhance the nonlinear representation ability of the model, W e 0 , W s 0 and W r 0 Trainable parameter matrices representing entities, types, and initial relations respectively;

[0015] Embed the initial entity of the i-th entity Entity representation after k-1 iterations The initial relation embedding with the i-th relation Relation representation after k-1 iterations Add and subtract them respectively, perform XOR operation on the two results, and get the scalar a of the weight of the i-th relationship after k-1 iterations. i k-1 , whose expression is

[0016] A i k-1 After f1 transformation and a learnable parameter matrix After multiplication, it is combined with another learnable parameter matrix Multiply them together, and finally process them with σ to get the attention weight α of the i-th node in the k-1 layer i k-1 , whose expression is in, For the k-1th iteration To transform, For the k-1th iteration Make a transformation;

[0017] Will and the embedding representation obtained by type i after k-1 iterations Input the attention layer to get the attention embedding of edge i after k-1 iterations Its expression is

[0018] The attention embedding after k-1 iterations of the edge The adjacency matrix A connecting entity edges and relationship edges se Perform dot multiplication to obtain the type information aggregation of the entity after k iterations Its expression is

[0019] Will

[0020] The embedding representation after k-1 iterations of type embedding The result is the node embedding parameter matrix W after k iterations. k Multiply them, and then transform them through f1 to get the embedding representation of the type embedding after k iterations. Its expression is

[0021] Aggregate the type information of the entity after l iterations Entity representation after l-1 iterations and Perform XOR operation, and the result is processed by MLP. The result is then processed by GRU mechanism to obtain the final entity representation after l iterations. Its expression is Where l represents the total number of iterations of embedding update, and k is the index of each specific iteration within the total number of iterations l.

[0022] Specifically, the knowledge Figure 3 The entity in the tuple is input into the hidden layer to obtain the entity feature H after i+1 iterations. s i+1 ,include:

[0023] Knowledge Figure 3 The entities and relations in the tuple are mapped to the query structure according to the QCP to obtain the specific query structure corresponding to the query q; each node in the specific query structure represents the knowledge Figure 3 An entity in a tuple, each edge in the specific query structure represents the knowledge Figure 3 A relation in a tuple;

[0024] Starting from the anchor node in the specific query structure, traversing to the intermediate nodes, all retrieved entities are stored in the cache set; starting from the target node in the specific query structure, traversing to the intermediate nodes, all retrieved entities are stored in the traversal set;

[0025] The entities common to the cache set and the traversal set are taken as positive entities to obtain positive samples. Among them, V q are all entities retrieved during the traversal, is a set of positive entities; entities that are not common to the cache set and the traversal set are taken as negative entities to obtain negative samples in, is the set of negative entities;

[0026] The entities in the positive sample and the negative sample are input into the hidden layer to obtain the entity features H after i+1 iterations s i+1 .

[0027] The present invention also provides a multi-hop reasoning system based on type-aware aggregation, comprising:

[0028] Entity feature acquisition module is used to convert knowledge Figure 3 The entity in the tuple is input into the hidden layer to obtain the entity feature H after i+1 iterations. s i+1 , whose expression is H s i+1 =g*(W i ′H s i +b i ′)+(1-g)*H s i ;in, is the entity feature after i iterations, σ is the sigmoid function, W i is the learnable matrix of weights after the i-th iteration in the hidden layer, W i ′ is the learnable matrix of weights after the i-th iteration in g, b i is the learnable bias matrix after the i-th iteration in the hidden layer, b i ′ is the bias learnable matrix after the i-th iteration in g;

[0029] Entity feature iteration module, used to transform H s i+1 After K iterations, we get the entity feature H after K iterations. s K ;

[0030] Linear transformation module, used to transform Input the linear layer to get the entity type representation after linear transformation Its expression is Among them, W is the matrix of weight learnability, and b is the matrix of bias learnability;

[0031] Enhancement module for With the initial entity Connect them in series to enhance the representation and get the final entity representation H e , whose expression is Among them, W′ is a learnable parameter of weight, and b′ is a learnable parameter of bias;

[0032] Multi-layer perception module, used to transform the knowledge Figure 3 The relationship in the tuple is input into the multi-layer perception network to obtain a relationship type graph, which is expressed as in, is the relationship feature after i iterations, is the relationship feature after j iterations, a i is a positive weight vector;

[0033] Aggregation module, used to convert a i and Input to the attention layer to aggregate and obtain the vector H of aggregation type information s , whose expression is

[0034] Projection module, used to e , H s and the initial relationship feature H r Projected into a unified dimensional space, the entities, types, and initial relations are embedded after nonlinear transformation. and Its expression is Among them, f1 represents the nonlinear activation function used to enhance the nonlinear representation ability of the model, W e 0 , W s 0 and W r 0 Trainable parameter matrices representing entities, types, and initial relations respectively;

[0035] XOR module, used to embed the initial entity of the i-th entity Entity representation after k-1 iterations The initial relation embedding with the i-th relation Relation representation after k-1 iterations Add and subtract them respectively, perform XOR operation on the two results, and get the scalar a of the weight of the i-th relationship after k-1 iterations. i k-1 , whose expression is

[0036] Operation module, used to convert a i k-1 Transformed by f1 and a learnable parameter matrix After multiplication, it is combined with another learnable parameter matrix Multiply them together, and finally process them with σ to get the attention weight α of the i-th node in the k-1 layer i k-1 , whose expression is in, For the k-1th iteration To transform, For the k-1th iteration Make a transformation;

[0037] The attention embedding acquisition module is used to and the embedding representation obtained by type i after k-1 iterations Input the attention layer to get the attention embedding of edge i after k-1 iterations Its expression is

[0038] Type information aggregation module, used to embed the attention of the edge after k-1 iterations The adjacency matrix A connecting entity edges and relationship edges se Perform dot multiplication to obtain the type information aggregation of the entity after k iterations Its expression is

[0039] Type embedding module, used to The embedding representation after k-1 iterations of type embedding The result is the node embedding parameter matrix W after k iterations. k Multiply them, and then transform them through f1 to get the embedding representation of the type embedding after k iterations. Its expression is

[0040] The final entity acquisition module is used to aggregate the type information of the entity after l iterations Entity representation after l-1 iterations and Perform XOR operation, and the result is processed by MLP. The result is then processed by GRU mechanism to obtain the final entity representation after l iterations. Its expression is Where l represents the total number of iterations of embedding update, and k is the index of each specific iteration within the total number of iterations l.

[0041] Specifically, the entity feature acquisition module includes:

[0042] The query structure acquisition unit is used to convert knowledge Figure 3 The entities and relations in the tuple are mapped to the query structure according to the QCP to obtain the specific query structure corresponding to the query q; each node in the specific query structure represents the knowledge Figure 3 An entity in a tuple, each edge in the specific query structure represents the knowledge Figure 3 A relation in a tuple;

[0043] A traversal unit, configured to start from the anchor node in the specific query structure and traverse to the intermediate nodes, and all retrieved entities are stored in the cache set; start from the target node in the specific query structure and traverse to the intermediate nodes, and all retrieved entities are stored in the traversal set;

[0044] A sample obtaining unit is used to take the entities common to the cache set and the traversal set as positive entities to obtain positive samples Among them, V q are all entities retrieved during the traversal, is a set of positive entities; entities that are not common to the cache set and the traversal set are taken as negative entities to obtain negative samples in, is the set of negative entities;

[0045] An entity feature obtaining unit is used to input the entities in the positive sample and the negative sample into a hidden layer to obtain entity features H after i+1 iterations. s i+1 , whose expression is H s i+1 =g*(W i ′H s i +b i ′)+(1-g)*H s i .

[0046] One or more technical solutions provided in the present invention have at least the following technical effects or advantages:

[0047] 1. By building a type-aware aggregation mechanism to realize semantic information, improve the representation extraction of entity and relationship types, and enrich the semantic content of the original knowledge graph. A novel fusion mechanism is adopted to more effectively fuse the representation of entity and relationship types, further improving the effectiveness of feature learning. In order to emphasize the relationship representation that is highly relevant to the process, an enhanced relationship attention mechanism is introduced to utilize and Jointly amplifying relational representations can aggregate relational information during node interactions, so that the updated node embeddings are rich in information, avoiding the loss of semantic information during the reasoning process and ensuring the reliability of the reasoning results.

[0048] 2. Based on query embedding and dual sampling strategy, it combines the aggregation of multi-relation type entities and relations. Among them, the query embedding method avoids the need for explicit traversal of the knowledge graph. Instead, it uses entity embedding and logical operators to more effectively manage complex knowledge graphs, thereby significantly reducing the complexity of calculations and helping to reduce computational costs. The dual sampling strategy, combined with forward traversal and backward validation, effectively alleviates the sparsity of training samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 A flowchart of a multi-hop reasoning method based on type-aware aggregation provided by an embodiment of the present invention;

[0050] Figure 2 is a schematic diagram of a double sampling process in an embodiment of the present invention;

[0051] Figure 3 A flowchart for the case study example;

[0052] Figure 4 It is the deductive reasoning result of HINT@3 on FB15k in the embodiment of the present invention;

[0053] Figure 5 It is the deductive reasoning result of HINT@3 on FB15k-237 in the embodiment of the present invention;

[0054] Figure 6 It is the deductive reasoning result of HINT@3 on NELL-995 in the embodiment of the present invention;

[0055] Figure 7 It is the inductive reasoning result of HINT@10 on FB15k-237-V2 in the embodiment of the present invention;

[0056] Figure 8 It is the inductive reasoning result of HINT@10 on NELL-V3 in the embodiment of the present invention;

[0057] Fig. 9 A module diagram of a multi-hop reasoning system based on type-aware aggregation provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0058] The embodiments of the present invention solve the technical problem of loss of semantic information in the reasoning process in the prior art by providing a multi-hop reasoning method and system based on type-aware aggregation, and achieve the technical effect of ensuring the reliability of the reasoning results.

[0059] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0060] like Figure 1As shown, the multi-hop reasoning method based on type-aware aggregation provided by an embodiment of the present invention includes:

[0061] Step S100: knowledge Figure 3 The entity in the tuple is input into the hidden layer to obtain the entity feature H after i+1 iterations. s i+1 , whose expression is H s i+1 =g*(W i ′H s i +b i ′)+(1-g)*H s i ;in, is the entity feature after i iterations, σ is the sigmoid function, W i is the learnable matrix of weights after the i-th iteration in the hidden layer, W i ′ is the learnable matrix of weights after the i-th iteration in g, b i is the learnable bias matrix after the i-th iteration in the hidden layer, b i ′ is the bias learnable matrix after the i-th iteration in g;

[0062] This step is explained in detail. Figure 3 The entity in the tuple is input into the hidden layer to obtain the entity feature H after i+1 iterations. s i+1 ,include:

[0063] like Figure 2 As shown, knowledge Figure 3 The entities and relations in the tuple are mapped to the query structure according to the QCP, and the specific query structure corresponding to the query q is obtained; each node in the specific query structure represents knowledge Figure 3 An entity in a tuple, each edge in the specific query structure represents knowledge Figure 3 A relation in a tuple;

[0064] Starting from the anchor node in the specific query structure and traversing to the intermediate nodes, all retrieved entities are stored in the cache set; starting from the target node in the specific query structure and traversing to the intermediate nodes, all retrieved entities are stored in the traversal set;

[0065] Take the entities shared by the cache set and the traversal set as positive entities and get positive samples Among them, V q are all entities retrieved during the traversal, is a set of positive entities; entities that are not common to the cache set and the traversal set are taken as negative entities to obtain negative samples in, is the set of negative entities;

[0066] Input the entities in the positive and negative samples into the hidden layer to obtain the entity features H after i+1 iterations s i+1 .

[0067] Step S110: H s i+1 After K iterations, we get the entity features after K iterations.

[0068] Step S120: Input the linear layer to get the entity type representation after linear transformation Its expression is Among them, W is the matrix of weight learnability, and b is the matrix of bias learnability;

[0069] Step S130: With the initial entity Connect them in series to enhance the representation and get the final entity representation H e , whose expression is Among them, W′ is a learnable parameter of weight, and b′ is a learnable parameter of bias;

[0070] Step S140: knowledge Figure 3 The relationship in the tuple is input into the multi-layer perception network to obtain a relationship type graph, which is expressed as in, is the relationship feature after i iterations, is the relationship feature after j iterations, a i is a positive weight vector, satisfying that for any 1≤j≤d, d is the size of the entity vector,

[0071] Step S150: i and Input to the attention layer to aggregate and obtain the vector H of the aggregated type information s , whose expression is

[0072] Step S160: H e , H s and the initial relationship feature H r Projected into a unified dimensional space, the entities, types, and initial relations are embedded after nonlinear transformation. and Its expression is Among them, f1 represents the nonlinear activation function used to enhance the nonlinear representation ability of the model, W e0 , W s 0 and W r 0 Trainable parameter matrices representing entities, types, and initial relations respectively;

[0073] Step S170: In order to emphasize the relationship representation that is highly relevant to the process, the embodiment of the present invention introduces an enhanced relationship attention mechanism. This mechanism uses and Jointly amplify the relation representation. Specifically, the initial entity embedding of the i-th entity Entity representation after k-1 iterations The initial relation embedding with the i-th relation Relation representation after k-1 iterations Add and subtract them respectively, perform XOR operation on the two results, and get the scalar a of the weight of the i-th relationship after k-1 iterations. i k-1 , whose expression is

[0074] Step S180: i k-1 Transformed by f1 and a learnable parameter matrix After multiplication, it is combined with another learnable parameter matrix Multiply them together, and finally process them with σ to get the attention weight α of the i-th node in the k-1 layer i k-1 , whose expression is in, For the k-1th iteration To transform, For the k-1th iteration Make a transformation;

[0075] Step S190: and the embedding representation obtained by type i after k-1 iterations Input the attention layer to get the attention embedding of edge i after k-1 iterations Its expression is

[0076] Step S200: embed the attention of the edge after k-1 iterations The adjacency matrix A connecting entity edges and relationship edges se Perform dot multiplication to obtain the type information aggregation of the entity after k iterations Its expression is

[0077] Step S210: The embedding representation after k-1 iterations of type embedding The result is the node embedding parameter matrix W after k iterations. k Multiply them, and then transform them through f1 to get the embedding representation of the type embedding after k iterations. Its expression is

[0078] Step S220: Aggregate the type information of the entity after l iterations Entity representation after l-1 iterations and Perform XOR operation, and the result is processed by MLP. The result is then processed by GRU mechanism to obtain the final entity representation after l iterations. Its expression is Where l represents the total number of iterations of embedding update, and k is the index of each specific iteration within the total number of iterations l.

[0079] like Figure 3 As shown, the method provided by the embodiment of the present invention is explained from the FB15k data set.

[0080] Given a logical query "Who are the co-authors of the Nobel Prize winners?", the entire query is instantiated by executing the QCP (Query Computation Plan) query statement, and its results are input into Figure 3 The second stage of bidirectional sampling in . Initially, bidirectional sampling is performed to generate positive samples (Pos_ans) and negative samples (Neg_ans), which are sent to Figure 3 The third part is type aggregation.

[0081] Subsequently, the entity type aggregation strategy is adopted to obtain the type information embeddings of all entities such as "Nobel Prize", "Physicist", "Marie Curie", "Becquerel", etc. At the same time, the relationship type aggregation strategy is used to derive type information embeddings for all relations (such as "won", "is", "co-author", etc.).

[0082] Finally, a fusion mechanism is used to combine the type information of entities and relations into a unified embedding. Using these integrated embeddings, the prediction process is performed for logical queries, resulting in the final reasoning output, which includes entities such as "Marie Curie" and "Henri Becquerel".

[0083] This case study demonstrates the effectiveness of the method provided by the embodiment of the present invention in processing complex logical queries by combining and integrating type information through sampling, aggregation and fusion technology systems.

[0084] In order to evaluate the generalization and reasoning capabilities of the embodiments of the present invention, experiments were conducted on three benchmarks, and the statistical data are shown in Table 1.

[0085] FB15k: constructed by selecting a subset of entities from the Wikilinks database and Freebase.

[0086] FB15k-237: Derived from FB15k, but the reverse relations are removed to prevent direct inference, including 237 relations.

[0087] NELL (NELL-995): The 995th iteration of the NELL system.

[0088] Table 1 Data statistics of the data set

[0089] Dataset entity relation Number of training samples Number of validation samples Number of test samples FB15k 14951 2690 1368550 123097 131016 FB15k-237 14505 474 745445 60101 62812 NELL 63361 400 539910 48927 49034

[0090] This experiment compared the method (DSMRT) provided by the embodiment of the present invention with five classic models (Q2B, BETAE, GQE, LOGICE and ConE) and the SOTA model in terms of generalization, deductive and inductive reasoning capabilities.

[0091] In the test data set, the triples (e s ,r,target) into query (e s ,r,? ). The source entity e and query relation r are input into the DSMRT model to generate candidate predictions and their probabilities. After sorting in descending order, the following two metrics are used to evaluate their performance:

[0092] HINT@N: It aims to measure the proportion of correctly predicted answers among the top N predicted by the model. Higher values ​​indicate better performance.

[0093] MRR(Mean Reciprocal Rank): It is the average reciprocal rank of all true-tail entities.

[0094] The performance experiment results are shown in Table 2, which are generalized MRR results (%).

[0095] Table 2 Overall MRR results

[0096]

[0097]

[0098] The best result is highlighted in bold, and the second best result is underlined. In addition, the HINT@3 results (%) of deductive reasoning are as follows: Figure 4 , Figure 5 and Figure 6 Then, the HINT@10 results (%) of inductive reasoning are shown as Figure 7 and Figure 8 shown.

[0099] Furthermore, if Fig. 9 As shown, the embodiment of the present invention also provides a multi-hop reasoning system based on type-aware aggregation, including:

[0100] Entity feature acquisition module 100 is used to obtain knowledge Figure 3 The entity in the tuple is input into the hidden layer to obtain the entity feature H after i+1 iterations. s i+1 , whose expression is H s i+1 =g*(W i ′H s i +b i ′)+(1-g)*H s i ;in, is the entity feature after i iterations, σ is the sigmoid function, W i is the learnable matrix of weights after the i-th iteration in the hidden layer, W i ′ is the learnable matrix of weights after the i-th iteration in g, b i is the learnable bias matrix after the i-th iteration in the hidden layer, b i ′ is the bias learnable matrix after the i-th iteration in g;

[0101] Specifically, the entity feature acquisition module 100 includes:

[0102] The query structure acquisition unit is used to convert knowledge Figure 3 The entities and relations in the tuple are mapped to the query structure according to the QCP, and the specific query structure corresponding to the query q is obtained; each node in the specific query structure represents knowledge Figure 3 An entity in a tuple, each edge in the specific query structure represents knowledge Figure 3 A relation in a tuple;

[0103] The traversal unit is used to start from the anchor node in the specific query structure and traverse to the intermediate nodes, and all retrieved entities are stored in the cache set; start from the target node in the specific query structure and traverse to the intermediate nodes, and all retrieved entities are stored in the traversal set;

[0104] The sample acquisition unit is used to take the entities shared by the cache set and the traversal set as positive entities to obtain positive samples Among them, V q are all entities retrieved during the traversal, is a set of positive entities; entities that are not common to the cache set and the traversal set are taken as negative entities to obtain negative samples in, is the set of negative entities;

[0105] The entity feature acquisition unit is used to input the entities in the positive and negative samples into the hidden layer to obtain the entity features H after i+1 iterations. s i+1 , whose expression is H s i+1 =g*(W i ′H s i +b i ′)+(1-g)*H s i .

[0106] The entity feature iteration module 200 is used to transform H s i+1 After K iterations, we get the entity features after K iterations.

[0107] The linear transformation module 300 is used to transform Input the linear layer to get the entity type representation after linear transformation Its expression is Among them, W is the matrix of weight learnability, and b is the matrix of bias learnability;

[0108] Enhancement module 400, used to With the initial entity Connect them in series to enhance the representation and get the final entity representation H e , whose expression is Among them, W′ is a learnable parameter of weight, and b′ is a learnable parameter of bias;

[0109] The multi-layer perception module 500 is used to transform knowledge Figure 3 The relationship in the tuple is input into the multi-layer perception network to obtain a relationship type graph, which is expressed as in, is the relationship feature after i iterations, is the relationship feature after j iterations, a i is a positive weight vector, satisfying that for any 1≤j≤d, d is the size of the entity vector,

[0110] Aggregation module 600, used to aggregate a i and Input to the attention layer to aggregate and obtain the vector H of aggregation type information s , whose expression is

[0111] The projection module 700 is used to project H e , H s and the initial relationship feature H r Projected into a unified dimensional space, the entities, types, and initial relations are embedded after nonlinear transformation. and Its expression is Among them, f1 represents the nonlinear activation function used to enhance the nonlinear representation ability of the model, W e 0 , W s 0 and W r 0 Trainable parameter matrices representing entities, types, and initial relations respectively;

[0112] XOR module 800, used to embed the initial entity of the i-th entity Entity representation after k-1 iterations The initial relation embedding with the i-th relation Relation representation after k-1 iterations Add and subtract them respectively, perform XOR operation on the two results, and get the scalar a of the weight of the i-th relationship after k-1 iterations. i k-1 , whose expression is

[0113] The operation module 900 is used to convert a i k-1 After f1 transformation and a learnable parameter matrix After multiplication, it is combined with another learnable parameter matrix Multiply them together, and finally process them with σ to get the attention weight α of the i-th node in the k-1 layer i k-1 , whose expression is in, For the k-1th iteration To transform, For the k-1th iteration Make a transformation;

[0114] The attention embedding acquisition module 1000 is used to and the embedding representation obtained by type i after k-1 iterations Input the attention layer to get the attention embedding of edge i after k-1 iterations Its expression is

[0115] Type information aggregation module 1100, used to embed the attention of the edge after k-1 iterations The adjacency matrix A connecting entity edges and relationship edges se Perform dot multiplication to obtain the type information aggregation of the entity after k iterations Its expression is

[0116] Type embedding acquisition module 1200, used to The embedding representation after k-1 iterations of type embedding The result is the node embedding parameter matrix W after k iterations. k Multiply them, and then transform them through f1 to get the embedding representation of the type embedding after k iterations. Its expression is

[0117] The final entity acquisition module 1300 is used to aggregate the type information of the entity after l iterations. Entity representation after l-1 iterations and Perform XOR operation, and the result is processed by MLP. The result is then processed by GRU mechanism to obtain the final entity representation after l iterations. Its expression is Where l represents the total number of iterations of embedding update, and k is the index of each specific iteration within the total number of iterations l.

[0118] In summary, in order to solve the three major problems of high computational cost, sparse training samples, and missing information in the reasoning process, an embodiment of the present invention proposes a new multi-hop knowledge graph reasoning model called DSMRT, which is based on query embedding (QE) and a dual sampling strategy, and combines the aggregation of multi-relationship type entities and relationships. Among them, the QE method helps to reduce the computational cost, while the dual sampling strategy, combined with forward traversal and backward verification, effectively alleviates the sparsity of training samples. In addition, by using type-aware representation, DSMRT solves the problem of information loss. Experiments have shown that DSMRT successfully balances and represents data by strategically using type information, while solving information gaps.

[0119] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0120] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0121] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0122] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0123] The parts not described in detail in the embodiments of the present invention are all known technologies to those skilled in the art. Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention is described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solutions of the present invention, which should be included in the scope of the claims of the present invention.

Claims

1. A multi-hop reasoning method based on type-aware aggregation, characterized in that: include: Input the entity in the knowledge graph triple into the hidden layer to obtain the entity feature H after i+1 iterations s i+1 , whose expression is H s i+1 =g*(W i ′H s i +b i ′)+(1-g)*H s i ;in, is the entity feature after i iterations, σ is the sigmoid function, W i is the learnable matrix of weights after the i-th iteration in the hidden layer, W i ′ is the learnable matrix of weights after the i-th iteration in g, b i is the learnable bias matrix after the i-th iteration in the hidden layer, b i ′ is the bias learnable matrix after the i-th iteration in g; H s i+1 After K iterations, we get the entity features after K iterations. Will Input the linear layer to get the entity type representation after linear transformation Its expression is Among them, W is the matrix of weight learnability, and b is the matrix of bias learnability; Will With the initial entity Connect them in series to enhance the representation and get the final entity representation H e , whose expression is Among them, W′ is a learnable parameter of weight, and b′ is a learnable parameter of bias; The relationship in the knowledge graph triple is input into the multi-layer perception network to obtain a relationship type graph, which is expressed as in, is the relationship feature after i iterations, is the relationship feature after j iterations, a i is a positive weight vector; A i and Input to the attention layer to aggregate and obtain the vector H of aggregation type information s , whose expression is H e , H s and the initial relationship feature H r Projected into a unified dimensional space, the entities, types, and initial relations are embedded after nonlinear transformation. and Its expression is Among them, f1 represents the nonlinear activation function used to enhance the nonlinear representation ability of the model, W e 0 , W s 0 and W r 0 Trainable parameter matrices representing entities, types, and initial relations respectively; Embed the initial entity of the i-th entity Entity representation after k-1 iterations The initial relation embedding with the i-th relation Relation representation after k-1 iterations Add and subtract them respectively, perform XOR operation on the two results, and get the scalar a of the weight of the i-th relationship after k-1 iterations. i k-1 , whose expression is A i k-1 Transformed by f1 and a learnable parameter matrix After multiplication, it is combined with another learnable parameter matrix Multiply them together, and finally process them with σ to get the attention weight α of the i-th node in the k-1 layer i k-1 , whose expression is in, For the k-1th iteration To transform, For the k-1th iteration Make a transformation; Will and the embedding representation obtained by type i after k-1 iterations Input the attention layer to get the attention embedding of edge i after k-1 iterations Its expression is The attention embedding after k-1 iterations of the edge The adjacency matrix A connecting entity edges and relationship edges se Perform dot multiplication to obtain the type information aggregation of the entity after k iterations Its expression is Will The embedding representation after k-1 iterations of type embedding The result is the node embedding parameter matrix W after k iterations. k Multiply them, and then transform them through f1 to get the embedding representation of the type embedding after k iterations. Its expression is Aggregate the type information of the entity after l iterations Entity representation after l-1 iterations and Perform XOR operation, and the result is processed by MLP. The result is then processed by GRU mechanism to obtain the final entity representation after l iterations. Its expression is Where l represents the total number of iterations of embedding update, and k is the index of each specific iteration within the total number of iterations l.

2. The multi-hop reasoning method based on type-aware aggregation as claimed in claim 1, characterized in that: The entity features H after i+1 iterations are obtained by inputting the entities in the knowledge graph triples into the hidden layer. s i+1 ,include: The entities and relations in the knowledge graph triples are mapped to the query structure according to the QCP to obtain a specific query structure corresponding to the query q; each node in the specific query structure represents an entity in the knowledge graph triple, and each edge in the specific query structure represents a relationship in the knowledge graph triple; Starting from the anchor node in the specific query structure, traversing to the intermediate nodes, all retrieved entities are stored in the cache set; starting from the target node in the specific query structure, traversing to the intermediate nodes, all retrieved entities are stored in the traversal set; The entities common to the cache set and the traversal set are taken as positive entities to obtain positive samples. Among them, V q are all entities retrieved during the traversal, is a set of positive entities; entities that are not common to the cache set and the traversal set are taken as negative entities to obtain negative samples in, is the set of negative entities; The entities in the positive sample and the negative sample are input into the hidden layer to obtain the entity features H after i+1 iterations s i+1 .

3. A multi-hop reasoning system based on type-aware aggregation, characterized in that: include: The entity feature acquisition module is used to input the entity in the knowledge graph triple into the hidden layer to obtain the entity feature H after i+1 iterations. s i+1 , whose expression is H s i+1 =g*(W i ′H s i +b i ′)+(1-g)*H s i ;in, is the entity feature after i iterations, σ is the sigmoid function, W i is the learnable matrix of weights after the i-th iteration in the hidden layer, W i ′ is the learnable matrix of weights after the i-th iteration in g, b i is the learnable bias matrix after the i-th iteration in the hidden layer, b i ′ is the bias learnable matrix after the i-th iteration in g; Entity feature iteration module, used to transform H s i+1 After K iterations, we get the entity features after K iterations. Linear transformation module, used to transform Input the linear layer to get the entity type representation after linear transformation Its expression is Among them, W is the matrix of weight learnability, and b is the matrix of bias learnability; Enhancement module for With the initial entity Connect them in series to enhance the representation and get the final entity representation H e , whose expression is Among them, W′ is a learnable parameter of weight, and b′ is a learnable parameter of bias; The multi-layer perception module is used to input the relationship in the knowledge graph triple into the multi-layer perception network to obtain a relationship type graph, which is expressed as in, is the relationship feature after i iterations, is the relationship feature after j iterations, a i is a positive weight vector; Aggregation module, used to convert a i and Input to the attention layer to aggregate and obtain the vector H of aggregation type information s , whose expression is Projection module, used to e , H s and the initial relationship feature H r Projected into a unified dimensional space, the entities, types, and initial relations are embedded after nonlinear transformation. and Its expression is Among them, f1 represents the nonlinear activation function used to enhance the nonlinear representation ability of the model, W e 0 , W s 0 and W r 0 Trainable parameter matrices representing entities, types, and initial relations respectively; XOR module, used to embed the initial entity of the i-th entity Entity representation after k-1 iterations The initial relation embedding with the i-th relation Relation representation after k-1 iterations Add and subtract them respectively, perform XOR operation on the two results, and get the scalar a of the weight of the i-th relationship after k-1 iterations. i k-1 , whose expression is Operation module, used to convert a i k-1 Transformed by f1 and a learnable parameter matrix After multiplication, it is combined with another learnable parameter matrix Multiply them together, and finally process them with σ to get the attention weight α of the i-th node in the k-1 layer i k-1 , whose expression is in, For the k-1th iteration To transform, For the k-1th iteration Make a transformation; The attention embedding acquisition module is used to and the embedding representation obtained by type i after k-1 iterations Input the attention layer to get the attention embedding of edge i after k-1 iterations Its expression is Type information aggregation module, used to embed the attention of the edge after k-1 iterations The adjacency matrix A connecting entity edges and relationship edges se Perform dot multiplication to obtain the type information aggregation of the entity after k iterations Its expression is Type embedding module, used to The embedding representation after k-1 iterations of type embedding The result is the node embedding parameter matrix W after k iterations. k Multiply them, and then transform them through f1 to get the embedding representation of the type embedding after k iterations. Its expression is The final entity acquisition module is used to aggregate the type information of the entity after l iterations Entity representation after l-1 iterations and Perform XOR operation, and the result is processed by MLP. The result is then processed by GRU mechanism to obtain the final entity representation after l iterations. Its expression is Where l represents the total number of iterations of embedding update, and k is the index of each specific iteration within the total number of iterations l.

4. The multi-hop reasoning system based on type-aware aggregation as claimed in claim 3, characterized in that: The entity feature acquisition module includes: A query structure obtaining unit, used for mapping entities and relations in the knowledge graph triple to the query structure according to the QCP, to obtain a specific query structure corresponding to the query q; each node in the specific query structure represents an entity in the knowledge graph triple, and each edge in the specific query structure represents a relationship in the knowledge graph triple; A traversal unit, configured to start from the anchor node in the specific query structure and traverse to the intermediate nodes, and all retrieved entities are stored in the cache set; start from the target node in the specific query structure and traverse to the intermediate nodes, and all retrieved entities are stored in the traversal set; A sample obtaining unit is used to take the entities common to the cache set and the traversal set as positive entities to obtain positive samples Among them, V q are all entities retrieved during the traversal, is a set of positive entities; entities that are not common to the cache set and the traversal set are taken as negative entities to obtain negative samples in, is the set of negative entities; An entity feature obtaining unit is used to input the entities in the positive sample and the negative sample into a hidden layer to obtain entity features H after i+1 iterations. s i+1 , whose expression is H s i+1 =g*(W i ′H s i +b i ′)+(1-g)*H s i .