Multi-hop retrieval method and system based on knowledge graph embedding and path information
By introducing path information and relation memory networks into the knowledge graph, the potential dependency problem between entities and relations in the knowledge graph multi-hop question answering system is solved, thereby improving the accuracy and robustness of multi-hop question answering.
Patent Information
- Application Number
- CN202310371221.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-10
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-04-10
AI Technical Summary
Existing knowledge graph multi-hop question answering systems struggle to effectively utilize the potential dependencies between entities and relationships when faced with incompleteness and sparsity, leading to answer omissions and insufficient model robustness.
We adopt a multi-hop retrieval method based on knowledge graph embedding and path information. By constructing dataset, entity and relation embedding, path query, path embedding and relation memory network, we analyze the potential dependencies between questions and entity embeddings and introduce multi-path scoring to enhance the accuracy and robustness of the retrieval system.
It improves the accuracy and robustness of the knowledge graph multi-hop question answering system, enabling it to better handle multi-hop relational reasoning and answer retrieval.
Smart Images

Figure CN116662478B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of knowledge graph-based question answering retrieval technology, specifically involving a multi-hop retrieval method and system based on knowledge graph embedding and path information. Background Technology
[0002] With the rapid development of the internet, humanity has entered the information age. However, in daily life and at work, people are often overwhelmed by the explosive growth of information online. Furthermore, internet information is often diverse, fragmented, and loosely structured, making the storage and utilization of this information a major challenge for the development of the Internet of Things (IoT). Traditional search engines often provide users not with precise and concise answers, but rather with a list of online resources. Therefore, people increasingly prefer question-answering systems that align with human language habits. These systems understand user input in natural language, process it, retrieve information, and perform other operations to return accurate answers. Thus, question-answering systems represent a significant research direction in the field of artificial intelligence.
[0003] The development of knowledge graphs (KB) has provided a new research area for question answering systems. A knowledge graph is a knowledge base with structured information, which can be viewed as a directed graph with a network structure. The basic element of a knowledge graph is generally a triple, where each triple consists of an entity and a relation to record a piece of knowledge. Entities are generally concrete nouns and things in life or abstract concepts, while relations generally refer to the attribute descriptions of the association between two entities. The triple is generally represented as (h, r, t), where h is the head entity, r is the relation, and t is the tail entity. Knowledge graph question answering (KBQA) utilizes the advantages of strong structure and good correlation of knowledge graphs to better query and reason about user questions using keywords, resulting in more accurate answers.
[0004] However, early single-hop retrieval methods can no longer meet people's daily needs, and multi-hop question answering is preferred. Its task is to perform multi-step reasoning on the knowledge graph and then infer the answer to the question that contains multi-hop relationships.
[0005] However, when performing multi-hop retrieval on knowledge graphs, the knowledge graphs are often incomplete and sparsity-prone. This means that the correct answer may not be obtained due to the lack of a link between two entities. To address the incompleteness of knowledge graphs, extensive research has been conducted in the field of link prediction. Among these, knowledge graph embedding works utilize mapping methods to represent entities and relations as high-dimensional dense vectors to solve the aforementioned sparsity and incompleteness problems of knowledge graphs. The earliest distance-based embedding model was the TransE model, whose basic idea is to use the potential latent relationship h+r≈t between head entities, tail entities, and relations to calculate the distance between entities. Subsequent distance-based embedding models include TransR, TransD, RotatE, etc. In recent years, with the development of deep learning, research has also been conducted on deep learning-based knowledge graph embedding models, such as ConvE and ConvKB models based on CNN networks, and R-GCN and SACN models based on graph networks.
[0006] The initial design purpose of knowledge graph embedding models was for link prediction tasks. The vectors they generate often implicitly contain the relationships between entities, which can better assist in multi-hop knowledge retrieval from knowledge graphs. The earliest work to apply knowledge graph embedding models to multi-hop question answering was the EmbedKGQA model proposed by Saxena et al. at the 2020 ACL conference. It first maps the question to a vector space using a pre-trained language model, Roberta, and then uses a scoring function to obtain the answer entity by combining the embedding vectors of the subject entity and the answer entity generated by the ComplEx embedding model. However, the EmbedKGQA model has some problems: First, the vectors generated by question embedding and the vectors generated by knowledge graph embedding are obtained through two different networks, meaning that the two types of vectors are not mapped in the same space, and the potential dependencies between them are not analyzed; second, the scoring function used in the EmbedKGQA model is the ComplEx scoring function, a relatively simple scoring method that may miss answers when faced with multiple questions, reducing the model's robustness. Summary of the Invention
[0007] In view of this, the purpose of the present invention is to provide a multi-hop retrieval method and system based on knowledge graph embedding and path information, which is used to enhance the detection of potential dependencies between question embedding and entity embedding in knowledge graph multi-hop question answering retrieval and to introduce multi-path scoring to increase the robustness of the retrieval system.
[0008] To achieve the above objectives, the present invention provides the following technical solution: a multi-hop retrieval method based on knowledge graph embedding and path information, comprising the following steps:
[0009] S1: Construct a knowledge graph G in the dataset and process the question-and-answer retrieval data in the dataset; define the triple K in the knowledge graph G as (h,r,t), where h,t∈E represent the subject entity and the object entity respectively, and the relationship between them is r∈R; process the question-and-answer retrieval data in the dataset to obtain the natural language question q, the subject entity h, and the question answer a;
[0010] S2: Embed the existing knowledge graph from S1 into a knowledge graph; use an embedding model to perform embedding mapping for each entity e∈E and relation r∈R, generating a fixed-dimensional entity embedding vector e. e ∈R d and relation embedding vector e r ∈R d ;
[0011] S3: Using the knowledge graph embedding vector generated in S2, obtain the vector embedding representation e of the subject entity h and the question answer a in S1 through a query. h With e a ;
[0012] S4: Embed the natural language questions mentioned in S1 into question embeddings, and use a pre-trained natural language model to map and embed the natural language questions q to obtain a fixed-dimensional vector e. q ∈C d ;
[0013] S5: Perform a link query on the knowledge graph G to find the link connection between the main entity h in the natural language question in S1 and the question answer a.
[0014] S6: Embed the paths obtained in S5 into P = p1, p2, ..., p i Each path p = (r1, r2, ..., r) l ) Perform path embedding to obtain the relation path embedding vector e p ;
[0015] S7: Embed the main entity from S3 into vector e h Question-answer embedding vector e a The representation of the relational path embedding vector e in S6 p By concatenating the vectors, we obtain an embedding vector e containing the answer path information. x ;
[0016] S8: Embed the natural language question from S4 into vector e q With the embedding vector e containing answer path information in S7 xThe data is fed into the relational memory embedding module to analyze the potential dependencies between question embeddings and entity embeddings, and to obtain the remapped question embedding vector.
[0017] S9: Will e h and e a The data is sent to the scoring module for scoring calculation, and path scoring is incorporated. The final answer 'a' is obtained through selection and calculation. ans .
[0018] Furthermore, in S2, the ComplEx model is used to embed the knowledge graph.
[0019] Furthermore, in S4, the natural language question q is input into the pre-trained natural language model RoBERTa for training and fine-tuning to obtain an initial embedding vector of the question. Then, through a fully connected network layer, the embedding vector e of question q is generated. q ∈C d .
[0020] Furthermore, in S5, the link connection refers to the connection between entities in a triplet through a relation. In the question-answering retrieval task, if the main entity and the question answer have a relation connection on the knowledge graph, then the path of the current relation is recorded as a path p = (r1, r2, ..., r...). l Record all paths between the main entity h and the answer a as P = p1, p2, ..., p i By utilizing deep learning principles, the following three scoring mechanisms are implemented during path sampling: A positive score is awarded when the subject entity can reach the answer entity.
[0021]
[0022] Shorter path lengths allow for more efficient processing and positive scoring.
[0023]
[0024] To find diverse paths, a diverse scoring mechanism is defined using the cosine similarity between the current path and existing paths:
[0025]
[0026] Furthermore, in S6, when performing operations on paths P = p1, p2, ..., p i When performing path embedding, in the knowledge graph embedding model based on tensor decomposition, the value of each triple can be obtained by the subject entity embedding vector h, the object entity embedding vector t, and the relation matrix M. rThe product of h and M is used to calculate the expected expression: h·M r t = 1. Therefore, the relational path embedding vector e p In the formula based on tensor decomposition, for each path p = (r1, r2, ..., r... l Satisfy constraints:
[0027]
[0028] Where P represents the set of all relations that contain the path sequence from the main entity h to the question answer a or the candidate entity h. Represents the i-th relation r i Embedding in set P.
[0029] Furthermore, in S8, the relational memory embedding module uses a relational memory-based embedding network to embed the natural language question vector e. q Processing is performed. The memory M of the relational memory embedding module network consists of N rows, each row being a memory slot. The relational memory embedding module uses M... (t) The steps to represent memory, and This represents the i-th memory slot in time step t. Following x... t renew Use multi-head self-attention mechanism:
[0030]
[0031] In the formula, H represents the number of attention heads. This is a vector concatenation operation. For the h-th head, W... h,V ∈R n×k It is a value projection matrix, where n is the size of the head and k = nH. and α i,N+1,h Attention weights are calculated using the softmax function on the scale dot product, as shown below:
[0032]
[0033]
[0034] Among them W h,Q ∈R n×k W h,K ∈R n×k These are the query projection matrix and the key projection matrix, respectively. t and The residual connections between them are provided to the multilayer perceptron, and then the encoded vector y is generated through memory gating. t ∈R k Let t represent the time step and the next memory slot. Let t+1 be used to represent the time step.
[0035] Furthermore, in S9, the remapping problem is embedded in the vector. and the main entity embedding vector e h Candidate question answer embedding vector e a The data is fed into the scoring module for score calculation. The relational path embedding vector e is also introduced. p Set up a scoring function to score the path. The final scoring function is:
[0036]
[0037] Multi-hop retrieval system based on knowledge graph embedding and path information
[0038] Compared with the prior art, the present invention has the following beneficial effects:
[0039] The beneficial effects of this invention are as follows: This invention adopts a multi-hop retrieval method and system based on knowledge graph embedding and path information. On the one hand, it introduces an embedding network based on relational memory, which solves the problem of different mapping spaces caused by using different networks for natural language question embedding and knowledge graph embedding, and considers the potential dependency relationship between the two. On the other hand, it introduces path information from the knowledge graph to enrich the scoring function, thereby improving the accuracy and robustness of the intelligent question answering retrieval system. Attached Figure Description
[0040] Figure 1 A schematic diagram of the system architecture of this invention.
[0041] Figure 2 The system flowchart of this invention.
[0042] Figure 3 A schematic diagram of the relational memory embedding module of this invention. Detailed Implementation
[0043] It should be noted that in the description of this invention, the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", "clockwise", "counterclockwise", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation.
[0044] In this invention, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link," etc., should be interpreted broadly. For example, "fixed" can mean a fixed connection, a detachable connection, or an integral part; a connection can be a mechanical connection or an electrical connection; a link can be a direct connection or an indirect connection through an intermediate medium, and can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0045] The system consists of the following modules: knowledge graph embedding module, question embedding module, path acquisition module, path embedding module, relation memory embedding module, answer scoring module, and answer selection module.
[0046] The knowledge graph embedding module transforms entities and relationships in the knowledge graph into numerical vectors, enabling these vectors to represent the structural and semantic information in the knowledge graph.
[0047] The question embedding module uses a pre-trained language model to represent natural language questions as vectors; it then matches the questions with information in the knowledge graph to achieve more efficient information retrieval and question answering.
[0048] The path acquisition module extracts the relationship paths between main entities and answers from the knowledge graph. These paths can be used to represent the relationships between entities and to solve knowledge graph reasoning problems.
[0049] The path embedding module establishes a vector space by selecting the corresponding path embedding method for different types of knowledge graph embedding methods, thereby obtaining path embedding vectors to represent the relationships between entities.
[0050] The relational memory embedding module stores the embedding vector information of the input in memory, allowing the model to remember previously learned relations when processing new inputs, thus better analyzing potential dependencies.
[0051] A multi-hop retrieval method based on knowledge graph embedding and path information includes the following steps:
[0052] Step 1: Preprocessing of the knowledge graph question-answering retrieval dataset. First, the knowledge graph in the dataset is constructed. The triple K in the knowledge graph G is defined as (h,r,t), where h,t∈E represent the head entity and the tail entity, respectively, and the relationship between them is r∈R. Second, the question-answering retrieval data in the dataset is processed to obtain the natural language question q, the main entity h, and the question answer a.
[0053] Step 2: Embed the existing knowledge graph from Step 1. Use an embedding model to perform embedding mapping for each entity e∈E and relation r∈R, generating a fixed-dimensional entity embedding vector e. e ∈R d and relation embedding vector e r ∈R d .
[0054] Specifically, the ComplEx model is used for knowledge graph embedding. The ComplEx model is a tensor decomposition-based embedding network model that maps relation and entity embeddings to a complex space. For h,t∈E and r∈R mentioned in step one, the corresponding embedding e is generated. h ,e r ,e t ∈C d During training, a scoring function is used:
[0055] This is such that for all proper triples φ(h,r,t)>0, and for false triples φ(h′,r′,t′)<0. Re denotes the real part of the complex number.
[0056] Step 3: Using the knowledge graph embedding vector generated in Step 2, obtain the vector embedding representation e of the subject entity h and the question answer a from Step 1 through a query. h With e a .
[0057] Step 4: Embed the natural language questions mentioned in Step 1. Use a pre-trained natural language model to map and embed the natural language questions q to obtain a fixed-dimensional vector e. q ∈C d .
[0058] Specifically, the natural language question q is input into the pre-trained natural language model RoBERTa for training and fine-tuning to obtain an initial embedding vector of the question. Then, through a fully connected network layer, the embedding vector e of question q is generated. q ∈C d .
[0059] Step 5: Query and obtain the link between the main entity h in the natural language question and the question answer a in the knowledge graph G. Entities in triples are connected through relations. In the question-answering retrieval task, if a main entity and the question answer have a relational connection in the knowledge graph, the path of the current relation is recorded as a path p = (r1, r2, ..., r...). l Record all paths between the main entity h and the answer a as P = p1, p2, ..., p i .
[0060] Specifically, by utilizing deep learning principles, the following three scoring mechanisms are implemented during path sampling: A positive score is awarded when the subject entity can reach the answer entity.
[0061]
[0062] Shorter path lengths allow for more efficient processing and positive scoring.
[0063]
[0064] To find diverse paths, a diverse scoring mechanism is defined using the cosine similarity between the current path and existing paths:
[0065]
[0066] Step Six: Embed the paths obtained in Step Five into P = p1, p2, ..., p i Each path p = (r1, r2, ..., r) l ) Perform path embedding to obtain the relation path embedding vector e p .
[0067] Specifically, in a knowledge graph embedding model based on tensor decomposition, the value of each triple can be obtained by the head entity embedding vector h, the tail entity embedding vector t, and the relation matrix M. r The product of h and M is used to calculate the expected expression: h·M r t = 1. Therefore, in the tensor decomposition-based formula, the path satisfies the following constraint:
[0068]
[0069] Where P represents the set of all relations that contain the path sequence from the subject entity h to the question answer a or the candidate entity h. Represents the i-th relation r i Embedding in set P.
[0070] Step 7: Embed the main entity from Step 3 into vector e h Question-answer embedding vector e a The representation of the path embedding vector e in step six p By concatenating the vectors, we obtain an embedding vector e containing the answer path information. x .
[0071] Step 8: Embed the natural language question from Step 4 into vector e q The embedding vector e containing the answer path information in step seven xThe data is fed into the relational memory embedding module to analyze the potential dependencies between question embeddings and entity embeddings, and to obtain the remapped question embedding vector. Specifically, an embedding network based on relational memory is used, assuming that memory M consists of N rows, where each row is a memory slot. Using M... (t) The steps to represent memory, and This represents the i-th memory slot in time step t. Following x... t renew Use multi-head self-attention mechanism:
[0072]
[0073] In the formula, H represents the number of attention heads. This is a vector concatenation operation. For the h-th head, W... h,V ∈R n×k It is a value projection matrix, where n is the size of the head and k = nH. and α i,N+1,h Attention weights are calculated using the softmax function on the scale dot product, as shown below:
[0074]
[0075]
[0076] Among them W h,Q ∈R n×k W h,K ∈R n×k These are the query projection matrix and the key projection matrix, respectively. t and The residual connections between them are provided to the multilayer perceptron, and then the encoded vector y is generated through memory gating. t ∈R k Let t represent the time step and the next memory slot. Let t+1 be used to represent the time step.
[0077] Step Nine: e h and e a The data is fed into the scoring module for score calculation, and a path score is introduced. Although the selection and calculation ultimately yield the final answer a. ans .
[0078] Specifically, the remapping problem in step eight is embedded into the vector. and the main entity embedding vector e h Candidate question answer embedding vector e a The data is then sent to the scoring module for scoring calculation. The relational path embedding vector e from step six is also introduced. pSet up a scoring function to score the path. The final scoring function is:
[0079]
[0080] The scoring function consists of two parts. The left half is the ComplEx scoring function, as detailed in step two.
[0081] The path scoring function for the right half is: where sim(e p ,e q The similarity between the question embedding vector and the path embedding vector is represented by α, which is calculated using the cosine distance function. α is a hyperparameter representing the weight of the trade-off between the ternary relation and the path-question relevance.
[0082] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A multi-hop retrieval method based on knowledge graph embedding and path information, characterized in that, Includes the following steps: S1: Construct a knowledge graph G in the dataset and process the question-and-answer retrieval data in the dataset; define the triple K in the knowledge graph G as (h,r,t), where h,t∈E represent the subject entity and the object entity respectively, and the relationship between them is r∈R; process the question-and-answer retrieval data in the dataset to obtain the natural language question q, the subject entity h, and the question answer a; S2: Embed the existing knowledge graph from S1 into a knowledge graph; use an embedding model to perform embedding mapping for each entity e∈E and relation r∈R, generating a fixed-dimensional entity embedding vector e. e ∈R d and relation embedding vector e r ∈R d ; S3: Using the knowledge graph embedding vector generated in S2, obtain the vector embedding representation e of the subject entity h and the question answer a in S1 through a query. h With e a ; S4: Embed the natural language questions mentioned in S1 into questions, and use a pre-trained natural language model to map and embed the natural language questions q to obtain a fixed-dimensional vector e. q ∈C d ; S5: Perform a link query on the knowledge graph G to find the link connection between the main entity h in the natural language question in S1 and the question answer a. The link connection is between entities in a triplet connected by a relation. In the question-answering retrieval task, if there is a relation connection between the main entity and the question answer on the knowledge graph, the path of the current relation is recorded as a path p=(r1,r2,…,r l Record all paths between the main entity h and the answer a as P = P1, P2, ..., P i By utilizing deep learning principles, the following three scoring mechanisms are implemented during path sampling: A positive score is awarded when the subject entity can reach the answer entity. Shorter path lengths allow for more efficient processing and positive scoring. To find diverse paths, a diverse scoring mechanism is defined using the cosine similarity between the current path and existing paths: ; S6: Embed the paths obtained in S5 into P=P1,P2,…,P i Each path p=(r1,r2,…,r) l ) Perform path embedding to obtain the relation path embedding vector e p ; S7: Embed the main entity from S3 into vector e h Question-answer embedding vector e a The representation of the relational path embedding vector e in S6 p By concatenating the vectors, we obtain an embedding vector e containing the answer path information. x ; S8: Embed the natural language question from S4 into vector e q With the embedding vector e containing answer path information in S7 x The data is fed into the relational memory embedding module to analyze the potential dependencies between question embeddings and entity embeddings, and to obtain the remapped question embedding vector. ; The relational memory embedding module uses a relational memory-based embedding network to embed the natural language question vector e. q The processing involves a relational memory embedding module network whose memory M consists of N rows, each row being a memory slot. The relational memory embedding module uses M... (t) The steps to represent memory, and This represents the i-th memory slot in time step t, following x t renew Use multi-head self-attention mechanism: In the formula, H represents the number of attention heads. This is a vector concatenation operation; for the h-th head, It is a value projection matrix, where n is the size of the head, and k = nH. and Attention weights are calculated using the softmax function on the scale dot product, as shown below: in , These are the query projection matrix and the key projection matrix, respectively, x t and The residual connections between them are provided to the multilayer perceptron, and then the encoded vector is generated through memory gating. Let t represent the time step and the next memory slot. To represent the time step (t+1); S9: Will e h and e a The data is sent to the scoring module for scoring calculation, and path scoring is incorporated. The final answer 'a' is obtained through selection and calculation. ans .
2. The multi-hop retrieval method based on knowledge graph embedding and path information as described in claim 1, characterized in that, In S2, the ComplEx model is used for knowledge graph embedding.
3. The multi-hop retrieval method based on knowledge graph embedding and path information as described in claim 1, characterized in that, In S4, the natural language question q is input into the pre-trained natural language model RoBERTa for training and fine-tuning to obtain an initial embedding vector of the question. Then, through a fully connected network layer, the embedding vector e of question q is generated. q ∈C d .
4. The multi-hop retrieval method based on knowledge graph embedding and path information as described in claim 1, characterized in that, In S6, when performing operations on paths P=P1,P2,…,P… i When performing path embedding, in the knowledge graph embedding model based on tensor decomposition, the value of each triple can be obtained by the subject entity embedding vector h, the object entity embedding vector t, and the relation matrix M. r The product of is used to calculate, and the expected result is that it satisfies the following expression: Therefore, the relational path embedding vector e p In the formula based on tensor decomposition, for each path p=(r1,r2,…,r…) l Satisfy constraints: Where P represents the set of all relations that contain the path sequence from the main entity h to the question answer a or the candidate entity h. Represents the i-th relation r i Embedding in set P.
5. The multi-hop retrieval method based on knowledge graph embedding and path information as described in claim 4, characterized in that, In S9, the remapping problem is embedded in the vector. and the main entity embedding vector e h Candidate question answer embedding vector e a The data is fed into the scoring module for scoring calculation, and the relational path embedding vector e is introduced. p Set up a scoring function to score the path; the final scoring function is: 。 6. A system for implementing the method as described in any one of claims 1-5, characterized in that, include: The module includes a knowledge graph embedding module, a question embedding module, a path acquisition module, a path embedding module, a relation memory embedding module, an answer scoring module, and an answer selection module. in The knowledge graph embedding module transforms entities and relationships in the knowledge graph into numerical vectors. The question embedding module uses a pre-trained language model to represent natural language questions as vectors; it matches questions with information in the knowledge graph to achieve more efficient information retrieval and question answering. The path acquisition module extracts the relationship paths between main entities and answers from the knowledge graph, which are used to represent the relationships between entities and to solve knowledge graph reasoning problems. The path embedding module selects the corresponding path embedding method to establish a vector space for different types of knowledge graph embedding methods, and obtains path embedding vectors to represent the relationships between entities. The relational memory embedding module stores the input embedding vector information in memory and analyzes dependencies.
Citation Information
Patent Citations
Complex question answering method and device based on knowledge graph and storage medium
CN113468311A
Knowledge graph completion method and system based on multi-scale dispersed dynamic routing
CN114741532A
