Knowledge graph completion method based on large and small model joint prediction

By combining an embedded completion model with a large language model for joint prediction, along with contextual hints and fine-tuning strategies, the lack of flexibility in the model fusion mechanism in knowledge graph completion is addressed, thereby improving the accuracy and adaptability of knowledge graph completion.

CN121543687APending Publication Date: 2026-02-17ANHUI AGRICULTURAL UNIVERSITY
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202511743912.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-25
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing knowledge graph completion methods suffer from insufficient semantic understanding capabilities of embedded models, insufficient structured reasoning capabilities of large language models, and a lack of flexibility in model fusion mechanisms, making it difficult to balance accuracy, robustness, and computational efficiency in knowledge graph completion.

Method used

We employ a joint prediction method combining an embedded completion model and a generative large language model, along with contextual hints and fine-tuning strategies. By constructing a set of relevant and adjacent triples and long text descriptions, we dynamically adjust the model's contribution ratio to achieve accurate prediction of missing entities in the knowledge graph.

Benefits of technology

It significantly improves the accuracy and adaptability of knowledge graph completion, enhances the model's comprehensive capabilities in structured reasoning and natural language semantic understanding, and achieves intelligent scheduling and collaborative optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121543687A_ABST
    Figure CN121543687A_ABST
Patent Text Reader

Abstract

The invention discloses a knowledge graph completion method based on combined prediction of large and small models, which comprises the following steps: 1, constructing and preprocessing a knowledge graph completion reference data set, and training by adopting a RotatE model to obtain candidate entities generated by the model and confidence scores; 2, constructing a related triad, an adjacent triad and entity long text description based on the query to form a context prompt, inputting the context prompt and the query into a large language model, and performing semantic reordering and scoring by the large language model; and 3, constructing a fine tuning data set, and performing fine tuning on the large language model to obtain the KGC task optimization-oriented large language model. And based on the KGC score, the LLM score and the dynamic weight, outputting a complementation result through joint prediction of a fusion result. According to the method, the structured reasoning ability of the small model and the deep semantic understanding of the large language are effectively combined, the prediction accuracy, robustness and specialty are remarkably improved, and the defects that a single model is weak in generalization ability and insufficient in semantic utilization are overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the interdisciplinary technology of knowledge graph completion and natural language processing. Specifically, it involves a method that combines a small structured completion model with a large generative language model to automatically complete missing entities in knowledge graph triples through joint prediction and fine-tuning mechanisms. Background Technology

[0002] Knowledge graphs, as an important tool for structured representation of entities and their relationships, have wide applications in information retrieval, question answering systems, recommender systems, and semantic reasoning. However, practically constructed knowledge graphs often suffer from incompleteness, meaning many triples contain missing entities or relationships, which limits the effectiveness of downstream applications. Therefore, knowledge graph completion has become one of the core research directions in this field.

[0003] Existing knowledge graph completion methods can be mainly divided into two categories: one is based on embedding-based knowledge graph completion models (such as the Trans series and RotatE), which learn vector representations of entities and relations and complete the knowledge graph based on similarity scores; the other utilizes large language models to perform semantic inference based on natural language context. Embedding models have advantages in capturing symbolic relation patterns and efficient reasoning, but they are insufficient in utilizing long text semantic descriptions and handling complex fuzzy queries. Large language models are strong in understanding long texts and semantic associations, but when used alone, they may be affected by training corpus bias and still have limitations in structured knowledge graph reasoning. In addition, most existing technologies adopt a single model or a fixed fusion strategy: embedding models and large language models are usually used separately or in a simple weighted fusion, lacking a mechanism to dynamically adjust the contribution of each model for specific queries, thus making it difficult to achieve an ideal balance between accuracy, robustness, and computational efficiency. Summary of the Invention

[0004] This invention aims to address the shortcomings of existing embedded models in semantic understanding, large language models in structured reasoning, and the lack of flexibility in model fusion mechanisms. It proposes a knowledge graph completion method based on joint prediction of large and small models. The method aims to improve the accuracy, stability, and interpretability of knowledge graph missing entity prediction by working collaboratively with embedded completion models and generative large language models, combined with contextual hints and fine-tuning joint strategies.

[0005] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: The knowledge graph completion method based on joint prediction of large and small models of the present invention is characterized by the following steps: Step 1: Obtain the knowledge graph dataset and divide it into training sets. Validation set and test set Using the training set The knowledge graph completion model is trained to obtain the trained knowledge graph completion model; Step 2, Any triple in the set is set as the missing triple. ,in, Indicates the head entity. This indicates the relationship between the head entity and the tail entity. Indicates a missing tail entity; Using the trained knowledge graph to complete the model The process involves making predictions, generating a list of candidate entities and their corresponding confidence scores, and then normalizing the confidence score list to obtain the candidate entities and their normalized confidence score lists. ,in, express The nth candidate entity in the list, Represents the nth candidate entity Normalized confidence score; Indicates the number of candidate entities; Step 3: Construct a set of relevant triples Adjacent triple set and Long text descriptions of all entities in the text Build into context hints ; Step 4: Construct knowledge graph completion task instructions Query , as well as The resulting prompt template , and enter ,in, Indicates the number after reordering One entity, for The corresponding confidence score, where L is the number of candidate entities after reordering; Step 5: Construct the fine-tuning dataset ; Step 6, based on The LoRA method is used to process pre-trained large language models. The parameters in the model are fine-tuned to obtain the larger model after fine-tuning. ; Step 7: Construct from and Create a prompt template and input the finely tuned large model. The dynamic weights are obtained through processing. ; Step 8, Calculation The final score of the xth candidate entity in the dataset. Thus obtain The final score of all candidate entities: Step 9, from The candidate entity with the highest final score among all candidate entities is selected. As a query Complete and output the tail entity.

[0006] The knowledge graph completion method based on joint prediction of large and small models described in this invention is also characterized in that step 3 includes: Construct the set of relevant triples ,in, and This represents the head and tail entities in the relevant triple. express and The entity set in; Construct a set of adjacent triples ,in, express and The relationship between them express and The set of relations in; Get Long text descriptions of all entities in the text ,in, express The Middle One entity, express A long text description; express and The number of entities in the text.

[0007] Furthermore, in step 5, it is... and Any triples in the dataset form a sample, thus constructing the fine-tuning dataset. ,in, and This represents the list of candidate entity scores obtained by KGC and LLM predicting the u-th sample. Let be the weight of the u-th sample, and U be the number of data points to be fine-tuned.

[0008] Furthermore, step 8 involves calculating using equation (7). The final score of the xth candidate entity in the dataset. : (7) In equation (7), and The predicted numbers for KGC and LLM are respectively x The confidence score of each candidate entity. For query middle The corresponding candidate tail entity.

[0009] The present invention provides an electronic device, including a memory and a processor, characterized in that the memory is used to store a program supporting the processor in executing the joint prediction knowledge graph completion method, and the processor is configured to execute the program stored in the memory.

[0010] The present invention provides a computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, performs the steps of the joint prediction knowledge graph completion method.

[0011] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention combines an embedded completion model with a large language model. Through a joint prediction mechanism, it takes into account the advantages of structured reasoning and natural language semantic inference. This enables the method to handle structured triple reasoning tasks and understand complex semantic contexts, thereby significantly improving the accuracy and adaptability of knowledge graph completion.

[0012] 2. This invention automatically generates dynamic weights based on the specific query using a fine-tuned large language model. It can adaptively adjust the contribution ratio of the large and small models based on entity relationship semantics, triple structure information, and prediction scores of the large and small models, thus achieving intelligent scheduling and collaborative optimization at the model level.

[0013] 3. This invention utilizes the LlamaFactory framework and the LoRA method to efficiently fine-tune the parameters of the LLaMA-3-8B model. It combines the prediction examples of the embedding model and the large language model to construct a dedicated dataset, enabling the large language model to have stronger domain adaptability in tasks such as understanding structured knowledge and performing entity prediction. Attached Figure Description

[0014] Figure 1 This is a flowchart of the KGC model training process of the present invention; Figure 2 This is a flowchart of the large-scale model prediction process of this invention; Figure 3 This is a flowchart of the fine-tuning process for the large model of this invention; Figure 4 This is a flowchart of the joint prediction process of the present invention; Figure 5 This is a flowchart illustrating the method architecture of the present invention. Detailed Implementation

[0015] In this embodiment, a knowledge graph completion method based on joint prediction of large and small models is described, such as... Figure 5 As shown, it includes the following steps: Step 1: The proposed method was systematically evaluated using two widely adopted knowledge graph completion benchmark datasets, FB15k-237 and WN18RR. FB15k-237 is an optimized subset of the Freebase knowledge graph, an encyclopedic structured database covering multidimensional entity relationships across multiple domains, including celebrities, organizations, movies, and sports. To enhance the model's inference capabilities, the original dataset was specially processed: inverse relations that might introduce prediction bias were removed, while the 237 most challenging relation types were retained. Specifically, inverse relations refer to pairs of relations. and The coexistence of these relationships in the dataset allows the model to easily infer answers without learning complex semantics, thus introducing prediction bias. The 237 relationship types were determined by filtering statistically simple or redundant relationships from the original set, focusing on those with higher complexity, such as many-to-many patterns, long-tailed distributions, and relationships requiring deeper contextual reasoning. WN18RR, as an improved version of the WordNet lexical semantic network, focuses on morphological relationships in English words (synonyms, antonyms, hyponyms, and syntagms). By eliminating the test set leakage problem present in the WN18 dataset, it provides a more rigorous benchmark for model evaluation.

[0016] The processed knowledge graph datasets FB15k-237 and WN18RR were divided into non-overlapping training sets according to an 80% : 10% : 10% ratio. Validation set and test set .

[0017] Step 2, as follows Figure 1 As shown, using the training dataset and validation dataset The knowledge graph completion model KGC is trained. In this embodiment, the RotatE model is used as the knowledge graph embedding algorithm. This model captures and infers the semantic associations of triples by rotating entities and relations in complex space.

[0018] In the initial training phase, all entity and relation vectors in the knowledge graph are randomly initialized, where each entity is mapped to a vector representation in complex form, and each relation is mapped to a complex vector with rotation semantics. To ensure stable model training, the magnitude of the relation vectors is normalized to maintain a unit length, thus representing only rotation operations without introducing scale bias.

[0019] Subsequently, the model is iteratively trained using triplet samples (including positive samples and negative samples generated through negative sampling) from the training set. In each training round, the model first calculates the similarity score between the head entity, relation, and tail entity in the sample, and then calculates the loss value based on the score to measure the difference between the predicted result and the true label. The model parameters are updated using a gradient descent-based optimization algorithm, continuously adjusting the embedding vectors of entities and relations so that the score of the true triplet is higher than the score of the negative sample.

[0020] During training, through the validation set Regularly evaluate model performance (e.g.) and The model's convergence status is dynamically monitored using metrics such as [list of metrics]. When the performance metrics on the validation set fail to improve significantly after several consecutive iterations, or when the number of training rounds reaches a preset upper limit, the model is determined to have converged or reached the termination condition, training is stopped, and the optimized knowledge graph completion model KGC is finally obtained.

[0021] Step 3: Use the trained RotatE model to... The triples in the dataset are used to predict and generate corresponding candidate entities and their confidence scores. ,in, express The nth candidate entity, This represents the confidence score of the nth candidate entity; the obtained confidence score... Normalization is performed: (1) In equation (1), Represents the nth candidate entity Normalized confidence scores, obtained through normalization Obtain the list of selected entities and their normalized scores. ,in, express The nth candidate entity in This indicates the number of candidate entities.

[0022] Step 4: For the missing triples in the input ,in, Indicates the head entity. Indicates a relationship. This represents a missing tail entity. In this embodiment, two types of triples are constructed from the knowledge graph: relevant triples and adjacent triples. The definition of a relevant triple is as follows: (2) in, and This represents the head and tail entities in a triple. express and The entity set in the query. By providing the relationship with the query. In this embodiment, identical triples enable the large language model to more accurately understand the semantic meaning of the query. The definition of adjacent triples is as follows: (3) in, Indicates a relationship. Represents a set of relationships in a knowledge graph. This is achieved by providing and querying the entity header. The associated additional triples inject richer contextual information into the large language model.

[0023] Organize entity sets Long text descriptions of all entities in the text ,in, express The Middle One entity, express A long text description, This indicates the number of entities in the dataset. By providing semantically rich descriptive information, it enhances the model's understanding of entity meaning and provides additional contextual information, thereby significantly improving the model's performance in entity prediction tasks. , and Build into context hints .

[0024] Step 5, as follows Figure 2 As shown, a unified prompt template is introduced. Query and the built context hints It is translated into natural language. Furthermore, task instructions are also incorporated. The goal of the large language model (LLM) is explicitly stated to rank and score candidate answers based on their reasonableness. In this embodiment, DeepSeek (DeepSeek-v3; DeepSeek-v2.5) and Qwen (Qwen2.5-72B-Instruct) are used as the large language model. All LLMs call third-party API interfaces and use default parameter settings, including temperature parameters, Top-p sampling, presence penalty, and frequency penalty. The organized context is input into the LLM, which then sorts the candidate entity list based on the context semantics. Re-sort and score: (4) in, This represents the candidate entity and score list after LLM reordering. This indicates a prompt template. This indicates a task instruction that returns a reordered list of candidate entities. ,in Indicates ranking The entity, The corresponding score is given, and L is the number of candidate entities after reordering.

[0025] Step 6, from and Any triples in the dataset can be used to construct a sample data set for fine-tuning the large model. ,in, and This represents the list of candidate entity scores obtained by the KGC model and LLM model for the u-th sample. For dynamic weights, U is the number of data points for fine-tuning.

[0026] Step 7, as follows Figure 3 As shown, the LlamaFactory framework is used for efficient parameter fine-tuning of the large language model LLaMA-3-8B. The fine-tuning dataset used is... This includes instruction-response samples and contextual cue samples built for specific tasks, which are used to guide the model to adapt knowledge and enhance capabilities in the target knowledge domain or task scenario.

[0027] In the specific implementation, the pre-trained language model is first loaded. Furthermore, the LoRA fine-tuning module is configured within the LlamaFactory framework. This module achieves efficient parameter updates by introducing trainable low-rank matrices into some linear layers of the model, while keeping the original model parameters frozen, thereby significantly reducing memory usage and computational costs.

[0028] Subsequently, based on the fine-tuned dataset The instruction samples in the dataset are used to perform supervised fine-tuning training of the model. During training, the LlamaFactory framework loads training samples according to the set batch size and learning rate, uses autoregressive language to model the objective function to calculate the prediction loss, and uses optimization algorithms (such as AdamW) to update the trainable parameters of the LoRA insertion layer using gradients.

[0029] After each training epoch, the system automatically evaluates the model's perplexity and task accuracy on the validation set, monitoring the model's convergence status. Training stops when the evaluation results show no significant improvement for several consecutive epochs, or when the preset maximum number of training epochs is reached. Finally, a fine-tuned large language model is obtained. (5) in, This represents the fine-tuned large language model. This represents a pre-trained large language model. Indicates based on fine-tuning dataset The learned low-rank weight increment.

[0030] Step 8, after fine-tuning Based on the predicted candidate entity score list and Provide dynamic weights: (6) in, Indicates dynamic weights, This indicates a prompt template.

[0031] Step 9, as follows Figure 4 As shown, fine-tuning the large model Based on the candidate entity score list and Predicting dynamic weights The final score of the candidate entity is calculated using a joint prediction function: (7) in, Let x be the final score of the x-th candidate entity. and These are the scores of the x-th candidate entity predicted by the KGC model and the LLM model, respectively. For query middle The corresponding candidate tail entities. A list of candidate entity scores obtained after joint prediction. Select the candidate entity with the highest score. As output.

[0032] In this embodiment, an electronic device includes a memory and a processor. The memory stores a program that supports the processor in executing the methods described above, and the processor is configured to execute the program stored in the memory.

[0033] In this embodiment, a computer-readable storage medium stores a computer program, which is executed by a processor to perform the steps of the above method.

Claims

1. A knowledge graph completion method based on joint prediction using large and small models, characterized in that, Includes the following steps: Step 1: Obtain the knowledge graph dataset and divide it into training sets. Validation set and test set Using the training set The knowledge graph completion model is trained to obtain the trained knowledge graph completion model; Step 2, Any triple in the set is set as the missing triple. ,in, Indicates the head entity. This indicates the relationship between the head entity and the tail entity. Indicates a missing tail entity; Using the trained knowledge graph to complete the model The process involves making predictions, generating a list of candidate entities and their corresponding confidence scores, and then normalizing the confidence score list to obtain the candidate entities and their normalized confidence score lists. ,in, express The nth candidate entity in the list, Represents the nth candidate entity Normalized confidence score; Indicates the number of candidate entities; Step 3: Construct a set of relevant triples Adjacent triplet set and Long text descriptions of all entities in the text Build into context hints ; Step 4: Construct knowledge graph completion task instructions Query , as well as The resulting prompt template , and enter ,in, Indicates the number after reordering One entity, for The corresponding confidence score, where L is the number of candidate entities after reordering; Step 5: Construct the fine-tuning dataset ; Step 6, based on The LoRA method is used to process pre-trained large language models. The parameters in the model are fine-tuned to obtain the larger model after fine-tuning. ; Step 7: Construct from and Create a prompt template and input the finely tuned large model. The dynamic weights are obtained through processing. ; Step 8, Calculation The final score of the xth candidate entity in the dataset. Thus obtain The final score of all candidate entities: Step 9, from The candidate entity with the highest final score among all candidate entities is selected. As a query Complete and output the tail entity.

2. The knowledge graph completion method based on joint prediction of large and small models according to claim 1, characterized in that, Step 3 includes: Construct the set of relevant triples ,in, and This represents the head and tail entities in the relevant triple. express and The entity set in; Construct a set of adjacent triples ,in, express and The relationship between them express and The set of relations in; Get Long text descriptions of all entities in the text ,in, express The Middle One entity, express A long text description; express and The number of entities in the text.

3. The knowledge graph completion method based on joint prediction of large and small models according to claim 2, characterized in that, Step 5 is... and Any triples in the dataset form a sample, thus constructing the fine-tuning dataset. ,in, and This represents the list of candidate entity scores obtained by KGC and LLM predicting the u-th sample. Let be the weight of the u-th sample, and U be the number of data points to be fine-tuned.

4. The knowledge graph completion method based on joint prediction of large and small models according to claim 3, characterized in that, Step 8 is to calculate using equation (7). The final score of the xth candidate entity in the dataset. : (7) In equation (7), and The predicted numbers for KGC and LLM are respectively x The confidence score of each candidate entity. For query middle The corresponding candidate tail entity.

5. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store programs that support the processor in executing the knowledge graph completion method of any one of claims 1-4, the processor being configured to execute the programs stored in the memory.

6. A computer-readable storage medium storing a computer program thereon, characterized in that, The computer program, when run by a processor, performs the steps of the knowledge graph completion method for joint prediction as described in any one of claims 1-4.

Citation Information

Cited By

  • Explanatability fusion and recovery method after large language model training based on interpretability

    CN121936572A

  • Geology big data knowledge completion method, system and device and medium

    CN122198086A

  • Knowledge graph completion method based on type constraint and relation memory enhanced network

    CN122242668A

  • Knowledge graph completion method based on dynamic routing and double-channel reasoning

    CN122287828A