Knowledge graph completion method and device, storage medium and equipment

By determining sentence templates in the knowledge graph and inserting vectors, and combining them with entity description information for model training, the accuracy problem of triple determination in the knowledge graph is solved, and high-quality knowledge graph completion is achieved.

CN117033645BActive Publication Date: 2026-05-01TSINGHUA UNIVERSITY +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TSINGHUA UNIVERSITY
Filing Date
2022-04-29
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately identify triples in knowledge graphs, resulting in insufficient accuracy of the completed knowledge graph.

Method used

By obtaining triples from the knowledge graph, determining sentence templates and inserting vectors, transforming them into sentences, and combining them with entity description information for model training, a knowledge graph completion model is generated, adding new entities and relations.

Benefits of technology

It improves the accuracy of knowledge graph completion, accurately identifies new triples, and ensures the quality of the completed knowledge graph.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117033645B_ABST
    Figure CN117033645B_ABST
Patent Text Reader

Abstract

The application discloses a knowledge graph completion method and device, a storage medium and equipment, and belongs to the field of artificial intelligence. The method comprises the following steps: acquiring a first sample set, wherein the first sample set comprises triples in a knowledge graph; determining a sentence pattern corresponding to a relation included in any triple in the first sample set, converting the triple into a sentence based on the sentence pattern corresponding to the relation, inserting a vector into the sentence, and obtaining first-class data; acquiring introduction information of an entity included in the triple, converting the entity and the introduction information into second-class data based on a sentence pattern corresponding to the introduction information; performing model training based on the first-class data and the second-class data corresponding to multiple triples in the first sample set; determining new triples for the knowledge graph based on a obtained knowledge graph completion model, and adding entities and relations in the knowledge graph based on the new triples. The application can ensure the accuracy of the completed knowledge graph.
Need to check novelty before this filing date? Find Prior Art

Description

Knowledge graph completion methods, devices, storage media and equipment Technical Field

[0001] This application relates to the field of artificial intelligence, and in particular to a knowledge graph completion method, apparatus, storage medium, and device. Background Technology

[0002] In the field of artificial intelligence, knowledge graph completion is an important task related to knowledge graphs. It helps to improve knowledge graphs, thereby supporting downstream natural language processing tasks. In other words, knowledge graph completion aims to supplement knowledge graphs with information that is not currently present in them.

[0003] Knowledge graphs represent knowledge in the form of a graph structure, with entities as nodes and relations as edges connecting two entities. Two entities and the relations between them form a triple, representing a specific fact. For example, (Country A, Capital City, City B) is a triple. "Country A" and "City B" are two entities, called the head entity and tail entity respectively, and "Capital City" is the relation. This triple represents the fact that the capital of Country A is City B.

[0004] As described above, the core of knowledge graph completion is discovering the correct triples. In other words, discovering the correct triples is key to improving the effectiveness of knowledge graph completion. Therefore, how to accurately determine triples through a new knowledge graph completion method, thereby ensuring the accuracy of the completed knowledge graph, has become a research hotspot for those skilled in the art. Summary of the Invention

[0005] This application provides a knowledge graph completion method, apparatus, storage medium, and device to ensure the accuracy of the completed knowledge graph. The technical solution is as follows:

[0006] On the one hand, a knowledge graph completion method is provided, the method comprising:

[0007] Obtain a first sample set, which includes triples in a knowledge graph, wherein the triples represent the relationships between entities in the knowledge graph;

[0008] For any triple in the first sample set, determine the sentence template corresponding to the relation included in the triple, convert the triple into a statement based on the sentence template corresponding to the relation, insert a vector into the statement, and obtain the first type of data;

[0009] Obtain the descriptive information of the entities included in the triple, and based on the sentence template corresponding to the descriptive information, convert the entities and the descriptive information into a second type of data;

[0010] The knowledge graph completion model is obtained by training the model based on the first type of data and the second type of data corresponding to multiple triples in the first sample set.

[0011] Based on the knowledge graph completion model, new triples are determined for the knowledge graph, and entities and relations are added to the knowledge graph based on the new triples.

[0012] In some embodiments, determining new triples for the knowledge graph based on the knowledge graph completion model, and adding entities and relations to the knowledge graph based on the new triples, includes:

[0013] Based on the knowledge graph completion model, the first triplet is classified, and the first triplet does not exist in the knowledge graph; in response to the first classification result indicating that the first triplet is a correct triplet, an entity and relation are added to the knowledge graph based on the first triplet; or...

[0014] Obtain the second triplet, where the tail entity of the second triplet is missing; based on the head entity and relation of the second triplet, predict the tail entity for the second triplet using the knowledge graph completion model; and add new entities and relations to the knowledge graph based on the second triplet with the supplemented tail entity.

[0015] On the other hand, a knowledge graph completion device is provided, the device comprising:

[0016] The acquisition module is configured to acquire a first sample set, which includes triples in a knowledge graph, wherein the triples represent the relationships between entities in the knowledge graph.

[0017] The first processing module is configured to, for any triple in the first sample set, determine the sentence template corresponding to the relation included in the triple, convert the triple into a statement based on the sentence template corresponding to the relation, insert a vector into the statement, and obtain the first type of data;

[0018] The second processing module is configured to obtain the descriptive information of the entities included in the triple, and convert the entities and the descriptive information into a second type of data based on the sentence template corresponding to the descriptive information;

[0019] The training module is configured to train the model based on the first type of data and the second type of data corresponding to multiple triples in the first sample set, so as to obtain a knowledge graph completion model.

[0020] The third processing module is configured to determine new triples for the knowledge graph based on the knowledge graph completion model, and to add entities and relations to the knowledge graph based on the new triples.

[0021] In some embodiments, the first processing module is configured to:

[0022] The head entity of the triple is filled into the first position of the sentence template, and the tail entity of the triple is filled into the second position of the sentence template to obtain the sentence;

[0023] Based on the relations included in the triples, a preset number of vectors are obtained from the vector lookup table; wherein, the vector lookup table is used to store vectors corresponding to various relations;

[0024] According to the determined insertion positions and the number of vectors to be inserted at each insertion position, the preset number of vectors are inserted into the corresponding positions of the statement to obtain the first type of data.

[0025] In some embodiments, the second processing module is configured to perform at least one of the following:

[0026] Obtain the definition information of the entities included in the triplet, and fill the entities and the definition information into the sentence template corresponding to the definition information to obtain the second type of data;

[0027] Obtain the attribute information of the entities included in the triplet, and fill the entity, the attribute information, and the attribute type corresponding to the attribute information into the sentence template corresponding to the attribute information to obtain the second type of data.

[0028] In some embodiments, the first sample set includes positive triples and negative triples, wherein the positive triples are triples in the knowledge graph, and the negative triples are obtained based on the positive triples;

[0029] The negative example triplet includes a first type of negative example triplet and a second type of negative example triplet;

[0030] The first type of negative triplet is obtained by randomly replacing the head entity or tail entity included in the positive triplet with other entities;

[0031] The second type of negative triple is obtained by replacing the head entity included in the positive triple with a first candidate entity; the first candidate entity is predicted based on the tail entity and relation included in the positive triple; or, the second type of negative triple is obtained by replacing the tail entity included in the positive triple with a second candidate entity; the second candidate entity is predicted based on the head entity and relation included in the positive triple.

[0032] In some embodiments, the evaluation process of the knowledge graph completion model includes:

[0033] Obtain a second sample set that is not manually labeled, which contains more negative triplets than positive triplets;

[0034] Candidate negative triples are determined from the negative triples included in the second sample set. The number of candidate negative triples is the same as the number of positive triples in the second sample set. The candidate negative triples are negative triples that have been manually labeled.

[0035] Based on the knowledge graph completion model, the triples included in the third sample set are classified to obtain the second classification result; wherein, the third sample set includes the candidate negative triples and the positive triples in the second sample set;

[0036] Based on the second classification result, the first evaluation data of the knowledge graph completion model is obtained.

[0037] In some embodiments, the evaluation process of the knowledge graph completion model includes:

[0038] Obtain the fourth sample set; for any triple in the fourth sample set, based on the head entity and relation included in the triple, predict a new tail entity for the triple using the knowledge graph completion model to obtain a new triple;

[0039] Obtain the third classification result of the new triplet, which is based on manual annotation; based on the third classification result, obtain the second evaluation data of the knowledge graph completion model.

[0040] On the other hand, a computer device is provided, the device including a processor and a memory, the memory storing at least one piece of program code, the at least one piece of program code being loaded and executed by the processor to implement the above-described knowledge graph completion method.

[0041] On the other hand, a computer-readable storage medium is provided, wherein at least one piece of program code is stored in the storage medium, the at least one piece of program code being loaded and executed by a processor to implement the above-described knowledge graph completion method.

[0042] On the other hand, a computer program product or computer program is provided, which includes computer program code stored in a computer-readable storage medium. A processor of a computer device reads the computer program code from the computer-readable storage medium and executes the computer program code, causing the computer device to perform the aforementioned knowledge graph completion method.

[0043] This embodiment uses a first sample set as the training set for model training. The first sample set includes triples from the knowledge graph. That is, this embodiment builds the training set based on existing structured knowledge in the knowledge graph for model training, eliminating the need for additional training set generation and saving significant manpower. Furthermore, this embodiment combines pre-generated sentence templates, vectors, and entity descriptions to transform the triples in the training set into two different forms, resulting in first-class and second-class data. Since these two types of data are not only rich in content but also grammatically correct, training the model based on them yields a high-performance knowledge graph completion model. This knowledge graph completion model can accurately determine new triples for the knowledge graph, thus completing unknown and correct knowledge, ensuring the accuracy of the completed knowledge graph. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 is a schematic diagram of the implementation environment of a knowledge graph completion method provided in an embodiment of this application;

[0046] Figure 2 is an overall architecture diagram of a knowledge graph completion method provided in an embodiment of this application;

[0047] Figure 3 is a flowchart of a knowledge graph completion method provided in an embodiment of this application;

[0048] Figure 4 is a schematic diagram of triple classification based on a pre-trained language model provided in an embodiment of this application;

[0049] Figure 5 is a comparison chart of link prediction based on different models provided in the embodiments of this application;

[0050] Figure 6 is a comparison diagram of triple classification based on different models provided in the embodiments of this application;

[0051] Figure 7 is a schematic diagram of the structure of a knowledge graph completion device provided in an embodiment of this application;

[0052] Figure 8 is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0054] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items that have essentially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or execution order. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms.

[0055] These terms are simply used to distinguish one element from another. For example, without departing from the various examples, the first element can be referred to as the second element, and similarly, the second element can be referred to as the first element. Both the first and second elements can be elements, and in some cases, they can be separate and distinct elements.

[0056] "At least one" refers to one or more elements. For example, at least one element can be one element, two elements, three elements, or any integer number of elements greater than or equal to one. "Multiple" refers to two or more elements. For example, multiple elements can be two elements, three elements, or any integer number of elements greater than or equal to two.

[0057] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the initial text and interest tags involved in this application were obtained with full authorization.

[0058] The knowledge graph completion scheme provided in this application involves artificial intelligence technology.

[0059] Artificial intelligence (AI) encompasses the theories, methods, technologies, and application systems that utilize digital computers or computers-controlled machines to simulate, extend, and expand human intelligence, enabling them to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce new intelligent machines capable of reacting in a manner similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess perception, reasoning, and decision-making capabilities.

[0060] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.

[0061] Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language people use in daily life—and thus it has a close relationship with linguistic research. NLP techniques typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.

[0062] Machine Learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instruction-based learning.

[0063] With the research and advancement of artificial intelligence (AI) technology, AI is being studied and applied in various fields, such as smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, autonomous driving, drones, robots, smart healthcare, and smart customer service. It is believed that with the development of technology, AI will be applied in more fields and play an increasingly important role.

[0064] The knowledge graph completion scheme provided in this application may involve artificial intelligence technologies such as natural language processing and machine learning, which will be specifically illustrated through the following embodiments.

[0065] The following section introduces some key terms or abbreviations involved in the embodiments of this application.

[0066] Pre-trained Language Model (PLM): A language model that is pre-trained in unsupervised mode on massive amounts of text. It has a strong ability to model text, such as BERT (Bidirectional Encoder Representation from Transformers) and T5.

[0067] Knowledge graphs represent knowledge in a structured graph format, enabling artificial intelligence to process, understand, and even reason about human knowledge, thus achieving a higher level of cognitive intelligence. A knowledge graph represents knowledge in a graph structure, with entities as nodes and edges indicating the relationships between nodes. In other words, a knowledge graph is a network of entities and relationships, often a large graph where entities are nodes, edges are relationships, and two entities and an edge in between form a triple representing a specific fact. In some embodiments, a triple is represented as (h, r, t), where h represents the head entity, r represents the relationship, and t represents the tail entity.

[0068] Knowledge graph completion: This involves adding knowledge that is not present in the knowledge graph. Knowledge graph completion is a crucial task related to knowledge graphs, helping to build and improve them and supporting numerous downstream NLP tasks. The two main tasks of knowledge graph completion are triple classification and link prediction. Triple classification verifies the truth value of a given triple (h, r, t), i.e., it determines the correctness of a given triple (h, r, t). Link prediction typically involves predicting entities that have a specific relationship with a given entity. For example, given (r, t), predict h, or given (h, r), predict t; where the former can be represented as (?, r, t), and the latter as (h, r, ?). Link prediction is also known as entity prediction.

[0069] Closed-world hypothesis: This hypothesis holds that only triples that exist in the knowledge graph are correct, that is, triples that are not in the knowledge graph are incorrect.

[0070] Open World Hypothesis: This hypothesis holds that the knowledge already existing in the knowledge graph is incomplete. That is, triples not in the knowledge graph are not necessarily wrong, but their correctness is uncertain.

[0071] Entities: From a data processing perspective, any objectively existing thing in the real world can be called an entity. In other words, an entity is any distinguishable and identifiable thing in the real world. For example, an entity can refer to people, such as teachers or students, or it can refer to objects, such as books or warehouses. In addition to referring to tangible objective objects, entities can also refer to abstract things, such as performances or football matches.

[0072] The implementation environment of the knowledge graph completion method provided in the embodiments of this application is described below.

[0073] The knowledge graph completion method provided in this application is applied to a computer device. In some embodiments, the computer device is a server. For example, FIG1 is a schematic diagram of an implementation environment related to a knowledge graph completion method provided in this application. The implementation environment includes a first computer device 101 and a second computer device 102. The first computer device 101 is used to train a knowledge graph completion model, and the second computer device 102 is used to perform a knowledge graph completion task using the trained knowledge graph completion model. In some embodiments, the first computer device 101 and the second computer device 102 may also be the same device, that is, after model training is completed on this device, the knowledge graph completion task is performed on this device; this application does not impose any limitations on this.

[0074] The aforementioned servers can be independent physical servers, server sample clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0075] In other embodiments, the application areas of this knowledge graph completion method include, but are not limited to, the medical field, the financial investment field, the security field, the e-commerce field, and the chatbot field. In the above-mentioned fields, combining knowledge graphs can achieve tasks such as text processing, semantic understanding, machine translation, and chatbot question answering, and this application does not impose any limitations on these areas.

[0076] In other embodiments, based on the above-described implementation environment, this application proposes a knowledge graph completion method based on a pre-trained language model. Referring to Figure 2, the overall framework of this knowledge graph completion method includes the following three parts: a first prompt generator 201, a second prompt generator 202, and a pre-trained language model 203. That is, the knowledge graph completion model includes the first prompt generator 201, the second prompt generator 202, and the pre-trained language model 203. Both the first prompt generator 201 and the second prompt generator 202 are connected to the pre-trained language model 203.

[0077] The first point to note is that the aforementioned first prompt is also referred to as a triplet prompt in this embodiment, and the aforementioned second prompt is also referred to as an additional information prompt. In the following text, the triplet prompt will be referred to as the first type of data, and the additional information prompt will be referred to as the second type of data. Both the triplet prompt and the additional information prompt will be input into the pre-trained language model 203.

[0078] For the first prompt generator 201, for each triple, this embodiment defines a template and uses the template to transform it into a sentence. Furthermore, since the defined template is unlikely to perfectly cover all semantic information, to enhance the expressiveness of the sentence, this embodiment also inserts several vectors into the sentence, ultimately forming a first type of data combining the template and vectors.

[0079] Regarding the second prompt generator 202, for each triplet, this embodiment of the application fully considers additional information beyond the triplet itself. For example, for each type of additional information, this embodiment of the application defines a corresponding template, and then uses the template to transform the aforementioned additional information to obtain the second type of data.

[0080] Among these features, triplet-based prompts and additional information prompts can better utilize the massive parameterized knowledge in the pre-trained language model; furthermore, in order to fully utilize the structured knowledge in the knowledge graph, this embodiment of the application trains positive and negative examples on existing triples in the knowledge graph during the model training process. See below for a detailed description.

[0081] The second point to note is that this application also proposes an evaluation method for knowledge graph completion based on the open-world assumption. That is, this application can evaluate the performance of the knowledge graph completion model under the open-world assumption, and can also fully utilize the massive parameterized knowledge in the pre-trained language model and the structured knowledge in the knowledge graph, thereby achieving the completion of unknown and correct knowledge for the knowledge graph.

[0082] Figure 3 is a flowchart of a knowledge graph completion method provided in an embodiment of this application. The execution subject of this knowledge graph completion method is a computer device. Referring to Figure 3, the method includes the following steps.

[0083] 301. The computer equipment obtains the first sample set.

[0084] In this embodiment, the first sample set is the training set. To fully utilize the structured knowledge in the knowledge graph, the first sample set includes existing triples in the knowledge graph, which represent the relationships between entities in the knowledge graph.

[0085] In some embodiments, this application performs positive and negative example training on existing triples in the knowledge graph. Alternatively, the first sample set includes positive triples and negative triples, where the positive triples are existing triples in the knowledge graph, and the negative triples are obtained based on the positive triples.

[0086] Formalized, the knowledge graph completion model is based on the set of triples D = T∪T - In the training context, D refers to the first sample set, T refers to the positive triplet, and T... - Refers to negative triples; and the set of triples T - There are two types of negative triplets, referred to as Type I negative triplets. Second type negative triplet

[0087] Among them, the first type of negative triplet Also known as random negative triples, these negative triples are obtained by randomly replacing the head or tail entity of the positive triple with other entities. Type II negative triples Also known as negative triples based on representation learning models. These negative triples are obtained by replacing the first and last entities of the positive triples with entities predicted by the representation learning model.

[0088] In other embodiments, the second type of negative triplet It is obtained by replacing the head entity of the positive triple with the first candidate entity; wherein the first candidate entity is predicted by a representation learning model based on the tail entity and relation of the positive triple; or, the second type of negative triple. It is obtained by replacing the tail entity included in the positive triple with the second candidate entity; wherein the second candidate entity is predicted by a representation learning model based on the head entity and relation included in the positive triple.

[0089] Representation learning refers to representing the semantic information of the research object as a dense, low-dimensional real-valued vector. The representation learning models used in this application include, but are not limited to, the Trans series models, and are not restricted herein. Furthermore, when predicting entities, the representation learning model provides the probability corresponding to each entity; a higher probability indicates a greater likelihood of the correctness of the resulting triple after the corresponding entity is added to the triplet. The first and second candidate entities can be entities whose probabilities rank in the top N predicted by the representation learning model, and are not restricted herein. Here, N is a positive integer.

[0090] The process of generating triplet hints will be described below through step 302.

[0091] 302. For any triple in the first sample set, the computer device determines the sentence template corresponding to the relation included in the triple, and based on the sentence template corresponding to the relation included in the triple, the triple is converted into a statement, and a vector is inserted into the obtained statement to obtain the first type of data.

[0092] For example, this application designes a template (hereinafter referred to as a sentence template) for each known type of relation r. For example, for the relation "member of sports team", the corresponding sentence template could be "[X] plays for [Y]".

[0093] In some embodiments, based on the sentence template corresponding to the relation included in the triple, the triple is transformed into a statement, and a vector is inserted into the obtained statement to obtain the first type of data, including the following steps:

[0094] 3021. Fill the first position of the sentence template with the head entity included in the triple, and fill the second position of the sentence template with the tail entity included in the triple, to obtain the statement.

[0095] The first and second positions mentioned above are the entity filling positions in the sentence template.

[0096] For example, taking the relation "member of sports team" as an example, for each triple with the relation "member of sports team" in the first sample set, the [X] in the sentence template "[X]playsfor[Y]." is replaced with the head entity of the triple, and the [Y] in the sentence template "[X]plays for[Y]." is replaced with the tail entity of the triple, thus transforming the triple into the corresponding statement. For example, referring to Figure 4, for a triple like (James, member of sportsteam, teamA), [X] can be replaced with "James", and [Y] can be replaced with "teamA" to obtain the statement "James plays for teamA."

[0097] In other embodiments, to make the triplet hints more expressive and ultimately improve the performance of the knowledge graph completion model, this application's embodiments insert several trainable vectors into the initially obtained triplet hints to form the final triplet hints. It should be noted that "trained" in "trained vectors" means that after the final triplet hints are input into the pre-trained language model, these input vectors will be optimized during model training, i.e., their values ​​will change.

[0098] 3022. Based on the relations included in the triple, retrieve a preset number of vectors from the vector lookup table.

[0099] This application embodiment maintains a vector lookup table, which stores vectors corresponding to various relationships. Formally, this vector lookup table is... Where |R| refers to the number of relations, n is the total number of vectors contained in a sentence, i.e., the aforementioned preset number; d refers to the dimension of the vector.

[0100] 3023. According to the determined insertion position and the number of vectors to be inserted at each insertion position, insert the preset number of vectors into the corresponding positions of the statement to obtain the first type of data.

[0101] In some embodiments, for each sentence template, this application embodiment designs 6 positions where vectors can be inserted, wherein the number of vectors inserted at each position are n1, n2, n3, n4, n5 and n6, and the sum of the number of vectors inserted at each position is n, that is, n = n1 + n2 + n3 + n4 + n5 + n6.

[0102] In addition, the number of insertion positions can also be other values, such as 4, which is not limited in this application. For example, the number of insertion positions can be set according to the length of the sentence template. As shown in Figure 4, a total of 4 insertion positions are set for "James plays for teamA.", where the position of the symbol [SP] corresponds to the 4 insertion positions.

[0103] In other embodiments, taking a number of insertion positions of 6 as an example, in response to n being 1, the vector can be inserted at any of the 6 insertion positions; in response to n being 2, the vector can be inserted at the first two, middle two, or last two positions; in response to n being 3, the vector can be inserted at the first three or last three positions; and in response to n being 6, a vector can be inserted at each of the 6 insertion positions.

[0104] It should be noted that, as shown in Figure 4, the final triplet hint includes plain text from the template, vectors from the vector lookup table, and entities. These inserted vectors are represented in Figure 4 as [SP]1, ..., [SP], respectively. j 、...、[SP]4 refers to , where j takes the value of a positive integer. After the final triplet prompts are input into the pre-trained language model, the plain text needs to be converted into the corresponding vocabulary vector by the vocabulary of the pre-trained language model, while the inserted vectors do not need to go through this step. They are directly concatenated with the obtained vocabulary vectors and input into the next layer of the pre-trained language model.

[0105] The process of generating additional information prompts will be described below through step 303.

[0106] 303. The computer device obtains the descriptive information of the entities included in the triple, and based on the sentence template corresponding to the obtained descriptive information, converts the entities included in the triple and the obtained descriptive information into second-class data.

[0107] In this embodiment of the application, in order to achieve better knowledge graph completion results, in addition to the information of the triples themselves, this embodiment of the application also fully considers various additional information, such as entity description information. For example, entity description information includes, but is not limited to, entity definition information and attribute information.

[0108] The first point to note is that, in this application's embodiments, only a corresponding sentence template needs to be designed for each type of additional information to easily introduce various types of additional information without changing the model structure. In some embodiments, the descriptive information of the entities included in the triple is obtained, and based on the sentence template corresponding to the entity's descriptive information, the entities and descriptive information are transformed into a second type of data, including at least one of the following:

[0109] 3031. Obtain the definition information of the entities included in the triplet, fill the entities and definition information into the sentence template corresponding to the definition information, and obtain the second type of data.

[0110] The second point to note is that the entity here includes both the head entity and the tail entity of the triple. In some other embodiments, the template for entity definition information is "[Entity]:[DefinitionText]". For a triple (h,r,t), after obtaining the definition information of h and t respectively, it is only necessary to replace [Entity] and [Definition Text] in the template with the entity and the corresponding definition information.

[0111] 3032. Obtain the attribute information of the entities included in the triple, and fill the entity, attribute information, and attribute type corresponding to the attribute information into the sentence template corresponding to the attribute information to obtain the second type of data.

[0112] In other embodiments, for the attribute information of an entity, the design template is "The[Attribute]of[Entity]is[Value]". For a triple (h,r,t), after obtaining the attribute information of h and t respectively, it is only necessary to replace [Entity], [Attribute] and [Value] in the template with the entity, the corresponding attribute (the attribute type mentioned above), and the attribute value (the attribute information mentioned above) respectively.

[0113] In other embodiments, an entity may have multiple attribute information. For simplicity, this application embodiment will randomly select one of the attribute information to generate corresponding additional information prompts.

[0114] For example, referring to Figure 4, for a triple (James, member of sports team, teamA), the definition hint for the head entity "James" could be "James: basketball player.", and the attribute hint could be "The sport number of James is 23."; for the tail entity "teamA", the definition hint could be "teamA: professional basketball team.", and the attribute hint could be "The founding tear of teamA is 1947."

[0115] In summary, regarding the model, based on pre-set sentence templates, triples can be transformed into grammatically correct triple hints and additional information hints. Therefore, triple hints and additional information hints can fully utilize the massive parameterized knowledge in the pre-trained language model. In addition, adding vectors and additional information can improve the model's performance. The knowledge graph completion model trained based on the above can accurately determine triples, thereby achieving better knowledge graph completion results.

[0116] 304. The computer equipment trains the model based on the first type of data and the second type of data corresponding to multiple triples in the first sample set to obtain a knowledge graph completion model.

[0117] For example, in this embodiment of the application, positive and negative example classification training is performed on existing triples in the knowledge graph. In this embodiment of the application, the first type of negative example triples in the training set are also controlled by setting the parameter α. Second type negative triplet The proportion. Among them,

[0118]

[0119] Furthermore, the embodiments of this application also control the overall ratio of positive and negative examples in the training set through the parameter K, i.e., |T|=K·|T - For example, α = 0.5, K = 30.

[0120] In some embodiments, for a triple τ = (h, r, t) in the training set, its classification score is:

[0121] s τ =Softmax(Wc)

[0122] As shown in Figure 4, c is the output corresponding to the input [CLS] of the pre-trained language model; W is a linear neural network. In some embodiments, the loss function used to train the knowledge graph completion model can be defined as:

[0123]

[0124] Among them, y τ ∈[0,1] are the labels for triplet τ, where 1 represents that triplet τ is correct (positive triplet) and 0 represents that triplet τ is incorrect (negative triplet); s τ This corresponds to the triplet prediction classification result of the final input model in Figure 4. For example, referring to Figure 4, the output c of the pre-trained language model is passed through a linear neural network to obtain this prediction classification result, where... It is s τ The first two dimensions.

[0125] It should be noted that after completing the training of the knowledge graph completion model through steps 301-304 above, the knowledge graph completion task can be performed based on the knowledge graph completion model.

[0126] 305. The computer device determines new triples for the knowledge graph based on the knowledge graph completion model, and adds entities and relations to the knowledge graph based on the new triples.

[0127] For the triple classification task, given any triple, the correctness of the given triple can be determined based on this knowledge graph completion model. Taking the given triple as the first triple as an example, the first triple can be classified based on this knowledge graph completion model, where the first triple does not exist in the knowledge graph; in response to the first classification result indicating that the first triple is a correct triple, the first triple is added to the knowledge graph, that is, new entities and relations are added to the knowledge graph based on the first triple.

[0128] For the link prediction task, for a triple (h, r, ?) where the tail entity is missing, based on the head entity h and relation r, this knowledge graph completion model can predict the tail entity for this triple (also known as the second triple), and then add the second triple with the missing tail entity to the knowledge graph. In other words, based on the second triple with the missing tail entity, new entities and relations are added to the knowledge graph. For example, the tail entity here is the tail entity with the highest probability predicted by the knowledge graph completion model.

[0129] It should be noted that the meaning of the tail entity with the highest probability is as follows: for a triple (h, r, ?), each entity in the entity set is treated as a tail entity to form different triples; then, these triples are classified based on the knowledge graph completion model, that is, the correctness of these triples is predicted based on the knowledge graph completion model, and the triple with the highest probability is determined based on the prediction results. The tail entity included in this triple is the tail entity with the highest probability.

[0130] This embodiment uses a first sample set as the training set for model training. The first sample set includes triples from the knowledge graph. That is, this embodiment constructs a training set based on existing structured knowledge in the knowledge graph for model training, eliminating the need for additional training set generation and saving significant manpower. Furthermore, this embodiment combines pre-generated sentence templates, vectors, and entity descriptions to transform the triples in the training set into two different forms, resulting in first-class and second-class data. Since these two types of data are not only rich in content but also grammatically correct, model training based on them can fully utilize the massive parameterized knowledge of the pre-trained language model and improve model performance. Based on this knowledge graph completion model, new triples can be accurately determined for the knowledge graph, meaning it can complete unknown but correct knowledge in the knowledge graph, thus significantly improving the accuracy of the completed knowledge graph.

[0131] In other embodiments, this application also proposes a method for evaluating knowledge graph completion under the open-world assumption.

[0132] For the triple classification task in knowledge graph completion, the evaluation process includes the following steps:

[0133] 1-1. Obtain a second sample set that has not been manually labeled; wherein the second sample set contains more negative triplets than positive triplets.

[0134] The second sample set is either a validation set or a test set. In other words, this embodiment evaluates the trained knowledge graph completion model based on the validation set and the test set. Specifically, this embodiment obtains a validation set and a test set that have not been manually verified; these sets contain positive triples and negative triples that are several times the number of positive triples.

[0135] It should be noted that positive triplets that have not been manually verified may be either genuine positive triplets or fake positive triplets (i.e., negative triplets); negative triplets that have not been manually verified may be either genuine negative triplets or fake negative triplets (i.e., positive triplets).

[0136] 1-2. Determine candidate negative triples from the negative triples included in the second sample set; wherein the number of candidate negative triples is the same as the number of positive triples in the second sample set, and the candidate negative triples are negative triples that have been manually labeled.

[0137] In some embodiments, this application randomly samples negative triples and performs manual judgment. Those negative triples determined to be true are added to the candidate negative triple pool as candidate negative triples. The entire process continues until the number of candidate negative triples in the candidate pool is the same as the number of positive triples.

[0138] For example, the positive example triples and the candidate negative example triples in the candidate pool form the final validation set and test set. The final validation set or test set is referred to as the third sample set in this embodiment of the application.

[0139] 1-3. Based on the knowledge graph completion model, classify the triples included in the third sample set; wherein the third sample set includes candidate negative triples and positive triples in the second sample set; based on the obtained classification results (also known as the second classification results), obtain the first evaluation data of the knowledge graph completion model.

[0140] For example, the second classification result described above can be the classification score for each triple in the third sample set, and this application does not impose any limitations on this. Furthermore, embodiments of this application use the F1 score as an evaluation metric to generate the first evaluation data.

[0141] in,

[0142] TP means predicting a positive example as a positive example, FN means predicting a positive example as a negative example, FP means predicting a negative example as a positive example, and TN means predicting a negative example as a negative example.

[0143] For the link prediction task in knowledge graph completion, the evaluation process includes the following steps:

[0144] 2-1. Obtain the fourth sample set; for any triple in the fourth sample set, based on the head entity and relation included in the triple, predict new tail entities for the triple using the knowledge graph completion model to obtain a new triple.

[0145] The fourth sample set is the test set. It should be noted that if the number of triples in the test set is enormous, triples can be sampled from the test set first, and the evaluation can be performed based on the sampled triples. This embodiment of the application does not impose such limitations. For example, the fourth sample set is a sample set composed of sampled triples.

[0146] In some embodiments, based on the head entity and relation included in the triple, a new tail entity is predicted for the triple using a knowledge graph completion model to obtain a new triple. This includes: deleting the original tail entity of the triple and using each entity in the entity set as a tail entity to form different triples; then, classifying these triples based on the knowledge graph completion model, that is, predicting the correctness of these triples based on the knowledge graph completion model, and determining the triple with the highest probability among these triples based on the prediction results. This triple is the new triple, and the corresponding entity is the new tail entity.

[0147] 2-2. Obtain the classification results of the new triples (also known as the third classification results), where the third classification results are obtained based on manual annotation; based on the third classification results, obtain the second evaluation data of the knowledge graph completion model.

[0148] For link prediction tasks, this application proposes a manual verification-based evaluation method. That is, after determining a new triplet, its correctness needs to be manually verified. For example, given a triplet (h, r, t), it is transformed into a triplet (h, r, ?). Assuming the knowledge graph completion model predicts the tail entity with the highest probability as t', then the correctness of the triplet (h, r, t') needs to be manually judged. Exemplarily, if the triplet is correct, its score is 1; otherwise, it is 0.

[0149] Ultimately, we can obtain the following evaluation results:

[0150]

[0151] Here, T refers to the fourth sample set, which is the set of all sampled triples.

[0152] The evaluation method proposed in this application under the open-world assumption can more accurately evaluate the performance of knowledge graph completion models. Furthermore, the knowledge graph completion method based on a pre-trained language model proposed in this application can achieve better results under both the closed-world and open-world assumptions.

[0153] For example, the effectiveness of knowledge graph completion was verified on datasets based on Freebase and Wikidata, covering two tasks: link prediction and triple classification, and two hypotheses: closed world and open world. Figure 5 shows the performance of the knowledge graph completion model (PKGC, PLM-based KGC Model) proposed in this application on the link prediction task, where CR@1 is the evaluation metric under the open world hypothesis; MRR (Mean Reciprocal Rank, a mechanism for evaluating search algorithms), @1, @3, and @10 are the evaluation metrics under the closed world hypothesis.

[0154] Here, @1, @3, and @10 originate from the model evaluation metric HITS@n, which refers to the average proportion of triples ranked less than or equal to n in the link prediction task, where n is a positive integer. Generally, n takes the value of 1, 3, or 10, and a higher value for HITS@n is better. That is, @1 above is essentially HITS@1, @3 above is essentially HITS@3, and @10 above is essentially HITS@10.

[0155] As shown in Figure 5, the knowledge graph completion model proposed in this application outperforms existing models under both closed-world and open-world assumptions. Furthermore, under the open-world assumption, the performance advantage of the knowledge graph completion model proposed in this application is even greater.

[0156] For example, Figure 6 shows the performance of the knowledge graph completion model proposed in this application on the triple classification task. The numbers before and after the slashes represent the evaluation results under the closed-world and open-world assumptions, respectively. As can be seen from Figure 6, the knowledge graph completion model proposed in this application significantly outperforms existing models under both assumptions.

[0157] It should be noted that in Figures 5 and 6, Wiki27K, FB15K-237-N, and FB15K-237-N refer to different datasets. Additionally, in Figures 5 and 6, PKGC refers to a knowledge graph completion model without any added information; PKGC refers to a knowledge graph completion model without any added information; PKGC w / attribute refers to a knowledge graph completion model with added attribute information; and PKGC w / definition refers to a knowledge graph completion model with added definition information.

[0158] In summary, the embodiments of this application significantly improve the performance of the knowledge graph completion method based on pre-trained language models, and effectively improve the evaluation method of knowledge graph completion models.

[0159] In other embodiments, the additional information involved in the embodiments of this application is not limited to definition information and attribute information, but may also include other types of information, only requiring the setting of corresponding templates.

[0160] Figure 7 is a schematic diagram of a knowledge graph completion device provided in an embodiment of this application. Referring to Figure 7, the device includes:

[0161] The acquisition module 701 is configured to acquire a first sample set, the first sample set including triples in a knowledge graph, the triples representing the relationships between entities in the knowledge graph;

[0162] The first processing module 702 is configured to, for any triple in the first sample set, determine the sentence template corresponding to the relation included in the triple, convert the triple into a statement based on the sentence template corresponding to the relation, insert a vector into the statement, and obtain the first type of data;

[0163] The second processing module 703 is configured to obtain the descriptive information of the entities included in the triple, and convert the entities and the descriptive information into a second type of data based on the sentence template corresponding to the descriptive information;

[0164] Training module 704 is configured to train the model based on the first type of data and the second type of data corresponding to multiple triples in the first sample set to obtain a knowledge graph completion model.

[0165] The third processing module 705 is configured to determine new triples for the knowledge graph based on the knowledge graph completion model, and to add entities and relations to the knowledge graph based on the new triples.

[0166] This embodiment uses a first sample set as the training set for model training. The first sample set includes triples from the knowledge graph. That is, this embodiment builds the training set based on existing structured knowledge in the knowledge graph for model training, eliminating the need for additional training set generation and saving significant manpower. Furthermore, this embodiment combines pre-generated sentence templates, vectors, and entity descriptions to transform the triples in the training set into two different forms, resulting in first-class data and second-class data. Since these two types of data are not only rich in content but also grammatically correct, training the model based on these two types of data yields a high-performance knowledge graph completion model. This knowledge graph completion model can accurately determine new triples for the knowledge graph, thus completing unknown but correct knowledge, significantly improving the accuracy of the completed knowledge graph.

[0167] In some embodiments, the first processing module 702 is configured to:

[0168] The head entity of the triple is filled into the first position of the sentence template, and the tail entity of the triple is filled into the second position of the sentence template to obtain the sentence;

[0169] Based on the relations included in the triples, a preset number of vectors are obtained from the vector lookup table; wherein, the vector lookup table is used to store vectors corresponding to various relations;

[0170] According to the determined insertion positions and the number of vectors to be inserted at each insertion position, the preset number of vectors are inserted into the corresponding positions of the statement to obtain the first type of data.

[0171] In some embodiments, the second processing module 703 is configured to perform at least one of the following:

[0172] Obtain the definition information of the entities included in the triplet, and fill the entities and the definition information into the sentence template corresponding to the definition information to obtain the second type of data;

[0173] Obtain the attribute information of the entities included in the triplet, and fill the entity, the attribute information, and the attribute type corresponding to the attribute information into the sentence template corresponding to the attribute information to obtain the second type of data.

[0174] In some embodiments, the first sample set includes positive triples and negative triples, wherein the positive triples are triples in the knowledge graph, and the negative triples are obtained based on the positive triples;

[0175] The negative example triplet includes a first type of negative example triplet and a second type of negative example triplet;

[0176] The first type of negative triplet is obtained by randomly replacing the head entity or tail entity included in the positive triplet with other entities;

[0177] The second type of negative triple is obtained by replacing the head entity included in the positive triple with a first candidate entity; the first candidate entity is predicted based on the tail entity and relation included in the positive triple; or, the second type of negative triple is obtained by replacing the tail entity included in the positive triple with a second candidate entity; the second candidate entity is predicted based on the head entity and relation included in the positive triple.

[0178] In some embodiments, the evaluation process of the knowledge graph completion model includes:

[0179] Obtain a second sample set that is not manually labeled, which contains more negative triplets than positive triplets;

[0180] Candidate negative triples are determined from the negative triples included in the second sample set. The number of candidate negative triples is the same as the number of positive triples in the second sample set. The candidate negative triples are negative triples that have been manually labeled.

[0181] Based on the knowledge graph completion model, the triples included in the third sample set are classified to obtain the second classification result; wherein, the third sample set includes the candidate negative triples and the positive triples in the second sample set;

[0182] Based on the second classification result, the first evaluation data of the knowledge graph completion model is obtained.

[0183] In some embodiments, the evaluation process of the knowledge graph completion model includes:

[0184] Obtain the fourth sample set; for any triple in the fourth sample set, based on the head entity and relation included in the triple, predict a new tail entity for the triple using the knowledge graph completion model to obtain a new triple;

[0185] Obtain the third classification result of the new triplet, which is based on manual annotation; based on the third classification result, obtain the second evaluation data of the knowledge graph completion model.

[0186] All of the above-mentioned optional technical solutions can be combined in any way to form optional embodiments of this disclosure, and will not be described in detail here.

[0187] It should be noted that the knowledge graph completion device provided in the above embodiments is only illustrated by the division of the above functional modules when performing knowledge graph completion. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the knowledge graph completion device and the knowledge graph completion method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0188] Figure 8 is a schematic diagram of a computer device 800 provided in an embodiment of this application. The computer 800 can be a server. The computer device 800 can vary significantly due to different configurations or performance, and may include one or more Central Processing Units (CPUs) 801 and one or more memories 802. The memory 802 stores at least one line of program code, which is loaded and executed by the processor 801 to implement the knowledge graph completion method provided in the above-described method embodiments. Of course, the computer device 800 may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The computer device 800 may also include other components for implementing device functions, which will not be elaborated here.

[0189] In an exemplary embodiment, this application also provides a computer-readable storage medium, such as a memory including program code, which can be executed by a processor in a computer device to complete the knowledge graph completion method in the above embodiments. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.

[0190] In an exemplary embodiment, this application also provides a computer program product or computer program, which includes computer program code stored in a computer-readable storage medium. The processor of a computer device reads the computer program code from the computer-readable storage medium and executes the computer program code, causing the computer device to perform the knowledge graph completion method described above.

[0191] In an exemplary embodiment, the computer program involved in the embodiments of this application may be deployed and executed on a computer device, or executed on multiple computer devices located in one location, or executed on multiple computer devices distributed in multiple locations and interconnected through a communication network. Multiple computer devices distributed in multiple locations and interconnected through a communication network may constitute a blockchain system.

[0192] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0193] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A knowledge graph completion method, characterized in that, The method includes: acquiring a first sample set, the first sample set including triples in a knowledge graph, the triples representing relationships between entities in the knowledge graph; for any triple in the first sample set, determining a sentence template corresponding to the relationship included in the triple, and converting the triple into a statement based on the sentence template corresponding to the relationship; acquiring a preset number of vectors in a vector lookup table based on the relationship included in the triple; wherein the vector lookup table is used to store vectors corresponding to various types of relationships; inserting the preset number of vectors into the corresponding positions of the statement according to a determined insertion position and the number of vectors inserted at each insertion position, to obtain a first type of data; acquiring descriptive information of the entities included in the triple, and converting the entities and the descriptive information into a second type of data based on the sentence template corresponding to the descriptive information; training a model based on the first type of data and the second type of data corresponding to multiple triples in the first sample set to obtain a knowledge graph completion model; determining new triples for the knowledge graph based on the knowledge graph completion model, and adding entities and relationships to the knowledge graph based on the new triples.

2. The method according to claim 1, characterized in that, The step of converting the triplet into a statement based on the sentence template corresponding to the relation includes: filling the head entity of the triplet into a first position of the sentence template, and filling the tail entity of the triplet into a second position of the sentence template to obtain the statement.

3. The method according to claim 1, characterized in that, The step of obtaining the descriptive information of the entities included in the triplet, and converting the entities and the descriptive information into second type data based on the sentence template corresponding to the descriptive information, includes at least one of the following: obtaining the definition information of the entities included in the triplet, filling the entities and the definition information into the sentence template corresponding to the definition information to obtain the second type of data; obtaining the attribute information of the entities included in the triplet, filling the entities, the attribute information, and the attribute types corresponding to the attribute information into the sentence template corresponding to the attribute information to obtain the second type of data.

4. The method according to claim 1, characterized in that, The first sample set includes positive triples and negative triples. The positive triples are triples in the knowledge graph, and the negative triples are obtained based on the positive triples. The negative triples include a first type of negative triple and a second type of negative triple. The first type of negative triple is obtained by randomly replacing the head or tail entity included in the positive triple with other entities. The second type of negative triple is obtained by replacing the head entity included in the positive triple with a first candidate entity. The first candidate entity is predicted based on the tail entity and relation included in the positive triple. Alternatively, the second type of negative triple is obtained by replacing the tail entity included in the positive triple with a second candidate entity. The second candidate entity is predicted based on the head entity and relation included in the positive triple.

5. The method according to any one of claims 1 to 4, characterized in that, The evaluation process of the knowledge graph completion model includes: obtaining a second sample set that has not been manually labeled, wherein the second sample set contains more negative triples than positive triples; identifying candidate negative triples from the negative triples in the second sample set, wherein the number of candidate negative triples is the same as the number of positive triples in the second sample set, and the candidate negative triples are manually labeled negative triples; classifying the triples in a third sample set based on the knowledge graph completion model to obtain a second classification result; wherein the third sample set includes the candidate negative triples and the positive triples in the second sample set; and obtaining the first evaluation data of the knowledge graph completion model based on the second classification result.

6. The method according to any one of claims 1 to 4, characterized in that, The evaluation process of the knowledge graph completion model includes: obtaining a fourth sample set; for any triple in the fourth sample set, based on the head entity and relation included in the triple, predicting a new tail entity for the triple using the knowledge graph completion model to obtain a new triple; obtaining the third classification result of the new triple, which is based on manual annotation; and obtaining the second evaluation data of the knowledge graph completion model based on the third classification result.

7. A knowledge graph completion device, characterized in that, The apparatus includes: an acquisition module configured to acquire a first sample set, the first sample set including triples in a knowledge graph, the triples representing relationships between entities in the knowledge graph; and a first processing module configured to, for any triple in the first sample set, determine a sentence template corresponding to the relationship included in the triple, convert the triple into a statement based on the sentence template corresponding to the relationship, and acquire a preset number of vectors from a vector lookup table based on the relationship included in the triple; wherein the vector lookup table is used to store vectors corresponding to various types of relationships; and insert a vector according to a determined insertion position and the vector corresponding to each insertion position. The first processing module is configured to: insert a preset number of vectors into the corresponding positions of the statement to obtain a first type of data; a second processing module is configured to: obtain the descriptive information of the entities included in the triples, and convert the entities and the descriptive information into a second type of data based on the sentence template corresponding to the descriptive information; a training module is configured to: train a model based on the first type of data and the second type of data corresponding to multiple triples in the first sample set to obtain a knowledge graph completion model; and a third processing module is configured to: determine new triples for the knowledge graph based on the knowledge graph completion model, and add entities and relations to the knowledge graph based on the new triples.

8. A computer device, characterized in that, The device includes a processor and a memory, the memory storing at least one piece of program code, the at least one piece of program code being loaded and executed by the processor to implement the knowledge graph completion method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The storage medium stores at least one piece of program code, which is loaded and executed by a processor to implement the knowledge graph completion method as described in any one of claims 1 to 6.

10. A computer program product or computer program, characterized in that, The computer program product or computer program includes computer program code stored in a computer-readable storage medium, a processor of a computer device reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code, causing the computer device to perform the knowledge graph completion method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Knowledge graph completion method and system

    CN113569062A

  • Zero sample knowledge graph completion method based on ontology adapter

    CN113987201A