A knowledge graph prediction method, system, device and medium
By constructing evaluation functions and minimizing objective functions, using the interaction between entities and relationships to model complex relationships, the problem of inability to accurately represent one-to-many, many-to-one and many-to-many relationships in the existing technology is solved, and efficient prediction of the knowledge graph is achieved.
Patent Information
- Application Number
- CN202210381630.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-12
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-04-12
AI Technical Summary
Existing knowledge representation learning methods cannot take into account the precise representation of complex relationships such as one-to-many, many-to-one and many-to-many between entities and the linking patterns of modeling graphs.
By obtaining the original triple dataset of the knowledge graph, processing triples are used to construct evaluation functions, and modeling complex relationships using the interaction between entities and relationships, learning the optimal embedding vector representation of entities and relationships by minimizing the objective function, selecting the triple with the highest score as the best prediction result.
It realizes accurate modeling of complex relationships and relationship connection patterns, can obtain complex semantics between entities and relationships, and improves the prediction accuracy of the knowledge graph.
Smart Images

Figure CN116561328B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a knowledge graph prediction method, system, device and medium. Background Art
[0002] With the advent of the Web 3.0 era, the way data is generated has undergone a dramatic transformation. Data generation has shifted from passive operational methods to active perception methods. The amount of information generated daily on the internet is exploding. Therefore, discovering valuable information from this massive amount of data to meet personalized user needs and filtering out valid information from this vast amount of data has become a challenging task. Knowledge graphs, which store this vast amount of knowledge, have emerged as a means to address this challenge.
[0003] A knowledge graph is a graph-like structure. People or things that represent entities in the real world (for example, food, animals, people, place names, etc.) are abstracted as nodes in the knowledge graph structure, and the internal connections (edges) between nodes are represented as relationships between entities. Ultimately, the knowledge in the knowledge graph is stored in the form of triples (head entity, relationship, tail entity). For example, the knowledge "The author of "Romance of the Three Kingdoms" is Luo Guanzhong" can be represented as ("Romance of the Three Kingdoms", author, Luo Guanzhong). Knowledge graphs can express complex semantic information between complex multi-relational data in the real world and are widely used in personalized recommendations, intelligent question answering, information retrieval and other fields. However, the number of entities and relationships in the real world is huge, and it is impossible to enumerate all knowledge. Therefore, automatic completion of knowledge graphs through artificial intelligence algorithms is a current research hotspot.
[0004] Because existing AI algorithms typically use numerical data as input, existing symbolic representation methods for knowledge graphs cannot be directly applied to AI algorithms. Representation learning, which maps entities and relationships into vector spaces, has made significant progress in recent years. However, existing knowledge representation learning methods are unable to accurately represent complex relationships between entities, such as one-to-many, many-to-one, and many-to-many, as well as the link patterns of modeling graphs. Summary of the Invention
[0005] In view of the shortcomings of the prior art described above, the purpose of the present invention is to provide a knowledge graph prediction method, system, device and medium to solve the problem that the knowledge representation learning method in the prior art cannot accurately represent complex relationships such as one-to-many, many-to-one and many-to-many between entities and the link pattern of the modeling graph.
[0006] A first aspect of the present invention provides a knowledge graph prediction method, comprising: obtaining an original triple dataset of the knowledge graph, wherein each original triple includes a head entity, a relationship, and a tail entity;
[0007] Processing each of the original triples to obtain an evaluation function, and constructing a boundary-based objective function based on the evaluation function;
[0008] By minimizing the objective function, the representation of entity vectors and relation vectors in each triple is learned to obtain a candidate triple dataset;
[0009] Sequentially extracting candidate entities and candidate relations from the candidate triple dataset, constructing multiple candidate triples, and substituting each candidate triple into an evaluation function to obtain a corresponding score;
[0010] The scores are sorted and the triplet with the highest score is selected as the best prediction result.
[0011] In one embodiment of the present invention, the step of processing each of the original triples to obtain an evaluation function includes:
[0012] Constructing new triples according to the entity vectors and the relationship vectors in each of the original triples;
[0013] translating the head entity in the new triple, and calculating a first distance between the translated head entity and the tail entity in the original triple;
[0014] translating the tail entity in the new triple, and calculating a second distance between the translated tail entity and the head entity in the original triple;
[0015] The sum of the first distance and the second distance constitutes an evaluation function.
[0016] In one embodiment of the present invention, the step of constructing a new triple based on the entity vector and the relationship vector in each triple includes:
[0017]
[0018] Where h represents the original vector representation of the head entity; r represents the vector representation of the relationship between the triplet and the head entity; The operator represents element-wise vector multiplication; h c A new vector representation of the head entity;
[0019]
[0020] Where t represents the original vector representation of the tail entity; r represents the vector representation of the relationship between the triplet and the head entity; The operator represents element-wise vector multiplication; t c A new vector representation representing the tail entity.
[0021] In one embodiment of the present invention, the step of translating the head entity in the new triple and calculating the first distance between the translated head entity and the tail entity in the original triple includes:
[0022] S h =||h c +-||2;
[0023] Among them, S h Indicates the first distance; h c represents the vector representation of the head entity after translation; r represents the vector representation of the relationship of the triple used to interact with the head entity; t represents the vector representation of the tail entity in the original triple; ||·||2 represents the L2 norm.
[0024] In one embodiment of the present invention, the step of translating the tail entity in the new triple and calculating the second distance between the translated tail entity and the head entity in the original triple includes:
[0025] S t =||t c +-||2;
[0026] Among them, S t represents the second distance; t c represents the vector representation of the translated tail entity; r represents the vector representation of the relationship between the triplet and the head entity; h represents the vector representation of the head entity in the original triplet; ||·||2 represents the L2 norm.
[0027] In one embodiment of the present invention, the step of constructing a boundary-based objective function based on the evaluation function includes:
[0028]
[0029] in, represents the objective function; V + Represents the positive sample set of triples; V - represents the negative sample set of triples; γ represents the fixed hyperparameter of the positive and negative sample segmentation boundary; S represents the distance between two positive samples; S′ represents the distance between two negative samples;
[0030] The expression of the evaluation function is:
[0031] S=S h +S t ;
[0032] Among them, S h Indicates the first distance; S t Indicates the second distance.
[0033] In one embodiment of the present invention, the step of learning the representation of the entity vector and the relationship vector in each triple by minimizing the objective function includes:
[0034] According to the direction of objective function reduction, the representation of entity vector and relationship vector in triple is iteratively updated until the number of iterations is completed and the optimal entity vector and relationship vector are obtained.
[0035] A second aspect of the present invention further provides a knowledge graph prediction system, comprising:
[0036] An acquisition module is used to obtain the original triple dataset of the knowledge graph, where each original triple includes a head entity, a relationship, and a tail entity;
[0037] a vector processing module, configured to process each of the original triples to obtain an evaluation function, and construct a boundary-based objective function based on the evaluation function;
[0038] The update module is used to minimize the objective function, learn the representation of entity vectors and relationship vectors in each triple, and obtain the candidate triple dataset;
[0039] The prediction module is used to sequentially extract candidate entities and candidate relationships from the candidate triple data set, construct multiple candidate triples, substitute each candidate triple into the evaluation function to obtain a corresponding score; sort the scores, and select the triple with the highest score as the best prediction result.
[0040] The third aspect of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, the method steps described in the knowledge graph prediction method of the first aspect of the present invention are implemented.
[0041] The fourth aspect of the present invention also provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the method steps described in the knowledge graph prediction method of the first aspect of the present invention are implemented.
[0042] As described above, the knowledge graph prediction method, system, device, and medium of the present invention have the following beneficial effects:
[0043] This method uses the interaction between entity vectors and relationship vectors in triples to model complex relationships such as one-to-many, many-to-one, and many-to-many. It uses two translations of the head and tail entities to model symmetric and inverse relationships. It then defines an evaluation function to measure the legitimacy of the triples. By minimizing the objective function, it learns the optimal embedding vector representations of entities and relationships, resulting in optimal predictions for both entity and relationship vectors. This method can simultaneously model complex relationships and relationship connection patterns, accurately capturing the complex semantics between entities and relationships. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0045] Figure 1 It is a schematic flow chart of the prediction method in the first embodiment of the present invention.
[0046] Figure 2 Shown is a schematic diagram of a one-to-many relationship in the first embodiment of the present invention.
[0047] Figure 3 It is a schematic diagram showing the symmetrical relationship in the first embodiment of the present invention.
[0048] Figure 4 It is a schematic diagram of the process of obtaining the evaluation function in the first embodiment of the present invention.
[0049] Figure 5 Shown is a structural block diagram of a prediction system in a second embodiment of the present invention.
[0050] Figure 6 FIG. 1 is a schematic diagram of a computer device according to a third embodiment of the present invention. DETAILED DESCRIPTION
[0051] The following describes the embodiments of the present invention through specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments. The details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other unless they conflict.
[0052] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention. Therefore, the figures only show components related to the present invention and are not drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component can be changed at will, and the component layout type may also be more complicated.
[0053] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to achieve optimal results.
[0054] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0055] See also Figure 1 The first embodiment of the present invention relates to a knowledge graph representation learning method, specifically comprising:
[0056] Step S101: Obtain the original triple dataset of the knowledge graph.
[0057] Specifically, a knowledge graph is a graph structure that includes nodes representing entities and edges describing the relationships between entities. There is a one-to-one correspondence between nodes and entities. A knowledge graph may include one or more relationships, that is, one or more types of edges. According to the positional relationship between entities and edges, the entity corresponding to the starting node of an edge is called the head entity, and correspondingly, the node pointed to by the edge is called the tail entity, and they form a triple. The knowledge graph not only contains complex relationships such as one-to-many, many-to-one, and many-to-many, but also connection patterns such as symmetric relationships, inverse relationships, combination relationships, and antisymmetric relationships. For example Figure 2 An example of a one-to-many relationship is given in Figure 2 In the example, multiple entities "China", "Beijing", "Shanghai", "Tianjin" and "Chongqing" are given. The relationship between the head entity "China" and the tail entities "Beijing", "Shanghai", "Tianjin" and "Chongqing" is "Municipality". Figure 3 An example of a symmetrical relationship pattern is given. The relationship between entities "Zhang San" and "Li Si" is "friends", where "Zhang San" can be the head entity or the tail entity, and vice versa.
[0058] Continuing to explain, the triple data set in this embodiment can be obtained through an open source knowledge graph database, or it can be obtained by self-statistication as needed. It should be understood that the triple data set is constructed based on the category to which each entity belongs under a specific relationship; in addition, the triple data set includes multiple triples, and the entities and relationships in each triple are represented in the form of vectors. Further, the triple data set includes positive samples and negative samples, wherein the positive samples can be obtained through an open source knowledge graph database. In order to increase the training samples, the entities in the positive samples are used to replace the head entity or the tail entity in the triple one by one. For example, there are three entities e1, e2 and e3 in the knowledge graph, and a relationship r, which constitutes two positive sample triplets (e1, r, e2) and (e2, r, e3). By replacing e2 with e3, a negative sample (e1, r, e3) that does not exist in the original knowledge graph is generated. It is also possible to replace e1 with e3 to generate a negative sample (e3, r, e3) that does not exist in the original knowledge graph.
[0059] Step S102: Process each original triple to obtain an evaluation function, and construct a boundary-based objective function based on the evaluation function.
[0060] See also Figure 4 , the steps of processing each original triple and obtaining the evaluation function include:
[0061] Step S401: construct new triples based on the entity vectors and relationship vectors in each original triple.
[0062] For an original triple (h, r, t), the differences between the head entities are captured through the interaction between the head entity and the relationship, and a new vector representation of the head entity is obtained, which is expressed as:
[0063]
[0064] Where h represents the original vector representation of the head entity; r represents the vector representation of the relationship between the triplet and the head entity; The operator represents element-wise vector multiplication; h c A new vector representation representing the head entity.
[0065] For an original triple (h, r, t), the differences between the tail entities are captured through the interaction between the tail entities and the relations, and a new vector representation of the tail entity is obtained, which is expressed as:
[0066]
[0067] Where t represents the original vector representation of the tail entity; r represents the vector representation of the relationship between the triplet and the head entity; The operator represents element-wise vector multiplication; t cA new vector representation representing the tail entity.
[0068] The above scheme is adopted to use two interactions between entities and relationships to model complex relationships such as one-to-many, many-to-one and many-to-many. The new triple vector after modeling is expressed as (h c , r, t c ).
[0069] Step S402: Shift the head entity in the new triplet, and calculate the first distance between the shifted head entity and the tail entity in the original triplet.
[0070] Step S403: Shift the tail entity in the new triplet, and calculate the second distance between the shifted tail entity and the head entity in the original triplet.
[0071] Specifically, the new triple vector is represented as (h c , r, t c ), translate the head entity in the new triplet to the tail entity, and calculate the first distance between the translated head entity and the tail entity in the original triplet, the expression is:
[0072] S h =||h c +-||2;
[0073] Among them, S h Indicates the first distance; h c represents the vector representation of the head entity after translation; r represents the vector representation of the relationship of the triple used to interact with the head entity; t represents the vector representation of the tail entity in the original triple; ||·||2 represents the L2 norm.
[0074] The tail entity in the new triple is translated toward the head entity, and the second distance between the translated tail entity and the head entity in the original triple is calculated. The expression is:
[0075] S t =||t c +-||2;
[0076] Among them, S t represents the second distance; t c represents the vector representation of the translated tail entity; r represents the vector representation of the relationship between the triplet and the head entity; h represents the vector representation of the head entity in the original triplet; ||·||2 represents the L2 norm.
[0077] Step S404: The sum of the first distance and the second distance constitutes an evaluation function S, which is used to describe the distances between the head entity, the tail entity, and the relationship in the new triple. The expression is:
[0078] S=h +S t .
[0079] Continuing to explain, a boundary-based objective function is constructed based on the evaluation function, where the expression of the objective function is:
[0080]
[0081] in, represents the objective function; V + Represents the positive sample set of triples; V - represents the set of negative samples in a triplet; γ represents a fixed hyperparameter for the positive-negative sample segmentation boundary; S represents the distance between two positive samples; and S′ represents the distance between two negative samples. It should be understood that the objective function is positively correlated with the sum of the distances between the two positive samples and negatively correlated with the sum of the distances between the two negative samples.
[0082] Step S103: By minimizing the objective function, the representation of the entity vector and the relationship vector in each triple is learned to obtain a set of candidate triples.
[0083] Specifically, the objective function is minimized, that is, through existing neural network learning algorithms, such as the optimization method of stochastic gradient descent, repeating the above steps, iteratively updating the representation of the entity vector and relationship vector in the triplet according to the direction of the objective function reduction, so that the sum of the distances between the two positive samples becomes smaller and smaller, while the sum of the distances between the two negative samples becomes larger and larger, until the number of iterations is completed or the objective function reaches a preset minimum value, and the optimal entity vector and relationship vector are obtained. Furthermore, in the above iterative process, the relationship vector can be trained first, and the optimal relationship vector obtained in each iteration replaces the relationship vector in the original triplet; then, the trained relationship vector is fixed, and the head entity vector and tail entity vector are further trained. The trained entity vector and relationship vector constitute the candidate triplet data set.
[0084] Step S104: Extract candidate entities and candidate relations from the candidate triple dataset in sequence, construct multiple candidate triples, substitute each candidate triple into the evaluation function to obtain a corresponding score; sort the scores, and select the triple with the highest score as the best prediction result.
[0085] As can be seen, this embodiment uses the interaction between entity vectors and relationship vectors in triples to model complex relationships such as one-to-many, many-to-one, and many-to-many. It uses two translations of the head and tail entities to model symmetric and inverse relationships. It then defines an evaluation function to measure the legitimacy of the triples, and learns the optimal embedding vector representations of entities and relationships by minimizing the objective function, thereby obtaining the best prediction results for entity vectors and relationship vectors. The present invention can simultaneously consider the modeling of complex relationships and relationship connection patterns, and can accurately capture the complex semantics between entities and relationships.
[0086] See also Figure 5 The second embodiment of the present invention relates to a knowledge graph prediction system, which corresponds to the knowledge graph prediction method disclosed in the first embodiment, and specifically includes:
[0087] The acquisition module is used to obtain the original triple dataset of the knowledge graph.
[0088] Specifically, a knowledge graph is a graph structure that includes nodes representing entities and edges describing the relationships between entities. There is a one-to-one correspondence between nodes and entities. A knowledge graph may include one or more relationships, that is, one or more types of edges. According to the positional relationship between entities and edges, the entity corresponding to the starting node of an edge is called the head entity, and correspondingly, the node pointed to by the edge is called the tail entity, and they form a triple. The knowledge graph not only contains complex relationships such as one-to-many, many-to-one, and many-to-many, but also connection patterns such as symmetric relationships, inverse relationships, combination relationships, and antisymmetric relationships. For example Figure 2 An example of a one-to-many relationship is given in Figure 2 In the example, multiple entities "China", "Beijing", "Shanghai", "Tianjin" and "Chongqing" are given. The relationship between the head entity "China" and the tail entities "Beijing", "Shanghai", "Tianjin" and "Chongqing" is "Municipality". Figure 3 An example of a symmetrical relationship pattern is given. The relationship between entities "Zhang San" and "Li Si" is "friends", where "Zhang San" can be the head entity or the tail entity, and vice versa.
[0089] Continuing to explain, the triple data set in this embodiment can be obtained through an open source knowledge graph database, or it can be obtained by self-statistication as needed. It should be understood that the triple data set is constructed based on the category to which each entity belongs under a specific relationship; in addition, the triple data set includes multiple triples, and the entities and relationships in each triple are represented in the form of vectors. Further, the triple data set includes positive samples and negative samples, wherein the positive samples can be obtained through an open source knowledge graph database. In order to increase the training samples, the entities in the positive samples are used to replace the head entity or the tail entity in the triple one by one. For example, there are three entities e1, e2 and e3 in the knowledge graph, and a relationship r, which constitutes two positive sample triplets (e1, r, e2) and (e2, r, e3). By replacing e2 with e3, a negative sample (e1, r, e3) that does not exist in the original knowledge graph is generated. It is also possible to replace e1 with e3 to generate a negative sample (e3, r, e3) that does not exist in the original knowledge graph.
[0090] The vector processing module is used to process each original triple to obtain an evaluation function, and construct a boundary-based objective function based on the evaluation function.
[0091] Specifically, the steps of processing each original triple to obtain the evaluation function include:
[0092] Step 1: Construct new triples based on the entity vectors and relationship vectors in each original triple.
[0093] For an original triple (h, r, t), the differences between the head entities are captured through the interaction between the head entity and the relationship, and a new vector representation of the head entity is obtained, which is expressed as:
[0094]
[0095] Where h represents the original vector representation of the head entity; r represents the vector representation of the relationship between the triplet and the head entity; The operator represents element-wise vector multiplication; h c A new vector representation representing the head entity.
[0096] For an original triple (h, c, t), the differences between the tail entities are captured through the interaction between the tail entities and the relations, and a new vector representation of the tail entity is obtained, which is expressed as:
[0097]
[0098] Where t represents the original vector representation of the tail entity; r represents the vector representation of the relationship between the triplet and the head entity; The operator represents element-wise vector multiplication; t c A new vector representation representing the tail entity.
[0099] The above scheme is adopted to use two interactions between entities and relationships to model complex relationships such as one-to-many, many-to-one and many-to-many. The new triple vector after modeling is expressed as (h r , r, t c ).
[0100] Step 2: Shift the head entity in the new triplet, and calculate the first distance between the shifted head entity and the tail entity in the original triplet.
[0101] Step 3: Translate the tail entity in the new triplet, and calculate the second distance between the translated tail entity and the head entity in the original triplet.
[0102] Specifically, the new triple vector is represented as (h c , r, t c ), translate the head entity in the new triplet to the tail entity, and calculate the first distance between the translated head entity and the tail entity in the original triplet, the expression is:
[0103] S h =||h c +-||2;
[0104] Among them, S h Indicates the first distance; h c represents the vector representation of the head entity after translation; r represents the vector representation of the relationship of the triple used to interact with the head entity; t represents the vector representation of the tail entity in the original triple; ||·||2 represents the L2 norm.
[0105] The tail entity in the new triple is translated toward the head entity, and the second distance between the translated tail entity and the head entity in the original triple is calculated. The expression is:
[0106] S t =||t c +-||2;
[0107] Among them, S t represents the second distance; t c represents the vector representation of the translated tail entity; r represents the vector representation of the relationship between the triplet and the head entity; h represents the vector representation of the head entity in the original triplet; ||·||2 represents the L2 norm.
[0108] Step 4: The sum of the first distance and the second distance constitutes the evaluation function S, which is used to describe the distance between the head entity, the tail entity, and the relationship in the new triple. Its expression is:
[0109] S= h +S t .
[0110] Continuing to explain, a boundary-based objective function is constructed based on the evaluation function, where the expression of the objective function is:
[0111]
[0112] in, represents the objective function; V + Represents the positive sample set of triples; V - represents the set of negative samples in a triplet; γ represents a fixed hyperparameter for the positive-negative sample segmentation boundary; S represents the distance between two positive samples; and S′ represents the distance between two negative samples. It should be understood that the objective function is positively correlated with the sum of the distances between the two positive samples and negatively correlated with the sum of the distances between the two negative samples.
[0113] The update module is used to minimize the objective function, learn the representation of entity vectors and relation vectors in each triple, and obtain the candidate triple dataset.
[0114] Specifically, the objective function is minimized, that is, through existing neural network learning algorithms, such as the optimization method of stochastic gradient descent, repeating the above steps, iteratively updating the representation of the entity vector and relationship vector in the triplet according to the direction of the objective function reduction, so that the sum of the distances between the two positive samples becomes smaller and smaller, while the sum of the distances between the two negative samples becomes larger and larger, until the number of iterations is completed or the objective function reaches a preset minimum value, and the optimal entity vector and relationship vector are obtained. Furthermore, in the above iterative process, the relationship vector can be trained first, and the optimal relationship vector obtained in each iteration replaces the relationship vector in the original triplet; then, the trained relationship vector is fixed, and the head entity vector and tail entity vector are further trained. The trained entity vector and relationship vector constitute the candidate triplet data set.
[0115] The prediction module is used to extract candidate entities and candidate relations from the candidate triple data set in sequence, construct multiple candidate triples, substitute each candidate triple into the evaluation function to obtain the corresponding score; sort the scores and select the triple with the highest score as the best prediction result.
[0116] As can be seen, this embodiment uses the interaction between entity vectors and relationship vectors in triples to model complex relationships such as one-to-many, many-to-one, and many-to-many. It uses two translations of the head and tail entities to model symmetric and inverse relationships. It then defines an evaluation function to measure the legitimacy of the triples, and learns the optimal embedding vector representations of entities and relationships by minimizing the objective function, thereby obtaining the best prediction results for entity vectors and relationship vectors. The present invention can simultaneously consider the modeling of complex relationships and relationship connection patterns, and can accurately capture the complex semantics between entities and relationships.
[0117] See also Figure 6 A third embodiment of the present invention relates to a computer device, comprising a memory 601, a processor 602, and a computer program stored in the memory 601 and executable on the processor 602. When the processor 602 executes the computer program, the following steps are implemented:
[0118] Obtaining a dataset of original triples of the knowledge graph, where each original triple includes a head entity, a relationship, and a tail entity;
[0119] Process each original triple to obtain an evaluation function, and construct a boundary-based objective function based on the evaluation function;
[0120] By minimizing the objective function, the representation of entity vectors and relation vectors in each triple is learned to obtain a candidate triple dataset;
[0121] Extract candidate entities and candidate relations from the candidate triple dataset in sequence, construct multiple candidate triples, and substitute each candidate triple into the evaluation function to obtain the corresponding score;
[0122] The scores are sorted and the triplet with the highest score is selected as the best prediction result.
[0123] Memory 601 and processor 602 are connected using a bus. The bus can include any number of interconnected buses and bridges, connecting various circuits of one or more processors 602 and memory 601. The bus can also connect various other circuits such as peripheral devices 603, voltage regulators 604, and power management circuits. These are all well known in the art and are therefore not described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single component or multiple components, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by processor 602 is transmitted over a wireless medium via an antenna. Furthermore, the antenna receives data and transmits it to processor 602.
[0124] The processor 602 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. The memory 601 can be used to store data used by the processor 602 when performing operations.
[0125] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0126] A fourth embodiment of the present invention relates to a storage medium having a computer program stored thereon, which, when executed by a processor, implements the following steps:
[0127] Obtaining a dataset of original triples of the knowledge graph, where each original triple includes a head entity, a relationship, and a tail entity;
[0128] Process each original triple to obtain an evaluation function, and construct a boundary-based objective function based on the evaluation function;
[0129] By minimizing the objective function, the representation of entity vectors and relation vectors in each triple is learned to obtain a candidate triple dataset;
[0130] Extract candidate entities and candidate relations from the candidate triple dataset in sequence, construct multiple candidate triples, and substitute each candidate triple into the evaluation function to obtain the corresponding score;
[0131] The scores are sorted and the triplet with the highest score is selected as the best prediction result.
[0132] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0133] In summary, the present invention provides a knowledge graph prediction method, system, device, and medium. The method utilizes the interaction between entity vectors and relationship vectors in triples to model complex relationships such as one-to-many, many-to-one, and many-to-many. The method utilizes two translations of the head entity and the tail entity to model symmetric and inverse relationships. The evaluation function is then defined to measure the legitimacy of the triples. The optimal embedding vector representation of entities and relationships is learned by minimizing the objective function to obtain the optimal prediction results for entity vectors and relationship vectors. The present invention can simultaneously consider modeling complex relationships and relationship connection patterns, and can accurately obtain the complex semantics between entities and relationships. Therefore, the present invention effectively overcomes the various shortcomings of the prior art and has a high industrial utilization value.
[0134] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.
Claims
1. A knowledge graph prediction method, characterized in that: include: Obtaining an original triplet dataset of a knowledge graph, wherein each original triplet includes a head entity, a relationship, and a tail entity, and the head entity and the tail entity are texts; Processing each of the original triples to obtain an evaluation function, and constructing a boundary-based objective function based on the evaluation function; By minimizing the objective function, the representation of entity vectors and relation vectors in each triple is learned to obtain a candidate triple dataset; Sequentially extracting candidate entities and candidate relations from the candidate triple dataset, constructing multiple candidate triples, and substituting each candidate triple into an evaluation function to obtain a corresponding score; Sort the scores and select the triple with the highest score as the best prediction result; The step of processing each of the original triples to obtain an evaluation function comprises: Constructing new triples according to the entity vectors and the relationship vectors in each of the original triples; translating the head entity in the new triple, and calculating a first distance between the translated head entity and the tail entity in the original triple; translating the tail entity in the new triple, and calculating a second distance between the translated tail entity and the head entity in the original triple; The sum of the first distance and the second distance constitutes an evaluation function; The step of constructing a new triple according to the entity vectors and the relationship vectors in each triple comprises: ; in, The raw vector representation of the head entity; A vector representation of the relationship between the triple and the head entity; The operator represents an element-wise vector multiplication operation; A new vector representation of the head entity; ; in, The original vector representation of the tail entity; A vector representation of the relationship between the triple and the head entity; The operator represents an element-wise vector multiplication operation; A new vector representation representing the tail entity.
2. The prediction method according to claim 1, characterized in that The step of translating the head entity in the new triple and calculating the first distance between the translated head entity and the tail entity in the original triple comprises: ; in, Indicates the first distance; The vector representation of the translated head entity; A vector representation of the relationship between the triple and the head entity; The vector representation of the tail entity in the original triple; express paradigm.
3. The prediction method according to claim 2, characterized in that The step of translating the tail entity in the new triple and calculating the second distance between the translated tail entity and the head entity in the original triple comprises: ; in, Indicates the second distance; The vector representation of the tail entity after translation; A vector representation of the relationship between the triple and the head entity; The vector representation of the head entity in the original triple; express paradigm.
4. The prediction method according to claim 3, characterized in that The step of constructing a boundary-based objective function based on the evaluation function comprises: ; in, represents the objective function; Represents the positive sample set of triples; Represents the negative sample set of triples; Represents the fixed hyperparameter of the positive and negative sample segmentation boundary; Represents the distance between two positive samples; Represents the distance between two negative samples; The expression of the evaluation function is: ; in, Indicates the first distance; Indicates the second distance.
5. The prediction method according to claim 3, characterized in that The step of learning the representation of the entity vector and the relationship vector in each triple by minimizing the objective function includes: According to the direction of objective function reduction, the representation of entity vector and relationship vector in triple is iteratively updated until the number of iterations is completed and the optimal entity vector and relationship vector are obtained.
6. A knowledge graph prediction system, characterized in that: include: An acquisition module is used to acquire an original triplet dataset of a knowledge graph, wherein each original triplet includes a head entity, a relationship, and a tail entity, and the head entity and the tail entity are text; a vector processing module, configured to process each of the original triples to obtain an evaluation function, and construct a boundary-based objective function based on the evaluation function; The update module is used to minimize the objective function, learn the representation of entity vectors and relationship vectors in each triple, and obtain the candidate triple dataset; A prediction module is used to sequentially extract candidate entities and candidate relations from the candidate triple dataset, construct multiple candidate triples, substitute each candidate triple into the evaluation function to obtain a corresponding score; sort the scores, and select the triple with the highest score as the best prediction result; The step of processing each of the original triples to obtain an evaluation function comprises: Constructing new triples according to the entity vectors and the relationship vectors in each of the original triples; translating the head entity in the new triple, and calculating a first distance between the translated head entity and the tail entity in the original triple; translating the tail entity in the new triple, and calculating a second distance between the translated tail entity and the head entity in the original triple; The sum of the first distance and the second distance constitutes an evaluation function; The step of constructing a new triple according to the entity vectors and the relationship vectors in each triple comprises: ; in, The raw vector representation of the head entity; A vector representation of the relationship between the triple and the head entity; The operator represents an element-wise vector multiplication operation; A new vector representation of the head entity; ; in, The original vector representation of the tail entity; A vector representation of the relationship between the triple and the head entity; The operator represents an element-wise vector multiplication operation; A new vector representation representing the tail entity.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the prediction method according to any one of claims 1 to 5 are implemented.
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 steps of the prediction method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Knowledge graph information representation learning method, system, equipment and terminal
CN112765369A
Knowledge graph relationship prediction method and device based on attention mechanism
CN113535984A