Temporal knowledge graph reasoning method and system based on time weight

Through the time weighting method based on transformer and attention mechanism, the time sequence knowledge graph is weighted, which solves the problem of neglecting the importance of timestamps in the prior art, and achieves more efficient and accurate knowledge graph inference and prediction.

CN116739092BActive Publication Date: 2025-08-26SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310725830.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-19
Publication Date
2025-08-26
Estimated Expiration
2043-06-19

AI Technical Summary

Technical Problem

Existing timing knowledge graph inference methods ignore the importance of different timestamps, resulting in a decrease in model efficiency and accuracy, and failing to effectively learn the potential semantic representation of entities and their relationships.

Method used

The time weighting method based on transformer and attention mechanism is used to weight the timestamps in the time sequence knowledge graph, and the attention weight vector matrix is ​​obtained through the timestamp attention mechanism encoder, and the multi-relational graph aggregator and recurrent neural network are combined to infer entities and relationships.

Benefits of technology

It improves the accuracy and efficiency of time series knowledge graph inference, can better capture the dynamic changes in time characteristics and entity relationships, and enhances the prediction ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116739092B_ABST
    Figure CN116739092B_ABST
Patent Text Reader

Abstract

The present invention discloses a temporal knowledge graph reasoning method and system based on time weights, which belongs to the field of knowledge graph reasoning technology. The present invention performs attention weighting processing on each timestamp in the temporal knowledge graph, so that the model aggregates each timestamp with different attention levels, considers the impact of timestamps on quadruple facts, and uses a multi-relationship graph aggregator to aggregate neighborhood information and fact information to better reason about the data in the temporal knowledge graph, thereby improving the reasoning efficiency and accuracy of the model. It solves the problem in the prior art of "ignoring the dynamic nature and time dependence of facts, failing to learn the potential semantics of entities and their relationships, and resulting in inaccurate knowledge graph reasoning."
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of knowledge graph reasoning technology, and in particular to a temporal knowledge graph reasoning method and system based on time weighting. Background Art

[0002] The statements in this section merely mention background art related to the present invention and do not necessarily constitute prior art.

[0003] Knowledge graph reasoning technology is currently a hot topic of research. It can mimic human reasoning to reason about knowledge graphs. However, most existing knowledge graph reasoning technologies are static, and these static knowledge graph reasoning methods cannot be directly applied to temporal knowledge graphs, because temporal knowledge graphs not only need to model entity relationships but also fully consider temporal characteristics.

[0004] Reasoning methods in time-series knowledge graphs can be broadly categorized into inference and extrapolation. Although relatively little research has been conducted on extrapolation, its application in time-series knowledge graphs is crucial. It can help populate knowledge graphs for future timestamps, enabling predictions of future events. For example, based on existing historical quadruple data, it can infer future changes in the relationships between entities. These predictions provide valuable insights and decision-making foundations, such as in financial risk forecasting and question-answering systems.

[0005] However, most of the current research on extrapolation of temporal knowledge graph reasoning is to generate knowledge graph snapshots based on timestamps. This type of method aggregates each timestamp with the same attention, ignoring the fact that facts in different timestamps have different degrees of influence on the reasoning results. Therefore, simply aggregating facts in all timestamps is not conducive to extracting the structural information of the entire temporal knowledge graph.

[0006] In addition, facts are dynamic, and entities and relations will change over time. Simply embedding time information into entities and relations ignores the integrity of the quadruple.

[0007] In the prior art, Jin et al. proposed an autoregressive structural reasoning method that models the occurrence of facts as a probability distribution conditioned on the time series of a historical knowledge graph. This method solves the reasoning problem of concurrent events and aggregates semantic information related to temporally adjacent events. Leblay et al. introduced an embedding method into the temporal knowledge graph, embedding timestamp expressions into a low-dimensional space and defining a scoring function to calculate the probability of the reasoning task. García et al. used a recurrent neural network to learn time-aware representations of relation types by incorporating timestamps. However, the following problems still exist:

[0008] (1) Since different timestamps have different importance in the temporal knowledge graph, the above method aggregates each timestamp with the same attention, which is not only not conducive to extracting the structural information of the entire graph, but also affects the efficiency and accuracy of the model. In addition, the above method cannot learn the latent semantic representation of entities and their relationships.

[0009] (2) Based on embedding technology, the dynamic nature and time dependency of facts are ignored. Entities and relationships will change over time. Only time information is embedded into entities and relationships, while the integrity of the quadruple is ignored. Summary of the Invention

[0010] In order to address the shortcomings of the existing technology, the present invention provides a temporal knowledge graph reasoning method, system, electronic device and computer-readable storage medium based on time weight, performs temporal knowledge graph reasoning based on transformer and attention mechanism, and changes and pays attention to weights of different timestamps, so as to be more accurate and reliable in reasoning and prediction tasks.

[0011] In the first aspect, the present invention provides a temporal knowledge graph reasoning method based on time weight;

[0012] The temporal knowledge graph reasoning method based on time weight includes:

[0013] Obtain a time series knowledge graph to be inferred, and obtain a fact sequence corresponding to a historical timestamp based on the time annotation of the facts in the time series knowledge graph; construct an entity embedding vector and a relationship embedding vector based on the fact sequence;

[0014] The fact sequence corresponding to the historical timestamp is input into the timestamp attention mechanism encoder for processing, and the attention weight vector matrix of the historical timestamp is obtained according to the fact sequence corresponding to the historical timestamp;

[0015] Input the entity embedding vector and the relationship embedding vector into the multi-relationship graph aggregator to obtain entity neighborhood information and fact aggregation information;

[0016] Based on the entity neighborhood information, fact aggregation information, the attention weight vector matrix of the historical timestamp, and the fact sequence corresponding to the historical timestamp, a recurrent neural network is used to determine the global and local representations of the fact sequence at the moment before the current timestamp.

[0017] The global representation and local representation are input into the fact decoder to reason on the temporal knowledge graph and predict the entity or relationship at the current timestamp.

[0018] Furthermore, the determining of the global representation and local representation of the fact sequence at the moment before the current timestamp by a recurrent neural network based on the entity neighborhood information, the attention weight vector matrix of the historical timestamp, and the fact sequence corresponding to the historical timestamp includes:

[0019] Based on the fact aggregation information at the moment before the current timestamp, the attention weight vector matrix of the historical timestamps, and the global representation of all facts corresponding to the historical timestamps, a recurrent neural network is used to determine the global representation of all facts at the moment before the current timestamp.

[0020] Based on the entity neighborhood information, the attention weight vector matrix of the historical timestamps, and the local representation of the entity and relationship at the moment before the current timestamp, the local representation of the entity and relationship at the moment before the current timestamp is updated through a recurrent neural network;

[0021] According to the entity neighborhood information, the attention weight vector matrix of the historical timestamps and the local representation of the head entity at the moment before the current timestamp, the local representation of the entity at the moment before the current timestamp is determined through a recurrent neural network.

[0022] Preferably, the attention weight vector matrix of the historical timestamp is expressed as:

[0023]

[0024]

[0025] in, For all factual information with historical timestamps, d n Indicates dimension, Q, K, and V are matrices.

[0026] Preferably, the global representation of all facts at the moment before the current timestamp is:

[0027] H t-1 =RNN 1 (g(G t-1 ),H t-2 *Att_W t-m:t-1 )

[0028] Among them, g(G t-1 ) is the aggregation of all facts at timestamp t-1, G t-1 is the set of all four-tuple facts at timestamp t-1, Att_W t-m:t-1 is the attention vector weight matrix of the historical timestamp, H t-2 This is all the information in the graph up to the time stamp t-2;

[0029] The local representation of the head entity and relationship at the moment before the current timestamp is:

[0030]

[0031] in, is the aggregation of entity neighborhood information, is the aggregation of facts associated with the head entity at timestamp t-1, Att_W t-m:t-2 is the attention vector weight matrix of the historical timestamp, h t-2 (s, r) is the local representation of the head entity s and relation r at timestamp t-2;

[0032] The local representation of the head entity and relationship at the moment before the current timestamp is:

[0033]

[0034] in, is the aggregation of entity neighborhood information, is the aggregation of facts associated with the head entity at timestamp t-1, Att_W t-m:t-2 is the attention vector weight matrix of the historical timestamp, h t-2 (s) is the local representation of the head entity s at timestamp t-2.

[0035] Furthermore, the multi-relationship graph aggregator is represented as:

[0036]

[0037] in, is the entity neighborhood information representation after aggregation output by the multi-relationship graph aggregator, l is the number of layers of the aggregator, k s is the normalization factor, is the neighborhood information associated with the head entity s and relation r at timestamp t-1, is the weight matrix of relation r in the aggregator layer l, represents the weight matrix of the tail entity o in the aggregator layer l, represents the static embedding vector e of the tail entity at the lth layer of the aggregator o The hidden representation of represents the static embedding vector e of the head entity at the lth layer of the aggregator s Hidden representation of .

[0038] Furthermore, the reasoning on the temporal knowledge graph is to predict the tail entity given a head entity and a relationship; or, given a head entity, predict the relationship; or, given the global information of all facts in the historical timestamp, predict the head entity.

[0039] Furthermore, the loss function of the temporal knowledge graph is expressed as:

[0040]

[0041] Among them, G is the set of all facts, p(o t |s t ,r t ) is the probability of the tail entity o inferred from the head entity s and the relation r at timestamp t, p(r t |s t ) is the probability of obtaining relation r based on head entity s at timestamp t, p(s t ) is the credibility of the head entity s at timestamp t, and λ1 and λ2 are the importance parameters that control the importance of each loss item.

[0042] In the second aspect, the present invention provides a temporal knowledge graph reasoning system based on time weight;

[0043] The temporal knowledge graph reasoning system based on time weight includes:

[0044] The preprocessing module is configured to: obtain a time series knowledge graph to be inferred, obtain a fact sequence corresponding to a historical timestamp based on the time annotation of facts in the time series knowledge graph; and construct an entity embedding vector and a relationship embedding vector based on the fact sequence;

[0045] The timestamp attention weighting module is configured to: input the fact sequence corresponding to the historical timestamp into the timestamp attention mechanism encoder for processing, and obtain the attention weight vector matrix of the historical timestamp based on the fact sequence corresponding to the historical timestamp;

[0046] The multi-relation aggregation module is configured to: input the entity embedding vector and the relationship embedding vector into the multi-relation graph aggregator to obtain entity neighborhood information and fact aggregation information;

[0047] The update module is configured to determine the global and local representations of the fact sequence at the moment before the current timestamp through a recurrent neural network based on the entity neighborhood information, fact aggregation information, the attention weight vector matrix of the historical timestamp, and the fact sequence corresponding to the historical timestamp;

[0048] The temporal knowledge graph reasoning module is configured to: input the global representation and local representation into the fact decoder, reason on the temporal knowledge graph, and predict the entity or relationship of the current timestamp.

[0049] In a third aspect, the present invention provides an electronic device;

[0050] An electronic device includes a memory and a processor, as well as computer instructions stored in the memory and running on the processor. When the computer instructions are run by the processor, the steps of the above-mentioned temporal knowledge graph reasoning method based on time weight are completed.

[0051] In a fourth aspect, the present invention provides a computer-readable storage medium;

[0052] A computer-readable storage medium for storing computer instructions, which, when executed by a processor, completes the steps of the above-mentioned temporal knowledge graph reasoning method based on time weight.

[0053] Compared with the prior art, the present invention has the following beneficial effects:

[0054] The technical solution provided by the present invention performs attention-weighted processing on each timestamp in the time series knowledge graph, so that the model aggregates each timestamp with different attention levels, considers the impact of timestamps on quadruple facts, so as to better reason about the data in the time series knowledge graph, thereby improving the reasoning efficiency and accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The accompanying drawings, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0056] Figure 1 A schematic diagram of a process flow provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0057] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0058] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0059] In the absence of conflict, the embodiments of the present invention and the features thereof may be combined with each other.

[0060] Example 1

[0061] In the existing technology, the model gives equal attention when aggregating each timestamp and ignores the impact of timestamps on four-tuple facts, which reduces the accuracy and reliability of temporal knowledge graph reasoning; therefore, the present invention provides a temporal knowledge graph reasoning method based on time weight, which changes and weights different timestamps and considers the impact of time information on four-tuple facts.

[0062] Next, combine Figure 1 The time-series knowledge graph reasoning method based on time weight disclosed in this embodiment is described in detail. The time-series knowledge graph reasoning method based on time weight includes the following steps:

[0063] S1. Obtain the time series knowledge graph to be inferred, construct the facts of each timestamp based on the time annotations of the facts in the time series knowledge graph, and obtain the fact sequence corresponding to the historical timestamps; based on the fact sequence, construct the entity embedding vector and the relationship embedding vector.

[0064] Specifically, obtain the time series knowledge graph to be inferred, and construct the four-tuple fact G for each timestamp according to the time annotation of the facts in the time series knowledge graph. t , sort them in ascending order of timestamps, and further get the facts G of the first m timestamps (historical timestamps) t-m:t-1 .

[0065] S2. Input the fact sequence corresponding to the historical timestamp into the timestamp attention mechanism encoder for processing, and obtain the attention weight vector matrix of the historical timestamp according to the fact sequence corresponding to the historical timestamp.

[0066] To distinguish the importance of different timestamps, this example proposes a transformer-based and attention-based timestamp attention mechanism encoder, named trans_Attn. This timestamp attention mechanism encoder transforms and weights time series data, making it more accurate and reliable in inference and prediction tasks.

[0067] Specifically, the facts G of the first m timestamps t-m:t-1 Input into the timestamp attention mechanism encoder trans_Attn, trans_Attn obtains an attention weight vector matrix Att_W of the historical timestamp by learning all the historical timestamps t-m:t-1 , the attention weight vector matrix of this historical timestamp can distinguish the importance of different timestamps.

[0068] trans_Attn is learned in the following way:

[0069]

[0070]

[0071] in, Represents all factual information of historical timestamps, d n To improve generalization performance, feature processing is required. This involves transforming or combining original features to generate new features or changing their dimensions. This can enhance the expressiveness and discriminability of features while reducing the likelihood of overfitting and improving the model's classification accuracy and predictive performance.

[0072] Where Q = G t-m:t-1 *W Q ,K=h t-1 (s,r)*W K ,V=h t-1 (s,r)*W V ,

[0073] Where, h t-1 (s,r) is the local representation of the head entity s and the relation r at timestamp t-1, d k d v Represents dimension.

[0074] Finally, we get a vector matrix Att_W representing the attention weight of the historical timestamp t-m:t-1 .

[0075] S3. Input the entity embedding vector and the relationship embedding vector into the multi-relationship graph aggregator to obtain entity neighborhood information and fact aggregation information.

[0076] To obtain the neighborhood information of the head entity s and the aggregation of all facts at timestamp t-1, we introduce a multi-relation graph aggregator, which can aggregate information from multiple relations and multi-hop neighborhoods to generate richer node representations. It can capture the neighborhood information of the head entity s. The definition of the multi-relationship graph aggregator is as follows:

[0077]

[0078] in, k represents the aggregated entity neighborhood information output by the multi-relationship graph aggregator. The number of layers of the aggregator is l, and the number of layers determines the depth that the node can reach. s is the normalization factor, represents the neighborhood information associated with the head entity s and relation r at timestamp t-1, represents the weight matrix of relation r in the aggregator layer l, represents the weight matrix of the tail entity o in the aggregator layer l, represents the embedding vector e of the tail entity at the lth layer of the aggregator p The hidden representation of The embedding vector e represents the head entity at the lth layer of the aggregator s Hidden representation of .

[0079] g(G t-1 ) indicates that at time stamp t-1 all G t-1 The collection of fact information, that is, the aggregation of fact information, defines For all Perform the maximum pooling operation.

[0080] S4. Based on the entity neighborhood information, fact aggregation information, the attention weight vector matrix of the historical timestamp and the fact sequence corresponding to the historical timestamp, the global representation and local representation of the fact sequence at the moment before the current timestamp are determined through a recurrent neural network.

[0081] Specifically, based on the aggregation of all facts at timestamp t-1, the attention weight vector matrix of historical timestamps, and the global representation of all facts corresponding to historical timestamps, a recurrent neural network is used to determine the global representation of all facts at the moment before the current timestamp. Based on the neighborhood information of head entity s, the attention weight vector matrix of historical timestamps, and the local representation of head entity s and relationship r corresponding to historical timestamps, a recurrent neural network is used to determine the local representation of head entity s and relationship r at the moment before the current timestamp. Based on the neighborhood information of head entity s, the attention weight vector matrix of historical timestamps, and the local representation of head entity corresponding to historical timestamps, a recurrent neural network is used to determine the global representation of all facts at the moment t-1 before the current timestamp, the local representation of head entity s and relationship r, and the local representation of head entity s.

[0082] Global representation H t-1 It is also an important feature, H t-1 By integrating all the information in the past graph until time stamp t-1, it can better describe the dynamic changes of the entity at different time stamps and the relationship between different entities. It reflects the global preference of the facts that are about to happen at time stamp t. t-1 As a global representation, it represents all the information in the graph up to the time stamp t. t-1 (s,r) and h t-1 (s) as a local representation, h t-1 (s,r) is the vector representation of the head entity s and the relation r at timestamp t-1, h t-1 (s) is the vector representation of the head entity s at timestamp t-1, which emphasizes more on the local facts associated with each entity relationship.

[0083] Calculate the global representation H of all facts before the current timestamp t-1 , local representation h of head entity s and relation r t-1 (s,r) and the local representation h of the head entity s t-1 (s):

[0084] H t-1 =RNN 1 (g(G t-1 ),H t-2 *Att_W t-m:t-1 )

[0085] Among them, g(G t-1 ) represents the aggregation of all facts at timestamp t-1, G t-1 is the set of all four-tuple facts at timestamp t-1, Att_W t-m:t-1 is the attention vector weight matrix of the historical timestamp, H t-2 All information in the graph up to timestamp t-2 is integrated.

[0086]

[0087] Among them, g(G t-1 ) represents the aggregation of all facts at timestamp t-1, G t-1 is the set of all four-tuple facts at timestamp t-1, Att_W t-m:t-1 is the attention vector weight matrix of the historical timestamp, H t-2 All information in the graph up to the time stamp (t-2) is integrated.

[0088]

[0089] in, is the aggregation of entity neighborhood information, Aggregates the facts associated with the head entity at timestamp t-1, Att_W t-m:t-2 is the attention vector weight matrix of the historical timestamp, h t-2 (s,r) is the local representation of the head entity s and relation r at timestamp t-2.

[0090] S5. Input the global representation and local representation into the fact decoder, perform reasoning on the temporal knowledge graph, and predict the entity or relationship of the current timestamp.

[0091] Specifically, the global representation of all facts before the current timestamp in the recurrent neural network, the local representations of the head entity s and the relationship r, and the local representation of the head entity s are input into the fact decoder to reason on the temporal knowledge graph and predict the entity or relationship at the current timestamp. The fact decoder calculates and scores based on the global representation of the facts before the current timestamp, the local representations of the head entity s and the relationship r, and the local representation of the head entity s, thereby realizing reasoning on the temporal knowledge graph.

[0092] Furthermore, the task of reasoning about the tail entity o given (s, r) can be considered a multi-classification task, where each category corresponds to each tail entity o. Similarly, given the head entity s and the tail entity o, the relationship is reasoned.

[0093]

[0094]

[0095]

[0096] Among them, p(o t |s,r,G t-m:t-1 ) is the local representation of the head entity s and relation r at timestamp t-1, and the tail entity is predicted; p(r t |s,G t-m:t-1 ) is the vector representation of the known head entity s, the local representation of the head entity s at timestamp t-1, and the predicted relationship r; p(s t |G t-m:t-1 ) To predict the head entity, we only need to know the global information of all facts up to timestamp t-1 (equivalent to randomly sampling a head entity s).

[0097] The loss function is defined as follows,

[0098]

[0099] Among them, G is the set of all facts, p(o t |s t ,r t ) represents the probability of the tail entity o inferred from the head entity s and the relation r at timestamp t, p(r t |s t ) represents the probability of obtaining relation r based on head entity s at timestamp t, p(s t ) represents the credibility of the head entity s at timestamp t, and λ1 and λ2 are the importance parameters that control the importance of each loss term.

[0100] Example 2

[0101] This embodiment discloses a temporal knowledge graph reasoning system based on time weight, including:

[0102] The preprocessing module is configured to: obtain a time series knowledge graph to be inferred, obtain a fact sequence corresponding to a historical timestamp based on the time annotation of facts in the time series knowledge graph; and construct an entity embedding vector and a relationship embedding vector based on the fact sequence;

[0103] The timestamp attention weighting module is configured to: input the fact sequence corresponding to the historical timestamp into the timestamp attention mechanism encoder for processing, and obtain the attention weight vector matrix of the historical timestamp based on the fact sequence corresponding to the historical timestamp;

[0104] The multi-relation aggregation module is configured to: input the entity embedding vector and the relationship embedding vector into the multi-relation graph aggregator to obtain entity neighborhood information and fact aggregation information;

[0105] The update module is configured to determine the global and local representations of the fact sequence at the moment before the current timestamp through a recurrent neural network based on the entity neighborhood information, fact aggregation information, the attention weight vector matrix of the historical timestamp, and the fact sequence corresponding to the historical timestamp;

[0106] The temporal knowledge graph reasoning module is configured to: input the global representation and local representation into the fact decoder, reason on the temporal knowledge graph, and predict the entity or relationship of the current timestamp.

[0107] It should be noted that the above-mentioned preprocessing module, timestamp attention weighting module, multi-relation aggregation module, update module, and temporal knowledge graph reasoning module correspond to the steps in Example 1. The examples and application scenarios implemented by the above-mentioned modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned modules, as part of the system, can be executed in a computer system such as a set of computer-executable instructions.

[0108] Example 3

[0109] Embodiment 3 of the present invention provides an electronic device, including a memory and a processor, and computer instructions stored in the memory and running on the processor. When the computer instructions are executed by the processor, the steps of the above-mentioned temporal knowledge graph reasoning method based on time weight are completed.

[0110] Example 4

[0111] Embodiment 4 of the present invention provides a computer-readable storage medium for storing computer instructions. When the computer instructions are executed by a processor, the steps of the above-mentioned temporal knowledge graph reasoning method based on time weight are completed.

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

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

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

[0115] The descriptions of the various embodiments in the above embodiments have different focuses. For parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0116] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.

Claims

1. A temporal knowledge graph reasoning method based on time weight, characterized by: include: Obtain the time series knowledge graph to be inferred, and obtain the fact sequence corresponding to the historical timestamp based on the time annotation of the facts in the time series knowledge graph; Based on the fact sequence, construct entity embedding vectors and relation embedding vectors; The fact sequence corresponding to the historical timestamp is input into the timestamp attention mechanism encoder for processing, and the attention weight vector matrix of the historical timestamp is obtained according to the fact sequence corresponding to the historical timestamp; The attention weight vector matrix is ​​expressed as: in, To historically timestamp all factual information, Represents the dimension, 、 、 is a matrix; Input the entity embedding vector and the relationship embedding vector into the multi-relationship graph aggregator to obtain entity neighborhood information and fact aggregation information; The multi-graph aggregator is represented as: in, It is the entity neighborhood information representation after aggregation output by the multi-relationship graph aggregator, l is the number of layers of the aggregator, is the normalization factor, is the neighborhood information associated with the head entity s and relation r at timestamp t-1, is the weight matrix of relation r in the aggregator layer l, represents the weight matrix of the tail entity o in the aggregator layer l, Represents the static embedding vector of the tail entity at the lth layer of the aggregator The hidden representation of Represents the static embedding vector of the head entity at the lth layer of the aggregator Hidden representation of ; Based on the entity neighborhood information, fact aggregation information, the attention weight vector matrix of the historical timestamp, and the fact sequence corresponding to the historical timestamp, a recurrent neural network is used to determine the global and local representations of the fact sequence at the moment before the current timestamp. The global representation of all facts before the current timestamp is: in, is the aggregation of all facts at timestamp t-1, is the set of all four-tuple facts at timestamp t-1, is the attention vector weight matrix of the historical timestamp, All the information in the graph up to the time stamp t-2; The local representation of the head entity and relationship at the moment before the current timestamp is: in, is the aggregation of entity neighborhood information, is the aggregation of facts associated with the head entity at timestamp t-1, is the attention vector weight matrix of the historical timestamp, is the local representation of the head entity s and relation r at timestamp t-2; The local representation of the head entity and relationship at the moment before the current timestamp is: in, is the aggregation of entity neighborhood information, is the aggregation of facts associated with the head entity at timestamp t-1, is the attention vector weight matrix of the historical timestamp, is the local representation of the head entity s at timestamp (t-2); The global representation and local representation are input into the fact decoder to reason on the temporal knowledge graph and predict the entity or relationship at the current timestamp.

2. The temporal knowledge graph reasoning method based on time weight according to claim 1 is characterized in that: The method of determining the global representation and local representation of the fact sequence at the moment before the current timestamp by using a recurrent neural network based on the entity neighborhood information, the attention weight vector matrix of the historical timestamp, and the fact sequence corresponding to the historical timestamp includes: Based on the fact aggregation information at the moment before the current timestamp, the attention weight vector matrix of the historical timestamps, and the global representation of all facts corresponding to the historical timestamps, a recurrent neural network is used to determine the global representation of all facts at the moment before the current timestamp. Based on the entity neighborhood information, the attention weight vector matrix of the historical timestamps, and the local representation of the entity and relationship at the moment before the current timestamp, the local representation of the head entity and relationship at the moment before the current timestamp is updated through a recurrent neural network; According to the entity neighborhood information, the attention weight vector matrix of the historical timestamps and the local representation of the head entity at the moment before the current timestamp, the local representation of the entity at the moment before the current timestamp is determined through a recurrent neural network.

3. The temporal knowledge graph reasoning method based on time weight according to claim 1 is characterized in that: The reasoning on the temporal knowledge graph is to predict the tail entity given a head entity and a relationship; or, given a head entity, predict the relationship; or, given the global information of all facts in the historical timestamp, predict the head entity.

4. The temporal knowledge graph reasoning method based on time weight according to claim 1 is characterized in that: The loss function of the temporal knowledge graph is expressed as: Where G is the set of all facts, is the probability of the tail entity o inferred from the head entity s and relation r at timestamp t, is the probability of obtaining relation r based on head entity s at timestamp t, is the credibility of the header entity s at timestamp t, and is the importance parameter that controls the importance of each loss term.

5. A temporal knowledge graph reasoning system based on time weight, characterized by: include: The preprocessing module is configured to: obtain a time series knowledge graph to be inferred, and obtain a fact sequence corresponding to a historical timestamp based on the time annotation of facts in the time series knowledge graph; Based on the fact sequence, construct entity embedding vectors and relation embedding vectors; The timestamp attention weighting module is configured to: input the fact sequence corresponding to the historical timestamp into the timestamp attention mechanism encoder for processing, and obtain the attention weight vector matrix of the historical timestamp based on the fact sequence corresponding to the historical timestamp; The attention weight vector matrix is ​​expressed as: in, To historically timestamp all factual information, Represents the dimension, 、 、 is a matrix; The multi-relation aggregation module is configured to: input the entity embedding vector and the relationship embedding vector into the multi-relation graph aggregator to obtain entity neighborhood information and fact aggregation information; The multi-graph aggregator is represented as: in, It is the entity neighborhood information representation after aggregation output by the multi-relationship graph aggregator, l is the number of layers of the aggregator, is the normalization factor, is the neighborhood information associated with the head entity s and relation r at timestamp t-1, is the weight matrix of relation r in the aggregator layer l, represents the weight matrix of the tail entity o in the aggregator layer l, Represents the static embedding vector of the tail entity at the lth layer of the aggregator The hidden representation of Represents the static embedding vector of the head entity at the lth layer of the aggregator Hidden representation of ; The update module is configured to determine the global and local representations of the fact sequence at the moment before the current timestamp through a recurrent neural network based on the entity neighborhood information, fact aggregation information, the attention weight vector matrix of the historical timestamp, and the fact sequence corresponding to the historical timestamp; The global representation of all facts before the current timestamp is: in, is the aggregation of all facts at timestamp t-1, is the set of all four-tuple facts at timestamp t-1, is the attention vector weight matrix of the historical timestamp, All the information in the graph up to the time stamp t-2; The local representation of the head entity and relationship at the moment before the current timestamp is: in, is the aggregation of entity neighborhood information, is the aggregation of facts associated with the head entity at timestamp t-1, is the attention vector weight matrix of the historical timestamp, is the local representation of the head entity s and relation r at timestamp t-2; The local representation of the head entity and relationship at the moment before the current timestamp is: in, is the aggregation of entity neighborhood information, is the aggregation of facts associated with the head entity at timestamp t-1, is the attention vector weight matrix of the historical timestamp, is the local representation of the head entity s at timestamp (t-2); The temporal knowledge graph reasoning module is configured to: input the global representation and local representation into the fact decoder, reason on the temporal knowledge graph, and predict the entity or relationship of the current timestamp.

6. An electronic device, characterized in that: The method comprises a memory and a processor, and computer instructions stored in the memory and executed on the processor, wherein the steps described in any one of claims 1 to 4 are completed when the computer instructions are executed by the processor.

7. A computer-readable storage medium, characterized in that Used to store computer instructions, which, when executed by a processor, complete the steps described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Time sequence knowledge graph representation learning method based on co-evolution modeling

    CN112860918A

  • Time sequence knowledge graph reasoning method, device and equipment based on attention mechanism

    CN114860854A