Time sequence knowledge graph reasoning method combined with external description information
By combining the temporal knowledge graph reasoning method with external description information and utilizing the Transformer encoder and self-attention mechanism, the problem of insufficient entity feature extraction in existing methods is solved, accurate modeling of entity relationships and understanding of dynamic changes are achieved, and the reasoning accuracy and efficiency of temporal knowledge graphs are improved.
Patent Information
- Application Number
- CN202510809474.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-17
- Publication Date
- 2025-09-19
AI Technical Summary
Existing temporal knowledge graph reasoning methods fail to fully utilize the entity's descriptive text, attribute information, category labels and other multi-dimensional additional information, resulting in an incomplete understanding of the entity's characteristics and affecting the performance of complex reasoning tasks.
The Transformer encoder and attention mechanism are used to extract the semantic features of entities, combined with topological structure enhancement, and the self-attention mechanism is used to iteratively integrate historical information within the time window to generate an entity temporal embedding representation that comprehensively reflects long-term and short-term temporal features.
It significantly enhances the model's ability to understand and predict the dynamic changes of entities and their relationships, and improves the accuracy and efficiency of temporal knowledge graph reasoning.
Smart Images

Figure CN120671840A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of constructing knowledge graphs, and specifically relates to a temporal knowledge graph reasoning method combined with external description information. Background Art
[0002] Temporal knowledge graphs introduce a time dimension based on traditional knowledge graphs. Each fact or relationship is accompanied by a timestamp or time period, indicating the time point or duration of the information. As a result, temporal knowledge graphs can capture and express information that changes over time, enabling queries on historical data, trend analysis, and future predictions. News event perception and prediction systems based on temporal knowledge graph reasoning integrate information from the time dimension, enabling real-time perception and prediction of events. This provides important technical support for hot news event analysis, social governance, and risk warning. Therefore, research on reasoning methods based on temporal knowledge graphs is of great value.
[0003] Most real-world temporal knowledge graphs contain not only the structural information of entity relationships but also other external knowledge. For example, for the quadruple <Zhang San, Travel, Beijing, 2023>, the graph also includes descriptions of Zhang San and Beijing, as well as other attribute information. This external knowledge plays a crucial role in improving the model's understanding of graph features. However, current temporal knowledge graph reasoning methods are mostly limited to the structural information of the triples themselves, failing to fully utilize the entity's descriptive text, attribute information, category labels, and other multi-faceted additional information. This limits the model's comprehensive understanding and representation of entity features, resulting in poor performance in these complex reasoning tasks. Summary of the Invention
[0004] In response to the above-mentioned deficiencies in the prior art, the present invention provides a temporal knowledge graph reasoning method combined with external description information to solve the problems of insufficient entity semantic feature extraction and inaccurate temporal feature modeling in existing methods.
[0005] In order to achieve the above-mentioned purpose, the technical solution adopted by the present invention is: a temporal knowledge graph reasoning method combined with external description information, comprising the following steps: S1. Obtain text and convert it into a feature vector sequence that integrates semantic and position information; S2. Input the feature vector sequence into the Transformer encoder to extract the word description information feature vector; S3. Based on the pre-trained head entity embedding vector and relationship embedding vector obtained by TransE knowledge representation learning, the head entity embedding vector, relationship embedding vector and word description information feature vector are fused to obtain the vector representation of the target entity; S4, generate a graph representation on each time slice through multi-source information fusion and topological structure enhancement; S5. Based on the graph representation at each time slice, the self-attention mechanism is used to iteratively and selectively integrate the historical information sequence based on the graph representation of the previous moment within the time window to complete the temporal knowledge graph reasoning.
[0006] Further: S1 includes the following sub-steps: S11. Input the text into the Word2Vec model and map the word sequence in the text into a word embedding matrix, including the word embedding vector of each word; S12. Randomly generate a trainable positional encoding matrix through the Word2Vec model, and extract the corresponding positional encoding vector according to the position index of the word; S13. Concatenate the word embedding vector of each word in the text with the position encoding vector to generate a feature vector sequence that integrates semantic and position information.
[0007] Further: S2 includes the following sub-steps: S21, input the feature vector sequence into the Transformer encoder; S22, through the multi-head self-attention mechanism and feedforward network processing sequence within the Transformer encoder, capturing long-range dependencies and contextual information between words; S23. Output the context-aware representation of each word in the feature vector sequence through the Transformer encoder to generate a word description information feature vector.
[0008] Furthermore, in S3, the method of fusing the header entity embedding vector, the relationship embedding vector, and the word description information feature vector includes the following steps: S31. For a given head entity embedding vector and relationship embedding vector, calculate the semantic relevance between the word description information feature vector of each word in the text description and the head entity and relationship pair to obtain the initial attention weight; S32. Use the relationship embedding vector to modify the initial attention weight based on the relationship, so that the weight can better reflect the part of the text related to the current relationship, and generate a modified attention weight. S33. Normalize the corrected attention weights, perform weighted summation on the word description information feature vectors using the normalized attention weights, and obtain a vector representation of the target entity.
[0009] Further: S4 includes the following sub-steps: S41. Initialize the entity and its neighborhood representation through pre-trained embedding, use relationship-aware aggregation to update the structural features, and perform weighted fusion with the vector representation of the target entity to generate the semantic feature representation of the entity; S42. Input the entity and its neighborhood subgraph at time t into GAT, learn the high-order structural information of the entity through the aggregation mechanism of GAT, and obtain the topological structure embedding representation of the entity; S43. Design a dynamic gating mechanism to adaptively fuse the semantic feature representation of the entity with the topological structure embedding representation to generate a graph representation at each time slice.
[0010] Further: S5 includes the following steps: S51. Take the atlas representation before time t as the historical atlas representation, and for the sequence of historical atlas representations within a time window, use the historical atlas representation at time t-1 as a benchmark to calculate the historical attention weights of the historical atlas representations compared with the historical atlas representations at other times in the sequence. S52. Perform weighted summation on the sequence represented by the historical graph according to the historical attention weight to generate a vector representation of the aggregated historical information; S53. Fuse the historical graph representation at time t-1 with the vector representation of aggregated historical information to generate a temporal embedding representation of the entity and complete temporal knowledge graph reasoning.
[0011] The beneficial effects of the present invention are as follows: the present invention provides a temporal knowledge graph reasoning method combined with external description information, which has the following effects compared with the existing temporal knowledge graph reasoning method: (1) Using the Transformer encoder and attention mechanism, we extract entity- and relationship-specific semantic features from the text description of the entity, solving the problem of insufficient entity semantic feature extraction in existing methods.
[0012] (2) The topological structure characteristics of the entity are obtained by constructing a neighborhood subgraph at time t, reflecting its position and connection pattern in the network, and enhancing the understanding of the entity structure information.
[0013] (3) After obtaining the graph representation at each time slice, the self-attention mechanism is iteratively applied to generate a historical attention weight for each historical graph representation within a set time window, and perform weighted aggregation on the historical graph representations based on these weights to generate a temporal embedding representation of the entity that can fully reflect the long-term and short-term temporal characteristics, thereby solving the problem of inaccurate temporal feature modeling in existing methods.
[0014] Through the above improvements, the present invention integrates entity description, topological structure and temporal information, significantly enhancing the model's ability to understand and predict the dynamic changes of entities and their relationships, and effectively improving the accuracy and efficiency of temporal knowledge graph reasoning. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 This is a flow chart of a temporal knowledge graph reasoning method combining external description information according to the present invention. DETAILED DESCRIPTION
[0016] The specific embodiments of the present invention are described below to facilitate understanding of the present invention by those skilled in the art. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the appended claims, these changes are obvious, and all inventions and creations utilizing the concepts of the present invention are protected.
[0017] like Figure 1 As shown, in one embodiment of the present invention, a temporal knowledge graph reasoning method combined with external description information includes the following steps: S1. Obtain text and convert it into a feature vector sequence that integrates semantic and position information; S2. Input the feature vector sequence into the Transformer encoder to extract the word description information feature vector; S3. Based on the pre-trained head entity embedding vector and relationship embedding vector obtained by TransE knowledge representation learning, the head entity embedding vector, relationship embedding vector and word description information feature vector are fused to obtain the vector representation of the target entity; S4, generate a graph representation on each time slice through multi-source information fusion and topological structure enhancement; S5. Based on the graph representation at each time slice, the self-attention mechanism is used to iteratively and selectively integrate the historical information sequence based on the graph representation of the previous moment within the time window to complete the temporal knowledge graph reasoning.
[0018] S1 includes the following sub-steps: S11. Input the text into the Word2Vec model and map the word sequence in the text into a word embedding matrix, including the word embedding vector of each word; S12. Randomly generate a trainable positional encoding matrix through the Word2Vec model, and extract the corresponding positional encoding vector according to the position index of the word; S13. Concatenate the word embedding vector of each word in the text with the position encoding vector to generate a feature vector sequence that integrates semantic and position information.
[0019] In this embodiment, word embedding technology is the core of natural language processing tasks. It preserves semantic relationships by converting vocabulary into numerical vectors. Therefore, the present invention uses the Word2Vec model to generate word embedding matrices. To capture the sequential information in the sequence, the model randomly generates a trainable positional encoding matrix, concatenates the word embedding vector of each word with the positional encoding vector, and generates a feature vector sequence that integrates semantic and positional information as the input of the Transformer layer. This process ensures that the model can simultaneously understand the semantics of words and their positional relationships in the sentence.
[0020] S2 includes the following sub-steps: S21, input the feature vector sequence into the Transformer encoder; S22, through the multi-head self-attention mechanism and feedforward network processing sequence within the Transformer encoder, capturing long-range dependencies and contextual information between words; S23. Output the context-aware representation of each word in the feature vector sequence through the Transformer encoder to generate a word description information feature vector.
[0021] In this embodiment, the Transformer encoder dynamically captures long-distance dependencies in text through a self-attention mechanism and a multi-layer stacking structure. Each processing unit contains two major modules: a multi-head attention mechanism and a feedforward neural network, and normalization is used to ensure training stability.
[0022] In S3, the method of fusing the header entity embedding vector, the relationship embedding vector, and the word description information feature vector includes the following steps: S31. For a given head entity embedding vector and relationship embedding vector, calculate the semantic relevance between the word description information feature vector of each word in the text description and the head entity and relationship pair to obtain the initial attention weight; S32. Use the relationship embedding vector to modify the initial attention weight based on the relationship, so that the weight can better reflect the part of the text related to the current relationship, and generate a modified attention weight. S33. Normalize the corrected attention weights, perform weighted summation on the word description information feature vectors using the normalized attention weights, and obtain a vector representation of the target entity.
[0023] Among them, the vector representation of the target entity aggregates the most relevant information of the current head entity and relation in the text description, which is used to characterize the potential target entity characteristics.
[0024] In this embodiment, in order to capture the importance of different words in the description information, this step adopts a method called relational attention, which generates a global representation of the description information by calculating the attention weight of each word. This process ensures that the model can dynamically adjust the importance of words in the description information according to specific relationships and generate a more accurate vector representation of the target entity.
[0025] S4 includes the following sub-steps: S41. Initialize the entity and its neighborhood representation through pre-trained embedding, use relationship-aware aggregation to update the structural features, and perform weighted fusion with the vector representation of the target entity to generate the semantic feature representation of the entity; S42. Input the entity and its neighborhood subgraph at time t into GAT (Multi-layer Graph Attention Network), learn the high-order structural information of the entity through the aggregation mechanism of GAT, and obtain the topological structure embedding representation of the entity; S43. Design a dynamic gating mechanism to adaptively fuse the semantic feature representation of the entity with the topological structure embedding representation to generate a graph representation at each time slice.
[0026] In this embodiment, the present invention generates a comprehensive and accurate entity feature representation through multi-source information fusion and topological structure enhancement. In order to further capture high-order structural information, GAT is introduced, and neighbor information is aggregated by calculating the attention weights between nodes to update the topological structure embedding representation of the entity.
[0027] S5 includes the following steps: S51. Take the atlas representation before time t as the historical atlas representation, and for the sequence of historical atlas representations within a time window, use the historical atlas representation at time t-1 as a benchmark to calculate the historical attention weights of the historical atlas representations compared with the historical atlas representations at other times in the sequence. S52. Perform weighted summation on the sequence represented by the historical graph according to the historical attention weight to generate a vector representation of the aggregated historical information; S53. Fuse the historical graph representation at time t-1 with the vector representation of aggregated historical information to generate a temporal embedding representation of the entity and complete temporal knowledge graph reasoning.
[0028] In this embodiment, this iterative method of calculating historical information complies with the law of temporal evolution, that is, the current system state at time t is generated by the evolution of the state at time t-1 of the previous moment, ensuring that the influence of historical information decays exponentially with time distance, which is consistent with the law that the influence of events in the real world decays with time. The specific implementation includes the following steps: First, calculate the attention weight, and determine the importance of different historical moments to the current prediction based on the similarity between the representation of the entity at time t-1 and the representation of other historical moments; second, generate a weighted historical information representation, and perform weighted summation of the historical moment representations through the attention weight to obtain a new representation that integrates historical information, thereby focusing on the past state that is most relevant to the future state and reducing the influence of irrelevant or too old information. Finally, the module fuses the structural features at timestamp t-1 with the time-aware representation before t-1 to generate a temporal embedding representation of the entity. This process is also applicable to the embedding representation of tail entities and relationships, thereby fully capturing the dynamic features in temporal evolution.
[0029] In this embodiment, a specific implementation case is provided for the solution of the present invention: Using S1’s method, the description text of Zhang San, “Zhang San is a junior student in the computer department of a certain university…”, is converted into a vector sequence containing the semantic and position information of each word. Using the S2 method, Zhang San's word vector sequence is processed through the Transformer encoder to obtain a single feature vector representing its overall descriptive information; Adopting the S3 method, the Zhang San structure vector obtained through TransE pre-training is fused with its description feature vector to generate a richer Zhang San entity representation; Adopting the S4 method, on the time slice of 2022, we use Zhang San’s enhanced representation as the initial feature and aggregate his neighbor information in the knowledge graph of that year through a graph neural network to obtain his graph representation for 2022. Using the S5 method, Zhang San’s graph representation sequence from the past few years (e.g., 2020-2022) is used to predict the entities most likely to be associated with “tourism” in 2023, such as “Tianjin”, through the self-attention mechanism. It can be seen from the above cases that in the knowledge graph question-answering scenario, the present invention adopts a temporal knowledge graph reasoning method combined with external description information, integrating entity description, topological structure and temporal information, thereby realizing temporal knowledge graph reasoning and improving the accuracy and efficiency of reasoning.
[0030] In the description of the present invention, it should be understood that the terms "center", "thickness", "upper", "lower", "horizontal", "top", "bottom", "inner", "outer", "radial", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only and cannot be understood as indicating or implying the relative importance or the number of technical features implicitly specified. Therefore, the features defined by "first", "second", and "third" may explicitly or implicitly include one or more of such features.
Claims
1. A temporal knowledge graph reasoning method combined with external description information, characterized in that: The following steps are involved: S1. Obtain text and convert it into a feature vector sequence that integrates semantic and position information; S2. Input the feature vector sequence into the Transformer encoder to extract the word description information feature vector; S3. Based on the pre-trained head entity embedding vector and relationship embedding vector obtained by TransE knowledge representation learning, the head entity embedding vector, relationship embedding vector and word description information feature vector are fused to obtain the vector representation of the target entity; S4, generate a graph representation on each time slice through multi-source information fusion and topological structure enhancement; S5. Based on the graph representation at each time slice, the self-attention mechanism is used to iteratively and selectively integrate the historical information sequence based on the graph representation of the previous moment within the time window to complete the temporal knowledge graph reasoning.
2. The temporal knowledge graph reasoning method combined with external description information according to claim 1 is characterized in that: S1 includes the following sub-steps: S11. Input the text into the Word2Vec model and map the word sequence in the text into a word embedding matrix, including the word embedding vector of each word; S12. Randomly generate a trainable positional encoding matrix through the Word2Vec model, and extract the corresponding positional encoding vector according to the position index of the word; S13. Concatenate the word embedding vector of each word in the text with the position encoding vector to generate a feature vector sequence that integrates semantic and position information.
3. The temporal knowledge graph reasoning method combined with external description information according to claim 1 is characterized in that: S2 includes the following sub-steps: S21, input the feature vector sequence into the Transformer encoder; S22, through the multi-head self-attention mechanism and feedforward network processing sequence within the Transformer encoder, capturing long-range dependencies and contextual information between words; S23. Output the context-aware representation of each word in the feature vector sequence through the Transformer encoder to generate a word description information feature vector.
4. The temporal knowledge graph reasoning method combined with external description information according to claim 1 is characterized in that: In S3, the method of fusing the header entity embedding vector, the relationship embedding vector, and the word description information feature vector includes the following steps: S31. For a given head entity embedding vector and relationship embedding vector, calculate the semantic relevance between the word description information feature vector of each word in the text description and the head entity and relationship pair to obtain the initial attention weight; S32. Use the relationship embedding vector to modify the initial attention weight based on the relationship, so that the weight can better reflect the part of the text related to the current relationship, and generate a modified attention weight. S33. Normalize the corrected attention weights, perform weighted summation on the word description information feature vectors using the normalized attention weights, and obtain a vector representation of the target entity.
5. The temporal knowledge graph reasoning method combined with external description information according to claim 1 is characterized in that: S4 includes the following sub-steps: S41. Initialize the entity and its neighborhood representation through pre-trained embedding, use relationship-aware aggregation to update the structural features, and perform weighted fusion with the vector representation of the target entity to generate the semantic feature representation of the entity; S42. Input the entity and its neighborhood subgraph at time t into GAT, learn the high-order structural information of the entity through the aggregation mechanism of GAT, and obtain the topological structure embedding representation of the entity; S43. Design a dynamic gating mechanism to adaptively fuse the semantic feature representation of the entity with the topological structure embedding representation to generate a graph representation at each time slice.
6. The temporal knowledge graph reasoning method combined with external description information according to claim 1 is characterized in that: S5 includes the following steps: S51. Take the atlas representation before time t as the historical atlas representation, and for the sequence of historical atlas representations within a time window, use the historical atlas representation at time t-1 as a benchmark to calculate the historical attention weights of the historical atlas representations compared with the historical atlas representations at other times in the sequence. S52. Perform weighted summation on the sequence represented by the historical graph according to the historical attention weight to generate a vector representation of the aggregated historical information; S53. Fuse the historical graph representation at time t-1 with the vector representation of aggregated historical information to generate a temporal embedding representation of the entity and complete temporal knowledge graph reasoning.