Knowledge graph completion method based on large language model and graph neural network

By combining large language models and graph neural networks to build multi-level local graphs, the problem of failing to make full use of knowledge graph structure information in the existing technology is solved, and more efficient knowledge graph completion performance is achieved.

CN120144775AActive Publication Date: 2025-06-13BEIJING JIAOTONG UNIV

Patent Information

Application Number
CN202510068910.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-16
Publication Date
2025-06-13
Estimated Expiration
2045-01-16

AI Technical Summary

Technical Problem

When using large language models to complete knowledge graphs, the prior art fails to fully utilize the structural information of the knowledge graph, resulting in the failure to fully realize the inference potential.

Method used

Using a knowledge graph completion method based on large language model and graph neural network, a multi-level local graph is constructed, combined with the RoBERTa-Large model and the GNN network, an embedded representation with more expressive capabilities is generated, thereby improving the performance of knowledge graph completion.

Benefits of technology

By making full use of the semantic understanding of large language models and the graph inference ability of graph neural networks, we enhance the perception of graph structure and improve the performance of knowledge graph completion, especially when dealing with complex relationships and multi-hop path inference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144775A_ABST
    Figure CN120144775A_ABST
Patent Text Reader

Abstract

The invention provides a knowledge graph completion method based on a large language model and a graph neural network. The method comprises the steps of obtaining definitions and descriptions of a head entity, a tail entity and a relation in a triple, and obtaining a problem instruction for triple classification; a multi-hop sub-graph with an entity as the center is obtained, a word embedding model is used as a feature extractor, the multi-hop relation between triples is analyzed, and therefore high-quality semantic features existing in multiple hops are obtained. Secondly, complex graph structure information is captured by using a graph neural network, and an interaction relationship between nodes is learned, so that graph structure data can be better understood. And finally, fine-tuning the large language model in combination with the question and answer instruction to help the large language model focus on the key task. According to the method, the characteristics of strong context perception capability and complicated sentence structure and context understanding of a large language model are combined with aggregated node structure information to generate embedded representation with better expression capability, so that the performance of knowledge graph completion is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer application technologies, and in particular, to a knowledge graph completion method based on a large language model and a graph neural network. Background Art

[0002] A knowledge graph represents factual knowledge in the form of triples (head entity, relation, tail entity), and these triples together form a graph. However, there may be problems of incomplete and incorrect information, resulting in many missing facts in the constructed knowledge graph. The knowledge graph completion task (Knowledge Graph Completion, KGC) is based on the existing triple information to judge the possible missing entities or relations, so as to expand and improve the knowledge graph. A large language model (Large Language Model, LLM) uses its powerful natural language processing and reasoning capabilities to better understand the semantics of entities and relations, predict missing triples, and plays an important role in the field of knowledge graph completion.

[0003] The knowledge graph completion task often needs to infer complex relations between entities, especially the relation reasoning on multi-hop paths. At present, the existing research on KGC based on LLM still has limitations, and there are deficiencies in using the structural information in the knowledge graph, and its reasoning potential has not been fully exerted. Summary of the Invention

[0004] The present invention provides a knowledge graph completion method based on a large language model and a graph neural network to effectively complete the knowledge graph.

[0005] To achieve the above object, the present invention adopts the following technical solutions.

[0006] A knowledge graph completion method based on a large language model and a graph neural network includes:

[0007] Taking multiple triples constituting the knowledge graph as a positive sample set, each triple includes a head entity, a relation, and a tail entity, forming an entity set from all entities in the knowledge graph, extracting entities from the entity set, and randomly replacing the head entity or the tail entity of each triple in the positive sample set to form an equal number of negative samples;

[0008] Obtaining the definitions and descriptions of the head entity, tail entity, and relation in the triple, and splicing the definitions and descriptions to obtain a problem instruction for triple classification;

[0009] Obtaining triples with direct relations, two-hop relations, and three-hop relations with each entity from the positive sample set to obtain local graphs at different levels centered on the entity;

[0010] Encode the entities and relationships in local graphs at different levels through the RoBERTa-Large model respectively, and store the encoded graph structures corresponding to each entity obtained by encoding according to the entity index;

[0011] Input the encoded graph structure corresponding to each entity into the graph neural network GNN. The GNN aggregates the information of entity neighbors to generate the local graph encoding corresponding to each entity;

[0012] Use the local graph encodings corresponding to the head and tail entities in a triple as prefixes, and form a sequence with the triple and the question instruction;

[0013] Input the sequence into the Llama3 model. The Llama3 model performs format conversion on the sequence, and then inputs the sequence after format conversion into the LoRA fine-tuned large model. The LoRA fine-tuned large model adds a low-rank matrix to the weight matrix and outputs the judgment result of whether the triple is correct or incorrect.

[0014] Preferably, use multiple triples that make up the knowledge graph as the positive sample set. Each triple includes a head entity, a relationship, and a tail entity. An entity set is composed of all entities in the knowledge graph. Entities are extracted from the entity set, and the head entity or tail entity of each triple in the positive sample set is randomly replaced to form an equal number of negative samples, including:

[0015] Set the knowledge graph where ε is the entity set, is the relationship set, T = {(h, r, t)} is the triple set, where h, t ∈ ε represent the head entity and the tail entity respectively, is the relationship between the head entity h and the tail entity t, and use T as the positive sample set;

[0016] Randomly extract h′ (h′≠h) or t′ (t′≠t) from ε, and replace the head and tail entities of the triple with the extracted h′ or t′ to form a negative sample set T′ = {(h′, r, t)|(h, r, t′)} equal to the positive sample set T.

[0017] Preferably, obtain the definitions and descriptions of the head entity, tail entity, and relationship in the triple, and splice the definitions and descriptions to obtain the question instruction for triple classification, including:

[0018] Read the definition of the head entity h in the triple Triples(h, r, t) The definition of the relationship r The definition of the tail entity t The description information of the head entity h And the description information of the tail entity t And the instruction T for asking questions qJointly splice to form the input text T x :

[0019]

[0020] Take the text T x as a question - answering instruction for triple classification.

[0021] Preferably, obtaining triples with direct, two - hop, and three - hop relationships with each entity from the positive sample set to obtain local graphs at different levels centered on the entity, including:

[0022] Obtain all entities in the positive sample set T = {(h, r, t)}, and obtain triples with direct, two - hop, and three - hop relationships with each entity. The first - level local graph G of each entity 1 is composed of triples with direct relationships with the target entity. The second - level local graph G 2 is to add a two - hop sub - graph related to the target entity on the basis of the first level. The third - level local graph G 3 adds a three - hop sub - graph related to the target entity on the basis of the second level, and so on, respectively constituting local graphs G at different levels centered on the entity n (n = 1, 2, 3).

[0023] Preferably, encoding both entities and relationships in local graphs at different levels through the RoBERTa - Large model, and storing the encoded graph structure corresponding to each entity according to the entity index, including:

[0024] Input the local graphs G at different levels centered on the entity n into the RoBERTa - Large model. Through the RoBERTa - Large model, extract features and number each entity and relationship in the multi - hop sub - graph G n to obtain the graph structure m is the number of entities;

[0025] Create a graph structure of all 0s When an entity that has not appeared is encountered during training or testing, then use the graph structure, and store the encoded graph structure corresponding to each entity according to the entity index.

[0026] Preferably, inputting the encoded graph structure corresponding to each entity into the graph neural network GNN network, and the GNN network aggregates the information of entity neighbors to generate the local graph encoding corresponding to each entity, including:

[0027] Find the corresponding graph structure according to the indices of the head entity and the tail entity, and input the graph structure into the GNN network. The GNN network uses a graph encoder to encode the graph structure and generate local graph encodings corresponding to each entity.

[0028]

[0029] POOL represents the average pooling operation, and MLP represents two fully connected layers.

[0030] Preferably, using the local graph encodings corresponding to the head and tail entities in a triple as a prefix, and combining with the triple and the question instruction to form a sequence, includes:

[0031] The local graph encodings corresponding to the head and tail entities in a triple Concatenate as a prefix, and vectorize the text Τ corresponding to the triple as the question instruction x to obtain Combine the prefix and the vectorized text to obtain the input sequence x;

[0032]

[0033] Preferably, inputting the sequence into the Llama3 model, the Llama3 model performs format conversion on the sequence, and inputs the format-converted sequence into the LoRA fine-tuned large model. The LoRA fine-tuned large model adds a low-rank matrix to the weight matrix and outputs a judgment result of whether the triple is correct or incorrect, including:

[0034] Using the graph encodings in the sequence x as soft prompts, and using the T in the sequence x x as the condition for the classification instruction. Input the sequence x into the Llama3 model. The Llama3 model performs format conversion on the sequence, and inputs the format-converted sequence into the LoRA fine-tuned large model. The LoRA fine-tuned large model generates the answer Y for the triple. The generation process of the answer Y is as follows:

[0035]

[0036] φ 0 represents the parameters of the frozen Llama3 model, φ 1φ is a prompt parameter available for training, and Δφ(Θ) is an incremental parameter specific to the downstream task, encoded with fewer parameters Θ (|φ| << |Θ|). LoRA fine-tunes the large model by adding low-rank matrices to the weight matrix to adapt the pre-trained language model to a specific task; output the judgment result Y of whether the triple is correct or incorrect. If Y is yes, it is judged that the triple is correct; if Y is no, it is judged that the triple is incorrect.

[0037] As can be seen from the technical solutions provided by the embodiments of the present invention described above, the present invention utilizes the powerful context awareness ability of the large language model, understands the characteristics of complex sentence structures and contexts, combines with the aggregated node structure information, and generates a more expressive embedding representation, thereby improving the performance of knowledge graph completion.

[0038] Additional aspects and advantages of the present invention will be given in part in the following description, which will become apparent from the following description, or can be understood through the practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0040] Figure 1 It is a processing flow chart of a knowledge graph completion method based on a large language model and a graph neural network provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0041] The embodiments of the present invention will be described in detail below. Examples of the embodiments are shown in the drawings, where the same or similar reference numerals represent the same or similar elements or elements with the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary only for explaining the present invention and should not be construed as limiting the present invention.

[0042] Those skilled in the art can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present invention means the presence of the described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups. It should be understood that when we say that an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or coupling. The phrase "and / or" used herein includes any and all combinations of any one of the one or more associated listed items.

[0043] Those skilled in the art can understand that, unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as the general understanding of those of ordinary skill in the field to which the present invention belongs. It should also be understood that terms such as those defined in a general dictionary should be understood to have a meaning consistent with the meaning in the context of the prior art, and will not be interpreted with an idealized or overly formal meaning unless defined as here.

[0044] For the convenience of understanding the embodiments of the present invention, the following will further explain with several specific embodiments in conjunction with the accompanying drawings, and each embodiment does not constitute a limitation to the embodiments of the present invention.

[0045] The present invention first utilizes the bidirectional encoding ability of the RoBERTa-Large model to comprehensively capture the deep semantic relationships of the local graph of entities. Then, with the reasoning ability of the GNN (Graph Neural Network), it can analyze the multi-hop paths in the knowledge graph and find the potential connections between the head entity and the tail entity. Combining the ability of the LLM to process language information, the model can not only predict the missing relationships in the knowledge graph, but also ensure the completion of the knowledge graph.

[0046] The processing flow of a knowledge graph completion method based on a large language model and a graph neural network provided by an embodiment of the present invention is as Figure 1 shown, including the following processing steps:

[0047] Step S1: The knowledge graph is composed of multiple triples Triples (head entity, relationship, tail entity), which is called the positive sample set; the entity set is composed of all entities in the knowledge graph, entities are extracted from the entity set, and the head entity or the tail entity of each triple is randomly replaced to form an equal number of negative samples;

[0048] Step S2: Obtain the definitions and descriptions of the head entity, tail entity, and relation in the triple, and splice the definitions and descriptions to obtain the question instruction for triple classification.

[0049] Step S3: Obtain the triples with direct, two-hop, and three-hop relationships with each entity from the positive sample set. A two-hop relationship means reaching a node through an intermediate node, and a three-hop relationship means reaching a node through two intermediate nodes.

[0050] Step S4: Obtain the local graphs at different levels centered on the entity from S3. At the same time, for entities that do not appear, construct a graph structure with all-zero edge relationships, so that each entity has a corresponding graph structure.

[0051] Step S5: Encode the entities and relationships in the local graphs at different levels through the RoBERTa-Large model respectively, and store the encoded graph structures corresponding to the entities according to the entity index.

[0052] Step S6: Input the encoded graph structures corresponding to each entity into the GNN network. The GNN network aggregates the information of entity neighbors to better represent and reason about complex multi-relational graphs, and generates the local graph encoding corresponding to each entity.

[0053] Step S7: For a triple, use the local graph encodings related to the head and tail entities obtained in S6 as a prefix, and form a sequence with the triple and the question instruction. Input the sequence into the Llama3 (Large Language Model Meta AI-3-8B-Instruct, a large language model released by Meta AI) model. Llama3 converts the sequence into an input format acceptable to the LoRA fine-tuned large model by loading a pre-trained text processing model.

[0054] Step S8: Input the sequence after format conversion into the LoRA (Low-Rank Adaptation of Large Language Models) fine-tuned large model. The LoRA fine-tuned large model adds a low-rank matrix to the weight matrix of the large model without changing the original pre-trained parameters. During the training process, only a small number of parameters in the low-rank matrix need to be updated. The LoRA fine-tuned large model outputs the answer (yes or no) to the question instruction in the above sequence, records the result, and calculates the evaluation metrics accuracy and F1 value. The F1 value is calculated from the precision and recall.

[0055]

[0056] Precision represents the ratio of truly positive samples among the positive samples predicted by the model, and Recall represents how many of all truly positive samples are successfully identified as positive by the model.

[0057] Further, in the step S1 where ε is the entity set, is the relation set, T = {(h, r, t)} is a triple, where h, r ∈ ε are the head and tail entities, and r is the relation between them. Randomly replace the head and tail entities of the triple, draw h′ (h′ ≠ h) or t′ (t′ ≠ t) from ε, and form the negative sample set T′ = {(h′, r, t)|(h, r, t′)}

[0058] Further, the step S2 reads the definitions of the entities and relations in the triple (h, r, t) and the description information about the entities together with the instruction T for asking questions q are jointly concatenated into the input text:

[0059]

[0060] Text T x is the Q&A instruction for triple classification and serves as a prompt for Llama3 model training.

[0061] Further, the implementation process of the step S3 is as follows:

[0062] The local graph is constructed under the multi-hop relations of the entities, and each level of the local graph is superimposed on the basis of the previous level. Obtain all the entities in the positive sample T = {(h, r, t)}, and construct local graphs of different levels for each entity. The first-level local graph G 1 is composed of triples directly related to the target entity. The second-level local graph G 2 adds a two-hop subgraph related to the target entity on the basis of the first level. The third-level local graph G 3 adds a three-hop subgraph related to the target entity on the basis of the second level. And so on, respectively constructing local graphs G of different levels centered on the target entity n (n = 1, 2, 3).

[0063] For example, for the triple ('Europe', 'location location contains', 'Italy'), the second-level local graph of the head entity 'Europe' contains 49 triples, and the second-level local graph of the tail entity 'Italy' contains 18 triples. Part of the information is listed below:

[0064] Instance Analysis of Local Map in Table 1

[0065]

[0066]

[0067] Furthermore, the goal of step S4 is to number the corresponding local maps G at different levels in the order of the entity set n for numbering.

[0068] Extract features for each entity and relationship in the multi-hop sub-graph G n through the RoBERTa-Large model, and perform numbering processing to obtain where m is the number of entities. Additionally, create a graph structure of all zeros When an entity that has not appeared is encountered during training or testing, then use the graph structure to save the encoded local map.

[0069] Furthermore, in step S5, find the corresponding local maps according to the indices of the head and tail entities, and use the graph encoder to encode the structures of the two local maps to obtain Defined as follows:

[0070]

[0071] POOL represents the average pooling operation, and MLP represents two-layer fully connected.

[0072] Furthermore, in step S6, encode the local maps corresponding to the head and tail entities in a triple concatenate as a prefix, and vectorize the text Τ corresponding to the triple as the question instruction x to obtain Merge the prefix and the vectorized text to obtain the input sequence x;

[0073]

[0074] Furthermore, in the last stage of step S7, the graph encoding acts as a soft prompt and T x to generate the answer Y under the condition of classifying instructions, and these inputs are fed into the frozen Llama3 model. The generation process is as follows:

[0075]

[0076] φ 0 represents the parameters of the frozen Llama3 model, φ1 They are prompt parameters available for training. To efficiently and quickly fine-tune the Llama3 model, LoRA is introduced to fine-tune large models. Δφ(Θ) are incremental parameters specific to downstream tasks, encoded with fewer parameters Θ (|φ| << |Θ|). The pre-trained language model is adapted to specific tasks by adding low-rank matrices to the weight matrix. LoRA adapts the pre-trained language model to specific tasks by adding low-rank matrices to the weight matrix.

[0077] The sequence x after format conversion is input into the LoRA fine-tuned large model, and the result Y of judging the triple is output. If the output is yes, it is considered that the triple is correct. Through the triple classification task, the knowledge graph becomes more complete.

[0078] Save the judgment result, extract the output result using regular expressions, and calculate the accuracy and F1 value. Finally, step S9 saves the judgment result, extracts the output result using regular expressions, and calculates the accuracy.

[0079] In summary, the present invention first obtains the triples formed by each entity and its neighbor nodes in the positive sample set and merges them with the multi-hop subgraph of the entity, encodes them through a word embedding model, thereby obtaining the local graph features of the entity, and inputs them into the GNN. The triples and their corresponding description information in the positive and negative samples are concatenated and encoded, and then concatenated with the graph structure information obtained above and input into the large language model for training.

[0080] Inference to obtain the judgment result.

[0081] The method of the present invention was experimented on three partial datasets of real worlds, namely FB15K237-N, Wiki27K, and WN18RR. Acc (Accuracy) and F1 (F-Measure) are used to evaluate the prediction results. The prediction results based on the three datasets are shown in Table 1. It can be seen from the experimental results that in terms of the ACC index performance, the index performance of the method of the present invention on the three test data has increased by 4.7%, 1%, and 3.5% respectively. In terms of the F1 index performance, the index performance of the method of the present invention on the three test data has increased by 11%, 6.1%, and 3.3% respectively.

[0082] Table 1 Evaluation index results based on three datasets

[0083]

[0084] In summary, the embodiments of the present invention enhance the perception of the graph structure, improve the reasoning ability, reduce resource overhead, and effectively address the generalization and update problems by fully utilizing the semantic understanding of the LLM and the graph reasoning ability of the GNN.

[0085] Knowledge graphs are also widely used in fields such as recommendation systems, natural language processing, and healthcare. The knowledge graph completion task enhances the integrity and accuracy of overall information by filling in the missing entities and relationships in the graph, providing better support for model reasoning and decision-making.

[0086] Those of ordinary skill in the art can understand that the accompanying drawings are only schematic diagrams of an embodiment, and the modules or processes in the drawings are not necessarily essential for implementing the present invention.

[0087] From the description of the above embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of the present invention.

[0088] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device or system embodiments, since they are basically similar to the method embodiments, they are described relatively simply. For the relevant parts, reference can be made to the partial description of the method embodiments. The device and system embodiments described above are only illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative efforts.

[0089] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A knowledge graph completion method based on a large language model and graph neural network, characterized in that: include: Take multiple triplets that constitute the knowledge graph as the positive sample set. Each triple includes a head entity, a relationship, and a tail entity. The entity set is composed of all entities in the knowledge graph. Entities are extracted from the entity set, and the head entity or tail entity of each triple in the positive sample set is randomly replaced to form an equal number of negative samples. Obtain the definitions and descriptions of the head entity, tail entity, and relationship in the triple, concatenate the definitions and descriptions, and obtain question instructions for triple classification; Acquire triples having direct, two-hop, and three-hop relationships with each entity from the positive sample set, and obtain entity-centered local graphs of different levels; The entities and relations in the local graphs at different levels are encoded by the RoBERTa-Large model respectively, and the encoded graph structure corresponding to each entity is stored according to the entity index; The encoded graph structure corresponding to each entity is input into the graph neural network GNN network. The GNN network aggregates the information of the entity neighbors and generates the local graph encoding corresponding to each entity. The local graph encoding corresponding to the head and tail entities in a triple is used as a prefix to form a sequence with the triple and the question instruction; The sequence is input into the Llama3 model, the Llama3 model performs format conversion on the sequence, and the sequence after format conversion is input into the LoRA fine-tuning large model, the LoRA fine-tuning large model adds a low-rank matrix to the weight matrix, and outputs a correct or incorrect judgment result of the triplet.

2. The method according to claim 1, characterized in that The method uses multiple triplets constituting the knowledge graph as a positive sample set, each triplet includes a head entity, a relationship and a tail entity, and an entity set is composed of all entities in the knowledge graph. Entities are extracted from the entity set, and the head entity or the tail entity of each triplet in the positive sample set is randomly replaced to form an equal amount of negative samples, including: Setting up the Knowledge Graph where ε is the entity set, is a relation set, T = {(h, r, t)} is a triple set, where h, t∈ε represent the head entity and the tail entity respectively. is the relationship between the head entity h and the tail entity t, and T is taken as the positive sample set; Randomly extract h′ (h′≠h) or t′ (t′≠t) from ε, and replace the head and tail entities of the triplet with the extracted h′ or t′ to form a negative sample set T′ = {(h′, r, t) | (h, r, t′)} with the same number as the positive sample set T.

3. The method according to claim 2, characterized in that The obtaining of the definitions and descriptions of the head entity, the tail entity, and the relationship in the triple, and concatenating the definitions and descriptions to obtain the question instructions for triple classification include: Read the definition of the head entity h in the triple Triples(h, r, t) Definition of relation r Definition of tail entity t Description information of the header entity h and description information of the tail entity t With the command T for asking questions q Concatenate together to form the input text T x : Text T x as question-answering instructions for triple classification.

4. The method according to claim 3, characterized in that The method of obtaining triples having direct, two-hop, and three-hop relationships with each entity from the positive sample set to obtain entity-centered local graphs of different levels includes: Get all entities in the positive sample set T = {(h, r, t)}, get the triples with direct, two-hop, and three-hop relationships with each entity, and the first-level local graph G of each entity 1 It is composed of triples that have a direct relationship with the target entity. The local graph G at the second level 2 The third level local graph G is based on the first level and adds a two-hop subgraph related to the target entity. 3 On the basis of the second level, a three-hop subgraph related to the target entity is added, and so on, to form local graphs G of different levels centered on the entity. n (n=1, 2, 3).

5. The method according to claim 4, characterized in that The entities and relations in the local graphs at different levels are encoded by the RoBERTa-Large model respectively, and the encoded graph structure corresponding to each encoded entity is stored according to the entity index, including: The local graphs G at different levels centered on the entity n Input into the RoBERTa-Large model, and use the RoBERTa-Large model to perform multi-hop subgraph G n Each entity and relationship in the graph is feature extracted and numbered to obtain a graph structure. m is the number of entities; Create a graph structure with all 0s When encountering an entity that has not appeared before during training or testing, Graph structure, the encoded graph structure corresponding to each encoded entity is stored according to the entity index.

6. The method according to claim 5, characterized in that The encoded graph structure corresponding to each entity is input into the graph neural network GNN network, and the GNN network aggregates the information of the entity neighbors to generate the local graph encoding corresponding to each entity, including: Find the corresponding graph structure according to the index of the head entity and the tail entity, input the graph structure into the GNN network, and the GNN network uses the graph encoder to encode the graph structure and generate the local graph code corresponding to each entity POOL represents the average pooling operation, and MLP represents two-layer full connection.

7. The method according to claim 6, characterized in that The method of using the local graph code corresponding to the head and tail entities in a triple as a prefix, and forming a sequence with the triple and the question instruction includes: Encode the local graph corresponding to the head and tail entities in a triple splicing as a prefix, and taking the text T corresponding to the triple as the question instruction x Vectorized processing is performed to obtain The prefix and the vectorized text Merge to get the input sequence x; 8. The method according to claim 7, characterized in that The step of inputting the sequence into the Llama3 model, converting the format of the sequence into the LoRA fine-tuning large model, and inputting the sequence after the format conversion into the LoRA fine-tuning large model, wherein the LoRA fine-tuning large model adds a low-rank matrix to the weight matrix and outputs a correct or incorrect judgment result of the triple, including: Encode the graph in the sequence x Acting as a soft hint, the sequence x in T x As a condition of the classification instruction, the sequence x is input into the Llama3 model, the Llama3 model performs format conversion on the sequence, and the format-converted sequence is input into the LoRA fine-tuning large model, and the LoRA fine-tuning large model generates the answer Y of the triple. The generation process of the answer Y is expressed as follows: φ0 represents the parameters of the frozen Llama3 model, φ1 is the prompt parameter that can be used for training, Δφ(Θ) is an incremental parameter specific to the downstream task, encoded with Θ with fewer parameters (|φ|<<|Θ|), and the LoRA fine-tuning large model adapts the pre-trained language model to specific tasks by adding a low-rank matrix to the weight matrix; the output is the judgment result Y of whether the triple is correct or wrong. If Y is yes, the triple is judged to be correct; if Y is no, the triple is judged to be wrong.

Citation Information

Patent Citations

  • Knowledge inference method based on knowledge embedding and association relationship combination

    CN115796283A

  • Graph data privacy protection method and system based on edge disturbance

    CN115906163A

  • Open knowledge graph completion method and device based on pre-training language model prompt fine tuning

    CN117892807A

  • Knowledge-graph extrapolating method and system based on multi-layer perception

    US20240086731A1

  • Method and apparatus for sorting question-answer relationships, and computer device and storage medium

    WO2020258487A1

Cited By

  • Question processing method and related device

    CN121436178A

  • Remote sensing ground object knowledge graph construction method based on cooperation of geographic object geometric features and graph enhancement retrieval

    CN121638430A

  • Remote sensing feature knowledge graph construction method based on cooperation of geographical object geometric features and graph enhanced retrieval

    CN121638430B