Inter-entity relationship prediction method, model training method and related equipment

By acquiring and aggregating the feature vectors of multi-degree relationships through the knowledge graph embedding model, the problem of incomplete multi-degree relationship information in the knowledge graph is solved, and the accuracy and application effect of the prediction of relationships between entities are improved.

CN120687620APending Publication Date: 2025-09-23MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510740276.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-09-23

AI Technical Summary

Technical Problem

The multi-degree relationship information between entities in existing knowledge graphs is incomplete or has low accuracy, resulting in low accuracy in entity relationship prediction.

Method used

The embedded feature vectors of multi-degree relationships are obtained through the knowledge graph embedding model, and feature aggregation is performed. The aggregated feature vectors are used to determine the matching feature vectors in the embedded feature vectors of the first-degree relationship to achieve the prediction of the relationship between entities.

Benefits of technology

It improves the accuracy of predicting relationships between entities and enhances the application effect of knowledge graphs in question-answering tasks and knowledge completion tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120687620A_ABST
    Figure CN120687620A_ABST
Patent Text Reader

Abstract

The invention provides an inter-entity relationship prediction method, a model training method and related equipment. The prediction method comprises the following steps: querying a plurality of multi-degree relationships including a first entity and a second entity in a first knowledge graph according to the first entity and the second entity; obtaining a first embedded feature vector of each multi-degree relationship and a second embedded feature vector of a one-degree relationship between every two entities in the first knowledge graph through a knowledge graph embedding model; obtaining a first aggregation feature vector according to the first embedded feature vector of each multi-degree relation; and determining a third embedded feature vector matched with the first aggregated feature vector in the plurality of second embedded feature vectors according to the first aggregated feature vector. According to the embodiment of the invention, the accuracy of relation prediction between entities can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method and device for predicting inter-entity relationships based on a knowledge graph, a training method for a knowledge graph embedding model, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] A knowledge graph is a structured data model used to represent knowledge, presenting relationships between entities in the form of a graph. In practical applications, knowledge graphs are often used to organize and store relationships between different entities, including first-degree and multi-degree relationships. A first-degree relationship (direct or one-hop relation) is a direct connection between two entities, while a multi-hop relationship is a relationship between two entities connected through one or more intermediate entities.

[0003] The multi-degree relationships between entities in knowledge graphs contain rich semantic information, but the knowledge graphs in related technologies often have problems with incomplete information or low information accuracy, which leads to low accuracy in entity relationship prediction based on knowledge graphs. Summary of the Invention

[0004] The present disclosure provides a method and device for predicting inter-entity relationships based on a knowledge graph, a training method for a knowledge graph embedding model, an electronic device, a computer-readable storage medium, and a computer program product.

[0005] In a first aspect, the present disclosure provides a method for predicting relationships between entities based on a knowledge graph, comprising:

[0006] According to the first entity and the second entity, a plurality of multi-degree relationships including the first entity and the second entity are searched in the first knowledge graph;

[0007] Obtaining a first embedding feature vector for each multi-degree relationship and a second embedding feature vector for a first-degree relationship between any two entities in the first knowledge graph through a knowledge graph embedding model;

[0008] Obtaining a first aggregated feature vector according to the first embedded feature vector of each multi-degree relationship;

[0009] A third embedded feature vector matching the first aggregated feature vector is determined from a plurality of second embedded feature vectors according to the first aggregated feature vector.

[0010] In a second aspect, the present disclosure provides a method for training a knowledge graph embedding model, comprising:

[0011] Extracting a first triple and a second triple from the first knowledge graph, wherein the first triple includes entities and a one-degree relationship between the entities, and the second triple includes the entities and a multi-degree relationship between the entities;

[0012] replacing at least one entity or first-degree relationship in the first triple to obtain a third triple corresponding to the first triple;

[0013] replacing at least one entity or multi-degree relation in the second triple to obtain a fourth triple corresponding to the second triple;

[0014] determining a first loss value based on the first triplet and the third triplet;

[0015] determining a second loss value according to the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple;

[0016] A knowledge graph embedding model is trained according to the first loss value and the second loss value.

[0017] In a third aspect, the present disclosure provides a device for predicting relationships between entities based on a knowledge graph, comprising:

[0018] A relationship query module, configured to query a first knowledge graph for a plurality of multi-degree relationships including the first entity and the second entity based on the first entity and the second entity;

[0019] A feature acquisition module, configured to acquire a first embedding feature vector for each multi-degree relationship and a second embedding feature vector for a first-degree relationship between any two entities in the first knowledge graph through a knowledge graph embedding model;

[0020] an aggregate feature determination module, configured to obtain a first aggregate feature vector based on the first embedded feature vector of each multi-degree relationship;

[0021] A feature matching module is configured to determine, based on the first aggregated feature vector, a third embedded feature vector that matches the first aggregated feature vector from among the plurality of second embedded feature vectors.

[0022] In a fourth aspect, the present disclosure provides a training device for a knowledge graph embedding model, comprising:

[0023] A triple extraction module, configured to extract a first triple and a second triple from the first knowledge graph, wherein the first triple includes entities and first-degree relationships between the entities, and the second triple includes the entities and multi-degree relationships between the entities;

[0024] a first replacement module, configured to replace at least one entity or first-degree relationship in the first triple to obtain a third triple corresponding to the first triple;

[0025] A second replacement module is configured to replace at least one entity or multi-degree relation in the second triple to obtain a fourth triple corresponding to the second triple;

[0026] a first loss determining module, configured to determine a first loss value based on the first triplet and the third triplet;

[0027] a second loss determining module, configured to determine a second loss value according to the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple;

[0028] A training module is used to train a knowledge graph embedding model according to the first loss value and the second loss value.

[0029] In a fifth aspect, the present disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor so that the at least one processor can execute the above-mentioned method for predicting the relationship between entities of the knowledge graph or the method for training the knowledge graph embedding model.

[0030] In a sixth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the above-mentioned method for predicting the relationship between entities of the knowledge graph or the method for training the knowledge graph embedding model.

[0031] In the seventh aspect, the present disclosure provides a computer program product, which includes a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned method for predicting the relationship between entities of the knowledge graph or the training method for the knowledge graph embedding model.

[0032] According to the embodiments of the present disclosure, it is possible to query multiple multi-degree relationships including a first entity and a second entity in a knowledge graph; obtain the first embedded feature vector of each multi-degree relationship through the knowledge graph embedding model; obtain an aggregated feature vector based on the first embedded feature vector of each multi-degree relationship, thereby realizing feature aggregation of the multi-degree relationship between the first entity and the second entity; and then determine a matching third embedded feature vector in the second embedded feature vectors of multiple first-degree relationships based on the aggregated feature vector, thereby realizing the prediction of the relationship between the first entity and the second entity based on the aggregated feature vector, thereby improving the accuracy of the prediction of the relationship between entities.

[0033] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings. In the accompanying drawings:

[0035] Figure 1 This is a flowchart of a method for predicting relationships between entities based on a knowledge graph provided by an embodiment of the present disclosure;

[0036] Figure 2 is a schematic diagram of a method for predicting inter-entity relationships based on a knowledge graph provided by an embodiment of the present disclosure;

[0037] Figure 3 This is a flowchart of a method for training a knowledge graph embedding model provided by an embodiment of the present disclosure;

[0038] Figure 4a and Figure 4b is a schematic diagram of a process for determining an entity resource value provided by an embodiment of the present disclosure;

[0039] Figure 5 is a block diagram of a prediction device for entity relationships based on a knowledge graph provided by an embodiment of the present disclosure;

[0040] Figure 6 It is a block diagram of a training device for a knowledge graph embedding model provided by an embodiment of the present disclosure;

[0041] Figure 7 It is a block diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0042] To enable those skilled in the art to better understand the technical solutions of the present disclosure, exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0043] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.

[0044] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.

[0045] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "comprising" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. Similar words such as "connected" or "connected" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.

[0046] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless expressly defined as such herein.

[0047] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. The use of user data in this technical solution complies with relevant national laws and regulations (for example, the "Information Security Technology Personal Information Security Specification", etc.). For example: corresponding prescribed measures are taken to control access to personal information; the display of personal information is subject to prescribed restrictions; the purpose of using personal information does not exceed the scope of direct or reasonable connection; when using personal information, clear identity reference is eliminated to avoid precise positioning of specific individuals.

[0048] In a knowledge graph, relationships between entities can be categorized as direct or one-hop relationships or multi-hop relationships, indicating varying degrees of connectivity between entities. A direct one-hop relationship is a relationship between two entities. For example, in a social network, if two people are directly friends, they have a one-hop relationship. This type of relationship is the most basic and is typically represented as a triplet of <head entity, relationship, tail entity>.

[0049] A multi-degree relationship refers to a relationship between two entities connected by one or more intermediate entities. For example, in a social network, two people may be connected by multiple mutual friends; this is a multi-degree relationship. Multi-degree relationships can be second-degree, third-degree, or even higher, depending on the number of intermediate entities.

[0050] Common knowledge graph representation methods often organize knowledge using triples. In a specific knowledge base network, nodes correspond to the head and tail entities of a triple, and edges correspond to the relationships between triples. While this discrete symbolic representation effectively structures data, it also faces significant challenges in large-scale application.

[0051] For computers, continuous vector representations can contain more semantic information and are easier for computers to understand and manipulate. Mapping entities and relationships in knowledge graphs to continuous vector spaces, while also including semantic information, is crucial for facilitating knowledge graph manipulation in downstream tasks such as question-answering and relation extraction.

[0052] In related technologies, knowledge graphs are often used to organize and store the relationships between different entities. The relationship paths of the multi-degree relationships between entities in the knowledge graph contain rich semantic information, but the knowledge graphs in related technologies often have problems of incomplete information or low information accuracy.

[0053] Based on this, the embodiments of the present disclosure provide a method for predicting inter-entity relationships based on a knowledge graph, a method for training a knowledge graph embedding model, a device for predicting inter-entity relationships based on a knowledge graph, a training device for a knowledge graph embedding model, an electronic device, a computer-readable storage medium, and a computer program product, which can realize feature aggregation of multi-degree relationships between entities and predict inter-entity relationships based on aggregated feature vectors, thereby improving the accuracy of inter-entity relationship prediction.

[0054] The following examples will describe them in detail one by one.

[0055] According to the embodiment of the present disclosure, the prediction method of the entity relationship based on the knowledge graph and the training method of the knowledge graph embedding model can be performed by an electronic device such as a terminal device or a server. The terminal device can be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The server can be an independent physical server, a server cluster composed of multiple physical servers, or a cloud server capable of cloud computing. The method can be implemented by a processor calling computer-readable program instructions stored in a memory.

[0056] Figure 1 This is a flowchart of a method for predicting relationships between entities based on a knowledge graph provided by an embodiment of the present disclosure.

[0057] See also Figure 1 According to an embodiment of the present disclosure, the method for predicting the relationship between entities based on the knowledge graph specifically includes the following steps:

[0058] Step S11: querying a first knowledge graph for multiple multi-degree relationships including the first entity and the second entity according to the first entity and the second entity;

[0059] Step S12: obtaining a first embedding feature vector of each multi-degree relationship and a second embedding feature vector of a first-degree relationship between any two entities in the first knowledge graph through a knowledge graph embedding model;

[0060] Step S13: obtaining a first aggregated feature vector according to the first embedded feature vector of each multi-degree relationship;

[0061] Step S14: determining, according to the first aggregated feature vector, a third embedded feature vector matching the first aggregated feature vector from a plurality of second embedded feature vectors.

[0062] For example, the first knowledge graph may include various entities and relationships. Two entities and a first-degree relationship between the two entities can be expressed in the triple form of <head entity, relationship, tail entity>, such as <movie, director, person's name>, which means that the relationship between the entity "movie" and the entity "person's name" is "director", "movie" and "person's name" are text expressions of the entities, and "director" is the text expression of the relationship.

[0063] In some possible implementations, the first entity and the second entity to be predicted may be determined based on a corresponding information prediction task. The information prediction task may be, for example, at least one of a question-answering task and a knowledge completion task based on the first knowledge graph.

[0064] The question-answering task is used to conduct natural language question-answering with users. In this task, the user's natural language question text is analyzed to extract the first and second entities to be predicted in the question text, thereby predicting the relationship between the first and second entities and providing the corresponding answer text.

[0065] The knowledge completion task is used to predict missing entities or relationships using known entities and relationships in the first knowledge graph. In the knowledge completion task, the first entity and the second entity that do not have a first-degree relationship in the first knowledge graph can be screened to predict the relationship between the first and second entities and achieve knowledge completion.

[0066] It should be understood that those skilled in the art may set the specific type of information prediction task according to actual conditions, and this disclosure does not impose any limitation on this.

[0067] In some possible implementations, in step S11, multiple multi-degree relationships including a first entity and a second entity can be queried in the first knowledge graph, and each multi-degree relationship corresponds to a relationship path from the first entity to the second entity. For example, there are three relationship paths from entity A to entity E, namely: A->B->E; A->C->E; A->D->C->E.

[0068] In some possible implementations, in step S12, the first embedding feature vector of each multi-degree relationship can be obtained through the trained knowledge graph embedding model, that is, the text of each relationship in each multi-degree relationship is input into the knowledge graph embedding model respectively, and the embedding feature vector of each relationship in the multi-degree relationship is output; then, the embedding feature vectors of each relationship in the multi-degree relationship are summed to obtain the first embedding feature vector of the multi-degree relationship.

[0069] In some possible implementations, if a relationship in the first knowledge graph is set with a relationship weight parameter, the relationship can be weighted according to the relationship weight parameter, and the weighted sum of the embedded feature vectors of all relationships in the multi-degree relationship is used as the first embedded feature vector of the multi-degree relationship. This disclosure does not limit the specific setting of the relationship weight parameter.

[0070] Similarly, the texts of the first-degree relationships between any two entities in the first knowledge graph can be respectively input into the knowledge graph embedding model to output the second embedding feature vector of the first-degree relationship.

[0071] In some possible implementations, the knowledge graph embedding model can be an embedding model in related technologies, such as TransE (Translating Embeddings for Modeling Multi-relational Data), TransH (Knowledge Graph Embedding by Translating on Hyperplanes), TransR (Learning Entity and Relation Embeddings for Knowledge Graph Completion), CTransR (Clustering-Entity and Relation Embeddings for Knowledge Graph Completion), PTransE (Path-based Translating Embeddings for Modeling Multi-relational Data), etc.

[0072] Among them, the TransE model is based on the distributed vector representation of entities and relations. It regards the relation vector r in each triple instance <head entity (head), relation (relation), tail entity (tail)> as the vector addition from the vector h of the head entity (head) to the vector t of the tail entity (tail). By continuously adjusting the vectors h, r and t, (h+r) is made as equal to t as possible, that is, h+r=t.

[0073] TransE only considers one-to-one relationships between entities; TransH considers one-to-many, many-to-one, and many-to-many relationships between entities in addition to one-to-one relationships; TransR projects the entity space vector onto the relationship space vector; and CTransR extends TransR with relational clustering. The PTransE model integrates relational paths in the knowledge graph into the knowledge representation learning model.

[0074] It should be understood that those skilled in the art can set the specific type of the knowledge graph embedding model according to actual conditions, and this disclosure does not limit this.

[0075] In some possible implementations, in step S13, a first aggregated feature vector can be obtained based on the first embedded feature vector of each multi-degree relationship. Specifically, the first embedded feature vectors of each multi-degree relationship between the first entity and the second entity can be averaged, with the average value serving as the first aggregated feature vector. Alternatively, a weight can be assigned to each multi-degree relationship, and a weighted average of the first embedded feature vectors of each multi-degree relationship between the first entity and the second entity can be calculated, with the weighted average serving as the first aggregated feature vector. This disclosure is not limited to this.

[0076] In some possible implementations, in step S14, a third embedded feature vector that matches the first aggregated feature vector may be determined from among the plurality of second embedded feature vectors based on the first aggregated feature vector. Feature distances between the first aggregated feature vector and the plurality of second embedded feature vectors may be determined, and the second embedded feature vector with the smallest feature distance may be selected as the third embedded feature vector that matches the first aggregated feature vector.

[0077] Furthermore, based on the relationship corresponding to the third embedded feature vector, the corresponding information prediction task can be implemented, such as generating the corresponding answer text in the question-answering task; or, the <first entity, the relationship corresponding to the third embedded feature vector, the second entity> can be used as a knowledge completion triple and added to the first knowledge graph.

[0078] According to the embodiments of the present disclosure, it is possible to achieve feature aggregation of multiple-degree relationships between a first entity and a second entity; and then determine a matching third embedded feature vector in the second embedded feature vectors of multiple first-degree relationships based on the aggregated feature vector, thereby achieving prediction of the relationship between the first entity and the second entity based on the aggregated feature vector, thereby improving the accuracy of the prediction of the relationship between entities.

[0079] The following describes in detail the method for predicting the relationship between entities based on the knowledge graph according to an embodiment of the present disclosure.

[0080] As mentioned above, after determining the first entity and the second entity to be predicted according to the corresponding information prediction task, multiple multi-degree relationships including the first entity and the second entity can be queried in the first knowledge graph in step S11; and in step S12, the text of each relationship in each multi-degree relationship is input into the trained knowledge graph embedding model respectively, and the embedded feature vector of each relationship in the multi-degree relationship is output.

[0081] In some possible implementations, the embedded feature vectors of each relationship in the multi-degree relationship are summed to obtain the first embedded feature vector of the multi-degree relationship. If the relationships in the first knowledge graph are set with relationship weight parameters, the relationships can be weighted according to the relationship weight parameters, and the weighted sum of the embedded feature vectors of each relationship in the multi-degree relationship is used as the first embedded feature vector of the multi-degree relationship. For details, please refer to the following formula 1:

[0082] p = k1r1 + k1r2 + ... + k end r end Formula 1

[0083] Among them, p represents the first embedded feature vector, r1, r2, ..., r end Represents the embedded feature vector of each relationship in the multi-degree relationship, k1, k2, ..., k end Represents the relation weight parameter of each relation in the multi-degree relation. Based on the above formula 1, the first embedding feature vector of the multi-degree relation can be calculated.

[0084] By adding a relationship weight parameter to each relationship in the multi-degree relationship, the importance of each relationship in the multi-degree relationship can be reflected, thereby improving the accuracy of the first embedded feature vector in representing the multi-degree relationship, thereby improving the accuracy of the prediction of the relationship between entities in subsequent processing.

[0085] In some possible implementations, the method for predicting entity relationships based on a knowledge graph according to an embodiment of the present disclosure further includes:

[0086] When interaction record information exists in the first knowledge graph, determining a relationship weight value of the relationship based on the interaction record information of the relationship; wherein the interaction record information includes at least one of the number of interactions, the number of messages exchanged, the number of citations, and the number of visits;

[0087] When there is no interaction record information in the first knowledge graph, the relationship weight value of the relationship is determined according to the edge betweenness centrality of the relationship.

[0088] For example, based on the scenarios in which the first knowledge graph is applied, such as customer service communication scenarios, video live broadcast scenarios, etc., it can be determined whether there is interaction record information in the first knowledge graph; if the first knowledge graph is applied to interactive scenarios, then there is interaction record information in the first knowledge graph. Among them, the interaction record information can represent the interaction information recorded between each entity in the first knowledge graph, for example, at least one of the number of interactions, number of messages exchanged, number of citations, and number of visits. In this case, for any relationship, the various interaction record information of entities with the relationship as a first-degree relationship can be summed, or weighted and summed to determine the relationship weight value of the relationship. The present disclosure does not limit the specific calculation method.

[0089] In some possible implementations, if the first knowledge graph is applied to a non-interactive scenario, then no interaction record information exists in the first knowledge graph. In this case, for any relationship, the relationship weight parameter of the relationship can be determined by determining the edge betweenness centrality of the relationship.

[0090] The edge betweenness centrality of an edge in a network is expressed as the percentage of all shortest paths in the network that pass through that edge, and is used to measure the criticality of an edge in the network. The network corresponding to the first knowledge graph includes edges between nodes, where nodes correspond to entities and edges correspond to relationships. The formula for calculating edge betweenness centrality is shown in Formula 2 below:

[0091]

[0092] Where e represents an edge (relationship), s and t represent any two nodes (entities) in the network, σ(s, t) represents the total number of shortest paths from entity s to entity t, and σ(s, t|e) represents the number of shortest paths that pass through edge e. Using Formula 2 above, we can calculate the edge betweenness centrality of each relationship and use it as the relationship weight parameter.

[0093] Determining the relationship weight parameters by recording interaction information or calculating edge betweenness centrality can more accurately reflect the importance of the relationship, thereby improving the accuracy of the embedded feature vector in representing multi-degree relationships and further improving the accuracy of the prediction of relationships between entities in subsequent processing.

[0094] In some possible implementations, in step S13, a first aggregated feature vector is obtained based on the first embedded feature vector of each multi-degree relationship. Step S13 may include:

[0095] The average value of the first embedded feature vectors of each multi-degree relationship is used as the first aggregated feature vector.

[0096] That is, if there is only one multi-degree relationship between the first entity and the second entity, the first embedded feature vector of that multi-degree relationship can be directly used as the first aggregated feature vector. If there are multiple multi-degree relationships between the first entity and the second entity, the first embedded feature vectors of each multi-degree relationship can be averaged and used as the first aggregated feature vector. For details, see the following formula 3 (taking three first embedded feature vectors as an example):

[0097]

[0098] Where p0 is the first aggregated feature vector, and p1, p2, and p3 are the first embedded feature vectors. It should be noted that Formula 1 only illustrates the implementation method of determining the first aggregated feature vector using three first embedded feature vectors as an example. The number of first embedded feature vectors is determined based on actual application conditions and is not limited in this disclosure.

[0099] In some possible implementations, a weight may be set for each multi-degree relationship, and a weighted average of the first embedded feature vectors of each multi-degree relationship between the first entity and the second entity may be calculated, with the weighted average being used as the first aggregated feature vector. This disclosure does not impose any restrictions on this.

[0100] In this way, the characteristic vectors of the paths corresponding to multiple multi-degree relationships can be aggregated, thereby better representing the association information between the first entity and the second entity.

[0101] In some possible implementations, in step S14, a third embedded feature vector matching the first aggregated feature vector may be searched for in multiple second embedded feature vectors based on the first aggregated feature vector. Step S14 may include:

[0102] determining a first feature distance between the first aggregated feature vector and each second embedded feature vector respectively;

[0103] The second embedded feature vector corresponding to the minimum first feature distance is determined as a third embedded feature vector that matches the first aggregated feature vector.

[0104] For example, the characteristic distance between feature vectors can be represented by the Euclidean distance, which is used to represent the actual distance between two points in m-dimensional space (m is an integer greater than 1), or the natural length of a vector (i.e., the distance from the point to the origin). The Euclidean distance in two-dimensional and three-dimensional space is used to represent the actual distance between two points.

[0105] In some possible implementations, the Euclidean distances between the first aggregated feature vector and the plurality of second embedded feature vectors may be determined, and the second embedded feature vector with the smallest Euclidean distance may be used as the third embedded feature vector that matches the first aggregated feature vector. This can be seen in the following formula 4:

[0106] r0 = arg min || p0 - x || Formula 4

[0107] Where r0 is the third embedded feature vector, p0 is the first aggregated feature vector, and x is the second embedded feature vector. Based on the above formula 4, a matching third embedded feature vector can be determined from multiple second embedded feature vectors.

[0108] In this way, the matching of embedded feature vectors can be achieved, the matching effect can be improved, and thus the accuracy of the prediction of the relationship between entities can be improved.

[0109] Figure 2 This is a schematic diagram of a method for predicting the relationship between entities based on a knowledge graph provided by an embodiment of the present disclosure. Figure 2 , further explaining the embodiments of the present disclosure.

[0110] As Figure 2 shown, taking the first entity as "3D movies" and the second entity as "English" as an example, there are 3 multi-degree relationships between the first entity "3D movies" and the second entity "English", which are respectively: "3D movies" -> "P Film Industry" -> "M Region" -> "English"; "3D movies" -> "Person Name" -> "English"; "3D movies" -> "M Region" -> "English".

[0111] Taking the first embedding feature vectors of the 3 multi-degree relationships as p1, p2, and p3 respectively, based on the above formula 3, the first aggregated feature vector between the first entity "3D movies" and the second entity "English" can be calculated as p0. Based on the above formula 4, among all the second embedding feature vectors in the first knowledge graph, the third embedding feature vector r0 with the smallest distance from the first aggregated feature vector p0 is determined. Further, the text corresponding to the third embedding feature vector r0 is determined to be "movie language", then the relationship between the first entity "3D movies" and the second entity "English" can be determined as "movie language", and the predicted triple is <3D movies, movie language, English>. In this way, the entire process of entity relationship prediction is completed.

[0112] In some possible implementation manners, corresponding information prediction tasks can be implemented based on the third embedding feature vector. Among them, the method for predicting the relationship between entities based on a knowledge graph according to an embodiment of the present disclosure further includes:

[0113] Generating a first text according to the embedding feature vector of the first entity, the embedding feature vector of the second entity, and the third embedding feature vector.

[0114] That is to say, according to the embedding feature vector of the first entity, the embedding feature vector of the second entity, and the third embedding feature vector, the predicted triple can be determined, that is, <first entity, relationship corresponding to the third embedding feature vector, second entity>. In a question-and-answer task, the first text corresponding to the question-and-answer task can be generated according to this triple. For example, if the predicted triple is <Zhang X, director, Ying X>, the generated first text is "Hello, Zhang X is the director of the movie Ying Y".

[0115] In this way, entity relationship prediction can be achieved, combined with the actual application scenario, and the corresponding text can be given to complete the entire application process of entity relationship prediction, thereby improving the application prospect and convenience of use of entity relationship prediction.

[0116] Before applying the method for predicting the relationship between entities based on a knowledge graph according to an embodiment of the present disclosure, it is also necessary to train the knowledge graph embedding model to improve the accuracy of the model in vector representation of entities and relationships, thereby improving the prediction accuracy of entity relationships.

[0117] Figure 3 This is a flowchart of a method for training a knowledge graph embedding model provided by an embodiment of the present disclosure.

[0118] See also Figure 3 According to an embodiment of the present disclosure, a method for training a knowledge graph embedding model is also provided, which specifically includes the following steps:

[0119] Step S31: extracting a first triple and a second triple from the first knowledge graph, wherein the first triple includes entities and first-degree relationships between the entities, and the second triple includes the entities and multi-degree relationships between the entities;

[0120] Step S32: replacing at least one entity or first-degree relationship in the first triple to obtain a third triple corresponding to the first triple;

[0121] Step S33: replacing at least one entity or multi-degree relation in the second triple to obtain a fourth triple corresponding to the second triple;

[0122] Step S34, determining a first loss value according to the first triplet and the third triplet;

[0123] Step S35, determining a second loss value according to the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple;

[0124] Step S36: training a knowledge graph embedding model according to the first loss value and the second loss value.

[0125] In some possible implementations, the trained knowledge graph embedding model can be applied to the above-mentioned knowledge graph-based entity relationship prediction method.

[0126] For example, in step S31, entities with first-degree relationships can be extracted from the first knowledge graph to obtain a first triplet. The first triplet includes the entity and the first-degree relationship between the entities. Furthermore, the multi-degree relationship between the entity and the entity is determined from the first knowledge graph to obtain a second triplet. For example, if the first triplet is <entity 1, relationship 1, entity 2>, then the multi-degree relationship between entity 1 and entity 2 is extracted from the first knowledge graph, resulting in second triplet such as <entity 1, relationship 2, entity 3> and <entity 3, relationship 3, entity 2>. The first and second triplet can be used as positive samples in training.

[0127] In some possible implementations, a length threshold may be preset to represent the maximum number of multi-degree relationships between entities, so as to remove a certain number of second triplets and reduce the total number of second triplets. For example, the length threshold may be set to 3, 4, etc. When the length threshold is 3, the maximum multi-degree relationship between entities is a 3-degree relationship, and multi-degree relationships exceeding 3 between entities may be removed.

[0128] In this way, the amount of data to be processed can be reduced and the complexity of the calculation can be lowered.

[0129] In some possible implementations, at step S32, at least one entity or first-degree relationship in the first triplet can be replaced to obtain a third triplet corresponding to the first triplet. For example, if the first triplet is <head entity 1, relationship 1, tail entity 1>, replacing the relationship in the first triplet yields a third triplet <head entity 1, relationship 2, tail entity 1>. In this case, the obtained third triplet is a triplet that does not exist in the first knowledge graph and can be used as a negative sample in training.

[0130] In some possible implementations, at least one entity or multi-degree relationship in the second triplet can be replaced in step S33 to obtain a fourth triplet corresponding to the second triplet. In this case, the entities or relationships in each second triplet can be replaced separately, and the resulting fourth triplet is a triplet that does not exist in the first knowledge graph and can be used as a negative sample in training.

[0131] In some possible implementations, in step S34, a first loss value may be determined based on the first triplet and the third triplet. Step S34 includes:

[0132] Inputting the entities and relations in the first triple and the third triple into the knowledge graph embedding model respectively to obtain an embedding feature vector of the first triple and an embedding feature vector of the third triple;

[0133] Determining a positive sample score value of the first triplet according to the embedded feature vector of the first triplet;

[0134] determining a negative sample score value of the third triplet according to the embedded feature vector of the third triplet;

[0135] The first loss value is determined according to the positive sample score value of the first triple and the negative sample score value of the third triple.

[0136] For example, for any pair of the first triple (positive triple) and the third triple (negative triple), the entities and relations in the first triple and the third triple can be input into the knowledge graph embedding model respectively, and the embedding feature vector of the first triple and the embedding feature vector of the third triple can be output. The embedding feature vector of the first triple (h, r, t) includes the embedding feature vectors of the entities and relations in the first triple, denoted as h, r, and t respectively, and the embedding feature vector of the third triple (h′, r′, t′) includes the embedding feature vectors of the entities and relations in the third triple, denoted as h′, r′, and t′ respectively.

[0137] In some possible implementations, the positive sample score value of the first triplet can be determined based on the embedded feature vector of the first triplet; the positive sample score value of the third triplet can be determined based on the embedded feature vector of the third triplet.

[0138] Among them, a scoring function can be preset. When the knowledge graph embedding model adopts the TransE model, the scoring function (taking the scoring function of the positive sample as an example) can be expressed as:

[0139]

[0140] Where h, r, and t represent the embedded feature vectors of the head entity, relation, and tail entity in the first triplet, respectively; L1 and L2 are the L1 norm and L2 norm, respectively. The positive sample score of the first triplet and the negative sample score of the third triplet can be calculated using Formula 5.

[0141] It should be understood that those skilled in the art may set the specific type of the scoring function according to actual circumstances, and this disclosure does not limit this.

[0142] In some possible implementations, based on the positive sample score of the first triplet and the negative sample score of the third triplet, the first loss value L(h, r, t) can be determined by the following formula 6:

[0143] L(h,r,t)=∑ (h′,r′,t′)∈S′ [γ+E(h,r,t)-E(h′,r′,t′)] + Formula 6

[0144] Where E(h, r, t) represents the positive sample score of the first triplet; E(h′, r′, t′) represents the negative sample score of the corresponding third triplet; γ represents the margin value, which is a fixed value used to control the score difference between positive and negative samples; S′ represents the set of negative samples of a batch of samples corresponding to the third triplet; [x] + =max(0,x), which means taking the maximum value between 0 and x.

[0145] Formula 6 represents the difference between the positive sample score value of the first triplet and the negative sample score value of the third triplet in each pair of samples in a batch, and adds the marginal value as the final difference. The difference values ​​of the samples in the batch are summed to obtain the first loss value of the knowledge graph embedding model.

[0146] In this way, the first loss value can be used to represent the difference information between positive and negative samples, so as to train the knowledge graph embedding model and improve the model training effect.

[0147] In some possible implementations, in step S35, a second loss value is determined based on the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple. Step S35 may include:

[0148] Inputting the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple into the knowledge graph embedding model respectively, to obtain an embedding feature vector of the first-degree relationship in the first triple, an embedding feature vector of the multi-degree relationship in the second triple, an embedding feature vector of the first-degree relationship in the third triple, and an embedding feature vector of the multi-degree relationship in the fourth triple;

[0149] Performing a weighted summation on the embedded feature vectors of the multi-degree relationship in the second triplet to obtain a weighted feature vector of the multi-degree relationship in the second triplet; performing a weighted summation on the embedded feature vectors of the multi-degree relationship in the fourth triplet to obtain a weighted feature vector of the multi-degree relationship in the fourth triplet;

[0150] determining a positive sample score value of the first-degree relationship in the first triple according to the embedded feature vector of the first-degree relationship in the first triple and the weighted feature vector of the multi-degree relationship in the second triple;

[0151] determining a negative sample score value of the first-degree relationship in the third triplet according to the embedded feature vector of the first-degree relationship in the third triplet and the weighted feature vector of the multi-degree relationship in the fourth triplet;

[0152] The second loss value is determined according to the positive sample score value of the first-degree relationship in the first triple and the negative sample score value of the first-degree relationship in the third triple.

[0153] For example, during the training process, the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple can be input into the knowledge graph embedding model respectively to obtain the embedded feature vector of the first-degree relationship in the first triple, the embedded feature vector of the multi-degree relationship in the second triple, the embedded feature vector of the first-degree relationship in the third triple, and the embedded feature vector of the multi-degree relationship in the fourth triple. The embedded feature vector of the multi-degree relationship includes the embedded feature vector of each relationship in the multi-degree relationship.

[0154] In some possible implementations, based on the relationship weight parameter of each relationship in the multi-degree relationship in the second triplet, Formula 1 can be used to perform weighted summation of the embedded feature vectors of each relationship in the multi-degree relationship of the second triplet to obtain the weighted feature vector of the multi-degree relationship in the second triplet; similarly, based on the relationship weight parameter of each relationship in the multi-degree relationship in the fourth triplet, Formula 1 can be used to perform weighted summation of the embedded feature vectors of each relationship in the multi-degree relationship of the fourth triplet to obtain the weighted feature vector of the multi-degree relationship in the fourth triplet.

[0155] In some possible implementations, according to a preset scoring function, the positive sample score value of the first-degree relationship in the first triplet can be determined based on the embedded feature vector of the first-degree relationship in the first triplet and the weighted feature vector of the multi-degree relationship in the second triplet; and the negative sample score value of the first-degree relationship in the third triplet can be determined based on the embedded feature vector of the first-degree relationship in the third triplet and the weighted feature vector of the multi-degree relationship in the fourth triplet.

[0156] In some possible implementations, when the knowledge graph embedding model adopts the TransE model, the scoring function (taking the scoring function of positive samples as an example) can be expressed as:

[0157]

[0158] Where p represents the weighted eigenvector of the multi-degree relationship in the second triplet, r represents the embedded eigenvector of the first-degree relationship in the first triplet, L1 and L2 are the L1 and L2 norms, respectively; and E(p,r) represents the positive sample score of the first-degree relationship in the first triplet. Formula 7 above can be used to calculate the positive sample score of the first-degree relationship in the first triplet and the negative sample score of the first-degree relationship in the third triplet.

[0159] In some possible implementations, the second loss value is determined based on the positive sample score value of the first-degree relationship in the first triple and the negative sample score value of the first-degree relationship in the third triple. It can be expressed as:

[0160] L(p,r)=∑ (h′,r′,t′)∈S′[γ+E(p,r)-E(p′,r′)] + Formula 8

[0161] Where p′ represents the weighted eigenvector of the multi-degree relationship in the fourth triplet, r′ represents the embedded eigenvector of the first-degree relationship in the third triplet, and E(p′, r′) represents the negative sample score of the first-degree relationship in the corresponding third triplet. γ represents the margin value, which is a fixed value used to control the score difference between positive and negative samples; S′ represents the set of negative samples of a batch of samples corresponding to the third triplet; [x] + =max(0,x), which means taking the maximum value between 0 and x. It can be understood that x in Formula 8 is γ+E(p,r)-E(p′,r′).

[0162] Formula 8 represents the difference between the positive sample score value of the first-degree relationship in each pair of triples in a batch of samples and the negative sample score value of the first-degree relationship in the third triplet, and adds the marginal value as the final difference. The difference values ​​of the samples in the batch are summed to obtain the second loss value of the knowledge graph embedding model.

[0163] In this way, the second loss value can be used to represent the difference information between the positive and negative samples, so as to train the knowledge graph embedding model and improve the model training effect.

[0164] In some possible implementations, in step S36, the knowledge graph embedding model is trained based on the first loss value and the second loss value. During training, model parameters of the knowledge graph embedding model may be adjusted based on the first loss value and the second loss value. When training conditions (e.g., model convergence) are met, a trained knowledge graph embedding model may be obtained.

[0165] In some possible implementations, step S36 includes:

[0166] Determining a third loss value based on the first loss value, the second loss value, and the resource value of the entity in the first triple;

[0167] The knowledge graph embedding model is trained according to the third loss value.

[0168] In practical applications, the multi-degree relationships between entities in a knowledge graph contain rich semantic information. Therefore, determining the reliability of these relationships is crucial. Related techniques often determine the reliability of multi-degree relationships by calculating the resource value of each entity in the knowledge graph.

[0169] In some possible implementations, the first loss value and the second loss value can be directly summed as the overall loss value of the knowledge graph embedding model; the resource value of the entity in the triplet can also be introduced to determine the overall loss value of the knowledge graph embedding model, so as to reflect the reliability of the multi-degree relationship in the connection between entities, thereby improving the training effect of the knowledge graph embedding model.

[0170] In some possible implementations, the third loss value Loss of the knowledge graph embedding model can be determined based on the first loss value, the second loss value, and the resource value of the entity in the first triple. It can be expressed as:

[0171]

[0172] Wherein, Loss represents the third loss value; L(h,r,t) represents the first loss value; L(p,r) represents the second loss value; P(h,t) represents the set of second triples of entities h and t, p represents the relationship path corresponding to any second triple in the set, R(p|h,t) represents the resource value transferred from entity h to entity t on any relationship path p; R(p|h,t)L(p,r) represents the second loss value weighted by the resource value on the relationship path; Z represents the normalization factor; Represents the second loss value weighted by resource value on all relationship paths between entities h and t.

[0173] In this way, information that reflects the reliability of the connections between entities can be introduced, which improves the accuracy of model loss calculation and thus improves the training effect of the model.

[0174] In some possible implementations, before introducing the resource value of the entity, it is necessary to determine the resource value of each entity in the first knowledge graph.

[0175] The training method of the knowledge graph embedding model according to an embodiment of the present disclosure further includes:

[0176] For each third entity in the first knowledge graph, query the first knowledge graph for a fourth entity that has a first-degree relationship with the third entity and is the head entity;

[0177] In a case where a fourth entity corresponding to the third entity is found, determining the second resource value of the third entity according to the first weight value and the first resource value of each fourth entity of the third entity;

[0178] In a case where the fourth entity corresponding to the third entity is not found in the query, the second resource value of the third entity is determined to be a preset value.

[0179] For example, for each entity in the first knowledge graph, hereinafter referred to as the third entity, the fourth entity that has a first-degree relationship with the third entity and is the head entity can be queried in the first knowledge graph, that is, each triple expressed as <fourth entity, relationship, third entity> with the fourth entity as the head entity and the third entity as the tail entity in the first knowledge graph is queried to obtain the set corresponding to the fourth entity, which can be called the predecessor entity set of the third entity, and the fourth entity can also be called the direct predecessor entity of the third entity.

[0180] In some possible implementations, if the fourth entity corresponding to the third entity is not found in the first knowledge graph, that is, there is no triple with the third entity as the last entity in the first knowledge graph, then the second resource value of the third entity can be determined as a preset value, such as 1, indicating that the resource value of this type of third entity is the initial value.

[0181] In some possible implementations, if a fourth entity corresponding to a third entity is found in the first knowledge graph, the second resource value of the third entity is determined based on the first weight value and first resource value of each fourth entity in the predecessor entity set of the third entity.

[0182] Related technologies, when determining the reliability of multi-degree relationships, do not consider the importance of the entity nodes in the relationship path in the knowledge graph, which reduces the accuracy of determining the reliability of the relationship path. Based on this, in the embodiments of the present disclosure, on top of determining the resource value of each entity in the knowledge graph, the weight value of each entity is further combined to determine a more accurate resource value for the entity, thereby improving the accuracy of model loss calculation in subsequent processes.

[0183] For each entity in the first knowledge graph, an initial weight value of the entity can be determined by a web page ranking algorithm, and the initial weight value can be standardized to obtain a first weight value of the entity.

[0184] The PageRank algorithm is used to measure the importance of a particular webpage relative to other webpages in a search engine index. In graph computing, it is used to represent the importance of a node in a graph. It should be understood that those skilled in the art may configure the calculation method for the initial weight value based on actual circumstances, and this disclosure does not impose any limitations thereon.

[0185] In some possible implementations, the normalization process of the weight values ​​can be expressed as:

[0186]

[0187] Among them, Pr represents the initial weight value of the entity; max represents the maximum value of the initial weight values ​​of all entities in the first knowledge graph; min represents the minimum value of the initial weight values ​​of all entities in the first knowledge graph; Pr′ represents the first weight value after standardization.

[0188] In this way, a standardized first weight value can be obtained, thereby reducing the computational workload of subsequent processing and improving computational efficiency.

[0189] In some possible implementations, the step of determining the second resource value of the third entity according to the first weight value and the first resource value of each fourth entity of the third entity includes:

[0190] For each of the fourth entities, searching the first knowledge graph for a fifth entity that has a one-degree relationship with the fourth entity and is the tail entity;

[0191] determining, according to the first weight value and the first resource value of the fourth entity and the quantity of the fifth entity, a third resource value to be transferred by the fourth entity to the third entity;

[0192] The second resource value of the third entity is determined according to the third resource value transmitted by each of the fourth entities to the third entity.

[0193] For example, for each fourth entity in the set of predecessor entities of the third entity, the first knowledge graph can be searched for a fifth entity that has a one-degree relationship with the fourth entity and is the tail entity. That is, each triple in the first knowledge graph represented as <fourth entity, relationship, fifth entity> with the fourth entity as the head entity and the fifth entity as the tail entity is searched. The set corresponding to the fifth entity can be called the set of successor entities of the fourth entity, and the fifth entity can also be called the direct successor entity of the fourth entity. The fifth entity includes the third entity, that is, the third entity is one of the direct successor entities of the fourth entity.

[0194] In some possible implementations, depending on the number of fifth entities, the third resource value transferred from the fourth entity to the third entity may be determined based on the first weight value and the first resource value of the fourth entity, and may be expressed as (first weight value * first resource value) / the number of fifth entities, N. In other words, the resource value of the fourth entity is evenly transferred to all directly subsequent entities, and the third resource value transferred to the third entity is 1 / N.

[0195] In some possible implementations, the second resource value of the third entity can be determined based on the third resource value passed to the third entity by each fourth entity in the set of predecessor entities of the third entity. In other words, the second resource value of the third entity can be obtained by summing the third resource values ​​passed to the third entity by each fourth entity. This can be expressed as:

[0196]

[0197] Among them, R p (m) is the second resource value of the third entity m; R p (n) is the resource value of the fourth entity n weighted by the first weight value; S i-1 (·,m) is the set of predecessor entities of the third entity m, that is, the set of the fourth entity, the fourth entity n∈S i-1 (·,m);S i (n,·) is the number of fifth entities in the set of successor entities of the fourth entity n (ie, the set of fifth entities).

[0198] The following explains with examples.

[0199] Figure 4a and Figure 4b It is a schematic diagram of the process of determining the entity resource value provided by the embodiment of the present disclosure.

[0200] Figure 4a An exemplary knowledge graph is shown. Figure 4a As shown, the knowledge graph includes entities A, B, C, D, E, and F. For example, with entity A as the head entity and entity E as the tail entity, there are three relationship paths from entity A to entity E: A->B->E; A->C->E; and A->D->C->E. Following the flow relationships of these three relationship paths, we obtain the entity set S0 = {A}, S1 = {B, C, D}, S2 = {E, C}, and S3 = {E}, where the head entity A∈S0, the tail entity E∈S2, and E∈S3. The predecessor entity set of entity B is {A}, the predecessor entity set of entity C is {A, D}, the predecessor entity set of entity D is {A}, the predecessor entity set of entity E is {B, C}, and the predecessor entity set of entity F is {A}.

[0201] Figure 4b Shown Figure 4a The process of determining the entity resource value of the knowledge graph. Figure 4b As shown, assuming that the resource value of the starting entity A is 1, calculate R p (B), the predecessor entity of entity B is only entity A, then S i-1 (·,B)={A}, entity A has four successor entities, namely entity B, entity F, entity C and entity D, then |S i (A,·)|=4.

[0202] Therefore, it can be determined

[0203] Furthermore, R p(E), according to the above formula 11, we can get At this time, we need to determine R p (C). According to the above formula 11, we can get The calculated R p (C) Substitute the calculated R p (E) In the formula, we can get

[0204] In this way, the reliability and accuracy of the obtained entity resource value can be improved, thereby improving the accuracy of the model loss calculation in the subsequent process.

[0205] According to the embodiments of the present disclosure, before training the knowledge graph embedding model, the resource value of each entity in the knowledge graph can be determined separately, thereby reflecting the importance information of the entity in the knowledge graph; and the resource value is weighted by the weight value of the entity, thereby improving the accuracy of the resource value of the entity.

[0206] According to an embodiment of the present disclosure, during the training process of the knowledge graph embedding model, triplets corresponding to positive and negative samples are constructed, and the difference information between the positive and negative samples and the difference information between the relationship between the positive and negative samples are determined respectively. The model loss is determined in combination with the resource value of the entity in the triplet, and then the knowledge graph embedding model is trained. This can improve the accuracy of the model loss calculation, thereby improving the training effect of the model.

[0207] According to the embodiments of the present disclosure, during the prediction of inter-entity relationships, feature aggregation of multiple-degree relationships between a first entity and a second entity to be predicted is achieved. Matching embedded feature vectors are queried from the embedded feature vectors of multiple first-degree relationships based on the aggregated feature vectors, thereby predicting the relationship between the first entity and the second entity based on the aggregated feature vectors, thereby improving the accuracy of inter-entity relationship prediction. Furthermore, the method can be combined with actual application scenarios to generate corresponding text based on the predicted inter-entity relationship results, completing the entire application process of inter-entity relationship prediction, thereby improving the application prospects and ease of use of inter-entity relationship prediction.

[0208] It is understood that the above-mentioned various method embodiments mentioned in this disclosure can be combined with each other to form combined embodiments without violating the principle logic. Due to space limitations, this disclosure will not go into details. It is understood by those skilled in the art that in the above-mentioned methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.

[0209] In addition, the present disclosure also provides a prediction device for entity relationships based on a knowledge graph, a training device for a knowledge graph embedding model, an electronic device, a computer-readable storage medium, and a computer program product. The above can all be used to implement any method for predicting entity relationships based on a knowledge graph or a training method for a knowledge graph embedding model provided by the present disclosure. The corresponding technical solutions and descriptions are referred to the corresponding records in the method section and will not be repeated here.

[0210] Figure 5 This is a block diagram of a prediction device for entity relationships based on a knowledge graph provided by an embodiment of the present disclosure. Figure 5 The present disclosure provides a device for predicting relationships between entities based on a knowledge graph, the device comprising:

[0211] A relationship query module 51 is configured to query a first knowledge graph for multiple multi-degree relationships including a first entity and a second entity based on the first entity and the second entity;

[0212] A feature acquisition module 52 is configured to acquire, through a knowledge graph embedding model, a first embedding feature vector for each multi-degree relationship and a second embedding feature vector for a first-degree relationship between any two entities in the first knowledge graph;

[0213] An aggregate feature determination module 53 is configured to obtain a first aggregate feature vector based on the first embedded feature vector of each multi-degree relationship;

[0214] The feature matching module 54 is configured to determine, based on the first aggregated feature vector, a third embedded feature vector that matches the first aggregated feature vector from among the plurality of second embedded feature vectors.

[0215] In some possible implementations, the feature matching module 54 is configured to:

[0216] determining a first feature distance between the first aggregated feature vector and each second embedded feature vector respectively;

[0217] The second embedded feature vector corresponding to the minimum first feature distance is determined as a third embedded feature vector that matches the first aggregated feature vector.

[0218] In some possible implementations, the aggregate feature determination module 53 is configured to:

[0219] The average value of the first embedded feature vectors of each multi-degree relationship is used as the first aggregated feature vector.

[0220] In some possible implementations, the apparatus further includes:

[0221] A text generation module is used to generate a first text according to the embedded feature vector of the first entity, the embedded feature vector of the second entity and the third embedded feature vector.

[0222] Figure 6 This is a block diagram of a training device for a knowledge graph embedding model provided by an embodiment of the present disclosure. Figure 6 , an embodiment of the present disclosure provides a training device for a knowledge graph embedding model, the device comprising:

[0223] A triple extraction module 61 is configured to extract a first triple and a second triple from the first knowledge graph, wherein the first triple includes entities and first-degree relationships between the entities, and the second triple includes the entities and multi-degree relationships between the entities;

[0224] A first replacement module 62 is configured to replace at least one entity or first-degree relationship in the first triple to obtain a third triple corresponding to the first triple;

[0225] A second replacement module 63 is configured to replace at least one entity or multi-degree relation in the second triple to obtain a fourth triple corresponding to the second triple;

[0226] a first loss determining module 64, configured to determine a first loss value based on the first triplet and the third triplet;

[0227] a second loss determining module 65 for determining a second loss value based on the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple;

[0228] The training module 66 is used to train the knowledge graph embedding model according to the first loss value and the second loss value.

[0229] In some possible implementations, the first loss determination module 64 is configured to:

[0230] Inputting the entities and relations in the first triple and the third triple into the knowledge graph embedding model respectively to obtain an embedding feature vector of the first triple and an embedding feature vector of the third triple;

[0231] Determining a positive sample score value of the first triplet according to the embedded feature vector of the first triplet;

[0232] determining a negative sample score value of the third triplet according to the embedded feature vector of the third triplet;

[0233] The first loss value is determined according to the positive sample score value of the first triple and the negative sample score value of the third triple.

[0234] In some possible implementations, the second loss determination module 65 is configured to:

[0235] Inputting the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple into the knowledge graph embedding model respectively, to obtain an embedding feature vector of the first-degree relationship in the first triple, an embedding feature vector of the multi-degree relationship in the second triple, an embedding feature vector of the first-degree relationship in the third triple, and an embedding feature vector of the multi-degree relationship in the fourth triple;

[0236] Performing a weighted summation on the embedded feature vectors of the multi-degree relationship in the second triplet to obtain a weighted feature vector of the multi-degree relationship in the second triplet; performing a weighted summation on the embedded feature vectors of the multi-degree relationship in the fourth triplet to obtain a weighted feature vector of the multi-degree relationship in the fourth triplet;

[0237] determining a positive sample score value of the first-degree relationship in the first triple according to the embedded feature vector of the first-degree relationship in the first triple and the weighted feature vector of the multi-degree relationship in the second triple;

[0238] determining a negative sample score value of the first-degree relationship in the third triplet according to the embedded feature vector of the first-degree relationship in the third triplet and the weighted feature vector of the multi-degree relationship in the fourth triplet;

[0239] The second loss value is determined according to the positive sample score value of the first-degree relationship in the first triple and the negative sample score value of the first-degree relationship in the third triple.

[0240] In some possible implementations, the training module 66 is configured to:

[0241] Determine a third loss value based on the first loss value, the second loss value, and the resource value of the entity in the first triplet; and train the knowledge graph embedding model based on the third loss value.

[0242] In some possible implementations, the apparatus further includes:

[0243] a head entity determination module, configured to, for each third entity in the first knowledge graph, query the first knowledge graph for a fourth entity that has a first-degree relationship with the third entity and is the head entity;

[0244] a first resource value determining module configured to determine, when a fourth entity corresponding to the third entity is found, a second resource value of the third entity based on the first weight value and the first resource value of each fourth entity of the third entity;

[0245] The second resource value determining module is configured to determine that the second resource value of the third entity is a preset value when no fourth entity corresponding to the third entity is found.

[0246] In some possible implementations, the first resource value determination module is configured to:

[0247] For each of the fourth entities, a fifth entity that has a first-degree relationship with the fourth entity and is the tail entity is queried in the first knowledge graph; based on the first weight value and the first resource value of the fourth entity and the number of the fifth entities, the third resource value transferred from the fourth entity to the third entity is determined; based on the third resource value transferred from each of the fourth entities to the third entity, the second resource value of the third entity is determined.

[0248] Each module in the above-mentioned apparatus may be implemented in whole or in part by software, hardware, or a combination thereof. Each module may be embedded in or independent of a processor in a computer device in the form of hardware, or may be stored in a memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.

[0249] Figure 7 A block diagram of an electronic device provided in an embodiment of the present disclosure.

[0250] See also Figure 7 , an embodiment of the present disclosure provides an electronic device 700, which includes: at least one processor 701; at least one memory 702, and one or more I / O interfaces 703, connected between the processor 701 and the memory 702; wherein the memory 702 stores one or more computer programs that can be executed by the at least one processor 701, and the one or more computer programs are executed by the at least one processor 701 to enable the at least one processor 701 to execute the above-mentioned knowledge graph entity relationship prediction method or knowledge graph embedding model training method.

[0251] Each module in the above-mentioned electronic device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0252] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor / processing core, the computer program implements the aforementioned method for predicting inter-entity relationships in a knowledge graph or the method for training a knowledge graph embedding model. The computer-readable storage medium may be volatile or non-volatile.

[0253] An embodiment of the present disclosure also provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned method for predicting the relationship between entities of the knowledge graph or the method for training the knowledge graph embedding model.

[0254] It will be understood by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium).

[0255] As is well known to those skilled in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is well known to those skilled in the art, communication media typically contains computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0256] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in the computer-readable storage medium in each computing / processing device.

[0257] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, and conventional procedural programming languages ​​such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., utilizing an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions. The electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0258] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one embodiment, the computer program product is implemented as a computer storage medium. In another embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0259] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer-readable program instructions.

[0260] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device is generated that implements the functions / actions specified in one or more blocks in the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks in the flowchart and / or block diagram.

[0261] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more blocks in the flowchart and / or block diagram.

[0262] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and the part of the module, program segment or instruction contains one or more executable instructions for realizing the prescribed logical function. In some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the prescribed function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0263] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for purposes of limitation. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly indicated, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, it will be understood by those skilled in the art that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.

Claims

1. A method for predicting the relationship between entities based on knowledge graph, characterized in that: include: According to the first entity and the second entity, a plurality of multi-degree relationships including the first entity and the second entity are searched in the first knowledge graph; Obtaining a first embedding feature vector for each multi-degree relationship and a second embedding feature vector for a first-degree relationship between any two entities in the first knowledge graph through a knowledge graph embedding model; Obtaining a first aggregated feature vector according to the first embedded feature vector of each multi-degree relationship; A third embedded feature vector matching the first aggregated feature vector is determined from a plurality of second embedded feature vectors according to the first aggregated feature vector.

2. The method according to claim 1, characterized in that The determining, in the second embedded feature vector according to the first aggregated feature vector, a third embedded feature vector that matches the first aggregated feature vector includes: determining a first feature distance between the first aggregated feature vector and each second embedded feature vector respectively; The second embedded feature vector corresponding to the minimum first feature distance is determined as a third embedded feature vector that matches the first aggregated feature vector.

3. A training method for a knowledge graph embedding model, characterized in that: include: Extracting a first triple and a second triple from the first knowledge graph, wherein the first triple includes entities and a one-degree relationship between the entities, and the second triple includes the entities and a multi-degree relationship between the entities; replacing at least one entity or first-degree relationship in the first triple to obtain a third triple corresponding to the first triple; replacing at least one entity or multi-degree relation in the second triple to obtain a fourth triple corresponding to the second triple; determining a first loss value based on the first triplet and the third triplet; determining a second loss value according to the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple; A knowledge graph embedding model is trained according to the first loss value and the second loss value.

4. The method according to claim 3, characterized in that The determining a first loss value according to the first triplet and the second triplet includes: Inputting the entities and relations in the first triple and the third triple into the knowledge graph embedding model respectively to obtain an embedding feature vector of the first triple and an embedding feature vector of the third triple; Determining a positive sample score value of the first triplet according to the embedded feature vector of the first triplet; determining a negative sample score value of the third triplet according to the embedded feature vector of the third triplet; The first loss value is determined according to the positive sample score value of the first triple and the negative sample score value of the third triple.

5. The method according to claim 4, characterized in that The determining a second loss value according to the first triple, the second triple, and the first-degree relationship in the third triple and the multi-degree relationship in the fourth triple includes: Inputting the first-degree relationship in the first triple, the multi-degree relationship in the second triple, the first-degree relationship in the third triple, and the multi-degree relationship in the fourth triple into the knowledge graph embedding model respectively, to obtain an embedding feature vector of the first-degree relationship in the first triple, an embedding feature vector of the multi-degree relationship in the second triple, an embedding feature vector of the first-degree relationship in the third triple, and an embedding feature vector of the multi-degree relationship in the fourth triple; Performing a weighted summation on the embedded feature vectors of the multi-degree relationship in the second triplet to obtain a weighted feature vector of the multi-degree relationship in the second triplet; performing a weighted summation on the embedded feature vectors of the multi-degree relationship in the fourth triplet to obtain a weighted feature vector of the multi-degree relationship in the fourth triplet; determining a positive sample score value of the first-degree relationship in the first triple according to the embedded feature vector of the first-degree relationship in the first triple and the weighted feature vector of the multi-degree relationship in the second triple; determining a negative sample score value of the first-degree relationship in the third triplet according to the embedded feature vector of the first-degree relationship in the third triplet and the weighted feature vector of the multi-degree relationship in the fourth triplet; The second loss value is determined according to the positive sample score value of the first-degree relationship in the first triple and the negative sample score value of the first-degree relationship in the third triple.

6. The method according to claim 3, characterized in that The training of the knowledge graph embedding model according to the first loss value and the second loss value includes: Determining a third loss value based on the first loss value, the second loss value, and the resource value of the entity in the first triple; The knowledge graph embedding model is trained according to the third loss value.

7. The method according to claim 6, characterized in that The method further comprises: For each third entity in the first knowledge graph, query the first knowledge graph for a fourth entity that has a first-degree relationship with the third entity and is the head entity; In a case where a fourth entity corresponding to the third entity is found, determining the second resource value of the third entity according to the first weight value and the first resource value of each fourth entity of the third entity; In a case where the fourth entity corresponding to the third entity is not found in the query, the second resource value of the third entity is determined to be a preset value.

8. The method according to claim 7, characterized in that The determining the second resource value of the third entity according to the first weight value and the first resource value of each fourth entity of the third entity includes: For each of the fourth entities, searching the first knowledge graph for a fifth entity that has a one-degree relationship with the fourth entity and is the tail entity; determining, according to the first weight value and the first resource value of the fourth entity and the quantity of the fifth entity, a third resource value to be transferred by the fourth entity to the third entity; The second resource value of the third entity is determined according to the third resource value transmitted by each of the fourth entities to the third entity.

9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1-2 or 3-8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 2 or 3 to 8.

11. A computer program product, characterized in that A method comprising: providing a computer-readable code or a non-volatile computer-readable storage medium carrying a computer-readable code; when the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the method as described in any one of claims 1-2 or 3-8.