Time sequence knowledge graph completion method based on large language model
Through the temporal knowledge graph-large language model framework (TKG-LLM), entities, relationships and time information are spliced into text sequences, and instruction fine-tuning technology is used to solve the large language model illusion problem in the existing temporal knowledge graph completion model. It achieves higher accuracy and controllability, and demonstrates the powerful semantic understanding capabilities of large language models in temporal knowledge graph completion tasks.
Patent Information
- Application Number
- CN202410780089.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-06-17
AI Technical Summary
The existing temporal knowledge graph completion model relies on embedding-based methods and lacks research on utilizing quadruple text information. Moreover, large language models are prone to hallucinations when dealing with professional problems, and it is difficult to effectively combine large language models with temporal knowledge graph complementation. Full mission.
Design the Temporal Knowledge Graph-Large Language Model Framework (TKG-LLM) to enhance the professionalism of the model by splicing entities, relationships and time information into text sequences, using the language understanding and generation capabilities of the large language model, combined with instruction fine-tuning technology and output controllability, predicting entities, relationships, or evaluating plausibility of quadruples.
Significantly improves the accuracy and controllability of temporal knowledge graph completion, especially in processing deep semantic information and complex text, achieving higher Hits@1 scores and accuracy than traditional models, proving that large language models can Powerful semantic understanding capabilities in temporal knowledge graph completion tasks.
Smart Images

Figure CN118779463A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to technologies in the fields of data mining, machine learning, etc., and in particular to the task of completing incomplete temporal knowledge graphs. Background Art
[0002] Temporal knowledge graph completion is one of the current research hotspots in the field of data mining, and has been widely used in search engines, question-answering systems, and recommendation systems. Compared with static knowledge graphs, temporal knowledge graphs can more accurately describe facts that change dynamically over time by introducing temporal information. Since facts in actual application scenarios often change over time, such as social networks, logistics distribution, etc. Therefore, the advantages of temporal knowledge graphs have a wider range of application value in practical applications. Like static knowledge graphs, temporal knowledge graphs also have the problem of incompleteness. How to effectively complete the missing facts in temporal knowledge graphs is a current research hotspot.
[0003] At present, the methods of knowledge graph completion can be divided into two categories: embedding-based completion methods and text-based completion methods. Embedding-based completion methods include TransE, TA-TransE, etc., which mainly use the structural information in the knowledge graph. Text-based completion methods aim to mine semantic information in text to enhance knowledge representation. However, most existing temporal knowledge graph completion models often rely on embedding-based completion methods, and few studies use text information in quadruplets. In the static knowledge graph completion task, KG-BERT uses BERT pre-trained on a large corpus to learn contextual text representation and achieves competitive results. With the rapid development of large language models, BERT has gradually shown disadvantages relative to large language models. Especially in processing deeper semantic information and more complex texts in text, language models with large-scale parameters such as LLaMA have shown stronger understanding. However, these large language models lack domain-specific knowledge and are often prone to hallucinations when facing some professional problems. Therefore, how to combine large language models with temporal knowledge graph completion tasks is a problem that needs to be explored. Summary of the invention
[0004] The present invention proposes a new method for completing temporal knowledge graphs based on a large language model. This method uses the excellent language understanding and generation capabilities of the large language model to design a framework for completing temporal knowledge graphs, the Temporal Knowledge Graph-Large Language Model Framework (TKG-LLM). The entities, relations, and time information in the quadruple are spliced into a text sequence, and the output of the large language model is constrained by designing prompts for specific tasks. The prompts, text sequences, and auxiliary prompts are spliced according to certain rules as the input of the large language model. In order to enhance the professionalism and output controllability of the large language model in the field of temporal knowledge graph completion, instruction fine-tuning technology is used to predict entities / relations or evaluate the rationality of quadruple, which alleviates the hallucination problem of the large language model in this task.
[0005] The present invention provides a method for completing a temporal knowledge graph based on a large language model, which mainly includes the following steps:
[0006] Firstly, four classic temporal knowledge graph databases (ICEWS14, ICEWS05-15, Wikidata12k, and YAGO11k) are used to construct input sample points, and the proposed temporal knowledge graph completion method based on a large language model is used to process the input data.
[0007] Given a quad E is the entity set, R is the relationship set, and Τ is the time set. The description set is defined as They are entity e∈E, and The input text sequence of the large language model is represented as It consists of several parts: Instructional instructions Four-tuple text sequence and auxiliary tips
[0008]
[0009] Command prompt It is used to guide large language models to perform related tasks. Dynamically composed four-tuple text sequence Reflects the text details of the quad associated with the task. Optional to suit various contexts.
[0010] For the four-tuple classification task, given a fact four-tuple f = (s, p, o, t), the four-tuple classification task is to classify the four-tuple into true or false. If the four-tuple is a fact, the large language model outputs "True", otherwise the large language model outputs "False". For this task, the instruction prompts the design Designed as "Is this true:", the four-tuple text sequence is defined as For example, given the four-tuple (South Korea, Criticize or Denounce, North Korea, 2014-05-13), the input text sequence For the question “Is this true: South Korea Criticize or Denounce North Korea in 2014-05-13?”, we expect the model to output a positive answer of “True”.
[0011] For the entity prediction task, given a query (s, r, ?, t) or (?, r, o, t), the goal of the entity prediction task is to find the missing entity o or s to construct the fact quad. For the task of predicting the missing entity o, the instruction prompts Defined as "What / Who / Which country / Where". A four-tuple text sequence Defined as For example, given the four-tuple (South Korea, Criticize or Denounce, ?, 2014-05-13), the input text sequence For “What / Who / Which country / Where did South Korea Criticize or Denounce in 2014-05-13?”, we expect the model to answer “North Korea”.
[0012] For the relationship prediction task, given a query (s,?,o,t), the task is to find the missing relationship in the query and construct the fact quadruple from the temporal knowledge graph. For this task, the instruction prompts design Designed as "What relation between", a four-tuple text sequence Defined as For example, given the four-tuple (South Korea, Criticize or Denounce, North Korea, 2014-05-13), the input text sequence For the question “What relation between South Korea and North Korea in2014-05-13?”, we expect the model to output a positive answer “Criticize or Denounce”.
[0013] Instruction fine-tuning is performed in a supervised manner, using instruction prompts to guide the large language model to follow human instructions to complete specific tasks. The purpose of instruction fine-tuning is to enhance the understanding and controllability of the large language model. The training objective in the model fine-tuning process is defined as
[0014]
[0015] s ij Refers to the input text sequence The j-th token of . Represents a large language model that needs fine-tuning.
[0016] Fine-tuning is divided into full fine-tuning and partial fine-tuning. LoRA technology is used for partial fine-tuning. During the inference process, the fine-tuning model is input with instruction prompts. and four-tuple text sequences from the test set The input text sequence Get the model's predicted answer
[0017] BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is the Temporal Knowledge Graph-Large Language Model framework (TKG-LLM).
[0019] Figure 2 It is the frequency histogram of relationship categories in the ICEWS14 dataset.
[0020] Figure 3 It is the frequency histogram of relation categories in the ICEWS05-15 dataset. DETAILED DESCRIPTION
[0021] The present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0022] This method proposes a temporal knowledge graph-large language model framework TKG-LLM, which can be adapted to various large language models and combined into a new model for temporal knowledge graph completion. The currently popular ChatGLM2, Baichuan2 and LLaMA series of large language models are embedded in the framework, and the following models for temporal knowledge graph completion are obtained, TKG-ChatGLM2-6B, TKG-Baichuan2-7B, Baichuan2-13B and LLaMA2-7B, collectively referred to as the TKG-LLM series models.
[0023] The effectiveness of this method is verified by using multiple temporal knowledge graph completion tasks, including quadruple classification, relationship prediction, and entity prediction. The TKG-LLM series model is evaluated on four public datasets, including ICEWS14, ICEWS05-15, Wikidata12k, and YAGO11k.
[0024] In order to verify the performance of the proposed temporal knowledge graph completion method, the TKG-LLM series models are compared with some advanced knowledge graph completion models, which are mainly divided into two categories. The first category is embedding-based models, which include models for static knowledge graph completion and models for temporal knowledge graph completion. Static knowledge graph completion models include TransE, DistMult, and RotatE; temporal knowledge graph completion models include TTransE, HyTE, TA-TransE, and DE-TransE. The second category is text-based models. Since the current text-based models are all models for static knowledge graph completion, in order to show the effects of these models on the task of temporal knowledge graph completion, on the basis of the original models, temporal information is introduced to obtain the corresponding temporal knowledge graph completion models, such as TKG-BERT and TKG-MLT.
[0025] For the four-tuple classification task, accuracy is used as the evaluation indicator. For the entity prediction and relationship prediction tasks, since the large language model is a generative model, when training the model output, only the model is required to output its most certain answer, so Hits@1 is used as the evaluation indicator. Hits@n is the average proportion of four-tuples with a ranking less than n.
[0026] Tables 1, 2, and 3 show the main experimental results of the three tasks of entity prediction, quadruple classification, and relationship prediction, respectively.
[0027] Table 1 shows the comparison results of the TKG-LLM series models and other advanced temporal knowledge graph completion models on the link prediction task. It can be observed that both the embedding-based method and the text-based method using a smaller pre-trained language model are not as good as TKG-ChatGLM2-6B. This is mainly due to the powerful semantic understanding ability of large language models, which can mine deeper semantic information in text.
[0028] Table 2 shows the accuracy of the TKG-LLM series model and other models on the quadruple classification task on the ICEWS14, ICEWS05-15, Wikidata12k, and YAGO11k datasets. It can be observed that the TKG-LLM series model achieves competitive results in all indicators.
[0029] For the relationship prediction task, as shown in Table 3, ChatGLM2-6B achieved the highest hit@1 score in all datasets, becoming the best performing TKG-LLM series model. On the ICEWS14, ICEWS05-15, YAGO11k, and Wikidata12k datasets, TKG-ChatGLM2-6B improved Hits@1 by 0.2%, 5.3%, 1.1%, and 5.3% respectively compared to the second-best results. At the same time, it is noted that all methods perform worse on the ICEWS14 and ICEWS05-15 datasets than on the YAGO11k and Wikidata12k datasets. The main reason is that the ICEWS14 and ICEWS06-15 datasets are more complex than other datasets. The types of relationships are about 10 times larger than that of Wikidata12k and more than 20 times larger than that of YAGO11k. Too many relationship categories may lead to semantic overlap between different categories. Taking ICEWS14 as an example, the relationship “Demand material cooperation” and the relationship “Demand material aid” have very similar semantics. The relationship “Threaten to halt mediation” and the relationship “Threaten to halt negotiations” also have semantic overlap. Figure 1 and Figure 2 The significant class imbalance problem in the ICEWS14 and ICEWS05-15 datasets is shown respectively, which further exacerbates the difficulty of relationship prediction.
[0030] Table 1 Results of entity prediction Hits@1 by different methods
[0031]
[0032] Table 2 Accuracy of quadruple classification by different methods
[0033]
[0034]
[0035] Table 3 Results of relationship prediction Hits@1 by different methods
[0036]
Claims
1. A method for completing a temporal knowledge graph based on a large language model, characterized in that: The following steps are involved: First, four classic time-series knowledge graph databases are used to construct input sample points, and the proposed time-series knowledge graph completion method based on a large language model is used to process the input data; Given a quad E is the entity set, R is the relationship set, Τ is the time set; the description set is defined as They are entity e∈E, and A concise description of ; the input text sequence of the large language model is represented as It consists of several parts: Instructional instructions Four-tuple text sequence and auxiliary tips Command prompt It is used to guide large language models to perform related tasks; a dynamically composed four-tuple text sequence Text details reflecting the task-related quadruple; auxiliary prompts Being optional can be adapted to various contexts; For the four-tuple classification task, given a fact four-tuple f = (s, p, o, t), the four-tuple classification task is to classify the four-tuple into true or false. If the four-tuple is a fact, the large language model outputs "True", otherwise the large language model outputs "False". For this task, the instruction prompts the design Designed as "Is this true:", the four-tuple text sequence is defined as For the entity prediction task, given a query (s, r, ?, t) or (?, r, o, t), the goal of the entity prediction task is to find the missing entity o or s to construct the fact quadruple; for the task of predicting the missing entity o, the instruction prompts Defined as "What / Who / Which country / Where"; a four-tuple text sequence Defined as For the relationship prediction task, given a query (s,?,o,t), the relationship prediction task is to find the missing relationship in the query from the time series knowledge graph to construct the fact quadruple; for this relationship prediction task, the instruction prompts the design Designed as "What relation between", a four-tuple text sequence Defined as Instruction fine-tuning is performed in a supervised manner, using instruction prompts to guide the large language model to follow human instructions to complete specific tasks; the purpose of instruction fine-tuning is to enhance the understanding and controllability of the large language model; The training objective during model fine-tuning is defined as s ij Refers to the input text sequence The jth token of Represents a large language model that needs fine-tuning; Fine-tuning is divided into full fine-tuning and partial fine-tuning. LoRA technology is used for partial fine-tuning. During the inference process, the fine-tuning model is input with instruction prompts. and four-tuple text sequences from the test set The input text sequence Get the model's predicted answer
Citation Information
Patent Citations
Knowledge graph completion method based on large language model
CN117634604A
Network security emergency response knowledge graph completion method based on large language model
CN117648448A
Meta-knowledge fine tuning method and platform for multi-task language model
US20220138414A1
Generating commonsense context for text using knowledge graphs
US20230153534A1
Cited By
Time sequence card generation method and device based on large language model
CN121212089A
Dynamic and static dual-state knowledge graph generation system
CN121722922A
LLM knowledge completion-based OPC UA information model automatic generation method
CN122332480A
OPCUA information model automatic generation method based on LLM knowledge completion
CN122332480B
