Time coding method based on time continuity and periodic characteristics
Through the time encoding method based on time continuity and periodic features, the explicit modeling and weighting fusion of trigonometric functions are used to solve the problem of incomplete time encoding in the knowledge graph, the quality of entity modeling is improved, and the storage logs are improved through multiple encryption Security.
Patent Information
- Application Number
- CN202411064257.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2025-01-07
AI Technical Summary
The existing knowledge graph completion model is difficult to effectively model the time continuity and periodic characteristics of entities, resulting in incomplete time coding of time knowledge graphs and insufficient physical modeling quality.
Using a time encoding method based on time continuity and periodic features, the time difference is calculated and parameterized into a multi-dimensional vector, and the continuous time features and periodic time features are obtained by explicit modeling of trigonometric functions, weighted fusion and embedding with entity, Generate dynamic entity embedding representations, completing time encoding.
Improves the comprehensiveness of time knowledge graph time coding and solid modeling quality, better capture time continuity and periodic patterns, and improves security by encrypting storage logs.
Smart Images

Figure CN119271820A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of knowledge graphs, and particularly to a time encoding method based on time continuity and periodic characteristics. Background Art
[0002] Knowledge graphs can be used to store a large amount of human knowledge and facts, which represent knowledge and facts in the form of triples (e s , r, e o ), where e s represents the head entity, r represents the relationship, and e o represents the tail entity, such as (Yao*, nationality, China). At present, many large-scale knowledge graphs have been constructed in this field, such as knowledge graphs like WIKI and YAGO. These knowledge graphs contain a vast amount of information and can provide data support for downstream applications, such as intelligent question-and-answer robots, recommendation algorithms, etc. However, there are still various problems of missing facts in these knowledge graphs, which has promoted the development of knowledge graph completion technology.
[0003] The core purpose of knowledge graph completion is to establish potential connections between entities (head entities, tail entities) that have not been captured in the knowledge graph. To achieve this goal, existing knowledge graph completion models learn the potential connections between entities, such as the connection structure of the knowledge graph and the text information of entities in the graph, to obtain entity and relationship embeddings with rich semantic information, so as to accurately capture the complex connections between entities and complete the knowledge graph completion.
[0004] In real life, many pieces of information change over time, and this fact only holds at a specific time. The answers to this query (knowledge graph) in the two time intervals [2011, 2016] and [2019, 2022] are different. For this reason, time knowledge graphs are proposed, which add a time dimension on the basis of triples and construct a knowledge graph structure with quadruples (e s , r, e o , t) as the basic unit, that is, to construct a dynamic knowledge graph with time attributes (time knowledge graph, TKG).
[0005] The time knowledge graph is not a whole graph structure, but is divided into multiple small graphs according to time stamps, also called subgraphs. Each subgraph records the facts that occur at the same time stamp, and entities will exist in multiple subgraphs. Entities will have different historical facts in different subgraphs, and these facts all carry time stamps and have specific patterns related to the time stamps. For example, in the competition for Oscar movie awards, the process of a movie from nomination to possible winning reflects a kind of time continuity and the continuity pattern of facts; while the quarterly update of TV dramas shows a kind of time periodicity and the periodic pattern of facts.
[0006] Traditional knowledge graph completion models usually evolve historical facts of entities according to time series to model entity embedding. This is an implicit modeling of temporal information. Although it can model entity continuity patterns, it cannot model entity periodic patterns well. For example, CyGNet models the frequency of repeated occurrence of facts in history and models the temporal characteristics of entity facts; KnowEvolve proposes a deep evolutionary network architecture to learn the dynamic nonlinear evolution of entity embeddings and applies a multivariate point process framework to simulate the occurrence of facts in continuous time; RE-GCN implicitly models the temporal characteristics of entities according to time series; TiRGN combines local recurrent graph encoders and global historical encoder networks to capture the historical dependencies of adjacent timestamps and collect recurring historical facts to fully understand the historical interactions and dependencies between entities; TECHS designs a temporal encoder and a logical decoder to achieve differentiable rule learning and reasoning on knowledge graphs.
[0007] Therefore, how to provide a time encoding method based on time continuity and periodic characteristics to improve the comprehensiveness of time encoding of temporal knowledge graphs and thereby improve the quality of entity modeling has become a technical problem that needs to be solved urgently. Summary of the invention
[0008] The technical problem to be solved by the present invention is to provide a time coding method based on time continuity and periodic characteristics, so as to improve the comprehensiveness of time coding of time knowledge graphs and thus improve the quality of entity modeling.
[0009] The present invention is implemented as follows: a time encoding method based on time continuity and periodic characteristics, comprising the following steps:
[0010] Step S1, the server obtains the current time and the query time of the input time knowledge graph, and calculates the time difference based on the current time and the query time;
[0011] Step S2, parameterizing the time difference to map it into a multi-dimensional vector;
[0012] Step S3, based on trigonometric functions with continuity and periodicity characteristics, explicitly modeling the multidimensional vector to obtain continuous time features and periodic time features;
[0013] Step S4, performing weighted fusion on the continuous time features and the periodic time features to obtain an explicit time embedding representation;
[0014] Step S5: Obtain entity embedding of the temporal knowledge graph, and concatenate the entity embedding and the temporal embedding representation to obtain a dynamic entity embedding representation to complete temporal encoding.
[0015] Furthermore, the step S5 further includes:
[0016] The server performs dynamic entity modeling based on the dynamic entity embedding representation and outputs a modeling result.
[0017] Furthermore, the step S5 further includes:
[0018] The server generates a modeling log based on the current time, query time, entity embedding, dynamic entity embedding representation, and modeling results, and encrypts and stores the modeling log.
[0019] Furthermore, the encrypted storage of the modeling log is specifically as follows:
[0020] Create a pair of public keys and private keys, perform hash calculation on the modeling log to obtain a hash value, encrypt the public key through the DES algorithm to obtain a key, encrypt the modeling log through the private key to obtain primary encrypted data, encrypt the primary encrypted data, the key and the hash value through the RC2 algorithm to obtain secondary encrypted data, shift each character in the secondary encrypted data to the right by a preset distance to obtain third-level encrypted data, encrypt the third-level encrypted data through the RSA algorithm to obtain an encrypted log, and perform distributed storage on the encrypted log.
[0021] Furthermore, in step S1, the time difference is calculated based on the current time and the query time as follows:
[0022] Δt=|tt q |;
[0023] Where Δt represents the time difference; t represents the current time; t q Indicates the query time.
[0024] Furthermore, in step S2, the calculation process of the multidimensional vector is:
[0025] Δt'=linear(param(Δt));
[0026] Among them, Δt' represents a multidimensional vector; linear() represents a linear function; param() represents a parameterized function; Δt represents the time difference.
[0027] Furthermore, in step S3, the explicit modeling of the multidimensional vector to obtain the continuous time feature and the periodic time feature is specifically:
[0028] Δt sin = Sin(Δt');
[0029] Δt tanh = TanH(Δt');
[0030] Among them, Δt sin represents the continuous time characteristic; Δt tanh represents the periodic time characteristic; Sin() represents the sine; TanH() represents the hyperbolic tangent function; Δt' represents a multidimensional vector.
[0031] Furthermore, in step S4, the calculation process of the time embedding representation is:
[0032] φ(Δt)=αΔt sin +(1-α)Δt tanh ;
[0033] α=sigmoid(w[Δt sin ||Δt tanh ]);
[0034] Where φ(Δt) represents the temporal embedding representation; α represents the gating threshold; Δt sin represents the continuous time characteristic; Δt tanh represents the periodic time feature; sigmoid() represents the activation function; w represents the learnable parameter matrix; || represents the splicing parameter.
[0035] The advantages of the present invention are:
[0036] 1. By obtaining the current moment and the query moment of the input time knowledge graph, the time difference is calculated based on the current moment and the query moment, the time difference is parameterized to map it into a multidimensional vector, and then based on trigonometric functions with continuity and periodicity characteristics, the multidimensional vector is explicitly modeled to obtain continuous time features and periodic time features, and the continuous time features and periodic time features are weighted fused to obtain an explicit time embedding representation, and finally the entity embedding of the time knowledge graph is obtained, and the entity embedding and the time embedding representation are spliced to obtain a dynamic entity embedding representation to complete the time coding; that is, the multidimensional vector is explicitly modeled based on trigonometric functions to obtain continuous time features with continuity and periodic time features with periodicity, and then the continuous time features and periodic time features are weighted fused and spliced to the entity embedding, so that the time coding combines the time continuity and periodicity characteristics, and ultimately greatly improves the comprehensiveness of the time coding of the time knowledge graph, and thus greatly improves the quality of entity modeling.
[0037] 2. Generate a modeling log based on the current time, query time, entity embedding, dynamic entity embedding representation, and modeling results, and encrypt and store the modeling log to facilitate later tracing.
[0038] 3. Create a pair of public and private keys, perform hash calculation on the modeling log to obtain a hash value, encrypt the public key with the DES algorithm to obtain the key, encrypt the modeling log with the private key to obtain the first-level encrypted data, encrypt the first-level encrypted data, the key and the hash value with the RC2 algorithm to obtain the second-level encrypted data, shift each character in the second-level encrypted data to the right by a preset distance to obtain the third-level encrypted data, encrypt the third-level encrypted data with the RSA algorithm to obtain the encrypted log, and store the encrypted log in a distributed manner. If you don’t know the corresponding encryption algorithm or data transformation rule, you will not be able to crack the encrypted log. At least 7 security measures have been taken (public and private keys, hash calculation, DES algorithm, RC2 algorithm, right shift, RSA algorithm, distributed storage), which greatly improves the security of modeling log storage. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.
[0040] Figure 1 It is a flow chart of a time encoding method based on time continuity and periodic characteristics of the present invention. DETAILED DESCRIPTION
[0041] The technical solution in the embodiments of the present application has the following overall idea: explicitly modeling multidimensional vectors based on trigonometric functions to obtain continuous time features with continuity and periodic time features with periodic characteristics, and then weighted fusion and concatenation of the continuous time features and periodic time features to embed entities, so that the time coding combines time continuity and periodic features, thereby improving the comprehensiveness of the time coding of the time knowledge graph and thereby improving the quality of entity modeling.
[0042] Please refer to Figure 1 As shown, a preferred embodiment of a time encoding method based on time continuity and periodic characteristics of the present invention comprises the following steps:
[0043] Step S1, the server obtains the current time and the query time of the input time knowledge graph, and calculates the time difference based on the current time and the query time; the time difference is calculated to obtain the time continuity and periodicity characteristics based on the query time;
[0044] Step S2, parameterizing the time difference to map it into a multi-dimensional vector for fine-grained representation of time information;
[0045] Step S3, based on trigonometric functions with continuity and periodicity characteristics, explicitly modeling the multidimensional vector to obtain continuous time features and periodic time features;
[0046] Step S4, performing weighted fusion on the continuous time features and the periodic time features to obtain an explicit time embedding representation;
[0047] Step S5: Obtain entity embedding of the temporal knowledge graph, and concatenate the entity embedding and the temporal embedding representation to obtain a dynamic entity embedding representation to complete temporal encoding.
[0048] The step S5 further comprises:
[0049] The server performs dynamic entity modeling based on the dynamic entity embedding representation and outputs a modeling result.
[0050] The step S5 further comprises:
[0051] The server generates a modeling log based on the current time, query time, entity embedding, dynamic entity embedding representation, and modeling results, and encrypts and stores the modeling log.
[0052] By generating a modeling log based on the current moment, query time, entity embedding, dynamic entity embedding representation, and modeling results, the modeling log is encrypted and stored for easy traceability later.
[0053] The encrypted storage of the modeling log is specifically as follows:
[0054] Create a pair of public keys and private keys, perform hash calculation on the modeling log to obtain a hash value, encrypt the public key through the DES algorithm to obtain a key, encrypt the modeling log through the private key to obtain primary encrypted data, encrypt the primary encrypted data, the key and the hash value through the RC2 algorithm to obtain secondary encrypted data, shift each character in the secondary encrypted data to the right by a preset distance to obtain third-level encrypted data, encrypt the third-level encrypted data through the RSA algorithm to obtain an encrypted log, and perform distributed storage on the encrypted log.
[0055] By creating a pair of public and private keys, hash calculation is performed on the modeling log to obtain a hash value, the public key is encrypted by the DES algorithm to obtain the key, the modeling log is encrypted by the private key to obtain the first-level encrypted data, the first-level encrypted data, the key and the hash value are encrypted by the RC2 algorithm to obtain the second-level encrypted data, each character in the second-level encrypted data is shifted right by a preset distance to obtain the third-level encrypted data, the third-level encrypted data is encrypted by the RSA algorithm to obtain the encrypted log, and the encrypted log is distributedly stored. If the corresponding encryption algorithm or data transformation rule is not known, the encrypted log cannot be cracked. At least 7 security measures (public and private keys, hash calculation, DES algorithm, RC2 algorithm, right shift, RSA algorithm, distributed storage) have been taken, which greatly improves the security of modeling log storage.
[0056] In step S1, the time difference is calculated based on the current time and the query time as follows:
[0057] Δt=|tt q |;
[0058] Where Δt represents the time difference; t represents the current time; t q Indicates the query time.
[0059] In step S2, the calculation process of the multidimensional vector is:
[0060] Δt'=linear(param(Δt));
[0061] Among them, Δt' represents a multidimensional vector; linear() represents a linear function; param() represents a parameterized function; Δt represents the time difference.
[0062] In step S3, the explicit modeling of the multidimensional vector to obtain the continuous time feature and the periodic time feature is specifically:
[0063] Δt sin = Sin(Δt');
[0064] Δt tanh = TanH(Δt');
[0065] Among them, Δt sin represents the continuous time characteristic; Δt tanh represents the periodic time characteristic; Sin() represents the sine; TanH() represents the hyperbolic tangent function; Δt' represents a multidimensional vector.
[0066] In step S4, the calculation process of the time embedding representation is:
[0067] φ(Δt)=αΔt sin +(1-α)Δt tanh ;
[0068] α=sigmoid(w[Δt sin ||Δt tanh ]);
[0069] Where φ(Δt) represents the temporal embedding representation; α represents the gating threshold; Δt sin represents the continuous time characteristic; Δt tanh represents the periodic time feature; sigmoid() represents the activation function; w represents the learnable parameter matrix; || represents the splicing parameter.
[0070] In summary, the advantages of the present invention are:
[0071] 1. By obtaining the current moment and the query moment of the input time knowledge graph, the time difference is calculated based on the current moment and the query moment, the time difference is parameterized to map it into a multidimensional vector, and then based on trigonometric functions with continuity and periodicity characteristics, the multidimensional vector is explicitly modeled to obtain continuous time features and periodic time features, and the continuous time features and periodic time features are weighted fused to obtain an explicit time embedding representation, and finally the entity embedding of the time knowledge graph is obtained, and the entity embedding and the time embedding representation are spliced to obtain a dynamic entity embedding representation to complete the time coding; that is, the multidimensional vector is explicitly modeled based on trigonometric functions to obtain continuous time features with continuity and periodic time features with periodicity, and then the continuous time features and periodic time features are weighted fused and spliced to the entity embedding, so that the time coding combines the time continuity and periodicity characteristics, and ultimately greatly improves the comprehensiveness of the time coding of the time knowledge graph, and thus greatly improves the quality of entity modeling.
[0072] 2. Generate a modeling log based on the current time, query time, entity embedding, dynamic entity embedding representation, and modeling results, and encrypt and store the modeling log to facilitate later tracing.
[0073] 3. Create a pair of public and private keys, perform hash calculation on the modeling log to obtain a hash value, encrypt the public key with the DES algorithm to obtain the key, encrypt the modeling log with the private key to obtain the first-level encrypted data, encrypt the first-level encrypted data, the key and the hash value with the RC2 algorithm to obtain the second-level encrypted data, shift each character in the second-level encrypted data to the right by a preset distance to obtain the third-level encrypted data, encrypt the third-level encrypted data with the RSA algorithm to obtain the encrypted log, and store the encrypted log in a distributed manner. If you don’t know the corresponding encryption algorithm or data transformation rule, you will not be able to crack the encrypted log. At least 7 security measures have been taken (public and private keys, hash calculation, DES algorithm, RC2 algorithm, right shift, RSA algorithm, distributed storage), which greatly improves the security of modeling log storage.
[0074] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included in the scope of protection of the claims of the present invention.
Claims
1. A time coding method based on time continuity and periodic characteristics, characterized in that: The steps include: Step S1, the server obtains the current time and the query time of the input time knowledge graph, and calculates the time difference based on the current time and the query time; Step S2, parameterizing the time difference to map it into a multi-dimensional vector; Step S3, based on trigonometric functions with continuity and periodicity characteristics, explicitly modeling the multidimensional vector to obtain continuous time features and periodic time features; Step S4, performing weighted fusion on the continuous time features and the periodic time features to obtain an explicit time embedding representation; Step S5: Obtain entity embedding of the temporal knowledge graph, and concatenate the entity embedding and the temporal embedding representation to obtain a dynamic entity embedding representation to complete temporal encoding.
2. A time encoding method based on time continuity and periodic characteristics as claimed in claim 1, characterized in that: The step S5 further comprises: The server performs dynamic entity modeling based on the dynamic entity embedding representation and outputs a modeling result.
3. A time encoding method based on time continuity and periodic characteristics as claimed in claim 2, characterized in that: The step S5 further comprises: The server generates a modeling log based on the current time, query time, entity embedding, dynamic entity embedding representation, and modeling results, and encrypts and stores the modeling log.
4. A time encoding method based on time continuity and periodic characteristics as claimed in claim 3, characterized in that: The encrypted storage of the modeling log is specifically as follows: Create a pair of public keys and private keys, perform hash calculation on the modeling log to obtain a hash value, encrypt the public key through the DES algorithm to obtain a key, encrypt the modeling log through the private key to obtain primary encrypted data, encrypt the primary encrypted data, the key and the hash value through the RC2 algorithm to obtain secondary encrypted data, shift each character in the secondary encrypted data to the right by a preset distance to obtain third-level encrypted data, encrypt the third-level encrypted data through the RSA algorithm to obtain an encrypted log, and perform distributed storage on the encrypted log.
5. A time encoding method based on time continuity and periodic characteristics as claimed in claim 1, characterized in that: In step S1, the time difference is calculated based on the current time and the query time as follows: Δt=|t-t q |; Where Δt represents the time difference; t represents the current time; t q Indicates the query time.
6. A time encoding method based on time continuity and periodic characteristics as claimed in claim 1, characterized in that: In step S2, the calculation process of the multidimensional vector is: Δt'=linear(param(Δt)); Among them, Δt' represents a multidimensional vector; linear() represents a linear function; param() represents a parameterized function; Δt represents the time difference.
7. A time encoding method based on time continuity and periodic characteristics as claimed in claim 1, characterized in that: In step S3, the explicit modeling of the multidimensional vector to obtain the continuous time feature and the periodic time feature is specifically: Δt sin =Sin(Δt'); Δt tanh =TanH(Δt'); Among them, Δt sin represents the continuous time characteristic; Δt tanh represents the periodic time characteristic; Sin() represents the sine; TanH() represents the hyperbolic tangent function; Δt' represents a multidimensional vector.
8. A time encoding method based on time continuity and periodic characteristics as claimed in claim 1, characterized in that: In step S4, the calculation process of the time embedding representation is: φ(Δt)=αΔt sin +(1-a)Δt tanh ; α=sigmoid(w[Δt sin ||Δt tanh ]); Where φ(Δt) represents the temporal embedding representation; α represents the gating threshold; Δt sin represents the continuous time characteristic; Δt tanh represents the periodic time feature; sigmoid() represents the activation function; w represents the learnable parameter matrix; || represents the splicing parameter.
Citation Information
Patent Citations
Time sequence knowledge graph representation learning method based on co-evolution modeling
CN112860918A
Single-sample time sequence knowledge graph extrapolation calculation method based on historical trend
CN117575023A
Time sequence knowledge graph reasoning method
CN117787399A