A time series knowledge graph reasoning method based on causal reinforcement and counterfactual intervention

CN122549573APending Publication Date: 2026-08-11SHANDONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-30
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0009]针对现有时序知识图谱推理方法在复杂时变环境下易受到结构扰动、环境偏差及环境敏感相关性影响,导致模型鲁棒性不足、跨环境泛化能力较弱的问题,本发明提供了一种基于因果增强与反事实混合干预的时序知识图谱推理方法(CA-HDT)

Benefits of technology

1、提高复杂时变环境下的建模稳定性。本发明通过基础视图与扰动视图构建多视图训练机制,在训练阶段主动模拟图结构扰动、关系迁移和局部噪声变化,使同一时间快照在不同观测条件下得到联合建模。模型不再仅依赖单一观测条件下的统计共现关系,因此在时间分布偏移、环境变化和非平稳场景下仍能保持较好的推理稳定性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122549573A_ABST
    Figure CN122549573A_ABST
Patent Text Reader

Abstract

This invention relates to a temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention. It inputs a historical temporal knowledge graph into a trained temporal knowledge graph reasoning model to output fact predictions corresponding to future timestamps. The temporal knowledge graph reasoning model includes a multi-view construction module, a causal reinforcement heterogeneous dual-stream encoder, an orthogonal feature decoupling module, a counterfactual hybrid intervention module, and a task decoder. The multi-view construction module generates a base view and a perturbed view for the same time snapshot. The causal reinforcement heterogeneous dual-stream encoder obtains a latent representation that considers both local structural information and global semantic information. The orthogonal feature decoupling module separates stable causal representations from environment-sensitive representations. The counterfactual hybrid intervention module constructs a counterfactual hybrid representation. The task decoder performs fact scoring and prediction. This invention improves the accuracy, stability, and generalization ability of temporal knowledge graph reasoning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the fields of artificial intelligence, knowledge graph reasoning and causal representation learning technology, and specifically relates to a temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention. Background Technology

[0002] Temporal knowledge graphs introduce timestamps into the traditional knowledge graph triples to describe entities, relationships, and their dynamic facts that change over time. Existing technologies for completing and reasoning with temporal knowledge graphs typically employ temporal embedding methods, recurrent neural networks, graph neural networks, and attention-based models to model the temporal evolution of entity relationships, thereby enabling future fact prediction or missing fact completion.

[0003] Early methods mostly added temporal embeddings or constraints to static knowledge graph completion models. These methods can represent the chronological order of events, but their utilization of temporal information remains relatively shallow, making it difficult to reflect the true changes in entity relationships at different stages. Later methods introduced recurrent neural networks, gating units, temporal graph neural networks, and attention mechanisms to encode historical subgraph sequences in order to learn evolutionary patterns from continuous snapshots. However, most of these methods still rely on statistical co-occurrence relationships in observed samples, lacking a clear distinction between stabilizing factors and environmental disturbances.

[0004] Existing temporal knowledge graph inference methods typically assume that training and test samples come from similar data distributions and learn prediction rules under relatively fixed sampling conditions. In practical applications, time spans, entity activity, relationship distribution, and event triggering methods can all change, and local graph structures may be affected by noise. In such cases, models are prone to mistaking accidental co-occurrence relationships for stable patterns, thus becoming susceptible to environmental noise and environmentally sensitive correlations, leading to decreased prediction accuracy, instability in inference, and insufficient long-term generalization ability. Especially in open environments, entity occurrence frequency, relationship triggering density, and temporal granularity may change simultaneously, making it difficult for models trained on a single observation view to maintain stable performance.

[0005] Existing methods often encode stable key factors and environmentally sensitive factors together in entity representations, making it difficult to separate cross-environmental stable information from information that fluctuates with local context in the representation space. Such representations typically achieve good results in uniformly distributed test scenarios, but they easily become overly reliant on accidental co-occurrence patterns in training samples when encountering non-stationary environments, distribution shifts, or noise-enhanced scenarios. For example, the high co-occurrence of certain short-term high-frequency relationships does not necessarily stem from a truly stable mechanism; it may simply be due to local sampling bias, concentrated event bursts, or short-term activity of individual entities. If the model cannot distinguish between these environmentally sensitive features and truly stable predictive criteria, it is prone to making judgments along statistical shortcuts.

[0006] Furthermore, most existing technologies improve predictive performance from the perspective of association modeling, with few explicit interventions to verify whether the model truly relies on stable information for reasoning. Without intervention, even if a model achieves high accuracy during training, it cannot be said that it can still make judgments based on stable mechanisms after environmental changes. For tasks such as temporal knowledge graph completion, dynamic relationship reasoning, and future fact prediction, the model must not only handle local topological structure and global semantic interactions, but also maintain decision stability under conditions of structural perturbations, relationship migration, and temporal distribution shifts.

[0007] Overall, existing methods have the following shortcomings: First, they lack explicit simulation of different environmental conditions, making it difficult to expose the model's sensitivity to structural perturbations and environmental changes during the training phase; second, they lack effective decoupling of stable causal features and environmentally sensitive features, resulting in unclear prediction basis; third, they lack intervention training methods for counterfactual scenarios, making it difficult to proactively weaken the impact of environmentally sensitive correlations on model decisions; and fourth, they lack a unified modeling approach that takes into account both local relational structures and global semantic dependencies, which limits the completeness and stability of representation learning.

[0008] Therefore, how to propose a temporal knowledge graph reasoning method that can extract stable causal representations, separate environmentally sensitive noise, and learn robust decision boundaries through counterfactual intervention constraint models to address structural perturbations, environmental changes, and spurious correlations in temporal knowledge graphs has become a technical problem that needs to be solved in this field. Summary of the Invention

[0009] To address the shortcomings of existing temporal knowledge graph reasoning methods in complex, time-varying environments, which are susceptible to structural perturbations, environmental biases, and environmentally sensitive correlations, resulting in insufficient model robustness and weak cross-environment generalization ability, this invention provides a temporal knowledge graph reasoning method based on a hybrid intervention of causal reinforcement and counterfactuality (CA-HDT). This method, based on the multi-view representation of the temporal knowledge graph, separates stable causal factors from environmentally sensitive factors and suppresses the interference of spurious correlation features on the reasoning results through intervention constraints, thereby improving the accuracy, stability, and generalization ability of temporal knowledge graph reasoning.

[0010] This invention addresses the problems of temporal knowledge graphs being susceptible to environmentally sensitive interference, lacking robustness, and exhibiting weak long-term generalization ability under conditions of temporal distribution shift, enhanced environmental noise, and non-stationary testing scenarios.

[0011] Terminology Explanation: 1. Relational Graph Convolutional Network (RGCN) is a graph neural network structure designed for multi-relation graph data. It sets relation transformation parameters for different relation types, and when aggregating neighbor node information, it can distinguish the influence of different relations on the target node representation, thereby learning explicit relational dependencies between entities. In this invention, the Relational Graph Convolutional Network is used to model the local topological structure and relational constraints in a snapshot of a temporal knowledge graph, outputting a local structural representation.

[0012] 2. The Transformer module is a feature modeling structure based on a self-attention mechanism. This module constructs a query matrix Q, a key matrix K, and a value matrix V, and calculates attention weights between different nodes, thereby capturing long-distance dependencies and global semantic interaction information. In this invention, the Transformer module is used to model the latent semantic associations between any two entities in the graph and output a global semantic representation.

[0013] 3. The adaptive gating fusion module is a structure that uses learnable gating coefficients to dynamically weight and fuse multi-path features. This module can adaptively determine the fusion ratio of the two types of features based on the local structural information and global semantic information of the current sample, so that the fusion result simultaneously preserves local relational constraints and global semantic dependencies. In this invention, this module is used to fuse the local structural representation output by the relation graph convolutional network and the global semantic representation output by the Transformer to obtain a unified latent representation.

[0014] To achieve the above objectives, the present invention adopts the following technical solution: A temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention is proposed, which inputs a historical temporal knowledge graph into a trained temporal knowledge graph reasoning model to output the fact prediction results corresponding to future timestamps; The temporal knowledge graph reasoning model includes a multi-view construction module, a causal enhanced heterogeneous dual-stream encoder, an orthogonal feature decoupling module, a counterfactual hybrid intervention module, and a task decoder. The multi-view construction module generates a base view and a perturbation view for snapshots at the same time to simulate structural changes under different environmental conditions; the causal-enhanced heterogeneous dual-stream encoder encodes the base view and the perturbation view using shared parameters to obtain a latent representation that takes into account both local structural information and global semantic information; the orthogonal feature decoupling module separates stable causal representations from environmentally sensitive representations in the latent space; the counterfactual hybrid intervention module constructs a counterfactual hybrid representation; and the task decoder performs fact scoring and prediction based on the stable causal representation and the counterfactual hybrid representation.

[0015] According to a preferred embodiment of the present invention, the time-series knowledge graph is defined as follows: Let the set of entities be The set of relations is Quadruple Indicates the timestamp At that time, the head entity With tail entity There is a relationship ; at timestamp All the facts appearing on it constitute a snapshot of the knowledge graph. The entire time-series knowledge graph is then represented as: ; in, Represents a complete temporal knowledge graph sequence. This indicates the total number of time steps.

[0016] According to a preferred embodiment of the present invention, during the training phase, for the target time... The prediction task, from historical windows Extract the length as The continuous time snapshots are used as input to the temporal knowledge graph reasoning model, where It is a positive integer that is pre-set or determined by the validation set; during the inference phase, the same historical window length as during the training phase is used.

[0017] According to a preferred embodiment of the present invention, the multi-view construction module is configured for any timestamp. Knowledge Graph Snapshot Construct a base view and a perturbation view; the base view is represented as follows: ; Disturbance view Generate by applying random edge perturbations to the base view; let... For the image Given the adjacency matrix, construct a random mask matrix. , The elements independently follow a Bernoulli distribution: ; in, This is the disturbance rate, used to control the intensity of structural disturbances; It refers to a probability distribution that takes only two discrete values, 0 or 1. Perturbed adjacency matrix Defined as: ; in, This represents element-wise multiplication; Based on the perturbed adjacency matrix That is, to obtain the corresponding perturbation view. The disturbance view It is the base view The graph structure formed after randomly deleting some edges.

[0018] According to a preferred embodiment of the present invention, the causal-enhanced heterogeneous dual-stream encoder employs a parameter-sharing method for the basic view. and perturbation view Performing the same encoding process is represented as: ; in, For parameters A parameterized shared encoder, where G represents the input graph. This is the potential representation of the shared encoder output; correspondingly, the fundamental representation and the perturbation representation are respectively... and .

[0019] More preferably, the shared encoder is the causal-enhanced heterogeneous dual-stream encoder, which includes a local structural stream, a global semantic stream, and an adaptive gating fusion module; In this context, the local structural flow employs a relational graph convolutional network to model the explicit relational dependencies between entities; Let... Represents a node In the The hidden state of the layer Representing relations The corresponding transformation matrix is ​​then updated according to the following rules: ; in, Represents a node In relation The following is a collection of neighbors. The normalization coefficient is... This is a self-loop weight matrix. It is a non-linear activation function; Representing neighboring nodes In the The hidden state of the layer Represents a node After the first The hidden state after the layer update; after multiple layers of propagation, the last layer hidden states of all nodes together constitute the local structure representation. That is, the potential representation of the local structural information; Global semantic flow uses the Transformer module to model the potential interaction relationships between any two entities in the graph. The graph refers to the graph structure representation corresponding to the current snapshot of the knowledge graph input to the encoder; global representation. That is, the potential representation of global semantic information is: ; in, , , These are the query matrix, key matrix, and value matrix, respectively. The dimension is the key vector; the Softmax function is a normalization function that maps a set of real numbers to non-negative weights that sum to 1, used to convert attention scores into attention weights; The adaptive gating fusion module is used to fuse local structural representations and global representations; gating coefficients Defined as: ; in, and For learnable parameters, Indicates feature splicing, This refers to the Sigmoid function, used to constrain the gating coefficients to a certain value. arrive between; The final fusion is represented as: ; in, This represents element-wise multiplication. This represents the potential representation after fusion; The base view and the perturbation view are encoded separately using a shared encoder to obtain the base representation. and disturbance representation .

[0020] According to a preferred embodiment of the present invention, the orthogonal feature decoupling module maps the basic representation and the perturbation representation to different latent subspaces through two independent nonlinear projection functions to obtain stable causal representation and environment-sensitive representation, respectively. ; ; in, Represents a stable causal projection function. Represents the environment-sensitive projection function. This represents the base representation of the base view obtained through the shared encoder. This represents the disturbance representation obtained from the disturbance view via the shared encoder. This represents a stable causal representation, used to characterize the core predictive factors that remain stable across different structural views; This indicates environmental sensitivity, used to characterize environmentally relevant features that are sensitive to structural disturbances.

[0021] Further optimization involves introducing orthogonal constraints to reduce... and To determine the degree of information coupling between features, before calculating the orthogonal loss, the features are first centered and normalized. ; in, This represents the feature vector of the current batch of samples. This represents the mean of the feature vectors of this type in the current batch. Represents the L2 norm, This represents the eigenvector after centering and normalization; Based on the normalized representation, orthogonal loss Defined as: ; in, Represents the current batch of sample sets. and They represent the first For each sample, a normalized stable causal representation and a normalized environment-sensitive representation are used. By constraining their inner product to approach zero, the information coupling between the stable causal representation and the environment-sensitive representation is reduced, thereby achieving effective separation of the two subspaces.

[0022] According to a preferred embodiment of the present invention, the counterfactual hybrid intervention module is based on stable causal representation. and environmental sensitivity Constructing a counterfactual hybrid representation : in, This represents the gradient truncation operation, used to... Treating it as a fixed environmental disturbance term, thus blocking the backpropagation effect of the hybrid branch on the environmentally sensitive representation branch, and making the temporal knowledge graph reasoning model pay more attention to the learning of stable causal representations during the training process.

[0023] Furthermore, the counterfactual hybrid intervention module also includes prediction consistency constraints and representation consistency constraints; Using the Convolutional Translation Embedding (ConvTransE) structure as the task decoder, for the tail entity prediction task, given the query facts... The task decoder takes the topic entity representation, relation representation, and temporal context representation as inputs and matches them one by one with the candidate tail entity representations, outputting the corresponding prediction scores; for the head entity prediction task, given the query facts... Then, the predicted scores of candidate head entities are generated in the same way, based on the object entity. All candidate entities are sorted in descending order of their prediction scores, and the candidate tail entity or candidate head entity with the highest score is taken as the final prediction result. The candidate entities constitute a ranked list of candidate answers; among them, the ConvTransE-based decoding function is used to generate the predicted scores of the candidate entities, and the binary cross-entropy loss function is used to measure the difference between the predicted results and the true labels; Predicting losses Defined as: ; in, This indicates a decoding function based on ConvTransE. Indicates the true label, Represents the binary cross-entropy loss function; Intraview consistency loss Defined as: ; in, Represents the cosine similarity function. Indicates the first The counterfactual mixed representation corresponding to each sample; View consistency loss Defined as: .

[0024] According to a preferred embodiment of the present invention, the overall optimization objective of the time-series knowledge graph reasoning model is defined as: ; in, Indicates the total loss. , and These are the tradeoff coefficients for each loss term, used to adjust the relative importance of each constraint term during the training process.

[0025] By adopting the above technical solution, the present invention has at least the following beneficial effects: 1. Improve modeling stability in complex time-varying environments. This invention constructs a multi-view training mechanism by using a base view and a perturbation view. During the training phase, it actively simulates graph structure perturbations, relation migrations, and local noise changes, enabling joint modeling of the same snapshot under different observation conditions. The model no longer relies solely on statistical co-occurrence relationships under a single observation condition, thus maintaining good inference stability even under time distribution shifts, environmental changes, and non-stationary scenarios.

[0026] 2. Enhanced collaborative representation of local structural information and global semantic information. This invention employs a causal-enhanced heterogeneous dual-stream encoder, where the local structural stream characterizes explicit relational dependencies within an entity's neighborhood, while the global semantic stream captures latent semantic associations between distant entities. An adaptive gating fusion module then dynamically integrates these two types of information. The resulting representation simultaneously reflects local topological constraints and global semantic dependencies, making it more suitable for handling temporal knowledge graph reasoning tasks in complex relationships, multi-hop dependencies, and dynamically evolving scenarios.

[0027] 3. Improve the separation of stable and environment-sensitive information. This invention uses an orthogonal feature decoupling module to split the encoded latent representation into a stable causal representation and an environment-sensitive representation. Furthermore, it reduces the coupling between these two types of representations in the feature space through centering, normalization, and orthogonal constraints. After this processing, the stable causal representation primarily retains more stable prediction criteria across environments, while the environment-sensitive representation reflects more changes brought about by local context, short-term fluctuations, and structural perturbations, thus helping to reduce the impact of spurious correlations on prediction results.

[0028] 4. Improve the effectiveness of counterfactual intervention training. This invention employs a counterfactual hybrid intervention strategy. While maintaining stable causal representations in prediction, it introduces environment-sensitive representations as intervention factors into the hybrid branch and utilizes gradient truncation to prevent the model from re-relying on the environment-sensitive branch during training to offset the intervention effect. Furthermore, this invention combines task prediction loss, orthogonal constraint loss, intra-view consistency loss, and inter-view consistency loss for joint optimization. This ensures the model focuses not only on the prediction result itself but also on the consistency relationships between different views, different intervention conditions, and different representation subspaces. Therefore, it exhibits better robustness and output stability under noise enhancement, structural perturbation, and out-of-distribution testing conditions.

[0029] 5. Facilitates integration with existing temporal knowledge graph reasoning frameworks. The method of this invention is complete and can be used in conjunction with convolutional fact scorers such as ConvTransE, and can also be adapted to other temporal knowledge graph decoders, facilitating deployment within existing reasoning frameworks. This method is not only applicable to future fact prediction and temporal knowledge graph completion, but can also be applied to scenarios such as dynamic relationship reasoning, event evolution analysis, risk warning, and intelligent decision support. Attached Figure Description

[0030] Figure 1 The overall flowchart of the temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention provided by this invention is shown in the present invention.

[0031] Figure 2 For the stable causal representation of this invention Representation of environmental sensitivity A visualization of the correlation matrix; Figure 3 For the stable causal representation of the present invention t-SNE dimensionality reduction visualization; Figure 4 Environmentally sensitive representation of the present invention A visualization of t-SNE dimensionality reduction. Detailed Implementation

[0032] The present invention will be further defined below with reference to the accompanying drawings and embodiments, but is not limited thereto.

[0033] Example 1 A temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention is proposed, which inputs a historical temporal knowledge graph into a trained temporal knowledge graph reasoning model to output the fact prediction results corresponding to future timestamps; The temporal knowledge graph reasoning model includes a multi-view construction module, a causal-enhanced heterogeneous dual-stream encoder, an orthogonal feature decoupling module, a counterfactual hybrid intervention module, and a task decoder. The multi-view construction module generates a base view and a perturbation view for snapshots taken at the same time to simulate structural changes under different environmental conditions; the causal-enhanced heterogeneous dual-stream encoder encodes the base view and the perturbation view with shared parameters to obtain a latent representation that takes into account both local structural information and global semantic information; the orthogonal feature decoupling module separates the stable causal representation and the environment-sensitive representation in the latent space; the counterfactual hybrid intervention module constructs a counterfactual hybrid representation to weaken the influence of environment-sensitive factors on the inference results; and the task decoder completes fact scoring and prediction based on the stable causal representation and the counterfactual hybrid representation.

[0034] Example 2 The difference between the temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention described in Example 1 and the following is: The definition of a time-series knowledge graph is as follows: Let the set of entities be The set of relations is Quadruple Indicates the timestamp At that time, the head entity With tail entity There is a relationship ; at timestamp All the facts appearing on it constitute a snapshot of the knowledge graph. The entire time-series knowledge graph is then represented as: ; in, Represents a complete temporal knowledge graph sequence. This indicates the total number of time steps.

[0035] Temporal knowledge graph reasoning is an entity prediction task, that is, given a historical sequence Predict future timestamps under the given conditions Missing object entity or missing subject entity .

[0036] During the training phase, targeting specific moments... The prediction task, from historical windows Extract the length as The continuous time snapshots are used as input to the temporal knowledge graph reasoning model, where The value is a pre-defined positive integer or determined through a validation set; during the inference phase, the same historical window length as during the training phase is used to ensure consistency in the temporal context modeling approach.

[0037] The multi-view building block is for any timestamp Knowledge Graph Snapshot Construct a base view and a perturbation view; among which, a knowledge graph snapshot. From timestamp The graph structure at that moment is formed by all the fact quadruples. Each fact quadruple is mapped to a directed edge of relation type between the head entity and the tail entity, thus yielding the graph structure at that time. Therefore, the base view is actually a graph representation directly formed from the fact set at that moment. The base view is represented as follows:

[0038] ; Here Represents timestamp The corresponding knowledge graph snapshot, which directly constitutes the base view, therefore here... The two views represent the same object, but emphasize different perspectives: the former emphasizes the meaning of the original snapshot, while the latter emphasizes the meaning of the graph structure as input to the model.

[0039] The base view preserves the complete topological structure and relational semantic information of the graph.

[0040] Disturbance view Generate by applying random edge perturbations to the base view; let... For the image Given the adjacency matrix, construct a random mask matrix. , The elements independently follow a Bernoulli distribution: ; in, This is the disturbance rate, used to control the intensity of structural disturbances; It refers to a probability distribution that takes only two discrete values, 0 or 1. The Bernoulli distribution refers to a probability distribution that takes only two discrete values, 0 or 1. In this invention, the elements of the random mask matrix M follow a Bernoulli (1-ρ) distribution, indicating that the original edge is retained at that position with probability 1-ρ, and the original edge is deleted with probability ρ.

[0041] Perturbed adjacency matrix Defined as: ; in, This represents element-wise multiplication; by randomly discarding some edges, the perturbation view changes local connectivity while preserving the main semantic information, and is used to simulate structural changes under different environments.

[0042] Based on the perturbed adjacency matrix That is, to obtain the corresponding perturbation view. ; Disturbance view It is the base view The graph structure formed after randomly deleting some edges. Its volume set and relation set remain unchanged; only local connectivity relationships change.

[0043] The causal-enhanced heterogeneous dual-stream encoder uses a parameter-sharing approach for the basic view. and perturbation view Performing the same encoding process is represented as: ; in, For parameters A parameterized shared encoder, where G represents the input graph. This is the potential representation of the shared encoder output; correspondingly, the fundamental representation and the perturbation representation are respectively... and .

[0044] A shared encoder is a causal-enhanced heterogeneous dual-stream encoder, which includes a local structural stream, a global semantic stream, and an adaptive gating fusion module. In this context, the local structural flow employs a Relational Graph Convolutional Network (RGCN) to model explicit relational dependencies between entities; Let... Represents a node In the The hidden state of the layer Representing relations The corresponding transformation matrix is ​​then updated according to the following rules: ; in, Represents a node In relation The following is a collection of neighbors. The normalization coefficient is... This is a self-loop weight matrix. It is a non-linear activation function; Representing neighboring nodes In the The hidden state of the layer Represents a node After the first The hidden state after the layer update; after multiple layers of propagation, the last layer hidden states of all nodes together constitute the local structure representation. That is, the potential representation of local structural information; Global semantic flow uses the Transformer module to model the potential interaction relationships between any two entities in the graph. The graph refers to the graph structure representation corresponding to the current snapshot of the knowledge graph input to the encoder; global representation. That is, the potential representation of global semantic information is: ; in, , , These are the query matrix, key matrix, and value matrix, respectively. The key vector dimension is used to capture latent semantic dependencies between distant entities. The Softmax function is a normalization function that maps a set of real numbers to non-negative weights that sum to 1, used to convert attention scores into attention weights.

[0045] The adaptive gating fusion module is used to fuse local structural representations and global representations; gating coefficients Defined as: ; in, and For learnable parameters, Indicates feature splicing, This refers to the Sigmoid function, used to constrain the gating coefficients to a certain value. arrive between; The final fusion is represented as: ; in, This represents element-wise multiplication. This represents the potential representation after fusion; The base view and the perturbation view are encoded separately using a shared encoder to obtain the base representation. and disturbance representation .

[0046] The orthogonal feature decoupling module maps the basic representation and the perturbation representation to different latent subspaces through two independent nonlinear projection functions to obtain stable causal representation and environment-sensitive representation, respectively. ; ; in, Represents a stable causal projection function. The environment-sensitive projection function, the stable causal projection function, and the environment-sensitive projection function can all be implemented using nonlinear mapping methods. Their function is to respectively improve the fundamental representation. and disturbance representation Stable causal features and environmentally sensitive features were extracted. This represents the base representation of the base view obtained through the shared encoder. This represents the disturbance representation obtained from the disturbance view via the shared encoder. This represents a stable causal representation, used to characterize the core predictive factors that remain stable across different structural views; This indicates environmental sensitivity, used to characterize environmentally relevant features that are sensitive to structural disturbances.

[0047] Introduce orthogonal constraints to reduce and To determine the degree of information coupling between features, before calculating the orthogonal loss, the features are first centered and normalized. ; in, This represents the feature vector of the current batch of samples. This represents the mean of the feature vectors of this type in the current batch. Represents the L2 norm, This represents the eigenvector after centering and normalization; Based on the normalized representation, orthogonal loss Defined as: ; in, Represents the current batch of sample sets. and They represent the first For each sample, a normalized stable causal representation and a normalized environment-sensitive representation are used. By constraining their inner product to approach zero, the information coupling between the stable causal representation and the environment-sensitive representation is reduced, thereby achieving effective separation of the two subspaces.

[0048] The counterfactual hybrid intervention module is based on stable causal representation. and environmental sensitivity Constructing a counterfactual hybrid representation : ; in, This represents the gradient truncation operation, used to... Treating it as a fixed environmental disturbance term, thus blocking the backpropagation effect of the hybrid branch on the environmentally sensitive representation branch, and making the temporal knowledge graph reasoning model pay more attention to the learning of stable causal representations during the training process.

[0049] To enhance the consistency of the model's output under different intervention conditions, the counterfactual hybrid intervention module also includes prediction consistency constraints and representation consistency constraints; Using the Convolutional Translation Embedding (ConvTransE) structure as the task decoder, for the tail entity prediction task, given the query facts... The task decoder takes the topic entity representation, relation representation, and temporal context representation as inputs and matches them one by one with the candidate tail entity representations, outputting the corresponding prediction scores; for the head entity prediction task, given the query facts... Then, the predicted scores of candidate head entities are generated in the same way, based on the object entity. All candidate entities are sorted in descending order of their prediction scores, and the candidate tail entity or candidate head entity with the highest score is taken as the final prediction result. The candidate entities constitute a ranked list of candidate answers; among them, the ConvTransE-based decoding function is used to generate the predicted scores of the candidate entities, and the binary cross-entropy loss function is used to measure the difference between the predicted results and the true labels; Predicting losses Defined as: ; in, This indicates a decoding function based on ConvTransE. Indicates the true label, Represents the binary cross-entropy loss function; Intraview consistency loss Defined as: ; in, Represents the cosine similarity function. Indicates the first Each sample corresponds to a counterfactual hybrid representation; it is used to constrain the stable semantics of the same sample in both the original sample branch and the counterfactual sample branch. It is also used to constrain the causal representation to remain stable before and after intervention.

[0050] View consistency loss Defined as: .

[0051] Used to constrain the semantic consistency between causal representations and the underlying representations.

[0052] The overall optimization objective of the time-series knowledge graph reasoning model is defined as: ; in, Indicates the total loss. , and represents the tradeoff coefficient for each loss term, used to adjust the relative importance of each constraint term during training. It is a non-negative real number, preferably determined through validation set parameter tuning; in one embodiment, it can be set to 0.01, 0.1, and 0.1 respectively to adjust the relative importance of each constraint term during training.

[0053] Example 3 The difference between the temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention described in Example 2 and the one described in Example 2 is as follows: A temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention, such as Figure 1 As shown, it includes: S1. Obtain historical fact quadruples with timestamps and construct a time snapshot sequence according to the preset time granularity. .

[0054] S2, for each time snapshot Generate a base view, and perform random edge perturbation on the base view to obtain the corresponding perturbation view. .

[0055] S3, Transfer the base view and perturbation view A causal-enhanced heterogeneous dual-stream encoder with shared input parameters yields the basic representations. and disturbance representation .

[0056] S4. Represent the basic representation Input a stable causal projection head to obtain a stable causal representation. ; represent the disturbance Input the environment-sensitive projection head to obtain the environment-sensitive representation. Furthermore, orthogonal constraints are used to reduce information overlap between the two types of representations.

[0057] S5. Based on stable causal representation and environmental sensitivity Constructing a counterfactual hybrid representation And through the task decoder respectively and The corresponding candidate facts are scored.

[0058] S6. Loss Prediction Based on Task Orthogonal constraint loss Intraview consistency loss Consistency loss between views The models are jointly trained to obtain a trained temporal knowledge graph reasoning model.

[0059] S7. In the reasoning stage, the historical time window is... Input the trained model, generate candidate answer ranking results for the target query facts, and output the predicted facts corresponding to future timestamps.

[0060] Through the above steps, this embodiment can learn stable causal representations under different environmental changes and reduce the interference of environmentally sensitive noise on the inference results. To fully verify the applicability of the model across different time spans, different time granularities, and different knowledge evolution modes, this invention selects four representative temporal knowledge graph datasets for experiments: ICEWS14, ICEWS14*, ICEWS05-15, and GDELT.

[0061] To comprehensively verify the inference performance of the proposed model under different temporal scales and event evolution scenarios, this embodiment selects four commonly used public datasets in temporal knowledge graph completion tasks for experiments: ICEWS14, ICEWS14*, ICEWS05-15, and GDELT. The source, time range, temporal granularity, and characteristics of each dataset are shown in Table 1.

[0062] Table 1. Dataset Summary; The ICEWS datasets originate from the Integrated Crisis Early Warning System. This system is an event-driven database built with funding from the U.S. Defense Advanced Research Projects Agency (DARPA), primarily used to record and monitor information related to international political conflicts, military operations, diplomatic relations, and other crisis events.

[0063] ICEWS14 contains event data for the entire year of 2014, with a time granularity of 24 hours. Because this dataset covers a relatively concentrated time range and the event evolution exhibits strong short-term continuity, it is often used to evaluate a model's ability to model local time dependencies and short-term dynamic patterns.

[0064] ICEWS14* is a variant built on top of ICEWS14, typically divided into training, validation, and test sets in a 70%:15%:15% ratio. Compared to the original ICEWS14, ICEWS14* has more standardized experimental settings, which helps to more objectively evaluate the model's generalization performance in tasks involving predicting unknown temporal facts.

[0065] ICEWS05-15, also derived from the ICEWS event database, has a longer time span, covering event sequences from January 2005 to December 2015, containing over 460,000 event facts. This dataset records the dynamic changes in cooperation, conflict, and interaction among nations over a longer period, with a time granularity of 24 hours. Due to its longer time span and more complex historical evolution, models need not only to capture event dependencies within local time windows but also to extract stable evolutionary patterns from long-term history. Therefore, this dataset is more suitable for testing the model's ability to model long-range temporal dependencies.

[0066] The GDELT dataset originates from the Global Database of Events, Language and Tone. This database enables near real-time monitoring of events in global news media, offering higher event density and finer-grained temporal characterization. Compared to the ICEWS series datasets, GDELT further refines the temporal granularity to 15 minutes and includes 20 different event categories, such as protests, military mobilization, and economic sanctions. Due to the frequent event updates and complex temporal evolution of GDELT, it places higher demands on the model's dynamic representation capabilities and robust inference abilities.

[0067] To verify the effectiveness of the proposed model, this invention selects representative interpolation and temporal extrapolation inference methods as comparative baselines. Interpolation methods include TTransE, TA-DistMult, DE-SimplE, and TNTComplEx. These methods typically learn temporal-related representations within the observed time range and are suitable for completing missing facts in existing time intervals. Extrapolation methods include TANGO, TANGO-Tucker, TANGO-DistMult, CyGNet, RE-NET, RE-GCN, TITer, xERTE, CEN, HiSMatch, and Re-Temp. These methods are primarily geared towards fact prediction tasks at future timestamps and can more directly reflect the model's temporal extrapolation inference capabilities.

[0068] The experiments for both CA-HDT and the comparative model were conducted under a unified data partitioning and evaluation protocol. Performance comparisons on the ICEWS14 and ICEWS14* datasets are shown in Tables 2 and 3.

[0069] Table 2 Performance comparison of ICEWS14 and ICEWS14* datasets (%). As shown in Table 2, CA-HDT achieved state-of-the-art results on both the ICEWS14 and ICEWS14* datasets. On the ICEWS14 dataset, CA-HDT achieved MRR, Hits@1, Hits@3, and Hits@10 of 61.75%, 49.60%, 69.01%, and 85.05%, respectively; on the ICEWS14* dataset, the corresponding metrics were 58.28%, 45.47%, 65.81%, and 82.79%. Compared to the best-performing comparative methods, CA-HDT showed significant improvements in all metrics on both datasets, indicating that the model has stronger fact prediction capabilities in short-time-span scenarios.

[0070] The events in ICEWS14 and ICEWS14* are densely distributed, and temporal associations are mainly concentrated within short time windows. The model not only needs to accurately capture local dynamics but also suppress noise interference caused by frequent changes. CA-HDT, through a causal-enhanced heterogeneous dual-stream modeling mechanism, characterizes the structural dependencies and semantic associations in the temporal knowledge graph from different perspectives. Furthermore, by employing an orthogonal feature decoupling strategy, it explicitly separates relatively stable causal information from environmentally sensitive information, thereby reducing the impact of noise and spurious correlations on the inference results. Therefore, on these two datasets, CA-HDT demonstrates stronger prediction accuracy and more stable overall performance.

[0071] The performance comparisons on the ICEWS05-15 and GDELT datasets are shown in Table 3.

[0072] Table 3 Performance comparison (%) on ICEWS05-15 and GDELT datasets; As shown in Table 3, CA-HDT also achieved state-of-the-art results on both the ICEWS05-15 and GDELT datasets. On the ICEWS05-15 dataset, CA-HDT achieved MRR, Hits@1, Hits@3, and Hits@10 of 69.43%, 56.30%, 78.71%, and 94.26%, respectively; on the GDELT dataset, the corresponding metrics were 31.20%, 19.26%, 35.13%, and 55.58%. Compared to other baseline models, CA-HDT's advantage on these two datasets remains significant, indicating that the model is not only suitable for short-term scenarios but also maintains strong inference capabilities in long-term evolution and high-frequency dynamic environments.

[0073] Among them, ICEWS05-15 has a longer time span and a more complex knowledge evolution process, requiring the model to simultaneously handle long-term historical dependencies and cross-period relationship changes. CA-HDT still achieves the best results on this dataset, indicating that it can not only characterize fine-grained changes within a local time range, but also extract relatively stable deep semantic associations from long-term evolution, thereby improving the inference accuracy in complex time-series scenarios. For the GDELT dataset, due to its finer time granularity and more frequent event updates, the model needs to complete fact prediction in a more complex dynamic environment. CA-HDT also achieves the best results on this dataset, indicating that it still has strong structural modeling capabilities and prediction stability in scenarios with high-frequency event flows, complex relationship interactions, and rapid distribution changes. The introduction of the counterfactual hybrid intervention mechanism further enhances the model's adaptability to distribution shift scenarios.

[0074] The experimental results in Tables 2 and 3 show that CA-HDT outperforms existing baseline methods on all four public datasets and exhibits good stability across different time spans, temporal granularities, and knowledge evolution patterns. This demonstrates that the causal-enhanced heterogeneous dual-stream modeling framework, orthogonal feature decoupling mechanism, and counterfactual hybrid intervention strategy proposed in this invention can effectively improve the model's ability to characterize complex temporal dependencies, while also enhancing its robustness and generalization ability under noisy environments and varying distribution conditions.

[0075] ablation experiment To further explore the effectiveness of each core module of CA-HDT, this invention conducts ablation experiments from four aspects: gradient blocking mechanism, hybrid enhancement strategy, orthogonal constraint and spurious correlation modeling. The specific configuration of each ablation model is shown in Table 4, and the experimental results of each ablation model are shown in Table 5.

[0076] Table 4. Comparison of Model Structures;

[0077] Table 5 Ablation experimental results (%) on ICEWS14*, ICEWS14 and ICEWS05-15 datasets;

[0078] Ablation experiments show that the performance improvement of CA-HDT stems from the synergistic effect of its components. First, removing the spurious association modeling module resulted in the most significant decrease in all metrics across all datasets, indicating that this module effectively mitigates the interference of historical noise and pseudo-related information on inference results, making it a key component in improving the model's predictive performance. Second, removing orthogonal constraints also led to varying degrees of performance degradation on most datasets, demonstrating that orthogonal constraints help promote effective separation between different representation spaces, thereby enhancing the stability and discriminative ability of representation learning. Removing the hybrid augmentation strategy resulted in relatively small changes in the model across different datasets, indicating that this module can complement the model's generalization ability from a data augmentation perspective. Overall, spurious association modeling, orthogonal constraints, gradient blocking mechanisms, and hybrid augmentation strategies collectively constitute the important sources of CA-HDT's performance improvement.

[0079] To further analyze the decoupling effect of the model on different relational signals, this invention conducted visualization experiments on the ICEWS14* dataset, and the results are as follows: Figure 2 As shown. Figure 2 A stable causal representation is given. Representation of environmental sensitivity The correlation matrix. Figure 2 The numbers on the horizontal and vertical axes represent the feature dimension numbers, and the color bars on the right represent the correlation magnitude, with red indicating a high positive correlation, blue indicating a high negative correlation, and near-white indicating a correlation close to zero. It can be seen that the correlation of the vast majority of feature pairs is close to zero, indicating a low correlation between the two types of representations, suggesting that the model has achieved a good separation between stable causal components and environmentally sensitive temporal components.

[0080] Meanwhile, this invention uses t-SNE to perform dimensionality reduction and visualization of the learned representations, such as... Figure 3 and Figure 4 As shown. Among them, Figure 3 and Figure 4 In the figure, the numbers on the horizontal and vertical axes represent the two-dimensional coordinates after t-SNE dimensionality reduction, which are used to characterize the relative distribution of the samples in the low-dimensional space; the scatter points in the figure represent the projection results of different samples. Figure 3 and Figure 4The color bar on the right is the color mapping range displayed by default by the drawing tool. In this embodiment, it is not used to represent different categories, different risk levels or other independent semantic information. The figure mainly focuses on the distribution pattern of sample points in low-dimensional space. Figure 3 The relatively compact distribution of the middle sample indicates that the stable causal representation has better aggregation properties; Figure 4 The relatively more dispersed distribution of the medium-sized samples indicates that the environmentally sensitive representations are more susceptible to the influence of local context and short-term perturbations. Figure 3 Corresponding stable causal representation The sample points formed several relatively compact clusters with clear boundaries, indicating that the representation can stably preserve the core relational patterns consistent across time. Figure 4 Corresponding environmental sensitivity Their distribution is more dispersed, and the local overlap is more obvious, indicating that this part of the feature is more sensitive to local context and short-term environmental changes. It focuses more on representing stable and time-robust causal relationships. This primarily preserves short-term, context-dependent association features. This result is consistent with the performance improvements in long-term prediction and OOD robustness experiments presented earlier, further validating the effectiveness of the proposed decoupling mechanism.

Claims

1. A temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention, characterized in that, Input the historical time-series knowledge graph into the trained time-series knowledge graph reasoning model to output the fact prediction results corresponding to future timestamps; The temporal knowledge graph reasoning model includes a multi-view construction module, a causal enhanced heterogeneous dual-stream encoder, an orthogonal feature decoupling module, a counterfactual hybrid intervention module, and a task decoder. The multi-view construction module generates a base view and a perturbation view for snapshots at the same time to simulate structural changes under different environmental conditions; the causal-enhanced heterogeneous dual-stream encoder encodes the base view and the perturbation view using shared parameters to obtain a latent representation that takes into account both local structural information and global semantic information; the orthogonal feature decoupling module separates stable causal representations from environmentally sensitive representations in the latent space; the counterfactual hybrid intervention module constructs a counterfactual hybrid representation; and the task decoder performs fact scoring and prediction based on the stable causal representation and the counterfactual hybrid representation.

2. The temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention according to claim 1, characterized in that, The definition of a time-series knowledge graph is as follows: Let the set of entities be The set of relations is Quadruple Indicates the timestamp At that time, the head entity With tail entity There is a relationship ; at timestamp All the facts appearing on it constitute a snapshot of the knowledge graph. The entire time-series knowledge graph is then represented as: ; in, Represents a complete temporal knowledge graph sequence. This indicates the total number of time steps.

3. The temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention according to claim 2, characterized in that, During the training phase, targeting specific moments... The prediction task, from historical windows Extract the length as The continuous time snapshots are used as input to the temporal knowledge graph reasoning model, where It is a positive integer that is pre-set or determined by the validation set; during the inference phase, the same historical window length as that used during the training phase is adopted.

4. The temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention according to claim 2, characterized in that, The multi-view building block is for any timestamp Knowledge Graph Snapshot Construct a base view and a perturbation view; the base view is represented as follows: ; Disturbance view Generate by applying random edge perturbations to the base view; let... For the image Given the adjacency matrix, construct a random mask matrix. , The elements independently follow a Bernoulli distribution: ; in, This is the disturbance rate, used to control the intensity of structural disturbances; It refers to a probability distribution that takes only two discrete values, 0 or 1. Perturbed adjacency matrix Defined as: ; in, This represents element-wise multiplication; Based on the perturbed adjacency matrix That is, to obtain the corresponding perturbation view. The disturbance view It is the base view The graph structure formed after randomly deleting some edges.

5. The temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention according to claim 2, characterized in that, The causal-enhanced heterogeneous dual-stream encoder employs a parameter-sharing method for the basic view. and perturbation view Performing the same encoding process is represented as: ; in, For parameters A parameterized shared encoder, where G represents the input graph. This is the potential representation of the shared encoder output; correspondingly, the fundamental representation and the perturbation representation are respectively... and ; The shared encoder is the causal-enhanced heterogeneous dual-stream encoder, which includes a local structural stream, a global semantic stream, and an adaptive gating fusion module. In this context, the local structural flow employs a relational graph convolutional network to model the explicit relational dependencies between entities; Let... Represents a node In the The hidden state of the layer Representing relations The corresponding transformation matrix is ​​then updated according to the following rules: ; in, Represents a node In relationship The following is a collection of neighbors. The normalization coefficient is... This is a self-loop weight matrix. It is a non-linear activation function; Representing neighboring nodes In the The hidden state of the layer Represents a node After the first The hidden state after the layer update; after multiple layers of propagation, the last layer hidden states of all nodes together constitute the local structure representation. That is, the potential representation of the local structural information; Global semantic flow uses the Transformer module to model the potential interaction relationships between any two entities in the graph. The graph refers to the graph structure representation corresponding to the current snapshot of the knowledge graph input to the encoder; global representation. That is, the potential representation of global semantic information is: ; in, , , These are the query matrix, key matrix, and value matrix, respectively. The dimension is the key vector; the Softmax function is a normalization function that maps a set of real numbers to non-negative weights that sum to 1, used to convert attention scores into attention weights; The adaptive gating fusion module is used to fuse local structural representations and global representations; gating coefficients Defined as: ; in, and For learnable parameters, Indicates feature splicing, This refers to the Sigmoid function, used to constrain the gating coefficients to a certain value. arrive between; The final fusion is represented as: ; in, This represents element-wise multiplication. This represents the potential representation after fusion; The base view and the perturbation view are encoded separately using a shared encoder to obtain the base representation. and disturbance representation .

6. The temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention according to claim 1, characterized in that, The orthogonal feature decoupling module maps the basic representation and the perturbation representation to different latent subspaces through two independent nonlinear projection functions to obtain stable causal representation and environment-sensitive representation, respectively. ; ; in, Represents a stable causal projection function. Represents the environment-sensitive projection function. This represents the base representation of the base view obtained through the shared encoder. This represents the disturbance representation obtained from the disturbance view via the shared encoder. This represents a stable causal representation, used to characterize the core predictive factors that remain stable across different structural views; This indicates environmental sensitivity, used to characterize environmentally relevant features that are sensitive to structural disturbances.

7. The temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention as described in claim 6, characterized in that, Introduce orthogonal constraints to reduce and To determine the degree of information coupling between features, before calculating the orthogonal loss, the features are first centered and normalized. ; in, This represents the feature vector of the current batch of samples. This represents the mean of the feature vectors of this type in the current batch. Represents the L2 norm, This represents the eigenvector after centering and normalization; Based on the normalized representation, orthogonal loss Defined as: ; in, Represents the current batch of sample sets. and They represent the first For each sample, a normalized stable causal representation and a normalized environment-sensitive representation are used. By constraining their inner product to approach zero, the information coupling between the stable causal representation and the environment-sensitive representation is reduced, thereby achieving effective separation of the two subspaces.

8. The temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention according to claim 1, characterized in that, The counterfactual hybrid intervention module is based on stable causal representation. and environmental sensitivity Constructing a counterfactual hybrid representation : in, This represents the gradient truncation operation, used to... Treating it as a fixed environmental disturbance term, thus blocking the backpropagation effect of the hybrid branch on the environmentally sensitive representation branch, and making the temporal knowledge graph reasoning model pay more attention to the learning of stable causal representations during the training process.

9. A temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention as described in any one of claims 2-8, characterized in that, The counterfactual hybrid intervention module also includes prediction consistency constraints and representation consistency constraints; Using the Convolutional Translation Embedding (ConvTransE) structure as the task decoder, for the tail entity prediction task, given the query facts... The task decoder takes the topic entity representation, relation representation, and temporal context representation as inputs and matches them one by one with the candidate tail entity representations, outputting the corresponding prediction scores; for the head entity prediction task, given the query facts... Then, the predicted scores of candidate head entities are generated in the same way, based on the object entity. All candidate entities are sorted in descending order of their prediction scores, and the candidate tail entity or candidate head entity with the highest score is taken as the final prediction result. The candidate entities constitute a ranked list of candidate answers; among them, the ConvTransE-based decoding function is used to generate the predicted scores of the candidate entities, and the binary cross-entropy loss function is used to measure the difference between the predicted results and the true labels; Predicting losses Defined as: ; in, This indicates a decoding function based on ConvTransE. Indicates the true label, Represents the binary cross-entropy loss function; Intraview consistency loss Defined as: ; in, Represents the cosine similarity function. Indicates the first The counterfactual mixed representation corresponding to each sample; View consistency loss Defined as: 。 10. A temporal knowledge graph reasoning method based on causal reinforcement and counterfactual intervention as described in claim 9, characterized in that, The overall optimization objective of the time-series knowledge graph reasoning model is defined as follows: ; in, Indicates the total loss. , and These are the tradeoff coefficients for each loss term, used to adjust the relative importance of each constraint term during the training process.