Subgraph-based temporal knowledge graph question answering method
Through the sub-graph time reasoning method, explicit time information is integrated into problem representation and time sub-graph is constructed, which solves the implicit time and time-limited inference problems of complex problems in tense knowledge graph questions and answers, and realizes reliable answer reasoning and complex time-based reasoning Optimal performance of state datasets.
Patent Information
- Application Number
- CN202210347571.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-01
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2042-04-01
AI Technical Summary
The existing tense knowledge graph question and answer methods are difficult to effectively deal with complex problems, especially those that contain implicit time expression and time limitations, which leads to unreliable answer reasoning.
The subgraph time reasoning method was designed, including implicit expression analysis module, relevant fact search module and subgraph logic reasoning module. Through pre-trained language model and tense knowledge graph embedding, explicit time information is integrated into problem representation, and time activation is used. The function is quantized to score, constructs a time subgraph and crops to determine the answer.
It improves the ability to identify time information in the problem, provides reliable time-limited inference, filters pseudo-tenin problems, achieves the best performance on complex tense data sets, and demonstrates the inference ability of unseen entities.
Smart Images

Figure CN114706951B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing, and in particular to a subgraph-based temporal knowledge graph question-answering method. Background Art
[0002] Knowledge graph question answering (KGQA) requires the system to reason over a knowledge graph (KG) to provide an answer after being given a natural language question. However, in real life, questions often contain time constraints, for example, "Who won the Nobel Prize in 2019?" Due to the lack of temporal information, it is difficult for traditional knowledge graphs to support inference of answers. In recent years, temporal knowledge graphs (TKGs) have flourished, in which the facts involved have a temporal attribute. When faced with temporal questions, temporal knowledge graphs can be used as a knowledge base to help locate potential answers. This task is called temporal knowledge graph question answering (TKGQA). TKGQA divides temporal questions into two categories: (1) simple questions that only require an answer to a single fact; (2) complex questions that require reasoning over multiple facts.
[0003] For a complex question “Who was the first president of the United States after World War II?”, the model should identify the golden prediction from the TKG by retrieving and comparing related entities.
[0004] This task becomes challenging because of the existence of the time dimension. First, in addition to containing specific times (simple questions), questions are likely to include implicit time expressions (also known as complex questions). In the example above, to answer this complex question, we need to figure out the period of World War II, that is, 1939-1945, and then we can perform temporal reasoning afterwards. Secondly, because of the existence of time trigger words such as "first" and "after", direct queries on the temporal knowledge graph cannot answer this question. Assuming that the model already knows that the time of World War II was 1939-1945, there are many candidates in TKG that match this period. At the same time, based on "first" and "after", the target answer can be accurately found through temporal logical reasoning.
[0005] TempoQR, a representative method of temporal knowledge graph question answering, uses temporal knowledge graph embedding to answer temporal questions as link prediction tasks on knowledge graphs. Specifically, it introduces time range information for each question, uses EaE (Entities as experts) to enrich the semantic information of question representation, and finally applies the scoring function of the temporal knowledge graph to predict the answer. Although TempoQR has achieved the best performance so far, it has not explored the core of temporal knowledge graph question answering. In addition, the reason for TempoQR's best performance is mainly due to the existence of pseudo-temporal questions in the current dataset CronQuestions. For example, for "What was the first award won by Carlo Taverna?", there is only one fact related to Carlo Taverna in the temporal knowledge graph, which makes the temporal trigger word "first" not play a role. We define such questions as pseudo-temporal questions. In order to avoid their influence, we refine the CronQuestions dataset and construct the Complex-CronQuestions dataset, which only contains truly complex temporal questions.
[0006] How do humans answer time-related questions? According to the dual process theory, we first understand the semantics of the question and search for relevant information in our vast memory, and then choose an answer considering specific constraints. In this way, people can make full use of the factual knowledge in their heads to understand the implicit time in the question, and further reason based on the time constraints to obtain reliable judgments. Therefore, we try to put this theory into the time series knowledge graph question answering, and its process can be as follows: Figure 1 For a specific question, such as "Who is the first president of the United States after World War II?", we can first retrieve a bunch of relevant facts, such as (World War II, time of occurrence, 1939-1945), etc. After that, considering the time trigger words, namely "first president" and "after World War II", we can dig deep into the time information, perform detailed reasoning, and the remaining candidates are eliminated to get the correct answer.
[0007] Knowledge graph question answering is an important part of intelligent systems. Research in this field is very valuable and has attracted the attention of many researchers. The current mainstream approach is to use KG pre-trained embeddings to answer questions. This type of approach performs well for simple questions, but is challenging for complex questions.
[0008] To address the limitations of the above methods, there are studies that use enhanced problem representations to solve complex problems. Such methods use logical reasoning or exploit available side information in the form of text documents. However, these KGQA algorithms work on non-temporal knowledge graphs, i.e., knowledge graphs containing triples of the form (subject, relation, object), and are not suitable for handling time constraints.
[0009] For temporal knowledge graph question answering, in order to answer temporal questions, we need to reason about temporal knowledge graphs containing facts in the form of (subject, relationship, object, start time, end time). Current temporal knowledge graph question answering methods mainly include two categories: one is the decomposition method based on time constraints, and the other is the representation method based on temporal knowledge graphs.
[0010] The decomposition method based on time constraints decomposes the original question into non-temporal questions and time constraints, and then uses traditional knowledge graph question answering methods to find candidate answers for the sub-questions. Finally, the candidate answers are filtered by time constraints to produce the final answer to the original question. A major disadvantage of this method is the use of pre-specified templates for decomposition and the assumption of time constraints on entities. In addition, it cannot be directly applied to temporal KGs where facts have time ranges.
[0011] Methods based on temporal graph representation use temporal knowledge graph embedding methods to learn entity, relation and timestamp embeddings, and then use the distance between the temporal knowledge graph embedding and the question embedding to score the answer. CronKGQA (Question Answering Over Temporal Knowledge Graphs) provides a learnable reasoning process for temporal knowledge graph question answering, which does not rely on hand-crafted rules and proves that temporal knowledge graph embedding can be applied to the task of temporal knowledge graph question answering. Although CronKGQA performs very well when answering simple questions, it encounters challenges when it needs to reason about certain complex questions with time constraints, mainly because CronKGQA lacks the ability to understand the implicit time and time constraint reasoning in the question. To make up for this shortcoming, TempoQR (Temporal Question Reasoning over Knowledge Graphs) introduces time range information for each question and adopts the EaE (Entity as Expert) method to enhance the semantic information of question representation. However, despite TempoQR's improved performance on complex questions, it still does not take into account temporal constraints such as "before / after", "first / last", etc., resulting in unreliable results. CronQuestions consists of two parts: a knowledge graph with temporal annotations and a question-answer set that requires temporal reasoning. The reason why TempoQR can achieve excellent results without considering complex constraints is mainly due to the existence of pseudo-temporality in CronQuestions. Summary of the invention
[0012] In order to effectively handle complex temporal issues, we design a method using subgraph temporal reasoning (SubGTR), which includes three modules: (1) an implicit expression parsing module, which aims to convert implicit temporal expressions into explicit ones; (2) a related fact search module, which attempts to retrieve all potential entities; and (3) a subgraph logic reasoning module, which considers time constraints for final answer determination. Specifically, in the implicit expression parsing module, the implicit temporal information contained in the natural language question is accurately identified and replaced by explicit time for subsequent search and reasoning. In the related fact search module, we first encode the question into an embedding containing question semantics, temporal knowledge graph semantics, and temporal semantics, and then use the TKG scoring function and the time-sensitive function to obtain candidate entities and their semantic scores. In the subgraph logic reasoning module, a subgraph of each question is first constructed and trimmed by time constraints. We design a temporal activation function to obtain a quantitative score for each entity, which helps to locate the final prediction.
[0013] The method disclosed in the present invention of converting a problem with a time constraint into a vector representation containing problem semantics, temporal knowledge graph semantics and time semantics includes:
[0014] The semantic information of natural language questions is obtained through the pre-trained language model. text The natural language form is converted into a semantic matrix Q by the pre-trained RoBERTa n :
[0015] Q n =W n RoBERTa(q text ),
[0016] in Q n In the i-th row, N is the number of tokens, D is the size of the temporal knowledge graph embedding, and W n It is a D×D roberta Projection matrix, D roberta is the dimension of RoBERTa embedding;
[0017] Replace the semantic matrix Q with the pre-trained temporal knowledge graph embedding n Embeddings of entities and timestamps corresponding to locations:
[0018]
[0019] Where W E is a D×D embedding matrix, e ò and t τ It is the pre-trained embedding of the temporal knowledge graph;
[0020] Incorporate the time embedding of the extracted temporal knowledge graph into the question representation:
[0021]
[0022] Yes all The matrix formed, T1 and T2 are the time ranges of the problem;
[0023] The information is fused into a single question representation q using an information fusion layer consisting of a learnable encoder Transformer(·) that fuses question, entity, and time-aware information together. The final token embedding matrix Q is calculated as
[0024] Q = Transformer (Q T ),
[0025] Where Q = [q CLS,q2,...,q N ], the final problem indicates that q selects the final output layer, that is, q = q CLS ,CLS is a special output of Transformer that aggregates all input information.
[0026] Furthermore, the temporal knowledge graph scoring function φ(·) and the time-sensitive function f(·) are used to obtain the candidate entities and their semantic scores Score sematic include:
[0027] An entity The final score of the answer is given by the following formula:
[0028]
[0029] Among them, s, o and τ are the subject, object and timestamp marked in the question respectively, P E is a D×D learnable matrix for entity prediction, which swaps the subject and object labeled in the question. The max(·) function ensures that when s or o is a false entity, the score is ignored.
[0030] In addition, a timestamp τ∈T is the final score of the answer given by the following formula:
[0031] max(φ(e s ,P T q,e o ,t τ ),f sensity (P T q,t τ )),
[0032] Among them, s and o are the subject and object of the annotation in the question, P T is a D×D learnable matrix for temporal prediction, f sensity is a function used to measure the sensitivity of the problem representation to the timestamp;
[0033] f sensity (P T q,t τ )=P T q·t τ .
[0034] During training, the scores of entities and time are concatenated to get Score sematic , and converted into probabilities through a softmax function; the parameters of the model are continuously updated to assign higher probabilities to the correct answers;
[0035] The Score sematic It is calculated as follows:
[0036]
[0037] Furthermore, the temporal neighbor subgraph contains a central entity e h and its L-order neighbor entities, which are connected by edges containing temporal information.
[0038] Furthermore, for the labeled entity e in the question h , query all its related facts in the temporal knowledge graph, and extract its related entities and time information to construct a temporal subgraph, then the temporal neighbor subgraph can be expressed as:
[0039]
[0040] in Yes h The corresponding L-hop subgraph of It contains the corresponding time information t r , N L (e h ) is e h The set of nodes in the knowledge graph that are not indirect neighbors, is the corresponding edge.
[0041] Furthermore, the clipping of the sub-graph by time constraint includes:
[0042] Extract all paths from neighbor nodes to the central node path = p1, p2, p3, ...;
[0043] Cut edges in the path that do not satisfy the time constraint;
[0044] Delete all isolated nodes, and the remaining part G f It is the subgraph that satisfies the time constraint.
[0045] Furthermore, the time activation function is used to quantitatively score each entity in the subgraph to obtain Score reasoning include:
[0046] The following four temporal activation functions are used to score entities in subgraphs of different question types:
[0047] Equality function: When the question type is equality, we assign corresponding scores to entities that have the same time as T, and 0 points to the rest:
[0048]
[0049] Where c1 is a positive number;
[0050] Before / After function: When the question type is before / after, give higher scores to entities closer to T1 / T2:
[0051]
[0052] First / Last function: When the question type is first / last, assign higher scores to entities that are earlier / later in time:
[0053]
[0054] Time range function: When the question type is time range, assign corresponding scores to entities between T1 and T2, and assign 0 points to other entities:
[0055]
[0056] Where c2 is a positive number;
[0057] Combining the four time-aware functions, the comprehensive scoring function is as follows:
[0058]
[0059] Among them, r(q i ,e i ) is the question q i The type of the condition, 1 means that the condition is met, and 0 means that the condition is not met.
[0060] Furthermore, the score obtained by spatiotemporal subgraph reasoning is combined with the score obtained by related fact search as the final entity score:
[0061] score fusing =μ*score sematic +(1-μ)*score reasoning ,
[0062] Where μ∈(0,1) is used to balance the semantic score sematic and subgraph reasoning score reasoning The weight of
[0063] The scores of all entities and times are concatenated and softmax is used to calculate the answer probability of this comprehensive score vector, and trained using cross entropy loss.
[0064] Furthermore, for each question in the CronQuestions dataset, the relevant facts in the temporal knowledge graph are retrieved according to the entity annotations in the question. If the number is less than 5, the question is eliminated, and the Complex-CronQuestions dataset is obtained.
[0065] Compared with the prior art, the present invention has the following beneficial effects:
[0066] A subgraph temporal reasoning framework SubGTR is proposed to solve TKGQA, which improves the ability to identify temporal information contained in questions;
[0067] The importance of logical reasoning for time constraints is proposed, and reliable answers to problems are obtained by reasoning about answers that meet time constraints through temporal subgraphs.
[0068] Filter out pseudo-temporal questions in the CronQuestions dataset to provide a real complex temporal dataset Complex-CronQuestions, which can better evaluate the model's ability to answer complex temporal questions; achieve the best performance on both CronQuestions and Complex-CronQuestions datasets;
[0069] Cold-start experiments demonstrate SubGTR’s ability to reason about unseen entities. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 Flowchart of time series knowledge graph question answering in the prior art;
[0071] Figure 2 The architecture diagram of implicit expression parsing and related fact search in the present invention;
[0072] Figure 3 The subgraph logic reasoning architecture diagram of the present invention;
[0073] Figure 4 Schematic diagram of the temporal neighbor subgraph in the present invention;
[0074] Figure 5 Schematic diagram of the sub-graph clipping process in the present invention;
[0075] Figure 6 Schematic diagram of four time activation functions in the present invention. DETAILED DESCRIPTION
[0076] The present invention is further described below in conjunction with the accompanying drawings, but the present invention is not limited in any way. Any changes or substitutions made based on the teachings of the present invention belong to the protection scope of the present invention.
[0077] The temporal knowledge graph K:=(E,R,T,F) is a multi-relational directed graph with time-stamped edges between entities. A fact in K can be formalized as (s,r,o,τ)∈F, where s,o∈E represents the subject and object entities, r∈R represents the relationship between them, and τ∈T is the timestamp associated with the relationship. The temporal knowledge graph embedding method learns each fact in K. and K-dimensional vector of τ∈T So that through the scoring function φ(·), the score ratio of each fact (s, r, o, τ) ∈ F is The score is high, which is formally expressed as φ(e s ,v r ,e o ,t τ )>φ(e s′ ,v r′ ,e o′ ,t τ′ ).
[0078] Given a temporal knowledge graph K and a natural language question q, temporal knowledge graph question answering aims to obtain an entity s / o∈E or a timestamp τ∈T that correctly answers question q. In general, question q can be formalized as a token list [token1,...token n ], where token i is the i-th token of the question, and n is the length of the question. In the temporal knowledge graph question answering dataset D, a data sample consists of a question-answer pair (q i ,a i ) and q i The entity in the TKG entity is linked to its unique identifier.
[0079] Figure 2 and Figure 3 The overall architecture of the present invention is presented. It consists of three modules: implicit expression parsing module, related fact search module and subgraph logic reasoning module. First, the background knowledge in the temporal knowledge graph is used to simplify the problem and obtain the corresponding time constraints. Then, candidate entities are searched in the massive temporal knowledge graph embedding to obtain the initial score. Finally, the answer entity is obtained by constructing the question subgraph, and it is trimmed and logically reasoned using the time constraint.
[0080] In the implicit expression parsing module, the time information hidden in the question is extracted and parsed through the knowledge in the temporal knowledge graph, and the natural language format question is replaced with a simplified question using a regular expression. Time constraints T1 and T2 are added to the question for subsequent reasoning and query. In the related fact search module, we first convert the natural language question into a vector representation containing the question semantics, temporal knowledge graph semantics, and time semantics, and then use the TKG scoring function φ(·) and the time-sensitive function f(·) to obtain the candidate entity and its semantic score Score sematic ; In the subgraph temporal reasoning module, we first build a subgraph for each problem, and then trim the subgraph by temporal constraints. Finally, we use the temporal activation function to quantify and score each entity in the subgraph to obtain Scorereasoning , and obtain the final answer by fusing the scores.
[0081] In complex questions, there is a lot of implicit temporal information, which poses an obstacle to question answering systems. Humans naturally associate existing common sense information to simplify questions. Based on this intuition, we designed an implicit expression parsing module that enables the model to simplify questions and explicitly obtain the hidden temporal information in questions. It mainly consists of two parts, generalized knowledge extraction and specific knowledge extraction.
[0082] Generalized knowledge extraction: In practice, we often use the names of some well-known events as time constraints, for example, "Who was the first president of the United States after World War II?" World War II has no direct relationship with the president of the United States, but it can be regarded as implicit time information. Due to the lack of background knowledge, existing models often miss this kind of time information. Therefore, we use the event knowledge in the temporal knowledge graph to replace the implicit event constraints appearing in natural language questions with explicit time information, i.e., 1921.
[0083] Specific knowledge extraction: In addition to well-known events, other types of hidden time information may also appear in complex questions. For example, “Who made significant contributions to quantum mechanics before Einstein?” We cannot directly obtain time information through Einstein. Instead, we need to query the knowledge graph through joint information such as (quantum mechanics, Einstein) to obtain the corresponding time information, which is called specific knowledge extraction.
[0084] In the related fact search module, inspired by EaE and TempoQR, we use language models and temporal knowledge graph embedding to transform questions in natural language form into vector representations (question encoding) that contain question semantics, temporal knowledge graph semantics, and time semantics, and then use the scoring function and time-sensitive function of the temporal knowledge graph to obtain candidate entities and their semantic scores.
[0085] Question encoding includes obtaining semantic information of natural language questions, capturing semantic knowledge about entities in natural language questions, integrating time embedding of temporal knowledge graph into question representation, and fusing question, entity and time-aware information.
[0086] Semantics of natural language: The semantic information of natural language questions is obtained through pre-trained language models. More specifically, the question q text The natural language form is converted into a semantic matrix Q by the pre-trained RoBERTa n .
[0087] Q n =W n RoBERTa(q text ),
[0088] among them Q n In the i-th row, N is the number of tokens, D is the size of the temporal knowledge graph embedding, and W N It is a D×D roberta The projection matrix, where D roberta is the dimension of RoBERTa embedding.
[0089] Semantics of entities: To capture the semantic knowledge about entities in natural language questions, we replace Q with pre-trained temporal knowledge graph embeddings. n Embeddings of entities and timestamps corresponding to locations.
[0090]
[0091] Where W E is a D×D embedding matrix, e ò and t τ is the pre-trained embedding of the temporal knowledge graph. This enriches the representation of the question with the entity information of the temporal knowledge graph.
[0092] Semantics of time: In the implicit knowledge perception module, we explicitly transform the time information in the question and obtain the time information T1 and T2. In order to strengthen the understanding of time information, we incorporate the time embedding of the extracted temporal knowledge graph into the question representation.
[0093]
[0094] T1 and T2 are the time frames of the questions obtained by the implicit knowledge perception module.
[0095] Semantic Fusion: Next, we propose an information fusion layer to fully fuse the information into a single question representation q. We use an information fusion layer consisting of a specialized learnable encoder Transformer(·). This encoder is able to fuse question, entity, and time-aware information together. The final token embedding matrix Q is calculated as
[0096] Q = Transformer (Q T ),
[0097] Where Q = [q CLS ,q2,...,q N ], the final problem indicates that q selects the final output layer, that is, q = q CLS .
[0098] Scoring function
[0099] An entity The final score of the answer is given by the following formula
[0100]
[0101] Among them, s, o and τ are the subject, object and timestamp marked in the question respectively, P E is a D×D learnable matrix specifically for entity prediction. Here, we swap the subject and object of the annotation, and the max(·) function ensures that we ignore the score when s or o is a false entity.
[0102] In addition, a timestamp τ∈T is the final score of the answer given by
[0103] max(φ(e s ,P T q,e o ,t τ ),f sensity (P T q,t τ )),
[0104] Among them, s, o are the annotation entities in the question, P T is a D×D learnable matrix specifically used for temporal prediction. sensity is a function used to measure the sensitivity of the problem representation to the timestamp.
[0105] f sensity (P T q,t τ )=P T q·t τ .
[0106] During training, the scores of entities and times are concatenated and converted into probabilities through a softmax function. During training, the parameters of the model are continuously updated to assign higher probabilities to the correct answers.
[0107] In the subgraph temporal reasoning module, we first construct a temporal neighbor subgraph for each question, then trim it according to the temporal constraints, and finally use the temporal activation function to achieve quantitative scoring of the temporal constraints to obtain the final answer. Specifically, it includes four steps: subgraph extraction, subgraph trimming, entity reasoning scoring, and scoring fusion.
[0108] Subgraph extraction: The neighbor entities of the labeled entity in the question contain a lot of information that helps answer the question. In order to obtain the information of the neighbor entities, we first construct a temporal neighbor subgraph. The temporal neighbor subgraph contains a central entity e h and its L-order neighbor entities, which are connected by edges containing temporal information. More precisely, for the problem ( Figure 4 The godfather in the tag entity e h , we query all its related facts in the temporal knowledge graph and extract its related entities and time information to build a temporal subgraph. k (e h ) is e h The set of nodes in the L-hop (non-indirect) neighborhood of the KG, is the corresponding edge, then the temporal neighbor subgraph can be expressed as
[0109]
[0110] in Yes h The corresponding L-hop subgraph of It contains the corresponding time information t r .
[0111] Subgraph pruning: Since the temporal neighbor subgraph contains a lot of useless neighbor information, we use the time constraints in the question to filter the temporal subgraph. In the implicit expression parsing module, we have obtained the time range [T1, T2] of each question, where T1 is the start time and T2 is the end time. We check whether all paths on the subgraph meet the time constraints. Figure 5 Specifically, we first extract all paths from neighbor nodes to the central node path = p1, p2, p3, ... and then cut the edges that do not meet the time constraint in the path, and finally delete all isolated nodes. The remaining part G f It is the subgraph that satisfies the time constraint.
[0112] Entity Reasoning Scoring: Reference Figure 6 ,In order to achieve the quantitative scoring of time constraints, the ,following four time activation functions are designed to score the entities in the ,subgraphs of different question types.
[0113] Equality: When the question type is equality, we assign corresponding scores to entities that have the same time as T, and 0 points to the rest.
[0114]
[0115] Where c1 is a positive number.
[0116] Before / After: When the question type is Before / After, we give higher scores to entities that are closer to T1 / T2.
[0117]
[0118] First / Last: When the question type is first / last, we assign higher scores to entities that are earlier / later in time.
[0119]
[0120] Time range: When the question type is time range (timejoin), we assign corresponding scores to entities between T1 and T2 and assign 0 points to other entities.
[0121]
[0122] Where c2 is a positive number.
[0123] Therefore, combining the four time-aware functions, we can give the comprehensive scoring function as follows.
[0124]
[0125] Among them, r(q i ,e i ) is the question q i The type of the condition, 1 means that the condition is met, and 0 means that the condition is not met.
[0126] Rating fusion: The score obtained by spatiotemporal subgraph reasoning is combined with the score obtained by related fact search as the final entity score.
[0127] score fusing =μ*score sematic +(1-μ)*score reasoning ,
[0128] where μ∈(0,1) is used to balance the weights of semantic and subgraph reasoning scores.
[0129] The scores of all entities and times are concatenated and softmax is used to calculate the answer probability for this combined score vector. The model is trained using cross entropy loss.
[0130] The following is the experimental results section, and the present invention is implemented by Pytorch. TComplEx is used as TKG embedding, and its size D=512. The pre-trained language model used in semantic search is RoBERTa. During the training process, the parameters of the language model and the TKG embedding are fixed and not updated. The number of transformation layers of the encoder Transformer(·) is set to l=6. The number of hops k of the subgraph is set to 1, and the score fusion weight μ is set to 0.5. The parameters of the model are updated using Adam with a learning rate of 0.0002. The model was trained for 20 maximum epochs, and the final parameters were determined based on the best validation performance.
[0131] CronQuestions is a dataset for answering questions on temporal knowledge graphs, including a temporal KG with 125k entities and 328k facts, and a set of 410k natural language questions that require temporal reasoning. In this temporal knowledge graph, facts are represented as (subject, relation, object, [start time, end time]). The CronQuestions dataset has 410,000 question-answer pairs, of which 350,000 are used for training and 30,000 are used for validation and testing. In addition, the entities and times present in the questions are annotated. CronQuestions has four question types, as shown in Table 1, including simple and complex temporal questions. However, in CronQuestions, there are a large number of pseudo-temporal questions, and the time restriction does not play a role due to the lack of relevant facts in TKG. To remedy this defect, the present invention constructs Complex-CronQuestions, which removes simple and pseudo-temporal questions in CronQuestions. Specifically, for each question, according to the entity annotations in the question, its relevant facts in the temporal knowledge graph are retrieved, and if the number is less than 5, the question is eliminated. Table 1 shows the dataset divisions for CronQuestions and Complex-CronQuestions.
[0132] Table 1
[0133] Dataset CronQuestions Complex-CronQuestions train 350000 35795 valid 30000 5020 test 30000 5006
[0134] The model of the present invention is compared with the following typical work.
[0135] BERT: We experiment with BERT and RoBERTa. To evaluate these models, we generate their LM-based question embeddings and concatenate them with the annotated entity and time embeddings followed by a learnable projection. The resulting embeddings are scored via point multiplication over all entities and timestamps and softmaxed to predict answer probabilities.
[0136] EmbedKGQA: EmbedKGQA is designed with regular KGs. Our experiments on TKGQA are as follows. Timestamps are ignored in pre-training and random time embeddings are used in the QA task.
[0137] CronKGQA: CronKGQA is a method based on TKGQA embedding. It first uses the LM model to obtain question embeddings, and then utilizes the scoring function based on TKG embeddings to predict the answer.
[0138] EaE: Entity as Expert (EaE) is an entity-aware approach. In the experiments, we use TKG embedding to enhance the representation of questions and then predict the probability of answers through dot products.
[0139] EntityQR: Based on EaE, EntityQR utilizes a scoring function based on TKG embedding for answer prediction.
[0140] TempoQR: Similar to EaE, TempoQR utilizes a scoring function based on TKG embedding to predict the answer and incorporates additional temporal information.
[0141] Results on the CronQuestions dataset: Table 2 shows the comparison results of the present invention and other baselines on CronQuestions. First, by comparing TempoQR and CronKGQA, we see that incorporating the entities and times contained in the question into the question representation is very helpful for answering complex questions. In this case, complex questions have 27% and 9% improvements in Hits@1 and Hits@10, respectively. In addition, comparing SubGTR and TempoQR, we see the benefits of subgraph reasoning for the question. Compared with TempoQR, SubGTR has a 5% improvement in overall Hits@1 and an 8% improvement in the Hits@1 indicator for complex questions. Our model is significantly improved over the current baseline model and achieves optimal results on CronQuestions.
[0142] Table 2
[0143]
[0144] Results on the Complex-CronQuestions dataset
[0145] In order to verify the effectiveness of the model on actual complex problems, we conducted experiments on the Complex-CronQuestions dataset. The experimental results are shown in Figure 4 Compared with the results on CronQuestions, CronKGQA, EntityQR, and TempoQR all show a significant decrease on Complex-CronQuestions, with a decrease of 0.381, 0.320, and 0.126 respectively at Hits@1. SubGTR shows the best result, 0.920 at Hits@1, which is only 0.04 lower than the result on CronQuestions. This highlights the model's ability to solve complex questions.
[0146] In CronQuestions and Complex-CronQuestions, the entities involved in the training set and the test set do not overlap with each other. However, the temporal knowledge graph embedding used for training contains all entity information, so the model can obtain entity information of the test set during training. To verify the effectiveness of the model in solving the entity cold start problem, we deleted the facts of the relevant entities in the test set from the temporal knowledge graph Wikidata and retrained the temporal knowledge graph embedding containing only the entities in the training set to ensure that the information of the entities in the test set does not appear in the training.
[0147] In the above way, we constructed CronQuestions(Zero) and Complex-CronQuestions(Zero), in which the entities involved in the prediction did not appear in the training, and there was no corresponding pre-trained TKG embedding, in order to simulate the entity cold start problem caused by adding new entities in extreme cases. The experimental results are shown in Table 4. TempoQR mainly relies on TKG embedding for reasoning. In the absence of TKG embedding in the test set, we extracted random vectors from the normal distribution as the embedding of the entity. It can be seen from the experimental results that TempoQR performs poorly on entities and only has some effect on the prediction of temporal entities. In contrast, SubGTR has an accuracy of 92.0% and 82.0% on the CronQuestions(Zero) and Complex-CronQuestions(Zero) datasets, respectively, indicating that SubGTR can make full use of the structural information of the temporal subgraph to infer questions and answers on entities that have never been seen, without being restricted by specific entities. The model of the present invention effectively avoids the entity cold start problem.
[0148] Table 4 Experiments on unseen entities
[0149]
[0150] In order to verify the effectiveness of each module of SubGTR, we conducted a reduction experiment. First, we removed the subgraph reasoning module and directly used the score of the related fact search module as the final score. It can be found that the HIts@1 value of the model in the experiment dropped by 7%, highlighting the effectiveness of the subgraph reasoning module.
[0151] Secondly, implicit expression parsing can obtain the hidden temporal information in the question. We replaced it with the Hard-supervision method in TempoQR, and the model dropped by 2% on HIts@1, which shows that our implicit expression parsing module can accurately extract hidden temporal information, simplify natural language questions, and improve the quality of question representation.
[0152] Finally, the time sensitivity score can improve the model's perception of timestamps. It can be found that after replacing the model's time sensitivity score with the time scoring function of the temporal knowledge graph embedding method, the effect dropped by 3%, indicating the effectiveness of the time sensitivity score proposed in the present invention.
[0153] Table 5 Ablation experiment results
[0154]
[0155] This section conducts a case study to demonstrate the unique advantages of SubGTR compared to the current state-of-the-art method TempoQR. In Table 6, typical examples of incorrect answers of TempoQR are shown, highlighting its design flaws. In contrast, SubGTR is able to effectively exploit the time constraints to prune and score entities through temporal subgraph reasoning to obtain the correct answer.
[0156] Table 6 Typical examples of TempoQR misprediction
[0157] Question Type Typical Problems TempoQR The present invention Before / After Who was the first president of the United States after World War II? mistake correct First / Last Who is Norway's Minister of Finance? mistake correct
[0158] Compared with the prior art, the present invention has the following beneficial effects:
[0159] A subgraph temporal reasoning framework SubGTR is proposed to solve TKGQA, which improves the ability to identify temporal information contained in questions;
[0160] The importance of logical reasoning for time constraints is proposed, and reliable answers to problems are obtained by reasoning about answers that meet time constraints through temporal subgraphs.
[0161] Filter out pseudo-temporal questions in the CronQuestions dataset to provide a real complex temporal dataset Complex-CronQuestions, which can better evaluate the model's ability to answer complex temporal questions; achieve the best performance on both CronQuestions and Complex-CronQuestions datasets;
[0162] Cold-start experiments demonstrate SubGTR’s ability to reason about unseen entities.
[0163] The word "preferred" as used in the present invention is intended to be used as an example, instance or illustration. Any aspect or design of the present invention described as "preferred" is not necessarily to be construed as being more advantageous than other aspects or designs. On the contrary, the use of the word "preferred" is intended to present concepts in a specific way. The term "or" as used in this application is intended to mean an inclusive "or" rather than an exclusive "or". That is, unless otherwise specified or clear from the context, "X uses A or B" means any one of the naturally included arrangements. That is, if X uses A; X uses B; or X uses both A and B, then "X uses A or B" is satisfied in any of the aforementioned examples.
[0164] Moreover, although the present disclosure has been shown and described with respect to one or implementations, those skilled in the art will think of equivalent variations and modifications based on the reading and understanding of this specification and the accompanying drawings. The present disclosure includes all such modifications and variations, and is limited only by the scope of the appended claims. In particular, with respect to the various functions performed by the above-mentioned components (such as elements, etc.), the terms used to describe such components are intended to correspond to any component (unless otherwise indicated) that performs the specified function of the component (such as it is functionally equivalent), even if the structure is not equivalent to the disclosed structure of the function in the exemplary implementation of the present disclosure shown in the present invention. In addition, although the specific features of the present disclosure have been disclosed with respect to only one of several implementations, such features can be combined with one or other features of other implementations that may be desired and advantageous for a given or specific application. Moreover, insofar as the terms "including", "having", "containing" or their variations are used in specific embodiments or claims, such terms are intended to be included in a manner similar to the term "comprising".
[0165] The functional units in the embodiments of the present invention may be integrated into a processing module, or each unit may exist physically separately, or multiple or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium. The above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc. The above-mentioned devices or systems may execute the storage method in the corresponding method embodiment.
[0166] To sum up, the above embodiment is an implementation mode of the present invention, but the implementation mode of the present invention is not limited by the embodiment. Any other changes, modifications, substitutions, combinations, and simplifications that deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A subgraph-based temporal knowledge graph question answering method, characterized in that: The following steps are involved: The time information hidden in the question is extracted and parsed through the knowledge in the temporal knowledge graph, and the question in natural language format is replaced with a simplified question using regular expressions. The time ranges T1 and T2 of the question are added to the question for subsequent reasoning and query. The problem with time constraints is transformed into a vector representation that contains question semantics, temporal knowledge graph semantics, and time semantics. Then, the temporal knowledge graph scoring function φ(·) and the time-sensitive function f(·) are used to obtain candidate entities and their semantic scores. Construct a temporal neighbor subgraph for each question; trim the temporal neighbor subgraph by time constraints; use a time activation function to quantitatively score each entity in the temporal neighbor subgraph to obtain a subgraph reasoning score; The final answer is obtained by integrating the semantic score and the subgraph reasoning score; The step of converting the problem with time constraints into a vector representation containing problem semantics, temporal knowledge graph semantics, and time semantics includes: The semantic information of natural language questions is obtained through the pre-trained language model. text The natural language form is converted into a semantic matrix Q by the pre-trained RoBERTa n : Q n =W n RoBERTa(q text ), in Q n In the i-th row, N is the number of tokens, D is the size of the temporal knowledge graph embedding, and W n It is a D×D roberta Projection matrix, D roberta is the dimension of RoBERTa embedding; Replace the semantic matrix Q with the pre-trained temporal knowledge graph embedding n Embeddings of entities and timestamps corresponding to locations: where w E is a D×D embedding matrix, and t τ It is the pre-trained embedding of the temporal knowledge graph; Incorporate the time embedding of the extracted temporal knowledge graph into the question representation: Yes all The matrix formed, T1 and T2 are the time ranges of the problem; The information is fused into a single question representation q using an information fusion layer consisting of a learnable encoder Transformer(·) that fuses question, entity, and time-aware information together. The final token embedding matrix Q is calculated as Q=Transformer(Q T ), Where Q = [q CLS ,q2,...,q N ], the final problem indicates that q selects the final output layer, that is, q = q CLS ,CLS is a special output of Transformer, which aggregates all input information; The temporal knowledge graph scoring function φ(·) and the time-sensitive function f(·) are used to obtain candidate entities and their semantic scores Score sematic include: The final score of an entity ∈∈ε being the answer is given by the following formula: Among them, ε, o and τ are the subject, object and timestamp marked in the question respectively, P E is a D×D learnable matrix for entity prediction, which swaps the subject and object labeled in the question. The max(·) function ensures that the score is ignored when s or o is a false entity. In addition, a timestamp τ∈T is the final score of the answer given by max(φ(e s ,P T q,e o ,t τ ),f sensity (P T q,t τ )), Among them, s, o are the subject and object of the annotation in the question, P r is a D×D learnable matrix for temporal prediction, f sensity is a function used to measure the sensitivity of the problem representation to the timestamp; f sensity (P T q,t τ )=P T q·t τ · During training, the scores of entities and time are concatenated to get Score sematic , and converted into probabilities through a softmax function; the parameters of the model are continuously updated to assign higher probabilities to the correct answers; The Score sematic It is calculated as follows:
2. The subgraph-based temporal knowledge graph question answering method according to claim 1, characterized in that: The temporal neighbor subgraph contains a central entity e h and its L-order neighbor entities, which are connected by edges containing temporal information.
3. The subgraph-based temporal knowledge graph question answering method according to claim 2, characterized in that: For the labeled entity e in the question h , query all its related facts in the temporal knowledge graph, and extract its related entities and time information to construct a temporal subgraph, then the temporal neighbor subgraph can be expressed as: in Yes h The corresponding L-hop subgraph of It contains the corresponding time information t r , N L (e h ) is e h The set of nodes in the knowledge graph that are not indirect neighbors, is the corresponding edge.
4. The subgraph-based temporal knowledge graph question answering method according to claim 1, characterized in that: The clipping of the sub-graph by using a time constraint comprises: Extract all paths from neighbor nodes to the central node path = p1, p2, p3, ...; Cut edges in the path that do not satisfy the time constraint; Delete all isolated nodes, and the remaining part G f It is the subgraph that satisfies the time constraint.
5. The subgraph-based temporal knowledge graph question answering method according to claim 1, characterized in that: The time activation function is used to quantitatively score each entity in the subgraph to obtain Score reasoning include: The following four temporal activation functions are used to score entities in subgraphs of different question types: Equality function: When the question type is equality, we assign corresponding scores to entities that have the same time as T, and 0 points to the rest: Where c1 is a positive number; Before / After function: When the question type is before / after, give higher scores to entities closer to T1 / T2: First / Last function: When the question type is first / last, assign higher scores to entities that are earlier / later in time: Time range function: When the question type is time range, assign corresponding scores to entities between T1 and T2, and assign 0 points to other entities: Where c2 is a positive number; Combining the four time-aware functions, the comprehensive scoring function is as follows: Among them, r(q i , e i ) is the question q i The type of the condition, 1 means that the condition is met, and 0 means that the condition is not met.
6. The subgraph-based temporal knowledge graph question answering method according to claim 1, characterized in that: The score obtained by spatiotemporal subgraph reasoning is combined with the score obtained by related fact search as the final entity score: score fusing =μ*score sematic +(1-μ)*score reasoning , Where μ∈(0, 1) is used to balance the semantic score sematic and subgraph reasoning score reasoning The weight of The scores of all entities and times are concatenated and softmax is used to calculate the answer probability of this comprehensive score vector, and trained using cross entropy loss.
7. The subgraph-based temporal knowledge graph question answering method according to claim 1, characterized in that: For each question in the CronQuestions dataset, the relevant facts in the temporal knowledge graph are retrieved according to the entity annotations in the question. If the number is less than 5, the question is eliminated and the Complex-CronQuestions dataset is obtained.
Citation Information
Cited By
An electronic product intelligent consultation question and answer method based on a knowledge graph
CN122862401A
