Temporal knowledge graph reasoning method, system and device based on graph topology enhancement
By using a graph topology enhancement method, the historical topology graph is dynamically expanded and combined with a large language model and graph model for temporal knowledge graph reasoning. This solves the problem of low efficiency and accuracy in existing technologies and achieves more efficient and accurate temporal knowledge completion.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INST OF AUTOMATION CHINESE ACAD OF SCI
- Filing Date
- 2026-03-17
- Publication Date
- 2026-07-03
AI Technical Summary
Existing technologies for temporal knowledge graph reasoning have low efficiency and accuracy, large rule search space and poor adaptability, and methods based on large language models have high computational cost and poor transferability, and fail to effectively model topological connections and temporal dependencies.
By using a graph-based topology enhancement method, the historical topology graph is dynamically expanded to construct the target topology graph, quantify the potential association strength, and combine large language models and graph models for reasoning to construct prompt words to improve accuracy and efficiency.
It improves the accuracy and efficiency of temporal knowledge graph reasoning, achieves more efficient and accurate temporal knowledge completion, and solves the efficiency and accuracy problems existing in the current technology.
Smart Images

Figure CN121859950B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and more specifically to a temporal knowledge graph reasoning method, system, and device based on graph topology enhancement. Background Technology
[0002] Temporal knowledge graphs (TKGs) represent facts in the form of quadruples, enabling them to characterize the dynamic evolution of knowledge over time. Temporal knowledge graph reasoning (TKGR) is a core task in this field, aiming to infer possible future events based on historical facts within this dynamic evolutionary sequence.
[0003] In the process of realizing the concept of this invention, it was found that the related technologies have at least the following problems: the related technologies mostly use temporal logic rules for reasoning. However, due to the large rule search space and the constraints of the dataset itself, there are technical problems of low reasoning efficiency and accuracy. Summary of the Invention
[0004] In view of the above problems, the present invention provides a temporal knowledge graph reasoning method, system and device based on graph topology enhancement.
[0005] According to one aspect of the present invention, a temporal knowledge graph reasoning method based on graph topology enhancement is provided, comprising: adding nodes and directed edges to a historical topology graph based on the types of multiple elements in a quadruple to be completed, to obtain a target topology graph, wherein nodes represent elements of a preset type and directed edges represent the associations between elements of different types, and the historical topology graph includes historical nodes determined by multiple historical quadruples and directed edges between historical nodes; determining the potential association strength between the quadruple to be completed and multiple historical quadruples based on the time decay of each historical quadruple compared to the quadruple to be completed and the connection between each node and each historical node in the target topology graph; constructing a prompt word based on the quadruple to be completed and at least one target quadruple determined from multiple historical quadruples using the potential association strength; inputting the prompt word into a large language model to reason for multiple first candidate elements and a first confidence level of each first candidate element; and determining the element to be completed based on the multiple first candidate elements, the first confidence level of each first candidate element, and multiple second candidate elements and a second confidence level of each second candidate element obtained by reasoning from the quadruple to be completed by the graph model.
[0006] Another aspect of the present invention provides a temporal knowledge graph reasoning system based on graph topology enhancement, comprising: a topology generation module, used to add nodes and directed edges to a historical topology graph based on the types of multiple elements in a quadruple to be completed, to obtain a target topology graph, wherein nodes represent elements of a preset type, and directed edges represent the associations between elements of different types, and the historical topology graph includes historical nodes determined by multiple historical quadruples and directed edges between historical nodes; and a first determination module, used to determine the time decay of each historical quadruple compared to the quadruple to be completed and the connections between each node and each historical node in the target topology graph. Depending on the situation, the potential association strength between the quadruple to be completed and multiple historical quadruples is determined; a construction module is used to construct a prompt word based on the quadruple to be completed and at least one target quadruple determined from multiple historical quadruples using the potential association strength; an inference module is used to input the prompt word into a large language model to infer multiple first candidate elements and the first confidence level of each first candidate element; a second determination module is used to determine the element to be completed based on multiple first candidate elements, the first confidence level of each first candidate element, and multiple second candidate elements and the second confidence level of each second candidate element obtained by inference from the quadruple to be completed by the graph model.
[0007] Another aspect of the present invention provides an electronic device comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.
[0008] Another aspect of the present invention provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, implement the steps of the above-described method.
[0009] Another aspect of the present invention provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method.
[0010] According to embodiments of the present invention, by analyzing the types of each element in the quadruple to be completed, the historical topology graph is dynamically expanded to construct a target topology graph containing newly added nodes and directed edges, thereby achieving a structured representation of the quadruple to be completed. Based on this, by combining the time decay of each historical quadruple and the connection relationships of each node in the target topology graph, the potential correlation strength between the quadruple to be completed and each historical quadruple is quantified, achieving a fine-grained evaluation of the relevance of historical information and improving the utilization of the global graph structure. Based on the quadruple to be completed and at least one target historical quadruple selected using potential correlation strength, prompt words are constructed and input into a large language model for reasoning. Utilizing its semantic understanding capabilities, multiple first candidate elements and their confidence levels are obtained, thereby improving the answer coverage of historical events. Combined with multiple second candidate elements obtained from graph model reasoning and their respective confidence levels, the element to be completed is comprehensively determined, improving the accuracy and efficiency of temporal knowledge graph reasoning. Therefore, this at least partially solves the technical problem of low reasoning efficiency and accuracy, achieving a more efficient and accurate technical effect for temporal knowledge completion. Attached Figure Description
[0011] The above-mentioned contents, as well as other objects, features and advantages of the present invention, will become clearer from the following description of embodiments of the present invention with reference to the accompanying drawings.
[0012] Figure 1 The diagram illustrates an application scenario of a graph-topology-enhanced temporal knowledge graph reasoning method, system, and device according to an embodiment of the present invention.
[0013] Figure 2 A flowchart of a time-series knowledge graph reasoning method based on graph topology enhancement according to an embodiment of the present invention is shown.
[0014] Figure 3 A schematic diagram of the target topology graph construction process according to an embodiment of the present invention is shown.
[0015] Figure 4 A schematic diagram of prompt words according to an embodiment of the present invention is shown.
[0016] Figure 5 A schematic diagram of a time-series knowledge graph reasoning method based on graph topology enhancement according to an embodiment of the present invention is shown.
[0017] Figure 6 A block diagram of a temporal knowledge graph reasoning system based on graph topology enhancement according to an embodiment of the present invention is shown.
[0018] Figure 7 An architecture diagram of a time-series knowledge graph reasoning system based on graph topology enhancement according to an embodiment of the present invention is shown.
[0019] Figure 8A block diagram of an electronic device suitable for implementing a graph topology-enhanced temporal knowledge graph reasoning method according to an embodiment of the present invention is shown. Detailed Implementation
[0020] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the invention. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the invention for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concept of the invention.
[0021] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0022] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0023] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0024] In the technical solution of this invention, the data involved (including but not limited to data used for analysis, data stored, data displayed, etc.) are all information and data authorized by the user or fully authorized by all parties. The collection, storage, use, processing, transmission, provision, disclosure and application of related data all comply with relevant laws, regulations and standards, necessary confidentiality measures have been taken, and they do not violate public order and good morals. Corresponding operation entry points are provided for users to choose to authorize or refuse.
[0025] Temporal knowledge graph reasoning is essentially an extrapolation-based prediction, which learns evolutionary patterns from historical temporal patterns and then generates predictions of future facts. It has important application value in event prediction, decision support, and other fields.
[0026] Related technologies typically employ rule-based methods, which specifically perform reasoning by mining temporal logic rules, offering good interpretability. However, their challenges lie in the large rule search space, making it difficult to generate a sufficient number of high-quality rules, and their poor adaptability to heterogeneous datasets.
[0027] Therefore, this invention utilizes the powerful semantic understanding and reasoning capabilities of Large Language Models (LLMs) for TKGR inference. However, during the research process, it was found that fine-tuning LLMs on specific datasets to adapt them to the TKGR task incurs high training overhead and computational costs. Furthermore, the model is prone to overfitting to specific datasets, exhibits poor transferability, and struggles to cope with the continuous dynamic updates of data in the real world.
[0028] Without fine-tuning the LLM, the primary approach leverages its contextual learning capabilities by retrieving relevant historical events as clues to guide inference. This method is more flexible, but its performance is highly dependent on the quality of the retrieved historical events. If the retrieved historical context fails to contain sufficient information or the correct answer, inference will directly fail, thus its performance is typically weaker than fine-tuning methods.
[0029] Furthermore, the research revealed that the effectiveness of non-fine-tuning methods is highly dependent on the "answer coverage" (i.e., the proportion of retrieved historical events containing correct answers) of the retrieved historical events. If the retrieval strategy (such as simple matching based on entities and relationships) cannot accurately locate highly relevant contexts, the model will not be able to obtain sufficient reasoning basis. Moreover, non-fine-tuning methods typically treat the task as pure text reasoning, failing to effectively model the key topological connections and temporal dependencies in the temporal knowledge graph, resulting in a lack of deep structural information.
[0030] Furthermore, the research also revealed that in temporal knowledge graph reasoning, learning the embedded representations of entities and relationships based on graph neural networks (GNNs) can explicitly model the dynamic evolution of knowledge over time, enabling joint learning of structural and temporal features.
[0031] Therefore, embodiments of the present invention provide a temporal knowledge graph reasoning method based on graph topology enhancement. By introducing a graph topology enhancement retrieval strategy, including steps such as determining the potential association strength between the quadruple to be completed and multiple historical quadruples, and filtering target quadruples, the answer coverage of historical context is improved, providing a more accurate reasoning basis for LLM. Furthermore, by combining the semantic understanding capability of LLM with the global structure awareness capability of graph models, the prediction results are made more robust and accurate.
[0032] Figure 1The diagram illustrates an application scenario of a graph-topology-enhanced temporal knowledge graph reasoning method, system, and device according to an embodiment of the present invention.
[0033] like Figure 1 As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0034] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0035] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0036] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0037] It should be noted that the graph topology-enhanced temporal knowledge graph reasoning method provided in this embodiment of the invention can generally be executed by server 105. Correspondingly, the graph topology-enhanced temporal knowledge graph reasoning system provided in this embodiment of the invention can generally be located in server 105. The graph topology-enhanced temporal knowledge graph reasoning method provided in this embodiment of the invention can also be executed by a server or server cluster that is different from server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the graph topology-enhanced temporal knowledge graph reasoning system provided in this embodiment of the invention can also be located in a server or server cluster that is different from server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.
[0038] It should be understood that Figure 1 The number of first terminal devices, second terminal devices, third terminal devices, networks, and servers shown in the diagram is merely illustrative. Depending on implementation needs, any number of first terminal devices, second terminal devices, third terminal devices, networks, and servers can be included.
[0039] The following will be based on Figure 1 The described scene, through Figures 2-5 The invention provides a detailed description of the temporal knowledge graph reasoning method based on graph topology enhancement according to the embodiments of the invention.
[0040] Figure 2 A flowchart of a time-series knowledge graph reasoning method based on graph topology enhancement according to an embodiment of the present invention is shown.
[0041] like Figure 2 As shown, the method includes operations S210 to S250.
[0042] In operation S210, based on the types of multiple elements in the quadruple to be completed, nodes and directed edges are added to the historical topology graph to obtain the target topology graph. Nodes represent elements of a preset type, and directed edges represent the associations between elements of different types. The historical topology graph includes historical nodes determined by multiple historical quadruples and directed edges between historical nodes.
[0043] In operation S220, based on the time decay of each historical quadruple relative to the quadruple to be completed and the connection between each node and each historical node in the target topology graph, the potential association strength between the quadruple to be completed and multiple historical quadruples is determined.
[0044] In operation S230, a prompt word is constructed based on the quadruple to be completed and at least one target quadruple determined from multiple historical quadruples using potential association strength.
[0045] In operation S240, the prompt words are input into the large language model to infer multiple first candidate elements and the first confidence of each first candidate element.
[0046] In operation S250, based on multiple first candidate elements, the first confidence level of each first candidate element, and multiple second candidate elements obtained from the graph model inference of the quadruple to be completed, and the second confidence level of each second candidate element, the element to be completed is determined.
[0047] A history quadruple can include the following types of history elements: history entity elements of type entity, history time elements of type timestamp, and history relation elements of type relation; among them, history entity elements include history subject elements of type subject and history object elements of type object.
[0048] Specifically, the historical quadruple can take the form of (subject, relation, object, timestamp), for example: (Company A, release, product a, 2007-01-××).
[0049] Similarly, the quadruple to be completed can also include elements of multiple types, such as entity elements of type entity, time elements of type timestamp, and relation elements of type relation; wherein, the entity elements include subject elements of type subject and object elements of type object.
[0050] Multiple elements can include the element to be completed, meaning the element to be completed can be any one or more of the above types of elements, namely, subject element, relation element, object element, or time element. The elements in the quadruple to be completed other than the element to be completed can be called known elements.
[0051] In the implementation process, nodes and directed edges can be determined based on the types of multiple elements in the quadruple to be completed. For example, multiple elements can be treated as nodes, and directed edges can be constructed according to a preset pointing logic. Another example is that relational elements can be used as attributes of directed edges, and subject elements, object elements, and time elements can be used as nodes.
[0052] By constructing a target topology graph using the quadruples to be completed and the historical quadruples, discrete temporal knowledge graphs can be integrated into a topology graph with timestamps that can reflect the relationships between elements, thus facilitating subsequent reasoning and analysis.
[0053] When determining the potential correlation strength between the quadruple to be completed and each historical quadruple, the decay effect over time can be considered. Since the influence of historical facts on current reasoning usually weakens over time, more recent events often have higher reference value. Therefore, different time weights can be assigned to each historical quadruple based on the time interval between it and the quadruple to be completed.
[0054] Furthermore, from a structural perspective, the connections between nodes and historical nodes in the target topology graph can reflect the semantic relationships between entities. By analyzing the path connectivity and path distance between the node corresponding to the quadruple to be completed and the historical node corresponding to the historical quadruple in the graph structure, the structural tightness between the node and the historical node can be measured. This combines the time decay factor with the structural tightness to comprehensively quantify the correlation between each historical quadruple and the quadruple to be completed, thereby achieving a fine-grained assessment of the importance of historical information and providing a basis for subsequent selection of target quadruples.
[0055] There are no restrictions on the methods for determining the potential association strength between the quadruple to be completed and multiple historical quadruples. In addition to the methods mentioned above, personalized PageRank, SimRank, and other methods can be combined for comprehensive determination. Personalized PageRank is an extension of traditional PageRank, used to calculate the local importance or association of nodes in a graph relative to a specified source node. Personalized PageRank can start from a specific node in the quadruple to be completed, performing a random walk with restart on the target topology graph to obtain a probability distribution. The probability value of each historical node in this distribution represents its association strength with the specific node. SimRank is a node similarity algorithm based on graph structure. Its recursive idea is: if two nodes are pointed to by similar neighbor nodes or point to similar neighbors, then the two nodes are similar.
[0056] Based on the strength of potential association, multiple target quadruples with high potential association strength with the quadruples to be completed can be selected from historical quadruples. These target quadruples represent historical facts that are closely related to the current reasoning in terms of time sequence and structure. Subsequently, the known elements in the quadruples to be completed can be integrated with the multiple target quadruples into a natural language description.
[0057] For example, target quadruples can be arranged chronologically to form a context. Then, the quadruples to be completed are presented in the form of a query, explicitly indicating the elements to be completed that need to be predicted, and guiding the large language model to infer the most likely elements to be completed based on historical facts, thereby forming prompt words.
[0058] The constructed prompt words are input into the large language model, which leverages its powerful semantic understanding and contextual reasoning capabilities to generate multiple prediction results for the element to be completed. Each prediction result is accompanied by a corresponding confidence score, which serves as the first candidate element and its first confidence score output.
[0059] The first candidate elements and first confidence scores output by the large language model are fused with the second candidate elements and second confidence scores obtained by graph model inference. By comprehensively comparing the confidence scores of the two types of candidate elements and combining them with a preset fusion strategy, the elements to be completed are determined from the candidate set, thereby completing the temporal knowledge graph.
[0060] According to embodiments of the present invention, by analyzing the types of each element in the quadruple to be completed, the historical topology graph is dynamically expanded to construct a target topology graph containing newly added nodes and directed edges, thereby achieving a structured representation of the quadruple to be completed. Based on this, by combining the time decay of each historical quadruple and the connection relationships of each node in the target topology graph, the potential correlation strength between the quadruple to be completed and each historical quadruple is quantified, achieving a fine-grained evaluation of the relevance of historical information and improving the utilization of the global graph structure. Based on the quadruple to be completed and at least one target historical quadruple selected using potential correlation strength, prompt words are constructed and input into a large language model for reasoning. Utilizing its semantic understanding capabilities, multiple first candidate elements and their confidence levels are obtained, thereby improving the answer coverage of historical events. Combined with multiple second candidate elements obtained from graph model reasoning and their respective confidence levels, the element to be completed is comprehensively determined, improving the accuracy and efficiency of temporal knowledge graph reasoning. Therefore, this at least partially solves the technical problem of low reasoning efficiency and accuracy, achieving a more efficient and accurate technical effect for temporal knowledge completion.
[0061] According to embodiments of the present invention, the graph topology-enhanced temporal knowledge graph reasoning method constructs a corresponding hybrid reasoning framework. This method eliminates the need for fine-tuning of large language models; instead, it improves reasoning performance through an innovative graph topology retrieval strategy.
[0062] According to an embodiment of the present invention, based on the types of the multiple elements included in the quadruple to be completed, nodes and directed edges are added to the historical topology graph to obtain the target topology graph, which may include the following operations.
[0063] If the preset type is all types, multiple elements are treated as nodes; based on the preset pointing logic between each type, directed edges between multiple nodes are determined; multiple nodes and directed edges are added to the historical topology graph.
[0064] Figure 3 A schematic diagram of the target topology graph construction process according to an embodiment of the present invention is shown.
[0065] like Figure 3 As shown, the quadruple to be completed and the history quadruple can be represented in the form (s, r, o, t), where s represents the subject element, r represents the relation element, o represents the object element, and t represents the timestamp, i.e., the time element.
[0066] In the diagram, entities 1 and 2, 1 and 3, and 2 and 4 can each belong to the same historical quadruple. Entity 2 and the element to be completed can belong to the quadruple to be completed. The temporal relationship can be determined based on the time element of each quadruple; for example, entities 1 and 2, and 1 and 3 correspond to 2014-04-01, while entities 2 and 4, and 2 and the element to be completed correspond to 2014-06-01. R1, R2, and R3 represent the relationships between the entities, respectively representing consultation, issuing a statement, and conducting a visit.
[0067] When constructing the target topology graph, for the quadruple to be completed, the following operations can be performed: create nodes for each unique s, r, o, t; create directed edges between nodes using preset pointing logic. The preset pointing logic is not limited and can be configured according to actual needs, such as: s→r, s→t, r→t, r→o, t→o. It can also include o→t, etc. This yields the topology of entity 2→R3→2014-06-01→the element to be completed. By merging this topology with the historical topology graph, the following can be obtained: Figure 3 The target topology diagram is shown.
[0068] The topologies of Entity 1→R1→2014-02-01→Entity 2, Entity 1→R2→2014-02-01→Entity 3, and Entity 2→R2→2014-06-01→Entity 4 can be used to construct historical topology graphs. Historical topology graphs can be either previously constructed or constructed when building the target topology graph in this instance.
[0069] You can also assign edge attributes to each edge, such as a timestamp attribute, to record its earliest occurrence time, ensuring that only events before the time element of the quadruple to be completed are considered during retrieval.
[0070] If the preset type is partial type, the elements that are nodes and the elements that are edge attributes are determined based on the type of each element, and the nodes and edge attributes are added to the historical topology graph.
[0071] According to embodiments of the present invention, traditional time-slice discretely distributed temporal knowledge graphs are integrated into a unified topological graph representation. This method, by introducing time-aware nodes and edges, fuses facts from different time slices into a coherent graph structure, thereby preserving temporal evolution information and eliminating the fragmentation between time slices. Furthermore, it supports seamless dynamic insertion of new data; flexible updates can be achieved simply by expanding the corresponding nodes and edges.
[0072] According to an embodiment of the present invention, the historical quadruple includes a historical time element of type timestamp; the quadruple to be completed includes a time element of type timestamp; the connection status includes connection paths; based on the time decay of each historical quadruple compared to the quadruple to be completed and the connection status between each node and each historical node in the target topology graph, the potential association strength between the quadruple to be completed and multiple historical quadruples can be determined, which may include the following operations.
[0073] Based on the historical time elements of each historical quadruple and the time elements of the quadruple to be completed, the time decay of each historical quadruple relative to the quadruple to be completed is determined. For the same historical quadruple, based on the length of the connection path between each node and multiple historical nodes of the historical quadruple, the initial association strength between the quadruple to be completed and the historical quadruple is determined. Based on the time decay of each historical quadruple relative to the quadruple to be completed, the initial association strength of each historical quadruple is corrected to obtain the potential association strength between the quadruple to be completed and multiple historical quadruples.
[0074] For each to-be-predicted complete quadruple It can calculate its relationship with each historical quadruple in the target topology graph. (in The topological association strength of ), i.e., the initial association strength. Represents the main element, Represents relational elements. Represents the time element. This indicates the element to be completed; in this example, it is an object element. In practical applications, the specific type of the element to be completed is not limited; it can be an object element, a subject element, a relation element, etc. Representing the main elements of history, Elements representing historical relationships Representing historical time elements, Represents historical object elements.
[0075] In the target topology graph, the length of the connection path between each node in the quadruple to be completed and each historical node in the historical quadruple can be calculated, and the number of connection paths of different lengths can be counted. The path length reflects the ease with which nodes can pass information through the graph structure; generally, the shorter the length, the tighter the structural association.
[0076] The initial association strength between the historical quadruple and the quadruple to be completed can be obtained by combining the length of the connection path between each node in the quadruple to be completed and the historical nodes of each historical quadruple, as well as the number of connection paths of different lengths, for example, by taking the minimum or average value of the path length or by weighted summation of the number of connection paths of different lengths.
[0077] To further emphasize temporal proximity, a time decay factor can be introduced. The initial association strength is calibrated so that historical facts that are closer to the query time point, i.e., historical quadruples, receive higher weights.
[0078] There are no restrictions on the calculation method of the time decay factor. It can be calculated using the following linear decay function, as shown in formula (1).
[0079] (1)
[0080] in, This represents the attenuation coefficient.
[0081] Alternatively, a nonlinear function can be used to calculate the time decay factor, as shown in the following formula (2).
[0082] (2)
[0083] By combining topological association strength and temporal proximity, the quadruplets to be completed can be corrected using the following formula (3). With the historical quadruple Initial correlation strength between This yields the potential correlation strength between the quadruple to be completed and the historical quadruple. .
[0084] (3)
[0085] After calculating the potential association strength between all historical quadruples and the quadruples to be completed, the historical quadruples can be sorted in descending order according to the magnitude of the potential association strength, and the top N most relevant historical quadruples can be selected as target quadruples and input into the large language model.
[0086] According to an embodiment of the present invention, based on a unified topology graph, a historical quadruple relevance scoring mechanism is proposed that integrates initial association strength (characterizing the strength of topological associations between nodes and capturing multi-hop dependencies) and temporal decay factor (measuring temporal relevance). This mechanism can take into account both structural similarity and temporal proximity, enabling more accurate retrieval of relevant and high-confidence historical events, thereby improving the answer coverage of historical events subsequently input into a large language model.
[0087] According to an embodiment of the present invention, determining the initial association strength between the quadruple to be completed and the historical quadruple based on the length of the connection path between each node and multiple historical nodes of the historical quadruple can include the following operations.
[0088] For each node, determine the number of connection paths of different lengths between the node and multiple historical nodes of the historical quadruple; for each length, sum the number of connection paths of different lengths between the node and multiple historical nodes of the historical quadruple to obtain the single-node association strength between the node and the historical quadruple at that length; based on the weights determined by each length, sum the single-node association strengths between the node and the historical quadruple at multiple lengths to obtain the target single-node association strength, where length is inversely proportional to weight; based on a preset weighted reassembly, sum the target single-node association strengths of multiple nodes of the quadruple to be completed to obtain the initial association strength between the quadruple to be completed and the historical quadruple.
[0089] For single-node pairs, such as the sub-association strength between a node and its historical nodes. It can be determined by the following formula (4).
[0090] (4)
[0091] in, This indicates that the length from node u to historical node v is... The number of paths, where β represents the decay factor (usually set to 0.5). Indicates the maximum path length.
[0092] Based on this, the initial correlation strength between the quadruple to be completed and the historical quadruple is... It can be composed of a weighted sum of three parts, and the calculation method can be shown in the following formula (5).
[0093] (5)
[0094] Among them, the function Used to calculate a specific element in the quadruple to be completed. The sum of the sub-association strengths with the four elements in the historical quadruple h; It can be , or Indicates the weight of each part; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths; Indicates from the representation Node to representation The length of the historical node is The number of paths. If a certain element in the quadruple to be completed... If it is completely new and has never appeared before, then it is defined as In temporal knowledge graph reasoning tasks, if the time element of a future query... If there are no edges pointing to historical nodes in the graph, then always... Therefore, in actual calculations, if This item can be ignored.
[0095] According to embodiments of the present invention, by statistically analyzing the number of connection paths of varying lengths between each node and each historical node in the historical quadruple, a comprehensive capture of multi-hop association information in the graph structure is achieved. Compared to methods that only consider direct connections or shortest paths, this approach can uncover indirect semantic associations hidden in long paths, thus more completely reflecting the potential historical interaction patterns between nodes. Furthermore, applying weights inversely proportional to the length of paths reflects the characteristic that the greater the distance, the weaker the association. This suppresses noise interference from long paths while preserving their reasonable contribution to the overall association strength, ensuring that the calculation of the initial association strength has both a global perspective and maintains the characteristics of close local associations, thereby improving quantification accuracy and robustness.
[0096] Furthermore, by using a pre-defined weighted reassembly to perform a weighted summation of the association strengths of target single nodes across different nodes, differentiated processing of the importance of each element in the query is achieved. Since the semantic roles of elements such as subject, relation, object, and time in the quadruple to be completed differ in the reasoning task, their dependence on historical facts also varies. This operation can flexibly configure node weights according to specific task requirements, enabling the initial association strength to better adapt to different reasoning scenarios.
[0097] According to an embodiment of the present invention, constructing a cue word based on the quadruple to be completed and at least one target quadruple determined from a plurality of historical quadruples using potential association strength may include the following operations.
[0098] When there are multiple target quadruples, at least one target quadruple is sorted according to the historical time elements in the multiple target quadruples to obtain a sorting result. Numerical labels are assigned to the historical elements included in each of the multiple target quadruples and the multiple elements included in the quadruples to be completed. For repeated historical elements, the numerical label of the repeated historical element when it first appeared is retained. For elements that are the same as historical elements, the numerical label of the same historical element is retained. According to the sorting result, the quadruples to be completed, the multiple target quadruples, and the numerical labels are embedded into the prompt word template to obtain prompt words. The prompt words are used to constrain the large language model to select or infer multiple first candidate elements from the vocabulary of numerical labels determined by historical elements of the same type as the elements to be completed, and output the first confidence of each first candidate element.
[0099] To reduce the inference difficulty of large language models, the temporal knowledge graph inference task can be transformed into a "numerical label prediction" problem. In the implementation process, the retrieved historical events, i.e., the target quadruples, can be sorted by time, and each element that appears for the first time in the quadruple can be assigned an integer label starting from 0. Entity elements in the quadruple to be completed that are the same as the historical entity elements will not be reassigned.
[0100] Figure 4A schematic diagram of prompt words according to an embodiment of the present invention is shown.
[0101] like Figure 4 As shown, the elements to be completed in the quadruplets are object elements. The prompt word template can constrain the large language model to predict the elements to be completed, describe the structure of each quadruplet, and omit numeric labels indicating the same entity.
[0102] Furthermore, explicit instructions can be added to the prompt word template, requiring the model to select the most likely value to be the object number label to be completed from the values that have appeared in the above historical quadruples in the form of subject number labels or object number labels, and output only a single value within the specified range without any explanation. Through this structured prompt word design, the large language model can be effectively guided to perform temporal reasoning based on historical facts and output prediction results that meet expectations.
[0103] Specifically, the prompt can be as follows: You must be able to accurately predict the next {object tag} from a given text containing multiple historical quadruples. These historical quadruples are presented in the form "{time}:[{subject number tag}, {subject}, {relation}, {object number tag}, {object}]", while the quadruple to be completed ends in the form "{time}:[{subject}, {relation}]". If the {subject} or {object} in the quadruple is the same as the {subject} in the quadruple to be completed, then the corresponding tag ({subject number tag} or {object number tag}) will be omitted from the quadruple.
[0104] The historical quadruples are as follows: 140: [{0}, {subject a}, {relation a}, {}, {object b}]; 140: [{}, {subject b}, {relation a}, {0}, {object a}]; 314: [{}, {subject b}, {relation b}, {}, {object c}]; 315: [{4}, {subject d}, {relation a}, {}, {object b}]; 335: [{}, {subject b}, {relation c}, {5}, {object e}]; 336: [{}, {subject b}, {relation a}, {6}, {object f}]; The quadruples to be completed are as follows: 337: [{}, {subject b}, {relation a}, {}, {}.
[0105] From the set of number tags that have appeared in the above historical quadruples in the form of {subject number tag} or {object number tag}, select the tag that is most likely to appear as the {object number tag in the quadruple to be completed}. Output only the single value of the {object number tag} in the range [0,6], without any additional explanation. Please strictly follow the above output requirements.
[0106] According to an embodiment of the present invention, the temporal knowledge graph reasoning task is reconstructed into a "numerical label prediction" problem, and lexical-level constraints are imposed during the LLM decoding stage, so that the output is limited to numerical labels within a preset range. This design transforms open-ended text generation into a restricted classification task, which can reduce reasoning complexity and error rate, and make the output format standardized and the results reliable.
[0107] According to an embodiment of the present invention, inputting prompt words into a large language model to infer multiple first candidate elements and the confidence level of each first candidate element may include the following operations.
[0108] The prompt word is input into the large language model, which performs the following decoding process: multiple candidate digit sequences are generated through beam search decoding, and the cumulative probability of generating each candidate digit sequence is obtained. Each candidate digit sequence includes digit characters and a sequence terminator. Each candidate digit sequence is parsed to obtain multiple first candidate elements. The cumulative probability of each candidate digit sequence is determined as the confidence level of the first candidate element corresponding to the candidate digit sequence.
[0109] After the constructed prompts are input into the large language model, the model executes a beam search strategy during the decoding phase. This generates multiple candidate digit sequences step-by-step, each consisting of digit characters and a sequence terminator, representing the predicted object digit label and its ending position. During generation, the model records the cumulative probability of each candidate digit sequence, reflecting the model's confidence level in that sequence. Subsequently, each generated candidate digit sequence is parsed, and the text representation corresponding to the digit characters is extracted as the first candidate element. The cumulative probability of this sequence is then determined as the first confidence level of that first candidate element. In this way, the large language model can output multiple possible prediction results and their confidence levels, providing a basis for subsequent fusion with graph model inference results.
[0110] In the implementation process, during the decoding stage, the output vocabulary can be constrained to numbers and end-of-sequence (EOS) markers, and a beam search (e.g., beam width set to 10) can be used to generate sequences. The probability calculation formula for the generated sequences can be shown in the following formula (6). Finally, the K sequences with the highest probabilities are retained, each sequence corresponding to a first candidate element and its first confidence level. , It is the first candidate element.
[0111] (6)
[0112] in, Represents a sequence of candidate numbers. This represents the cumulative probability, and T represents the total length of the candidate number sequence. This represents the time step index when the candidate number sequence was generated. Indicates the first A tag is generated at each time step; the tag can be a numeric character or a sequence terminator. This represents the conditional probability of generating a specific label in the current step, given that the labels generated in the previous step were known.
[0113] According to an embodiment of the present invention, during the decoding process, the model progressively generates candidate digit sequences composed of numeric characters and sequence terminators based on the context of the prompt words, and records the cumulative probability of each sequence as a basis for confidence. This generation method provides a quantifiable confidence assessment for candidate elements by introducing cumulative probability. Simultaneously, the cluster search strategy reduces the local optima problem caused by greedy decoding by retaining multiple high-probability sequences, thus enhancing the coverage of diverse prediction results.
[0114] According to an embodiment of the present invention, determining the element to be completed based on a plurality of first candidate elements, a first confidence level of each first candidate element, a plurality of second candidate elements obtained by inference of the quadruples to be completed from the graph model, and a second confidence level of each second candidate element may include the following operations.
[0115] From multiple first candidate elements and multiple second candidate elements, identify the same third candidate element; weight and fuse the first confidence and second confidence of the third candidate element to obtain the third confidence of the third candidate element; based on the first confidence of the remaining first candidate elements excluding the third candidate element, the second confidence of the remaining second candidate elements excluding the third candidate element, and the third confidence of the third candidate element, determine the element to be completed from the remaining first candidate elements, the remaining second candidate elements, and the third candidate element.
[0116] To combine the semantic understanding advantages of large language models with the global structure modeling capabilities of graph models, a weighted fusion strategy can be adopted. For example, first, a graph model is used to reason about the same quadruple to be completed, obtaining multiple second candidate elements and their original scores. Then, these scores are normalized to a probability distribution using the Softmax function, thus obtaining the second confidence score for each second candidate element. This represents the second candidate element. The Softmax function is a normalization function used to normalize any set of data to a preset range.
[0117] Elements that are the same in the first and second candidate sets can be considered as third candidate elements. The third confidence level of the third candidate element can be determined by the following formula (7). .
[0118] (7)
[0119] Where γ represents the fusion weight hyperparameter (e.g., it can be set to 0.7).
[0120] All candidate elements can be ranked based on the first confidence level of the remaining first candidate elements (excluding the third candidate element), the second confidence level of the remaining second candidate elements (excluding the third candidate element), and the third confidence level of the third candidate element. The candidate element with the highest confidence level can be selected as the element to be completed. If multiple candidate elements have the same and the highest confidence level, the third candidate element is selected first.
[0121] According to an embodiment of the present invention, the LLM inference results and the graph model prediction results are weighted and fused to form the final answer. This strategy combines the deep semantic understanding of LLM with the global structure awareness of graph models, making up for the shortcomings of pure LLM methods that may miss correct answers due to contextual limitations, thereby making the prediction results more robust and accurate.
[0122] Figure 5 A schematic diagram of a time-series knowledge graph reasoning method based on graph topology enhancement according to an embodiment of the present invention is shown.
[0123] like Figure 5 As shown, the graph topology-enhanced temporal knowledge graph reasoning method of the present invention can be divided into three stages: historical retrieval, prompt word construction, and reasoning. In historical retrieval, a target topology graph is constructed using the quadruple to be completed and multiple historical quadruples. The initial correlation strength is calculated to determine the initial correlation between the quadruple to be completed and multiple historical quadruples, such as historical quadruple 1, ..., historical quadruple n. Subsequently, the initial correlation strength is corrected through time-dependent decay, thereby obtaining the potential correlation strength between the quadruple to be completed and each of the multiple historical quadruples.
[0124] Multiple historical quadruples can be sorted by potential association strength, such as in descending order, and the top N historical quadruples in the sorting results can be selected as target quadruples for subsequent input into the large language model.
[0125] N target quadruples, such as target quadruples 1, ..., target quadruples N, can be arranged by time and adjusted to the format {time}:[{subject}, {relation}, {object}], thus obtaining formatted target quadruples 1, ..., and formatted target quadruples N. By labeling the formatted target quadruples with numerical tags and embedding task indicators, prompt words can be obtained.
[0126] The data is then input into a large language model. During the inference phase, lexical constraints and search bundle constraints can be applied to obtain candidate number sequences, from which the first candidate element 1 and its first confidence level 1, ..., the first candidate element k and its first confidence level k are determined. Furthermore, a graph model can be used for inference to obtain the second candidate element 1 and its second confidence level 1, ..., the second candidate element x and its second confidence level x. By fusing the first candidate element and its first confidence level, and the second candidate element and its second confidence level, the element to be completed can be determined.
[0127] Furthermore, by formalizing the task as numerical label prediction and imposing lexical-level constraints, the output space of LLM is constrained, the risk of irrelevant generation and illusion is reduced, and the controllability of inference results and system reliability are improved.
[0128] To verify the effectiveness of the graph topology-enhanced temporal knowledge graph reasoning method of this invention, the following experiment was conducted. The experimental setup is shown below.
[0129] Datasets: This invention uses widely recognized benchmark datasets in the TKGR field, such as Integrated Crisis Early Warning System (ICEWS) 14, ICEWS 18, and ICEWS 05-15, whose detailed statistical information is shown in Table 1. These datasets differ in time span, number of facts, and data density, allowing for a comprehensive evaluation of model performance.
[0130] Table 1
[0131]
[0132] Evaluation metrics: The evaluation metrics used include Hits@n and Mean Reciprocal Rank (MRR). Hits@n represents the proportion of correct entities ranked in the top n based on similarity. MRR represents the average reciprocity level of correct entities. Higher Hits@n and MRR values indicate stronger method performance. All experiments were conducted under a "time-aware filtering" setting to ensure fairness in the evaluation.
[0133] Table 2 presents the experimental results of the graph topology-enhanced temporal knowledge graph reasoning method of this invention (hereinafter referred to as GT-LLM for convenience) on ICEWS14, ICEWS18, and ICEWS05-15, compared with three representative baseline methods: hierarchical structure matching method (HiSMatch), temporal rule method (TR-Rules), and hybrid expert model collaborative reasoning method (Mixtral-8x7B-CoH). For ease of expression, Hits@n is written as H@n in the table.
[0134] Table 2
[0135]
[0136] As shown in Table 2, GT-LLM achieves state-of-the-art performance on both datasets. On ICEWS14, its MRR reaches 47.8%, an improvement of 1.4 percentage points over the best baseline HiSMatch; on ICEWS18, the MRR is 36.5%, an improvement of 3.5 percentage points over the strongest baseline Mixtral-8x7B-CoH.
[0137] The results show that GT-LLM outperforms rule-based and learning-based methods, and also surpasses the current state-of-the-art Mixtral-8x7B-CoH. The graph topology-enhanced retrieval strategy of this invention significantly improves the answer coverage of historical context, and the score fusion of LLM and graph models achieves complementary advantages in semantic understanding and structural modeling.
[0138] In addition, a systematic ablation study was conducted to verify the contribution of each operation, and the results are shown in Table 3.
[0139] Table 3
[0140]
[0141] Note: * Representations use only LLM for inference and do not incorporate graph models. w / oGT representations do not use graph topology enhancement retrieval; instead, they use a baseline retrieval strategy. w / oTD representations retain the topology graph, but remove the time decay factor during retrieval.
[0142] The ablation experiments showed that removing graph topology retrieval (w / o GT) or the time decay factor (w / o TD) both led to performance degradation, indicating that both are key factors for effective retrieval. When using only LLM inference (GT-LLM*), introducing graph topology retrieval improved the MRR from 35.9% to 40.8%, demonstrating that the retrieval strategy itself has significant gains and does not solely depend on the capabilities of large models.
[0143] According to embodiments of the present invention, by introducing a graph topology-enhanced retrieval strategy, the present invention effectively improves the answer coverage of historical context, providing more accurate reasoning basis for LLM. Combining the semantic understanding capability of LLM with the structural reasoning advantages of graph models, superior performance has been achieved on multiple benchmark datasets (such as ICEWS14, ICEWS18, ICEWS05-15, etc.), and it outperforms traditional learning-based or rule-based models.
[0144] Furthermore, this invention belongs to a non-fine-tuning paradigm, eliminating the need for expensive parameter fine-tuning of LLMs, significantly reducing computational and deployment costs. The unified topology graph representation supports incremental updates to adapt to dynamic time-series graphs, demonstrating efficient adaptability to streaming time-series data. Because it does not rely on training with specific data, the process and core logic of this invention exhibit good consistency and portability across different datasets, demonstrating strong generalization capabilities.
[0145] Based on the above-mentioned graph topology-enhanced temporal knowledge graph reasoning method, this invention also provides a graph topology-enhanced temporal knowledge graph reasoning system. The following will combine... Figure 6 The system is described in detail.
[0146] Figure 6 A block diagram of a temporal knowledge graph reasoning system based on graph topology enhancement according to an embodiment of the present invention is shown.
[0147] like Figure 6 As shown, the graph topology-enhanced temporal knowledge graph reasoning system 600 of this embodiment includes a topology generation module 610, a first determination module 620, a construction module 630, a reasoning module 640, and a second determination module 650.
[0148] The topology generation module 610 is used to add nodes and directed edges to the historical topology graph based on the types of multiple elements in the quadruple to be completed, to obtain the target topology graph. The nodes represent elements of a preset type, and the directed edges represent the associations between elements of different types. The historical topology graph includes historical nodes determined by multiple historical quadruples and the directed edges between historical nodes.
[0149] The first determining module 620 is used to determine the potential association strength between the quadruple to be completed and multiple historical quadruples based on the time decay of each historical quadruple compared to the quadruple to be completed and the connection between each node and each historical node in the target topology graph.
[0150] Module 630 is used to construct a prompt word based on the quadruple to be completed and at least one target quadruple determined from multiple historical quadruples using potential association strength.
[0151] The inference module 640 is used to input prompt words into a large language model to infer multiple first candidate elements and the first confidence level of each first candidate element.
[0152] The second determining module 650 is used to determine the element to be completed based on multiple first candidate elements, the first confidence level of each first candidate element, and multiple second candidate elements obtained by inference of the quadruple to be completed from the graph model and the second confidence level of each second candidate element.
[0153] According to an embodiment of the present invention, the historical quadruple includes a historical time element of type timestamp; the quadruple to be completed includes a time element of type timestamp; the connection status includes a connection path; the first determining module includes: a first determining submodule, used to determine the time decay of each historical quadruple relative to the quadruple to be completed based on the historical time element of each historical quadruple and the time element of the quadruple to be completed; a second determining submodule, used to determine the initial association strength between the quadruple to be completed and the historical quadruple based on the length of the connection path between each node and multiple historical nodes of the historical quadruple for the same historical quadruple; a third determining submodule, used to correct the initial association strength of each historical quadruple based on the time decay of each historical quadruple relative to the quadruple to be completed, to obtain the potential association strength between the quadruple to be completed and multiple historical quadruples.
[0154] According to an embodiment of the present invention, the second determining submodule includes: a first determining unit, configured to determine, for each node, the number of connection paths of different lengths between the node and multiple historical nodes of the historical quadruple; a first calculating unit, configured to, for each length, sum the number of connection paths of the specified length between the node and multiple historical nodes of the historical quadruple to obtain the single-node association strength between the node and the historical quadruple at that length; a second calculation, based on weights determined by each length, weighted summing of the single-node association strengths between the node and the historical quadruple at multiple lengths to obtain the target single-node association strength, wherein the length is inversely proportional to the weights; and a third calculating unit, configured to, based on a preset weighted set, weighted summing of the target single-node association strengths of multiple nodes of the quadruple to be completed to obtain the initial association strength between the quadruple to be completed and the historical quadruple.
[0155] According to an embodiment of the present invention, the topology generation module includes: a node determination submodule, configured to treat all of the elements as nodes when the preset type is all types; an edge determination submodule, configured to determine directed edges between the multiple nodes based on preset pointing logic between the types; and an adding submodule, configured to add the multiple nodes and the directed edges to the historical topology graph.
[0156] According to an embodiment of the present invention, the construction module includes: a sorting submodule, configured to sort at least one of the target quadruples according to the historical time elements in the multiple target quadruples, when there are multiple target quadruples, to obtain a sorting result; an allocation submodule, configured to allocate numeric labels to the historical elements included in each of the multiple target quadruples and the multiple elements included in the quadruples to be completed, wherein, for repeated historical elements, the numeric label of the first occurrence of the repeated historical element is retained, and for elements identical to the historical elements, the numeric label of the same historical element is retained; and an embedding submodule, configured to embed the quadruples to be completed, the multiple target quadruples, and the numeric labels into a prompt word template according to the sorting result, to obtain the prompt word, wherein the prompt word is used to constrain the large language model to select or infer multiple first candidate elements from a numeric label vocabulary determined by historical elements of the same type as the elements to be completed, and output the first confidence of each first candidate element.
[0157] According to an embodiment of the present invention, the inference module includes: a generation submodule, configured to generate multiple candidate number sequences through beam search decoding and obtain the cumulative probability of generating each candidate number sequence, wherein each candidate number sequence includes a numeric character and a sequence terminator; a parsing submodule, configured to parse each candidate number sequence to obtain multiple first candidate elements; and a confidence determination submodule, configured to determine the cumulative probability of each candidate number sequence as the confidence level of the first candidate element corresponding to the candidate number sequence.
[0158] According to an embodiment of the present invention, the second determining module includes: a fourth determining submodule, configured to determine the same third candidate element from a plurality of first candidate elements and a plurality of second candidate elements; a fifth determining submodule, configured to perform weighted fusion of the first confidence level and the second confidence level of the third candidate element to obtain a third confidence level of the third candidate element; and a sixth determining submodule, configured to determine the element to be completed from the remaining first candidate elements, the remaining second candidate elements, and the third candidate element based on the first confidence level of the remaining first candidate elements other than the third candidate element in the plurality of first candidate elements, the second confidence level of the remaining second candidate elements other than the third candidate element in the plurality of second candidate elements, and the third confidence level of the third candidate element.
[0159] According to embodiments of the present invention, any plurality of modules among the topology generation module 610, the first determination module 620, the construction module 630, the inference module 640, and the second determination module 650 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of the present invention, at least one of the topology generation module 610, the first determination module 620, the construction module 630, the inference module 640, and the second determination module 650 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging circuitry, or implemented in hardware or firmware, or in any one of software, hardware, and firmware implementations, or in a suitable combination of any of these. Alternatively, at least one of the topology generation module 610, the first determination module 620, the construction module 630, the reasoning module 640, and the second determination module 650 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.
[0160] Figure 7 An architecture diagram of a time-series knowledge graph reasoning system based on graph topology enhancement according to an embodiment of the present invention is shown.
[0161] like Figure 7 As shown, a time-series knowledge graph reasoning system based on graph topology enhancement can include a data preprocessing device, a reasoning device, a model management device, and a result output device.
[0162] The preprocessing unit is responsible for accessing, cleaning, and transforming the raw temporal knowledge graph data, and constructing a unified temporal topology graph. Internally, it may include: a data parsing module: parsing the input quadruple data and extracting entity, relation, and timestamp information; a topology generation module: integrating the discrete temporal quadruples into a globally unified target topology graph according to the aforementioned construction rules, generating nodes and edges and recording time attributes; and a graph storage module: persistently storing the constructed target topology graph in a graph database, supporting efficient graph query operations.
[0163] The inference mechanism can receive user queries and complete the entire process from historical quadruple retrieval to inference execution. It mainly includes: a query parsing module, which parses the query (i.e., the quadruple to be completed) and extracts the subject element, relation element, and time element. It also includes: a first determination module, an inference module, and a second determination module. The functions of these modules are already described in [the original text]. Figure 6 The explanation is already provided and will not be repeated here.
[0164] Furthermore, the second determination module can also be used to post-process and interpret the inference results, and it may also include: a result formatting submodule: mapping the numerical labels output by the model back to entity names to generate the final prediction results.
[0165] The model management unit is responsible for the loading, running, and configuration management of large language models and graph models. Specifically, it includes: an LLM service module: deploying and invoking large language models, supporting controlled decoding and beam search; a graph model service module: deploying and invoking graph models, performing global graph structure inference; and a parameter configuration module: managing hyperparameters (such as fusion weight γ, beam width, etc.), supporting dynamic adjustment.
[0166] The results output device can present the inference results. Specifically, it includes: a visualization module: providing a visual display of the inference process, including historical events retrieved, LLM inference paths, and graph model inference paths.
[0167] In practical use, the system workflow can be as follows: After a user submits a query, the inference device first parses the query and retrieves relevant historical events in the unified topology graph. The construction module then builds prompts with numerical tags. The inference module synchronously calls the LLM and graph model for inference and performs a weighted fusion of their outputs to obtain the final prediction result. The result output module formats the result and returns it to the user. This system can support high-concurrency temporal knowledge graph inference tasks.
[0168] Figure 8 A block diagram of an electronic device suitable for implementing a graph topology-enhanced temporal knowledge graph reasoning method according to an embodiment of the present invention is shown.
[0169] like Figure 8 As shown, an electronic device 800 according to an embodiment of the present invention includes a processor 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage portion 808 into a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0170] RAM 803 stores various programs and data required for the operation of electronic device 800. Processor 801, ROM 802, and RAM 803 are interconnected via bus 804. Processor 801 executes various operations of the method flow according to embodiments of the present invention by executing programs in ROM 802 and / or RAM 803. It should be noted that the programs may also be stored in one or more memories other than ROM 802 and RAM 803. Processor 801 may also execute various operations of the method flow according to embodiments of the present invention by executing programs stored in said one or more memories.
[0171] According to an embodiment of the present invention, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to a bus 804. The electronic device 800 may also include one or more of the following components connected to the input / output (I / O) interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output (I / O) interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 810 as needed so that computer programs read from it can be installed into the storage section 808 as needed.
[0172] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of the present invention.
[0173] According to embodiments of the present invention, a computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of the present invention, a computer-readable storage medium may include ROM 802 and / or RAM 803 and / or one or more memories other than ROM 802 and RAM 803 described above.
[0174] Embodiments of the present invention also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code enables the computer system to implement the graph topology-enhanced temporal knowledge graph reasoning method provided in the embodiments of the present invention.
[0175] When the computer program is executed by the processor 801, it performs the functions defined in the system / apparatus of this invention. According to embodiments of the invention, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0176] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via the communication section 809, and / or installed from a removable medium 811. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0177] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by processor 801, it performs the functions defined in the system of this embodiment of the invention. According to embodiments of the invention, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0178] According to embodiments of the present invention, program code for executing the computer programs provided in the embodiments of the present invention can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0179] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0180] Those skilled in the art will understand that the features described in the various embodiments of the present invention can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, the features described in the various embodiments of the present invention can be combined and / or combined in various ways without departing from the spirit and teachings of the present invention. All such combinations and / or combinations fall within the scope of the present invention.
[0181] The embodiments of the present invention have been described above. However, these embodiments are merely illustrative and not intended to limit the scope of the invention. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of the invention, and all such substitutions and modifications should fall within the scope of the invention.
Claims
1. A temporal knowledge graph reasoning method based on graph topology enhancement, characterized in that, The method includes: Based on the types of multiple elements in the quadruple to be completed, nodes and directed edges are added to the historical topology graph to obtain the target topology graph. The nodes represent elements of a preset type, and the directed edges represent the associations between elements of different types. The historical topology graph includes historical nodes determined by multiple historical quadruples and directed edges between the historical nodes. Based on the time decay of each historical quadruple relative to the quadruple to be completed and the connection between each node and each historical node in the target topology graph, the potential association strength between the quadruple to be completed and multiple historical quadruples is determined. Based on the quadruple to be completed and at least one target quadruple determined from multiple historical quadruples using the potential association strength, a prompt word is constructed; The prompt words are input into a large language model to infer multiple first candidate elements and the first confidence level of each first candidate element; The element to be completed is determined based on multiple first candidate elements, the first confidence level of each first candidate element, multiple second candidate elements obtained by inference from the graph model on the quadruple to be completed, and the second confidence level of each second candidate element.
2. The temporal knowledge graph reasoning method according to claim 1, characterized in that, The historical quadruple includes a historical time element of type timestamp; the quadruple to be completed includes a time element of type timestamp; the connection status includes the connection path; The step of determining the potential association strength between the quadruple to be completed and multiple historical quadruples based on the time decay of each historical quadruple compared to the quadruple to be completed and the connection between each node and each historical node in the target topology graph includes: Based on the historical time elements of each historical quadruple and the time elements of the quadruple to be completed, the time decay of each historical quadruple relative to the quadruple to be completed is determined. For the same historical quad, the initial association strength between the quad to be completed and the historical quad is determined based on the length of the connection path between each node and multiple historical nodes of the historical quad; Based on the time decay of each historical quadruple relative to the quadruple to be completed, the initial association strength of each historical quadruple is corrected to obtain the potential association strength between the quadruple to be completed and multiple historical quadruples.
3. The temporal knowledge graph reasoning method according to claim 2, characterized in that, The determination of the initial association strength between the quadruple to be completed and the historical quadruple based on the length of the connection path between each node and multiple historical nodes of the historical quadruple includes: For each of the nodes, Determine the number of connection paths of different lengths between the node and multiple historical nodes of the historical quadruple; For each length, the number of connection paths between the node and multiple historical nodes of the historical quadruple is summed to obtain the single-node association strength between the node and the historical quadruple at that length. Based on the weights determined by each of the lengths, the single-node association strengths of the node and the historical quadruple at multiple lengths are weighted and summed to obtain the target single-node association strength, wherein the lengths are inversely proportional to the weights. Based on a preset weighted reorganization, the target single-node association strengths of multiple nodes in the quadruple to be completed are weighted and summed to obtain the initial association strength between the quadruple to be completed and the historical quadruple.
4. The temporal knowledge graph reasoning method according to any one of claims 1 to 3, characterized in that, The step of adding nodes and directed edges to the historical topology graph based on the types of the multiple elements included in the quadruple to be completed, to obtain the target topology graph, includes: when the preset type is all types, Each of the aforementioned elements is treated as a node; Based on the preset pointing logic between each of the aforementioned types, directed edges between multiple nodes are determined; Add the nodes and the directed edges to the historical topology graph.
5. The temporal knowledge graph reasoning method according to claim 1, characterized in that, The step of constructing a prompt word based on the quadruple to be completed and at least one target quadruple determined from multiple historical quadruples using the potential association strength includes: when there are multiple target quadruples, Based on the historical time elements in the multiple target quadruples, sort at least one of the target quadruples to obtain a sorting result; Assign numerical labels to the historical elements included in each of the target quadruples and the multiple elements included in the quadruples to be completed, wherein, for repeated historical elements, retain the numerical label of the repeated historical element when it first appears, and for elements that are the same as the historical elements, retain the numerical label of the same historical element. According to the sorting result, the quadruple to be completed, multiple target quadruples, and the number tags are embedded into the prompt word template to obtain the prompt word. The prompt word is used to constrain the large language model to select or infer multiple first candidate elements from the vocabulary of number tags determined by historical elements of the same type as the element to be completed, and output the first confidence of each first candidate element.
6. The temporal knowledge graph reasoning method according to claim 1 or 5, characterized in that, The step of inputting the prompt words into a large language model to infer multiple first candidate elements and the confidence level of each first candidate element includes: The prompt word is input into the large language model, and the large language model performs the following decoding process: Multiple candidate number sequences are generated through bundle search decoding, and the cumulative probability of generating each candidate number sequence is obtained, wherein each candidate number sequence includes a number character and a sequence terminator; Each candidate number sequence is parsed to obtain multiple first candidate elements; The cumulative probability of each candidate number sequence is determined as the confidence level of the first candidate element corresponding to the candidate number sequence.
7. The temporal knowledge graph reasoning method according to claim 1, characterized in that, The step of determining the element to be completed based on multiple first candidate elements, a first confidence level of each first candidate element, and multiple second candidate elements obtained by inference from the graph model on the quadruple to be completed, and a second confidence level of each second candidate element, includes: From a plurality of first candidate elements and a plurality of second candidate elements, determine the same third candidate element; The first confidence score and the second confidence score of the third candidate element are weighted and fused to obtain the third confidence score of the third candidate element; Based on the first confidence level of the remaining first candidate elements (excluding the third candidate element) among the plurality of first candidate elements, the second confidence level of the remaining second candidate elements (excluding the third candidate element) among the plurality of second candidate elements, and the third confidence level of the third candidate element, the element to be completed is determined from the remaining first candidate elements, the remaining second candidate elements, and the third candidate element.
8. The temporal knowledge graph reasoning method according to claim 1, characterized in that, The historical quadruple includes the following types of historical elements: historical entity elements of type entity, historical time elements of type timestamp, and historical relation elements of type relation; wherein, the historical entity elements include historical subject elements of type subject and historical object elements of type object.
9. A temporal knowledge graph reasoning system based on graph topology enhancement, characterized in that, The system includes: The topology generation module is used to add nodes and directed edges to the historical topology graph based on the types of multiple elements in the quadruple to be completed, to obtain the target topology graph. The nodes represent elements of a preset type, and the directed edges represent the associations between elements of different types. The historical topology graph includes historical nodes determined by multiple historical quadruples and directed edges between the historical nodes. The first determining module is used to determine the potential association strength between the quadruple to be completed and multiple historical quadruples based on the time decay of each historical quadruple compared to the quadruple to be completed and the connection between each node and each historical node in the target topology graph. The construction module is used to construct a prompt word based on the quadruple to be completed and at least one target quadruple determined from a plurality of historical quadruples using the potential association strength; The reasoning module is used to input the prompt words into the large language model to reason and obtain multiple first candidate elements and the first confidence level of each first candidate element; The second determining module is used to determine the element to be completed based on multiple first candidate elements, the first confidence level of each first candidate element, and multiple second candidate elements and the second confidence level of each second candidate element obtained by inference from the graph model on the quadruple to be completed.
10. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 8.