Time sequence knowledge graph reasoning method and system based on dynamic dependency selection
By employing a time-series knowledge graph reasoning method with dynamic dependency selection, combined with time awareness and dual-channel comparative learning, the shortcomings of existing technologies in terms of time dynamics and dependency selection are addressed, achieving higher accuracy in predicting future events.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-03
AI Technical Summary
Existing temporal knowledge graph reasoning methods are insufficient in terms of deep integration of temporal dynamic characteristics, adaptive selection of dynamic dependencies, and balanced prediction of periodic patterns and emerging entities, resulting in low accuracy in predicting future events.
We employ a time-series knowledge graph reasoning method based on dynamic dependency selection. Through time-aware dependency modeling, dual-channel comparative learning, and trend statistics, we dynamically select the most relevant entity dependencies. Combining stock entity attributes, relationship features, and time encoding, we generate dependency representations of historical and new entities and use an attention mechanism to assign weights for prediction.
It significantly improves the accuracy of future event prediction, especially when dealing with strong periodic patterns and complex scenarios of emerging entities. Experiments on multiple public datasets show that the prediction accuracy is better than existing mainstream models.
Smart Images

Figure CN121787572A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of knowledge graph technology, specifically, it relates to a temporal knowledge graph reasoning method and system based on dynamic dependency selection. Background Technology
[0002] With the rapid development of internet technology and the information industry, the data generated in the real world is not only massive in scale but also exhibits complex dynamic evolutionary characteristics. To effectively characterize and utilize this time-varying knowledge system, Temporal Knowledge Graphs (TKGs) have emerged. Unlike traditional static knowledge graphs that use (head entity, relation, tail entity) triples, temporal knowledge graphs represent facts as quadruples (subject s, relation r, object o, time t), thus accurately describing the point in time or time period in which an event occurred. This structure enables temporal knowledge graphs to model the dynamic evolution of the world state along a timeline, thus demonstrating enormous application potential in fields such as intelligent question answering, public opinion analysis, financial forecasting, and recommendation systems.
[0003] Temporal knowledge graph reasoning, as its core research topic, primarily aims to infer missing or future facts based on known historical events. Based on the relationship between the reasoning time and known time, this task can be divided into two categories: interpolation reasoning and extrapolation reasoning. Interpolation reasoning aims to use complete information from time 0 to the current time T to fill in missing historical facts before time T. However, it cannot predict future events occurring after time T. In contrast, extrapolation reasoning is a more challenging and practically relevant task, requiring the model to predict events that may occur at time T+1 and beyond based solely on the historical subgraph from time 0 to T. Examples include predicting tomorrow's stock price trend in the stock market or predicting next month's travel peak in traffic planning. Due to its crucial role in predicting the future and supporting decision-making, this invention focuses on the extrapolation reasoning task of temporal knowledge graphs.
[0004] In recent years, researchers have proposed numerous temporal knowledge graph reasoning models, attempting to address this problem from different perspectives. Early models, such as Know-Evolve, were the first to introduce multi-relational temporal processes into the reasoning domain, focusing on modeling the continuous temporal dynamics of event occurrence. RE-NET uses recurrent neural networks to encode the neighborhood event sequence of each entity and aggregates neighbor information through an attention mechanism, but it fails to explicitly learn the evolutionary representation of the entities themselves. RE-GCN improves upon this by using a recurrent relational graph convolutional network (R-GCN) combined with gated temporal units to capture the evolutionary patterns of entities and relations in historical subgraphs, but this method still struggles to capture long-term temporal dependencies. CyGNet proposes a replication-based model that calculates the frequency of historical entities appearing under the same (subject, relation) query and tends to predict these high-frequency historical entities. However, this method is limited by the fact that the model fails when the correct answer is a completely new entity that has never appeared before. CENET builds upon CyGNet by introducing contrastive learning, focusing on emerging entities through an additional channel and weightedly fusing historical and emerging dependencies, achieving better results. However, CENET still falls short in capturing complex structural dependencies in local subgraphs.
[0005] In summary, existing temporal knowledge graph reasoning methods have significant shortcomings in terms of deep integration of temporal dynamic characteristics, adaptive selection of dynamic dependencies, and balanced prediction of periodic patterns and emerging entities. Summary of the Invention
[0006] To address the shortcomings of existing temporal knowledge graph reasoning methods in terms of dynamic time modeling and dependency selection, this invention proposes a temporal knowledge graph reasoning method and system based on dynamic dependency selection. This method aims to accurately capture periodic patterns and time decay effects through time-aware dependency modeling, dual-channel comparative learning, and relational trend statistics, and dynamically select the most relevant entity dependencies (historical entities or new entities), thereby significantly improving the accuracy of future event prediction.
[0007] This invention is achieved through the following technical solution: a temporal knowledge graph reasoning method based on dynamic dependency selection; the method specifically includes the following steps: Step 1: Perform time-aware dependency modeling on the query (s, p, t) in the stock time series knowledge graph to generate dependency representations of historical entities and new entities; where s represents a specific stock entity, p represents the relationship between stock entities, and t represents a specific time node or time interval. Step 2: Based on the dependency representation generated in Step 1, and combined with stock entity attributes, relationship features and time encoding, construct historical discriminative representation and time-aligned representation through a dual-channel contrastive learning framework, and train a binary classifier; Step 3: Calculate the proportion of new entities associated with stock correlation p within a specific time slice, as well as the stock price fluctuations, capital flow changes, and earnings forecast adjustments of the associated entities within that time slice. Calculate the new entity trend index, and then combine it with the stock market risk coefficient to obtain the trend weight. Use the trend weight to adjust the output of the binary classifier to obtain the final tendency score. Step 4: Generate a dependency mask based on the final propensity score, integrate historical dependency representations, new entity dependency representations and dependency masks, assign weights to different representations through an attention mechanism, calculate the predicted probability of each candidate stock entity associated with stock entity s through association relationship p at time t, and output the predicted entity with the highest probability.
[0008] Further, in step 1, The dependency representation of historical entities is based on stock entities that have a stable relationship p with s before query time t; The dependency of a new entity is represented by stock entities that are newly added or first form a relationship with s around query time t.
[0009] Further, in step 1, The stock time series knowledge graph is divided into a training set, a validation set, and a test set; Based on time decay and periodic similarity, the time-enhanced frequency vector of the stock entities involved in the query is calculated; Based on frequency vectors and dynamic thresholds, a binary dependency signal is generated to identify historical dependent entities and new entities. Based on the binary dependency signal, and combined with the temporal feature encoding of stock entity s, stock relationship p, and time t, historical dependency representation and new entity dependency representation are generated respectively.
[0010] Furthermore, in step 2, Based on stock entity s, stock relationship p, and time-enhanced frequency vector, a historical discriminant representation is constructed; Based on the temporal feature encoding of stock entity s, stock relationship p, and time t, and the time-enhanced frequency vector, a time-aligned representation is constructed. The binary classifier is a history discriminant classifier and a time consistency classifier; The training history discriminant classifier is used to determine the credibility of the association between the stock entity and the historical dependent entity, and the time consistency classifier is used to determine the rationality of the temporal association between the stock entity and the target entity at time t.
[0011] Furthermore, in step 2, Based on stock entity s, stock relationship p, and time-enhanced frequency vector, a historical discriminant representation is constructed; Based on the temporal feature encoding of stock entity s, stock relationship p, and time t, and the time-enhanced frequency vector, a time-aligned representation is constructed. A dual-channel contrastive loss function is constructed, where the historical discrimination channel loss focuses on the consistency constraint of the association between the stock entity and the historical dependent entity, and the time alignment channel loss focuses on the temporal adaptability constraint between the stock entity and the associated entity at time t.
[0012] Furthermore, in step 2, A binary classifier is trained by dynamically fusing dual-channel loss through time-sensitivity coefficient; The binary classifier is a history discriminant classifier and a time consistency classifier; The training history discriminant classifier is used to determine the credibility of the association between the stock entity and the historical dependent entity, and the time consistency classifier is used to determine the rationality of the temporal association between the stock entity and the target entity at time t.
[0013] Furthermore, in step 3, The statistical analysis includes the proportion of new entities associated with stock-related relationships p within a specific time frame and the changes in these entities. The specific time frame includes, but is not limited to, the past N trading days, monthly statistical periods, and policy impact periods. The new entities include newly listed related company stocks, newly established cooperative stocks, and stocks involved in sudden business linkages. The changes in these entities include the magnitude of stock price fluctuations, changes in capital flows, and adjustments to earnings forecasts of the related entities within the time frame. Based on the above statistical results, a new entity trend index is obtained through weighted calculation, wherein the weights of the weighted calculation are set according to the characteristics of the stock market. Based on the new entity trend index, the trend weight is calculated by combining the risk coefficient of the stock market; The outputs of the historical discriminant classifier and the time consistency classifier are adjusted using the trend weights to obtain the final tendency score. The higher the final tendency score, the stronger the reliability of the association between the target stock entity and s under relationship p and time t.
[0014] Furthermore, in step 4, A dynamic threshold is set based on the final tendency score, and the dynamic threshold is dynamically adjusted based on the statistical distribution of historical stock correlation data; a dependency mask is generated based on the threshold: when the score is higher than the threshold, the mask identifies the corresponding entity as a new entity dependency; when the score is lower than the threshold, the mask identifies the corresponding entity as a historical dependency. The system integrates historical dependency representation, new entity dependency representation, and masking. The historical dependency representation highlights the long-term stable correlation characteristics between stock entities, while the new entity dependency representation highlights the potential characteristics of new correlations between stock entities. The system also allocates weights for different representations through an attention mechanism. Based on the weighted fusion features, the final entity probability is calculated using the softmax function, which is the probability value of each candidate stock entity being associated with s through the association relationship p at time t; the candidate stock entity with the highest probability is selected using the argmax function, and the predicted entity is output.
[0015] A temporal knowledge graph reasoning system based on dynamic dependency selection; The system includes a dependency generation module, a dual-channel contrast learning module, an entity trend statistics module, and a prediction fusion module. The dependency generation module is used to receive stock time series datasets, perform time-aware dependency modeling on queries (s, p, t) in the stock time series knowledge graph, and generate historical dependency representations and new entity dependency representations; s represents a specific stock entity, p represents the relationship between stock entities, and t represents a specific time node or time interval; The dual-channel contrastive learning module is used to receive the dependency representation output by the dependency generation module, combine stock entity attributes, relationship features and time coding, construct historical discriminative representation and time-aligned representation through the dual-channel contrastive learning framework, and train a binary classifier. The entity trend statistics module counts the proportion of new entities associated with stock correlation p within a specific time slice, as well as the stock price fluctuations, capital flow changes, and earnings forecast adjustments of the associated entities within that time slice. It calculates the new entity trend index, and then combines it with the risk coefficient of the stock market to obtain the trend weight. The trend weight is used to adjust the output of the binary classifier to obtain the final tendency score. The prediction fusion module generates a dependency mask based on the final propensity score, merges historical dependency representations, new entity dependency representations and the mask, assigns weights to different representations through an attention mechanism, calculates the prediction probability of each candidate stock entity associated with stock entity s through association relationship p at time t, and outputs the predicted entity with the highest probability.
[0016] An electronic device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the above method.
[0017] A computer-readable storage medium for storing computer instructions that, when executed by a processor, implement the steps of the above-described method.
[0018] Beneficial effects of the invention Compared with existing technologies, this invention has the following significant advantages: First, by introducing time decay and periodic similarity functions, the model can effectively distinguish between periodic recurring events and random new events, overcoming the drawbacks of traditional methods that rely solely on static frequency statistics. Second, the innovative dual-channel contrastive learning framework combined with the entity trend statistics module can dynamically and adaptively select the most suitable dependency source (historical entity or new entity) for each query, rather than a fixed pattern. Finally, through the synergistic effect of the above mechanisms, experiments on multiple public datasets show that its prediction accuracy (e.g., MRR, Hits@1, Hits@3, Hits@10) is superior to existing mainstream time-series inference models, especially when dealing with complex scenarios where strong periodic patterns and new entities coexist. Attached Figure Description
[0019] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is a schematic diagram of the dynamic dependency selection model in an embodiment of the present invention. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Unless otherwise specified, the experimental methods used in the following examples are conventional methods. Unless otherwise specified, the materials, reagents, methods, and instruments used are all conventional materials, reagents, methods, and instruments in the art, and can be obtained commercially by those skilled in the art.
[0022] A temporal knowledge graph reasoning method based on dynamic dependency selection, the process of which is as follows: Figure 1 As shown, the specific steps include: The method is applied to stock knowledge graph reasoning: Step 1: Perform time-aware dependency modeling on queries (s, p, t) in the time-series knowledge graph to generate dependency representations of historical entities and new entities; The query (s, p, t) is defined as follows: s represents a specific stock entity (including but not limited to listed company stocks, industry index constituent stocks, and leading stocks of thematic concepts); p represents the relationship between stock entities (including but not limited to upstream and downstream relationships in the industrial chain, competitive relationships within the same industry, capital flow relationships, and performance linkage relationships); and t represents a specific time node or time interval (including but not limited to trading days, trading hours, and monthly / quarterly statistical periods). The historical dependency is generated based on stock entities that have a stable relationship p with s before the query time t. The new entity dependency is generated based on stock entities that are newly added or form a relationship p with s for the first time near the query time t (including but not limited to newly listed related company stocks, newly cooperative stocks, and stocks with sudden business linkages). The stock time-series knowledge graph (which includes stock entity attribute data, inter-stock relationship data, transaction data, performance data, and capital flow data at different time points) is divided into training set, validation set, and test set; Based on time decay and periodic similarity, the time-enhanced frequency vector of the stock entities involved in the query is calculated (the frequency vector dimension includes the frequency of correlation triggers, stock price linkage magnitude, frequency of joint capital inflows / outflows, and frequency of unidirectional changes in performance in the same direction of the historical period). Based on frequency vectors and dynamic thresholds, binary dependency signals are generated to identify historical dependent entities (stock entities that existed before query time t and have a stable relationship p with s) and new entities (stock entities that were newly added or formed a relationship p with s for the first time near query time t, including but not limited to newly listed related company stocks and newly cooperative stocks). Based on the binary dependency signal, and combined with the query subject (stock entity s), relationship (stock association relationship p), and time code (time-series feature code of time t, including transaction period type, market environment attribute, and policy cycle factor), historical dependency representation and new entity dependency representation are generated respectively.
[0023] Step 2: Based on the dependency representation generated in Step 1, and combining stock entity attributes, relationship features, and time coding (including trading period type, market environment attributes, and policy cycle factors), a historical discriminant representation (characterizing the stable association fit between stock entity s and historical dependent entities) and a time alignment representation (characterizing the temporal matching between stock entity s and potential related entities at time t) are constructed using a dual-channel contrastive learning framework. A binary classifier is then trained; the binary classifier consists of a historical discriminant classifier (determining the credibility of the association between the stock entity and historical dependent entities) and a time consistency classifier (determining the rationality of the temporal association between the stock entity and the target entity at time t). Based on the query subject (stock entity s), relationship (stock correlation relationship p), and time-enhanced frequency vector (including the frequency of triggering of stock correlation relationships in the same period of history, the magnitude of stock price linkage, the frequency of joint capital inflow / outflow, the frequency of performance changes in the same direction, etc.), a historical discriminant representation is constructed (used to characterize the adaptability features of stock entity s and historical dependent entities based on stable correlation relationship p). Based on the query subject (stock entity s), relationship (stock association p), time code (time-series feature code of time t, including transaction period type, market environment attributes, and policy cycle factor), and time-enhanced frequency vector, a time-aligned representation is constructed (used to characterize the time-series matching features of stock entity s with potential associated entities at time t). A dual-channel contrastive loss function is constructed, where the historical discrimination channel loss focuses on the consistency constraint of the association between the stock entity and the historical dependent entity, and the time alignment channel loss focuses on the temporal adaptability constraint between the stock entity and the associated entity at time t. The dual-channel loss is dynamically fused by a timeliness perception coefficient (dynamically adjusted according to the timeliness of the stock market, such as increasing the weight of the time alignment channel during periods of high market volatility and increasing the weight of the historical discrimination channel during periods of stable market conditions). This allows for the training of a historical discrimination classifier (used to determine the credibility of the association between the stock entity and the historical dependent entity) and a time consistency classifier (used to determine the rationality of the temporal association between the stock entity and the target entity at time t).
[0024] Step 3: Utilize the entity trend statistics module to receive the initial classifier results output by the stock time series knowledge graph and the dual-channel comparative learning module. Calculate the proportion of new entities associated with stock correlation relationship p within a specific time slice (including but not limited to the last N trading days, monthly statistical period, and policy impact period), as well as the entity changes such as stock price fluctuations, capital flow changes, and earnings forecast adjustments within that time slice. Calculate the new entity trend index, and then combine it with the stock market risk coefficient (such as industry volatility and overall market turnover rate) to obtain the trend weight. Use the trend weight to adjust the output of the binary classifier to obtain the final tendency score. The statistical analysis includes the proportion of new entities associated with stock-related relationships p within a specific time slice and the changes in these entities. The specific time slice includes, but is not limited to, the last N trading days (N being a positive integer from 1 to 30), monthly statistical periods, and policy impact periods. The new entities include newly listed related company stocks, newly established cooperative stocks, and stocks involved in sudden business collaborations. The changes in these entities include the magnitude of stock price fluctuations, changes in capital flows, and adjustments to earnings forecasts within the associated entity's time slice. Based on the above statistical results, a new entity trend index (used to quantify the strength of the stock correlation p in the current time slice tending to be associated with new entities) is obtained through weighted calculation. The weights of the weighted calculation are set according to the characteristics of the stock market: the weight of changes in capital flow is 0.4-0.6, the weight of stock price fluctuation is 0.2-0.3, the weight of earnings forecast adjustment is 0.1-0.2, and the weight of the new entity correlation ratio is 0.1-0.2. Based on the new entity trend index, the trend weight is calculated by combining the risk coefficient of the stock market (including industry volatility and overall market turnover rate). The outputs of the historical discriminant classifier and the time consistency classifier are adjusted using the trend weights to obtain the final tendency score. The higher the score, the stronger the reliability of the association between the target stock entity and s under relationship p and time t.
[0025] Step 4: Integrate historical dependency representations, new entity dependency representations, and trend weights. Generate a dependency mask based on the final tendency score (scores above a dynamic threshold are identified as new entity dependencies, and scores below the threshold are identified as historical dependencies). Integrate historical dependency representations (highlighting long-term stable correlations between stock entities), new entity dependency representations (highlighting potential new correlations between stock entities), and the mask. Assign weights to different representations using an attention mechanism. Calculate the predicted probability of each candidate stock entity associated with stock entity s through correlation p at time t, and output the predicted entity with the highest probability. (That is, the target stock entities associated with stock entity s through correlation p at time t, including but not limited to stocks in the industrial chain, stocks with capital linkages, stocks with synergistic performance, and stocks with sudden correlations).
[0026] A dynamic threshold is set based on the final tendency score, and the threshold is dynamically adjusted based on the statistical distribution of historical stock correlation data. A dependency mask is generated based on the threshold: when the score is higher than the threshold, the mask identifies the corresponding entity as a new entity dependency (adapting to newly added correlation scenarios in the stock market); when the score is lower than the threshold, the mask identifies the corresponding entity as a historical dependency (adapting to stable correlation scenarios in the stock market). The system integrates historical dependency representation, new entity dependency representation, and a mask. The historical dependency representation highlights the long-term stable correlation characteristics between stock entities (such as long-term industrial chain cooperation and continuous capital linkage), while the new entity dependency representation highlights the potential characteristics of new correlations between stock entities (such as sudden policy-driven correlations and short-term business cooperation). An attention mechanism is used to allocate weights to different representations: in the new entity dependency scenario, the weight of the new entity dependency representation is 0.6-0.8, and the weight of the historical dependency representation is 0.2-0.4; in the historical dependency scenario, the weight of the historical dependency representation is 0.6-0.8, and the weight of the new entity dependency representation is 0.2-0.4. Based on the weighted fusion features, the final entity probability (i.e., the probability value of each candidate stock entity being associated with s through the association relationship p at time t) is calculated by the softmax function; the candidate stock entity with the highest probability is selected by the argmax function, and the predicted entity is output (including but not limited to stocks with supporting industrial chains, stocks with capital linkage, stocks with performance synergy, and stocks with sudden related events).
[0027] In an embodiment, In step 1: the time series dataset is divided into training set, validation set and test set according to 70%, 15% and 15% respectively; Step 1.1: Calculate the time-enhanced frequency vector Its formula is:
[0028] in It is an exponentially decaying function ( >0), giving higher weight to recent events; It is a periodic similarity function ( = 365 days), used to capture cyclical changes; This is an indicator function for the existence of events. This design ensures that the statistics reflect the regularity of entity occurrence within a specific time context.
[0029] Step 1.2: Generate binary dependent signals based on frequency vectors Its formula is:
[0030] Here For historical frequency dynamic thresholds, It is a recently emerged time-enhancing factor ( Representing entities (Last occurrence time). Signal value. (o)>0 indicates historically dependent entities. (o)<0 indicates a new entity dependency.
[0031] Step 1.3: Calculate the historical dependency representation Dependency representation of new entities The formulas are as follows:
[0032] in It is a periodic encoding. This is the expanded projection matrix, used to fuse the time dimension. New entity dependency representation. Defined as:
[0033] Step 1.4: In the final inference stage, the probability of all entities at time t is predicted using the softmax function, as shown in the following formula:
[0034] The above predictions are optimized by minimizing the dependency loss function. Defined as:
[0035] Here It is an adaptive weight based on the proportion of historical entities. The loss function is the sigmoid function. This loss function forces the model to assign a high probability of success to historical entities. Scoring, assigning low scores to new entities Scoring, while maintaining timing consistency through time coding.
[0036] Step 2: Based on the dependency representation generated in Step 1, construct historical discriminative representation and time-aligned representation through a dual-channel contrastive learning framework, and train a binary classifier; Step 2.1: Construct historical discriminative representations using the original contrastive learning method. This is used to distinguish between historical entities and new entities, and its formula is:
[0037] in The timing enhancement frequency vector generated in step 1.1, These are trainable parameters. This representation is projected onto a unit sphere via an MLP to optimize contrastive learning.
[0038] Step 2.2: Construct a time-aligned representation Its formula is:
[0039] Based on the above representation, a dual-channel contrast loss function is designed.
[0040] First, the historical judgment channel Improved self-supervised contrastive loss:
[0041] in For query sets of the same category (historical / new entities), This is a set of cross-category queries. Denominator decomposition allows the model to focus more on difficult negative samples (cross-category queries that represent similarities).
[0042] Timing alignment channel Innovatively introduces time-aware positive and negative sample pairs:
[0043] Positive sample set Retrieve past events that are similar to the current query time context, among which For periodic similarity, the threshold = 0.8. Negative sample set Includes time-dissimilar samples ( <0.2) and random negative samples within the batch.
[0044] Dual-channel loss through time-sensitivity coefficient Dynamic fusion:
[0045] in, Define the dynamic weight function. These are learnable parameters. This design enables recent events ( Emphasis on historical judgment ( ), long-term events ( Emphasis on timing alignment ( ).
[0046] Step 2.3: Train the history discriminant classifier and the time consistency classifier, whose outputs are as follows: in, This is the sigmoid function.
[0047] Step 3: Calculate the trend weight of the relationship within a specific time slice using the entity trend statistics module, adjust the confidence level of the classifier output, and obtain the final propensity score; Step 3.1: Calculate the relationship In time slice New Entity Trend Index Its formula is: in, For relationship exist The number of times new entities are linked internally. For relationship exist Total number of occurrences within, The standard deviation of the number of changes in the entity. Average frequency; Step 3.2: Calculate the trend weight Its formula is: Step 3.3: Adjust the classifier output confidence level to obtain the final propensity score. Its formula is:
[0048] Step 4: Integrate historical dependency representations, new entity dependency representations, and trend weights to generate the final entity prediction probability and output the predicted entity.
[0049] Step 4.1: Generate a dependency mask based on the final propensity score Its formula is: Step 4.2: Integrate historical dependency representations, new entity dependency representations, and masks to calculate the final entity probability. Its formula is: in, For preliminary entity probabilities, These are adjustable weight parameters; Step 4.3: Output the predicted entity using the argmax function. Its formula is:
[0050] Figure 2 This is a schematic diagram of the dynamic dependency selection model in this embodiment of the invention, illustrating the collaborative workflow of three core modules: time-aware dependency generation, dual-channel comparative learning, and entity trend statistics. The first part is the dependency generation module, the second part is the trend statistics module, and the third part is the dual-channel comparative learning module.
[0051] A temporal knowledge graph reasoning system based on dynamic dependency selection. The system includes a dependency generation module, a dual-channel contrast learning module, an entity trend statistics module, and a prediction fusion module. The dependency generation module is used to perform time-aware dependency modeling on queries (s, p, t) in the time-series knowledge graph, generating dependency representations of historical entities and new entities; s represents a specific stock entity (including but not limited to listed company stocks, industry index constituent stocks, and leading stocks of thematic concepts), p represents the relationship between stock entities (including but not limited to upstream and downstream relationships in the industrial chain, competitive relationships within the same industry, capital flow relationships, and performance linkage relationships), and t represents a specific time node or time interval (including but not limited to trading days, trading hours, monthly, and quarterly statistical periods); the historical dependency representation is generated based on stock entities that have a stable relationship p with s before query time t, and the new entity dependency representation is generated based on stock entities that are newly added or form a relationship p with s for the first time near query time t (including but not limited to newly listed related company stocks, newly cooperative stocks, and stocks with sudden business linkages); The dual-channel contrastive learning module receives the dependency representation output by the dependency generation module. Combining stock entity attributes, relationship features, and time encoding (including trading period type, market environment attributes, and policy cycle factors), it constructs a historical discriminant representation (characterizing the stable association fit between stock entity s and historical dependent entities) and a time alignment representation (characterizing the temporal matching between stock entity s and potential related entities at time t) through the dual-channel contrastive learning framework. It also trains a historical discriminant classifier (to determine the credibility of the association between stock entities and historical dependent entities) and a time consistency classifier (to determine the rationality of the temporal association between stock entities and target entities at time t). The entity trend statistics module is used to receive the stock time series dataset and the initial classifier results output by the dual-channel contrast learning module. It calculates the proportion of new entities associated with stock correlation p within a specific time slice (including but not limited to the last N trading days, monthly statistical period, and policy impact period), as well as the entity changes such as stock price fluctuations, capital flow changes, and earnings forecast adjustments within that time slice. It calculates the new entity trend index, and then combines it with the stock market risk coefficient (such as industry volatility and overall market turnover rate) to obtain the trend weight. The trend weight is used to adjust the output of the two classifiers in the dual-channel contrast learning module to obtain the final tendency score. The prediction fusion module receives the final tendency score output by the entity trend statistics module and two types of dependency representations output by the dependency generation module. It generates a dependency mask based on the final tendency score (a score higher than a dynamic threshold is identified as a new entity dependency, and a score lower than the threshold is identified as a historical dependency). It fuses the historical dependency representation (highlighting the long-term stable correlation characteristics between stock entities), the new entity dependency representation (highlighting the potential for new correlation characteristics between stock entities), and the mask. It assigns weights to different representations through an attention mechanism, calculates the predicted probability of each candidate stock entity associated with stock entity s through the correlation relationship p at time t, and outputs the predicted entity with the highest probability (including but not limited to stocks with supporting industrial chains, stocks with capital linkage, stocks with performance synergy, and stocks with sudden correlation).
[0052] By introducing a time decay mechanism and a periodic similarity metric, the model is able to distinguish between periodically repeating events and new entity events, thereby reconstructing the dependency generation process. Specifically, the calculation of the time-enhanced frequency vector fully considers the temporal proximity and periodic regularity of events, providing a reliable basis for subsequent dependency partitioning.
[0053] By employing a dual-channel contrastive learning framework, the model simultaneously optimizes both historical discrimination and temporal alignment, enabling it to accurately identify historically dependent entities while capturing periodic temporal evolution patterns. This dual-channel design overcomes the limitation of a single representation in handling two different types of dependencies.
[0054] The entity trend statistics module dynamically captures the dependency preferences of different relationships on new and old entities over different time periods, thus providing important supplementary information for the final dependency selection. This module works in conjunction with the dual-channel contrastive learning framework to jointly complete the final dependency selection decision.
[0055] An electronic device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the above method.
[0056] A computer-readable storage medium for storing computer instructions that, when executed by a processor, implement the steps of the above-described method.
[0057] The memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM). It should be noted that the memory of the methods described in this invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0058] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired means such as coaxial cable, optical fiber, digital subscriber line, DSL, or wireless means such as infrared, wireless, microwave, etc. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium such as a floppy disk, hard disk, magnetic tape; an optical medium such as a high-density digital video disc, DVD; or a semiconductor medium such as a solid-state disk, SSD, etc.
[0059] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0060] It should be noted that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiments can be completed by the integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied as execution by a hardware decoding processor, or as execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above methods.
[0061] The present invention provides a detailed description of a temporal knowledge graph reasoning method and system based on dynamic dependency selection, and elucidates the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A temporal knowledge graph reasoning method based on dynamic dependency selection, characterized in that: The method specifically includes the following steps: Step 1: Perform time-aware dependency modeling on the query (s, p, t) in the stock time series knowledge graph to generate dependency representations of historical entities and new entities; where s represents a specific stock entity, p represents the relationship between stock entities, and t represents a specific time node or time interval. Step 2: Based on the dependency representation generated in Step 1, and combined with stock entity attributes, relationship features and time encoding, construct historical discriminative representation and time-aligned representation through a dual-channel contrastive learning framework, and train a binary classifier; Step 3: Calculate the proportion of new entities associated with stock correlation p within a specific time slice, as well as the stock price fluctuations, capital flow changes, and earnings forecast adjustments of the associated entities within that time slice. Calculate the new entity trend index, and then combine it with the stock market risk coefficient to obtain the trend weight. Use the trend weight to adjust the output of the binary classifier to obtain the final tendency score. Step 4: Generate a dependency mask based on the final propensity score, integrate historical dependency representations, new entity dependency representations and dependency masks, assign weights to different representations through an attention mechanism, calculate the predicted probability of each candidate stock entity associated with stock entity s through association relationship p at time t, and output the predicted entity with the highest probability.
2. The method according to claim 1, characterized in that: In step 1, The dependency representation of historical entities is based on stock entities that have a stable relationship p with s before query time t; The dependency representation of new entities is based on stock entities that are newly added or first form a relationship with s around query time t; The stock time series knowledge graph is divided into a training set, a validation set, and a test set; Based on time decay and periodic similarity, the time-enhanced frequency vector of the stock entities involved in the query is calculated; Based on frequency vectors and dynamic thresholds, a binary dependency signal is generated to identify historical dependent entities and new entities. Based on the binary dependency signal, and combined with the temporal feature encoding of stock entity s, stock relationship p, and time t, historical dependency representation and new entity dependency representation are generated respectively.
3. The method according to claim 2, characterized in that: In step 2, Based on stock entity s, stock relationship p, and time-enhanced frequency vector, a historical discriminant representation is constructed; Based on the temporal feature encoding of stock entity s, stock relationship p, and time t, and the time-enhanced frequency vector, a time-aligned representation is constructed. The binary classifier is a history discriminant classifier and a time consistency classifier; The training history discriminant classifier is used to determine the credibility of the association between the stock entity and the historical dependent entity, and the time consistency classifier is used to determine the rationality of the temporal association between the stock entity and the target entity at time t.
4. The method according to claim 3, characterized in that: In step 2, Based on stock entity s, stock relationship p, and time-enhanced frequency vector, a historical discriminant representation is constructed; Based on the temporal feature encoding of stock entity s, stock relationship p, and time t, and the time-enhanced frequency vector, a time-aligned representation is constructed. A dual-channel contrastive loss function is constructed, where the historical discrimination channel loss focuses on the consistency constraint of the association between the stock entity and the historical dependent entity, and the time alignment channel loss focuses on the temporal adaptability constraint between the stock entity and the associated entity at time t.
5. The method according to claim 4, characterized in that: In step 2, A binary classifier is trained by dynamically fusing dual-channel loss through time-sensitivity coefficient; The binary classifier is a history discriminant classifier and a time consistency classifier; The training history discriminant classifier is used to determine the credibility of the association between the stock entity and the historical dependent entity, and the time consistency classifier is used to determine the rationality of the temporal association between the stock entity and the target entity at time t.
6. The method according to claim 5, characterized in that: In step 3, The statistical analysis includes the proportion of new entities associated with stock-related relationships p within a specific time frame and the changes in these entities. The specific time frame includes, but is not limited to, the past N trading days, monthly statistical periods, and policy impact periods. The new entities include newly listed related company stocks, newly established cooperative stocks, and stocks involved in sudden business linkages. The changes in these entities include the magnitude of stock price fluctuations, changes in capital flows, and adjustments to earnings forecasts of the related entities within the time frame. Based on the above statistical results, a new entity trend index is obtained through weighted calculation, wherein the weights of the weighted calculation are set according to the characteristics of the stock market. Based on the new entity trend index, the trend weight is calculated by combining the risk coefficient of the stock market; The outputs of the historical discriminant classifier and the time consistency classifier are adjusted using the trend weights to obtain the final tendency score. The higher the final tendency score, the stronger the reliability of the association between the target stock entity and s under relationship p and time t.
7. The method according to claim 6, characterized in that: In step 4, A dynamic threshold is set based on the final tendency score, and the dynamic threshold is dynamically adjusted based on the statistical distribution of historical stock correlation data; a dependency mask is generated based on the threshold: when the score is higher than the threshold, the mask identifies the corresponding entity as a new entity dependency; when the score is lower than the threshold, the mask identifies the corresponding entity as a historical dependency. The method integrates historical dependency representation, new entity dependency representation, and mask. The historical dependency representation highlights the long-term stable correlation characteristics between stock entities, while the new entity dependency representation highlights the potential characteristics of new correlations between stock entities. Weights are assigned to different representations using an attention mechanism; Based on the weighted fusion features, the final entity probability is calculated using the softmax function, which is the probability value of each candidate stock entity being associated with s through the association relationship p at time t; the candidate stock entity with the highest probability is selected using the argmax function, and the predicted entity is output.
8. A temporal knowledge graph reasoning system based on dynamic dependency selection, characterized in that: The system is used to execute the temporal knowledge graph reasoning method based on dynamic dependency selection as described in any one of claims 1 to 7; The system includes a dependency generation module, a dual-channel contrast learning module, an entity trend statistics module, and a prediction fusion module. The dependency generation module is used to receive stock time series datasets, perform time-aware dependency modeling on queries (s, p, t) in the stock time series knowledge graph, and generate historical dependency representations and new entity dependency representations; s represents a specific stock entity, p represents the relationship between stock entities, and t represents a specific time node or time interval. The dual-channel contrastive learning module is used to receive the dependency representation output by the dependency generation module, combine stock entity attributes, relationship features and time coding, construct historical discriminative representation and time-aligned representation through the dual-channel contrastive learning framework, and train a binary classifier. The entity trend statistics module counts the proportion of new entities associated with stock correlation p within a specific time slice, as well as the stock price fluctuations, capital flow changes, and earnings forecast adjustments of the associated entities within that time slice. It calculates the new entity trend index, and then combines it with the risk coefficient of the stock market to obtain the trend weight. The trend weight is used to adjust the output of the binary classifier to obtain the final tendency score. The prediction fusion module generates a dependency mask based on the final propensity score, merges historical dependency representations, new entity dependency representations and the mask, assigns weights to different representations through an attention mechanism, calculates the prediction probability of each candidate stock entity associated with stock entity s through association relationship p at time t, and outputs the predicted entity with the highest probability.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium for storing computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 7.