Knowledge graph reasoning method and device, model training method and device and computer equipment

By screening the nearest neighbor entities of the query entity in knowledge graph inference and selecting candidate entities based on probability, the problem of low efficiency of knowledge graph inference in the prior art is solved, and more efficient training of knowledge graph inference and type distribution prediction model is achieved.

CN119988644APending Publication Date: 2025-05-13ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510112468.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-04-28
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

In the prior art, the knowledge graph inference efficiency is low, mainly because the candidate entities are selected when traversing the entire knowledge graph, resulting in too large number of candidate entities, which affects efficiency.

Method used

By obtaining the query entity and query relationship, selecting the nearest neighbor entity of the query entity, and filtering the candidate entity according to the first probability of the nearest neighbor entity, and finally selecting the candidate entity that matches the query entity and query relationship as the result entity.

Benefits of technology

The number of candidate entities is reduced, the efficiency of knowledge graph inference is improved, and the type distribution prediction model is trained through a self-supervised way, without labeling knowledge graph samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119988644A_ABST
    Figure CN119988644A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a knowledge graph reasoning method and device, a model training method and device and computer equipment. The method comprises the following steps: acquiring a query entity and a query relationship; selecting a neighbor entity of the query entity from the knowledge graph; determining a first probability of the neighbor entity, wherein the first probability is used for representing the communication possibility of the neighbor entity and the query relationship; selecting a neighbor entity as a candidate entity according to the first probability; a candidate entity that matches the query entity and the query relationship is selected as a result entity. According to the embodiment of the invention, the knowledge graph reasoning efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the invention patent application with application number 202210457668.3, application date April 28, 2022, and invention name "Knowledge graph reasoning method, model training method, device and computer equipment". Technical Field

[0002] The embodiments of this specification relate to the field of computer technology, and in particular to a knowledge graph reasoning method, model training method, device and computer equipment. Background Art

[0003] Knowledge Graph (KG) aims to describe various entities and their relationships in the real world.

[0004] Knowledge Graph Reasoning (KGR) aims to use the existing knowledge in the knowledge graph to obtain new knowledge through reasoning. Knowledge graph reasoning has important application value in question answering, information retrieval and other fields.

[0005] Therefore, it is necessary to improve the efficiency of knowledge graph reasoning. Summary of the invention

[0006] The embodiments of this specification provide a knowledge graph reasoning method, model training method, device and computer equipment to improve the efficiency of knowledge graph reasoning. The technical solutions provided by the embodiments of this specification are as follows.

[0007] A first aspect of the embodiments of this specification provides a knowledge graph reasoning method, including:

[0008] Get the query entity and query relationship;

[0009] Select neighboring entities of the query entity from the knowledge graph;

[0010] Determine a first probability of a neighbor entity, where the first probability is used to indicate a possibility that the neighbor entity is connected to the query relationship;

[0011] According to the first probability, a neighbor entity is selected as a candidate entity;

[0012] Candidate entities that match the query entity and the query relation are selected as result entities.

[0013] A second aspect of the embodiments of this specification provides a model training method, including:

[0014] Mask one or more entity relationships of the target entity in the knowledge graph sample;

[0015] Determine the type distribution information of the target entity according to the masked knowledge graph sample and the type distribution prediction model, wherein the type distribution information is used to indicate the possibility of the target entity being connected to multiple known entity relationships;

[0016] Determine a third probability of the target entity according to the type distribution information and the masked entity relationship, wherein the third probability is used to indicate the possibility that the target entity is connected to the masked entity relationship;

[0017] Based on the third probability, model parameters of the type distribution prediction model are optimized.

[0018] A third aspect of the embodiments of this specification provides a knowledge graph reasoning device, including:

[0019] An acquisition unit, used for acquiring query entities and query relations;

[0020] A first selection unit, used to select neighbor entities of the query entity from the knowledge graph;

[0021] A determining unit, configured to determine a first probability of a neighbor entity, wherein the first probability is used to indicate a possibility that the neighbor entity is connected to the query relationship;

[0022] A second selection unit, configured to select a neighbor entity as a candidate entity according to the first probability;

[0023] The third selection unit is used to select a candidate entity that matches the query entity and the query relationship as a result entity.

[0024] A fourth aspect of the embodiments of this specification provides a model training device, including:

[0025] A masking unit, used to mask one or more entity relationships of a target entity in a knowledge graph sample;

[0026] An acquisition unit, used to determine type distribution information of a target entity according to the masked knowledge graph sample and the type distribution prediction model, wherein the type distribution information is used to indicate the possibility of the target entity being connected to multiple known entities;

[0027] A determination unit, configured to determine a third probability of the target entity according to the type distribution information and the masked entity relationship, wherein the third probability is used to indicate a possibility of the target entity being connected to the masked entity relationship;

[0028] The optimization unit is used to optimize the model parameters of the type distribution prediction model according to the third probability.

[0029] According to a fifth aspect of the embodiments of this specification, a computer device is provided, including:

[0030] at least one processor;

[0031] A memory storing program instructions, wherein the program instructions are configured to be suitable for being executed by the at least one processor, and the program instructions include instructions for executing the method as described in the first aspect or the second aspect.

[0032] The technical solution provided in the embodiments of this specification can obtain query entities and query relationships; select neighbor entities of the query entity from the knowledge graph; determine the first probability of the neighbor entity; select the neighbor entity as a candidate entity based on the first probability; and select the candidate entity that matches the query entity and the query relationship as the result entity. In this way, the entities in the knowledge graph can be screened according to the query entity to obtain neighbor entities; the neighbor entities can be screened according to the first probability to obtain candidate entities. Thereby, the number of candidate entities can be reduced and the efficiency of knowledge graph reasoning can be improved. In addition, the technical solution provided in the embodiments of this specification realizes the training of the type distribution prediction model by masking the entity relationship of the target entity in the knowledge graph sample. In this way, there is no need to annotate the knowledge graph sample, and the type distribution prediction model can be trained in a self-supervised manner. The trained type distribution prediction model is used to determine the type distribution information. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. The drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0034] Figure 1 This is a flowchart of the knowledge graph reasoning method in the embodiments of this specification;

[0035] Figure 2 This is a schematic diagram of the process of knowledge graph reasoning in the embodiments of this specification;

[0036] Figure 3 A schematic diagram of type distribution information in an embodiment of this specification;

[0037] Figure 4 A schematic diagram of a neural network model in the embodiment of this specification;

[0038] Figure 5 A schematic diagram of the flow chart of the model training method in the embodiment of this specification;

[0039] Figure 6 This is a schematic diagram of the structure of the knowledge graph reasoning device in the embodiment of this specification;

[0040] Figure 7 This is a schematic diagram of the structure of the model training device in the embodiment of this specification;

[0041] Figure 8 Schematic diagram of the structure of a computer device in an embodiment of this specification. DETAILED DESCRIPTION

[0042] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0043] In the real world, there are various entities (such as companies, cities, users, devices, commodities, user social accounts, images, text or audio data, etc.). The entities may come from, including but not limited to, the financial industry, insurance industry, Internet industry, automobile industry, catering industry, telecommunications industry, energy industry, entertainment industry, sports industry, logistics industry, medical industry, security industry, etc. Graph data can be constructed based on entities and the relationships between entities. The graph data may include nodes and edges. The nodes are used to represent entities, and the edges are used to represent the relationships between entities. If the node and the edge are connected, it means that the entity corresponding to the node and the entity corresponding to the edge are connected. If the node and the edge are not connected, it means that the entity corresponding to the node and the entity corresponding to the edge are not connected. The graph data may include directed graph data and undirected graph data. The edges in the directed graph data have directions, and the edges in the undirected graph data have no directions. In practical applications, depending on the entity type, the graph data may include social graphs (nodes represent users, edges represent user relationships), device network graphs (nodes represent network devices, edges represent communication relationships), transfer graphs (nodes represent user accounts, edges represent fund flow relationships), etc.

[0044] The graph data may be used to represent a knowledge graph. For example, the graph data may include a social graph, a device network graph, and a transfer graph, and the corresponding knowledge graph may include a social knowledge graph, a device network knowledge graph, a transfer knowledge graph, and the like.

[0045] The knowledge graph may include multiple triples. The triples may be used to represent knowledge. The triples include a head entity, an entity relationship, and a tail entity. The head entity and the entity relationship are connected, and the entity relationship and the tail entity are connected. So that the head entity and the tail entity have the entity relationship. For example, the triple may be represented as (h, r, t), where h represents the head entity, r represents the entity relationship, and t represents the tail entity. Knowledge graph reasoning may be to obtain the missing elements by reasoning given two elements in a triple. For example, given the head entity h and the entity relationship r in a triple, the tail entity t is obtained by reasoning. For another example, given the entity relationship r and the tail entity t in a triple, the head entity h is obtained by reasoning.

[0046] In related technologies, the process of knowledge graph reasoning is as follows: obtain query entities and query relations; use entities in the knowledge graph as candidate entities; and select candidate entities that match the query entities and query relations as result entities by traversing the knowledge graph. For example, a rule-based reasoning method or a representation learning-based reasoning method can be used to select candidate entities as result entities. However, the number of entities in the knowledge graph is large, and directly using entities in the knowledge graph as candidate entities and selecting candidate entities as result entities by traversing the knowledge graph makes the efficiency of knowledge graph reasoning low.

[0047] In order to improve the efficiency of knowledge graph reasoning, the embodiments of this specification provide a knowledge graph reasoning method. The knowledge graph reasoning method can be applied to computer devices. The computer devices include but are not limited to personal computers, servers, server clusters including multiple servers, etc. Figure 1 The knowledge graph reasoning method may include the following steps.

[0048] Step S11: Obtain query entities and query relations.

[0049] In some embodiments, the query entity may be an entity in a knowledge graph, and the query relationship may be an entity relationship in the knowledge graph. In the knowledge graph, the query entity and the query relationship may be connected or not connected.

[0050] In some embodiments, due to various factors, the knowledge graph is often incomplete. Therefore, although an entity and an entity relationship are not connected in the knowledge graph, in the real world, the entity and the entity relationship still have the possibility of being connected. In other words, in the real world, the entity and the entity relationship still have the possibility of matching into a triple.

[0051] For example, in the real world, there is an entity relationship r between entity h and entity t. However, in the process of constructing the knowledge graph, the connectivity between entity h and entity relationship r, and the connectivity between entity relationship r and entity t are not observed. As a result, in the constructed knowledge graph, entity h and entity relationship r are not connected, and entity relationship r and entity t are not connected. Specifically, for example, in the real world, user A is the father of user B. However, in the knowledge graph, the entity "user A" is not connected to the entity relationship "father", and the entity relationship "father" is not connected to the entity "user B".

[0052] In some embodiments, the query entity and the query relationship can be used to find the result entity. The query entity, the query relationship and the result entity can be matched into a triple. The triple may exist in the knowledge graph. Alternatively, limited by the incompleteness of the knowledge graph, the triple may not exist in the knowledge graph. The query entity may be a head entity and the result entity may be a tail entity, or the query entity may be a tail entity and the result entity may be a head entity. For example, the query entity, the query relationship and the result entity can be matched into a triple (A, Plays_for, G). A represents the query entity, Plays_for represents the query relationship, and G represents the result entity.

[0053] In some embodiments, a query entity and a query relationship input by a user may be received. Specifically, a user may input a query entity and a query relationship. A query entity and a query relationship input by a user may be received. Alternatively, a user may input a query statement. A query statement input by a user may be received; a semantic analysis may be performed on the received query statement to obtain a query entity and a query relationship. For example, a user may input a query statement "Who is the father of Emperor Wu of Han." A query statement may be received; a semantic analysis may be performed on the received query statement to obtain a query entity "Emperor Wu of Han" and a query relationship "father".

[0054] Of course, query entities and query relationships sent by other devices can also be received. The other devices may include terminal devices such as smart phones and personal computers. Specifically, the other devices can send query entities and query relationships. Query entities and query relationships sent by other devices can be received. Alternatively, the other devices can send query statements. Query statements sent by other devices can be received; semantic analysis can be performed on the received query statements to obtain query entities and query relationships.

[0055] Step S13: Select neighboring entities of the query entity from the knowledge graph.

[0056] In some embodiments, considering that the result entity is often located near the query entity, a neighboring entity of the query entity can be selected from the knowledge graph. In this way, entities in the knowledge graph can be screened according to the query entity, avoiding traversing the entire knowledge graph when selecting the result entity, thereby reducing the number of candidate entities and improving the efficiency of knowledge graph reasoning.

[0057] In some embodiments, an entity whose proximity to the query entity is less than or equal to K1 order can be selected as a neighbor entity. The proximity can be characterized by an order. The order can include the number of edges in the shortest path between entities. For example, if the shortest path between two entities includes K edges, the proximity between the two entities can be considered to be K order. An entity can be called a K-order neighbor entity of another entity. The size of K1 can be positively correlated with the number of neighbor entities. The size of K1 can be flexibly set according to actual needs, for example, it can be 3, 4, 6, 8, 9, etc.

[0058] For example, in Figure 2 In the knowledge graph shown, nodes A, B, C, etc. represent entities, and the edges between nodes (such as Father_of, Lives_in, etc.) represent entity relationships. Figure 2 In the knowledge graph shown, entity A is the query entity, and entities B to H are the neighboring entities of entity A. Among them, entity B and entity D are the first-order neighboring entities of entity A. Entity C, entity G, entity E, and entity F are the second-order neighboring entities of entity A. Entity H is the third-order neighboring entity of entity A.

[0059] Of course, the proximity can also be represented by other methods. For example, the proximity can also be represented by the number of edges in the longest path between entities. Other methods can be used to select neighboring entities of the query entity from the knowledge graph.

[0060] Step S15: Determine the first probability of the neighbor entity.

[0061] In some embodiments, entities in the knowledge graph may have multiple types. For example, the types of entities in the knowledge graph may include "person", "object", "animal", "geographic location", etc. The query relationship can reflect the possible types of the result entity to a certain extent. For example, based on the query relationship "father", it can be inferred that the type of the result entity may be "person" or "animal", rather than "object" or "geographic location". Therefore, if the neighboring entities are screened according to the query relationship, the number of candidate entities can be further reduced, and the efficiency of knowledge graph reasoning can be improved.

[0062] However, knowledge graphs are often incomplete. If we directly obtain neighboring entities connected to the query relationship as candidate entities based on the connectivity between entities in the knowledge graph, we may miss neighboring entities, thereby reducing the accuracy of knowledge graph reasoning. For example, although the query relationship is not connected to a neighboring entity in the knowledge graph, in the real world, the query relationship and the neighboring entity are still likely to be connected. The neighboring entity may still become the result entity.

[0063] To this end, the first probability of each neighbor entity can be determined so that the neighbor entities can be screened according to the first probability, thereby improving the accuracy of knowledge graph reasoning. The first probability is used to indicate the possibility that the neighbor entity is connected to the query relationship. The magnitude of the first probability is positively correlated with the possibility. For example, the first probability can be a real number within the interval [0, 1]. The 0 indicates that the neighbor entity is not connected to the query relationship, and the 1 indicates that the neighbor entity is connected to the query relationship.

[0064] In some embodiments, the number of neighbor entities is one or more. A sub-knowledge graph of each neighbor entity can be extracted from the knowledge graph; type distribution information of the neighbor entity can be determined based on the sub-knowledge graph and the type distribution prediction model; and a first probability of the neighbor entity can be determined based on the type distribution information and the query relationship.

[0065] Entities whose proximity to neighboring entities is less than or equal to K2 can be selected from the knowledge graph; sub-knowledge graphs can be extracted from the knowledge graph, and the sub-knowledge graphs contain entities less than or equal to K2. The size of K2 can be positively correlated with the size of the sub-knowledge graph. The size of K2 can be flexibly set according to actual needs, for example, it can be 3, 5, 6, 10, etc. Of course, the degree of proximity can also be characterized by other methods, so that entities can be selected from the knowledge graph in other ways to extract sub-knowledge graphs based on the selected entities.

[0066] Of course, other methods can also be used to extract sub-knowledge graphs of neighboring entities from the knowledge graph.

[0067] For example, entities whose proximity to neighboring entities is less than or equal to K2 order, and entities whose proximity to neighboring entities is greater than K2 order and less than or equal to K3 order can be selected from the knowledge graph. Due to the richness of entity relationship types, it is more important for the type distribution prediction model. Therefore, for entities with a proximity greater than K2 order and less than or equal to K3 order, if the entity relationship connected to the entity is different from the entity relationship connected to the neighboring entity, the entity can be retained; if the entity relationship connected to the entity is the same as the entity relationship connected to the neighboring entity, the entity can be ignored. Therefore, sub-knowledge graphs can be extracted from the knowledge graph based on entities with a proximity less than or equal to K2 order, and retained entities with a proximity greater than K2 order and less than or equal to K3 order.

[0068] The type distribution information is used to indicate the possibility of the neighboring entity being connected to a variety of known entity relationships. The type distribution information may include the probability distribution of the neighboring entity on a variety of known entity relationships. The multiple known entity relationships may specifically include various types of entity relationships in the knowledge graph. The multiple known entity relationships may include entity relationships connected to neighboring entities in the knowledge graph, and may also include entity relationships that are not connected to neighboring entities in the knowledge graph. For example, the entity relationships in the knowledge graph may be deduplicated to obtain the multiple known entity relationships. For example, in Figure 3 In the knowledge graph shown, entities in gray represent neighboring entities. Figure 3 The knowledge graph shown includes 11 entity relationships such as r1 to r11. The type distribution information includes the probability distribution of neighbor entities on the 11 entity relationships. Among them, the probability that the neighbor entity is connected to the entity relationship r1 is 0.2, the probability that the neighbor entity is connected to the entity relationship r2 is 1, the probability that the neighbor entity is connected to the entity relationship r3 is 0.2, the probability that the neighbor entity is connected to the entity relationship r4 is 0, the probability that the neighbor entity is connected to the entity relationship r5 is 1, the probability that the neighbor entity is connected to the entity relationship r6 is 0.3, the probability that the neighbor entity is connected to the entity relationship r7 is 0.5, the probability that the neighbor entity is connected to the entity relationship r8 is 0, the probability that the neighbor entity is connected to the entity relationship r9 is 0, the probability that the neighbor entity is connected to the entity relationship r10 is 0.1, and the probability that the neighbor entity is connected to the entity relationship r11 is 0.

[0069] The type distribution prediction model can be used to determine type distribution information. The type distribution prediction model may include a graph neural network model (GNN), a multi-layer perceptron (MLP), etc. The graph structure data of the sub-knowledge graph can be input into the graph neural network model to obtain the type distribution information of the neighboring entities. The graph structure data may include an embedding representation of an entity and an embedding representation of an entity relationship. The embedding representation may include a vector, etc.

[0070] For example, see Figure 4 The graph neural network model may include an input layer, multiple hidden layers, and an output layer. The input layer is used to input graph structure data into the hidden layer. The hidden layer is used to update the embedding representation of the entity and the embedding representation of the entity relationship. For each hidden layer, the embedding representation of the entity and the embedding representation of the entity relationship will be updated once. For example, the hidden layer can use the following formula to update the embedding representation of the entity and the embedding representation of the entity relationship: in, represents the embedding representation of entity relationship e, N(v) represents the set of entity relationships connected to entity v, represents the embedding representation of entity v, represents the updated embedding representation of the entity relationship e, represents the embedding representation of entity u, v,u∈N(e), N(e) represents the set of entities connected by entity relationship e, N(e) contains two entities such as v and u, [] represents the concatenation operation, W i represents the transformation matrix, b i represents the bias vector, and σ represents the ReLU function. The output layer can be understood as a multi-classifier. The output layer is used to classify neighbor entities according to the embedded representation of the neighbor entities, and obtain the probability distribution of the neighbor entities on multiple known entity relationships.

[0071] For the training process of the type distribution prediction model, please refer to the subsequent embodiments.

[0072] The type distribution information may include probability distribution of neighbor entities on multiple known entity relationships. The multiple known entity relationships may include query relationships. The first probability of the neighbor entity may be determined based on the type distribution information and the query relationship. Specifically, the corresponding probability may be obtained from the type distribution information based on the query relationship as the first probability. For example, see Figure 3 The type distribution information may include probability distribution of neighbor entities on 11 entity relationships, such as r1 to r11. The query relationship may be entity relationship r1. The probability that the neighbor entity is connected to entity relationship r1 may be obtained as the first probability.

[0073] Step S17: According to the first probability, select a neighbor entity as a candidate entity.

[0074] In some embodiments, one or more neighbor entities may be directly selected from one or more neighbor entities as candidate entities based on the first probability. For example, one or more neighbor entities with the largest first probability may be selected as candidate entities.

[0075] In some embodiments, the second probability of the neighbor entity can also be calculated based on the first probability and the degree of the neighbor entity; the neighbor entity can be selected as a candidate entity based on the second probability. The degree of the neighbor entity can include the number of entity relationships connected to the neighbor entity. For example, the graph data corresponding to the knowledge graph can be directed graph data, and the degree of the neighbor entity can include the sum of the out-degree and in-degree of the node corresponding to the neighbor entity. For another example, the graph data corresponding to the knowledge graph can be undirected graph data, and the degree of the neighbor entity can include the number of edges of the node corresponding to the neighbor entity. The more entity relationships connected to the neighbor entity, the more likely the neighbor entity is to be a candidate entity. Using the second probability in this way is conducive to more accurate selection of candidate entities.

[0076] The first probability and the degree of the neighboring entity can be subjected to mathematical operations such as addition and multiplication to obtain the second probability of the neighboring entity. For example, the first probability of the neighboring entity can be p(r|e), and the degree of the neighboring entity can be p(e). The second probability can be calculated according to the formula p(e|r)=p(e)×p(r|e). p(e|r) represents the second probability. r represents the query relationship, and e represents the neighboring entity.

[0077] One or more neighbor entities with the second highest probability may be selected from the one or more neighbor entities as candidate entities.

[0078] For example, in Figure 2 In the knowledge graph shown, entity A is the query entity, and entities B to H are neighbor entities of entity A. Neighbor entities G and H can be selected from neighbor entities B to H as candidate entities.

[0079] Step S19: Select candidate entities that match the query entity and the query relationship as result entities.

[0080] In some embodiments, the number of candidate entities is one or more. A result entity may be selected from the one or more candidate entities. The result entity, the query entity, and the query relationship may be matched into a triple.

[0081] In some embodiments, for each candidate entity, a candidate triple can be constructed based on the candidate entity, the query entity, and the query relationship. The number of candidate triples can be equal to the number of candidate entities. The confidence of the candidate triple can be determined. The confidence is used to indicate the degree of trust that the candidate triple can be established. The candidate triple can be selected as the target triple based on the confidence. The candidate entity in the target triple can be determined as the result entity.

[0082] The confidence of the candidate triples can be determined by using a rule-based reasoning method or a representation learning-based reasoning method. Taking the representation learning-based reasoning method as an example, the confidence of the candidate triples can be determined based on the embedded representation of the query entity, the embedded representation of the candidate entity, and the embedded representation of the query relationship in the candidate triples. For example, the embedded representation of the query entity and the embedded representation of the candidate entity can be subtracted; the subtraction result can be compared with the embedded representation of the query relationship; and the confidence of the candidate triples can be determined based on the comparison result. The closer the subtraction result is to the embedded representation of the query relationship, the greater the confidence of the candidate triple. Of course, the candidate triples can also be scored using a scoring function based on the embedded representation of the query entity, the embedded representation of the candidate entity, and the embedded representation of the query relationship; the score can be used as the confidence of the candidate triple.

[0083] From one or more candidate triples, a candidate triple with the highest confidence may be selected as a target triple.

[0084] For example, see Figure 2 . Candidate entity G, query entity A and query relation Plays_for can constitute candidate triple triad1. Candidate entity H, query entity A and query relation Plays_for can constitute candidate triple triad2. The embedding representation of candidate entity G is subtracted from the embedding representation of query entity A, and the subtraction result is close to the embedding representation of query relation Plays_for. Therefore, the confidence of candidate triple triad1 is relatively large. The embedding representation of candidate entity H is subtracted from the embedding representation of query entity A, and the subtraction result is far away from the embedding representation of query relation Plays_for. Therefore, the confidence of candidate triple triad2 is relatively small. Candidate triple triad1 can be selected as the target triple. Candidate entity G in the target triple can be used as the result entity.

[0085] The knowledge graph reasoning method of the embodiment of the present specification can obtain the query entity and the query relationship; can select the neighboring entity of the query entity from the knowledge graph; can determine the first probability of the neighboring entity; can select the neighboring entity as the candidate entity according to the first probability; can select the candidate entity that matches the query entity and the query relationship as the result entity. In this way, the entities in the knowledge graph can be screened according to the query entity to obtain the neighboring entities; the neighboring entities can be screened according to the first probability to obtain the candidate entities. Thereby, the number of candidate entities can be reduced and the efficiency of knowledge graph reasoning can be improved.

[0086] The embodiment of this specification also provides a model training method. The model training method can be applied to a computer device. The computer device includes but is not limited to a personal computer, a server, a server cluster including multiple servers, etc.

[0087] See also Figure 5 The model training method may include the following steps.

[0088] Step S21: Mask one or more entity relationships of the target entity in the knowledge graph sample.

[0089] In some embodiments, the number of knowledge graph samples can be multiple.

[0090] Multiple knowledge graphs can be obtained as knowledge graph samples; an entity can be selected from each knowledge graph sample as a target entity. Alternatively, multiple entities can be selected from the knowledge graph as target entities; sub-knowledge graphs of each target entity can be extracted from the knowledge graph as knowledge graph samples. The process of extracting the sub-knowledge graph of the target entity can refer to the process of extracting the sub-knowledge graph of the neighboring entity in the above embodiment, which will not be repeated here.

[0091] In some embodiments, the knowledge graph sample may include a target entity. The entity relationship of the target entity may include the entity relationship connected to the target entity. One or more entity relationships of the target entity may be masked. Specifically, all entity relationships of the target entity may be masked. Alternatively, any one or more entity relationships of the target entity may be masked. The masking process may include deletion, etc.

[0092] by Figure 3 Taking the knowledge graph shown as an example, the entity in gray is the target entity. The entity relationships of the target entity may include r2, r3, r5, etc. The entity relationships r3 and r5 of the target entity may be masked.

[0093] Step S23: Determine the type distribution information of the target entity based on the masked knowledge graph sample and the type distribution prediction model, where the type distribution information is used to indicate the possibility of the target entity being connected to multiple known entity relationships.

[0094] In some embodiments, the type distribution prediction model may include a graph neural network model, a multi-layer perceptron, etc. The graph structure data of the knowledge graph sample after masking processing may be obtained; the graph structure data may be input into the type distribution prediction model to obtain the type distribution information of the target entity. The graph structure data may include an embedded representation of the entity and an embedded representation of the entity relationship. The type distribution information is used to indicate the possibility of the target entity being connected to a plurality of known entity relationships. The plurality of known entity relationships may specifically include various types of entity relationships in the knowledge graph sample.

[0095] Step S25: Determine a third probability of the target entity according to the type distribution information and the masked entity relationship, where the third probability is used to indicate the possibility that the target entity is connected to the masked entity relationship.

[0096] In some embodiments, the type distribution information includes a probability distribution of the target entity on a plurality of known entity relationships. The plurality of known entity relationships include masked entity relationships. A third probability of the target entity can be determined based on the type distribution information and the masked entity relationships. The third probability is used to indicate the possibility that the target entity is connected to the masked entity relationship. Specifically, a corresponding probability can be obtained from the type distribution information as the third probability based on the masked entity relationship.

[0097] Step S27: Optimize the model parameters of the type distribution prediction model according to the third probability.

[0098] In some embodiments, the model parameters of the type distribution prediction model can be optimized directly based on the third probability. For example, a target probability can be set for the masked entity relationship, and the target probability is used to indicate that the target entity is connected to the masked entity relationship. The target probability can be 1, for example. Loss information can be calculated based on the third probability and the target probability; the model parameters of the type distribution prediction model can be optimized based on the loss information. For example, the model parameters are optimized using a back propagation mechanism.

[0099] In some embodiments, a fourth probability of the target entity may be determined based on the type distribution information and the specific entity relationship; and model parameters of the type distribution prediction model may be optimized based on the third probability and the fourth probability. The specific entity relationship may include an entity relationship that is not connected to the target entity. Figure 3 Taking the knowledge graph shown in the figure as an example, the gray entity is the target entity. Specific entity relationships may include r1, r4, r6, r7, r8, r9, r10, and r11.

[0100] The type distribution information includes probability distribution of the target entity on multiple known entity relationships. The multiple known entity relationships include specific entity relationships. According to the specific entity relationship, a corresponding probability can be obtained from the type distribution information as a fourth probability. The fourth probability is used to indicate the possibility of the target entity being connected to the specific entity relationship.

[0101] The loss information can be calculated using a loss function according to the third probability and the fourth probability, and the model parameters of the type distribution prediction model can be optimized according to the loss information, for example, by using a back propagation mechanism to optimize the model parameters.

[0102] The loss function may include a cross entropy loss function, a mean square error loss function, etc. The loss function is used to constrain the third probability to be greater than the fourth probability. In some scenario examples, the loss function can be expressed as Among them, Ω obs represents the set of observable entity relationships, Ω uno represents the set of unobservable entity relationships, p j Represents the target entity and the set Ω uno The probability that the entity relationship j in is connected, p i Represents the target entity and the set Ω obs The probability that entity relationship i is connected, p j and p i It can be obtained from the type distribution information, and γ and m are hyperparameters. Among them, the observable entity relationship can be understood as: the entity relationship connected to the target entity in the knowledge graph sample. The unobservable entity relationship can be understood as: the entity relationship that is not connected to the target entity in the knowledge graph sample. Set Ω obs and the set Ω uno The union of can include various types of entity relationships in the knowledge graph sample. In addition, it is worth noting that the set Ω obs It can include masked entity relationships. Of course, the set Ω obs It can also include entity relationships that are connected to the target entity but not masked. uno Specific entity relationships may be included. In addition, the calculation formula of the loss function is only an example, and may have other deformations or changes in practice.

[0103] In some embodiments, steps S21 to S27 may be iteratively performed until an iteration termination condition is satisfied. The iteration termination condition may include: the number of iterations reaches a preset number. Through at least one iteration, a better model parameter may be obtained.

[0104] The model training method of the embodiment of this specification realizes the training of the type distribution prediction model by masking the entity relationship of the target entity in the knowledge graph sample. In this way, the type distribution prediction model can be trained in a self-supervised manner without labeling the knowledge graph sample. The trained type distribution prediction model is used to determine the type distribution information.

[0105] See also Figure 6 The embodiment of this specification also provides a knowledge graph reasoning device, including the following units.

[0106] An acquisition unit 31, used to acquire a query entity and a query relationship;

[0107] A first selection unit 33, configured to select a neighboring entity of a query entity from the knowledge graph;

[0108] A determination unit 35, configured to determine a first probability of a neighbor entity, wherein the first probability is used to indicate a possibility that the neighbor entity is connected to the query relationship;

[0109] A second selection unit 37, configured to select a neighbor entity as a candidate entity according to the first probability;

[0110] The third selection unit 39 is used to select a candidate entity that matches the query entity and the query relationship as a result entity.

[0111] See also Figure 7 The embodiment of this specification also provides a model training device, including the following units.

[0112] A masking unit 41, used to mask one or more entity relationships of a target entity in a knowledge graph sample;

[0113] An acquisition unit 43 is used to determine type distribution information of a target entity according to the masked knowledge graph sample and the type distribution prediction model, wherein the type distribution information is used to indicate the possibility of the target entity being connected to multiple known entities;

[0114] A determination unit 45, configured to determine a third probability of the target entity according to the type distribution information and the masked entity relationship, wherein the third probability is used to indicate a possibility of the target entity being connected to the masked entity relationship;

[0115] The optimization unit 47 is used to optimize the model parameters of the type distribution prediction model according to the third probability.

[0116] An embodiment of the computer device of the present specification is introduced below. Figure 8 Schematic diagram of the hardware structure of the computer device in this embodiment. Figure 8As shown, the computer device may include one or more (only one is shown in the figure) processors, memory and transmission modules. Of course, it can be understood by those skilled in the art that Figure 8 The hardware structure shown is only for illustration and does not limit the hardware structure of the above-mentioned computer device. In practice, the computer device may also include Figure 8 More or fewer component units as shown; or, Figure 8 Different configurations shown.

[0117] The memory may include a high-speed random access memory; or, it may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory or other non-volatile solid-state memory. Of course, the memory may also include a remotely set network memory. The memory may be used to store program instructions or modules of application software, such as the instructions in this manual. Figure 1 or Figure 5 The program instructions or modules of the corresponding embodiment.

[0118] The processor may be implemented in any suitable manner. For example, the processor may take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, etc. The processor may read and execute program instructions or modules in the memory.

[0119] The transmission module can be used for transmitting data via a network, for example, via a network such as the Internet, an intranet, a local area network, a mobile communication network, etc.

[0120] This specification also provides an embodiment of a computer storage medium. The computer storage medium includes but is not limited to a random access memory (RAM), a read-only memory (ROM), a cache, a hard disk (HDD), a memory card, etc. The computer storage medium stores computer program instructions. When the computer program instructions are executed, the following are achieved: Figure 1 or Figure 5 The program instructions or modules of the corresponding embodiment.

[0121] It should be noted that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, computer equipment embodiment, and computer storage medium embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. In addition, it is understandable that after reading this specification document, those skilled in the art can think of any combination of some or all of the embodiments listed in this specification without creative work, and these combinations are also within the scope of disclosure and protection of this specification.

[0122] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0123] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0124] It can be known from the above description of the implementation mode that the technicians in this field can clearly understand that the present specification can be implemented by means of software plus the necessary general hardware platform. Based on such an understanding, the technical solution of the present specification can be essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present specification or some parts of the embodiments.

[0125] This specification can be used in many general or special computer system environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, and distributed computing environments that include any of the above systems or devices.

[0126] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0127] Although the present specification is described through embodiments, those skilled in the art will appreciate that there are many modifications and changes to the present specification without departing from the spirit of the present specification, and it is intended that the appended claims include these modifications and changes without departing from the spirit of the present specification.

Claims

1. A knowledge graph reasoning method, comprising: Get the query entity and query relationship; Select neighboring entities of the query entity from the knowledge graph; Determine a first probability of a neighbor entity, where the first probability is used to indicate the possibility that the neighbor entity is connected to the query relationship; According to the first probability, a neighbor entity is selected as a candidate entity; Candidate entities that match the query entity and the query relation are selected as result entities.

2. According to the method of claim 1, the step of selecting a neighbor entity of the query entity from the knowledge graph comprises: Select entities from the knowledge graph whose proximity to the query entity is less than or equal to K1 as neighboring entities; The degree includes the number of edges in the shortest path between entities.

3. The method according to claim 1, wherein determining the first probability of the neighbor entity comprises: Determine type distribution information of neighbor entities, where the type distribution information is used to indicate the possibility of connection between neighbor entities and multiple known entities; According to the type distribution information and the query relationship, a first probability of the neighbor entity is determined.

4. The method according to claim 3, wherein determining the type distribution information of the neighboring entities comprises: Extract the sub-knowledge graph of neighboring entities from the knowledge graph; According to the sub-knowledge graph and the type distribution prediction model, the type distribution information of the neighboring entities is determined.

5. According to the method of claim 4, extracting a sub-knowledge graph of neighbor entities from the knowledge graph comprises: Select entities from the knowledge graph whose proximity to neighboring entities is less than or equal to K2 order; Extracting a sub-knowledge graph from the knowledge graph, wherein the sub-knowledge graph contains entities of order less than or equal to K2; The degree includes the number of edges in the shortest path between entities.

6. According to the method of claim 4, the type distribution prediction model comprises a graph neural network model; The determining of type distribution information of neighbor entities includes: The graph structure data of the sub-knowledge graph is input into the graph neural network model to obtain the type distribution information of the neighboring entities, wherein the graph structure data includes the embedded representation of the entity and the embedded representation of the entity relationship.

7. According to the method of claim 4, the type distribution prediction model is trained according to the following method: Mask one or more entity relationships of the target entity in the knowledge graph sample; Determine the type distribution information of the target entity according to the masked knowledge graph sample and the type distribution prediction model, wherein the type distribution information is used to indicate the possibility of the target entity being connected to multiple known entity relationships; Determine a third probability of the target entity according to the type distribution information and the masked entity relationship, wherein the third probability is used to indicate the possibility that the target entity is connected to the masked entity relationship; Based on the third probability, model parameters of the type distribution prediction model are optimized.

8. The method according to claim 7, further comprising: Determine, according to the type distribution information and the specific entity relationship, a fourth probability of the target entity, wherein the fourth probability is used to indicate the possibility that the target entity is connected to the specific entity relationship, wherein the specific entity relationship includes an entity relationship that the target entity is not connected to; The model parameters of the optimization type distribution prediction model include: Based on the third probability and the fourth probability, model parameters of the type distribution prediction model are optimized.

9. The method according to claim 1, wherein selecting a neighbor entity as a candidate entity comprises: Calculate the second probability of the neighbor entity according to the first probability and the degree of the neighbor entity; According to the second probability, a neighbor entity is selected as a candidate entity.

10. The method according to claim 1, wherein the step of selecting a candidate entity that matches the query entity and the query relationship as a result entity comprises: Construct candidate triples based on candidate entities, query entities, and query relations; According to the confidence of the candidate triplet, the candidate triplet is selected as the target triplet; The candidate entities in the target triplet are determined as the result entities.

11. According to the method of claim 1, the query entity is a head entity, and the result entity is a tail entity; or, the query entity is a tail entity, and the result entity is a head entity.

12. A model training method, comprising: Mask one or more entity relationships of the target entity in the knowledge graph sample; Determine the type distribution information of the target entity according to the masked knowledge graph sample and the type distribution prediction model, wherein the type distribution information is used to indicate the possibility of the target entity being connected to multiple known entity relationships; Determine a third probability of the target entity according to the type distribution information and the masked entity relationship, wherein the third probability is used to indicate the possibility that the target entity is connected to the masked entity relationship; Based on the third probability, model parameters of the type distribution prediction model are optimized.

13. The method according to claim 12, further comprising: Determine, according to the type distribution information and the specific entity relationship, a fourth probability of the target entity, wherein the fourth probability is used to indicate the possibility that the target entity is connected to the specific entity relationship, wherein the specific entity relationship includes an entity relationship that the target entity is not connected to; The model parameters of the optimization type distribution prediction model include: Based on the third probability and the fourth probability, model parameters of the type distribution prediction model are optimized.

14. A knowledge graph reasoning device, comprising: An acquisition unit, used for acquiring query entities and query relations; A first selection unit, used to select neighboring entities of the query entity from the knowledge graph; A determining unit, configured to determine a first probability of a neighbor entity, wherein the first probability is used to indicate a possibility that the neighbor entity is connected to the query relationship; A second selection unit, configured to select a neighbor entity as a candidate entity according to the first probability; The third selection unit is used to select a candidate entity that matches the query entity and the query relationship as a result entity.

15. A model training device, comprising: A masking unit, used to mask one or more entity relationships of a target entity in a knowledge graph sample; An acquisition unit, used to determine type distribution information of a target entity according to the masked knowledge graph sample and the type distribution prediction model, wherein the type distribution information is used to indicate the possibility of the target entity being connected to multiple known entities; A determination unit, configured to determine a third probability of the target entity according to the type distribution information and the masked entity relationship, wherein the third probability is used to indicate a possibility of the target entity being connected to the masked entity relationship; The optimization unit is used to optimize the model parameters of the type distribution prediction model according to the third probability.

16. A computer device comprising: at least one processor; A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for executing the method according to any one of claims 1-13.