A knowledge graph relationship prediction method, device, equipment and storage medium

By constructing candidate triplet sets in sparse knowledge graphs and calculating instance equivalence scores using large language model and BERT model, the problem of low relationship prediction accuracy in sparse knowledge graphs is solved, and higher prediction accuracy and Evidence-based support strength.

CN119025685BActive Publication Date: 2025-02-11HUAQIAO UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411479256.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-11
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

The prior art has low accuracy in relation prediction in sparse knowledge graphs, making it difficult to effectively deal with complex relationships and long-tail entities.

Method used

By obtaining sparse knowledge graphs and preset prompt templates, a candidate triplet set is constructed, and a triplet evidence-based text set is generated using a large language model to calculate the relationship support of candidate triplets. Then, the embedding vector and relational support of the BERT model are combined, the instance equivalence score of the candidate triplet is calculated, and the candidate triplet that reaches the preset threshold is selected as the predicted triplet.

Benefits of technology

It improves the accuracy of relation prediction in sparse knowledge graph, enhances the evidence-based support for prediction results, is highly adaptable, and can surpass existing models in terms of relation prediction accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025685B_ABST
    Figure CN119025685B_ABST
Patent Text Reader

Abstract

The present invention provides a knowledge graph relationship prediction method, device, equipment and storage medium, which relates to the technical field of knowledge graph relationship prediction. The present invention constructs candidate triples from sparse knowledge graphs, obtains a triple evidence-based text set according to a preset prompt template, calculates the relationship support of candidate triples using a large language model combination decision method, then fuses the relationship support and BERT model vector embedding to obtain the instance equivalence vectors of all candidate triples of the knowledge graph, that is, the candidate triple vector and the true standardized vector, then calculates the instance equivalence score of the candidate triple and the fact triple based on the Euclidean distance, and finally, selects the candidate triples exceeding the threshold as the predicted triples according to the instance equivalence score to realize the knowledge graph relationship prediction. The present invention improves the prediction accuracy of knowledge graph relationships, enhances the evidence-based support strength of the prediction results, and performs well in adapting to sparse knowledge graphs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of knowledge graph relationship prediction technology, and specifically, to a knowledge graph relationship prediction method, device, equipment and storage medium. Background Art

[0002] As the application of knowledge graphs continues to expand in various fields, relationship prediction, as a key task of knowledge graphs, has received more and more attention. Knowledge graphs represent knowledge by describing entities and the relationships between entities, and are widely used in search engines, recommendation systems, and intelligent question-answering systems.

[0003] However, knowledge graphs face the problem of data sparsity during construction and application, that is, the relationship information between many entities is incomplete, which limits the reasoning and application effects. Existing relationship prediction methods include path-based prediction methods, representation learning-based methods, and rule-based reasoning methods. Path-based methods use path information in the graph for reasoning, but their effects are limited in sparse graphs; representation learning-based methods express the structure and semantic information of the graph by embedding entities and relationships into low-dimensional vector spaces, but they perform poorly when dealing with complex relationships and long-tail entities; rule-based reasoning methods rely on the completeness of rules and the quality of knowledge graphs, and are difficult to expand and adapt to dynamically changing knowledge. Although deep neural network methods have made significant progress in relationship prediction in recent years, most of these methods rely on a large amount of labeled data, and the effects on sparse knowledge graphs are still not ideal.

[0004] In view of this, the applicant filed this application after studying the existing technology. Summary of the invention

[0005] The present invention aims to provide a knowledge graph relationship prediction method, apparatus, device and storage medium that integrate instance equivalence and relationship support, so as to solve the shortcoming of low accuracy of relationship prediction in sparse knowledge graphs in existing methods.

[0006] In order to solve the above technical problems, the present invention is implemented through the following technical solutions:

[0007] A knowledge graph relationship prediction method, comprising:

[0008] S1, obtaining a sparse knowledge graph and a preset prompt template, constructing a candidate triple set consisting of a head entity, a relationship, and a tail entity according to the knowledge graph, and inputting the candidate triple set into several large language models in turn according to the prompt template to generate a triple evidence-based text set;

[0009] S2, according to the triple-based text set, calculating the relation support for each candidate triple of the candidate triple set in turn;

[0010] S3, according to each candidate triple, find all fact triples with the same relationship and tail entity from the knowledge graph to obtain a fact triple set; and accumulate and average the fact triple set combined with the output of the BERT model to obtain the true standardized vector of the corresponding candidate triple;

[0011] S4, integrating the relation support and the BERT model to obtain the candidate triple vectors corresponding to the candidate triple set, and traversing and calculating the inverse of the Euclidean distance between each candidate triple vector and its corresponding true standardized vector to obtain an instance equivalence score;

[0012] S5, according to the instance equivalence score, the candidate triples in the candidate triple set that reach the preset threshold are screened out as the predicted triple set, and a knowledge graph relationship prediction model based on the fusion of instance equivalence and relationship support is obtained to realize knowledge graph relationship prediction.

[0013] Preferably, the knowledge graph includes a head entity, a head entity type, a relationship, a tail entity set and a tail entity type, and S1 is specifically:

[0014] S11, assuming the head entity is , the header entity type is , the relationship is , the tail entity set is , the tail entity type is ;in, is the size of the tail entity set, is the nth tail entity;

[0015] Construct candidate triple sets using a fully combined approach ;

[0016] S12, assuming that the prompt template is a description of rule processing including the head entity, the head entity type, the tail entity type and the candidate triple set;

[0017] The candidate triple set is combined with the prompt template and input into several large language models to obtain a triple evidence-based text set, which is expressed as:

[0018] ;

[0019] in, Represents the header entity The evidence-based text of the triplet obtained through one of the large language models, Represents a large language model.

[0020] Preferably, S2 is specifically:

[0021] S21, according to the triple-based evidence-based text set, obtaining the ranking number of each candidate triple in the candidate triple set in the triple-based evidence-based text set, that is, the ranking weight;

[0022] S22, all ranking weights of the current candidate triples are accumulated and summed to obtain the single relation support of the current candidate triples, which is expressed as:

[0023] ;

[0024] in, Represents a candidate triple The relationship support, Represents a candidate triple Triple evidence-based texts in the Triple Evidence-Based Text Set The sorting weight in The triple-based evidence-based text sets obtained for different large language models; .

[0025] Preferably, the rule processing in the prompt template includes: arranging the candidate triple sets in descending order according to confidence, and S3 is specifically:

[0026] S31, based on the candidate triples , find all the fact triples with the same relationship and tail entity from the knowledge graph ,in represents the size of the set of triples of the fact;

[0027] According to the fact triple set , use the pre-trained language representation model BERT to get the vector of each fact triple:

[0028] ;

[0029] in, It is a fact triple The vector of , represents the matrix coefficients used to fine-tune the vector, represents the embedding vector obtained by the BERT model, represents the vector concatenation operation, To perform dimensionality reduction operations; represents the i-th head entity; Represents a candidate triple the relationship between Represents a candidate triple The tail entity in;

[0030] S32, accumulate the vectors of all fact triples element by element, and then average them to obtain the true standardized vector of the candidate triple:

[0031] ;

[0032] in, is the true normalized vector, Add the sign of a vector element by element; Indicates the size of the fact triple; Represents the mth fact triple.

[0033] Preferably, S4 is specifically:

[0034] S41, combining the relationship support and the embedding vector function of the BERT model to obtain the vector of the candidate triple:

[0035] ;

[0036] in, Represents a candidate triple The candidate triple vector of , represents the matrix coefficients used to fine-tune the vector, is a candidate triple Relationship support;

[0037] S42, using the Euclidean distance to calculate the distance between the candidate triplet vector and the true standard vector corresponding to the candidate triplet, and taking the reciprocal as the confidence score of the corresponding candidate triplet, the formula is:

[0038] ;

[0039] in, represents the confidence score of the candidate triple c, Represents the dimension of the vector; Represents the candidate triple vector The kth value in ; Represents the true normalized vector The kth value in ;

[0040] S43, traverse and calculate the confidence score of each candidate triple in the candidate triple set C, so as to obtain the instance equivalence score of each candidate triple. The expression of the instance equivalence score is:

[0041] ;

[0042] in, Represents a candidate triple The instance equivalence score of ,| | represents the cardinality of a set; Represents a normalization constant, which is used to adjust the scale of the score to eliminate the impact caused by the different sizes of candidate triple sets and make the scores comparable under different set sizes.

[0043] Preferably, S5 is specifically as follows: when the instance equivalence score of the candidate triplet reaches a preset threshold, the corresponding candidate triplet is stored in the predicted triplet set In the expression:

[0044] ;

[0045] in, is the preset threshold.

[0046] Preferably, it also includes:

[0047] S6, using the stochastic gradient descent method to iteratively train and optimize the knowledge graph relationship prediction model, and performing cross entropy calculation on the predicted triple set and the real triple set in the test data. The cross entropy calculation formula is:

[0048] ;

[0049] in, To predict triples; is the true label, the value is 0 or 1; To predict triples Instance equivalence score of .

[0050] The present invention also provides a knowledge graph relationship prediction device, comprising:

[0051] An input module is used to obtain a sparse knowledge graph and a preset prompt template, obtain a sparse knowledge graph and a preset prompt template, construct a candidate triple set consisting of a head entity, a relationship, and a tail entity according to the knowledge graph, and input the candidate triple set into several large language models in sequence according to the prompt template to generate a triple evidence-based text set;

[0052] A relation support module, for calculating the relation support for each candidate triple of the candidate triple set in turn according to the triple-based text set;

[0053] A true normalized vector module is used to obtain a true normalized vector. According to each candidate triple, all fact triples with the same relationship and tail entity are found from the knowledge graph to obtain a fact triple set; and the fact triple set is combined with the output of the BERT model to accumulate and average to obtain the true normalized vector of the corresponding candidate triple.

[0054] An instance equivalence module is used to obtain an instance equivalence score, integrate the relation support and the BERT model, obtain the candidate triple vectors corresponding to the candidate triple set, and traverse and calculate the inverse of the Euclidean distance between each candidate triple vector and its corresponding true normalized vector to obtain an instance equivalence score;

[0055] The prediction module is used to obtain a predicted triple set. According to the instance equivalence score, the candidate triples that reach a preset threshold in the candidate triple set are screened out as the predicted triple set, and a knowledge graph relationship prediction model based on the fusion of instance equivalence and relationship support is obtained to realize knowledge graph relationship prediction.

[0056] The present invention also provides a knowledge graph relationship prediction device, including a processor and a memory, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a knowledge graph relationship prediction method as described above.

[0057] The present invention also provides a computer-readable storage medium, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a device where the computer-readable storage medium is located, a knowledge graph relationship prediction method as described above is implemented.

[0058] In summary, compared with the prior art, the present invention has the following beneficial effects: the present invention proposes a knowledge graph relationship prediction method that integrates instance equivalence and relationship support, and improves the accuracy of relationship prediction in sparse knowledge graphs by comprehensively utilizing the generation capability of large language models and the embedded representation of knowledge graphs. Specifically, the present invention first constructs candidate triples from sparse knowledge graphs, and calculates the relationship support of candidate triples using the large language model combined decision method; then, the relationship support and BERT model vector embedding are integrated to obtain the instance equivalence vectors (candidate triple vectors and true standardized vectors) of all candidate triples in the knowledge graph; then, the instance equivalence scores of candidate triples and fact triples are calculated based on Euclidean distance; finally, candidate triples exceeding the threshold are screened as predicted triples according to the instance equivalence scores to achieve knowledge graph relationship prediction.

[0059] Compared with the existing technology, the present invention can predict missing relationships between entities, and performs well in improving the accuracy of knowledge graph relationship prediction, enhancing the evidence-based support of prediction results, and adapting to sparse knowledge graphs, providing a technical means to surpass existing models in terms of relationship prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0061] Figure 1 A schematic diagram of a knowledge graph relationship prediction method provided in Example 1 of the present invention.

[0062] Figure 2 A schematic diagram of a knowledge graph relationship prediction device provided in Example 2 of the present invention.

[0063] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. DETAILED DESCRIPTION

[0064] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention claimed for protection, but merely represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0065] Embodiment 1

[0066] Embodiment 1 of the present invention provides a knowledge graph relationship prediction method, which can be implemented by a knowledge graph relationship prediction device (hereinafter referred to as the relationship prediction device), and in particular, executed by one or more processors in the relationship prediction device.

[0067] In this embodiment, the relationship prediction device may be an electronic device equipped with a processor, the processor having a computer program of the knowledge graph relationship prediction method and the computer program can be executed, such as a computer, a smart phone, a smart tablet, etc.

[0068] like Figure 1 As shown, a knowledge graph relationship prediction method includes steps S1 to S5.

[0069] S1, obtain a sparse knowledge graph and a preset prompt template, construct a candidate triple set consisting of a head entity, a relationship, and a tail entity according to the knowledge graph, and input the candidate triple set into several large language models in turn according to the prompt template to generate a triple evidence-based text set.

[0070] In this embodiment, the head entity "Top level"; head entity type = "Sensitive words"; relationship =Related laws and regulations;

[0071] Tail Entity Collection {Article 9 of Chapter 2 of Law A, Article 11 of Chapter 2 of Law A, ..., Article 7 of Standard A}, a total of 620 candidate tail entities;

[0072] Tail Entity Type = Legal regulations;

[0073] Construct a set of candidate triples using a fully combined approach [(highest level, related laws and regulations, Article 9 of Chapter 2 of Law A), (highest level, related laws and regulations, Article 11 of Chapter 2 of Law A), …, (highest level, related laws and regulations, Article 7 of Standard A)], a total of 620 candidate triples.

[0074] Assume that the prompt template is: "For ( )( ), there is a pair of ( ) , please sort the candidate triplets from high to low according to confidence and give a list of sorted results."

[0075] Then, the triple evidence-based text set in this embodiment is a text set obtained after being processed according to the rules of the above-mentioned prompt template and input into the large language model.

[0076] The prompt template may also be set as other processing rules, and then the relationship support is calculated in combination with the rules, which will not be described in detail here.

[0077] Then, based on the large language model prompt template, a prompt is constructed: "For (sensitive word) (superlative), there is a set of candidate triples for (related legal regulations) [(superlative, related legal regulations, Article 9 of Chapter 2 of Law A), (superlative, related legal regulations, Article 7 of Standard A), ..., (superlative, related legal regulations, Article 11 of Chapter 2 of Law A)], please sort the candidate triples from high to low according to confidence and give a list of sorted results."

[0078] Then, the prompt sentence of the large language model is input into several large language models to obtain the triple evidence-based text set generated by different large language models (as shown in Table 1). The large language model is an existing common large language model, including ChatGPT, Tongyi Qianwen, and Wenxin Yiyan.

[0079] Table 1 Examples of evidence-based texts with triples

[0080]

[0081] S2, according to the triple-based text set, calculating the relationship support for each candidate triple in the candidate triple set in turn.

[0082] According to the rules in the prompt template, after getting the header entity Based on the "highest level" triple-based text, each candidate triple in the candidate triple set is analyzed, and their ranking numbers in different triple-based texts, i.e., ranking weights, are counted. The ranking weights are accumulated and summed to obtain the single relation support for the current candidate triple.

[0083] For example, for the candidate triple (superlative, related legal regulations, Article 9 of Chapter 2 of Law A), its ranking number in the triple-based text A obtained by the ChatGPT large language model is 2, and the ranking weight is 1 / 2; the ranking number in the triple-based text B obtained by the Tongyi Qianwen large language model is 2, and the ranking weight is also 1 / 2; the ranking number in the triple-based text C obtained by the Wenxin Yiyan large language model is 3, and the ranking weight is 1 / 3. Then add up the three ranking weights to get 4 / 3, which is the relationship support of the current candidate triple.

[0084] For the current head entity The 620 “highest” candidate triples are given their relation support vectors , the vector dimension is 620, and each dimension represents the strength of evidence-based support for the corresponding candidate triple. The formula is:

[0085] ;

[0086] in, Indicates the current header entity The relation support vector of ; each dimension of the relation support vector represents the strength of evidence-based support for the corresponding candidate triple, which is one of the bases for evaluating the confidence of the candidate triple in the knowledge graph.

[0087] S3, according to each candidate triple, find all fact triplets with the same relationship and tail entity from the knowledge graph to obtain a set of fact triples; and accumulate and average the output of the fact triple set combined with the BERT model to obtain the true standardized vector of the corresponding candidate triple.

[0088] For the candidate triples (Highest level, related legal regulations, Article 9 of Chapter 2 of Law A), first find all fact triples with the same relationship and tail entity from the knowledge graph {(lowest price, related laws and regulations, Article 9 of Chapter 2 of Law A), (most efficient, related laws and regulations, Article 9 of Chapter 2 of Law A), …, (most advanced, related laws and regulations, Article 9 of Chapter 2 of Law A)}, its scale is 33.

[0089] Then, the BERT model is used to obtain the fact triple set The vector representation of the fact triple set The vector representation of is accumulated element by element and then averaged to obtain the candidate triples (Superlative level, related legal regulations, Article 9, Chapter 2 of Law A) True normalized vector .

[0090] S4, integrating the relation support and the BERT model, obtaining the candidate triple vectors corresponding to the candidate triple set, and traversing and calculating the inverse of the Euclidean distance between each candidate triple vector and its corresponding true standardized vector to obtain the instance equivalence score.

[0091] Combining the relationship support and the embedded vector representation of the BERT model, we get the candidate triples (Superlative, related legal regulations, Article 9, Chapter 2 of Law A) vector .

[0092] Using Euclidean distance, calculate the candidate triple vector The true normalization of the corresponding candidate triples The reciprocal of the distance between them is taken as the instance equivalence score of the candidate triple.

[0093] Traverse and calculate the candidate triple set The confidence scores of the 620 candidate triples in are calculated to obtain the instance equivalence score of each candidate triple.

[0094] S5, according to the instance equivalence score, the candidate triples in the candidate triple set that reach the preset threshold are screened out as the predicted triple set, and a knowledge graph relationship prediction model based on the fusion of instance equivalence and relationship support is obtained to realize knowledge graph relationship prediction.

[0095] By setting the threshold To determine the predicted triple, that is, when the instance equivalence score of the candidate triple is higher than the threshold, the candidate triple is included in the predicted triple set [(highest level, related laws and regulations, Article 11 of Chapter 2 of Law A), (highest level, related laws and regulations, Article 7 of Standard A), (highest level, related laws and regulations, Article 9 of Chapter 2 of Law A), (highest level, related laws and regulations, Article 28 of Chapter 2 of Law A), (highest level, related laws and regulations, Article 8 of Law B), (highest level, related laws and regulations, Article 20 of Law C)], the scale is 6.

[0096] In addition, it also includes: S6, using a stochastic gradient descent method to iteratively train and optimize the knowledge graph relationship prediction model, and performing cross entropy calculation on the predicted triple set and the real triple set in the test data, and the cross entropy calculation formula is:

[0097] ;

[0098] in, To predict triples; is the true label, the value is 0 or 1; To predict triples Instance equivalence score of .

[0099] The cross entropy calculation is performed on the predicted triple set (highest level, related legal regulations, Article 11 of Chapter 2 of Law A) and the real triple set in the test data.

[0100] In the prediction triple set The cross entropy training iteration target is constructed and optimized using the stochastic gradient descent method to obtain a knowledge graph relationship prediction model that integrates instance equivalence and relationship support.

[0101] In summary, compared with the prior art, the present invention has the following beneficial effects:

[0102] The present invention excels in improving the accuracy of knowledge graph relationship prediction, enhancing the evidence-based support of prediction results, and adapting to sparse knowledge graphs, providing a technical means to surpass existing models in terms of relationship prediction accuracy.

[0103] Embodiment 2

[0104] like Figure 2 As shown, the second embodiment of the present invention further provides a knowledge graph relationship prediction device, comprising:

[0105] An input module is used to obtain a sparse knowledge graph and a preset prompt template, obtain a sparse knowledge graph and a preset prompt template, construct a candidate triple set consisting of a head entity, a relationship, and a tail entity according to the knowledge graph, and input the candidate triple set into several large language models in sequence according to the prompt template to generate a triple evidence-based text set;

[0106] A relation support module, for calculating the relation support for each candidate triple of the candidate triple set in turn according to the triple-based text set;

[0107] A true normalized vector module is used to obtain a true normalized vector. According to each candidate triple, all fact triples with the same relationship and tail entity are found from the knowledge graph to obtain a fact triple set; and the fact triple set is combined with the output of the BERT model to accumulate and average to obtain the true normalized vector of the corresponding candidate triple.

[0108] An instance equivalence module is used to obtain an instance equivalence score, integrate the relation support and the BERT model, obtain the candidate triple vectors corresponding to the candidate triple set, and traverse and calculate the inverse of the Euclidean distance between each candidate triple vector and its corresponding true normalized vector to obtain an instance equivalence score;

[0109] The prediction module is used to obtain a predicted triple set. According to the instance equivalence score, the candidate triples that reach a preset threshold in the candidate triple set are screened out as the predicted triple set, and a knowledge graph relationship prediction model based on the fusion of instance equivalence and relationship support is obtained to realize knowledge graph relationship prediction.

[0110] Embodiment 3

[0111] The third embodiment of the present invention also provides a knowledge graph relationship prediction device, which includes a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement the knowledge graph relationship prediction method as described above.

[0112] Embodiment 4

[0113] The fourth embodiment of the present invention also provides a computer-readable storage medium, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a device where the computer-readable storage medium is located, the knowledge graph relationship prediction method as described above is implemented.

[0114] In several embodiments provided in the embodiments of the present invention, it should be understood that the disclosed apparatus and method can also be implemented in other ways. The apparatus and method embodiments described above are merely schematic. For example, the flowcharts in the accompanying drawings show the possible architecture, functions and operations of the apparatus, method and computer program product according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0115] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0116] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, an electronic device, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code. It should be noted that in this article, the term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or device. Without more constraints, an element defined by the phrase "comprising a..." does not exclude the existence of other identical elements in the process, method, article or apparatus comprising the element.

[0117] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0118] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0119] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0120] The "first\second" mentioned in the embodiments is only to distinguish similar objects, and does not represent a specific order for the objects. It is understandable that the "first\second" can be interchanged with the specific order or sequence where permitted. It should be understood that the objects distinguished by "first\second" can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than those illustrated or described herein.

[0121] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A knowledge graph relationship prediction method, characterized in that: include: S1, obtaining a sparse knowledge graph and a preset prompt template, constructing a candidate triple set consisting of a head entity, a relationship, and a tail entity according to the knowledge graph, and inputting the candidate triple set into several large language models in turn according to the prompt template to generate a triple evidence-based text set; S2, according to the triple-based text set, calculate the relation support for each candidate triple of the candidate triple set in turn; and arrange the candidate triple set in descending order according to the confidence, and S2 is further: S21, according to the triple-based evidence-based text set, obtaining the ranking number of each candidate triple in the candidate triple set in the triple-based evidence-based text set, that is, the ranking weight; S22, all ranking weights of the current candidate triples are accumulated and summed to obtain the single relation support of the current candidate triples, which is expressed as: ; in, Represents a candidate triple The relationship support, Represents a candidate triple Triple evidence-based texts in the Triple Evidence-Based Text Set The sorting weight of The triple-based evidence-based text sets obtained for different large language models; ; C is the candidate triple set; S3, according to each candidate triple, find all fact triples with the same relationship and tail entity from the knowledge graph to obtain a fact triple set; and accumulate and average the fact triple set combined with the output of the BERT model to obtain the true standardized vector of the corresponding candidate triple; S4, integrating the relation support and the BERT model, obtaining the candidate triple vectors corresponding to the candidate triple set, and traversing and calculating the inverse of the Euclidean distance between each candidate triple vector and its corresponding true normalized vector, to obtain an instance equivalence score; wherein, S4 is specifically: S41, combining the relationship support and the embedding vector function of the BERT model to obtain the candidate triple vector: ; in, Represents a candidate triple The candidate triple vector of , represents the matrix coefficients used to fine-tune the vector; represents the embedding vector obtained by the BERT model, represents the vector concatenation operation, To perform dimensionality reduction operations; Represents a candidate triple the relationship between Represents a candidate triple The tail entity in; S42, using the Euclidean distance to calculate the distance between the candidate triplet vector and the true standard vector corresponding to the candidate triplet, and taking the reciprocal as the confidence score of the corresponding candidate triplet, the formula is: ; in, represents the confidence score of the candidate triple c, Represents the dimension of the vector; Represents the candidate triple vector The kth value in ; Represents the true normalized vector The kth value in ; S43, traverse and calculate the confidence score of each candidate triple in the candidate triple set C, so as to obtain the instance equivalence score of each candidate triple. The expression of the instance equivalence score is: ; in, Represents a candidate triple The instance equivalence score of ,| | represents the cardinality of a set, represents the normalization constant used to adjust the scale of the score; S5, according to the instance equivalence score, the candidate triples in the candidate triple set that reach the preset threshold are screened out as the predicted triple set, and a knowledge graph relationship prediction model based on the fusion of instance equivalence and relationship support is obtained to realize knowledge graph relationship prediction.

2. A knowledge graph relationship prediction method according to claim 1, characterized in that ,The knowledge graph includes head entity, head entity type, relationship, tail entity set and tail entity type, and S1 is specifically: S11, assuming the head entity is , the header entity type is , the relationship is , the tail entity set is , the tail entity type is ;in, is the size of the tail entity set, is the nth tail entity; Construct candidate triple sets using a fully combined approach ; S12, the prompt template is a description of rule processing including the head entity, the head entity type, the tail entity type and the candidate triple set; wherein the rule processing in the prompt template is: arranging the candidate triple set in descending order according to confidence; The candidate triple set is combined with the prompt template and input into several large language models to obtain a triple evidence-based text set, which is expressed as: ; in, Represents the header entity The evidence-based text of the triplet obtained through one of the large language models, Represents a large language model.

3. A knowledge graph relationship prediction method according to claim 2, characterized in that , the S3 is specifically: S31, based on the candidate triples , find all the fact triples with the same relationship and tail entity from the knowledge graph ,in represents the size of the set of triples of the fact; According to the fact triple set , use the pre-trained language representation model BERT to get the vector of each fact triple: ; in, It is a fact triple The vector of , represents the matrix coefficients used to fine-tune the vector, represents the i-th head entity; S32, accumulate the vectors of all fact triples element by element, and then average them to obtain the true standardized vector of the candidate triple: ; in, is the true normalized vector, Add the sign of a vector element by element; Represents the mth fact triple.

4. A knowledge graph relationship prediction method according to claim 3, characterized in that ,S5 specifically includes: when the instance equivalence score of the candidate triple reaches the preset threshold, the corresponding candidate triple is stored in the predicted triple set In the expression: ; in, is the preset threshold.

5. A knowledge graph relationship prediction method according to claim 4, characterized in that , also includes: S6, using the stochastic gradient descent method to iteratively train and optimize the knowledge graph relationship prediction model, and performing cross entropy calculation on the predicted triple set and the real triple set in the test data. The cross entropy calculation formula is: ; in, To predict triples; is the true label, the value is 0 or 1; To predict triples Instance equivalence score of .

6. A knowledge graph relationship prediction device, characterized in that: include: An input module is used to obtain a sparse knowledge graph and a preset prompt template, obtain a sparse knowledge graph and a preset prompt template, construct a candidate triple set consisting of a head entity, a relationship, and a tail entity according to the knowledge graph, and input the candidate triple set into several large language models in sequence according to the prompt template to generate a triple evidence-based text set; The relation support module is used to calculate the relation support for each candidate triple of the candidate triple set in turn according to the triple-based text set; and to arrange the candidate triple set in descending order according to the confidence, further comprising: S21, according to the triple-based evidence-based text set, obtaining the ranking number of each candidate triple in the candidate triple set in the triple-based evidence-based text set, that is, the ranking weight; S22, all ranking weights of the current candidate triples are accumulated and summed to obtain the single relation support of the current candidate triples, which is expressed as: ; in, Represents a candidate triple The relationship support, Represents a candidate triple Triple evidence-based texts in the Triple Evidence-Based Text Set The sorting weight of The triple-based evidence-based text sets obtained for different large language models; ; C is the candidate triple set; A true normalized vector module is used to obtain a true normalized vector. According to each candidate triple, all fact triples with the same relationship and tail entity are found from the knowledge graph to obtain a fact triple set; and the fact triple set is combined with the output of the BERT model to accumulate and average to obtain the true normalized vector of the corresponding candidate triple. The instance equivalence module is used to obtain the instance equivalence score, integrate the relation support and the BERT model, obtain the candidate triple vectors corresponding to the candidate triple set, and traverse and calculate the inverse of the Euclidean distance between each candidate triple vector and its corresponding true normalized vector to obtain the instance equivalence score; specifically: S41, combining the relationship support and the embedding vector function of the BERT model to obtain the candidate triple vector: ; in, Represents a candidate triple The candidate triple vector of , represents the matrix coefficients used to fine-tune the vector; represents the embedding vector obtained by the BERT model, represents the vector concatenation operation, To perform dimensionality reduction operations; Represents a candidate triple the relationship between Represents a candidate triple The tail entity in; S42, using the Euclidean distance to calculate the distance between the candidate triplet vector and the true standard vector corresponding to the candidate triplet, and taking the reciprocal as the confidence score of the corresponding candidate triplet, the formula is: ; in, represents the confidence score of the candidate triple c, Represents the dimension of the vector; Represents the candidate triple vector The kth value in ; Represents the true normalized vector The kth value in ; S43, traverse and calculate the confidence score of each candidate triple in the candidate triple set C, so as to obtain the instance equivalence score of each candidate triple. The expression of the instance equivalence score is: ; in, Represents a candidate triple The instance equivalence score of ,| | represents the cardinality of a set, represents the normalization constant used to adjust the scale of the score; The prediction module is used to obtain a predicted triple set. According to the instance equivalence score, the candidate triples that reach a preset threshold in the candidate triple set are screened out as the predicted triple set, and a knowledge graph relationship prediction model based on the fusion of instance equivalence and relationship support is obtained to realize knowledge graph relationship prediction.

7. A knowledge graph relationship prediction device, characterized in that: It includes a processor and a memory, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a knowledge graph relationship prediction method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor of a device where the computer-readable storage medium is located, a knowledge graph relationship prediction method as described in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Knowledge graph representation learning method

    CN105630901A

  • Knowledge representation learning method based on entity distance

    CN110909172A