A knowledge graph completion method based on large language models and graph neural networks
By combining large language models and graph neural networks, a local graph of multi-hop relationships is constructed and encoded for judgment, which solves the shortcomings of existing knowledge graph completion methods in complex relationship inference and achieves a more efficient knowledge graph completion effect.
Patent Information
- Application Number
- CN202510068910.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2045-01-16
AI Technical Summary
Existing knowledge graph completion methods based on large language models have shortcomings in utilizing the structural information of knowledge graphs and fail to fully leverage their reasoning potential, especially when inferring complex relationships, where they are inefficient.
We employ a method based on large language models and graph neural networks. By constructing positive and negative sample sets, we obtain a local graph of multi-hop relationships. We encode entity information using the RoBERTa-Large model, aggregate neighbor information using a GNN network, and perform triplet judgment using Llama3 and LoRA fine-tuning models to output the correct or incorrect result.
It improves the performance of knowledge graph completion, enhances the accuracy and completeness of entity relationship reasoning, strengthens the perception of graph structure, and reduces resource overhead.
Smart Images

Figure CN120144775B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer application technology, and in particular to a knowledge graph completion method based on a large language model and graph neural network. Background Technology
[0002] Knowledge graphs represent factual knowledge in the form of triples (head entity, relation, tail entity), which together form a graph. However, information can be incomplete or erroneous, often resulting in knowledge graphs containing many missing facts. Knowledge Graph Completion (KGC) tasks expand and improve knowledge graphs by identifying potentially missing entities or relations based on existing triple information. Large Language Models (LLMs), leveraging their powerful natural language processing and reasoning capabilities, better understand the semantics of entities and relations and predict missing triples, playing a crucial role in the field of knowledge graph completion.
[0003] Knowledge graph completion tasks often require inferring complex relationships between entities, especially relationship reasoning along multi-hop paths. Currently, existing LLM-based KGC research still has limitations, failing to fully utilize the structural information in knowledge graphs and thus not fully realizing their reasoning potential. Summary of the Invention
[0004] This invention provides a knowledge graph completion method based on a large language model and graph neural network to effectively complete knowledge graphs.
[0005] To achieve the above objectives, the present invention adopts the following technical solution.
[0006] A knowledge graph completion method based on a large language model and graph neural network includes:
[0007] Multiple triples constituting the knowledge graph are used as positive sample sets. Each triple includes a head entity, a relation, and a tail entity. The entity set is composed of all entities in the knowledge graph. Entities are extracted from the entity set and randomly replaced with the head or tail entity of each triple in the positive sample set to form an equal number of negative samples.
[0008] Obtain the definitions and descriptions of the head entity, tail entity, and relation in the triple, and concatenate the definitions and descriptions to obtain the question instructions for triple classification;
[0009] From the positive sample set, triples with direct, two-hop, and three-hop relationships with each entity are obtained to obtain local graphs at different levels centered on the entities.
[0010] Entities and relationships in local graphs at different levels are encoded using the RoBERTa-Large model, and the encoded graph structure corresponding to each entity is stored according to the entity index.
[0011] The encoded graph structure corresponding to each entity is input into the graph neural network (GNN). The GNN network aggregates the information of the entity's neighbors and generates the local graph encoding corresponding to each entity.
[0012] Use the local graph encoding corresponding to the head and tail entities in a triple as a prefix, and combine it with the problem instructions of the triple to form a sequence;
[0013] The sequence is input into the Llama3 model, which performs format conversion on the sequence. The converted sequence is then input into the LoRA fine-tuning model, which adds a low-rank matrix to the weight matrix and outputs the correct or incorrect judgment result of the triple.
[0014] Preferably, the step of using multiple triples constituting the knowledge graph as a positive sample set, where each triple includes a head entity, a relation, and a tail entity, and an entity set is composed of all entities in the knowledge graph, and entities are extracted from the entity set to randomly replace the head or tail entity of each triple in the positive sample set to form an equal number of negative samples, includes:
[0015] Set up a knowledge graph Where ε is the entity set. Let T = {(h, r, t)} be a set of relations, where T = {(h, r, t)} is a set of triples, and h, t ∈ ε represent the head entity and the tail entity, respectively. It is the relationship between the head entity h and the tail entity t, with T as the positive sample set;
[0016] Randomly select h′ (h′≠h) or t′ (t′≠t) from ε, and replace the first and last entities of the triple with the selected h′ or t′ to form a negative sample set T′={(h′,er,t)|(h,r,t′)} that is equal in size to the positive sample set T.
[0017] Preferably, the step of obtaining the definitions and descriptions of the head entity, tail entity, and relation in the triple, and concatenating the definitions and descriptions to obtain the problem instruction for triple classification, includes:
[0018] Read the definition of the head entity h in the triples Triples(h,r,t) Definition of relation r Definition of tail entity t Description information of the head entity h Description information of entity t With the instruction T used to ask questions qTogether they form the input text T x :
[0019]
[0020] Text T x As a question-and-answer instruction used for triple classification.
[0021] Preferably, the step of 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 entities includes:
[0022] Retrieve all entities in the positive sample set T = {(h,r,t)}, and obtain the triples with direct, two-hop, and three-hop relationships to each entity. Also, obtain the first-level local graph G for each entity. 1 It consists of triples directly related to the target entity, and is the second-level local graph G. 2 It adds a two-hop subgraph related to the target entity to the first level, and the third level is the local graph G. 3 Based on the second level, add a three-hop subgraph related to the target entity, and so on, to form local graphs G at different levels centered on the entity. n (n = 1, 2, 3).
[0023] Preferably, the step of encoding entities and relations in local graphs at different levels using the RoBERTa-Large model, and storing the encoded graph structure corresponding to each entity according to the entity index, includes:
[0024] Local graphs G at different levels centered on entities n The input is fed into the RoBERTa-Large model, and the multi-hop subgraph G is processed by the RoBERTa-Large model. n Each entity and relation in the graph is feature-extracted and numbered to obtain the graph structure. m is the number of entities;
[0025] Create a graph structure consisting entirely of zeros. When encountering entities that have not appeared before during training or testing, then... The graph structure stores the encoded graph structure corresponding to each entity according to the entity index.
[0026] Preferably, the step of inputting the encoded graph structure corresponding to each entity into a graph neural network (GNN), whereby the GNN aggregates information about the entity's neighbors to generate a local graph encoding for each entity, includes:
[0027] The corresponding graph structure is found based on the indices of the head and tail entities. This graph structure is then input into the GNN network, which uses a graph encoder to encode the graph structure, generating a local graph code for each entity.
[0028]
[0029] POOL represents average pooling operation, and MLP represents two fully connected layers.
[0030] Preferably, the step of using the local graph encoding corresponding to the head and tail entities in a triple as a prefix, and forming a sequence with the problem instruction of the triple, includes:
[0031] Encode the local graph corresponding to the head and tail entities in a triplet. The concatenation is used as a prefix to connect the text T corresponding to the triple as the question instruction. x Vectorization process to obtain The prefix and vectorized text are then... The input sequence x is obtained by merging the sequences.
[0032]
[0033] Preferably, the sequence 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 model. The LoRA fine-tuning model adds a low-rank matrix to the weight matrix and outputs the correct or incorrect judgment result of the triples, including:
[0034] Encode the graph in sequence x Acting as a soft cue, T in sequence x x As a condition for the classification instruction, the sequence x is input into the Llama3 model, which performs format conversion on the sequence. The converted sequence is then input into the LoRA fine-tuning model, which generates the answer Y for the triple. The generation process of answer Y is as follows:
[0035]
[0036] φ0 represents the parameters of the frozen Llama3 model, φ1 is the cue parameters that can be used for training, and Δφ(Θ) is the incremental parameter specific to the downstream task, encoded with Θ (|φ|<<|Θ|). LoRA fine-tunes large models by adding low-rank matrices to the weight matrix to adapt the pre-trained language model to specific tasks; it outputs the judgment result Y of whether the triplet is correct or incorrect. If Y is yes, the triplet is judged to be correct; if Y is no, the triplet is judged to be incorrect.
[0037] As can be seen from the technical solutions provided by the embodiments of the present invention above, the present invention utilizes the powerful context awareness capability of large language models to understand the characteristics of complex sentence structures and contexts, and combines them with aggregated node structure information to generate more expressive embedded representations, thereby improving the performance of knowledge graph completion.
[0038] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and will become apparent from the description or may be learned by practice of the invention. Attached Figure Description
[0039] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a flowchart illustrating a knowledge graph completion method based on a large language model and graph neural network, provided in an embodiment of the present invention. Detailed Implementation
[0041] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0042] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this specification means the presence of the stated 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 groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or couplings. The term “and / or” as used herein includes any and all combinations of one or more of the associated listed items.
[0043] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless defined as herein.
[0044] To facilitate understanding of the embodiments of the present invention, the following will provide further explanation and description with reference to the accompanying drawings and several specific embodiments. These embodiments do not constitute a limitation on the embodiments of the present invention.
[0045] This invention first utilizes the bidirectional encoding capability of the RoBERTa-Large model to comprehensively capture the deep semantic relationships of entities in the local graph. Then, leveraging the reasoning capabilities of GNNs (Graph Neural Networks), it can analyze multi-hop paths in the knowledge graph and find potential connections between head and tail entities. Combined with the linguistic information processing capabilities of LLMs, the model can not only predict 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 graph neural network provided by this invention is as follows: Figure 1 As shown, the processing steps include the following:
[0047] Step S1: The knowledge graph consists of multiple triples (head entity, relation, tail entity), which is called the positive sample set; the entity set consists of all entities in the knowledge graph. Entities are extracted from the entity set, and the head entity or 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 concatenate the definitions and descriptions to obtain the question instructions for triple classification.
[0049] Step S3: Obtain triples from the positive sample set that have direct, two-hop, and three-hop relationships with each entity. A two-hop relationship is a node reached through one intermediate node, and a three-hop relationship is a node reached through two intermediate nodes.
[0050] Step S4: Obtain local graphs at different levels centered on entities from S3. At the same time, for entities that do not appear, construct a graph structure with all edge relationships set to 0, so that each entity has a corresponding graph structure.
[0051] Step S5: The entities and relations of the local graphs at different levels are encoded using the RoBERTa-Large model, and the encoded graph structures corresponding to the entities are stored according to the entity index.
[0052] Step S6: Input the encoded graph structure corresponding to each entity into the GNN network. The GNN network aggregates the information of the entity's neighbors to better represent and reason about complex multi-relationship graphs and generate the local graph encoding corresponding to each entity.
[0053] Step S7: For a triple, use the local graph encoding related to the head and tail entities obtained in S6 as a prefix, and combine it with the question instruction of the triple to form a sequence. 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-tuning large model by loading a pre-trained text processing model.
[0054] Step S8: Input the format-converted sequence into the LoRA (Low-Rank Adaptation of Large Language Models) fine-tuning method for large language models. LoRA fine-tuning adds a low-rank matrix to the weight matrix of the large model without changing the original pre-trained parameters. During training, only a small number of parameters in the low-rank matrix need to be updated. The LoRA fine-tuning model outputs the answer (yes or no) to the question instruction in the above sequence, records the result, and calculates the evaluation metrics precision and F1 score. The F1 score is calculated using precision and recall.
[0055]
[0056] Precision represents the ratio of positive samples predicted by the model to those that are actually positive, while Recall represents the percentage of truly positive samples that were successfully identified as positive by the model.
[0057] Furthermore, in step S1 Where ε is the entity set. It is a relation set, and T = {(h,r,t)} is a triple, where h,t∈ε are the head and tail entities. It's about the relationship between them. Randomly replace the first and last entities of the triples, and extract h′ (h′≠) from ε.
[0058] h) or t′(t′≠t), forming the negative sample set T′={(h′,r,t)|(h,r,t′)}
[0059] Furthermore, step S2 reads the definitions of entities and relations in the triple (h,r,t). And descriptive information about the entity With the instruction T used to ask questions q Together they form the input text:
[0060]
[0061] Text T x This provides question-and-answer instructions for triple classification, serving as a cue for training the Llama3 model.
[0062] Furthermore, the implementation process of step S3 is as follows:
[0063] Local graphs are constructed based on the multi-hop relationships of entities, with each level of local graph being an overlay of the previous level. We obtain all entities in the positive sample T = {(h,r,t)} and construct local graphs at different levels for each entity. The first-level local graph G... 1 It consists of triples that are directly related to the target entity. The second-level local graph G 2 It adds a two-hop subgraph related to the target entity on top of the first level. The third level local graph G... 3 Based on the second level, add a three-hop subgraph related to the target entity. Continue in this manner to construct local graphs G at different levels centered on the target entity. n (n = 1, 2, 3).
[0064] For example, for the triples ('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. Some information is listed below:
[0065] Table 1. Analysis of Examples of Partial Views
[0066]
[0067]
[0068] Furthermore, the objective of step S4 is to rank the local graphs G at different levels according to the entity set order. n Number them.
[0069] The multi-hop graph G is analyzed using the RoBERTa-Large model. n Feature extraction is performed on each entity and relation in the dataset, and they are then numbered to obtain... m is the number of entities. Also, create a graph structure consisting entirely of zeros. When encountering entities that have not appeared before during training or testing, then... The graph structure saves the encoded local graph.
[0070] Furthermore, in step S5, the corresponding local graph is found based on the index of the head and tail entities, and the structure of the two local graphs is encoded using a graph encoder to obtain... The definition is as follows:
[0071]
[0072] POOL represents average pooling operation, and MLP represents two fully connected layers.
[0073] Furthermore, in step S6, the local graph encoding corresponding to the head and tail entities in a triple is performed. The concatenation is used as a prefix to connect the text T corresponding to the triple as the question instruction. x Perform vectorization to obtain The prefix and vectorized text are then... The input sequence x is obtained by merging the sequences.
[0074]
[0075] Furthermore, in the final stage of step S7, the graph is encoded. Act as a soft prompt and T xThe answer Y is generated under the conditions of the classification instruction, and these inputs are fed into the frozen Llama3 model. The generation process is represented as follows:
[0076]
[0077] φ0 represents the parameters of the frozen Llama3 model, and φ1 represents the cue parameters available for training. To efficiently and quickly fine-tune the Llama3 model, LoRA is introduced to fine-tune the large model. Δφ(Θ) is a downstream task-specific incremental parameter, encoded using Θ with fewer parameters (|φ| << |Θ|). LoRA adapts the pre-trained language model to a specific task by adding a low-rank matrix to the weight matrix.
[0078] The converted sequence x is input into the LoRA fine-tuning model, and the output is the result Y of judging the triples. If the output is yes, the triple is considered correct. Through the triple classification task, the knowledge graph is made more complete.
[0079] The judgment result is saved, and the output result is extracted using a regular expression. The accuracy and F1 score are then calculated. Finally, step S9 saves the judgment result, extracts the output result using a regular expression, and calculates the accuracy.
[0080] In summary, this invention first obtains the triples formed by each entity and its neighboring nodes from the positive sample set and merges them with the multi-hop subgraph of that entity. These subgraphs are then encoded using a word embedding model to obtain the entity's local graph features, which are then input into a GNN. The triples from the positive and negative samples, along with their corresponding descriptive information, are concatenated and encoded, and then concatenated with the structural information of the graph obtained above. This is then input into a large language model for training and inference to obtain the judgment result.
[0081] The method of this invention was tested on three real-world partial datasets: FB15K237-N, Wiki27K, and WN188RR. Accuracy (Accuracy) and F1 (F-Measure) were used to evaluate the prediction results. The prediction results based on the three datasets are shown in Table 1. The experimental results show that...
[0082] Regarding ACC performance, the method of this invention improved the performance of the three test data sets by 4.7%, 1%, and 3.5%, respectively. Regarding F1 performance, the method of this invention improved the performance of the three test data sets by 11%, 6.1%, and 3.3%, respectively.
[0083] Table 1. Evaluation metrics results based on three datasets.
[0084]
[0085] In summary, the embodiments of the present invention fully utilize the semantic understanding of LLM and the graph reasoning capabilities of GNN to enhance the perception of graph structures, improve reasoning ability, reduce resource overhead, and effectively address generalization and update issues.
[0086] Knowledge graphs have wide applications in fields such as recommender systems, natural language processing, and medicine. Knowledge graph completion tasks improve the completeness and accuracy of overall information by filling in missing entities and relationships in the graph, thus providing better support for model reasoning and decision-making.
[0087] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of one embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing the present invention.
[0088] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of the present invention, 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 to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of the present invention.
[0089] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for apparatus or system embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. The apparatus and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0090] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A knowledge graph completion method based on a large language model and graph neural networks, characterized in that, include: Multiple triples constituting the knowledge graph are used as positive sample sets. Each triple includes a head entity, a relation, and a tail entity. The entity set is composed of all entities in the knowledge graph. Entities are extracted from the entity set and randomly replaced with the head or tail entity of each triple in the positive sample set to form an equal number of negative samples. Obtain the definitions and descriptions of the head entity, tail entity, and relation in the triples; concatenate the definitions and descriptions to obtain the problem instructions for triple classification; including: Read the definition of the head entity h in the triples Triples(h,r,t) Definition of relation r Definition of tail entity t Description information of the head entity h Description information of entity t With the instruction T used to ask questions q Together they form the input text T x : Text T x As a problem instruction used for triple classification; From the positive sample set, triples with direct, two-hop, and three-hop relationships with each entity are obtained to obtain local graphs at different levels centered on the entities. Entities and relationships in local graphs at different levels are encoded using the RoBERTa-Large model, 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). The GNN network aggregates the information of the entity's 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, and a sequence is formed with the problem instructions for the triple, including: encoding the local graphs corresponding to the head and tail entities in a triple. The concatenation is used as a prefix to connect the text T corresponding to the triple as the question instruction. x Vectorization process is performed to obtain The prefix and vectorized text are then... The input sequence x is obtained by merging the sequences. The sequence is input into the Llama3 model, and the graph in the sequence x is encoded. Acting as a soft cue, T in sequence x x As a condition for the classification instruction, the Llama3 model performs a format conversion on the sequence and inputs the format-converted sequence into the LoRA fine-tuning model. The LoRA fine-tuning model adds a low-rank matrix to the weight matrix and outputs the correct or incorrect judgment result of the triple.
2. The method according to claim 1, characterized in that, The method involves using multiple triples constituting the knowledge graph as a positive sample set. Each triple includes a head entity, a relation, and a tail entity. An entity set is composed of all entities in the knowledge graph. Entities are extracted from this entity set and randomly replaced with the head or tail entity of each triple in the positive sample set to form an equal number of negative samples. This includes: Set up a knowledge graph Where ε is the entity set. Let T = {(h, r, t)} be a set of relations, where T = {(h, r, t)} is a set of triples, and h, t ∈ ε represent the head entity and the tail entity, respectively. It is the relationship between the head entity h and the tail entity t, with T as the positive sample set; Randomly select h from ε ′ (h ′ ≠h) or t ′ (t ′ ≠t), using the extracted h ′ or t ′ Replace the first and last entities of the triples to form a negative sample set T′={(h′,r,t)|(h,r,t′)} that is equal in size to the positive sample set T.
3. The method according to claim 1, characterized in that, The process of 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 entities includes: Retrieve all entities in the positive sample set T = {(h,r,t)}, and obtain the triples with direct, two-hop, and three-hop relationships to each entity. Also, obtain the first-level local graph G for each entity. 1 It consists of triples directly related to the target entity, and is the second-level local graph G. 2 It adds a two-hop subgraph related to the target entity to the first level, and the third level is the local graph G. 3 Based on the second level, add a three-hop subgraph related to the target entity, and so on, to form local graphs G at different levels centered on the entity. n (n = 1, 2, 3).
4. The method according to claim 3, characterized in that, The process of encoding entities and relations in local graphs at different levels using the RoBERTa-Large model, and storing the encoded graph structure corresponding to each entity according to the entity index, includes: Local graphs G at different levels centered on entities n The input is fed into the RoBERTa-Large model, and the multi-hop subgraph G is processed by the RoBERTa-Large model. n Each entity and relation in the graph is feature-extracted and numbered to obtain the graph structure. m is the number of entities; Create a graph structure consisting entirely of zeros. When encountering entities that have not appeared before during training or testing, then... The graph structure stores the encoded graph structure corresponding to each entity according to the entity index.
5. The method according to claim 4, characterized in that, The process of inputting the encoded graph structure corresponding to each entity into a graph neural network (GNN), whereby the GNN aggregates information about the entity's neighbors to generate a local graph encoding for each entity, includes: The corresponding graph structure is found based on the indices of the head and tail entities. This graph structure is then input into the GNN network, which uses a graph encoder to encode the graph structure, generating a local graph code for each entity. POOL represents average pooling operation, and MLP represents two fully connected layers.
6. The method according to claim 1, characterized in that, The sequence is input into the Llama3 model, which performs format conversion on the sequence. The converted sequence is then input into the LoRA fine-tuning model, which adds a low-rank matrix to the weight matrix and outputs the correct or incorrect judgment result of the triplet, including: The sequence x is input into the Llama3 model, which performs format conversion on the sequence. The converted sequence is then input into the LoRA fine-tuning model, which generates the answer Y for the triple. The generation process of answer Y is as follows: φ0 represents the parameters of the frozen Llama3 model, φ1 is the cue parameters that can be used for training, and Δφ(Θ) is the incremental parameter specific to the downstream task, encoded with Θ which has fewer parameters. LoRA fine-tunes large models by adding low-rank matrices to the weight matrix to adapt the pre-trained language model to specific tasks; it outputs the judgment result Y of whether the triplet is correct or incorrect. If Y is yes, the triplet is judged to be correct; if Y is no, the triplet is judged to be incorrect.
Citation Information
Patent Citations
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