Time sequence knowledge graph reasoning method based on large language model

Through the temporal knowledge graph reasoning method based on a large language model, combined with the embedding model and multimodal information, an event evolution tree is constructed and instructions are fine-tuned, which solves the difficult problems of complex semantic constraints and temporal evolution path modeling in temporal knowledge graph reasoning, and achieves efficient and accurate entity type alignment and temporal dependency capture.

CN120671804APending Publication Date: 2025-09-19TIANJIN UNIV
View PDF 0 Cites 8 Cited by

Patent Information

Application Number
CN202510581548.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-07
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Existing technologies find it difficult to simultaneously meet the needs of complex semantic constraint modeling and temporal evolution path modeling in temporal knowledge graph reasoning, leading to problems such as entity type alignment errors, information loss, and semantic drift.

Method used

A temporal knowledge graph reasoning method based on a large language model is adopted, combined with an embedding model for vectorized representation, an event evolution tree is constructed, a structured prompt template is designed, and the pre-trained model is fine-tuned through LoRA technology. Multimodal information fusion and dynamic interactive reasoning mechanisms are introduced to achieve efficient screening of candidate entities and reasoning results.

Benefits of technology

It significantly improves the accuracy and efficiency of temporal knowledge graph reasoning, can more accurately capture entity type alignment and temporal evolution paths, reduce reasoning bias, enhance semantic understanding capabilities, and improve the adaptability and transparency of the model in complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120671804A_ABST
    Figure CN120671804A_ABST
Patent Text Reader

Abstract

The invention discloses a time sequence knowledge graph reasoning method based on a large language model, which comprises the following steps of: performing vectorization expression on query entities and relationships by utilizing an embedded model, and generating vectors containing structural features and semantic information in combination with adjacent entities, relationships and time information; a candidate entity set most relevant to query is screened out from the large-scale entity set by calculating the conditional probability; constructing an event evolution tree, and performing multi-hop sampling on adjacent nodes of a query entity and a candidate entity in a time window to generate a tree structure capable of completely reflecting a historical event evolution path; the method comprises the following steps: designing a structured prompt template, and performing instruction fine tuning on a pre-trained large language model by adopting an LoRA (Low Rank fine tuning technology), so that the model better follows a task instruction to generate a reasoning result. And efficient and accurate time sequence knowledge graph reasoning is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a temporal knowledge graph reasoning method based on a large language model. Background Art

[0002] Temporal Knowledge Graphs (TKGs) extend traditional knowledge graphs by introducing a time dimension, dynamically representing the evolution of relationships between entities. They possess significant application value in fields such as event prediction, causal reasoning, and intelligent decision-making. However, reasoning in temporal knowledge graphs faces two core challenges: first, modeling complex semantic constraints—the semantic constraints implicit in queries, such as entity types and relationship logic, need to be accurately captured; and second, modeling temporal evolution paths—the dynamic changes in entity states and relationships over time require effective modeling of their historical evolutionary trajectories and causal dependencies.

[0003] Traditional methods are mainly divided into two categories: methods based on embedding models and methods based on large language models, but both have significant limitations. Methods based on embedding models, such as TransE and its variants (such as TransH, TransR) and ConvsTransE, have alleviated the data sparsity and dynamic problems in knowledge graph completion to a certain extent. However, because they mainly focus on local structural features, they have difficulty capturing deep semantic constraints and complex causal relationships, and are prone to problems such as entity type alignment errors, information loss, or semantic drift. Although methods based on large language models have powerful semantic understanding and generation capabilities, in the task of temporal knowledge graph reasoning, the prompt template design often has information redundancy or lack of precision, and the candidate information screening process is prone to contain noise or redundant data, affecting the accuracy of the reasoning results.

[0004] In addition, the existing technology has technical barriers in processing temporal logic constraint modeling and complex semantic understanding, and it is difficult to simultaneously meet the needs of fine-grained characterization of entity evolution paths and precise reasoning type constraints. Therefore, the present invention proposes a temporal knowledge graph reasoning method based on a large language model to solve the above problems. Summary of the Invention

[0005] In view of the defects of the above-mentioned prior art, the purpose of the present invention is to provide a temporal knowledge graph reasoning method based on a large language model.

[0006] To achieve the above objectives, the present invention provides a temporal knowledge graph reasoning method based on a large language model, comprising the following steps:

[0007] Step 1: Use the embedding model to vectorize the query entities and relationships, combining adjacent entities, relationships, and time information to generate a vector containing structural features and semantic information;

[0008] Step 2: Filter out the candidate entity set most relevant to the query from the large-scale entity set by calculating the conditional probability;

[0009] Step 4: Construct an event evolution tree by performing multi-hop sampling on the adjacent nodes of the query entity and the candidate entity within the time window to generate a tree structure that can fully reflect the evolution path of historical events;

[0010] Step 5: Design a structured prompt template, including task description, query information, event evolution tree, candidate entities, and step-by-step reasoning steps, as input to the large language model;

[0011] Step 6: Use LoRA to fine-tune the pre-trained large language model so that the model can better follow the task instructions to generate inference results.

[0012] Furthermore, the embedding model uses the ConvTransE model to calculate the score of the query triples and calculate the conditional probability according to the formula:

[0013]

[0014] Among them, e s ,e r ,e o are the embedding vectors of query entity s, relation r, and candidate entity o respectively, and t is the timestamp. All candidate entities are sorted by the above formula, and the top k entities with the highest scores are selected to form the initial candidate entity set.

[0015] Furthermore, the construction of the event evolution tree satisfies the following conditions: the tree structure is defined as a directed tree, the root node is the query entity s or the key candidate node, and the edge represents the entity affecting the entity o through the relationship r at the timestamp t, which is recorded as (s q ,r q ,? ,t q ); If there is a path (s1, r1, o1, t1) → (o2, r2, o2, t2), then t1 must be satisfied. <t2。

[0016] Furthermore, the event evolution tree construction algorithm includes the following steps:

[0017] Input: query quad (s q ,r q ,? ,t q ), initial candidate entity set C, temporal knowledge graph TKG and time window [t start ,t end ];

[0018] Process: For the query entity s, in the time range [t start ,tend ], sample its adjacent nodes and record them in the set N s , to build the event evolution tree EETree s And add it to the overall tree set T; for the entity o that has not been sampled in the candidate entity set C, also perform adjacent sampling along the time dimension to construct the event tree EETree o , added to T;

[0019] Output: The final event evolution tree set T contains the dynamic evolution information of different candidate entities in historical time.

[0020] Furthermore, the method further includes a multimodal information fusion mechanism. In the embedding model, in addition to traditional text information, multimodal data such as images and audio related to entities and relationships are also integrated. Through the joint representation of multimodal embedding vectors, the model's semantic understanding ability of entities and relationships is enhanced; in the process of constructing the event evolution tree, the timestamps of multimodal information are aligned to generate an event evolution path containing multimodal features, providing richer contextual information for the large language model; in the instruction fine-tuning stage, a multimodal prompt template is designed to combine text prompts with multimodal information such as images and audio, guiding the large language model to make full use of multimodal information in the reasoning process, thereby improving the accuracy and reliability of the reasoning results, and solving the problem of insufficient semantic understanding caused by relying solely on text information in the existing technology.

[0021] Furthermore, the instruction fine-tuning technology includes the following steps:

[0022] For each instruction fine-tuning sample, consisting of an instruction hint P and an input I, the model parameters θ are optimized by minimizing the log-likelihood loss function:

[0023]

[0024] Where P(I|P,θ) represents the probability of generating sequence I. LoRA technology is used, that is, the pre-training parameters are frozen and only the newly added low-rank matrices A and B are trained. The parameter transformation form is:

[0025] θ′=θ+A·B;

[0026] The calculation formula for forward propagation is:

[0027] h′=h+A·B·h

[0028] Where h is the input hidden state and h′ is the hidden state adjusted by LoRA. The above method can not only maintain pre-training knowledge but also inject new reasoning capabilities in task-specific scenarios.

[0029] Furthermore, the construction of the structured prompt template includes: clearly stating the model task, that is, in the query of missing tail entities, using historical event chains and candidate entities to predict answers; displaying the query content (s, r,?, t) in text form; displaying the constructed event evolution tree in structured text, including historical events and timestamp information; listing the candidate entity set C obtained based on the embedding model and the event evolution tree; describing the reasoning process in detail step by step, including historical event identification and sorting, entity evolution path tracing, causal relationship analysis, candidate entity prediction and context consistency sorting. The method further optimizes the temporal knowledge graph reasoning task through the following steps: using the embedding model to obtain multi-dimensional semantic and structural information, and screening out highly relevant candidate entities from a large-scale entity set; constructing an event tree reflecting historical evolution through multi-hop adjacency sampling within the time window, providing structured context information for reasoning; designing a structured prompt template and using LoRA technology to efficiently fine-tune the large language model to generate reasoning results that conform to temporal logic and causal relationships.

[0030] Furthermore, a dynamic time window adjustment mechanism is introduced in the construction process of the event evolution tree, which dynamically adjusts the size of the time window according to the historical event density of the query entity. For entities with dense historical events, the time window is narrowed to focus on recent key events; for entities with sparse historical events, the time window is expanded to obtain more contextual information; within the time window, an adaptive multi-hop sampling strategy is adopted to dynamically adjust the sampling depth and frequency according to the importance and time interval of the relationship between entities to ensure that the key temporal evolution path can be captured; by introducing a time decay factor to weight events with different timestamps, the influence of recent events on the reasoning results is greater, thereby improving the timeliness and accuracy of the reasoning results.

[0031] Furthermore, a dynamic interactive reasoning mechanism is introduced into the structured prompt template. During the reasoning process, the large language model is allowed to conduct real-time interactive queries with the external knowledge base, dynamically obtaining additional knowledge related to the current reasoning task to supplement the insufficient information in the prompt template. A multi-round interactive reasoning process is designed. In each round of reasoning, the large language model dynamically adjusts the prompt template content for subsequent reasoning based on the current reasoning result, gradually refining the reasoning logic until the final reasoning result is generated. A feedback mechanism is introduced to compare the reasoning result with the real data, and dynamically adjust the structure and content of the prompt template based on the comparison results to optimize the performance of subsequent reasoning tasks, thereby improving the adaptability and accuracy of the model in complex temporal knowledge graph reasoning tasks.

[0032] Furthermore, a two-way feedback optimization mechanism is introduced between the embedding model and the large language model. During the candidate entity screening stage, the embedding model dynamically adjusts the weight of the entity embedding vector based on the preliminary reasoning results of the large language model, thereby enhancing the entity features that are highly relevant to the reasoning task. During the instruction fine-tuning stage, the large language model dynamically adjusts the structure and content of the prompt template based on the semantic consistency feedback of the candidate entity set provided by the embedding model to better guide the reasoning process. Through the two-way feedback mechanism, the embedding model and the large language model collaborate and dynamically optimize with each other during the reasoning process, significantly improving the accuracy of the reasoning results and the efficiency of the reasoning process, and solving the problem of limited reasoning capability of a single model in the existing technology.

[0033] Compared with the prior art, the present invention has the following beneficial effects:

[0034] 1. By combining the structured representation of an embedding model with the semantic reasoning capabilities of a large language model, this method overcomes the technical barriers between modeling temporal logic constraints and understanding complex semantics using a single model. Compared to traditional embedding-based methods, this method more accurately captures entity type alignment and temporal evolution paths, significantly reducing type alignment errors and reasoning biases caused by local information limitations.

[0035] 2. The event evolution tree construction method introduced in this paper effectively captures the dynamic evolution of entities over time, providing rich temporal context for reasoning and further improving reasoning accuracy. Compared with methods that rely solely on static information, this method can better handle temporal dependencies, thereby achieving higher reasoning efficiency in complex scenarios.

[0036] 3. During the candidate entity screening phase, this invention utilizes an embedding model combined with conditional probability calculations to efficiently select the most relevant candidate entities from a large entity set, reducing the interference of irrelevant information. Compared to traditional methods using static vocabularies or random sampling, this approach more accurately locates entities relevant to the query, improving the efficiency and accuracy of subsequent reasoning.

[0037] 4. This invention introduces a dynamic time window adjustment mechanism and an adaptive multi-hop sampling strategy during the event evolution tree construction process. The time window size is dynamically adjusted according to the historical event density of the query entity. For entities with dense historical events, the time window is narrowed to focus on recent key events; for entities with sparse historical events, the time window is expanded to obtain more contextual information. This dynamic adjustment mechanism can more flexibly capture key temporal evolution paths, avoiding the problem of traditional fixed time window methods that may miss important information, thereby optimizing the modeling process of candidate information.

[0038] 5. By providing a structured prompt template that includes a task description, query information, an event evolution tree, candidate entities, and a step-by-step chain of reasoning steps, the present invention not only provides clear reasoning clues for the large language model but also makes the entire reasoning process more transparent and explainable. Compared with traditional methods that rely on simple natural language prompts, the prompt template of the present invention can more clearly guide the model's step-by-step reasoning, resulting in accurate, logical, and consistent reasoning results, making them easier for users to understand and verify.

[0039] 6. The dynamic interactive reasoning mechanism introduced in this invention allows large language models to conduct real-time interactive queries with external knowledge bases during the reasoning process, dynamically acquiring additional knowledge relevant to the current reasoning task. This mechanism not only supplements the information deficiencies in the prompt template but also dynamically adjusts the prompt template content for subsequent reasoning based on the reasoning results, gradually refining the reasoning logic until the final reasoning result is generated. This dynamic interaction and feedback mechanism further enhances the transparency and interpretability of the reasoning process, making the model more adaptable to complex temporal knowledge graph reasoning tasks.

[0040] 7. The present invention uses LoRA (low-rank adaptation technology) to fine-tune the instructions of the pre-trained large language model, which not only maintains the knowledge of the pre-trained model, but also can inject new reasoning capabilities in task-specific scenarios. Compared with full parameter fine-tuning, LoRA technology reduces training costs and improves the adaptability of the model to different tasks. This efficient parameter fine-tuning method enables the present invention to demonstrate good generalization capabilities in different temporal knowledge graph reasoning tasks without the need to retrain the entire model for each task.

[0041] 8. The present invention further improves the adaptability of the model by setting up a two-way feedback optimization mechanism between the embedding model and the large language model. In the candidate entity screening stage, the embedding model dynamically adjusts the weight of the entity embedding vector based on the preliminary reasoning results of the large language model, enhancing the entity features that are highly relevant to the reasoning task; in the instruction fine-tuning stage, the large language model dynamically adjusts the structure and content of the prompt template based on the semantic consistency feedback of the candidate entity set provided by the embedding model. The two-way feedback mechanism enables the two models to cooperate and dynamically optimize with each other during the reasoning process, significantly improving the adaptability and accuracy of the model in complex temporal knowledge graph reasoning tasks, and solving the problem of limited reasoning capability of a single model in the existing technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the solutions in the present invention, a brief introduction is given below to the drawings required for use in describing the embodiments of the present invention. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0043] Figure 1 It is a schematic diagram of the process provided by the present invention. DETAILED DESCRIPTION

[0044] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more precise definition of the scope of protection of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making any creative work are within the scope of protection of the present invention.

[0045] The terms "including," "having," and any variations thereof in the present specification, claims, and accompanying drawings are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the present specification, claims, and accompanying drawings are used to distinguish between different items, not to describe a specific order.

[0046] See also Figure 1 , a temporal knowledge graph reasoning method based on a large language model, comprising the following steps:

[0047] Step 1: Use the embedding model to vectorize the query entities and relationships, combining adjacent entities, relationships, and time information to generate a vector containing structural features and semantic information;

[0048] Step 2: Filter out the candidate entity set most relevant to the query from the large-scale entity set by calculating the conditional probability;

[0049] Step 4: Construct an event evolution tree by performing multi-hop sampling on the adjacent nodes of the query entity and the candidate entity within the time window to generate a tree structure that can fully reflect the evolution path of historical events;

[0050] Step 5: Design a structured prompt template, including task description, query information, event evolution tree, candidate entities, and step-by-step reasoning steps, as input to the large language model;

[0051] Step 6: Use LoRA to fine-tune the pre-trained large language model so that the model can better follow the task instructions to generate inference results.

[0052] As an improvement to the above technical solution, the embedding model uses the ConvTransE model to calculate the score of the query triples and calculate the conditional probability according to the formula:

[0053]

[0054] Among them, e s ,e r ,e o are the embedding vectors of query entity s, relation r, and candidate entity o respectively, and t is the timestamp. All candidate entities are sorted by the above formula, and the top k entities with the highest scores are selected to form the initial candidate entity set.

[0055] As an improvement of the above technical solution, the construction of the event evolution tree satisfies the following conditions: the tree structure is defined as a directed tree, the root node is the query entity s or the key candidate node, and the edge represents the entity affecting the entity o through the relationship r at the timestamp t, which is recorded as (s q ,r q ,? ,t q ); If there is a path (s1, r1, o1, t1) → (o2, r2, o2, t2), then t1 must be satisfied. <t2。

[0056] As an improvement to the above technical solution, the event evolution tree construction algorithm includes the following steps:

[0057] Input: query quad (s q ,r q ,? ,t q ), initial candidate entity set C, temporal knowledge graph TKG and time window [t start ,t end ];

[0058] Process: For the query entity s, in the time range [t start ,t end ], sample its adjacent nodes and record them in the set N s , to build the event evolution tree EETree s And add it to the overall tree set T; for the entity o that has not been sampled in the candidate entity set C, also perform adjacent sampling along the time dimension to construct the event tree EETree o , added to T;

[0059] Output: The final event evolution tree set T contains the dynamic evolution information of different candidate entities in historical time.

[0060] As an improvement to the above technical solution, this method further includes a multimodal information fusion mechanism. In the embedding model, in addition to traditional text information, multimodal data such as images and audio related to entities and relationships are also integrated. Through the joint representation of multimodal embedding vectors, the model's semantic understanding ability of entities and relationships is enhanced; in the process of constructing the event evolution tree, the timestamps of multimodal information are aligned to generate an event evolution path containing multimodal features, providing richer contextual information for the large language model; in the instruction fine-tuning stage, a multimodal prompt template is designed to combine text prompts with multimodal information such as images and audio, guiding the large language model to make full use of multimodal information during the reasoning process, thereby improving the accuracy and reliability of the reasoning results, and solving the problem of insufficient semantic understanding caused by relying solely on text information in the existing technology.

[0061] As an improvement to the above technical solution, the instruction fine-tuning technology includes the following steps:

[0062] For each instruction fine-tuning sample, consisting of an instruction hint P and an input I, the model parameters θ are optimized by minimizing the log-likelihood loss function:

[0063]

[0064] Where P(I|P,θ) represents the probability of generating sequence I. LoRA technology is used, that is, the pre-training parameters are frozen and only the newly added low-rank matrices A and B are trained. The parameter transformation form is:

[0065] θ′=θ+A·B;

[0066] The calculation formula for forward propagation is:

[0067] h′=h+A·B·h

[0068] Where h is the input hidden state and h′ is the hidden state adjusted by LoRA. The above method can not only maintain pre-training knowledge but also inject new reasoning capabilities in task-specific scenarios.

[0069] As an improvement of the above technical solution, the construction of a structured prompt template includes: clearly stating the model task, that is, in queries with missing tail entities, using historical event chains and candidate entities to predict answers; displaying the query content (s, r, ?, t) in text form; displaying the constructed event evolution tree in structured text, including historical events and timestamp information; listing the candidate entity set C obtained based on the embedding model and the event evolution tree; describing the reasoning process in detail step by step, including historical event identification and sorting, entity evolution path tracing, causal relationship analysis, candidate entity prediction and context consistency sorting. This method further optimizes the temporal knowledge graph reasoning task through the following steps: using the embedding model to obtain multi-dimensional semantic and structural information, and screening out highly relevant candidate entities from a large-scale entity set; constructing an event tree reflecting historical evolution through multi-hop adjacency sampling within the time window, providing structured context information for reasoning; designing a structured prompt template and using LoRA technology to efficiently fine-tune the large language model to generate reasoning results that conform to temporal logic and causal relationships.

[0070] As an improvement to the above technical solution, a dynamic time window adjustment mechanism is introduced in the construction process of the event evolution tree. The size of the time window is dynamically adjusted according to the historical event density of the query entity. For entities with dense historical events, the time window is narrowed to focus on recent key events; for entities with sparse historical events, the time window is expanded to obtain more contextual information; within the time window, an adaptive multi-hop sampling strategy is adopted to dynamically adjust the sampling depth and frequency according to the importance and time interval of the relationship between entities to ensure that the key temporal evolution path can be captured; by introducing a time decay factor to weight events with different timestamps, the influence of recent events on the reasoning results is greater, thereby improving the timeliness and accuracy of the reasoning results.

[0071] As an improvement to the above technical solution, a dynamic interactive reasoning mechanism is introduced into the structured prompt template. During the reasoning process, the large language model is allowed to conduct real-time interactive queries with the external knowledge base, dynamically obtaining additional knowledge related to the current reasoning task to supplement the insufficient information in the prompt template. A multi-round interactive reasoning process is designed. In each round of reasoning, the large language model dynamically adjusts the prompt template content for subsequent reasoning based on the current reasoning results, gradually refining the reasoning logic until the final reasoning result is generated. A feedback mechanism is introduced to compare the reasoning results with the real data, and dynamically adjust the structure and content of the prompt template based on the comparison results to optimize the performance of subsequent reasoning tasks, thereby improving the adaptability and accuracy of the model in complex temporal knowledge graph reasoning tasks.

[0072] As an improvement to the above technical solution, a two-way feedback optimization mechanism is introduced between the embedding model and the large language model. During the candidate entity screening stage, the embedding model dynamically adjusts the weight of the entity embedding vector based on the preliminary reasoning results of the large language model, enhancing the entity features that are highly relevant to the reasoning task; during the instruction fine-tuning stage, the large language model dynamically adjusts the structure and content of the prompt template based on the semantic consistency feedback of the candidate entity set provided by the embedding model to better guide the reasoning process; through the two-way feedback mechanism, the embedding model and the large language model collaborate and dynamically optimize with each other during the reasoning process, significantly improving the accuracy of the reasoning results and the efficiency of the reasoning process, and solving the problem of limited reasoning capabilities of a single model in the existing technology.

[0073] Working principle and usage of the present invention:

[0074] The present invention achieves efficient and accurate temporal knowledge graph reasoning by integrating the advantages of embedding models and large language models, combining event evolution trees and instruction fine-tuning technology, and using embedding models (such as ConvTransE) to vectorize query entities and relationships. Combining adjacent entities, relationships and time information, it generates vectors containing structural features and semantic information, converts complex graph structure data into a vector form that can be processed by the model, while retaining the semantic information of entities and relationships, providing a basis for subsequent candidate entity screening. By calculating conditional probabilities, the candidate entity set most relevant to the query is screened from a large-scale entity set, and the query is processed by the entity set. Using the vectorized representation of the embedded model and conditional probability calculation, we can efficiently filter out entities that are highly relevant to the query event, reduce irrelevant interference, improve the accuracy and efficiency of reasoning, build an event evolution tree, and use multi-hop adjacent sampling within the time window to generate a tree structure that can fully reflect the evolution path of historical events. Through multi-hop sampling, we can capture the dynamic evolution path of entities in historical time, effectively model long-range temporal dependencies and causal relationships, provide rich temporal context for the reasoning process, and make up for the shortcomings of traditional methods in modeling long-range temporal dependencies. We design a structured prompt template that includes task description, query information, event evolution tree, candidate entities, and more. The large language model is input with a step-by-step reasoning chain of thought steps. Through the task description, the large language model is made clear of the specific requirements of the reasoning task. The event evolution tree and candidate entity information are combined to provide the large language model with structured clues for reasoning. Through the step-by-step reasoning chain of thought steps, the large language model is guided to gradually generate reasoning results, which improves the logic and accuracy of reasoning. LoRA (low-rank adaptation technology) is used to fine-tune the instructions of the pre-trained large language model so that the model can better follow the task instructions to generate reasoning results. By freezing the pre-training parameters, only the newly added low-rank matrix is ​​trained to reduce the demand for computing resources while maintaining the pre-training accuracy. Training knowledge, through instruction fine-tuning, enables large language models to demonstrate stronger logical consistency and answer accuracy in specific task scenarios. Multimodal data such as images and audio are integrated into the embedding model, and multimodal information is introduced during the event evolution tree construction and instruction fine-tuning stages. Through the fusion of multimodal information, the model's ability to understand the semantics of entities and relationships is enhanced, solving the problem of insufficient semantic understanding caused by relying solely on text information in existing technologies. The size of the time window is dynamically adjusted according to the historical event density of the query entity, and an adaptive multi-hop sampling strategy is adopted. For entities with dense historical events, the time window is narrowed to focus on recent key events;For entities with sparse historical events, the time window is expanded to obtain more contextual information, and events with different timestamps are weighted by the time decay factor to make recent events have a greater impact on the reasoning results. The large language model is allowed to interact with the external knowledge base in real time, and a multi-round interactive reasoning process is designed to dynamically obtain additional knowledge related to the current reasoning task and supplement the insufficient information in the prompt template. Through multi-round interaction and feedback mechanism, the reasoning logic is gradually refined to improve the adaptability and accuracy of the model in complex temporal knowledge graph reasoning tasks. A two-way feedback mechanism is introduced between the embedding model and the large language model. The embedding model dynamically adjusts the weight of the entity embedding vector according to the preliminary reasoning results of the large language model; The language model dynamically adjusts the structure and content of the prompt template based on the semantic consistency feedback of the candidate entity set provided by the embedding model. Through a two-way feedback mechanism, the embedding model and the large language model collaborate and dynamically optimize during the inference process, significantly improving the accuracy of the inference results and the efficiency of the inference process. This invention obtains candidate entities through the embedding model, uses the event evolution tree to capture historical information, and combines structured prompt templates with LoRA technology to guide the large language model in reasoning, thereby optimizing the temporal knowledge graph reasoning task. The core of its working principle is to integrate the advantages of multiple models, enhance semantic understanding capabilities, capture long-range temporal dependencies, and improve the accuracy and efficiency of reasoning through dynamic adjustment and optimization mechanisms.

[0075] Example: Temporal Knowledge Graph Reasoning

[0076] 1. Background setting

[0077] Suppose we have a temporal knowledge graph (TKG) that contains multiple entities (such as companies, people, events, etc.) and their relationships that change over time. For example, the graph records information such as changes in partnerships between different companies and interactions between people.

[0078] 2. Reasoning Task

[0079] We need to answer a query question: "At time point t, with which company did Company A establish a new partnership?" The query quadruple is represented as: (Company A, established partnership, ?, t)

[0080] 3. Implementation steps

[0081] Step 1: Use the embedding model for vectorized representation. Use the ConvTransE embedding model to vectorize the query entity "Company A" and the relationship "Establishing a cooperative relationship". Combine adjacent entities, relationships, and time information to generate a vector containing structural features and semantic information. Assume that the embedding vectors are: es (embedding vector of Company A) er (embedding vector of establishing a cooperative relationship) and relevant information about timestamp t is also integrated into the vector.

[0082] Step 2: Filter the candidate entity set. By calculating the conditional probability, filter out the candidate entity set that is most relevant to the query from the large-scale entity set. The conditional probability is calculated using the formula: P(o, s, r, t) = f(e s ,e r ,e o ,t) Where f is the scoring function of the ConvTransE model. All candidate entities are sorted and the top k entities with the highest scores are selected to form the initial candidate entity set. Assume that the candidate companies selected are Company B, Company C, and Company D.

[0083] Step 3: Build an event evolution tree (EETree)

[0084] Input: query quadruple (Company A, establish cooperation,?,t), initial candidate entity set {Company B, Company C, Company D}, temporal knowledge graph TKG and time window [t start ,t end ].

[0085] Process: For the query entity "Company A", in the time range [t start ,t end ], sample its adjacent nodes and record them in the set Ns, and build the event evolution tree EETree s And add the overall tree set T, and for Company B, Company C, and Company D in the candidate entity set, also perform adjacent sampling along the time dimension to construct the event tree EETree o , add to T.

[0086] Output: The final event evolution tree set T contains the dynamic evolution information of different candidate entities over time. Suppose the event evolution tree shows that Company A has technical cooperation with Company B at t1, marketing cooperation with Company C at t2, and financial cooperation with Company D at t3.

[0087] Step 4: Design a structured prompt template. Construct a structured prompt template that includes the following: predict which company Company A has established a new cooperative relationship with at time point t, identify historical events related to Company A, track the evolution path of Company A and candidate companies, determine which company is most likely to establish a new cooperative relationship with Company A at time t, and sort the candidate companies by contextual consistency.

[0088] Step 5: Instruction fine-tuning and reasoning. Use LoRA technology to fine-tune the pre-trained large language model, input the structured prompt template into the large language model, and generate reasoning results. Assume that the large language model infers that at time point t, company A is most likely to establish a new cooperative relationship with company C based on the event evolution tree and the prompt template, because company C has more market cooperation with company A in historical events, and time point t is close to t2.

[0089] 4. Result Verification and Summary

[0090] The inference results are compared with the real data to verify the accuracy of the inference. If the inference results are consistent with the real data, the inference is successful; if not, the prompt template can be further optimized or the model parameters can be adjusted. The method of the present invention can efficiently and accurately complete the time series knowledge graph reasoning task. It combines the advantages of the embedding model and the large language model, captures historical information through the event evolution tree, and uses structured prompt templates and instruction fine-tuning technology to guide the reasoning process, significantly improving the accuracy and efficiency of reasoning.

[0091] The above description is only used to illustrate the technical solution of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, it should be understood by those skilled in the art that the technical solutions described in the aforementioned embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied to other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A temporal knowledge graph reasoning method based on a large language model, characterized by: The following steps are involved: Step 1: Use the embedding model to vectorize the query entities and relationships, combining adjacent entities, relationships, and time information to generate a vector containing structural features and semantic information; Step 2: Filter out the candidate entity set most relevant to the query from the large-scale entity set by calculating the conditional probability; Step 4: Construct an event evolution tree by performing multi-hop sampling on the adjacent nodes of the query entity and the candidate entity within the time window to generate a tree structure that can fully reflect the evolution path of historical events; Step 5: Design a structured prompt template, including task description, query information, event evolution tree, candidate entities, and step-by-step reasoning steps, as input to the large language model; Step 6: Use LoRA (low-rank adaptation technology) to fine-tune the pre-trained large language model so that the model can better follow the task instructions to generate inference results.

2. A temporal knowledge graph reasoning method based on a large language model according to claim 1, characterized in that: The embedding model uses the ConvTransE model to calculate the score of the query triples and calculate the conditional probability according to the formula: Among them, e s ,e r ,e o are the embedding vectors of query entity s, relation r, and candidate entity o respectively, and t is the timestamp. All candidate entities are sorted by the above formula, and the top k entities with the highest scores are selected to form the initial candidate entity set.

3. A temporal knowledge graph reasoning method based on a large language model according to claim 2, characterized in that: The construction of the event evolution tree satisfies the following conditions: the tree structure is defined as a directed tree, the root node is the query entity s or the key candidate node, and the edge represents the entity affecting the entity o through the relationship r at the timestamp t, which is recorded as (s, r, o, t); if there is a path (s1, r1, o1, t1) → (o2, r2, o2, t2), then t1 must be satisfied. <t2。 4. A temporal knowledge graph reasoning method based on a large language model according to claim 3, characterized in that: The event evolution tree construction algorithm includes the following steps: Input: query quad (s q ,r q ,? ,t q ), initial candidate entity set C, temporal knowledge graph TKG and time window [t start ,t end ]; Process: For the query entity s, in the time range [t start ,t end ], sample its adjacent nodes and record them in the set N s , to build the event evolution tree EETree s And add it to the overall tree set T; for the entity o that has not been sampled in the candidate entity set C, also perform adjacent sampling along the time dimension to construct the event tree EETree o , added to T; Output: The final event evolution tree set T contains the dynamic evolution information of different candidate entities in historical time.

5. The temporal knowledge graph reasoning method based on a large language model according to claim 4 is characterized in that: The method further includes a multimodal information fusion mechanism. In addition to traditional text information, the embedding model also incorporates multimodal image and audio data related to entities and relationships. Through the joint representation of multimodal embedding vectors, the model's semantic understanding of entities and relationships is enhanced. During the construction of the event evolution tree, the timestamps of multimodal information are aligned to generate an event evolution path containing multimodal features, providing richer contextual information for the large language model. During the instruction fine-tuning phase, a multimodal prompt template was designed to combine text prompts with image and audio multimodal information, guiding the large language model to make full use of multimodal information during the reasoning process.

6. A temporal knowledge graph reasoning method based on a large language model according to claim 5, characterized in that: The instruction fine-tuning technique includes the following steps: For each instruction fine-tuning sample, consisting of an instruction hint P and an input I, the model parameters θ are optimized by minimizing the log-likelihood loss function: Where P(I|P,θ) represents the probability of generating sequence I; LoRA technology is used, that is, the pre-training parameters are frozen, and only the newly added low-rank matrices A and B are trained. The parameter transformation form is: θ′=θ+A·B; the calculation formula during forward propagation is: h′=h+A·B·h, where h is the input hidden state and h′ is the hidden state after LoRA adjustment. The above method can not only maintain pre-training knowledge, but also inject new reasoning capabilities into task-specific scenarios.

7. The temporal knowledge graph reasoning method based on a large language model according to claim 6 is characterized in that: The structured prompt template construction includes: clearly stating the model task, that is, using the historical event chain and candidate entities to predict the answer in the query with missing tail entity; presenting the query content in text form (s q ,r q ,? ,t q ); present the constructed event evolution tree in structured text, including historical events and timestamp information; list the candidate entity set C obtained based on the embedding model and the event evolution tree; explain the reasoning process in detail step by step, including historical event recognition and sorting, entity evolution path tracing, causal relationship analysis, candidate entity prediction and context consistency sorting. This method further optimizes the temporal knowledge graph reasoning task through the following steps: using the embedding model to obtain multi-dimensional semantic and structural information, and screening highly relevant candidate entities from a large-scale entity set; constructing an event tree reflecting historical evolution through multi-hop adjacency sampling within the time window, providing structured context information for reasoning; designing a structured prompt template and using LoRA technology to efficiently fine-tune the large language model, thereby generating reasoning results that conform to temporal logic and causal relationships.

8. The temporal knowledge graph reasoning method based on a large language model according to claim 7 is characterized in that: A dynamic time window adjustment mechanism is introduced during the construction of the event evolution tree. The size of the time window is dynamically adjusted according to the historical event density of the query entity. For entities with dense historical events, the time window is narrowed to focus on recent key events; for entities with sparse historical events, the time window is expanded to obtain more contextual information. Within the time window, an adaptive multi-hop sampling strategy is used to dynamically adjust the sampling depth and frequency according to the importance and time interval of the relationship between entities, ensuring that the key temporal evolution path can be captured; By introducing a time decay factor to weight events with different timestamps, recent events have a greater impact on the inference results.

9. The temporal knowledge graph reasoning method based on a large language model according to claim 8 is characterized in that: The structured prompt template introduces a dynamic interactive reasoning mechanism. During the reasoning process, the large language model is allowed to conduct real-time interactive queries with an external knowledge base, dynamically acquiring additional knowledge related to the current reasoning task to supplement the information deficiencies in the prompt template. A multi-round interactive reasoning process is designed. In each round of reasoning, the large language model dynamically adjusts the prompt template content for subsequent reasoning based on the current reasoning result, gradually refining the reasoning logic until the final reasoning result is generated. A feedback mechanism is introduced to compare the reasoning result with the real data. Based on the comparison results, the structure and content of the prompt template are dynamically adjusted to optimize the performance of subsequent reasoning tasks.

10. The temporal knowledge graph reasoning method based on a large language model according to claim 9 is characterized in that: A bidirectional feedback optimization mechanism is introduced between the embedding model and the large language model. During the candidate entity screening phase, the embedding model dynamically adjusts the weights of the entity embedding vectors based on the preliminary reasoning results of the large language model, enhancing entity features that are highly relevant to the reasoning task. During the instruction fine-tuning phase, the large language model dynamically adjusts the structure and content of the prompt template based on the semantic consistency feedback of the candidate entity set provided by the embedding model to better guide the reasoning process; through a two-way feedback mechanism, the embedding model and the large language model collaborate and dynamically optimize during the reasoning process.

Citation Information

Cited By

  • Knowledge graph entity completion method

    CN120851176A

  • Version knowledge graph reasoning method and system based on big language model enhancement

    CN120875056A

  • Training sample generation method and training method for domain-specific large language model

    CN120892822A

  • Supply chain knowledge graph construction method based on time sequence dynamic perception and large language model

    CN120930757A

  • Cross-modal multi-source data typhoon path prediction method and system based on large language model

    CN122172351A