A knowledge graph completion method and related equipment
By obtaining the missing triplet text description and tail entity prediction type description in the knowledge graph, and using the text semantic information model and the embedded representation learning model to calculate the candidate entity score, the problem of low completion accuracy of the knowledge graph is solved and more efficient is achieved The knowledge graph completion effect.
Patent Information
- Application Number
- CN202410704741.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-06-03
AI Technical Summary
The accuracy of existing knowledge graph completion methods is not high. Especially when faced with large-scale knowledge bases, manual supplementation of information is inefficient and difficult to effectively alleviate the problems of data sparseness and incompleteness.
By obtaining the missing triplet text description and tail entity prediction type description in the knowledge graph to be completed, a candidate entity set is generated, and the text semantic information model and the embedded representation learning model are used to calculate the candidates from both text semantic information and structural information. The score value of the entity, select the candidate entity with the highest score for completion.
The accuracy of knowledge graph completion is improved, and the missing triples in the knowledge graph are more effectively completed by combining text semantic information and structural information.
Smart Images

Figure CN118278519B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of knowledge graph completion, and in particular to a knowledge graph completion method and related equipment. Background Art
[0002] Knowledge graphs represent concepts, entities and relationships in the real world in a structured form. With the development of artificial intelligence and big data technology, knowledge graphs have become the mainstream storage method for data due to their good search performance and high storage quality. Knowledge graphs often use triples <head entity h, relationship r, tail entity t> to represent the relationship between entities, which is well structured and intuitive.
[0003] Although the number of entities in knowledge graphs can reach billions, most knowledge graphs are incomplete, which affects the data quality and overall structure of knowledge graphs, resulting in inefficiency and poor results in downstream tasks based on them, such as information retrieval and recommendation systems, making it difficult to realize their value. In order to alleviate this technical problem, scoring functions can be used to calculate and rank candidate entities or relationships, and missing entities or relationships can be inferred based on existing entities and relationships in the knowledge graph. This task is called knowledge graph completion.
[0004] In the face of the problem of missing content in the knowledge base, if the missing information is supplemented by manual reasoning, it is inefficient and consumes a lot of manpower and financial resources, especially when faced with a knowledge base of hundreds of millions. How to mine implicit information based on existing facts in the knowledge graph, supplement the missing content, and alleviate the problem of data sparsity and incompleteness is becoming a hot topic for current researchers.
[0005] The knowledge graph completion methods currently studied in the prior art can be divided into two categories: embedding-based methods and text-based methods. The embedding-based methods map each entity and method to a low-dimensional vector, without considering auxiliary information such as entity descriptions, such as the Trans series of methods; the text-based methods learn the representation of entities and relationships from natural language descriptions, which have the potential for inductive learning completion, but the accuracy is not ideal. Summary of the invention
[0006] The present invention provides a knowledge graph completion method and related equipment, the purpose of which is to improve the accuracy of knowledge graph completion.
[0007] In order to achieve the above object, the present invention provides a knowledge graph completion method, comprising:
[0008] Step 1: obtain the text description and tail entity prediction type description of the missing triples in the knowledge graph to be completed, and generate a candidate entity set based on the tail entity prediction type description;
[0009] Step 2, combining each candidate entity in the candidate entity set with the missing triplet to obtain multiple complete triples, and inputting each complete triplet into the trained text semantic information model to extract semantic information, obtaining the text semantic information extraction result of each candidate entity, and obtaining the text semantic information score value of each candidate entity based on the text semantic information extraction result;
[0010] Step 3, for each complete triple, obtain the text information embedding vector of the complete triple, input the text information embedding vector of the complete triple as the initialization vector of the complete triple into the trained embedding representation learning model to extract structural information, obtain the structural information extraction result of each candidate entity, and obtain the embedding representation learning score value of each candidate entity based on the structural information extraction result;
[0011] Step 4: Calculate the total score of each candidate entity based on the text semantic information score of each candidate entity and the embedding representation learning score of each candidate entity, and take the candidate entity with the highest total score among all candidate entities as the confident tail entity to complete the missing triples in the knowledge graph to obtain the knowledge graph completion result.
[0012] Specifically, before step 1, the following steps are also included:
[0013] Construct a training data set, which is a knowledge graph consisting of multiple positive triples and multiple negative triples, and obtain text descriptions of all triples in the training data set;
[0014] Input the text descriptions of all triples in the training data set into the text semantic information model to extract text semantic information, and obtain a first embedding vector and a second embedding vector, wherein the first embedding vector is the text semantic information embedding vector of the predicted tail entity, and the second embedding vector is the text semantic information embedding vector of the actual tail entity;
[0015] Calculating the cosine similarity between the first embedding vector and the second embedding vector, and training the text semantic information model by using a first loss function calculated based on the cosine similarity to obtain a trained text semantic information model;
[0016] Input the text descriptions of all triples in the training dataset into the Bert pre-trained model for encoding, and obtain the semantic information embedding vector of each triple, the type embedding vector of the head entity, and the type embedding vector of the tail entity;
[0017] For each triple in the training data set, the semantic information embedding vector of the triple, the type embedding vector of the head entity, and the type embedding vector of the tail entity are input as initialization vectors into the embedding representation learning model to extract structural information, and the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity are obtained. The triple score is calculated through the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity;
[0018] The embedding representation learning model is trained by a second loss function calculated based on the triple score to obtain a trained embedding representation learning model.
[0019] Specifically, we obtain the text descriptions of all triples in the training dataset, including:
[0020] For each of all triples, if there is no text description for the head entity, relation, and tail entity in the triple, the triple is input into the ChatGPT model for text information processing to generate a text description corresponding to the head entity, relation, and tail entity in the triple;
[0021] For each triple of all triples, if there is no text description for the head entity or tail entity in the triple, the triple is input into the ChatGPT model for text information processing to generate the head entity type description and tail entity type description corresponding to the relationship, and the head entity type and tail entity type description are added to the text description corresponding to the head entity and tail entity in the triple.
[0022] Specifically, the text semantic information model is a Bert encoder model. The text descriptions of all triples in the training data set are input into the Bert encoder model to extract text semantic information and obtain the first embedding vector and the second embedding vector The expression is:
[0023]
[0024]
[0025] in
[0026]
[0027]
[0028] represents the first embedding vector, i.e., the text semantic information embedding vector of the predicted tail entity, represents the second embedding vector, i.e., the text semantic information embedding vector of the real tail entity, represents an expression encoded by the Bert encoder model, An expression representing the pooling process, A sequence of text representing the head entity, relation, and predicted tail entity type, A text sequence representing a true tail entity, and Is a special mark symbol, Indicates the beginning of the text description. Indicates the end of a delimiter or text description. Represents a textual description of the header entity, A textual description representing the relationship, Represents the text description of the tail entity, Represents the tail entity prediction type description.
[0029] Further, the cosine similarity between the first embedding vector and the second embedding vector is calculated. The expression is:
[0030]
[0031] The first loss function is calculated based on cosine similarity. The expression is:
[0032]
[0033] in, represents the set of all negative triples, represents a negative triple, represents the additive margin, represents the temperature parameter, Represents cosine similarity, which is the score of text semantic information;
[0034] The text semantic information model is trained using the first loss function to obtain a trained text semantic information model.
[0035] Further, the embedding representation learning model is a convolutional information propagation network model;
[0036] For each triple in the training data set, the semantic information embedding vector of the triple, the type embedding vector of the head entity and the type embedding vector of the tail entity are obtained, and the semantic information embedding vector of the triple, the type embedding vector of the head entity and the type embedding vector of the tail entity are input as initialization vectors into the convolutional information propagation network model for structural information extraction, and the embedding vector of the head entity, the embedding vector of the relationship and the embedding vector of the tail entity are obtained, including:
[0037] Set the maximum number of iterations of the convolutional information propagation network model to , and initialize the current number of iterations ;
[0038] For The embedding vector of the head entity is , Indicates the first Neighbor entities, Represents the neighbor entity set of the current head entity, Indicates The attention weights of neighbor entities, Indicates the last iteration The embedding vector of the neighbor entity and the embedding vector of the tail entity are , Indicates the current tail entity Neighbor entities, Represents the neighbor entity set of the current tail entity, Indicates The attention weights of neighbor entities, Indicates the last iteration The embedding vectors of neighbor entities;
[0039] At the current iteration The maximum number of iterations has been reached When The structural information embedding vector of the head entity after iterations , the structural information embedding vector of the tail entity ;
[0040] The structural information of the head entity after the Kth iteration is embedded into the vector , the structural information embedding vector of the tail entity Nonlinear coupling is performed with the initialization vector, and the coupled vector is linearly activated with the type embedding vector to obtain the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity.
[0041] Furthermore, the second loss function is calculated based on the triple score. The expression is:
[0042]
[0043] in, represents the knowledge graph, represents a triple label, represents the score function, , .
[0044] Furthermore, the total score of each candidate entity is calculated based on the text semantic information score of each candidate entity and the embedding representation learning score of each candidate entity. The expression is:
[0045]
[0046] in, Represents the text semantic information score, represents the embedding representation learning score value, represents the score weight, .
[0047] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, a knowledge graph completion method is implemented.
[0048] The present invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a knowledge graph completion method when executing the computer program.
[0049] The above scheme of the present invention has the following beneficial effects:
[0050] The present invention obtains the text description and tail entity prediction type description of the missing triples in the knowledge graph to be completed, and generates a candidate entity set based on the tail entity prediction type description; combines each candidate entity in the candidate entity set with the missing triple to obtain multiple complete triples, and inputs each complete triple into the trained text semantic information model for semantic information extraction to obtain the text semantic information extraction result of each candidate entity, and obtains the text semantic information score value of each candidate entity based on the text semantic information extraction result; for each complete triple, obtains the text information embedding vector of the complete triple, inputs the text information embedding vector of the complete triple as the initialization vector of the complete triple into the trained embedding representation learning model for structural information extraction, obtains the structural information extraction result of each candidate entity, and obtains the embedding representation learning score value of each candidate entity based on the structural information extraction result; according to the text semantic information of each candidate entity The total score of each candidate entity is calculated based on the information score value and the embedding representation learning score value of each candidate entity, and the candidate entity with the highest total score among all candidate entities is taken as the confident tail entity to complete the missing triples in the knowledge graph to be completed, so as to obtain the knowledge graph completion result; by obtaining the text description of the missing triples in the knowledge graph to be completed and the tail entity prediction type description, a candidate entity set is generated based on the tail entity prediction type description to limit the generation of the candidate entity set; multiple complete triples and text information embedding vectors of complete triples obtained by combining each candidate entity in the candidate entity set with the triple to be completed are respectively input into the text semantic information model and the embedding representation learning model for information extraction, so as to obtain the text semantic information score value and the embedding representation learning score value of each candidate entity, and obtain the total score value of each candidate entity from the two aspects of text semantic information and structural information, thereby improving the accuracy of knowledge graph completion.
[0051] Other beneficial effects of the present invention will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a schematic diagram of a flow chart of an embodiment of the present invention;
[0053] Figure 2 A schematic diagram of a text description of a triple in an embodiment of the present invention;
[0054] Figure 3 A schematic diagram of describing the types of triples in an embodiment of the present invention;
[0055] Figure 4 Schematic diagram of a convolutional information propagation network model in an embodiment of the present invention. DETAILED DESCRIPTION
[0056] In order to make the technical problems, technical solutions and advantages to be solved by the present invention clearer, the following will be described in detail with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0057] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0058] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense, for example, it can be a locking connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0059] In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0060] In view of the existing problems, the present invention provides a knowledge graph completion method and related equipment.
[0061] like Figure 1 As shown, an embodiment of the present invention provides a knowledge graph completion method, including:
[0062] Step 1: obtain the text description and tail entity prediction type description of the missing triples in the knowledge graph to be completed, and generate a candidate entity set based on the tail entity prediction type description;
[0063] Step 2, combining each candidate entity in the candidate entity set with the missing triplet to obtain multiple complete triples, and inputting each complete triplet into the trained text semantic information model to extract semantic information, obtaining the text semantic information extraction result of each candidate entity, and obtaining the text semantic information score value of each candidate entity based on the text semantic information extraction result;
[0064] Step 3, for each complete triple, obtain the text information embedding vector of the complete triple, input the text information embedding vector of the complete triple as the initialization vector of the complete triple into the trained embedding representation learning model to extract structural information, obtain the structural information extraction result of each candidate entity, and obtain the embedding representation learning score value of each candidate entity based on the structural information extraction result;
[0065] Step 4: Calculate the total score of each candidate entity based on the text semantic information score of each candidate entity and the embedding representation learning score of each candidate entity, and take the candidate entity with the highest total score among all candidate entities as the confident tail entity to complete the missing triples in the knowledge graph to obtain the knowledge graph completion result.
[0066] Specifically, before step 1, it also includes:
[0067] Construct a training data set, which is a knowledge graph consisting of multiple positive triples and multiple negative triples, and obtain text descriptions of all triples in the training data set;
[0068] Input the text descriptions of all triples in the training data set into the text semantic information model to extract text semantic information, and obtain a first embedding vector and a second embedding vector, wherein the first embedding vector is the text semantic information embedding vector of the predicted tail entity, and the second embedding vector is the text semantic information embedding vector of the actual tail entity;
[0069] Calculating the cosine similarity between the first embedding vector and the second embedding vector, and training the text semantic information model by using a first loss function calculated based on the cosine similarity to obtain a trained text semantic information model;
[0070] Input the text descriptions of all triples in the training dataset into the Bert pre-trained model for encoding, and obtain the semantic information embedding vector of each triple, the type embedding vector of the head entity, and the type embedding vector of the tail entity;
[0071] For each triple in the training data set, the semantic information embedding vector of the triple, the type embedding vector of the head entity, and the type embedding vector of the tail entity are input as initialization vectors into the embedding representation learning model to extract structural information, and the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity are obtained. The triple score is calculated through the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity;
[0072] The embedding representation learning model is trained by a second loss function calculated based on the triple score to obtain a trained embedding representation learning model.
[0073] Specifically, building a training dataset includes:
[0074] Download the knowledge graph for training. The knowledge graph includes multiple positive triples, each of which includes <head entity, relationship, tail entity>;
[0075] Input each positive triplet into the generative adversarial network for sample expansion to obtain multiple negative triplets;
[0076] All negative triples are added to the knowledge graph used for training to construct a training data set, where the training data set is a training knowledge graph consisting of multiple positive triples and multiple negative triples.
[0077] In the embodiment of the present invention, a knowledge graph (KG) for training is downloaded. Multiple triples Composition, among which, Represents the head entity, Represents the tail entity, Represents the relationship between the head entity and the tail entity. The triples are represented as , Represents the triple number. The triples in the knowledge graph constitute the positive sample set ;
[0078] Each triplet in the positive sample set Input to the generative adversarial network for sample expansion and generation High-quality negative triples , Generally, 20 is taken;
[0079] The generated negative triples are merged with the positive sample set to construct a training data set, which is a training knowledge graph consisting of multiple positive triplets and multiple negative triplets.
[0080] Specifically, each triplet in the positive sample set Input to the generative adversarial network for sample expansion and generation High-quality negative triples ,include:
[0081] For every positive triple Add a random perturbation , and then generate the tail entity corresponding to the negative triple through a two-layer fully connected layer ;
[0082] Among them, the expression of the generator in the generative adversarial network is:
[0083]
[0084] The discriminator in the generative adversarial network makes a judgment based on the marginal loss function:
[0085]
[0086] in, represents a random disturbance, , represents the identity matrix, , and the dimension of the embedding vector same, represents the deviation of the input noise, Represents the learnable parameters of the fully connected layer A collection of Edge distance parameter, T represents positive triples, and G represents the generator.
[0087] Specifically, obtain the text descriptions of all triples in the training dataset, including:
[0088] For each of all triples, if there is no text description for the head entity, relation, and tail entity in the triple, the triple is input into the ChatGPT model for text information processing to generate a text description corresponding to the head entity, relation, and tail entity in the triple;
[0089] For each triple of all triples, if there is no text description for the head entity or tail entity in the triple, the triple is input into the ChatGPT model for text information processing to generate the head entity type description and tail entity type description corresponding to the relationship, and the head entity type and tail entity type description are added to the text description corresponding to the head entity and tail entity in the triple.
[0090] In the embodiment of the present invention, the text description of all triples in the training data set is obtained; specifically, Figure 2 , Figure 3 As shown, for example, the head entity is a giant panda, the relation is eat, and the tail entity is the text description of bamboo;
[0091] For triples with missing entity type descriptions, the question template “For the triple <giant panda, eat, bamboo>, please generate a type description of the head entity <giant panda> and the tail entity <bamboo> of the relationship <eat>” is input into the ChatGPT model for text information processing to obtain the corresponding entity type description. In this embodiment of the present invention, the question template for obtaining the missing type description The expression is as follows:
[0092]
[0093]
[0094] Get the entity type description of each triple through the text description of the triple .
[0095] For each triple in the training set, the question template “For the triple <giant panda, eat,?>, please generate a predicted tail entity type description about the relationship <eat> and the head entity <giant panda>” is input into the ChatGPT model for text information processing to obtain the predicted tail entity type description. In this embodiment of the present invention, the question template The expression is as follows:
[0096]
[0097] in, Represents the predicted tail entity type description.
[0098] Specifically, step 2 includes:
[0099] By formula The head entity text description, the relationship text description and the predicted tail entity type description are concatenated and input into the text semantic information model for training. The first embedding vector of the head entity and the relationship joint enhanced by the predicted tail entity type and the second embedding vector of the real tail entity are obtained through the pooling layer in the text semantic information model. The first embedding vector is the text semantic information embedding vector of the predicted tail entity, and the second embedding vector is the text semantic information embedding vector of the real tail entity.
[0100] In the embodiment of the present invention, the text semantic information model is a Bert encoder model following the pooling strategy, and the text descriptions of all triples in the training data set are input into the pooling layer in the Bert encoder model to extract text semantic information, and the first embedding vector is obtained. and the second embedding vector The expression is:
[0101]
[0102]
[0103] in
[0104]
[0105]
[0106] represents the first embedding vector, i.e., the text semantic information embedding vector of the predicted tail entity, represents the second embedding vector, i.e., the text semantic information embedding vector of the real tail entity, represents an expression encoded by the Bert encoder model, An expression representing the pooling process, A sequence of text representing the head entity, relation, and predicted tail entity type, A text sequence representing a true tail entity, and Is a special mark symbol, Indicates the beginning of the text description. Indicates the end of a delimiter or text description. Represents a textual description of the header entity, A textual description representing the relationship, Represents the text description of the tail entity, Represents the tail entity prediction type description.
[0107] Specifically, the cosine similarity between the first embedding vector and the second embedding vector is calculated. The expression is:
[0108]
[0109] in, is the scoring function for each triple;
[0110] The first loss function is calculated based on cosine similarity. The expression is:
[0111]
[0112] in, represents the set of all negative triples, represents a negative triple, represents the additive margin, represents the temperature parameter, Represents cosine similarity, which is the score of text semantic information;
[0113] The text semantic information model is trained using a first loss function to obtain a trained text semantic information model.
[0114] Specifically, if Figure 4 As shown, the embedding representation learning model is a convolutional information propagation network model;
[0115] Input the text descriptions of all triples in the training dataset into the Bert pre-trained model in the format:
[0116]
[0117] Get the text information embedding vector for each triple and type embedding vector , the expression is:
[0118] ;
[0119] Embedding text information into vectors As the initialization vector of each triple in the training data set, it is input into the convolutional information propagation network model to extract structural information, and the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity are obtained, including:
[0120] Set the maximum number of iterations of the convolutional information propagation network model to , and initialize the current number of iterations ;
[0121] For The embedding vector of the head entity is , Indicates the first Neighbor entities, Represents the neighbor entity set of the current head entity, Indicates The attention weights of neighbor entities, Indicates the last iteration The embedding vector of the neighbor entity and the embedding vector of the tail entity are , Indicates the current tail entity Neighbor entities, Represents the neighbor entity set of the current tail entity, Indicates The attention weights of neighbor entities, Indicates the last iteration The embedding vectors of neighbor entities;
[0122] At the current iteration The maximum number of iterations has been reached When The structural information embedding vector of the head entity after iterations , the structural information embedding vector of the tail entity ;
[0123] The structural information of the head entity after the Kth iteration is embedded into the vector , the structural information embedding vector of the tail entity Nonlinearly coupled with the initialization vector to obtain the head entity embedding vector that incorporates context information features , the tail entity embedding vector , linearly activate the entity embedding vector fused with context information features and the entity type embedding vector to obtain the final head and tail entity embedding vector and , the expression of linear activation is:
[0124]
[0125] For the relationship embedding vector, the embodiment of the present invention uses the tail entity type embedding vector and the head entity type embedding vector to perform vector difference to obtain , and then concatenated with the semantic information embedding vector of the relationship to obtain the final relationship embedding vector ;
[0126] Finally, the score function Calculate the embedding representation learning score value for each candidate entity .
[0127] Specifically, the second loss function is calculated based on the triple score. The expression is:
[0128]
[0129] in, represents the knowledge graph, represents a triple label, represents the score function, , .
[0130] The embedding representation learning model is trained by the second loss function to obtain a trained embedding representation learning model.
[0131] Specifically, the specific process of obtaining the attention weights of neighbor entities is as follows:
[0132] Determine the relationship between the head entity and its neighbor entities Relationship with triples The distance between , the calculation formula is:
[0133]
[0134] in, is the weight matrix, is the bias parameter, The first entity and the The relationship between neighbor entities, Represents triple relationship, distance The larger the relationship Relationship with triples The higher the similarity;
[0135] Attention weights are assigned to neighbor entities based on the similarity between the neighbor entity relationship and the triple relationship. The expression is:
[0136]
[0137] in, Indicates Neighbor Entities The attention score, Indicates The relationship set between the head entity and its neighbor entities, score The higher the The more important the neighbor entities are, the higher the importance of the neighbor entities.
[0138] Specifically, in an embodiment of the present invention, the missing triples in the knowledge graph to be completed are obtained , and obtain the text description of the head entity and relationship in the missing triple, where the tail entity needs to be completed;
[0139] Use the predicted type information of the tail entity as prior knowledge to filter candidate entities and obtain the candidate entity set of missing triples in the knowledge graph to be completed .
[0140] The missing triples in the knowledge graph to be completed and the candidate entity set Each candidate entity in is reorganized into multiple complete triples, and each complete triple is input into the text semantic information model to extract text semantic information, and the first embedding vector is obtained. and the second embedding vector ;
[0141] By formula Calculate the cosine similarity between the first embedding vector and the second embedding vector as the text semantic information score value of each candidate entity .
[0142] In the embodiment of the present invention, for each complete triple, the text information embedding vector of the complete triple is obtained as the initialization vector of the complete triple and input into the embedding representation learning model to extract structural information, and the triple embedding vector is obtained. ;
[0143] Finally, the formula Calculate the embedding representation learning score value for each candidate entity .
[0144] Specifically, the total score of each candidate entity is calculated based on the text semantic information score of each candidate entity and the embedding representation learning score of each candidate entity. The expression is:
[0145]
[0146] in, Represents the text semantic information score, represents the embedding representation learning score value, represents the score weight, .
[0147] The present invention obtains the text description and tail entity prediction type description of the missing triples in the knowledge graph to be completed, and generates a candidate entity set based on the tail entity prediction type description; combines each candidate entity in the candidate entity set with the missing triple to obtain multiple complete triples, and inputs each complete triple into the trained text semantic information model for semantic information extraction to obtain the text semantic information extraction result of each candidate entity, and obtains the text semantic information score value of each candidate entity based on the text semantic information extraction result; for each complete triple, obtains the text information embedding vector of the complete triple, inputs the text information embedding vector of the complete triple as the initialization vector of the complete triple into the trained embedding representation learning model for structural information extraction, obtains the structural information extraction result of each candidate entity, and obtains the embedding representation learning score value of each candidate entity based on the structural information extraction result; according to the text semantic information of each candidate entity The total score of each candidate entity is calculated based on the information score value and the embedding representation learning score value of each candidate entity, and the candidate entity with the highest total score among all candidate entities is taken as the confident tail entity to complete the missing triples in the knowledge graph to be completed, so as to obtain the knowledge graph completion result; by obtaining the text description of the missing triples in the knowledge graph to be completed and the tail entity prediction type description, a candidate entity set is generated based on the tail entity prediction type description to limit the generation of the candidate entity set; multiple complete triples and text information embedding vectors of complete triples obtained by combining each candidate entity in the candidate entity set with the triple to be completed are respectively input into the text semantic information model and the embedding representation learning model for information extraction, so as to obtain the text semantic information score value and the embedding representation learning score value of each candidate entity, and obtain the total score value of each candidate entity from the two aspects of text semantic information and structural information, thereby improving the accuracy of knowledge graph completion.
[0148] An embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, a knowledge graph completion method is implemented.
[0149] If the integrated module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above method embodiment, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the construction device / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk.
[0150] An embodiment of the present invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a knowledge graph completion method when executing the computer program.
[0151] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, a server, a server cluster, a cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.
[0152] The processor may be a central processing unit (CPU), or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0153] In some embodiments, the memory may be an internal storage unit of the terminal device, such as a hard disk or memory of the terminal device. In other embodiments, the memory may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart memory card (SMC, Smart Media Card), a secure digital (SD, Secure Digital) card, a flash card (Flash Card), etc. equipped on the terminal device. Further, the memory may also include both an internal storage unit of the terminal device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (Boot Loader), data and other programs, such as the program code of the computer program, etc. The memory may also be used to temporarily store data that has been output or is to be output.
[0154] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the embodiment of the present invention. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0155] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0156] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A knowledge graph completion method, characterized in that: include: Step 1, obtaining the text description and tail entity prediction type description of the missing triples in the knowledge graph to be completed, and generating a candidate entity set based on the tail entity prediction type description; Also include before step 1: Constructing a training data set, wherein the training data set is a knowledge graph consisting of a plurality of positive triples and a plurality of negative triples, and obtaining text descriptions of all triples in the training data set; Inputting the text descriptions of all triples in the training data set into a text semantic information model to extract text semantic information, obtaining a first embedding vector and a second embedding vector, wherein the first embedding vector is an embedding vector of text semantic information of a predicted tail entity, and the second embedding vector is an embedding vector of text semantic information of a real tail entity; Calculating the cosine similarity between the first embedding vector and the second embedding vector, and training the text semantic information model by using a first loss function calculated based on the cosine similarity to obtain a trained text semantic information model; Input the text descriptions of all triples in the training data set into the Bert pre-training model for encoding, and obtain the semantic information embedding vector of each triple, the type embedding vector of the head entity, and the type embedding vector of the tail entity; For each triple in the training data set, the semantic information embedding vector of the triple, the type embedding vector of the head entity, and the type embedding vector of the tail entity are input as initialization vectors into the embedding representation learning model to extract structural information, so as to obtain the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity, and the triple score is calculated by the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity; Training the embedding representation learning model by using a second loss function calculated based on the triple score to obtain a trained embedding representation learning model; Step 2, combining each candidate entity in the candidate entity set with the missing triplet to obtain a plurality of complete triples, and inputting each of the complete triplet into the trained text semantic information model to extract semantic information, to obtain a text semantic information extraction result of each candidate entity, and obtaining a text semantic information score value of each candidate entity based on the text semantic information extraction result; The text semantic information extraction result of each candidate entity is a first embedding vector and a second embedding vector; Calculate the cosine similarity between the first embedding vector and the second embedding vector as a text semantic information score value of each candidate entity; Step 3, for each of the complete triples, obtain the text information embedding vector of the complete triple, input the text information embedding vector of the complete triple as the initialization vector of the complete triple into the trained embedding representation learning model to extract structural information, obtain the structural information extraction result of each of the candidate entities, and obtain the embedding representation learning score value of each of the candidate entities based on the structural information extraction result; The structural information extraction result of each candidate entity is the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity; Calculate the embedding representation learning score value of each candidate entity based on the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity; Step 4, calculate the total score of each candidate entity according to the text semantic information score of each candidate entity and the embedding representation learning score of each candidate entity, and take the candidate entity with the highest total score among all candidate entities as the confident tail entity to complete the missing triples in the knowledge graph to be completed, so as to obtain the knowledge graph completion result.
2. The knowledge graph completion method according to claim 1, characterized in that: The obtaining of text descriptions of all triples in the training data set includes: For each of all triples, if the head entity, relationship, and tail entity in the triple have no text description, the triple is input into the ChatGPT model for text information processing to generate a text description corresponding to the head entity, relationship, and tail entity in the triple; For each triple of all triples, if the head entity or tail entity in the triple has no text description, the triple is input into the ChatGPT model for text information processing to generate a head entity type description and a tail entity type description corresponding to the relationship, and the head entity type and the tail entity type description are added to the text description corresponding to the head entity and the tail entity in the triple.
3. The knowledge graph completion method according to claim 2, characterized in that: The text semantic information model is a Bert encoder model, and the text descriptions of all triples in the training data set are input into the Bert encoder model to extract text semantic information to obtain a first embedding vector and the second embedding vector The expression is: in represents the first embedding vector, i.e., the text semantic information embedding vector of the predicted tail entity, represents the second embedding vector, i.e., the text semantic information embedding vector of the real tail entity, represents an expression encoded by the Bert encoder model, An expression representing the pooling process, A sequence of text representing the head entity, relation, and predicted tail entity type, A text sequence representing a true tail entity, and Is a special mark symbol, Indicates the beginning of the text description. Indicates the end of a delimiter or text description. Represents a textual description of the header entity, A textual description representing the relationship, Represents the text description of the tail entity, Represents the tail entity prediction type description.
4. The knowledge graph completion method according to claim 3, characterized in that: The step 3 comprises: Calculate the cosine similarity between the first embedding vector and the second embedding vector, the cosine similarity The expression is: A first loss function is calculated based on the cosine similarity. The first loss function The expression is: in, represents the set of all negative triples, represents a negative triple, represents the additive margin, represents the temperature parameter, Represents cosine similarity, which is the score of text semantic information; The text semantic information model is trained using the first loss function to obtain a trained text semantic information model.
5. The knowledge graph completion method according to claim 4, characterized in that: The embedding representation learning model is a convolutional information propagation network model; For each triple in the training data set, a semantic information embedding vector of the triple, a type embedding vector of the head entity, and a type embedding vector of the tail entity are obtained, and the semantic information embedding vector of the triple, the type embedding vector of the head entity, and the type embedding vector of the tail entity are input as initialization vectors into a convolutional information propagation network model for structural information extraction, to obtain an embedding vector of the head entity, an embedding vector of the relationship, and an embedding vector of the tail entity, including: Set the maximum number of iterations of the convolutional information propagation network model to , and initialize the current number of iterations ; For The embedding vector of the head entity is , Indicates the first Neighbor entities, Represents the neighbor entity set of the current head entity, Indicates The attention weights of neighbor entities, Indicates the last iteration The embedding vector of the neighbor entity, the embedding vector of the tail entity is , Indicates the current tail entity Neighbor entities, Represents the neighbor entity set of the current tail entity, Indicates The attention weights of neighbor entities, Indicates the last iteration The embedding vectors of neighbor entities; At the current iteration The maximum number of iterations has been reached When The structural information embedding vector of the head entity after iterations , the structural information embedding vector of the tail entity ; The structural information of the head entity after the Kth iteration is embedded into the vector , the structural information embedding vector of the tail entity Nonlinear coupling is performed with the initialization vector, and the coupled vector is linearly activated with the type embedding vector to obtain the embedding vector of the head entity, the embedding vector of the relationship, and the embedding vector of the tail entity.
6. The knowledge graph completion method according to claim 1, characterized in that: A second loss function is calculated based on the triple score, wherein the second loss function The expression is: in, represents the knowledge graph, represents a triple label, represents the score function, , .
7. The knowledge graph completion method according to claim 6, characterized in that: The total score of each candidate entity is calculated based on the text semantic information score of each candidate entity and the embedding representation learning score of each candidate entity. The expression is: in, Represents the text semantic information score, represents the embedding representation learning score value, represents the score weight, .
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the knowledge graph completion method as described in any one of claims 1 to 7 is implemented.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the knowledge graph completion method as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Zero sample knowledge graph completion method based on pre-training language model
CN117273134A
Common disease knowledge graph link prediction method fusing entity description
CN117371525A
Open knowledge graph completion method and device based on pre-training language model prompt fine tuning
CN117892807A
Zero sample knowledge graph completion method and device
CN117951308A
Method and apparatus for completing describable knowledge graph
WO2022108206A1
