Knowledge graph multi-hop question answering method and system based on contrastive learning relation representation

By training a relation encoder through contrastive learning and negative sampling mechanisms, and combining it with a KG context processor and adaptive beam search, the problems of cascading error propagation and interpretability in multi-hop question answering of knowledge graphs are solved, achieving efficient and accurate multi-hop reasoning.

CN115757737BActive Publication Date: 2026-01-02FUDAN UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211482851.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-24
Publication Date
2026-01-02
Estimated Expiration
2042-11-24

AI Technical Summary

Technical Problem

Existing knowledge graph-based multi-hop question answering methods suffer from problems such as cascading error propagation, insufficient interpretability, high model complexity, and slow inference speed, making it difficult to effectively answer complex multi-hop questions.

Method used

We employ a method based on contrastive learning relation representation, which trains a relation encoder through contrastive learning and negative sampling mechanisms. Combined with a KG context processor and adaptive beam search, we achieve multi-hop inference, reduce error propagation, and provide interpretability.

Benefits of technology

It enables sophisticated multi-hop reasoning on knowledge graphs, finds the optimal reasoning chain, reduces error propagation and provides interpretability, and improves the efficiency and accuracy of answering complex questions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115757737B_ABST
    Figure CN115757737B_ABST
Patent Text Reader

Abstract

The application relates to a knowledge graph multi-hop question answering method and system based on a contrast learning relationship representation, which comprises the following steps: for a KG subgraph corresponding to a question, a corresponding relationship representation is trained based on a contrast learning and a negative sampling mechanism, that is, an encoder is obtained; the relationship is encoded through the encoder, integrated processing is conducted by using a KG context processor, a correlation score for multi-hop reasoning is determined, and a weighted subgraph is obtained; a text classification model is used to predict the number of hops of the question, and an adaptive beam search method is used to search for an optimal weighted chain on the weighted subgraph, and then the answer corresponding to the question is returned. Compared with the prior art, the application can conduct fine multi-hop reasoning on a knowledge graph containing various relationships, effectively find an optimal reasoning chain, reduce error propagation and provide interpretability.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, in particular to a knowledge graph multi-hop question answering method and system based on contrast learning relationship representation. BACKGROUND

[0002] The automatic question answering system based on knowledge graph integrates the cutting-edge technologies in the fields of natural language processing and knowledge graph, and realizes the automatic analysis and answering of complex natural language questions by using knowledge graph. The natural language question answering based on knowledge graph has always been a research hotspot in the academic and industrial circles. The ultimate goal of natural language processing is to enable machines to understand text like humans. Compared with pure text information which describes external objective facts, knowledge is an induction and summary of external objective facts based on text information. The introduction of external knowledge can help machines enhance the understanding of natural language text, and the knowledge graph is a typical carrier thereof.

[0003] Complex multi-hop question answering based on knowledge graph is a key and challenging task, which often requires complex multi-hop reasoning and multiple relationships. The two mainstream methods, i.e. the method based on semantic parsing and the method based on information retrieval, when facing complex multi-hop questions, either need to design complex logical forms to cover different types of questions, or cannot provide interpretable reasoning.

[0004] Specifically, simple questions are relatively easy to answer, and these questions only contain one relationship in the underlying knowledge graph. In contrast, complex questions are difficult to answer because they usually involve multiple relationships in the knowledge graph [Zhou et al., 2018; Lan and Jiang, 2020]. The existing SP-based method (i.e. the method based on semantic parsing) relies heavily on the design of logical forms, which will be difficult to cover various complex questions; in addition, the stage-by-stage parsing and query generation are too early and lead to error propagation [Qiu et al., 2020]. The IR-based method (i.e. the method based on information retrieval) benefits from advanced graph neural network (GNN) architecture, which can perform message passing between entity nodes in the knowledge graph, but due to the weak encoding of relationships and the black-box style of training process, it cannot provide sufficient interpretability [Lan et al., 2021].

[0005] Among them, based on the question, the knowledge graph and the mined meta semantic pattern to construct a structured query subgraph, the purpose of query graph construction is to establish a correct executable SPARQL on the knowledge graph, which is used to answer natural language questions. Although the recent NN (Neural Network) based query graph ranking method performs well, more complex problems face more complex SPARQL syntax, huge ranking search space, locally noisy queries Figure ThreeItem challenge. To this end, a new unified query graph syntax is used, which treats the SPARQL syntax as a subgraph composed of vertices and edges, and is specifically divided into two stages: in the first stage, top-k relevant instances (entities, relations, etc.) are collected as candidate instances through a simple strategy; in the second stage, a graph generation model performs hierarchical generation. It first outlines a graph structure whose vertices and edges are empty slots, and then fills the appropriate instances into the slots, thus completing the query graph. This method decomposes the unbearable search space of the entire query graph into bearable operator spaces, and at the same time, eliminates local ambiguity by using global structure information. In addition, a mutual optimization mechanism is added to improve the overall performance, and each module adjusts itself according to the feedback of other modules, so that the performance of each module will be enhanced and the error propagation will be alleviated. However, this way relies on manual mining and design of complex semantic parsers and logic templates, and has low flexibility.

[0006] The solution to the problem-relation matching is to encode the question and the relation with a pre-trained language model (language model) and calculate the semantic similarity between the embeddings. Studies [Li et al., 2020] have shown that sentence embeddings from pre-trained language models [Devlin et al., 2018] are difficult to capture semantic similarity from the non-smooth anisotropic semantic space of sentences. IR-based methods [Feng et al., 2020; Yasunaga et al., 2021] tend to integrate relation link information into the attention module of the GNN to adjust the messages passing through the entity nodes, which is not sufficient to convincingly backtrack the inference chain due to the lack of explicit multi-hop reasoning on the relation edges. In addition, the candidate chain space presents an exponential growth characteristic [Feng et al., 2020]. Some studies [Lan et al., 2019] try to limit the search space through bundle search, but this approach may exclude correct candidate sub-chains too early, leading to cascading errors.

[0007] In summary, the main problems and challenges of existing knowledge graph-based multi-hop QA are: (1) cascading error propagation problem in the reasoning process; (2) explainability problem; (3) high model complexity and slow reasoning speed, which is difficult to meet the response demand. SUMMARY

[0008] The purpose of the present application is to overcome the defects of the prior art and provide a knowledge graph multi-hop QA method and system based on contrastive learning relation representation, which can perform fine multi-hop reasoning on a knowledge graph containing multiple relations, effectively find the optimal reasoning chain, reduce error propagation and provide explainability.

[0009] The object of the application can be realized by the following technical solutions: a knowledge graph multi-hop question and answer method based on contrast learning relationship representation, comprising the following steps:

[0010] S1, for the KG subgraph corresponding to the question, based on the contrast learning and negative sampling mechanism, the corresponding relationship representation is trained to generate, that is, the encoder is obtained;

[0011] S2, the relationship is encoded by the encoder, and the KG context processor is used for integrated processing to determine the relevance score for multi-hop reasoning, and a weighted subgraph is obtained;

[0012] S3, the number of jumps of the question is predicted by using a text classification model, and the adaptive beam search is used to find the optimal weighted chain on the weighted subgraph, and then the answer corresponding to the question is returned.

[0013] Further, the step S1 specifically comprises the following steps:

[0014] S11, sampling the edges and paths on the KG subgraph corresponding to the question with the topic entity as the center;

[0015] S12, based on the contrast learning and negative sampling mechanism, the corresponding relationship representation is trained to generate, that is, the encoder is obtained.

[0016] Further, the specific process of step S12 is: using the KG and the related question-answer data set, constructing positive and negative examples, and training the question and relationship encoder by contrast learning.

[0017] Further, the step S2 specifically comprises the following steps:

[0018] S21, starting from the topic entity, extracting a k-hop subgraph, and using the encoder to encode the relationship;

[0019] S22, using the KG context processor to score the context relationship of the k-hop subgraph;

[0020] S23, based on the relevance score value, the k-hop subgraph is sequentially executed filtering, fusion and injection operation, and a weighted subgraph containing the relevance score is obtained.

[0021] Further, the step S22 specifically calculates the distance between the context relationship of the k-hop subgraph and the question as the corresponding relevance score value.

[0022] Further, the filtering operation in step S23 is specifically: filtering out the context relationship with a relevance score value lower than a preset threshold.

[0023] Further, the fusion operation in step S23 is specifically: fusing the context edge representation.

[0024] Further, the injecting operation in the step S23 is specifically injecting the context edge representation into the current edge representation.

[0025] Further, the step S3 specifically includes the following steps:

[0026] S31, predicting the hop number of the question by using a text classification model;

[0027] S32, performing an optimal inference chain searching algorithm on the weighted subgraph by adaptive beam search to obtain the answer corresponding to the question.

[0028] A knowledge graph multi-hop question answering system based on contrast learning relationship representation, comprising an encoder, a KG context processor and an inference chain detection module connected in sequence, the encoder is based on a SimCRE model and is used for encoding relationships;

[0029] The KG context processor is used for integrating the encoded relationships to obtain a correlation score for multi-hop inference in a contextual manner;

[0030] The inference chain detection module is used for predicting the hop number of the question and finding the optimal weighted chain through adaptive beam search, thereby returning the answer corresponding to the question.

[0031] Compared with the prior art, the present application is aimed at multi-hop type complex questions, first trains a relationship encoder based on contrast learning and negative sampling mechanism to generate effective relationship representation, proposes the concept of knowledge graph context and designs a knowledge graph context processor for integrating contrast relationship representation to realize multi-hop inference in a contextual manner, in addition, introduces adaptive beam search to effectively find the optimal inference chain, thereby reducing error propagation and providing explainability.

[0032] The present application trains and generates effective relationship representation based on contrast learning and negative sampling mechanism, in addition, combines the SimCRE model and the KG context processor to obtain a correlation score containing semantic distance and structural similarity information, which directly represents the importance of the relationship in answering the question, considers semantic and logical double information and contains reliable inference ability.

[0033] The present application scores the contextual relationship and sequentially performs filtering, fusion and injection operations to fully realize information propagation between edges and ensure realization of explainability path backtracking. BRIEF DESCRIPTION OF DRAWINGS

[0034] Figure 1 It is a method flowchart of the present application;

[0035] Figure 2This is a schematic diagram of the system structure of the present invention;

[0036] Figure 3 This is a schematic diagram of the application framework for an example.

[0037] Figure 4 This is a schematic diagram of the problem sub-diagram in the embodiment;

[0038] Figure 5a This is a schematic diagram of the relational representation generated by the conventional method in the embodiment;

[0039] Figure 5b This is a schematic diagram of the relationship representation generated by the method of the present invention in the embodiment;

[0040] The markings in the diagram are as follows: 1. Encoder; 2. KG context processor; 3. Inference chain detection module. Detailed Implementation

[0041] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0042] Example

[0043] like Figure 1 As shown, a multi-hop question answering method for knowledge graphs based on contrastive learning relation representations includes the following steps:

[0044] S1. For the KG subgraph corresponding to the problem, based on contrastive learning and negative sampling mechanisms, the corresponding relation representation is trained and generated, thus obtaining the encoder. Specifically:

[0045] First, taking the topic entity as the center, sample the edges and paths on the KG subgraph corresponding to the question;

[0046] Then, based on contrastive learning and negative sampling mechanisms, positive and negative examples are constructed using KG and related question-and-answer datasets, and question and relation encoders are trained through contrastive learning.

[0047] S2. The relations are encoded using an encoder and integrated using a KG context processor to determine the relevance scores for multi-hop inference, resulting in a weighted subgraph. Specifically:

[0048] S21. Starting from the topic entity, extract the k-hop subgraph and use an encoder to encode the relations;

[0049] S22. Use the KG context processor to score the relevance of the context relationships in the k-hop subgraph (calculate the distance between the context relationships in the k-hop subgraph and the problem);

[0050] S23, based on the correlation score, the k-hop subgraph is sequentially executed filtering (filtering out the context relationship with a correlation score lower than a preset threshold), fusion (fusing the context edge representation), and injection (injecting the context edge representation into the current edge representation) operations to obtain a weighted subgraph containing a correlation score;

[0051] S3, using a text classification model to predict the number of hops of the question, and using an adaptive beam search to find the optimal weighted chain on the weighted subgraph, and then returning the answer corresponding to the question.

[0052] Based on the above method, a knowledge graph multi-hop question answering system is constructed, as shown in Figure 2 The encoder 1 is based on the SimCRE model and is used for encoding the relationship;

[0053] The KG context processor 2 is used for integrating the encoded relationship to obtain a correlation score for multi-hop reasoning in a contextual manner;

[0054] The reasoning chain detection module 3 is used for predicting the number of hops of the question and finding the optimal weighted chain through adaptive beam search to return the answer corresponding to the question.

[0055] The embodiment applies the above technical solution, as shown in Figure 3 The main steps include:

[0056] First step: based on contrastive learning and a representative negative sampling mechanism, an effective relationship representation is trained.

[0057] Second step: the KG context processor is used to integrate the contrastive relationship embedding to realize multi-hop reasoning in a contextual manner.

[0058] Third step: a text classification model is used to predict the number of hops of the question, and an efficient adaptive beam search is used to find the optimal weighted chain to reduce the error rate and support interpretability.

[0059] Fourth step: the answer to the question is returned.

[0060] In the embodiment, for a corresponding multi-hop complex question, the k-hop subgraph (i.e., the question subgraph) is as shown in Figure 4 First, the existing entity linking method is used to identify the topic entity A1 in the question, the KG and the related question-answer dataset are used to construct positive and negative examples, and the question and relationship encoders are trained through contrastive learning;

[0061] Then, the k-hop subgraph of the topic entity is extracted and encoded, and the similarity score is calculated.

[0062] Then, through adaptive beam search, the optimal inference chain search algorithm is performed on the weighted subgraph to obtain the answer D4 of the question.

[0063] As shown in Figure 5a and Figure 5b The technical solution learns the difference information between the order of the relationships in each hop in the k-hop subgraph. The training sample is used for comparison of positive and negative examples, and the distance between only semantic similarity and different structure is pulled away (the fine-tuned vector representation is not a simple semantic similarity information representation, but a measurement of semantic and structural double distance. In fact, it shares the pressure of subsequent reasoning and contains the function of reasoning). This is also the reason why the technical solution can use the relationship representation output by SimCRE as the basis for subsequent shortest path optimization.

[0064] In addition, the technical solution uses the trained SimCRE model to score the relationships on the question subgraph and calculate the distance between them and the question. Since the KG context path information is integrated, this score contains semantic distance and structural similarity information. This score is used as a basic unit to measure the similarity of relationships in triples and questions in order to effectively find the optimal inference chain.

[0065] In previous ranking work, only the relationship information was used as attention in GNN to regulate message passing between nodes. However, this approach does not fully realize information propagation between edges, making it difficult to backtrack the reasoning path. The technical solution converts the entity scoring and ranking method to relation scoring and ranking, which is also the key to realizing the explainable path backtracking of the technical solution.

[0066] As can be seen from the above, the technical solution considers that the inference chain for identifying complex problems needs to perform fine multi-hop reasoning on a knowledge graph containing multiple relationships. Currently, there are two main challenges: stronger multi-relation linking and the trade-off between search efficiency and accuracy. Relationship linking is the task of identifying relationships from the knowledge graph mentioned in the question. Traditional methods only measure the similarity between the question and a single relationship, which essentially has a major problem: the same relationship in different triples will get the same score, making it difficult to perform multi-hop reasoning on the knowledge graph.

[0067] To this end, the technical solution combines contrastive learning, KG context processor and adaptive beam search mode, wherein based on contrastive learning and a representative negative sampling mechanism, effective relation representation is trained and generated, the SimCRE model is combined with the KG context processor, the obtained relation scoring contains semantic distance and structural similarity information, the score directly represents the importance of the relation in answering the question, the double information of semantics and logic is considered, and the reasoning ability is contained;

[0068] The KG context processor integrates the contrastive relation embedding, multi-hop reasoning is realized in the above cultural manner, scoring and information propagation are performed by directly interacting the relation in the subgraph with the question text, information in the question text can be more fully utilized, and thus the inferential chain of the ground truth is closer;

[0069] The technical solution defines the k-hop KG context of the relation in a triple as the k-hop adjacent relation of the relation, considering that introducing all adjacent relations will cause data explosion and introduce too much noise, inherent knowledge contained in a language model is used for filtering. For example, by using the mask mechanism of Bert, the probability of predicting the occurrence of another entity (except the common node entity of the triple with the current relation) of the candidate context relation in the triple by taking the question as the context is recorded as the co-occurrence rate of the question and the entity, the lower the co-occurrence rate, the less the corresponding relation as context information helps the current relation, and thus the candidate context relation lower than a preset threshold is filtered;

[0070] A text classification model is used to predict the number of hops of the question, an efficient adaptive beam search is used to find the optimal weighted chain, the bit error rate is reduced, and interpretability is supported. By performing depth-first search on the query graph, the query graph is converted into a tree according to the order of visited nodes, and the path from the root node to the leaf node is used as a subquery task. In this way, the query task can be divided into finer-grained subtasks, and these subtasks share computing resources in the early stage and are completely independent in the later stage.

[0071] To verify the effectiveness of the technical solution, the embodiment also carries out experiments on three public data sets of PathQuestion, Wordcup2014 and SimpleQuestion, and the experimental results obviously exceed the previous traditional method.

[0072] The technical solution designs a relationship encoder based on contrast learning to generate effective relationship representation, and adds a representative negative sampling mechanism; proposes the concept of knowledge graph context, and designs a knowledge graph context processor for the same, integrates contrast relationship representation, and realizes multi-hop reasoning in a contextualized manner; adaptive beam search is introduced, which can effectively find the optimal reasoning chain to reduce error propagation and provide explainability.

Claims

1. A knowledge graph multi-hop question answering method based on contrastive learning relationship representation, characterized in that, The method comprises the following steps: S1, for the KG subgraph corresponding to the question, based on the contrast learning and the negative sampling mechanism, training generates the corresponding relationship representation, that is, obtains the encoder; S2, the relationship is encoded by the encoder, and the KG context processor is used for integrated processing to determine the relevance score for multi-hop reasoning, and a weighted subgraph is obtained; S3, the text classification model is used to predict the number of hops of the question, and the adaptive beam search is used to find the optimal weighted chain on the weighted subgraph, and then the answer corresponding to the question is returned; Step S2 specifically comprises the following steps: S21, starting from the topic entity, the k-hop subgraph is extracted, and the relationship is encoded by using the encoder; S22, the context relationship of the k-hop subgraph is scored by using the KG context processor; S23, based on the relevance score value, the k-hop subgraph is sequentially executed filtering, fusion and injection operation, and a weighted subgraph containing the relevance score is obtained; The step S22 specifically calculates the distance between the context relationship of the k-hop subgraph and the question as the corresponding relevance score value; The filtering operation in step S23 is specifically: filtering out the context relationship with a relevance score value lower than a preset threshold; The fusion operation in step S23 is specifically: fusing the context edge representation; The injection operation in step S23 is specifically: injecting the context edge representation into the current edge representation.

2. The knowledge graph multi-hop question answering method based on contrastive learning relationship representation according to claim 1, characterized in that, The step S1 specifically comprises the following steps: S11, taking the topic entity as the center, sampling the edges and paths on the KG subgraph corresponding to the question; S12, based on the contrast learning and the negative sampling mechanism, training generates the corresponding relationship representation, that is, obtains the encoder.

3. The knowledge graph multi-hop question answering method based on contrastive learning relationship representation according to claim 2, characterized in that, The specific process of step S12 is: using the KG and the related question-answer data set, constructing positive and negative examples, and training the question and relationship encoder by contrast learning.

4. The knowledge graph multi-hop question answering method based on contrastive learning relationship representation according to claim 1, characterized in that, The step S3 specifically comprises the following steps: S31, using the text classification model to predict the number of hops of the question; S32, by adaptive beam search, executing the optimal reasoning chain searching algorithm on the weighted subgraph to obtain the answer corresponding to the question.

5. A contrastive learning relation representation based knowledge graph multi-hop question answering system, characterized in that, It comprises an encoder (1), a KG context processor (2) and a reasoning chain detection module (3) connected in sequence, the encoder (1) is based on a SimCRE model and is used for encoding the relationship, specifically, for the KG subgraph corresponding to the question, based on the contrast learning and the negative sampling mechanism, training generates the corresponding relationship representation, to obtain the encoder; The KG context processor (2) is used for integrating the encoded relationship, and the relevance score for multi-hop reasoning is obtained in a context manner, and the specific process comprises: Starting from the topic entity, the k-hop subgraph is extracted, and the relationship is encoded by using the encoder (1); The KG context processor (2) is used for scoring the context relationship of the k-hop subgraph, specifically, calculating the distance between the context relationship of the k-hop subgraph and the question as the corresponding relevance score value; Based on the correlation score, the k-hop subgraph is sequentially subjected to filtering, fusion and injection operations to obtain a weighted subgraph containing the correlation score, wherein the filtering operation is specifically filtering out the context relationship with a correlation score lower than a preset threshold; The fusion operation is specifically fusing the context edge representation; The injection operation is specifically injecting the context edge representation into the current edge representation; The reasoning chain detection module (3) is configured to predict the hop number of the question and find the optimal weighted chain through adaptive beam search, thereby returning the answer corresponding to the question.

Citation Information

Patent Citations

  • Knowledge graph multi-hop question and answer method and model based on cognitive reasoning

    CN113360604A

  • Knowledge graph embedding-based interpretable multi-hop question and answer method and system

    CN114168719A