Temporal knowledge graph logical reasoning method and device based on temporal probability distribution
Through the time probability distribution method, the problems of high cost and limitations of time-sequential processing in timing knowledge graph logical reasoning are solved, and more efficient and accurate complex time logic query processing is achieved, providing more flexible and interpretable query results .
Patent Information
- Application Number
- CN202410979834.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-07-22
AI Technical Summary
The prior art is costly and has limitations in chronological processing when processing logical reasoning of timing knowledge graphs, especially when processing complex temporal logical queries and chronological processing, accuracy and efficiency are insufficient.
Using a time probability distribution method, the entity and timestamp are represented as probability distribution, the timing knowledge graph is completed by link predictors, and it is modeled into a sparse matrix form, and fuzzy logic operations are performed to process complex time logic queries, using Time probability distribution TProb assigns probability scores to each entity or timestamp, handling traditional and time-specific logical operators.
It improves the processing ability of complex time logic queries, provides more flexible and accurate query answers, can provide a richer information foundation in the face of data incompleteness, and improves the interpretability and efficiency of the query answering process.
Smart Images

Figure CN118504695B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of big data, artificial intelligence and knowledge graph technology, and in particular to a method and device for logical reasoning of a temporal knowledge graph based on temporal probability distribution. Background Art
[0002] Complex Query Answering (CQA) on Knowledge Graph (KG) aims to handle First-Order Logic (FOL) queries involving a series of logical operators, including existential quantifiers ( , meaning "exists"), conjunction (∨, meaning "or"), disjunction (∧, meaning "and"), and negation (¬, meaning "not"), etc. These logical operators are key to processing complex information and relationships in the context of knowledge graphs.
[0003] Although CQA on knowledge graphs has received extensive research and attention, there is relatively little research on temporal knowledge graphs (TKGs). Unlike traditional static knowledge graphs, TKGs add time information (t) to static triples (s, r, o) in knowledge graphs to form time-tagged quadruples (s, r, o, t), where s represents the subject, r represents the relation, o represents the object, and t represents the time when the event occurred. This design enables TKG to not only reflect the relationships between entities, but also capture the dynamic characteristics of these relationships over time, thereby more comprehensively and accurately reflecting the complexity of the real world.
[0004] The complexity of complex queries for temporal logic reasoning lies in that it not only needs to deal with the static relationship between entities, but also needs to consider the dynamic changes in the time dimension. Such queries are not easy to answer directly for a large language model (LLM) because it requires sophisticated reasoning on temporal logic to handle the complex logical relationships in the query.
[0005] There are two major challenges in logical reasoning on TKG: first, the answer to a query may be an entity or a timestamp, which increases the complexity of query processing; second, compared with static KG, TKG introduces new temporal logic operators, such as "After" and "Before", which require the system to understand and process the concepts of time order and time interval. Therefore, logical reasoning on TKG requires not only understanding the relationship between entities, but also accurately processing time information to ensure that the query results reflect the relationship between entities and meet the requirements of temporal logic.
[0006] Traditionally, the problem of CQA is mainly solved by symbolic methods in graph databases, which rely on traversing the knowledge graph and exploring all possible paths to find the correct answer. However, knowledge graphs often have data incompleteness problems, such as missing entity relationships or attributes, which limits the effectiveness and accuracy of purely symbolic methods.
[0007] In order to perform effective logical reasoning on such incomplete knowledge graphs, many researchers have turned to query embedding (QE) methods. These methods, such as Query2box, BetaE, ConE (for static KGs), and TFLEX (designed for temporal knowledge graphs, TKGs), aim to learn embedded representations of entities, timestamps, and queries, and determine the answer to CQA by comparing the distances in the embedding space. This method can capture the implicit dependencies and logical relationships between entities and timestamps, so that effective reasoning can be performed despite the incompleteness of the knowledge graph.
[0008] However, a major challenge faced by QE methods is the need to train on a large number of complex logical queries, which is very expensive in terms of resources and time. In particular, the integration of timestamps and temporal logical operators (such as "After" and "Before") makes the structure of temporal queries more complex, so for these methods, understanding and embedding such complex query structures requires extensive training on a wider range of query types. TFLEX attempts to handle this complexity by building embeddings in multiple dimensions, such as entity space, entity logic space, temporal space, and temporal logic space. It learns the interconnections between different spaces through extensive training to achieve the correct embedding of queries.
[0009] Furthermore, although QE methods can model relationships between entities and timestamps, they still have limitations in dealing with temporal order. Temporal order is a key aspect in temporal queries, especially when considering temporal logic operators. QE methods usually model temporal logic such as "After" by transforming positions in the embedding space, but this approach cannot accurately calculate temporal order, especially in scenarios that require precise temporal order judgments. In addition, QE methods also show limitations in dealing with temporal boundaries, for example, there is no concept of "After" at the very end of the timeline. Summary of the invention
[0010] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0011] To this end, the first purpose of this application is to propose a temporal knowledge graph logical reasoning method based on time probability distribution, which solves the technical problems of high cost and limitations in time sequence of existing methods. By representing entities and timestamps as probability distributions, it reduces dependence on traditional QE methods, thereby improving the processing capabilities of complex time logic queries.
[0012] The second purpose of this application is to propose a temporal knowledge graph logical reasoning device based on time probability distribution.
[0013] To achieve the above purpose, the first embodiment of the present application proposes a time series knowledge graph logical reasoning method based on time probability distribution. The time series knowledge graph is generated based on text data. Each text in the text data represents an event in the real world. An event in the real world is stored in the form of a time series knowledge graph. The method performs logical reasoning on the time series knowledge graph based on the logical query input by the user to obtain the query result. The method includes: completing the time series knowledge graph through a link predictor; modeling the completed time series knowledge graph as a time series probability distribution, and converting the time series probability distribution into a time series probability distribution in a sparse matrix form through screening; for the logical query input by the user, performing fuzzy logic operations on the time series probability distribution in the sparse matrix form to obtain the intermediate path from the starting point to the end point and the corresponding probability distribution, and taking the path with the highest probability value as the query result.
[0014] The temporal knowledge graph logical reasoning method based on time probability distribution in the embodiment of the present application introduces the time probability distribution TProb, where TProb is in [0, 1], each entity or timestamp is assigned a score, which indicates the probability that the entity or timestamp matches a query condition. This representation method can not only reflect the matching degree of the entity or timestamp with the query condition, but also allow the efficient reasoning and calculation of probability in the whole TKG. TProb can provide more flexible and accurate query answers in the face of data incompleteness by treating the missing relationship edges in TKG as probability distributions. TProb provides a richer information basis for further logical reasoning by assigning probability scores to possible relationships. TProb traverses the probability space of entities, timestamps and relationships through an efficient fuzzy logic processor. This processor can process not only traditional logical operators (such as "and", "or", and "not"), but also time-specific logical operators (such as "after", "before"), and calculate the probability distribution of all intermediate variables and the final answer, which effectively improves the interpretability of the query answering process. Since each logical operation corresponds to the update of the probability distribution, it is possible to clearly track how the score of each entity or timestamp changes with the progress of logical reasoning.
[0015] Optionally, in one embodiment of the present application, completing the temporal knowledge graph by a link predictor includes:
[0016] For each missing edge of the temporal knowledge graph, at any time On, through the neural link predictor Inferred by any tail entity The four-tuple In the probability space Score in , , where the probability space is the probability space of the time series probability distribution.
[0017] Optionally, in one embodiment of the present application, the completed temporal knowledge graph is modeled as a temporal probability distribution, including:
[0018] Neural Link Predictor The inferred scores construct the temporal probability distribution of entities or timestamps ,in, , is the preset threshold, the probability is lower than The fact is a false fact;
[0019] For any tail entity , determine the triples it constitutes The explicit temporal probability distribution of ,in, Represents a triple The probability of occurrence at all times, triple At any time The probability of occurrence of ;
[0020] A neural adjacency matrix is defined to align temporal probability distributions with temporal logical operators.
[0021] Optionally, in one embodiment of the present application, the neural adjacency matrix is , Represents the probability of links between different entities through specific relationships at a given time, the neural adjacency matrix Elements in It is expressed as:
[0022]
[0023] in, Indicates a given time Next, entity and Through the relationship connection probability.
[0024] Optionally, in one embodiment of the present application, the method further includes:
[0025] When performing logical reasoning, explicit time probability distribution is used to represent the variable expression along the reasoning path. In all the explicit time probability distributions determined, each value in the interval [0, 1] represents the assigned score of the corresponding entity or timestamp;
[0026] The fuzzy set in the time series probability distribution is , the corresponding fuzzy vector is .
[0027] Optionally, in one embodiment of the present application, the logical query is a first-order logical query, the logical query is an entity query or a timestamp query, the logical query includes an entity, a timestamp and a plurality of time logical operators, the time logical operators are relational projection, intersection, union, negation, After or Before,
[0028] The temporal logic operation of relational projection is expressed as:
[0029]
[0030] in, , , Represents a specific entity. Indicates a specific timestamp. , For a given query, For the answer object, Represents a given entity , given a timestamp , the answer is The score, represents the fuzzy entity distribution and fuzzy timestamp distribution, Represents the fraction of a specific timestamp in the fuzzy timestamp distribution, is a value of the fuzzy matrix, indicating that , head entity , tail entity , timestamp In the case of , the scores stored in the fuzzy matrix are yes A case of , which is extended to all head entities and time, the extended expression is:
[0031]
[0032] Among them, ···× is a copy of the column, the superscript T represents the transpose, ⊙ represents the Hadamard product, and : represents a matrix slice. is the two-dimensional maximum;
[0033] The time logic operation of AND is expressed as:
[0034]
[0035] in, Represents the fraction of a specific timestamp in the fuzzy timestamp distribution, represents the score of a specific entity in the fuzzy entity distribution, Indicates a timestamp or the total number of entities;
[0036] The temporal logic operation of intersection is expressed as:
[0037]
[0038] The time logic operation of After is expressed as:
[0039]
[0040] Before time logic operation is expressed as:
[0041]
[0042] in, Represents the fraction of a specific timestamp in the fuzzy timestamp distribution.
[0043] Optionally, in one embodiment of the present application, for a logical query input by a user, a fuzzy logic operation is performed on a time series probability distribution in a sparse matrix form to obtain an intermediate path from the starting point to the end point and a corresponding probability distribution, and the path with the highest probability value is taken as the query result, including:
[0044] Build the initial fuzzy vector starting from the entity or timestamp in the logical query , when building, the dimension of the vector is determined based on the number of entities or timestamps in the logical query, and the index position of the query starting point is set to 1, and all other elements are set to 0;
[0045] The entity set directly related to the entity or timestamp in the logical query is taken as the anchor set, and the entity set that does not meet the query condition is taken as the non-answer set. Starting from the anchor set, the knowledge graph calculation graph is iterated. During the traversal, the entities in the current non-answer set are subjected to temporal logic operations according to the temporal logic operators included in the logical query to achieve the initial fuzzy vector. The updated fuzzy vector is obtained through multiple iterations. ;
[0046] Determine whether the logical query is an entity query or a timestamp query. If it is an entity query, use Get the entity query answer sorted in descending order by score. If it is a timestamp query, use Get the answer to the timestamp query sorted in descending order by score. The element with the highest score is taken as the final answer set.
[0047] Optionally, in one embodiment of the present application, the method further includes:
[0048] For the intermediate nodes on the reasoning path, use the updated fuzzy vector Get the sorted answer scores.
[0049] Optionally, in one embodiment of the present application, the final answer set is expressed as:
[0050]
[0051] in, Number your answers. The operation is to get the subscript corresponding to the element with the largest value in a vector.
[0052] To achieve the above purpose, the second embodiment of the present application proposes a time series knowledge graph logical reasoning device based on time probability distribution. The time series knowledge graph is generated based on text data. Each text in the text data represents an event in the real world. The device stores an event in the real world in the form of a real world event. The device performs logical reasoning on the time series knowledge graph based on the logical query input by the user to obtain the query result. The device includes:
[0053] The knowledge graph completion module is used to complete the temporal knowledge graph through the link predictor;
[0054] The knowledge graph modeling module is used to model the completed time series knowledge graph as a time series probability distribution, and convert the time series probability distribution into a time series probability distribution in the form of a sparse matrix through screening;
[0055] The query module is used to perform fuzzy logic operations on the time series probability distribution in the form of a sparse matrix for the logical query input by the user, obtain the intermediate path from the starting point to the end point and the corresponding probability distribution, and take the path with the highest probability value as the query result.
[0056] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0058] Figure 1 A schematic diagram of an existing timing calculation graph method;
[0059] Figure 2 It is a schematic diagram of the existing embedding method;
[0060] Figure 3 A schematic diagram of the scheme of this application;
[0061] Figure 4 A flowchart of a temporal knowledge graph logic reasoning method based on time probability distribution provided in Example 1 of the present application;
[0062] Figure 5 A schematic diagram of a flow chart of a temporal knowledge graph logic reasoning system based on time probability distribution provided in an embodiment of the present application;
[0063] Figure 6 A schematic diagram of the timing probability distribution of an embodiment of the present application;
[0064] Figure 7 A schematic diagram of the structure of a temporal knowledge graph logic reasoning device based on time probability distribution provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0066] based on Figure 1 , Figure 2 , Figure 3 For comparison, Figure 3 TProb is the solution disclosed in this application, such as Figure 3 As shown, take a real-life problem as an example: when someone asks "Which countries did B visit during the period when A held a specific position?", this question is converted into a time series computation graph to find the answer.
[0067] When dealing with such problems, previous methods such as TFLEX embed time features and temporal logic operators into specific spaces, and then perform operations in these spaces to simulate temporal logic. However, this method does not consider the order of time in logical reasoning, which leads to inaccuracy in temporal logic calculations. At the same time, using embedded methods to represent time also ignores the concept of time boundaries. For example, there should not be any "after" state after the last time point, but it is difficult to express such boundaries in embedded representations.
[0068] To address these issues, a method named TProb, or temporal probability method, is proposed. In this model, entities and timestamps are represented as fuzzy vectors, and all missing TKG edge information is completed as fuzzy matrices. Then, temporal logic operators that utilize time order information are designed for fuzzy vectors. For example, the "after" operator shifts the score to the right according to the index order, thereby achieving more accurate calculations. In addition, as a bounded ordered array, the fuzzy vector also effectively handles the start and end boundaries of time, namely 0 and T-1.
[0069] The following describes the temporal knowledge graph logical reasoning method and device based on time probability distribution in an embodiment of the present application with reference to the accompanying drawings.
[0070] Figure 4 A flow chart of a method for logical reasoning of a temporal knowledge graph based on temporal probability distribution provided in Example 1 of the present application. The temporal knowledge graph is generated based on text data. Each text in the text data represents an event in the real world. The temporal knowledge graph is generated based on text data. An event in the real world is stored in the form of a graph. This method is used to perform logical reasoning on the time series knowledge graph based on the logical query input by the user to obtain the query result.
[0071] like Figure 4 As shown, the temporal knowledge graph logical reasoning method based on time probability distribution includes the following steps:
[0072] Step 101, completing the temporal knowledge graph through a link predictor;
[0073] Step 102, modeling the completed time series knowledge graph as a time series probability distribution, and converting the time series probability distribution into a time series probability distribution in the form of a sparse matrix through screening;
[0074] Step 103, for the logical query input by the user, fuzzy logic operation is performed on the time series probability distribution in the form of a sparse matrix to obtain the intermediate path from the starting point to the end point and the corresponding probability distribution, and the path with the highest probability value is taken as the query result.
[0075] The temporal knowledge graph logical reasoning method based on time probability distribution in the embodiment of the present application introduces the time probability distribution TProb, where TProb is in [0, 1], each entity or timestamp is assigned a score, which indicates the probability that the entity or timestamp matches a query condition. This representation method can not only reflect the matching degree of the entity or timestamp with the query condition, but also allow the efficient reasoning and calculation of probability in the whole TKG. TProb can provide more flexible and accurate query answers in the face of data incompleteness by treating the missing relationship edges in TKG as probability distributions. TProb provides a richer information basis for further logical reasoning by assigning probability scores to possible relationships. TProb traverses the probability space of entities, timestamps and relationships through an efficient fuzzy logic processor. This processor can process not only traditional logical operators (such as "and", "or", and "not"), but also time-specific logical operators (such as "after", "before"), and calculate the probability distribution of all intermediate variables and the final answer, which effectively improves the interpretability of the query answering process. Since each logical operation corresponds to the update of the probability distribution, it is possible to clearly track how the score of each entity or timestamp changes with the progress of logical reasoning.
[0076] See also Figure 5 , Figure 5 A flow chart of a temporal knowledge graph logic reasoning system based on temporal probability distribution provided by an embodiment of the present application is shown. The method is executed by an electronic device.
[0077] The temporal knowledge graph logical reasoning system based on temporal probability distribution includes a model TProb for temporal knowledge graph (TKG), which models entities and timestamps as probability distributions, and completes the representation of TKG in this way, and performs reasoning through a fuzzy logic processor. The core idea of TProb is to regard each entity and timestamp in TKG as not just a static data point, but a probability distribution that can represent uncertainty and possibility. This approach allows the model to capture implicit relationships and dynamic changes in TKG, providing richer and more flexible representation capabilities than traditional static methods. In TProb, each possible state or value of an entity and timestamp is assigned a probability score, which indicates how likely the state or value is in a given query context. For example, a timestamp can be represented as a probability distribution of a series of time points, each of which has a corresponding probability score indicating the likelihood of an event occurring at that time point. In order to reason on such a probability distribution, TProb introduces a fuzzy logic processor. This processor uses the principles of fuzzy logic to efficiently traverse and manipulate probability spaces, perform logical operations such as AND, OR, and NOT, and time-specific operations such as BEFORE and AFTER. The fuzzy logic processor is able to handle uncertainty and ambiguity, providing accurate and flexible answers to complex queries.
[0078] like Figure 5 As shown, the processing process of the system includes:
[0079] (1) Link prediction: First, a link predictor is used to complete the missing quadruple (s, r, o, t) in the temporal knowledge graph, where s represents subject, r represents relation, o represents object, and t represents timestamp. The purpose of this step is to enrich the information content of the knowledge graph and provide a more complete data foundation for subsequent queries.
[0080] (2) Time series probability modeling: Next, the completed time series knowledge graph is modeled as a time series probability distribution. Specifically, for each event (s, r, o), the probability P(s, r, o) of its occurrence at all time points is calculated. This model can capture the temporal dynamics of event occurrence and provide insights into the time dimension for further query analysis.
[0081] (3) Offline storage: In order to improve the efficiency of data retrieval and calculation, the time series probability distribution information is filtered and stored in the form of a sparse matrix. This step aims to optimize the storage structure and ensure that the required probability distribution values can be quickly obtained during the query process.
[0082] The above three steps constitute the preprocessing stage, laying the foundation for subsequent logical query processing. After the preprocessing is completed, the system can efficiently respond to any logical query, including:
[0083] (4) Input logical query: The system accepts the logical query input by the user. It should be noted that the logical query here is a structured query form, not a natural language, and it contains several knowledge graph nodes and logical relationships.
[0084] (5) Fuzzy logic operation: The system performs fuzzy logic operation on the time series probability distribution in response to the user's input. This operation process is represented by a tree structure, starting from the starting entity specified by the user and gradually advancing through logical operations until the target entity is reached. This method ensures the flexibility of the query and can effectively process time series information.
[0085] (6) Answer and path explanation: After fuzzy logic operation, the system can obtain the intermediate path from the starting point to the end point and the corresponding probability distribution. Among them, the path with the highest probability value is regarded as the answer to the query. At the same time, for these intermediate paths, the system can also provide explanations based on probability values to help users understand the logical reasoning process of the query results.
[0086] This series of steps not only enhances the application capabilities of the time series knowledge graph, but also improves the flexibility and interpretability of query processing through the introduction of fuzzy logic, providing users with an efficient and intuitive knowledge query service.
[0087] Specifically, constructing a time series probability distribution includes:
[0088] To make all temporal first-order logic (FOL) query operators reason in the same probability distribution space of the fuzzy logic processor, we introduce the Temporal Probability Distribution (TPD), a fuzzy Temporal Knowledge Graph (TKG) with explicit completion. To infer the score for each missing edge exist space. Then TPD can be defined as ,in , is a hypothetical condition. The probability is lower than Facts will be considered false. Figure 6 As shown, each triple can be represented as an explicit temporal probability distribution , directly reflects the specific occurrence time of this triple. In this embodiment, temporal knowledge graph completion (TKGC) is used as the neural link predictor In order to align the probability space of TPD with the temporal logic operators, a neural adjacency matrix is defined as follows:
[0089]
[0090] here, Indicates a given time Next, entity and Through the relationship In this way, not only can the dynamics and complexity of TKG be represented at the probabilistic level, but also the fuzzy logic processor can efficiently reason in this probabilistic space and process complex temporal logic queries. This method provides a new, more direct and flexible way to process temporal logic operations, which is expected to improve the accuracy and efficiency of answering complex temporal queries.
[0091] Specifically, the fuzzy distribution of entities and timestamps includes:
[0092] Explicit probability distributions are used to represent variables along the inference path, where each value in the interval [0, 1] represents an entity or timestamp assigned a score. , also called bound variables, is represented as a fuzzy vector The fuzzy vectors explicitly show the answer distribution of TemporalFOL queries. In addition, timestamps are naturally arranged in index order, which is beneficial for After and Before operators on time series.
[0093] Specifically, temporal logical operators include:
[0094] Type I Relationship Projection
[0095] Since the fuzzy sets, entities and timestamps of TPD satisfy fuzzy logic through t-norms, considering P e : P e (V, r,T) = V′, then:
[0096]
[0097] in, , , Represents a specific entity. represents a specific timestamp, both of which are given queries. And v' represents the answer entity. Here, we calculate the score of this special case assuming that the answer is a certain entity. That is, It indicates that given an entity v and a timestamp t, the answer at this time is the score of v'. represents the fuzzy entity distribution and fuzzy timestamp distribution, represents the fraction of a specific timestamp in the fuzzy timestamp distribution. [r,v,v',t] is a value of the fuzzy matrix, which means the score stored in the fuzzy matrix under the condition of relation r, head entity v, tail entity v', and time t. yes This is a special case of , and then this special case is extended to all head entities and all times:
[0098]
[0099] where ···× is a copy of the columns, superscript T is the transpose, ⊙ is the Hadamard product, : is a matrix slice, is the two-dimensional maximum. Similar to the above calculation, by repeating all v′∈ V, the calculation of v′ can be parallelized, because each calculation takes the data of a specific column and reuses v and t.
[0100] Similarly, Pt(V1, r, V2) = T, and we get:
[0101]
[0102] Type II Intersection and Type III Union
[0103]
[0104]
[0105] Type IV Negative
[0106] Since v[e] ∈ [0, 1] is the assignment score of entity e to variable v, and v[e] = 1 means 100% certainty, the negation of v[e] has an assignment score The calculation of timestamp is similar, and we can get the negation of fuzzy distribution:
[0107]
[0108] Type V Time After and Before
[0109] When processing temporal logic in a time series knowledge graph (TKG), especially when processing temporal logic operators such as "Before" and "After", this embodiment uses a fuzzy logic-based method to simulate the relationship between timestamps. The core idea of this method is to assume that for a given fuzzy distribution t, the assigned score of each timestamp is independent, which can flexibly handle the logical relationship in the time series.
[0110] Specific to the "Before" and "After" operators, the following strategy is used:
[0111] For the "Before" operation, assuming that t' is the time distribution after processing, the value of t'[i] is considered to be jointly contributed by the timestamp set {t[i + 1], ..., t[|T| - 1]}, that is, all timestamps after timestamp i contribute to the value of t'[i]. This reflects the probability distribution of the set of all possible events before a time point.
[0112] For the "After" operation, the value of t'[i] comes from the timestamp in the opposite direction, that is, all timestamps before timestamp i. Because this embodiment arranges the timestamps according to the index order of the fuzzy vector, it can simulate the probability distribution of a set of events that may occur after a time point.
[0113] In order to ensure that this processing method based on time logic is logically consistent and keep the sum of the probability distribution to 1, this embodiment introduces an amortization operation. Taking "Before" as an example, considering that all timestamps before timestamp i may contribute to it, all non-zero values of timestamp i in t are evenly redistributed to {t'[0], ..., t'[i -1]}, and the distribution of each value is t[i] / i. This method ensures that the probability score of each time point reflects the logical meaning of its position in the time series while maintaining the consistency of the entire distribution.
[0114] In this way, we can accurately simulate temporal logic operators such as "Before" and "After" without sacrificing distribution consistency, thereby effectively processing temporal logic queries in TKG. This method not only maintains the simplicity of the model, but also improves the flexibility and accuracy of processing temporal logic. It is an effective tool for processing complex temporal logic queries in temporal knowledge graphs.
[0115]
[0116] Specifically, the fuzzy reasoning process includes:
[0117] After designing the temporal logic operators, this embodiment can effectively process first-order logic (FOL) queries containing temporal logic, which is crucial for understanding and analyzing complex information in the temporal knowledge graph (TKG). The following are the steps to use these operators to solve the FOL problem with temporal logic:
[0118] (1) Initialize the fuzzy vector: After the user enters a logical query, a fuzzy vector needs to be initialized for the starting point of the query. This starting point can be a given entity or a timestamp. In the initialized fuzzy vector, the probability of the starting point element is set to 1, while the probabilities of all other elements are set to 0. This initialization ensures that the starting point of the query is given priority consideration in subsequent processing, while other elements are gradually explored as potential solutions during the logical operation process.
[0119] (2) Iteratively apply operations: Next, starting from the so-called anchor set, temporal logic operations are iteratively applied to the set of non-answers according to the directed edges defined in the knowledge graph computation graph. These operations include but are not limited to the designed temporal logic operators such as "Before", "After", and other logical operators (such as "and", "or", "not", etc.). The purpose of this step is to explore all possible paths and gradually narrow down the range of potential answers by continuously and iteratively applying temporal logic operations.
[0120] (3) Obtaining answer scores: For the target variable , we can get the fuzzy vector Get the sorted entity query answer score from . If a timestamp query is performed, the corresponding To obtain the sorted timestamp query answer scores. This step determines the final answer set by evaluating the probability score of each potential answer, and the answer with the highest score is considered the result of the query.
[0121] (4) Intermediate path explanation: For intermediate nodes on the reasoning path, fuzzy vectors can also be used to obtain the sorted answer scores. This not only helps determine the final answer, but also provides users with explanations of the intermediate path, enhancing the interpretability of the results. By analyzing these intermediate nodes and their scores, users can better understand how the answer is derived from the starting point of the query through logical operations.
[0122] Specifically, when performing a logical query on a knowledge graph, we first need to determine the starting point of the query, which is usually a specified entity or a specific timestamp. To this end, we create a data structure called a fuzzy vector v, where the index position of the query starting point is set to 1 and all other elements are set to 0. In the knowledge graph, the number of entities or timestamps determines the dimension of the vector, so v is a vector with a length equal to the number of entities or timestamps.
[0123] Next, the query process starts with the so-called anchor set. An anchor set refers to a set of entities that are directly related to the starting entity or timestamp in the logical query. In the context of knowledge graphs, a computational graph represents the structure of entities connected by relationships and computed for logical queries. In this computational graph, the relationships between entities are represented by directed edges.
[0124] In order to find the answer that satisfies the logical query, starting from the anchor set, the computation graph is iterated and temporal logic operations are applied to the entities in the non-answer set. The non-answer set refers to the set of entities that do not currently satisfy the query conditions. In each iteration, the system updates the fuzzy vector v using the temporal logic operators defined in the input logical query (such as "before", "after", or "at the same time"), gradually approaching the final answer set.
[0125] After multiple iterations, an updated fuzzy vector is obtained. , each element of which represents the probability score of the corresponding entity or timestamp becoming the final answer. These scores reflect the degree to which each entity or timestamp matches the query conditions.
[0126] Finally, the target vector for the query , from the updated blur vector If the goal of this example is to query entities, use to get the sorted entity query answer score; if the query target is a timestamp, use to get the sorted answers to the timestamp query. The answer set can be viewed by The element with the highest score is obtained, and the answer entities (or timestamps) are sorted in descending order of their matching scores.
[0127] The final answer can be expressed as the following expression:
[0128]
[0129] Here R is the answer number, The operation is to find the subscript corresponding to the element with the largest value in a vector.
[0130] In order to implement the above embodiments, the present application also proposes a temporal knowledge graph logical reasoning device based on time probability distribution.
[0131] Figure 7 A schematic diagram of a time series knowledge graph logic reasoning device based on time probability distribution provided in an embodiment of the present application. The time series knowledge graph is generated based on text data. Each text in the text data represents an event in the real world. The time series knowledge graph is generated based on text data. The device stores an event in the real world in the form of a time series knowledge graph. Based on the logical query input by the user, the device performs logical reasoning on the time series knowledge graph to obtain the query result.
[0132] like Figure 7 As shown, the temporal knowledge graph logic reasoning device based on time probability distribution includes:
[0133] The knowledge graph completion module is used to complete the temporal knowledge graph through the link predictor;
[0134] The knowledge graph modeling module is used to model the completed time series knowledge graph as a time series probability distribution, and convert the time series probability distribution into a time series probability distribution in the form of a sparse matrix through screening;
[0135] The query module is used to perform fuzzy logic operations on the time series probability distribution in the form of a sparse matrix for the logical query input by the user, obtain the intermediate path from the starting point to the end point and the corresponding probability distribution, and take the path with the highest probability value as the query result.
[0136] It should be noted that the aforementioned explanation of the embodiment of the temporal knowledge graph logical reasoning method based on time probability distribution is also applicable to the temporal knowledge graph logical reasoning device based on time probability distribution of this embodiment, and will not be repeated here.
[0137] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0138] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0139] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0140] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0141] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0142] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0143] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0144] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A temporal knowledge graph logical reasoning method based on temporal probability distribution, characterized in that: The temporal knowledge graph is generated based on text data. Each text in the text data represents an event in the real world. An event in the real world is stored in the form of, and the method performs logical reasoning on the time series knowledge graph based on a logical query input by a user to obtain a query result, and the method includes: Completing the temporal knowledge graph through link predictors; Modeling the completed time series knowledge graph as a time series probability distribution, and converting the time series probability distribution into a time series probability distribution in a sparse matrix form through screening; For the logical query input by the user, a fuzzy logic operation is performed on the time series probability distribution in the sparse matrix form to obtain the intermediate path from the starting point to the end point and the corresponding probability distribution, and the path with the highest probability value is taken as the query result; The method of completing the temporal knowledge graph by using a link predictor includes: For each missing edge of the temporal knowledge graph, at any time On, through the neural link predictor Inferred by any tail entity The four-tuple In the probability space Score in , , where the probability space is the probability space of time series probability distribution; The method of modeling the completed time series knowledge graph as a time series probability distribution includes: Neural Link Predictor The inferred scores construct the temporal probability distribution of entities or timestamps ,in, , is the preset threshold, the probability is lower than The fact is a false fact; For any tail entity , determine the triples it constitutes The explicit temporal probability distribution of ,in, Represents a triple The probability of occurrence at all times, triple At any time The probability of occurrence of ; A neural adjacency matrix is defined to align the temporal probability distributions with the temporal logical operators.
2. The temporal knowledge graph logical reasoning method based on time probability distribution according to claim 1 is characterized in that: The neural adjacency matrix is , Represents the probability of links between different entities through specific relationships at a given time, the neural adjacency matrix Elements in It is expressed as: in, Indicates a given time Next, entity and Through the relationship connection probability.
3. The temporal knowledge graph logical reasoning method based on time probability distribution as claimed in claim 2, characterized in that: The method further comprises: When performing logical reasoning, explicit time probability distribution is used to represent the variable expression along the reasoning path. In all the explicit time probability distributions determined, each value in the interval [0, 1] represents the assigned score of the corresponding entity or timestamp; The fuzzy set in the time series probability distribution is , the corresponding fuzzy vector is .
4. The temporal knowledge graph logical reasoning method based on time probability distribution as claimed in claim 3 is characterized in that: The logical query is a first-order logical query, the logical query is an entity query or a timestamp query, the logical query includes an entity, a timestamp and several time logic operators, the time logic operators are relational projection, intersection, union, negation, After or Before, The temporal logic operation of relational projection is expressed as: in, , , Represents a specific entity. Indicates a specific timestamp. , For a given query, For the answer object, Represents a given entity , given a timestamp , the answer is The score, represents the fuzzy entity distribution and fuzzy timestamp distribution, Represents the fraction of a specific timestamp in the fuzzy timestamp distribution, is a value of the fuzzy matrix, indicating that , head entity , tail entity , timestamp In the case of , the scores stored in the fuzzy matrix are yes A case of , which is extended to all head entities and time, the extended expression is: Among them, ···× is a copy of the column, the superscript T represents the transpose, ⊙ represents the Hadamard product, and : represents a matrix slice. is the two-dimensional maximum; The time logic operation of AND is expressed as: in, Represents the fraction of a specific timestamp in the fuzzy timestamp distribution, represents the score of a specific entity in the fuzzy entity distribution, Indicates a timestamp or the total number of entities; The temporal logic operation of intersection is expressed as: The time logic operation of After is expressed as: Before time logic operation is expressed as: in, Represents the fraction of a specific timestamp in the fuzzy timestamp distribution.
5. The temporal knowledge graph logical reasoning method based on time probability distribution as claimed in claim 4 is characterized in that: The logic query input by the user performs fuzzy logic operation on the time series probability distribution in the sparse matrix form to obtain the intermediate path from the starting point to the end point and the corresponding probability distribution, and takes the path with the highest probability value as the query result, including: Build the initial fuzzy vector starting from the entity or timestamp in the logical query , when building, the dimension of the vector is determined based on the number of entities or timestamps in the logical query, and the index position of the query starting point is set to 1, and all other elements are set to 0; The entity set directly related to the entity or timestamp in the logical query is taken as the anchor set, and the entity set that does not meet the query condition is taken as the non-answer set. Starting from the anchor set, the knowledge graph calculation graph is iteratively traversed. During the traversal, the entities in the current non-answer set are subjected to temporal logic operations according to the temporal logic operators included in the logical query to achieve the initial fuzzy vector. The updated fuzzy vector is obtained through multiple iterations. ; Determine whether the logical query is an entity query or a timestamp query. If it is an entity query, use Get the entity query answer sorted in descending order by score. If it is a timestamp query, use Get the answer to the timestamp query sorted in descending order by score; Will The element with the highest score is taken as the final answer set.
6. The temporal knowledge graph logical reasoning method based on time probability distribution as claimed in claim 5, characterized in that: Also includes: For the intermediate nodes on the reasoning path, use the updated fuzzy vector Get the sorted answer scores.
7. The temporal knowledge graph logical reasoning method based on time probability distribution according to claim 6 is characterized in that: The final answer set is expressed as: in, Number your answers. The operation is to get the subscript corresponding to the element with the largest value in a vector.
8. A temporal knowledge graph logical reasoning device based on temporal probability distribution, characterized in that: The temporal knowledge graph is generated based on text data. Each text in the text data represents an event in the real world. The device stores an event in the real world in the form of, based on the logical query input by the user, performs logical reasoning on the time series knowledge graph to obtain the query result, and the device includes: The knowledge graph completion module is used to complete the temporal knowledge graph through the link predictor; A knowledge graph modeling module is used to model the completed time series knowledge graph as a time series probability distribution, and convert the time series probability distribution into a time series probability distribution in a sparse matrix form through screening; A query module is used to perform fuzzy logic operations on the time series probability distribution in the form of a sparse matrix for the logic query input by the user, obtain the intermediate path from the starting point to the end point and the corresponding probability distribution, and take the path with the highest probability value as the query result; The method of completing the temporal knowledge graph by using a link predictor includes: For each missing edge of the temporal knowledge graph, at any time On, through the neural link predictor Inferred by any tail entity The four-tuple In the probability space Score in , , where the probability space is the probability space of time series probability distribution; The method of modeling the completed time series knowledge graph as a time series probability distribution includes: Neural Link Predictor The inferred scores construct the temporal probability distribution of entities or timestamps ,in, , is the preset threshold, the probability is lower than The fact is a false fact; For any tail entity , determine the triples it constitutes The explicit temporal probability distribution of ,in, Represents a triple The probability of occurrence at all times, triple At any time The probability of occurrence of ; A neural adjacency matrix is defined to align the temporal probability distributions with the temporal logical operators.
