Knowledge graph reasoning model training method, device and storage medium

By optimizing the entity node representation and logical structure of the knowledge graph reasoning model through the neighborhood diffusion module and triple reconstruction error, the model's insufficient generalization ability when facing unseen logical structures and out-of-domain data is solved, thereby improving the model's reasoning accuracy and noise resistance.

CN115577119BActive Publication Date: 2026-04-21ALIBABA (CHINA) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ALIBABA (CHINA) CO LTD
Filing Date
2022-10-09
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing knowledge graph reasoning models have poor generalization ability when faced with unseen first-order logical structures and out-of-domain data, making them difficult to resist noise and resulting in decreased reasoning accuracy, especially in open-set knowledge graphs.

Method used

The neighboring entity nodes are searched by the neighborhood diffusion module to expand the inference subgraph, optimize the vector representation of entity nodes, and introduce triple reconstruction error to distinguish between data inside and outside the domain. A new first-order logical structure is constructed by combining multi-level connection query, and feature aggregation and logical structure expansion are performed by using neighborhood filter.

Benefits of technology

It improves the generalization ability and reasoning performance of the knowledge graph reasoning model for unseen first-order logical structures, enhances its resistance to interference from data outside the domain, and improves reasoning accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115577119B_ABST
    Figure CN115577119B_ABST
Patent Text Reader

Abstract

This application provides a method, device, and storage medium for training a knowledge graph reasoning model. The method includes: obtaining a first tuple corresponding to a first first-order logical structure; determining the first adjacent entity nodes corresponding to each entity node in the first tuple in the knowledge graph; determining a second tuple and a second first-order logical structure corresponding to the second tuple in a reasoning subgraph containing multiple entity nodes and their corresponding first adjacent entity nodes. The method further involves determining the second adjacent entity nodes corresponding to each entity node in the target tuple in the knowledge graph; determining the second vector representation corresponding to the corresponding entity node based on the concatenation result of the first vector representations of the entity node and its second adjacent entity node, thereby obtaining a vector representation set for the target tuple. The knowledge graph reasoning model is then trained based on the vector representation set. Model performance is improved by optimizing the vector representations of entity nodes and expanding the samples of new first-order logical structures.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, device and storage medium for training a knowledge graph reasoning model. Background Technology

[0002] A knowledge graph (KG) can be viewed as a graph containing various relationships. In the graph, each node is an entity (such as a person's name, place name, event, or activity), and the edge between any two nodes represents the relationship between them. Generally, any two connected nodes in a knowledge graph and their connecting edge can be represented as a triplet, i.e., (head entity node, relationship, tail entity node), for example: (Beijing, capital, China).

[0003] Knowledge graph reasoning is a method for exploring machine intelligence by mimicking human social cognitive patterns. Researchers have extensively studied common-sense reasoning algorithms based on knowledge graphs, combining mathematical logic, relational paths, and distributed representations, and have achieved generalization of reasoning capabilities under first-order logic queries using deep learning models. One approach to knowledge graph reasoning is to embed the knowledge graph and query into a low-dimensional vector space for first-order logic (FOL) reasoning. Unlike the basic triple structure, first-order logic is implemented through combinations of logical predicates and logical quantifications, such as the use of logical operators like existence, conjunction, disjunction, negation, and mapping, making it well-suited for describing relationships. These logical operators allow the learning objective of knowledge graph reasoning models to typically focus on logical mapping rather than the representation of entities and relationships.

[0004] However, first-order logical reasoning often requires artificially defined logical paradigms (or logical structures), which have a weak ability to generalize to unseen logical paradigms, resulting in poor generalization. Furthermore, the relatively poor representation makes the reasoning model less resistant to noise, thus adversely affecting the accuracy of reasoning, especially in open-set knowledge graphs constructed from real-world knowledge. Summary of the Invention

[0005] This invention provides a method, apparatus, device, and storage medium for training a knowledge graph reasoning model, in order to improve the generalization ability and accuracy of the knowledge graph reasoning model.

[0006] In a first aspect, embodiments of the present invention provide a method for training a knowledge graph reasoning model, the method comprising:

[0007] Obtain a first tuple corresponding to the first first-order logical structure. The first tuple includes multiple entity nodes and at least one relation determined from preset training query information. The multiple entity nodes include at least one anchor entity node and a target entity node.

[0008] In the preset knowledge graph, determine the first adjacent entity node corresponding to each of the multiple entity nodes in the first tuple;

[0009] In the reasoning subgraph that includes the plurality of entity nodes and the first adjacent entity nodes corresponding to each of the plurality of entity nodes, a second tuple and the second first-order logic structure corresponding to the second tuple are determined.

[0010] In the knowledge graph, determine the second neighboring entity node corresponding to any entity node in the target tuple, wherein the target tuple is either the first tuple or the second tuple;

[0011] The second vector representation corresponding to any entity node is determined based on the concatenation result of the first vector representations corresponding to any entity node and its second neighboring entity node, so as to obtain the vector representation set corresponding to the target tuple. The vector representation set includes the second vector representation of each entity node in the target tuple and the initial vector representation of each relation.

[0012] The knowledge graph reasoning model is trained based on the vector representation set.

[0013] Secondly, embodiments of the present invention provide a knowledge graph reasoning model training device, the device comprising:

[0014] The acquisition module is used to acquire a first tuple corresponding to the first first-order logical structure. The first tuple includes multiple entity nodes and at least one relation determined from preset training query information. The multiple entity nodes include at least one anchor entity node and a target entity node.

[0015] The neighbor diffusion module is used to determine, in a preset knowledge graph, the first neighboring entity node corresponding to each of the plurality of entity nodes in the first tuple; in a reasoning subgraph containing the plurality of entity nodes and the first neighboring entity nodes corresponding to each of the plurality of entity nodes, determine the second tuple and the second first-order logical structure corresponding to the second tuple; and determine the second neighboring entity node corresponding to any entity node in the target tuple in the knowledge graph, wherein the target tuple is either the first tuple or the second tuple.

[0016] The feature determination module is used to determine the second vector representation corresponding to any entity node based on the concatenation result of the first vector representations corresponding to any entity node and its second neighboring entity node, so as to obtain the vector representation set corresponding to the target tuple. The vector representation set includes the second vector representation of each entity node in the target tuple and the initial vector representation of each relation.

[0017] The training module is used to train the knowledge graph reasoning model based on the vector representation set.

[0018] Thirdly, embodiments of the present invention provide an electronic device, including: a memory, a processor, and a communication interface; wherein, the memory stores executable code, and when the executable code is executed by the processor, the processor executes the knowledge graph reasoning model training method as described in the first aspect.

[0019] Fourthly, embodiments of the present invention provide a non-transitory machine-readable storage medium storing executable code, wherein when the executable code is executed by a processor of an electronic device, the processor executes the knowledge graph reasoning model training method as described in the first aspect.

[0020] Fifthly, embodiments of the present invention provide a method for training a knowledge graph reasoning model, the method comprising:

[0021] Receive a request triggered by a user device through calling a knowledge graph reasoning model training service, the request including the preset training query information;

[0022] The following steps are performed using the processing resources corresponding to the knowledge graph reasoning model training service:

[0023] Obtain a first tuple corresponding to the first first-order logical structure. The first tuple includes multiple entity nodes and at least one relation determined from the preset training query information. The multiple entity nodes include at least one anchor entity node and a target entity node.

[0024] In the preset knowledge graph, determine the first adjacent entity node corresponding to each of the multiple entity nodes in the first tuple;

[0025] In the reasoning subgraph that includes the plurality of entity nodes and the first adjacent entity nodes corresponding to each of the plurality of entity nodes, a second tuple and the second first-order logic structure corresponding to the second tuple are determined.

[0026] In the knowledge graph, determine the second neighboring entity node corresponding to any entity node in the target tuple, wherein the target tuple is either the first tuple or the second tuple;

[0027] The second vector representation corresponding to any entity node is determined based on the concatenation result of the first vector representations corresponding to any entity node and its second neighboring entity node, so as to obtain the vector representation set corresponding to the target tuple. The vector representation set includes the second vector representation of each entity node in the target tuple and the initial vector representation of each relation.

[0028] The knowledge graph reasoning model is trained based on the vector representation set.

[0029] In the training process of the knowledge reasoning model provided in this embodiment of the invention, multiple first-order logical structures can be pre-defined. Query information corresponding to any first-order logical structure is accepted as input. The query information used for training is converted into a tuple form according to its corresponding first-order logical structure. Each tuple contains at least one anchor entity node, at least one relation, and a target entity node. Then, a neighborhood diffusion strategy is used to enhance entity features (vector representation optimization) and expand the logical structure at the logical level (logic enhancement). This optimizes the vector representations corresponding to entity nodes and expands to include more first-order logical structures, thereby expanding the training samples. Thus, through the above representation establishment and logic enhancement processes, the knowledge graph reasoning model can learn more sample tuples of unseen first-order logical structures based on more optimized entity node vector representations, improving the generalization ability and reasoning performance of the knowledge graph reasoning model for unseen first-order logical structures.

[0030] Specifically, the above logic enhancement process is manifested as follows: First, for each anchor entity node and target entity node contained in the first tuple, their neighboring entity nodes are searched in the known knowledge graph. Thus, these anchor entity nodes, target entity nodes, and the searched neighboring entity nodes constitute an expanded inference subgraph. In this inference subgraph, a new second-order logical structure and its corresponding second tuple can be discovered, achieving sample expansion. The above representation establishment process is manifested as follows: Regardless of whether it is the first tuple or the second tuple, for ease of description, it is referred to as the target tuple. The neighboring entity nodes corresponding to each entity node in the target tuple are determined in the knowledge graph. For any entity node, its vector representation can be optimized by combining the first vector representation corresponding to its neighboring entity nodes. In this way, the vector representations of each entity node in the target tuple are optimized based on the features of its neighboring entity nodes. Then, the knowledge graph inference model can be trained based on the vector representation set containing the optimized entity node vector representations. Attached Figure Description

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

[0032] Figure 1 A flowchart of a knowledge graph reasoning model training method provided in an embodiment of the present invention;

[0033] Figure 2 Schematic diagrams of various defined first-order logic structures provided in embodiments of the present invention;

[0034] Figure 3 A schematic diagram illustrating the first-order logic structure expansion process provided in an embodiment of the present invention;

[0035] Figure 4 This is a schematic diagram illustrating the application of a knowledge graph reasoning model training method provided in an embodiment of the present invention.

[0036] Figure 5 A flowchart of a knowledge graph reasoning model training method provided in an embodiment of the present invention;

[0037] Figure 6 A flowchart of a knowledge graph reasoning model training method provided in an embodiment of the present invention;

[0038] Figure 7 A flowchart of a knowledge graph reasoning model training method provided in an embodiment of the present invention;

[0039] Figure 8 This is a schematic diagram illustrating the application of a knowledge graph reasoning model training method provided in an embodiment of the present invention.

[0040] Figure 9 This is a schematic diagram of the structure of a knowledge graph reasoning model training device provided in an embodiment of the present invention;

[0041] Figure 10 This is a schematic diagram of the structure of an electronic device provided in this embodiment. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0043] Furthermore, the timing of the steps in the following method embodiments is merely an example and not a strict limitation.

[0044] First, let's explain some of the concepts involved in this article.

[0045] Knowledge Graph: A knowledge graph is a knowledge base that uses a graph-structured data model or topology to integrate data. It is typically used to store descriptions of entities and the relationships between them, while also encoding the semantics of the descriptions (i.e., the text used to describe entities and relationships). Entities include names of people, places, events, and activities. In a knowledge graph, two entities and their associated relationships can be organized into a triple representation.

[0046] Open set knowledge graph: An open set knowledge graph, also known as an open domain knowledge graph, is a knowledge graph composed of triples from different source data domains. Triples with a larger proportion from different sources are considered in-domain data, while those with a smaller proportion from different sources are considered out-of-domain data.

[0047] Knowledge graph reasoning: Reasoning new facts, relationships, and rules based on existing facts in a knowledge graph. It generally revolves around reasoning about relationships and focuses on examining entities, relationships, and graph structure.

[0048] Reasoning Subgraph: In a knowledge graph structure, a directed subgraph consists of sets of entities related to multi-hop reasoning queries and logical operators. Nodes in the graph represent sets of entities, and edges represent logical operators. Logical operators include, for example, existence, conjunction, disjunction, negation, and mapping.

[0049] Multi-hop knowledge graph reasoning: This involves performing logical operations on the directed edges along the path from the anchor entity node set (source node of the reasoning subgraph) to the target entity node set (sink node of the reasoning subgraph) in the reasoning subgraph, using the corresponding logical operators. If the number of anchor entity nodes in the anchor entity set is greater than 1, the path length is greater than or equal to 1; if the number of anchor entity nodes in the anchor entity set is equal to 1, the path length is greater than 1. For ease of understanding, multi-hop knowledge graph reasoning can be simply considered as starting from an anchor entity node and needing to traverse multiple relational edges to reach the target entity node.

[0050] First-order logic: First-order logic is a set of logical paradigms consisting of logical predicates (such as logical intersection, logical union, and logical negation) and logical quantifiers (such as existential quantifiers and universal quantifiers).

[0051] Distributed hypothesis: In natural language processing, if two words have similar contexts, then the two words themselves are also similar; extending to the knowledge graph domain, if the neighboring nodes of two entity nodes in the knowledge graph structure are similar, then the low-dimensional vector representations of the two entity nodes themselves are also similar.

[0052] Prompt: An input format or template designed for downstream tasks that helps knowledge graph reasoning models grasp the unique characteristics of each logical structure.

[0053] Traditional knowledge graph reasoning schemes based on first-order logic can only perform reasoning based on a limited set of predefined first-order logic structures. These models exhibit poor generalization to unseen first-order logic structures and are susceptible to interference from external data. Furthermore, relatively poor representations (primarily the vector representations of entity nodes) make them vulnerable to noise, severely impacting reasoning accuracy. Specifically, several first-order logic structures are predefined, and query information conforming to these structures is collected as training samples for training the knowledge graph reasoning model. If, after training, the input query information does not conform to these defined first-order logic structures, the model's reasoning results are often inaccurate. This is especially true in open-set knowledge graphs constructed from knowledge from different source domains, where interference from external data and the problem of unseen first-order logic structures have a more significant impact on the accuracy of reasoning results.

[0054] Regarding interference from external data, for example, suppose the construction of the knowledge graph uses knowledge from domain 1 and domain 2, and the current query question corresponds to domain 1. Then, the knowledge of domain 2 in the knowledge graph (the triples related to domain 2) belongs to external data and will interfere with the correct reasoning to obtain the answer to the query question.

[0055] To overcome the aforementioned problems, embodiments of the present invention provide corresponding solutions for the problems of invisible first-order logic structures and out-of-domain data interference. In summary, the problem of invisible first-order logic structures is addressed through a plug-and-play universal module—the neighborhood diffusion module—enabling the knowledge graph reasoning model to generalize to any first-order logic structure. The problem of out-of-domain data interference (also known as the open set problem) is addressed through a training loss function—the triple reconstruction error.

[0056] The neighborhood diffusion module can consist of multiple functional modules (which may include multiple neural network models). Based on the distributed assumption, it searches for and stores neighborhood nodes of all entity nodes from the training data. It aggregates neighborhood information from both the entity representation dimension and the logical dimension. The former optimizes the features of the central entity node through a neighborhood filter, while the latter constructs an invisible first-order logical structure through multi-level connection queries. Furthermore, during the training of the knowledge graph reasoning model, a prompt containing class-specific features can be added to each type of first-order logical structure, and gradient adaptation between different first-order logical structures can be achieved by balancing the convergence speed.

[0057] Among them, the triplet reconstruction error distinguishes in-domain data from out-of-domain data by constraining the bidirectional mapping relationship between the anchor entity node set and the target entity node set, and thus eliminates the interference of out-of-domain data in model training or testing by using distance metric (or similarity metric).

[0058] In this embodiment of the invention, the knowledge graph reasoning model can be a neural network model containing multiple convolutional layers, and can adopt the structure of any existing knowledge graph reasoning model. The solution provided in this embodiment of the invention is essentially an optimization of the traditional knowledge graph reasoning model.

[0059] Figure 1 A flowchart of a knowledge graph reasoning model training method provided in an embodiment of the present invention is shown below. Figure 1 As shown, the method includes the following steps:

[0060] 101. Obtain the first tuple corresponding to the first first-order logical structure. The first tuple includes multiple entity nodes and at least one relation determined from the preset training query information. The multiple entity nodes include at least one anchor entity node and a target entity node.

[0061] 102. In the preset knowledge graph, determine the first adjacent entity node corresponding to each of the multiple entity nodes in the first tuple.

[0062] 103. In the reasoning subgraph containing the plurality of entity nodes and the first adjacent entity nodes corresponding to each of the plurality of entity nodes, determine the second tuple and the second first-order logic structure corresponding to the second tuple.

[0063] 104. In the knowledge graph, determine the second neighboring entity node corresponding to any entity node in the target tuple, where the target tuple is either the first tuple or the second tuple.

[0064] 105. Determine the second vector representation corresponding to any entity node in the target tuple based on the concatenation result of the first vector representations corresponding to each of the second adjacent entity nodes, so as to obtain the vector representation set corresponding to the target tuple. Train the knowledge graph reasoning model based on the vector representation set. The vector representation set contains the second vector representations of each entity node in the target tuple and the initial vector representations of each relation.

[0065] In this embodiment, multiple first-order logic structures can be predefined manually, and a large amount of query information (usually referred to as first-order logic queries) corresponding to these first-order logic structures can be collected as training data. In order to train the knowledge graph reasoning model, these query information are converted into tuples for representation.

[0066] For ease of understanding, Figure 2 The diagram illustrates various first-order logic structures, involving the following logical operators:

[0067] i: represents the intersection operation (conjunction); u: represents the union operation (disjunction); n: represents the negation operation (negation); p: represents the projection operation. For ease of representation, the negation operation is indicated by a dashed arrow in the diagram.

[0068] like Figure 2 As shown, 14 first-order logic structures are defined here, including the atomic training structure: {1p, 2p, 3p, 2i, 3i}, the advanced training structure: {2in, 3in, inp, pni, pin}, and the invisible training structure: {ip, pi, 2u, up}. The invisible training structure is used only during the testing phase of the knowledge graph reasoning model; the first two sets of structures are used during the training phase. The invisible training structure is used to test the generalization ability of the trained knowledge graph reasoning model for first-order logic structures not seen during the training phase.

[0069] Figure 2 The structure includes three types of entity nodes: target entity nodes (indicated by black dots), anchor entity nodes (indicated by white dots), and other entity nodes on the multi-hop mapping path between the anchor and target entity nodes (indicated by triangles). In practical applications, anchor entity nodes often correspond to the query question, while target entity nodes correspond to the answer to that query question.

[0070] The following examples illustrate the meaning of the various first-order logic structures.

[0071] For example, 1p, 2p, 3p refers to the number of (1, 2, 3) hops required between the anchor entity node and the target entity node.

[0072] For example, 2i, 3i refers to several (2, 3) anchor entity nodes pointing to the same target entity node. For example, the description of the query information: the color of grass is green, the color of leaves is green, corresponds to a first-order logical structure like 2i, where grass and leaves are anchor entity nodes, "green" is the target entity node, "color" is a relation, and "and" is the intersection operation.

[0073] For example, 2in can be considered a first-order logical structure extended from the atomic training structure 2i. For instance, the query "people living in Hangzhou who do not work at Alibaba" belongs to this first-order logical structure. Here, n represents the negation result of the projection.

[0074] based on Figure 2 The example illustrates various predefined first-order logical structures, which can be used to collect a large amount of query information that conforms to these first-order logical structures to train the knowledge graph reasoning model. First, based on the first-order logical structure corresponding to each query information, it is necessary to convert it into a tuple. The tuple includes at least one anchor entity node, at least one relation, and a target entity node. These entity nodes and relations are all contained in the predefined knowledge graph.

[0075] Taking the query "The color of grass is green, the color of leaves is green" as an example, based on its corresponding first-order logic structure 2i, we know that the tuple corresponding to this query should include two anchor entity nodes (grass, leaves), one target entity node (green), and one relation (color). Therefore, we can understand that the anchor entity node is the source node corresponding to a reasoning step, and the target entity node is the end node corresponding to a reasoning step.

[0076] In step 101 above, the first first-order logic structure is any one of a variety of defined first-order logic structures, and the first tuple is any tuple in the training set corresponding to the first first-order logic structure, that is, the tuple corresponding to any query information among the several query information corresponding to the first first-order logic structure. For ease of description, this embodiment of the invention only uses the first tuple as an example for illustration. It can be understood that similar subsequent processing is performed on each tuple in the training set corresponding to each first-order logic structure.

[0077] After obtaining the first tuple, the neighboring nodes corresponding to each entity node in the first tuple are determined in the knowledge graph, called the first neighboring entity nodes. Thus, a reasoning subgraph can be formed by each entity node in the first tuple, the first neighboring entity nodes corresponding to each entity node, and the related relationships. In this reasoning subgraph, the second tuple and the second first-order logical structure corresponding to the second tuple can be determined. This second first-order logical structure is not included in the multiple first-order logical structures that have been defined, which is equivalent to discovering a new first-order logical structure and obtaining its corresponding sample: the second tuple.

[0078] The process described above, which uses neighborhood search to extend new first-order logical structures and their corresponding new tuples, is the process of constructing invisible first-order logical structures through multi-level join queries.

[0079] Combination Figure 3 The above sample and the first-order logic structure expansion process are illustrated.

[0080] Figure 3 The system includes three types of entity nodes: the original target entity node indicated by black dots, the original anchor entity node indicated by white dots, and the extended adjacent entity node indicated by rectangles. Figure 3 In the diagram, T0 and T1 represent the original level 0 target entity node and the level 1 target entity node that diffuses out through the neighborhood. Similarly, A0-A3 represent the original level 0 anchor entity node and the level 1, 2 and 3 anchor entity nodes that diffuse out through the neighborhood.

[0081] Figure 3 The diagram shows that it is based on Figure 2 The five atomic training structures in the diagram are subjected to neighborhood expansion, where "-ex" indicates expansion.

[0082] Depend on Figure 3 As illustrated in the diagram, the so-called expansion of a new first-order logical structure through multi-level join queries refers to expanding new query samples and new first-order logical structures based on a known first-order logical structure corresponding to a certain query information through multi-level joins. For example... Figure 3 As shown, optionally, when performing multi-level join query expansion, taking the first tuple as an example, the adjacent entity nodes in the inbound direction of each anchor entity node included in the knowledge graph are determined, as well as the adjacent entity nodes in the outbound and inbound directions of the target entity node included in the knowledge graph are determined. That is, when performing multi-level join expansion, for the anchor entity node, only the entity nodes adjacent to its inbound direction (i.e., the direction pointing to the anchor entity) are considered (this is just an example and not a limitation), and for the target entity node, the adjacent entity nodes in both its inbound and outbound directions (the directions pointed out from the target entity node) are considered. In this embodiment of the invention, "adjacent" and "neighboring" are not distinguished.

[0083] The reason for restricting the above-mentioned expansion direction is that the purpose of the neighborhood expansion here is to discover new first-order logical structures and new tuple samples. These new tuples correspond to some query information in reality. In the reasoning process, the reasoning is from the anchor entity node to the target entity node, which has obvious directionality. Therefore, the neighborhood expansion for the anchor entity node considers the inbound direction, while the neighborhood expansion for the target entity node can consider bidirectional. The inbound direction is equivalent to expanding the anchor entity node, and the outbound direction is equivalent to expanding the new target entity node.

[0084] In obtaining such Figure 3 After some of the extended results shown, a new second-order logic structure and its corresponding second tuple can be extracted. Specifically, a new second-order logic structure can be proposed manually or based on manually defined extraction rules, such as {9p, 10i, 3i7p}, etc.

[0085] Through the above process, a new second tuple and a second first-order logical structure can be extended based on the known first tuple. The second tuple is added to the training set corresponding to the second first-order logical structure for use in training the knowledge graph reasoning model, so that more new samples can be used and more new first-order logical structures can be learned during the model training process.

[0086] When training a knowledge graph reasoning model, it is necessary to embed the entity nodes and relations in the tuple into a low-dimensional vector space to obtain the vector representations of the entity nodes and relations.

[0087] Inspired by the distributed hypothesis, this embodiment of the invention introduces a neighborhood filter module, whose core function is feature aggregation: by fusing the features of entity nodes within a small subgraph region, a better feature description of the central entity node is achieved. The features of an entity node are its vector representation.

[0088] Taking a target tuple as an example, the optimization process of the vector representation of each entity node contained in the target tuple using the neighborhood filter can be as follows: In the knowledge graph, determine the second neighboring entity node corresponding to any entity node in the target tuple; and determine the second vector representation corresponding to any entity node based on the concatenation result of the first vector representations corresponding to that entity node and its second neighboring entity node. Here, the target tuple is either the first tuple or the second tuple mentioned above; that is, the vector representation optimization process for the entity node is performed for each tuple.

[0089] The first vector representation of a certain entity node refers to the vector representation of the entity node before being optimized by the neighborhood filter, and the second vector representation refers to the vector representation of the entity node after being optimized by the neighborhood filter.

[0090] Taking any entity node e in the target multi-tuple (which can be the anchor entity node or the target entity node) as an example, the adjacent entity nodes (the entity nodes within one-hop range can be searched) can be searched along the in-direction and out-direction of the entity node e on the knowledge graph, so as to obtain the second adjacent entity node e of the entity node e. neib , and thus the neighborhood entity set N(e) of the entity node e as the center is composed of the searched second adjacent entity nodes, which can be expressed as:

[0091] where ∨ is the union operator, represents the set of relationships in the knowledge graph, r represents a relationship in the set of relationships, r(e neib , e) means that there is a relationship from the entity node e neib pointing to the entity node e, and r(e, e neib ) means that there is a relationship from the entity node e pointing to the entity node e neib .

[0092] Since the sizes of the neighborhood entity sets of different entity nodes are not determined, the neighborhood filter aligns them to a maximum value constrained by the hyperparameter M. Suppose n is the actual size of the neighborhood entity set. If n < M, then M - n d-dimensional zero vectors can be added to the original set, where it is assumed that the vector representation corresponding to each entity node is a d-dimensional vector; conversely, if n > M, then M elements are randomly selected from the original set.

[0093] Thus, the aligned neighborhood entity set N e ′ can be expressed as where represents the first vector representation corresponding to the i-th adjacent entity node. In the embodiments of the present invention, e in regular font represents a vector, and e in italic represents an entity node.

[0094] After that, a multi-layer two-dimensional convolutional network can be used for feature fusion. Specifically, suppose the first vector representation of the entity node e is then its second vector representation after being optimized by the neighborhood filter can be expressed as:

[0095] e′ = MLP(Flatten(ReLU(ω n ★(τ′(e, N′ e )) + b n ))

[0096] Where ★ represents a two-dimensional convolution operation, ω n For a given standard filter (convolution kernel), b n This is a preset bias vector. e′ represents the second vector representation of entity node e, and τ′ is a predefined connection and two-dimensional reshaping operation function. That is, the concatenation result of the first vector representation e corresponding to entity node e and the first vector representations of each second neighboring entity node: [e; e neib 1′ ;e neib 2′ ;…;e neib M ], where e neib i ∈N′ e .

[0097] MLP stands for Multilayer Perceptron, which is a multilayer two-dimensional convolutional network, and can be represented as... Where m1×m2=M. The main function of this multilayer perceptron is to reduce the dimensionality of the feature vector, so that the dimension of the second vector representing e′ is reduced to d dimensions.

[0098] Flatten is an operator that flattens a two-dimensional matrix into a one-dimensional vector, and ReLU is an activation function.

[0099] After performing vector representation optimization processing on each entity node contained in the target tuple using neighborhood filters, the optimized vector representation set corresponding to the target tuple can be obtained. This set includes the second vector representation of each entity node in the target tuple and the initial vector representation of each relation in the target tuple.

[0100] The initial vector representation refers to the vector representation obtained by semantically encoding each entity node and relation when constructing a knowledge graph, such as a one-hot vector.

[0101] By optimizing the vector representation of entity nodes through the aforementioned neighborhood filter, the second vector representation of each entity node in the target tuple incorporates the semantic information of its neighboring entity nodes, resulting in a better semantic representation.

[0102] After obtaining the vector representation set corresponding to the target tuple, this vector representation set can be used to train the knowledge graph inference model. Simply put, the second vector representation of each anchor entity node and the initial vector representation of each relation in this vector representation set can be input into the knowledge graph inference model. This allows the model to output a predicted vector representation of the target entity node. Based on this predicted vector representation and the known second vector representation of the target entity node in the target tuple, a loss function value is calculated to adjust the parameters of the knowledge graph inference model.

[0103] As mentioned above, during knowledge graph construction, semantic encoding can be performed on each entity node and relation to obtain their respective initial vector representations. The first vector representation of the aforementioned entity node can be obtained by embedding optimization of its initial vector representation. It should be noted that when using the aforementioned neighborhood filter for feature optimization of entity nodes, the first vector representation can also be replaced with the initial vector representation.

[0104] In practical applications, a knowledge graph embedding model can be pre-trained. For each entity node contained in the aforementioned target tuple, the first vector representation of each entity node can be obtained through this knowledge graph embedding model. Since different tuples involve different entity nodes in the knowledge graph, the first vector representation of each entity node contained in the knowledge graph can be obtained in advance through this knowledge graph embedding model.

[0105] The training process of this knowledge graph embedding model includes:

[0106] Obtain the target triple, which includes a head entity node, a relation, and a tail entity node; wherein, the target triple includes triples contained in the knowledge graph, or the target triple includes triples contained in the knowledge graph and triples split from the target triple.

[0107] Multiple convolutional layers are applied to the concatenation result of the initial vector representation of the head entity node and the initial vector representation of the relation to obtain a fused vector representation; the target vector representation of the tail entity node is determined based on the sum of the fused vector representation and the concatenation result; and the loss function value used to train the knowledge graph embedding model is determined based on the target vector representation and the initial vector representation of the tail entity node.

[0108] Therefore, the knowledge graph embedding model is trained using triples extracted from the knowledge graph and the target tuple. The training process of the knowledge graph embedding model is described in detail below:

[0109] Suppose τ is a splicing and two-dimensional reshaping function, with a triple (e s,r,e o For example, e s This represents the head entity node, r represents the relation, and e o Let represent the tail entity node, and assume that the initial vector of the head entity node is denoted as . The initial vector representation of this relationship but Where m1×m2=2d. After inputting e and r into the knowledge graph embedding model, the knowledge graph embedding model containing multiple convolutional layers obtains the tail entity node e through the following calculation process. o The first vector representation of o:

[0110]

[0111]

[0112]

[0113] Where ★ represents two-dimensional convolution calculation. This is a standard filter that is set up. This refers to the dilated filter in dilated convolution. and It is the bias vector. C l C represents the output after l layers of convolution. L This is the output of the last convolutional layer. Flatten is an operator that flattens a two-dimensional matrix into a one-dimensional vector, and ReLU is an activation function.

[0114] After obtaining the tail entity node e o After the first vector representation o, the first vector representation o and the tail entity node e are used together. o The initial vectors represent the similarity, which determines the loss function value to adjust the parameters of the knowledge graph embedding model. This similarity can be represented by some distance between the two vectors, such as cosine distance or Euclidean distance.

[0115] It is understandable that in one triplet a certain entity node may be the head entity node, and in another triplet the same entity node may be the tail entity node. Therefore, after training the knowledge graph embedding model with a large number of triples, the first vector representation of each entity node in the knowledge graph can be obtained through the trained knowledge graph embedding model.

[0116] In summary, this embodiment of the invention utilizes a neighborhood diffusion strategy to enhance entity features (vector representation optimization) and expand the logical structure at the logical level (logic enhancement). This optimizes the vector representations corresponding to entity nodes and expands the training samples to include more first-order logical structures. Thus, through the aforementioned representation establishment and logic enhancement processes, the knowledge graph reasoning model can learn more sample tuples with unseen first-order logical structures based on more optimized entity node vector representations, improving the generalization ability and reasoning performance of the knowledge graph reasoning model for unseen first-order logical structures.

[0117] The knowledge graph reasoning model training method provided in this embodiment of the invention can be executed by a server. The process of the server executing this knowledge graph reasoning model training method is described in [link to documentation]. Figure 4 .

[0118] Based on a trained knowledge graph reasoning model, a query question can be input into it. The query question can be transformed into a tuple consisting of anchor entity nodes and relations. The knowledge graph reasoning model then predicts the answer corresponding to the query question—the target entity node—in the knowledge graph.

[0119] The following describes the training process of the knowledge graph reasoning model after obtaining the above vector representation set of the target tuple.

[0120] Figure 5 A flowchart of a knowledge graph reasoning model training method provided in an embodiment of the present invention is shown below. Figure 5 As shown, the method includes the following steps:

[0121] 501. Send the vector representation set corresponding to the target tuple and the identification information of the target first-order logical structure corresponding to the target tuple to the preset prompting network model, so that the prompting network model determines the prompting vector corresponding to the target first-order logical structure and the fusion result of the prompting vector with the second vector representation of each anchor entity node and the initial vector representation of each relation contained in the vector representation set.

[0122] 502. Input the fusion result into the knowledge graph reasoning model to obtain the prediction vector representation of the target entity node output by the knowledge graph reasoning model.

[0123] 503. Based on the predicted vector representation and the second vector representation of the target entity node contained in the vector representation set, determine the target loss function value corresponding to the target tuple, and train the knowledge graph reasoning model and the prompting network model based on the target loss function value.

[0124] In this embodiment, during the training of the knowledge graph reasoning model, a prompt network model training task is introduced simultaneously. This prompt network model can be a convolutional neural network model composed of multiple convolutional layers. Its purpose is to add prompt vectors containing class-specific features to each class of first-order logical structures during the training of the knowledge graph reasoning model, so that the knowledge graph reasoning model can learn the unique structural features (a kind of class-specific information) of various first-order logical structures, thereby improving the performance of the knowledge graph reasoning model.

[0125] It is understandable that, after expanding upon the first-order logic structures described above, and combining them with the previously predefined multiple first-order logic structures, even more first-order logic structures can be obtained. For ease of description, let's assume that k first-order logic structures have been obtained. Each first-order logic structure corresponds to a specific training set, denoted as: {Q1, Q2, ..., Q...} k}

[0126] Suppose the target tuple is the j-th tuple in the training set corresponding to the i-th first-order logistic structure, q i,j It is the vector representation set corresponding to the target tuple. Then q... i,j The identification information of the first-order logical structure of the target tuple is sent to the prompting network model.

[0127] The cue network model can be initialized with k cue vectors {T1, T2, ..., T} using a normal random distribution. k}, which correspond to the k first-order logic structures mentioned above. Next, T... i Concatenate the vector representations of each tuple in the training set corresponding to the i-th first-order logical structure. For the target tuple, this means concatenating it to its corresponding vector representation set q. i,j Above, to achieve the cue vector T i With vector representation set q i,j Feature fusion. Specifically, the fusion process can be represented as:

[0128] q′ i,j =ReLU(ω) T [T i ,q i,j ]+b T )

[0129] Where, ω T Represents a filter, [T i ,q i,j ] represents the cue vector T i And vector representation set q i,j The concatenation of the second vector representation of the anchor entity node and the initial vector representation of the relation, b T This is the set bias vector. q′i,j This indicates the fusion result.

[0130] The fusion result is input into the knowledge graph inference model, which outputs a prediction result: the vector representation corresponding to the predicted target entity node, called the prediction vector representation. Then, the error between the prediction vector representation and the second vector representation of the target entity node contained in the target tuple is calculated to obtain the loss function value corresponding to the target tuple. During gradient backpropagation, the parameters of the knowledge graph inference model and the cue network model are adjusted based on this loss function value. Specifically, the parameter adjustment of the cue network model continuously adjusts the cue vector for each first-order logical structure, so that the subsequent knowledge graph inference model can more accurately learn the features of different first-order logical structures based on the optimized cue vectors.

[0131] In an optional embodiment, determining the target loss function value corresponding to the target tuple based on the predicted vector representation and the second vector representation of the target entity nodes in the target tuple can also be implemented as follows:

[0132] In the knowledge graph, non-target entity nodes corresponding to the target tuple are identified, and a first vector representation corresponding to the non-target entity node is determined. The non-target entity node is different from each anchor entity node and target entity node contained in the target tuple. The first vector representation is obtained based on the pre-trained knowledge graph embedding model described above.

[0133] A first loss function value is determined based on the predicted vector representation and the second vector representation of the target entity node, and a second loss function value is determined based on the predicted vector representation and the first vector representation of the non-target entity node;

[0134] The first target loss function value is determined based on the first loss function value and the second loss function value, so as to train the knowledge graph reasoning model and the prompting network model based on the first target loss function value.

[0135] For ease of understanding and description, assume the target tuple is [e1,e2,r1,r2,t], where e1 and e2 are two anchor entity nodes; r1 and r2 are two relations; and t is the target entity node. Also assume the corresponding vector representation set for the target tuple is [e1,e2,r1,r2,t], where e1 and e2 are the second vector representations of the two anchor entity nodes; r1 and r2 are the initial vector representations of the two relations; and t is the second vector representation of the target entity node.

[0136] Suppose that n_s non-target entity nodes, different from the anchor entity nodes and target entity nodes mentioned above, are randomly selected in the knowledge graph. The first vector representation of the selected i-th non-target entity node is denoted as ti′. Suppose that after inputting [e1,e2,r1,r2,?] into the knowledge graph inference model, the prediction vector output by the model is denoted as q, where ? indicates that the second vector representation of the target entity node was not input into the model.

[0137] Based on the above assumptions, the calculation of the first objective loss function value corresponding to the objective tuple can be expressed as:

[0138]

[0139] Here, score(q,t) represents the normalized similarity score between the second vector representation t of the target entity node and the predicted vector representation q, which can be determined by calculating a certain distance between them. score(q,ti′) represents the normalized similarity score between the predicted vector representation q and the first vector representation ti′ of the non-target entity node. σ represents the Sigmoid function.

[0140] The first term in the aforementioned first objective loss function value refers to the distance between the predicted vector representation q and the second vector representation t of the target entity node, while the second term refers to the distance between the first vector representation ti′ of the non-target entity node and the predicted vector representation q.

[0141] Figure 6 A flowchart of a knowledge graph reasoning model training method provided in an embodiment of the present invention is shown below. Figure 6 As shown, the method includes the following steps:

[0142] 601. Send the vector representation set corresponding to the target tuple and the identification information of the target first-order logical structure corresponding to the target tuple to the preset prompting network model, so that the prompting network model determines the prompting vector corresponding to the target first-order logical structure and the fusion result of the prompting vector with the second vector representation of each anchor entity node and the initial vector representation of each relation contained in the vector representation set.

[0143] 602. Input the fusion result into the knowledge graph reasoning model to obtain the prediction vector representation of the target entity node output by the knowledge graph reasoning model.

[0144] 603. Determine the first target loss function value corresponding to the target tuple based on the predicted vector representation and the second vector representation of the target entity nodes contained in the vector representation set.

[0145] 604. Based on the first objective loss function values ​​of each of the multiple tuples in the training set corresponding to the first-order logic structure of the target in the current round of iterative training, determine the second objective loss function value corresponding to the first-order logic structure of the target in the current round of iterative training.

[0146] 605. Based on the second objective loss function values ​​corresponding to various first-order logic structures in the current iteration training process, determine the first total loss function value corresponding to the current iteration training process; based on the first objective loss function values ​​corresponding to various tuples in the training set corresponding to the target first-order logic structure in the previous iteration training process, determine the third objective loss function value corresponding to the target first-order logic structure in the previous iteration training process.

[0147] 606. Determine the third objective loss function values ​​that meet the set size conditions among the third objective loss function values ​​corresponding to various first-order logic structures in the previous round of iterative training. Use a set attenuation factor to attenuate the third objective loss function values ​​that meet the set size conditions. Determine the second total loss function value corresponding to the current round of iterative training based on the first total loss function value and the attenuation result. Train the knowledge graph reasoning model and the prompting network model based on the second total loss function value.

[0148] In this embodiment, the target tuple is any tuple in the training set corresponding to the target first-order logical structure, and the target first-order logical structure is one of the various first-order logical structures already obtained. Since the introduction of a multi-level connection query mechanism expands to a rich variety of first-order logical structures, without imposing any restrictions, the knowledge graph inference model will tend to learn explicit or simple first-order logical structures, which is detrimental to overall performance. Therefore, this embodiment proposes a gradient adaptive scheme, the key idea of ​​which is to suppress the sample gradient information on the first-order logical structure with the fastest convergence speed. Through this processing, the knowledge graph inference model has more opportunities to learn difficult or long-tailed samples in the early stages of training.

[0149] Specifically, the model training process involves multiple rounds of iterative training. In each round of iterative training, all the tuples in the training set corresponding to each of the various first-order logic structures can be traversed.

[0150] Taking the target first-order logic structure as an example, the target tuple is a sample in its corresponding training set. Through the training process described above, the first objective loss function value corresponding to the target tuple in the current iteration of training can be obtained. Similarly, the first objective loss function value can be calculated for each tuple in the training set. By accumulating the first objective loss function values ​​of each tuple in the training set corresponding to the target first-order logic structure in the current iteration of training, the second objective loss function value corresponding to the target first-order logic structure in the current iteration of training can be obtained.

[0151] Similarly, by performing the above processing on each first-order logic structure, we can obtain the second objective loss function values ​​corresponding to each of the multiple first-order logic structures in the current iteration of training. The second objective loss function values ​​corresponding to each of the multiple first-order logic structures in the current iteration of training are accumulated to determine the first total loss function value corresponding to the current iteration of training.

[0152] The same process is applied to the previous iteration of training. Based on the first objective loss function values ​​corresponding to the multiple tuples in the training set corresponding to the target first-order logic structure during the previous iteration, the third objective loss function value corresponding to the target first-order logic structure can be determined. Similarly, the third objective loss function values ​​corresponding to various first-order logic structures during the previous iteration can be obtained.

[0153] Determine the third objective loss function value that meets the set size condition among the third objective loss function values ​​corresponding to various first-order logic structures in the previous round of iterative training. This set size condition is, for example, greater than a set threshold, or taking the maximum value.

[0154] Next, the third objective loss function value that meets the set size condition is attenuated using a set attenuation factor z, that is, the third objective loss function value is multiplied by the attenuation factor. In fact, the first-order logic structure corresponding to the third objective loss function value that meets the set size condition is a fast-converging first-order logic structure, and its fast convergence is suppressed by multiplying it by an attenuation factor.

[0155] Subsequently, the first total loss function value obtained in the current iteration is adjusted based on the above attenuation processing results to obtain the second total loss function value corresponding to the current iteration training process, and the knowledge graph inference model and the prompting network model are trained based on the second total loss function value.

[0156] It should be noted that the gradient adaptive scheme and the prompting network model provided in this embodiment can be decoupled.

[0157] For ease of understanding, the above gradient adaptive processing procedure is represented as follows:

[0158] Suppose there are k possible first-order logic structures: {p1, p2, ..., p...} n},like The sum of the target loss function values ​​corresponding to each first-order logic structure calculated in the (i-1)th iteration is: The sum of the target loss function values ​​corresponding to each first-order logic structure obtained in the i-th iteration is: Then the adjusted second total loss function value in the i-th iteration can be expressed as:

[0159]

[0160] Where z is the attenuation factor, for example, a value of 0.05. This indicates taking the maximum value of the target loss function values ​​corresponding to the k first-order logic structures in the (i-1)th iteration.

[0161] Figure 7 A flowchart of a knowledge graph reasoning model training method provided in an embodiment of the present invention is shown below. Figure 7 As shown, the method includes the following steps:

[0162] 701. In the knowledge graph, determine the non-target entity node corresponding to the target tuple and determine the first vector representation corresponding to the non-target entity node. The non-target entity node is different from each anchor entity node and target entity node contained in the target tuple. The first vector representation is obtained based on the pre-trained knowledge graph embedding model described above.

[0163] 702. Input the second vector representation of each anchor entity node in the vector representation set of the target tuple and the initial vector representation of the relation into the knowledge graph inference model to obtain the predicted vector representation output by the knowledge graph inference model. Determine the first loss function value based on the predicted vector representation and the second vector representation of the target entity node in the target tuple, and determine the second loss function value based on the predicted vector representation and the first vector representation of the non-target entity node. Determine the first target loss function value corresponding to the target tuple based on the first loss function value and the second loss function value.

[0164] 703. Determine the initial vector representation of the first relationship from any anchor entity node in the target tuple to the target entity node; perform reverse mapping on the initial vector representation of the first relationship to obtain the initial vector representation of the second relationship from the target entity node to the any anchor entity node, wherein the first relationship is contained in the target tuple.

[0165] 704. Input the second vector representation of the target entity node and the initial vector representation of the second relation into the knowledge graph inference model to obtain the first predicted vector representation corresponding to any anchor entity node; and input the first vector representation of the non-target entity node and the initial vector representation of the second relation into the knowledge graph inference model to obtain the second predicted vector representation corresponding to any anchor entity node.

[0166] 705. Determine the third loss function value corresponding to any anchor entity node based on the first prediction vector representation and the second vector representation of any anchor entity node; determine the fourth loss function value corresponding to any anchor entity node based on the second prediction vector representation and the second vector representation of any anchor entity node; determine the total loss function value corresponding to any anchor entity node based on the third loss function value and the fourth loss function value.

[0167] 706. Based on the total loss function value corresponding to each anchor entity node in the target tuple, determine the fourth target loss function value corresponding to the target tuple.

[0168] 707. Train the knowledge graph reasoning model based on the first and fourth objective loss function values ​​corresponding to the objective tuples.

[0169] Previously, the problems in the reasoning process of open set knowledge graphs were decomposed into two main issues: invisible first-order logic structure and interference from out-of-domain data. In this embodiment, a triple reconstruction error is proposed to solve the problem of interference from out-of-domain data.

[0170] Complex query problems constructed using logical operators can be simply represented as reasoning subgraphs. Answering the query problem by performing logical operations from anchor entity nodes to target entity nodes is defined as the forward reasoning process. However, existing methods only use the forward reasoning process, which leads to unreliable bidirectional mapping between query problems and answers. Therefore, this embodiment designs a backward reasoning process to improve the reasoning—the inversion process is key to solving this problem.

[0171] Triple reconstruction error, by constraining the bidirectional mapping relationship between the anchor entity node set and the target entity node set, distinguishes between in-domain and out-of-domain data through distance metric, thereby eliminating interference from out-of-domain data in model training or testing.

[0172] First, it should be noted that if a tuple contains more than one target entity node, then during a single training iteration, one target entity node will be randomly selected to participate in the current training round. Therefore, for ease of description, let's assume that the target tuple contains only one target entity node.

[0173] Suppose the target tuple is [e1,e2,r1,r2,t], where e1 and e2 are two anchor entity nodes; r1 and r2 are two relations; and t is the target entity node. Also assume the vector representation set corresponding to the target tuple is [e1,e2,r1,r2,t], where e1 and e2 are the second vector representations of the two anchor entity nodes; r1 and r2 are the initial vector representations of the two relations; and t is the second vector representation of the target entity node.

[0174] Suppose that n_s non-target entity nodes, different from the anchor entity nodes and target entity nodes, are randomly selected in the knowledge graph. The first vector representation of the selected i-th non-target entity node ti′ is denoted as ti′. It is assumed that after inputting [e1, e2, r1, r2, ? ] into the knowledge graph inference model, the predicted vector output by the model is denoted as q, where ? indicates that the second vector representation of the target entity node was not input into the model. In this embodiment, the calculation result of the first target loss function value corresponding to the target tuple is represented as... The calculation process is described above.

[0175] Suppose the target tuple [e1, e2, r1, r2, t] can be decomposed into two triples: [e1, r1, t] and [e2, r2, t]. Taking the anchor entity node e1 as an example, its first relation to the target entity node t is r1, and its initial vector is denoted as r1. Also assume that starting from the anchor entity node e1, a randomly selected non-target entity node ti′ is reached through the first relation r1. In this embodiment, the path from the anchor entity node e1 to the target entity node t through the first relation r1 is called the forward positive relation path: [e1, r1, t], and the path from the anchor entity node e1 to the non-target entity node ti′ through the first relation r1 is called the forward negative relation path [e1, r1, ti′]. Here, "forward" corresponds to the direction from the anchor entity node to the target entity node; the forward negative and forward negative directions correspond to the cases of reaching the target entity node and the non-target entity node, respectively.

[0176] Then, the initial vector representation r1 of the first relation r1 is reverse-mapped to obtain the initial vector representation of the second relation from the target entity node t to the anchor entity node e1. Based on this reverse mapping relationship, a forward-reverse relationship path can be formed, starting from the target entity node t and reaching the anchor entity node e1 through the second relationship: The path that starts from the non-target entity node ti′ and reaches the anchor entity node e1 through the second relation is called the negative reverse relation path. Here, "reverse" corresponds to the direction from the target entity node to the anchor entity node; the positive / negative directions of the reverse direction correspond to the cases of reaching the anchor entity node from the target entity node and the cases of reaching the anchor entity node from a non-target entity node, respectively.

[0177] In the example above, the second vector representation t of the target entity node and the initial vector representation of the second relation are used. Input the knowledge graph reasoning model to obtain the first predicted vector representation e1′; input the first vector representation ti′ of the non-target entity node and the initial vector representation of the second relation. Input the knowledge graph reasoning model to obtain the second prediction vector representation e1″. Here, the second vector representation t of the target entity node and the initial vector representation of the second relation are used. The input form of the knowledge graph reasoning model can be: t-r1, i.e.

[0178] Next, the similarity score between the first predicted vector representation e1′ and the second vector representation e1 of the anchor entity node e1 is calculated to determine the third loss function value corresponding to the anchor entity node e1. Then, the similarity score between the second predicted vector representation e1″ and the second vector representation e1 of the anchor entity node e1 is calculated to determine the fourth loss function value corresponding to the anchor entity node e1. The sum of the third and fourth loss function values ​​is then determined as the total loss function value corresponding to the anchor entity node e1.

[0179] Similarly, for anchor entity node e2 within the aforementioned target tuple, the total loss function value corresponding to anchor entity node e2 is obtained through a similar calculation process.

[0180] Then, based on the total loss function value corresponding to anchor entity node e1 The total loss function value corresponding to anchor entity node e2 Then the value of the fourth objective loss function corresponding to the objective tuple can be obtained.

[0181] Specifically, based on the number of anchor entity nodes in the target tuple and the target first-order logic structure corresponding to the target tuple, the fourth target loss function value corresponding to the target tuple is determined from the total loss function values ​​corresponding to each anchor entity node in the target tuple. The calculation formula is as follows:

[0182]

[0183] Here, pk represents the target first-order logical structure corresponding to the target tuple, and {} contains the identification information of the first-order logical structure. Max indicates taking the maximum value, and Min indicates taking the minimum value.

[0184] The above The defined loss function is the triplet reconstruction error defined in this embodiment of the invention.

[0185] Based on the above calculation formula, if the target tuple contains three anchor entity nodes, the maximum value among the total loss function values ​​corresponding to these three anchor entity nodes can be determined as the fourth target loss function value of the target tuple. If the target tuple contains two anchor entity nodes, the maximum or minimum value among the total loss function values ​​corresponding to these two anchor entity nodes can be determined as the fourth target loss function value, taking into account the target first-order logic structure corresponding to the target tuple. If the target tuple contains one anchor entity node, the total loss function value corresponding to that anchor entity node is directly used as the fourth target loss function value of the target tuple.

[0186] For the total loss function value corresponding to the anchor node entity, such as the above The calculation can be performed using the following formula:

[0187]

[0188] Among them, e j Let j represent the j-th anchor entity node contained in the target tuple, and i be the i-th non-target entity node among n_s randomly selected non-target entity nodes from the knowledge graph. This represents the vector representation predicted from the target entity node t along the inverse forward relation path. Let represent the vector representation predicted for the i-th non-target entity node along the corresponding inverse negative relation path. Here, 'score' represents the normalized similarity score, and 'σ' represents the Sigmoid function.

[0189] For the aforementioned target tuple, after determining the similarity between the first predicted vector representation and the second vector representation of any anchor entity node e1, it can be further determined whether the target tuple contains out-of-domain data based on the comparison result of this similarity with a set threshold. If it is determined that the target tuple contains out-of-domain data, the target tuple is deleted from the training set corresponding to the target first-order logical structure. Here, the similarity is... If the similarity is less than a set threshold, it indicates that the target tuple is out-of-domain data. This is because if it were in-domain data, the predicted vector representation of the anchor entity node predicted from the target entity node along the forward and reverse relationship paths should be very similar to the second vector representation of that anchor entity node.

[0190] In summary, for the target tuple, after obtaining its corresponding first target loss function value... and the fourth objective loss function value Then, the final loss function for the target tuple can be calculated: Here, λ is a preset hyperparameter that controls the weights of the triplet reconstruction error.

[0191] In fact, in this embodiment of the invention, it is assumed that the anchor entity node set in the tuple corresponding to a certain first-order logical query information is: {a1, a2, ..., a s The reasoning subgraph G represents the anchor entity nodes, target entity nodes, and the connections between them in this tuple. q Then in G q Positive / negative forward relationship paths can be defined in the code. Specifically Indicates from a certain anchor entity node a j Departure, via G q A directed path is taken from the target entity t. Indicates from a certain anchor entity node a j Departure, via G q A directed path in the path reaches a randomly selected non-target entity node t′. i Clearly, the only logical operation involved in the positive / negative forward relation path is the relation projection operator: P. r (e)≡{e′∈:r(e,e′)=True}, where r(e,e′) represents the mapping of anchor entity node e to entity node e′ through relation r. After defining the above two forward relation paths, all relation projection operators in the forward relation paths are replaced with their inverse mappings. This allows the generation of backward relation paths with similar strategies: This represents the distance from the target entity node t to the anchor entity node a. j Forward and reverse relationship paths; Represents a non-target entity node t′ i To anchor entity node a j The negative reverse relationship path.

[0192] The above describes the training methods for knowledge graph reasoning models. These methods can overcome the interference of external data in open-set knowledge graphs and improve the generalization ability and performance of knowledge graph reasoning models for first-order logical structures.

[0193] The knowledge graph reasoning model training method provided in this invention can be executed in the cloud. Several computing nodes (cloud servers) can be deployed in the cloud, each with processing resources such as computing and storage. In the cloud, multiple computing nodes can be organized to provide a certain service; of course, a single computing node can also provide one or more services. The cloud can provide this service by providing an external service interface, which users can call to use the corresponding service.

[0194] According to the solution provided in this embodiment of the invention, the cloud can provide a service interface for training knowledge graph inference models. Users can call this service interface through in-vehicle terminal devices to trigger a knowledge graph inference model training request to the cloud, which includes preset training query information. The cloud determines the computing node that responds to the request and uses the processing resources in that computing node to perform the following steps:

[0195] Obtain a first tuple corresponding to the first first-order logical structure. The first tuple includes multiple entity nodes and at least one relation determined from preset training query information. The multiple entity nodes include at least one anchor entity node and a target entity node.

[0196] In the preset knowledge graph, determine the first adjacent entity node corresponding to each of the multiple entity nodes in the first tuple;

[0197] In the reasoning subgraph that includes the plurality of entity nodes and the first adjacent entity nodes corresponding to each of the plurality of entity nodes, a second tuple and the second first-order logic structure corresponding to the second tuple are determined.

[0198] In the knowledge graph, determine the second neighboring entity node corresponding to any entity node in the target tuple, wherein the target tuple is either the first tuple or the second tuple;

[0199] The second vector representation corresponding to any entity node is determined based on the concatenation result of the first vector representations corresponding to any entity node and its second neighboring entity node, so as to obtain the vector representation set corresponding to the target tuple. The vector representation set includes the second vector representation of each entity node in the target tuple and the initial vector representation of each relation.

[0200] The knowledge graph reasoning model is trained based on the vector representation set.

[0201] The above execution process can be referred to the relevant descriptions in the other embodiments mentioned above, and will not be repeated here.

[0202] For ease of understanding, combined with Figure 8 To illustrate this, users can... Figure 8 The example illustrates user device E1 calling the knowledge graph inference model training service to upload preset training query information. The service interfaces for this user call can take the form of software development kits (SDKs) or application programming interfaces (APIs). Figure 8The diagram illustrates an API interface scenario. In the cloud, as shown in the figure, assume that service cluster E2 provides the knowledge graph inference model training service, and service cluster E2 includes at least one computing node. After receiving the request, service cluster E2 executes the steps described in the previous embodiment to obtain the trained knowledge graph inference model.

[0203] The knowledge graph reasoning model training apparatus of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will understand that these apparatuses can be configured using commercially available hardware components through the steps taught in this solution.

[0204] Figure 9 This is a schematic diagram of the structure of a knowledge graph reasoning model training device provided in an embodiment of the present invention, as shown below. Figure 9 As shown, the device includes: an acquisition module 11, a neighborhood diffusion module 12, a feature determination module 13, and a training module 14.

[0205] The acquisition module 11 is used to acquire a first tuple corresponding to the first first-order logical structure. The first tuple includes multiple entity nodes and at least one relationship determined from preset training query information. The multiple entity nodes include at least one anchor entity node and a target entity node.

[0206] The neighbor diffusion module 12 is used to determine, in a preset knowledge graph, the first neighboring entity nodes corresponding to each of the plurality of entity nodes in the first tuple; in a reasoning subgraph containing the plurality of entity nodes and the first neighboring entity nodes corresponding to each of the plurality of entity nodes, determine the second tuple and the second first-order logic structure corresponding to the second tuple; and determine the second neighboring entity node corresponding to any entity node in the target tuple in the knowledge graph, wherein the target tuple is either the first tuple or the second tuple.

[0207] The feature determination module 13 is used to determine the second vector representation corresponding to any entity node based on the concatenation result of the first vector representations corresponding to any entity node and its second adjacent entity node, so as to obtain the vector representation set corresponding to the target tuple. The vector representation set includes the second vector representation of each entity node in the target tuple and the initial vector representation of each relation.

[0208] Training module 14 is used to train the knowledge graph reasoning model based on the vector representation set.

[0209] Optionally, the neighbor diffusion module 12 is specifically used to: determine the neighboring entity nodes in the ingress direction of each of the at least one anchor entity node in the first tuple in the knowledge graph, and determine the neighboring entity nodes in the outgress and ingress directions of the target entity node.

[0210] Optionally, the neighbor diffusion module 12 is specifically used to: determine the neighboring entity nodes in the outgoing and incoming directions of any entity node in the target tuple in the knowledge graph.

[0211] Optionally, the apparatus further includes an embedding module, configured to obtain the target tuple and the first vector representation of each entity node contained in the knowledge graph based on a pre-trained knowledge graph embedding model.

[0212] Optionally, the embedding module is further configured to: obtain a target triplet, the target triplet including a head entity node, a relation, and a tail entity node; wherein, the target triplet includes triples contained within the knowledge graph, or, the target triplet includes triples contained within the knowledge graph and triples split from the target triplet; perform convolution operations on the concatenation result of the initial vector representation of the head entity node and the initial vector representation of the relation through multiple convolutional layers to obtain a fused vector representation; determine the target vector representation of the tail entity node based on the sum of the fused vector representation and the concatenation result; and determine the loss function value used to train the knowledge graph embedding model based on the target vector representation and the initial vector representation of the tail entity node.

[0213] Optionally, the training module is specifically configured to: send the identification information of the target first-order logical structure corresponding to the vector representation set and the target tuple to a preset prompting network model, so that the prompting network model determines the prompt vector corresponding to the target first-order logical structure and the fusion result of the prompt vector with the second vector representation of each anchor entity node contained in the vector representation set and the initial vector representation of each relation; input the fusion result into the knowledge graph reasoning model to obtain the predicted vector representation corresponding to the target entity node output by the knowledge graph reasoning model; determine the target loss function value corresponding to the target tuple based on the predicted vector representation and the second vector representation of the target entity node contained in the vector representation set, so as to train the knowledge graph reasoning model and the prompting network model based on the target loss function value.

[0214] Optionally, in the process of determining the target loss function value corresponding to the target tuple based on the predicted vector representation and the second vector representation of the target entity node included in the vector representation set, the training module is specifically used to: determine the non-target entity node corresponding to the target tuple in the knowledge graph and determine the first vector representation corresponding to the non-target entity node, wherein the non-target entity node is different from at least one anchor entity node and the target entity node in the target tuple, and the first vector representation is obtained based on a pre-trained knowledge graph embedding model; determine the first loss function value based on the predicted vector representation and the second vector representation of the target entity node, and determine the second loss function value based on the predicted vector representation and the first vector representation of the non-target entity node; determine the first target loss function value corresponding to the target tuple based on the first loss function value and the second loss function value, so as to train the knowledge graph inference model and the prompting network model based on the first target loss function value.

[0215] Optionally, the target tuple is any tuple in the training set corresponding to the corresponding target first-order logical structure, and the target first-order logical structure is one of multiple first-order logical structures. During the training of the knowledge graph inference model and the prompting network model based on the first target loss function value, the training module is specifically used to: determine the second target loss function value corresponding to the target first-order logical structure in the current iteration training process based on the first target loss function values ​​corresponding to each of the multiple tuples in the training set corresponding to the target first-order logical structure in the current iteration training process; determine the first total loss function value corresponding to the current iteration training process based on the second target loss function values ​​corresponding to each of the multiple first-order logical structures in the current iteration training process; and determine the first total loss function value corresponding to the current iteration training process based on the training set corresponding to the target first-order logical structure in the previous iteration training process. The system determines the first target loss function value corresponding to each of the multiple tuples in the training process, and then determines the third target loss function value corresponding to the first-order logic structure in the previous iteration. It then determines the third target loss function value that meets a set size condition among the third target loss function values ​​corresponding to the various first-order logic structures in the previous iteration. Finally, it applies a set attenuation factor to the third target loss function value that meets the set size condition. Based on the first total loss function value and the attenuation result, it determines the second total loss function value corresponding to the current iteration. Finally, it trains the knowledge graph reasoning model and the prompting network model based on the second total loss function value.

[0216] Optionally, the training module is further configured to: determine an initial vector representation of a first relation from any anchor entity node in the target tuple to the target entity node, wherein the first relation is included in the at least one relation; perform inverse mapping on the initial vector representation of the first relation to obtain an initial vector representation of a second relation from the target entity node to any anchor entity node; input the second vector representation of the target entity node and the initial vector representation of the second relation into the knowledge graph inference model to obtain a first prediction vector representation corresponding to any anchor entity node; and input the first vector representation of the non-target entity node and the initial vector representation of the second relation into the knowledge graph inference model to obtain the first prediction vector representation corresponding to any anchor entity node. The first prediction vector representation is used to determine the second prediction vector representation of the node; the third loss function value of the anchor entity node is determined based on the first prediction vector representation and the second vector representation of the anchor entity node; the fourth loss function value of the anchor entity node is determined based on the second prediction vector representation and the second vector representation of the anchor entity node; the total loss function value of the anchor entity node is determined based on the third loss function value and the fourth loss function value; the fourth target loss function value of the target tuple is determined based on the total loss function value of each of the at least one anchor entity node; and the knowledge graph reasoning model and the prompting network model are trained based on the first target loss function value and the fourth target loss function value.

[0217] Optionally, in the process of determining the fourth target loss function value corresponding to the target tuple based on the total loss function value corresponding to each of the at least one anchor entity node, the training module is specifically used to: determine the fourth target loss function value corresponding to the target tuple from the total loss function values ​​corresponding to each of the at least one anchor entity node, based on the number of anchor entity nodes included in the target tuple and the target first-order logic structure corresponding to the target tuple.

[0218] The training module is further configured to: determine the similarity between the first predicted vector representation and the second vector representation of any anchor entity node, wherein the third loss function value is determined based on the similarity; determine whether the target tuple contains out-of-domain data based on the comparison result of the similarity and a set threshold; if the target tuple is determined to contain out-of-domain data, then delete the target tuple from the training set corresponding to the target first-order logical structure of the target tuple.

[0219] Figure 9 The device shown can perform the steps in the foregoing embodiments. For detailed execution process and technical effects, please refer to the description in the foregoing embodiments, which will not be repeated here.

[0220] In one possible design, the above Figure 9 The structure of the knowledge graph reasoning model training device shown can be implemented as an electronic device. For example... Figure 10 As shown, the electronic device may include: a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable code, which, when executed by the processor 21, enables the processor 21 to at least implement the knowledge graph reasoning model training method provided in the foregoing embodiments.

[0221] In addition, embodiments of the present invention provide a non-transitory machine-readable storage medium storing executable code, which, when executed by a processor of an electronic device, enables the processor to at least implement the knowledge graph reasoning model training method provided in the foregoing embodiments.

[0222] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0223] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of a necessary general-purpose hardware platform, or by a combination of hardware and software. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0224] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for training a knowledge graph reasoning model, characterized in that, include: Obtain a first tuple corresponding to the first first-order logical structure. The first tuple includes multiple entity nodes and at least one relation determined from preset training query information. The multiple entity nodes include at least one anchor entity node and a target entity node. In the preset knowledge graph, determine the first adjacent entity node corresponding to each of the multiple entity nodes in the first tuple; In the reasoning subgraph that includes the plurality of entity nodes and the first adjacent entity nodes corresponding to each of the plurality of entity nodes, a second tuple and a second first-order logic structure corresponding to the second tuple are determined. The second first-order logic structure is not included in the multiple first-order logic structures that have been defined. In the knowledge graph, determine the second neighboring entity node corresponding to any entity node in the target tuple, wherein the target tuple is either the first tuple or the second tuple; The second vector representation corresponding to any entity node is determined based on the concatenation result of the first vector representations corresponding to any entity node and its second neighboring entity node, so as to obtain the vector representation set corresponding to the target tuple. The vector representation set includes the second vector representation of each entity node in the target tuple and the initial vector representation of each relation. The knowledge graph reasoning model is trained based on the vector representation set.

2. The method according to claim 1, characterized in that, The step of determining the first neighboring entity node corresponding to each of the multiple entity nodes in the first tuple in the preset knowledge graph includes: In the knowledge graph, the neighboring entity nodes in the ingress direction of each of the at least one anchor entity node in the first tuple are determined, as well as the neighboring entity nodes in the outgress and ingress directions of the target entity node are determined.

3. The method according to claim 1, characterized in that, The step of determining the second neighboring entity node corresponding to any entity node in the target tuple in the knowledge graph includes: In the knowledge graph, determine the outgoing and incoming neighboring entity nodes of any entity node in the target tuple.

4. The method according to claim 1, characterized in that, The method further includes: Based on a pre-trained knowledge graph embedding model, the target tuple and the first vector representation of each entity node contained in the knowledge graph are obtained; wherein, the training process of the knowledge graph embedding model includes: Obtain a target triplet, which includes a head entity node, a relation, and a tail entity node; wherein, the target triplet includes triplets contained in the knowledge graph, or the target triplet includes triplets contained in the knowledge graph and triplets split from the target triplet. The concatenation result of the initial vector representation of the head entity node and the initial vector representation of the relationship is subjected to multiple convolutional layers to obtain a fused vector representation; The target vector representation of the tail entity node is determined based on the sum of the fused vector representation and the splicing result. Based on the target vector representation and the initial vector representation of the tail entity node, the loss function value used to train the knowledge graph embedding model is determined.

5. The method according to claim 1, characterized in that, The step of training the knowledge graph reasoning model based on the vector representation set includes: The identification information of the target first-order logical structure corresponding to the vector representation set and the target tuple is sent to a preset prompting network model so that the prompting network model determines the prompting vector corresponding to the target first-order logical structure and the fusion result of the prompting vector with the second vector representation of each anchor entity node and the initial vector representation of each relation contained in the vector representation set; The fusion result is input into the knowledge graph reasoning model to obtain the prediction vector representation of the target entity node output by the knowledge graph reasoning model. Based on the predicted vector representation and the second vector representation of the target entity node contained in the vector representation set, the target loss function value corresponding to the target tuple is determined, so as to train the knowledge graph reasoning model and the prompting network model based on the target loss function value.

6. The method according to claim 5, characterized in that, The step of determining the target loss function value corresponding to the target tuple based on the predicted vector representation and the second vector representation of the target entity node contained in the vector representation set includes: In the knowledge graph, non-target entity nodes corresponding to the target tuple are determined, and a first vector representation corresponding to the non-target entity node is determined. The non-target entity node is different from at least one anchor entity node and the target entity node in the target tuple. The first vector representation is obtained based on a pre-trained knowledge graph embedding model. A first loss function value is determined based on the predicted vector representation and the second vector representation of the target entity node, and a second loss function value is determined based on the predicted vector representation and the first vector representation of the non-target entity node; The first target loss function value corresponding to the target tuple is determined based on the first loss function value and the second loss function value, so as to train the knowledge graph reasoning model and the prompting network model based on the first target loss function value.

7. The method according to claim 6, characterized in that, The target tuple is any tuple in the training set corresponding to the first-order logical structure of the target, and the first-order logical structure of the target is one of a variety of first-order logical structures; training the knowledge graph reasoning model and the prompting network model based on the first target loss function value includes: Based on the first target loss function values ​​corresponding to each of the multiple tuples in the training set corresponding to the target first-order logic structure during the current round of iterative training, the second target loss function value corresponding to the target first-order logic structure during the current round of iterative training is determined. Based on the second target loss function values ​​corresponding to the various first-order logic structures in the current iteration training process, determine the first total loss function value corresponding to the current iteration training process; Based on the first target loss function values ​​corresponding to each of the multiple tuples in the training set corresponding to the target first-order logic structure during the previous round of iterative training, the third target loss function value corresponding to the target first-order logic structure during the previous round of iterative training is determined. Determine the third objective loss function value that meets the set size condition among the third objective loss function values ​​corresponding to the various first-order logic structures in the previous round of iterative training; The value of the third objective loss function that meets the set size condition is attenuated using a set attenuation factor; Based on the first total loss function value and the decay processing result, determine the second total loss function value corresponding to the current round of iterative training process; The knowledge graph reasoning model and the prompting network model are trained based on the second total loss function value.

8. The method according to claim 6 or 7, characterized in that, The method further includes: Determine an initial vector representation of a first relationship from any anchor entity node in the target tuple to the target entity node, wherein the first relationship is contained in the at least one relationship; The initial vector representation of the first relationship is reverse-mapped to obtain the initial vector representation of the second relationship from the target entity node to any anchor entity node; The second vector representation of the target entity node and the initial vector representation of the second relationship are input into the knowledge graph reasoning model to obtain the first predicted vector representation corresponding to any anchor entity node; and the first vector representation of the non-target entity node and the initial vector representation of the second relationship are input into the knowledge graph reasoning model to obtain the second predicted vector representation corresponding to any anchor entity node. Based on the first prediction vector representation and the second vector representation of any anchor entity node, determine the third loss function value corresponding to any anchor entity node; based on the second prediction vector representation and the second vector representation of any anchor entity node, determine the fourth loss function value corresponding to any anchor entity node. The total loss function value corresponding to any anchor entity node is determined based on the third loss function value and the fourth loss function value. Based on the total loss function value corresponding to each of the at least one anchor entity node, determine the fourth target loss function value corresponding to the target tuple; The knowledge graph reasoning model and the prompting network model are trained based on the first target loss function value and the fourth target loss function value.

9. The method according to claim 8, characterized in that, The step of determining the fourth target loss function value corresponding to the target tuple based on the total loss function value corresponding to each of the at least one anchor entity node includes: Based on the number of anchor entity nodes contained in the target tuple and the target first-order logic structure corresponding to the target tuple, the fourth target loss function value corresponding to the target tuple is determined from the total loss function values ​​corresponding to each of the at least one anchor entity node.

10. The method according to claim 8, characterized in that, The method further includes: Determine the similarity between the first predicted vector representation and the second vector representation of any anchor entity node, wherein the value of the third loss function is determined based on the similarity; Based on the comparison result between the similarity and the set threshold, it is determined whether the target tuple contains out-of-domain data; If it is determined that the target tuple contains out-of-domain data, then the target tuple is deleted from the training set corresponding to the target first-order logical structure of the target tuple.

11. A method for training a knowledge graph reasoning model, characterized in that, include: Receive a request triggered by a user device through calling a knowledge graph reasoning model training service, the request including preset training query information; The following steps are performed using the processing resources corresponding to the knowledge graph reasoning model training service: Obtain a first tuple corresponding to the first first-order logical structure. The first tuple includes multiple entity nodes and at least one relation determined from the preset training query information. The multiple entity nodes include at least one anchor entity node and a target entity node. In the preset knowledge graph, determine the first adjacent entity node corresponding to each of the multiple entity nodes in the first tuple; In the reasoning subgraph that includes the plurality of entity nodes and the first adjacent entity nodes corresponding to each of the plurality of entity nodes, a second tuple and a second first-order logic structure corresponding to the second tuple are determined. The second first-order logic structure is not included in the multiple first-order logic structures that have been defined. In the knowledge graph, determine the second neighboring entity node corresponding to any entity node in the target tuple, wherein the target tuple is either the first tuple or the second tuple; The second vector representation corresponding to any entity node is determined based on the concatenation result of the first vector representations corresponding to any entity node and its second neighboring entity node, so as to obtain the vector representation set corresponding to the target tuple. The vector representation set includes the second vector representation of each entity node in the target tuple and the initial vector representation of each relation. The knowledge graph reasoning model is trained based on the vector representation set.

12. An electronic device, characterized in that, include: The system includes a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor performs the knowledge graph reasoning model training method as described in any one of claims 1 to 10.

13. A non-transitory machine-readable storage medium, characterized in that, The non-transitory machine-readable storage medium stores executable code, which, when executed by the processor of the cloud server, causes the processor to perform the knowledge graph reasoning model training method as described in any one of claims 1 to 10.

Citation Information

Patent Citations

  • Food safety intelligent question and answer reasoning method and device

    CN114399051A