Method, device and electronic device for completing time series knowledge graph based on QR decomposition

By embedding and representing the head entities, relationships, tail entities, and timestamps of the temporal knowledge graph based on the QR decomposition method, the problem of low completion speed and accuracy of the temporal knowledge graph in the existing technology is solved, and a fast and accurate Dynamic knowledge graph construction and completion.

CN114691890BActive Publication Date: 2024-09-06NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210406181.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-18
Publication Date
2024-09-06
Estimated Expiration
2042-04-18

AI Technical Summary

Technical Problem

The existing time series knowledge graph completion methods are not very fast and accurate, making it difficult to effectively construct dynamic knowledge graphs, especially for sparse or incompletely mined implicit relationships.

Method used

A method based on QR decomposition is used to obtain the initial embedding representation of the head entity, relationship, tail entity, and timestamp in the time series knowledge graph. QR decomposition is performed through Gram-Schmidt orthogonalization to obtain the real and imaginary orthogonal matrices, and Fuse it with the initial embedding representation of the head entity, relationship, and tail entity to generate a fusion time embedding representation. Combined with the predetermined scoring function and loss function, the missing content is predicted to complete the knowledge graph completion.

Benefits of technology

It achieves the rapid and accurate construction of dynamic knowledge graphs, improves the integrity and interpretability of knowledge graphs, and improves the efficiency and effect of time-series knowledge graph completion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691890B
    Figure CN114691890B
Patent Text Reader

Abstract

The present application relates to a method, device and electronic device for completing a time series knowledge graph based on QR decomposition. The method obtains the initial embedding representation of the head entity, relationship, tail entity and timestamp in the time series knowledge graph, and the initial embedding representation is in a complex form; the real part and the imaginary part of the initial embedding representation of the timestamp are respectively subjected to QR decomposition by Gram-Schmidt orthogonalization to obtain two orthogonal matrices corresponding to the real part and the imaginary part of the timestamp, and the initial embedding representation of the head entity, relationship and tail entity are fused according to the two orthogonal matrices to obtain a fused time embedding representation of the head entity, relationship and tail entity, and the score of the knowledge in the time series knowledge graph to be completed is calculated according to the fused time embedding representation, and the missing content in the time series knowledge graph to be completed is predicted by the score to complete the time series knowledge graph. The method can accurately and quickly construct a dynamic knowledge graph, and has better practical significance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of time series knowledge graphs, and in particular to a method, device and electronic device for completing a time series knowledge graph based on QR decomposition. Background Art

[0002] Knowledge Graph, known as knowledge domain visualization or knowledge domain mapping map in the library and information industry, is a series of various graphics that show the development process and structural relationship of knowledge. It uses visualization technology to describe knowledge resources and their carriers, and mine, analyze, construct, draw and display knowledge and their mutual connections. Knowledge Graph is a modern theory that combines the theories and methods of applied mathematics, graphics, information visualization technology, information science and other disciplines with methods such as metrology citation analysis and co-occurrence analysis, and uses visualized graphs to vividly display the core structure, development history, frontier fields and overall knowledge architecture of the discipline to achieve the purpose of multidisciplinary integration.

[0003] Knowledge graphs display complex knowledge domains through data mining, information processing, knowledge measurement, and graph drawing, revealing the dynamic development laws of knowledge domains and providing practical and valuable references for subject research. Most current knowledge graph research focuses on static knowledge graphs that do not change over time, while time-varying knowledge graphs are less explored. However, temporal information is very important because much structured knowledge is only valid within a specific period of time, and changes in facts follow a time series. Recent research has begun to incorporate temporal information into knowledge graph learning and knowledge graph completion, which is called temporal knowledge graphs.

[0004] The knowledge graph completion algorithm can make the knowledge graph more complete, especially since the knowledge graph is generally constructed manually or directly learned through representation learning. Although the features constructed by manual intervention usually have good interpretability, it obviously consumes too many resources. Representation learning, that is, automatically learning new representations from data through machine learning algorithms, can automatically construct features according to tasks with less manual intervention, but the interpretability of the constructed features is usually poor. Recently, there is a method that combines these two construction methods to integrate prior knowledge (such as rules, entity types, multi-hop paths, etc.) into representation learning. Therefore, for such incomplete knowledge graphs obtained manually or semi-automatically, especially sparse or many implicit relationships that have not been mined, if there is a way to complete them to a certain extent, the knowledge graph can be made more complete.

[0005] Knowledge Graph Completion (KGC) is currently mainly abstracted into a prediction problem, that is, predicting the missing part of the triple. Therefore, it can be divided into three subtasks: head entity prediction; relationship prediction; tail entity prediction. At the same time, according to whether new entities or new relationships can be processed, knowledge graph completion algorithms can be divided into two categories: static knowledge graph completion (Static KGC), the role of this scenario is to complete the implicit relationship between known entities. It can only handle scenarios where entities and relationships are fixed, so the scalability is poor; dynamic knowledge graph completion (Dynamic KGC), it involves more than just entities or relationships in the knowledge graph G, that is, some words that do not appear, or scenarios where you want to complete the knowledge graph later.

[0006] It is quite difficult to construct a dynamic knowledge graph, and the speed and accuracy of existing temporal knowledge graph completion methods are not high. Summary of the invention

[0007] Based on this, it is necessary to provide a method, device and electronic device for completing a temporal knowledge graph based on QR decomposition to address the above technical problems.

[0008] A method for completing a temporal knowledge graph based on QR decomposition, the method comprising:

[0009] The initial embedding representation of the head entity, relationship, tail entity, and timestamp in the temporal knowledge graph is obtained, where the initial embedding representation is represented by a complex number, including a real part and an imaginary part.

[0010] The real part and the imaginary part of the initial embedded representation of the timestamp are subjected to QR decomposition by Gram-Schmidt orthogonalization to obtain the real part and the imaginary part of the initial embedded representation of the timestamp.

[0011] The real orthogonal matrix and the imaginary orthogonal matrix are fused with the initial embedding representations of the head entity, the relationship, and the tail entity, respectively, to obtain the fused temporal embedding representations of the head entity, the relationship, and the tail entity.

[0012] According to the fused temporal embedding representation of the head entity, relationship and tail entity and the predetermined scoring function, the score of the knowledge in the time series knowledge graph to be completed is calculated, and the missing content in the time series knowledge graph to be completed is predicted based on the score and the preset loss function to complete the time series knowledge graph completion.

[0013] In one of the embodiments, the initial embedded representation is represented by a complex number, including a real part and an imaginary part.

[0014] Get the initial embedding representation of the head entity, relationship, tail entity, and timestamp in the temporal knowledge graph, including:

[0015] The head entity, relationship, tail entity, and timestamp in the temporal knowledge graph are randomly initialized to obtain the initial embedding representation of the head entity, relationship, tail entity, and timestamp band.

[0016] Classify the head entity and the tail entity as entities and generate an initial embedding matrix of the entity, denoted as E |ε|×k , generate an initial embedding matrix of a relationship, denoted as Generate an initial embedding matrix of timestamp, denoted as where k is the dimension of the three initial embedding matrices, |ε|, and are the number of entities, relations and timestamps respectively.

[0017] In one embodiment, the initial embedding of the timestamp is expressed as:

[0018] e τ =e τ_real +e τ_img i

[0019] Among them, e τ is the initial embedding representation of the timestamp, e τ_real is the real part of the initial embedded representation of the timestamp, e τ_img is the imaginary part of the initial embedded representation of the timestamp, and i is the imaginary unit.

[0020] The real part and the imaginary part of the initial embedded representation of the timestamp are subjected to QR decomposition by Gram-Schmidt orthogonalization to obtain the real part and the imaginary part of the initial embedded representation of the timestamp. The real part orthogonal matrix and the imaginary part orthogonal matrix corresponding to the real part and the imaginary part of the initial embedded representation of the timestamp are obtained, including:

[0021] The real part of the initial embedded representation of the timestamp is subjected to QR decomposition using Gram-Schmidt orthogonalization to obtain the real part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the real part QR decomposition is:

[0022] e τ_real =Q τ_real R τ_real

[0023] Among them, Q τ_real is the real orthogonal matrix of the initial embedding representation of the timestamp, R τ_real The real part R matrix of the initial embedding representation of the timestamp;

[0024] The imaginary part of the initial embedded representation of the timestamp is subjected to QR decomposition using Gram-Schmidt orthogonalization to obtain the imaginary part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the imaginary part QR decomposition is:

[0025] e τ_img =Qτ_imgR τ _img

[0026] Among them, Q τ_img is the imaginary orthogonal matrix of the initial embedding representation of the timestamp, R τ_img The imaginary R matrix of the imaginary orthogonal matrix of the initial embedding representation of the timestamp;

[0027] In one embodiment, the real orthogonal matrix and the imaginary orthogonal matrix are respectively fused with the initial embedding representations of the head entity, the relationship, and the tail entity to obtain the fused temporal embedding representations of the head entity, the relationship, and the tail entity, including:

[0028] The real part orthogonal matrix and the imaginary part orthogonal matrix are used as the real part and the imaginary part respectively to form an orthogonal matrix about the timestamp; the expression of the orthogonal matrix about the timestamp is:

[0029] Q τ =Q τ_real +Q τ_img i

[0030] Among them, Q τ is an orthogonal matrix with respect to timestamps, Q τ_real is the real orthogonal matrix, Q τ_img is the imaginary orthogonal matrix, and i is the imaginary unit.

[0031] The orthogonal matrix about the timestamp is multiplied with the initial embedding representations of the head entity, relation, and tail entity respectively to obtain the fused temporal embedding representations of the head entity, relation, and tail entity.

[0032] In one embodiment, the score of the knowledge in the time series knowledge graph to be completed is calculated according to the fused temporal embedding representation of the head entity, the relationship and the tail entity and the predetermined scoring function, and the missing content in the time series knowledge graph to be completed is predicted according to the score and the preset loss function, so as to complete the time series knowledge graph completion, including:

[0033] Obtain a test set including a plurality of valid triples, wherein the triples include: a head entity, a relation, and a tail entity;

[0034] The head entity and the tail entity of all triples constitute an entity set.

[0035] The head entity or tail entity of each triple is replaced with an entity in the entity set except the head entity or tail entity contained in the triple itself to obtain a damaged triple. All damaged triples are compared with the existing triples in the knowledge graph, and the damaged triples that already exist in the knowledge graph are deleted. The remaining damaged triples form a set of negative examples.

[0036] The scores of valid triplets and damaged triplets are calculated according to the preset scoring function, and the scores are arranged in ascending order.

[0037] According to the score, preset loss function and predetermined evaluation indicators, the missing content in the time series knowledge graph to be completed is predicted, and the time series knowledge graph is completed.

[0038] In one embodiment, the scores of the valid triples and the damaged triples are calculated according to a preset scoring function, and the scores are arranged in ascending order. The preset scoring function in the step is:

[0039]

[0040] Among them, f(h,r,t) is a fraction, h τ is the fused temporal embedding representation of the head entity, r τ For the head entity h τ and tail entity t τ relationship, The tail entity t τ The conjugate of , τ is the timestamp, |||| 1 / 2 To obtain the L1 or L2 norm.

[0041] In one embodiment, the predetermined evaluation indicator is that the loss of the knowledge graph reaches a predetermined threshold, and the preset loss function expression is:

[0042]

[0043] Among them, T + is the set of all valid triples; T - is the set of negative examples; f(h,r,t) is the fraction of valid triplets; f(h′,r,t′) is the fraction of damaged triplets; h and h′ are head entities; t and t′ are tail entities, r is a relation; γ is the interval hyperparameter, γ>0; [] + It is the max(0,γ+f(h,r,t)-f(h′,r,t′)) operation.

[0044] A device for completing a temporal knowledge graph based on QR decomposition, the device comprising:

[0045] The initial embedding representation acquisition module is used to obtain the initial embedding representation of the head entity, relationship, tail entity, and timestamp in the temporal knowledge graph. The initial embedding representation is represented by a complex number, including a real part and an imaginary part.

[0046] The QR decomposition module of the initial embedded representation of the timestamp is used to perform QR decomposition on the real part and the imaginary part of the initial embedded representation of the timestamp by using Gram-Schmidt orthogonalization to obtain a real orthogonal matrix and an imaginary orthogonal matrix corresponding to the real part and the imaginary part of the initial embedded representation of the timestamp.

[0047] The fused temporal embedding representation determination module is used to fuse the real orthogonal matrix and the imaginary orthogonal matrix with the initial embedding representations of the head entity, the relationship and the tail entity respectively to obtain the fused temporal embedding representations of the head entity, the relationship and the tail entity.

[0048] The knowledge graph completion module is used to calculate the score of the knowledge in the time series knowledge graph to be completed based on the fused temporal embedding representation of the head entity, relationship and tail entity and the predetermined scoring function, and predict the missing content in the time series knowledge graph to be completed based on the score and the preset loss function to complete the time series knowledge graph completion.

[0049] The method, device and electronic device for completing the temporal knowledge graph based on QR decomposition, the method obtains the initial embedding representation of the head entity, relationship, tail entity and timestamp in the temporal knowledge graph, and the initial embedding representation is represented in complex form; the real part and the imaginary part of the initial embedding representation of the timestamp are respectively decomposed by Gram-Schmidt orthogonalization to obtain the real orthogonal matrix and the imaginary orthogonal matrix of the timestamp, and the real orthogonal matrix and the imaginary orthogonal matrix of the timestamp, the initial embedding representation of the head entity, relationship and tail entity are fused to obtain the fused temporal embedding representation of the head entity, relationship and tail entity, according to the fused temporal embedding representation of the head entity, relationship and tail entity and the predetermined scoring function, the score of the knowledge in the temporal knowledge graph to be completed is calculated, and the missing content in the temporal knowledge graph to be completed is predicted according to the score and the preset loss function, and the temporal knowledge graph is completed. The method can accurately and quickly construct a dynamic knowledge graph, and has better practical significance. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 Schematic diagram of a process of a method for completing a temporal knowledge graph based on QR decomposition in one embodiment;

[0051] Figure 2 A schematic diagram of a process of completing a temporal knowledge graph in one embodiment;

[0052] Figure 3 It is a structural block diagram of a temporal knowledge graph completion device based on QR decomposition in one embodiment;

[0053] Figure 4 FIG. 4 is a diagram showing the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0055] The temporal knowledge graph completion method based on QR decomposition in the present invention is applied to intelligence mining, and intelligence analysis is performed using the network character relationship graph.

[0056] In one embodiment, Figure 1 As shown, a method for completing a temporal knowledge graph based on QR decomposition is provided, and the method includes the following steps:

[0057] Step 100: Obtain the initial embedding representation of the head entity, relationship, tail entity, and timestamp in the temporal knowledge graph. The initial embedding representation is represented by a complex number, including a real part and an imaginary part.

[0058] Specifically, the temporal knowledge graph includes multiple quadruples consisting of a head entity, a relationship, a tail entity, and a timestamp. The quadruples in the temporal knowledge graph are extracted from multiple facts described in a telecom case character relationship graph. For example, the description of a telecom case character relationship graph includes the following three facts: Zhang purchased loan customer information from an institution on October 11, 2020, including Wang's loan information; Zhang hired Li to work for him from January 2019 to December 2021; Li induced Wang to pay "intermediary service fees" by phone on October 30, 2020. The above three facts are described by quadruples as (Zhang, purchase, Wang's information, 2020 / 10 / 11); (Zhang, hire, Li, 2019 / 1-2021 / 12); (Li, deceive, Wang, 2020 / 10 / 30). These quadruple groups are connected with nodes and edges to form a temporal knowledge graph, where the node represents the head entity or tail entity in the quadruple group, and the edge represents the relationship and time pair in the quadruple group.

[0059] A relationship is a relationship between a head entity and a tail entity.

[0060] Use random initialization for the head entity, relationship, tail entity, and timestamp in the temporal knowledge graph to obtain the corresponding initial embedding representation e h , e r , e t and e τ ; The initial embedding representations of the head entity, relation, tail entity, and timestamp are obtained using the TransE method. h and e t They are the initial embeddings of the head entity and the tail entity respectively. Both the head entity and the tail entity are classified as entities, generating an entity initial embedding matrix, denoted as E|ε|×k , generate an initial relation embedding matrix, denoted as Generate an initial embedding matrix of timestamp, denoted as Where k is the initial embedding dimension, and it is assumed here that the dimensions of the three initial embeddings are the same; the number of entities, relations, and timestamps are represented by |ε|, and The above embedding representations are all represented by complex numbers, and the dimensions of the real and imaginary parts are consistent. The initial embedding representation of the head entity, relationship, tail entity, and timestamp is e h , e r , e t and e τ The expression is:

[0061] e h =e h_real +e h_img i

[0062] e r =e r_real +e r_img i

[0063] e t =e t_real +e t_img i

[0064] e τ =e τ_real +e τ_img i

[0065] Among them, e h_real , and e h_img are the real and imaginary parts of the initial embedding representation of the head entity, respectively, and e r_real , and e r_img are the real and imaginary parts of the initial embedding representation of the relation, respectively, and e t_real , and e t_img are the real and imaginary parts of the initial embedded representation of the real tail, respectively, and i is the imaginary unit.

[0066] Step 102: Perform QR decomposition on the real part and the imaginary part of the initial embedded representation of the timestamp using Gram-Schmidt orthogonalization to obtain a real orthogonal matrix and an imaginary orthogonal matrix corresponding to the real part and the imaginary part of the initial embedded representation of the timestamp.

[0067] Step 104: The real orthogonal matrix and the imaginary orthogonal matrix are respectively fused with the initial embedding representations of the head entity, the relationship, and the tail entity to obtain the fused temporal embedding representations of the head entity, the relationship, and the tail entity.

[0068] Step 106: Based on the fused temporal embedding representation of the head entity, relationship, and tail entity and the predetermined scoring function, the score of the knowledge in the time series knowledge graph to be completed is calculated, and the missing content in the time series knowledge graph to be completed is predicted based on the score and the preset loss function to complete the completion of the time series knowledge graph.

[0069] In the above-mentioned method for completing the temporal knowledge graph based on QR decomposition, the method obtains the initial embedding representation of the head entity, relationship, tail entity, and timestamp in the temporal knowledge graph, and the initial embedding representation is represented in complex form; the real part and the imaginary part of the initial embedding representation of the timestamp are respectively subjected to QR decomposition by Gram–Schmidt orthogonalization to obtain the real orthogonal matrix and the imaginary orthogonal matrix of the timestamp, and the real orthogonal matrix and the imaginary orthogonal matrix of the timestamp, the initial embedding representation of the head entity, relationship, and tail entity are fused to obtain the fused temporal embedding representation of the head entity, relationship, and tail entity, and the score of the knowledge in the temporal knowledge graph to be completed is calculated according to the fused temporal embedding representation of the head entity, relationship, and tail entity and the predetermined scoring function, and the missing content in the temporal knowledge graph to be completed is predicted according to the score and the preset loss function, so as to complete the temporal knowledge graph completion. This method can accurately and quickly construct a dynamic knowledge graph, and has better practical significance.

[0070] In one embodiment, step 100 includes: using random initialization on the head entity, relationship, tail entity, and timestamp in the time series knowledge graph to obtain the initial embedding representation of the head entity, relationship, tail entity, and timestamp band; classifying the head entity and the tail entity as entities, and generating an initial embedding matrix of the entity, denoted as E |ε|×k , generate an initial embedding matrix of a relationship, denoted as Generate an initial embedding matrix of timestamp, denoted as where k is the dimension of the three initial embedding matrices, |ε|, and are the number of entities, relations and timestamps respectively;

[0071] In one embodiment, the initial embedding of the timestamp is represented as:

[0072] e τ =e τ_real +e τ_img i

[0073] Among them, e τ is the initial embedding representation of the timestamp, e τ_real is the real part of the initial embedded representation of the timestamp, e τ_imgis the imaginary part of the initial embedded representation of the timestamp, and i is an imaginary unit; step 102 includes: performing QR decomposition on the real part of the initial embedded representation of the timestamp using Gram-Schmidt orthogonalization to obtain a real part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the real part QR decomposition is:

[0074] e τ_real =Q τ_real R τ_real

[0075] Among them, Q τ_real is the real orthogonal matrix of the initial embedding representation of the timestamp, R τ_real The real part of the R matrix of the initial embedding representation of the timestamps.

[0076] The imaginary part of the initial embedded representation of the timestamp is subjected to QR decomposition using Gram-Schmidt orthogonalization to obtain the imaginary part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the imaginary part QR decomposition is:

[0077] e τ_img =Q τ_img R τ_img

[0078] Among them, Q τ_img is the imaginary orthogonal matrix of the initial embedding representation of the timestamp, R τ_img The initial embedding of the timestamp is represented by the imaginary part of the orthogonal matrix R.

[0079] In one embodiment, step 104 includes: using the real orthogonal matrix and the imaginary orthogonal matrix as the real part and the imaginary part, respectively, to form an orthogonal matrix about the timestamp; the expression of the orthogonal matrix about the timestamp is:

[0080] Q τ =Q τ_real +Q τ_img i

[0081] Among them, Q τ is an orthogonal matrix about timestamp, Q τ_real is the real orthogonal matrix, Q τ_img is the imaginary orthogonal matrix, and i is the imaginary unit.

[0082] The orthogonal matrix about the timestamp is multiplied with the initial embedding representations of the head entity, relation, and tail entity respectively to obtain the fused temporal embedding representations of the head entity, relation, and tail entity.

[0083] Specifically, use the complex number multiplication formula:

[0084] z1z2=(a+bi)(c+di)=ac+adi+bci+bdi 2=(ac-bd)+(ad+bc)i

[0085] The orthogonal matrix about the timestamp is respectively combined with the initial embedding representation of the head entity, relation, and tail entity. h , e r and e t Fusion is performed to obtain the fused temporal embedding representation h of the head entity, relation, and tail entity respectively. τ ,r τ ,t τ :

[0086] h τ =e h Q τ =(e h_real Q τ_real -e h_img Q τ_img )+(e h_real Q τ_img +e h_img Q τ_real )i

[0087] r τ =e r Q τ =(e r_real Q τ_real -e r_img Q τ_img )+(e r_real Q τ_img +e r_img Q τ_real )i

[0088] t τ =e t Q τ =(e t _ real Q τ_real -e t_img Q τ_img )+(e t_real Q τ_img +e t_img Q τ_real )i

[0089] In one embodiment, step 106 specifically includes:

[0090] Step 200: Obtain a test set including multiple valid triples, where the triples include: a head entity, a relationship, and a tail entity.

[0091] Step 202: The head entity and the tail entity of all triples form an entity set.

[0092] Step 204: Replace the head entity or tail entity of each triple with an entity in the entity set other than the head entity or tail entity contained in the triple itself to obtain a damaged triple, and compare all damaged triples with the existing triples in the knowledge graph, delete the damaged triples that already exist in the knowledge graph, and form the remaining damaged triples into a set of negative examples.

[0093] Step 206: Calculate the scores of valid triples and damaged triples according to a preset scoring function, and arrange the scores in ascending order; predict the missing content in the time series knowledge graph to be completed based on the scores, the preset loss function and the predetermined evaluation indicators, and complete the completion of the time series knowledge graph.

[0094] In one embodiment, the preset scoring function in step 206 is:

[0095]

[0096] Among them, f(h,r,t) is a fraction, h τ is the fused temporal embedding representation of the head entity, r τ For the head entity h τ and tail entity t τ relationship, The tail entity t τ The conjugate of , τ is the timestamp, |||| 1 / 2 To obtain the L1 or L2 norm.

[0097] In one embodiment, the predetermined evaluation indicator is that the loss of the knowledge graph reaches a predetermined threshold, and the preset loss function expression is:

[0098]

[0099] Among them, T + is the set of all valid triples; T - is the set of negative examples; f(h,r,t) is the fraction of valid triples; f(h′,r,t′) is the fraction of damaged triples; h and h′ are head entities; t and t′ are tail entities, r is a relation; γ is the interval hyperparameter, γ>0; [] + It is the max(0,γ+f(h,r,t)-f(h′,r,t′)) operation.

[0100] γ+f(h,r,t)-f(h′,r,t′)It should be understood that although Figure 1-2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequentially, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0101] In one embodiment, Figure 3 As shown, a temporal knowledge graph completion device based on QR decomposition is provided, comprising: an initial embedding representation acquisition module, a QR decomposition module of the initial embedding representation of the timestamp, a fused time embedding representation determination module and a knowledge graph completion module, wherein:

[0102] The initial embedding representation acquisition module is used to obtain the initial embedding representation of the head entity, relationship, tail entity, and timestamp in the temporal knowledge graph. The initial embedding representation is represented by a complex number, including the real part and the imaginary part;

[0103] A QR decomposition module of the initial embedded representation of the timestamp, used for performing QR decomposition on the real part and the imaginary part of the initial embedded representation of the timestamp by using Gram-Schmidt orthogonalization to obtain a real orthogonal matrix and an imaginary orthogonal matrix corresponding to the real part and the imaginary part of the initial embedded representation of the timestamp;

[0104] A fused temporal embedding representation determination module is used to fuse the real orthogonal matrix and the imaginary orthogonal matrix with the initial embedding representations of the head entity, the relationship, and the tail entity, respectively, to obtain the fused temporal embedding representations of the head entity, the relationship, and the tail entity;

[0105] The knowledge graph completion module is used to calculate the score of the knowledge in the time series knowledge graph to be completed based on the fused temporal embedding representation of the head entity, relationship and tail entity and the predetermined scoring function, and predict the missing content in the time series knowledge graph to be completed based on the score and the preset loss function to complete the time series knowledge graph completion.

[0106] In one embodiment, the initial embedding representation acquisition module is also used to use random initialization to the head entity, relationship, tail entity, and timestamp in the time series knowledge graph to obtain the initial embedding representation of the head entity, relationship, tail entity, and timestamp band; the head entity and the tail entity are classified as entities to generate an initial embedding matrix of the entity, denoted as E |ε|×k , generate an initial embedding matrix of a relationship, denoted as Generate an initial embedding matrix of timestamp, denoted as where k is the dimension of the three initial embedding matrices, |ε|, and are the number of entities, relations and timestamps respectively;

[0107] In one embodiment, the initial embedding of the timestamp is represented as:

[0108] e τ =e τ_real +e τ_img i

[0109] Among them, e τ is the initial embedding representation of the timestamp, e τ_real is the real part of the initial embedded representation of the timestamp, e τ_img is the imaginary part of the initial embedded representation of the timestamp, and i is the imaginary unit; the QR decomposition module of the initial embedded representation of the timestamp is also used to perform QR decomposition on the real part of the initial embedded representation of the timestamp using Gram-Schmidt orthogonalization to obtain the real part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the real part QR decomposition is:

[0110] e τ_real =Q τ_real R τ_real

[0111] Among them, Q τ_real is the real orthogonal matrix of the initial embedding representation of the timestamp, R τ_real The real part of the R matrix of the initial embedding representation of the timestamps.

[0112] The imaginary part of the initial embedded representation of the timestamp is subjected to QR decomposition using Gram-Schmidt orthogonalization to obtain the imaginary part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the imaginary part QR decomposition is:

[0113] e τ_img =Q τ_img R τ_img

[0114] Among them, Q τ_img is the imaginary orthogonal matrix of the initial embedding representation of the timestamp, R τ_img The initial embedding of the timestamp is represented by the imaginary part of the orthogonal matrix R.

[0115] In one embodiment, the fused time embedding representation determination module is further used to use the real orthogonal matrix and the imaginary orthogonal matrix as the real part and the imaginary part respectively to form an orthogonal matrix about the timestamp; the expression of the orthogonal matrix about the timestamp is:

[0116] Q τ =Q τ_real +Q τ_img i

[0117] Among them, Q τ is an orthogonal matrix about timestamp, Q τ_real is the real orthogonal matrix, Qτ_img is the imaginary orthogonal matrix, and i is the imaginary unit.

[0118] The orthogonal matrix about the timestamp is multiplied with the initial embedding representations of the head entity, relation, and tail entity respectively to obtain the fused temporal embedding representations of the head entity, relation, and tail entity.

[0119] In one of the embodiments, the knowledge graph completion module is also used to obtain a test set including multiple valid triples, wherein the triples include: a head entity, a relationship, and a tail entity; the head entity and the tail entity of all triples constitute an entity set; and the head entity or the tail entity of each triple is replaced by an entity in the entity set other than the head entity or the tail entity contained in the triple itself to obtain a damaged triple, and all the damaged triples are compared with the existing triples in the knowledge graph, and the damaged triples that already exist in the knowledge graph are deleted, and the remaining damaged triples are formed into a set of negative examples; the scores of the valid triples and the damaged triples are calculated according to a preset scoring function, and the scores are arranged in ascending order; according to the scores, the preset loss function and the predetermined evaluation indicators, the missing content in the time series knowledge graph to be completed is predicted to complete the time series knowledge graph completion.

[0120] In one embodiment, the preset scoring function in the knowledge graph completion module is:

[0121]

[0122] Among them, f(h,r,t) is a fraction, h τ is the fused temporal embedding representation of the head entity, r τ For the head entity h τ and tail entity t τ relationship, The tail entity t τ The conjugate of , τ is the timestamp, |||| 1 / 2 To obtain the L1 or L2 norm.

[0123] In one embodiment, the predetermined evaluation indicator in the knowledge graph completion module is that the loss of the knowledge graph reaches a predetermined threshold, and the preset loss function expression is:

[0124]

[0125] Among them, T + is the set of all valid triples; T - is the set of negative examples; f(h,r,t) is the fraction of valid triplets; f(h′,r,t′) is the fraction of damaged triplets; h and h′ are head entities; t and t′ are tail entities, r is a relation; γ is the interval hyperparameter, γ>0; [] +It is the max(0, γ+f(h,r,t)-f(h′,r,t′)) operation, that is, when the value of γ+f(h,r,t)-f(h′,r,t′) is greater than 0, the value of the preset loss function is γ+f(h,r,t)- f(h′,r,t′); when the value of γ+f(h,r,t)-f(h′,r,t′) is less than or equal to 0, the value of the preset loss function is 0.

[0126] For the specific limitations of the temporal knowledge graph completion device based on QR decomposition, please refer to the limitations of the temporal knowledge graph completion method based on QR decomposition above, which will not be repeated here. Each module in the above-mentioned temporal knowledge graph completion device based on QR decomposition can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0127] In one embodiment, an electronic device is provided. The electronic device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The electronic device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for completing a time series knowledge graph based on QR decomposition is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.

[0128] Those skilled in the art will understand that Figure 4 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0129] In one embodiment, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method embodiment when executing the computer program.

[0130] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0131] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A time series knowledge graph completion method based on QR decomposition, applied to intelligence analysis of network character relationship graph, characterized in that: The method comprises: Obtaining initial embedding representations of head entities, relations, tail entities, and timestamps in a temporal knowledge graph, wherein the initial embedding representations are represented by complex numbers, including real and imaginary parts; The real part and the imaginary part of the initial embedded representation of the timestamp are subjected to QR decomposition by Gram-Schmidt orthogonalization to obtain the real part and the imaginary part of the initial embedded representation of the timestamp. The real orthogonal matrix and the imaginary orthogonal matrix are respectively fused with the initial embedding representations of the head entity, the relationship, and the tail entity to obtain the fused temporal embedding representations of the head entity, the relationship, and the tail entity; According to the fused temporal embedding representation of the head entity, relationship and tail entity and the predetermined scoring function, the score of the knowledge in the time series knowledge graph to be completed is calculated, and the missing content in the time series knowledge graph to be completed is predicted according to the score and the preset loss function, so as to complete the time series knowledge graph completion; The initial embedding of the timestamp is expressed as: yes τ =e τ_real +e τ_img and Among them, e τ is the initial embedding representation of the timestamp, e τ_real is the real part of the initial embedded representation of the timestamp, e τ_img is the imaginary part of the initial embedded representation of the timestamp, i is the imaginary unit; The real part and the imaginary part of the initial embedded representation of the timestamp are subjected to QR decomposition by Gram-Schmidt orthogonalization to obtain the real part and the imaginary part of the initial embedded representation of the timestamp. The real part orthogonal matrix and the imaginary part orthogonal matrix corresponding to the real part and the imaginary part of the initial embedded representation of the timestamp are obtained, including: The real part of the initial embedded representation of the timestamp is subjected to QR decomposition using Gram-Schmidt orthogonalization to obtain the real part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the real part QR decomposition is: e τ_real =Q τ_real R τ_real Among them, Q τ_real is the real orthogonal matrix of the initial embedding representation of the timestamp, R τ_real The real part R matrix of the initial embedding representation of the timestamp; The imaginary part of the initial embedded representation of the timestamp is subjected to QR decomposition using Gram-Schmidt orthogonalization to obtain the imaginary part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the imaginary part QR decomposition is: e τ_img =Q τ_img R τ_img Among them, Q τ_img is the imaginary orthogonal matrix of the initial embedding representation of the timestamp, R τ_img The initial embedding of the timestamp is represented by the imaginary part of the orthogonal matrix R.

2. The method according to claim 1, characterized in that The initial embedded representation is represented by a complex number, including a real part and an imaginary part; Get the initial embedding representation of the head entity, relationship, tail entity, and timestamp in the temporal knowledge graph, including: The head entity, relationship, tail entity, and timestamp in the temporal knowledge graph are randomly initialized to obtain the initial embedding representation of the head entity, relationship, tail entity, and timestamp; Classify the head entity and the tail entity as entities and generate an initial embedding matrix of the entity, denoted as E |ε|×k , generate an initial embedding matrix of a relationship, denoted as Generate an initial embedding matrix of timestamp, denoted as where k is the dimension of the three initial embedding matrices, |ε|, and are the number of entities, relations and timestamps respectively.

3. The method according to claim 1, characterized in that The real orthogonal matrix and the imaginary orthogonal matrix are respectively fused with the initial embedding representations of the head entity, the relationship, and the tail entity to obtain the fused temporal embedding representations of the head entity, the relationship, and the tail entity, including: The real part orthogonal matrix and the imaginary part orthogonal matrix are used as the real part and the imaginary part respectively to form an orthogonal matrix about the timestamp; the expression of the orthogonal matrix about the timestamp is: Q τ =Q τ_real +Q τ_img i Among them, Q τ is an orthogonal matrix about timestamp, Q τ_real is the real orthogonal matrix, Q τ_img is the imaginary orthogonal matrix, i is the imaginary unit; The orthogonal matrix about the timestamp is multiplied with the initial embedding representations of the head entity, relation, and tail entity respectively to obtain the fused temporal embedding representations of the head entity, relation, and tail entity.

4. The method according to claim 1, characterized in that: According to the fused temporal embedding representation of the head entity, relationship, and tail entity and the predetermined scoring function, the score of the knowledge in the time series knowledge graph to be completed is calculated, and the missing content in the time series knowledge graph to be completed is predicted based on the score and the preset loss function, completing the time series knowledge graph completion, including: Obtain a test set including a plurality of valid triples, wherein the triples include: a head entity, a relation, and a tail entity; The head entity and the tail entity of all triples constitute an entity set; Replace the head entity or tail entity of each triple with an entity in the entity set other than the head entity or tail entity contained in the triple itself to obtain a damaged triple. Compare all damaged triples with the existing triples in the knowledge graph, delete the damaged triples that already exist in the knowledge graph, and form the remaining damaged triples into a set of negative examples. Calculate the scores of valid triples and damaged triples according to a preset scoring function, and arrange the scores in ascending order; According to the score, preset loss function and predetermined evaluation indicators, the missing content in the time series knowledge graph to be completed is predicted, and the time series knowledge graph is completed.

5. The method according to claim 4, characterized in that The scores of valid triples and damaged triples are calculated according to the preset scoring function, and the scores are arranged in ascending order. The preset scoring function in the step is: Among them, f(h, r, t) is a fraction, h τ is the fused temporal embedding representation of the head entity, r τ For the head entity h τ and tail entity t τ relationship, The tail entity t τ The conjugate of , τ is the timestamp, || || 1 / 2 To obtain the L1 or L2 norm.

6. The method according to claim 5, characterized in that According to the score, the preset loss function and the predetermined evaluation index, the missing content in the time series knowledge graph to be completed is predicted, and the time series knowledge graph is completed. The predetermined evaluation index in the step is that the loss of the knowledge graph reaches a predetermined threshold; the preset loss function is: Among them, T + is the set of all valid triples, T - It is T + The set of negative examples, f(h, r, t) is the score of valid triples, f(h′, r, t′) is the score of damaged triples, h and h′ are head entities, t and t′ are tail entities, r is a relation, γ>0 is the interval hyperparameter, [] + It is the max(0,γ+f(h,r,t)-f(h′,r,t′)) operation.

7. A time series knowledge graph completion device based on QR decomposition, applied to intelligence analysis of network character relationship graph, characterized in that: The device comprises: An initial embedding representation acquisition module is used to acquire the initial embedding representation of the head entity, relationship, tail entity, and timestamp in the temporal knowledge graph, where the initial embedding representation is represented by a complex number, including a real part and an imaginary part; A QR decomposition module for the initial embedded representation of the timestamp is used to perform QR decomposition on the real part and the imaginary part of the initial embedded representation of the timestamp by using Gram-Schmidt orthogonalization to obtain a real orthogonal matrix and an imaginary orthogonal matrix corresponding to the real part and the imaginary part of the initial embedded representation of the timestamp; A fused temporal embedding representation determination module is used to fuse the real orthogonal matrix and the imaginary orthogonal matrix with the initial embedding representations of the head entity, the relationship, and the tail entity, respectively, to obtain a fused temporal embedding representation of the head entity, the relationship, and the tail entity; The knowledge graph completion module is used to calculate the score of the knowledge in the time series knowledge graph to be completed based on the fused temporal embedding representation of the head entity, relationship and tail entity and the predetermined scoring function, and predict the missing content in the time series knowledge graph to be completed based on the score and the preset loss function, so as to complete the time series knowledge graph completion; The initial embedding representation of the timestamp in the acquisition module is represented as follows: yes τ =e τ_real +e τ_img and Among them, e τ is the initial embedding representation of the timestamp, e τ_real is the real part of the initial embedded representation of the timestamp, e τ_img is the imaginary part of the initial embedded representation of the timestamp, i is the imaginary unit; The QR decomposition module of the initial embedded representation of the timestamp is also used to perform QR decomposition on the real part of the initial embedded representation of the timestamp using Gram-Schmidt orthogonalization to obtain the real part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the real part QR decomposition is: e τ_real =Q τ_real R τ_real Among them, Q τ_real is the real orthogonal matrix of the initial embedding representation of the timestamp, R τ_real The real part R matrix of the initial embedding representation of the timestamp; The imaginary part of the initial embedded representation of the timestamp is subjected to QR decomposition using Gram-Schmidt orthogonalization to obtain the imaginary part orthogonal matrix of the initial embedded representation of the timestamp; the expression of the imaginary part QR decomposition is: e τ_img =Q τ_img R τ_img Among them, Q τ_img is the imaginary orthogonal matrix of the initial embedding representation of the timestamp, R τ_img The initial embedding of the timestamp is represented by the imaginary part of the orthogonal matrix R.

8. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.