A time-aware knowledge graph reasoning method based on attention network
By introducing attention network, graph convolution network, attention mechanism, time gate mechanism and gated loop unit in timing knowledge graph inference, the problem of insufficient processing capabilities on dynamic changes in timing knowledge graphs and the impact of multiple relationship types in the existing technology is solved, and more efficient and accurate future event reasoning is achieved.
Patent Information
- Application Number
- CN202411458578.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-10-18
AI Technical Summary
When using the timing knowledge graph for future event inference, the prior art is difficult to effectively capture the dynamic changes of events, fail to accurately reflect the impact of different relationship types on the inference results, and has limited ability to handle concurrent events, resulting in low inference accuracy and insufficient generalization ability.
The timing-aware knowledge graph inference method based on attention network is adopted, and the connection between the target entity and the higher-order neighbor entity is established through the graph convolution network and attention mechanism, and the impact of different relationship types on the target entity is distinguished, and a time gate mechanism and gated loop unit are introduced to dynamically update the entity and relationship embedding.
It significantly improves the accuracy and efficiency of reasoning, improves the processing ability of complex timing knowledge graphs, realizes accurate prediction of future events and their relationships, and improves the stability and generalization capabilities of the model.
Smart Images

Figure CN119415705B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence knowledge reasoning technology, and in particular to a time-series-aware knowledge graph reasoning method based on an attention network. Background Art
[0002] Knowledge graphs are a series of various graphs that display the process and structural relationships of knowledge development. Currently, traditional methods for reasoning about future events using temporal knowledge graphs rely mainly on historical data modeling and rule-based reasoning, but these methods have many shortcomings. First, traditional reasoning models are usually based on static knowledge graphs and cannot effectively capture the dynamic changes of events. Second, existing models lack consideration of the differences between different types of relationships and fail to accurately reflect the impact of different relationships on the reasoning results. In addition, existing technologies have limited ability to handle concurrent events, making it difficult to model the interdependence between multiple events occurring at the same time point, resulting in low reasoning accuracy and insufficient generalization capabilities. Summary of the Invention
[0003] The purpose of this invention is to provide a time-series-aware knowledge graph reasoning method based on attention network, to improve the reasoning accuracy and efficiency, to improve the processing ability of complex time-series knowledge graphs, and to achieve accurate prediction of future events and their relationships.
[0004] To achieve the above objectives, the present invention provides a time-series-aware knowledge graph reasoning method based on an attention network, comprising the following steps:
[0005] S1. Input historical event time sequence aware knowledge graph and attribute time sequence aware knowledge graph;
[0006] S2. Use a graph convolutional network to perform multi-layer propagation on each entity in the historical event time sequence perception knowledge graph. By aggregating neighbor entities layer by layer, the connection between the target entity and high-order neighbor entities is established to enrich the entity embedding representation;
[0007] S3. Introduce the attention mechanism to distinguish the impact of different relationship types on the target entity;
[0008] S4. Use a graph convolutional network without self-loops to obtain the attribute embedding of each entity in the attribute temporal-aware knowledge graph to enrich the entity embedding representation;
[0009] S5. Introduce a time gate mechanism to filter the historical information embedded in the entity time series in steps S2 and S4 through adaptive gating;
[0010] S6. Use gated recurrent units to process relationships at different timestamps, capture dynamic changes in time series, and adaptively update the relationship embedding matrix through the memory and forgetting mechanism of historical information;
[0011] S7. Based on the entity and relationship embedding representations obtained after processing in steps S5 and S6, entity prediction and relationship prediction are realized.
[0012] Preferably, the knowledge graph in step S1 uses quadruple as the basic unit, including subject, relationship, object and time. The historical event time sequence-aware knowledge graph represents entities and relationships, and the attribute time sequence-aware knowledge graph contains static characteristics of entities, including categories and attribute values.
[0013] Preferably, in step S2, a connection is established between the target entity and the high-order neighbor entity, and the formula is:
[0014]
[0015] Where, represents the embedding of the head entity at layer l at time T, represents the embedding of the tail entity at layer l at time T, e r,T represents the embedding of the relationship at layer l at time T, Indicates the translation of the head entity h to the tail entity through the relationship r, h a represents the head entity in the attribute temporal-aware knowledge graph, t a represents the head entity and tail entity in the attribute temporal-aware knowledge graph, ε a A collection of entities representing an attribute-time-aware knowledge graph.
[0016] Preferably, step S3 includes: using To measure the impact of different relationship types on translation, we use dot product attention to learn the weights of different relationships:
[0017]
[0018] Where, Represents the influence of different relationship types when the head entity h is translated to the tail entity through the relationship r.
[0019] Preferably, in step S4, a graph convolutional network without self-loop is used to obtain the attribute embedding of each entity in the attribute temporal-aware knowledge graph, and the formula is:
[0020]
[0021] Where, Represent the embedding of the head entity and the tail entity at time T, h a represents the head entity in the attribute temporal-aware knowledge graph, t a represents the head entity and tail entity in the attribute temporal-aware knowledge graph, ε a A collection of entities representing an attribute-time-aware knowledge graph.
[0022] Preferably, in step S5, a time gate mechanism is introduced to filter the historical information embedded in the entity time series in steps S2 and S4 through adaptive gating, including:
[0023] First, consider the historical events carried by the knowledge graph series at different times and use the time gate to optimize the entity embedding. The formula is:
[0024]
[0025] U T =σ(WH T-1 +b);
[0026] Where H T represents the entity embedding matrix at time T, H represents the entity embedding matrix obtained by modeling the historical event time series perception knowledge graph through the graph neural network at time T, T-1 Represents the entity embedding matrix obtained by modeling the historical event time series perception knowledge graph through the graph neural network at time T-1; represents the entity embedding matrix obtained from the attribute temporal perception knowledge graph at time T, U T represents the time gate factor;
[0027] Then consider the impact of changes in its attributes over time on the reasoning effect, the formula is:
[0028]
[0029] U T =σ(WH T-1 +b);
[0030] Where, H represents the entity embedding matrix obtained by graph neural network modeling attribute temporal perception knowledge graph at time T, T-1 Represents the entity embedding matrix at time T-1.
[0031] Preferably, in step S6, a gated recurrent unit is used to process the relationships at different timestamps, including an average pooling operation and a GRU component update, and the formula is:
[0032]
[0033] Where, Represents the embedding of relation r in the relation matrix R at time T, Represents the vector connection operation. If no corresponding event occurs at time T, then By all Composition, RT represents the relation embedding matrix.
[0034] Preferably, the entity prediction in step S7 represents the entities that may participate in an event at a predicted future time point, and the relationship prediction is used to infer the possible relationships between entities;
[0035] The probability vector for all entities is:
[0036] P(h / t|t / h,r,H T ,R T )=σ(H T ConvTransE(e r,T / e h,T ,e r,T ));
[0037] The probability vectors of all relationships are:
[0038] P(r|h,t,H T ,R T )=σ(R T ConvTransE(e h,T ,e t,T ));
[0039] In the formula, σ represents the activation function, e h,T and e t,T Respectively represent H T The embedding of h and t, e r,T Represents R T In the embedding of r, H represents the entity embedding matrix, R represents the relationship embedding matrix, and the entity and relationship prediction tasks are regarded as multi-label learning. and Represent the label vectors of the two tasks at time T, for events and relationships that actually occurred, and The value of is 1, otherwise it is 0;
[0040] The entity prediction loss function is:
[0041]
[0042] The relationship prediction loss function is
[0043]
[0044] The total objective loss function is:
[0045] L=L e +L r ;
[0046] Where, L erepresents the entity prediction loss function, L r represents the relationship prediction loss function, L represents the total loss function, and are respectively represented in vector and The i-th element in P i (h / t|t / h,r,H T ,R T ) and P i (r|h,t,H T ,R T ) represent the probabilities of entity i and relation i respectively, and V represents the total number of entities.
[0047] Therefore, the present invention adopts the above-mentioned time-series-aware knowledge graph reasoning method based on attention network, which has the following beneficial effects:
[0048] (1) The introduction of graph convolutional networks and attention mechanisms fully utilizes high-order neighbor entities and multiple relationship types, significantly improving the accuracy and efficiency of reasoning;
[0049] (2) The introduction of the time gate mechanism can effectively cope with changes in time series, prevent the convergence problem of entity embedding at different timestamps, and improve the stability of temporal reasoning. At the same time, the introduction of the time gate mechanism solves the problem of difficulty in modeling the interdependence between multiple events occurring at the same time point;
[0050] (3) By utilizing a graph convolutional network without self-loops and a gated recurrent unit component, the expressive power of entity and relation embeddings is enhanced, improving the generalization ability of the model.
[0051] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A method block diagram of an embodiment of the present invention;
[0053] Figure 2 This is an overall framework diagram of an embodiment of the present invention. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0055] Example
[0056] Reference Figure 1-Figure 2 The present invention provides a time-series-aware knowledge graph reasoning method based on an attention network, comprising the following steps:
[0057] S1. Input historical event time series-aware knowledge graph and attribute time series-aware knowledge graph.
[0058] The knowledge graph uses quadruple as the basic unit, including subject, relationship, object and time. The historical event time-series-aware knowledge graph represents entities and relationships, and the attribute time-series-aware knowledge graph contains the static characteristics of entities, including categories and attribute values. By combining these two different information sources, the model can more comprehensively understand and model entities and the dynamic relationships between them. The data sources of the two knowledge graphs are both from authoritative public datasets in related fields, and they are time-based temporal knowledge graphs. These temporal knowledge graphs include the Integrated Crisis Early Warning System (ICEWS18, ICEWS14), and the Global Database of Events, Language and Tone (GDELT). These datasets are widely used in time-series event prediction and dynamic relationship modeling, covering a large number of events and corresponding time information worldwide.
[0059] S2. A graph convolutional network (GCN) performs multi-layer propagation on each entity in the historical event temporal perception knowledge graph. By aggregating neighboring entities layer by layer, the target entity's field of view is gradually expanded, and connections are established between the target entity and its higher-order neighboring entities to enrich the entity's embedded representation. This connection not only enhances the entity's local representation capabilities but also helps the model capture the underlying structural relationships and complex dependencies in the knowledge graph.
[0060] In this embodiment, the relationship between the target entity and the high-order neighbor entity is established using the following formula:
[0061]
[0062] Where, represents the embedding of the head entity at layer l at time T, represents the embedding of the tail entity at layer l at time T, e r,T represents the embedding of the relationship at layer l at time T, represents the translation of the head entity h to the tail entity through the relationship r, α represents the impact of different relationship types on the translation of the head entity h to the tail entity through the relationship r, represents the weight of the first layer in the neural network, and ε represents the entity set in the knowledge graph.
[0063] S3. Introducing an attention mechanism to distinguish the impact of different relationship types on the target entity. The attention mechanism dynamically adjusts the weight of each relationship's influence on the target entity, ensuring that key relationships are highlighted and unimportant relationships are downplayed during information dissemination. This step ensures that the model better captures complex and diverse relationships between entities, improving reasoning accuracy.
[0064] In this embodiment, using To measure the impact of different relationship types on translation, we use dot product attention to learn the weights of different relationships:
[0065]
[0066] Where, Represents the influence of different relationship types when the head entity h is translated to the tail entity through the relationship r.
[0067] S4. A graph convolutional network with no self-loops is used to obtain attribute embeddings for each entity in the attribute-time-aware knowledge graph, enriching the entity's embedding representation. By obtaining attribute information for each entity, such as category and status, a more semantically layered embedding is generated to enrich the entity's embedding representation. This avoids excessive information propagation introduced by self-loops and ensures that the model effectively captures attribute features without losing detail.
[0068] In this embodiment, a graph convolutional network without self-loop is used to obtain the attribute embedding of each entity in the attribute time-series-aware knowledge graph. The formula is:
[0069]
[0070] Where, Represent the embedding of the head entity and the tail entity at time T, h a represents the head entity in the attribute temporal-aware knowledge graph, t a represents the head entity and tail entity in the attribute temporal-aware knowledge graph, ε a A collection of entities representing an attribute-time-aware knowledge graph.
[0071] S5. Introducing the TimeGate mechanism, this adaptively gates the historical information embedded in the entity time series in steps S2 and S4. This prevents the time-aware attribute-aware knowledge graph from stabilizing over a short period of time, leading to overly similar entity embeddings at different timestamps. This mechanism also effectively mitigates the vanishing gradient problem caused by too many layers in graph neural networks, improving model stability.
[0072] In this embodiment, a time gate mechanism is introduced to filter the historical information embedded in the entity time series in steps S2 and S4 through adaptive gating, including:
[0073] First, consider the historical events carried by the knowledge graph series at different times and use the time gate to optimize the entity embedding. The formula is:
[0074]
[0075] U T =σ(WH T-1 +b);
[0076] Where H T represents the entity embedding matrix at time T, H represents the entity embedding matrix obtained by modeling the historical event time series perception knowledge graph through the graph neural network at time T, T-1 Represents the entity embedding matrix obtained by modeling the historical event time series perception knowledge graph through the graph neural network at time T-1; represents the entity embedding matrix obtained from the attribute temporal perception knowledge graph at time T, U T Represents the time gate factor. H T Depend on H T-1 and After the time gate, we will jointly decide how to decide. T control.
[0077] Then consider the impact of changes in its attributes over time on the reasoning effect, the formula is:
[0078]
[0079] U T =σ(WH T-1 +b);
[0080] Where, H represents the entity embedding matrix obtained by graph neural network modeling attribute temporal perception knowledge graph at time T, T-1 Represents the entity embedding matrix at time T-1. Depend on and H T-1 After the time gate, we will jointly decide how to decide. T control.
[0081] S6. A gated recurrent unit is used to process relations at different timestamps to capture dynamic changes in the time series. The relationship embedding matrix is adaptively updated through the memory and forgetting mechanism of historical information to ensure that the representation of the relationship at each timestamp can reflect the actual temporal dependency and relationship differences.
[0082] In this embodiment, a gated recurrent unit is used to process the relationships at different timestamps, including average pooling operations and GRU component updates. The formula is:
[0083]
[0084] Where, Represents the embedding of relation r in the relation matrix R at time T, Represents the vector connection operation. If no corresponding event occurs at time T, then By all Composition, R T represents the relation embedding matrix.
[0085] S7. Based on the entity and relationship embedding representations obtained after processing in steps S5 and S6, entity prediction and relationship prediction are realized.
[0086] Entity prediction refers to the entities that may be involved in an event at a predicted future time point, and relationship prediction is used to infer the possible relationships between entities;
[0087] The probability vector for all entities is:
[0088] P(h / t|t / h,r,H T ,R T )=σ(H T ConvTransE(e r,T / e h,T ,e r,T ));
[0089] The probability vectors of all relationships are:
[0090] P(r|h,t,H T ,R T )=σ(R T ConvTransE(e h,T ,e t,T ));
[0091] In the formula, σ represents the activation function, eh,T and e t,T Respectively represent H T The embedding of h and t, e r,T Represents R T In the embedding of r, H represents the entity embedding matrix, R represents the relationship embedding matrix, and the entity and relationship prediction tasks are regarded as multi-label learning. and Represent the label vectors of the two tasks at time T, for events and relationships that actually occurred, and The value of is 1, otherwise it is 0;
[0092] The entity prediction loss function is:
[0093]
[0094] The relationship prediction loss function is
[0095]
[0096] The total objective loss function is:
[0097] L=L e +L r ;
[0098] Where, L e represents the entity prediction loss function, L r represents the relationship prediction loss function, L represents the total loss function, and are respectively represented in vector and The i-th element in P i (h / t|t / h,r,H T ,R T ) and P i (r|h,t,H T ,R T ) represent the probabilities of entity i and relation i respectively, and V represents the total number of entities.
[0099] In order to verify the effectiveness of the proposed method, the R-GCN model and the RE-GCN model were selected as comparison models. They were tested on three datasets: ICEWS18, ICEWS18, and GDELT. The mean reciprocal (MRR) was used for comparison. The entity prediction results and the relationship prediction results are shown in Table 1 and Table 2, respectively.
[0100] Table 1 Entity prediction results
[0101]
[0102] Table 2 Relationship prediction results
[0103]
[0104] It can be seen from the experimental results table that the average inverse of the indicators of the method of the present invention are higher than those of the R-GCN model and the RE-GCN model. It can be concluded that using the relational attention network to differentially capture the structural information and high-order information of the knowledge graph, dynamically update attributes, and recursively capture historical events can help improve the prediction effect.
[0105] Therefore, the present invention adopts the above-mentioned time-aware knowledge graph reasoning method based on attention network, which can differentially capture the structural and high-order connections of knowledge graphs through the attention mechanism, recursively propagate embeddings from the entity's neighbors to optimize entities, and dynamically model historical knowledge graph series through time gates and gated recurrent units to capture all historical events and update relationships. In addition, the model also enriches entity representation by dynamically updating entity attributes, thereby realizing simultaneous reasoning of entities and their relationships.
[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit the same. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solutions of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. A time-series-aware knowledge graph reasoning method based on attention network, characterized in that the steps include: S1. Input the historical event time sequence aware knowledge graph and the attribute time sequence aware knowledge graph. The knowledge graph uses quadruple as the basic unit, including subject, relationship, object and time. The historical event time sequence aware knowledge graph represents entities and relationships, and the attribute time sequence aware knowledge graph contains the static characteristics of entities, including categories and attribute values. S2. Use graph convolutional networks to perform multi-layer propagation on each entity in the historical event time-series-aware knowledge graph, and establish connections between target entities and high-order neighbor entities by aggregating neighbor entities layer by layer to enrich the embedding representation of entities. Establish the connection between the target entity and the high-order neighbor entity, the formula is: ; In the formula, Indicates at time T The embedding of the moment head entity at layer l, Indicates at time T The embedding of the moment-end entity at layer l, Indicates at time T The embedding of the moment relation at layer l, Represents the header entity h Through the relationship r Translation of the end entity, Represents the peer entity h Through the relationship r The impact of different relationship types on the translation of the end entity, represents the weights of the first layer in the neural network, Represents a set of entities in a knowledge graph; S3, introduce the attention mechanism to distinguish the impact of different relationship types on the target entity; Among them, using To measure the impact of different relationship types on translation, we use dot product attention to learn the weights of different relationships: ; In the formula, Represents the header entity h Through the relationship r The impact of different relationship types on the translation of the end entity; S4. Use a layer of graph convolutional network without self-loop to obtain the embedding of attributes of each entity in the attribute time-series-aware knowledge graph to enrich the embedding representation of the entity. The formula is: ; In the formula, , Respectively represent the time T The embedding of the head entity and the tail entity at the moment, represents the head entity in the attribute temporal-aware knowledge graph, Represents the head entity and tail entity in the attribute temporal-aware knowledge graph, A collection of entities representing the attribute-time-aware knowledge graph; S5. Introduce a time gate mechanism to filter the historical information embedded in the entity time series in steps S2 and S4 through adaptive gating, specifically including: First, consider the historical events carried by the knowledge graph series at different times, and use the time gate to optimize the entity embedding. The formula is: ; ; In the formula, express T The entity embedding matrix at time t, Indicated by T The entity embedding matrix obtained by the graph neural network modeling the historical event time series perception knowledge graph, express T -1 The entity embedding matrix obtained by modeling the historical event time series perception knowledge graph through the graph neural network at time; express T The entity embedding matrix obtained from the moment attribute time series aware knowledge graph, represents the time gate factor; Then consider the impact of changes in its attributes over time on the reasoning effect, the formula is: ; ; In the formula, express T The entity embedding matrix obtained by modeling the attribute time-aware knowledge graph through the graph neural network at each moment, express T -1 entity embedding matrix; S6. Use gated recurrent units to process relations at different timestamps, capture dynamic changes in time series, and adaptively update the relation embedding matrix through the memory and forgetting mechanism of historical information; S7. Based on the entity and relationship embedding representations obtained after processing in step S5 and step S6, entity prediction and relationship prediction are implemented.
2. According to claim 1, a time-series-aware knowledge graph reasoning method based on an attention network is characterized in that: In step S6, a gated recurrent unit is used to process the relationships at different timestamps, including average pooling operations and GRU component updates. The formula is: ; ; In the formula, Representing relationships r exist T Time in the relationship matrix R The embedding in Represents the concatenation operation of vectors. T If no corresponding event occurs at the time, , By all composition, Represents the relation embedding matrix.
3. According to claim 2, a time-series-aware knowledge graph reasoning method based on an attention network is characterized in that: In step S7, entity prediction represents entities that may be involved in an event at a predicted future time point, and relationship prediction is used to infer possible relationships between entities; The probability vector for all entities is: ; All relationship probability vectors are: ; In the formula, represents the activation function, and Respectively middle h and t The embedding express middle r The embedding H represents the entity embedding matrix, R Represents the relation embedding matrix and regards the entity and relation prediction tasks as multi-label learning. and Respectively expressed in T The label vectors of the two tasks at the moment, for events and relationships that actually occurred, and The value of is 1, otherwise it is 0; The entity prediction loss function is: ; The relationship prediction loss function is ; The total objective loss function is: ; In the formula, represents the entity prediction loss function, represents the relationship prediction loss function, L represents the total loss function, and are respectively expressed in vector and The Number element, and Representing entities and relationship The probability of V Indicates the total number of entities.
Citation Information
Patent Citations
Implicit discourse relation recognition method based on knowledge-enhanced attention neural network
CN110888980A
Time sequence knowledge graph dynamic completion method, medium and terminal
CN117609507A