Knowledge graph complex logical reasoning-oriented generative method

Through the structure-enhanced diffusion model and self-attention mechanism, the problem of semantic uncertainty of complex logical queries in knowledge graph reasoning is solved, and better knowledge graph logical reasoning performance and answer generation effects are achieved.

CN118760745AInactive Publication Date: 2024-10-11INSTITUTE OF INFORMATION ENGINEERING CHINESE ACADEMY OF SCIENCES
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410736214.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-10-11
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing knowledge graph reasoning methods are difficult to effectively capture the semantic uncertainty of multiple relationships in complex logical queries, and most methods can only retrieve answers but cannot understand the semantics of the query. The application of generative models in this field has not been fully explored.

Method used

The structure-enhanced diffusion model is used to convert complex logical queries into input sequences through the query conversion module, and the forward and backward processes of the diffusion reasoning module are used, combined with the structure-enhanced self-attention mechanism, to learn multiple complex logical queries on the knowledge graph. Semantic joint distribution,captures uncertainty about entities and relations, and,generates coherent answers.

Benefits of technology

It improves the performance of knowledge graph logical reasoning tasks, can better understand the semantics of complex queries and generate accurate answers, and performs better on common data sets than baseline methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760745A_ABST
    Figure CN118760745A_ABST
Patent Text Reader

Abstract

The invention discloses a knowledge graph complex logical reasoning-oriented generative method. The system comprises a query conversion module and a diffusion reasoning module, the logic query conversion module converts a first-order logic query into an input sequence, the diffusion reasoning module displays a forward and backward bidirectional generation process, and a converter of a structure enhanced self-attention mechanism is designed. The query conversion module converts a symbolized first-order logic query into a natural language input sequence, and the diffusion reasoning module captures composite distribution of a complex logic query through a multi-step generation process of a forward process and a backward process; meanwhile, a self-attention mechanism with an enhanced structure is designed in a converter of the diffusion model, so that important structural features in the knowledge graph are effectively fused. According to the method, the controllability and interpretability of the model are further guaranteed through multi-granularity control over the diffusion intermediate process; and compared with other baseline methods, a better knowledge graph reasoning result is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer data mining and analysis technology, and in particular to the field of knowledge graph representation and reasoning technology, and specifically refers to a generative method for complex logical reasoning of knowledge graphs. Background Art

[0002] Knowledge reasoning is the process of analyzing, synthesizing and predicting based on existing knowledge facts. Knowledge graphs use the structured form of entity and relationship triples to organize and express massive data and valuable knowledge in the real world. As the basis of knowledge reasoning, the knowledge graph reasoning task aims to infer new knowledge or answer query questions based on observed facts. In recent years, knowledge graph reasoning technology has played a vital role in many fields such as intelligent question answering, recommendation systems, and drug discovery, and has attracted widespread attention from academia and industry. The task that the present invention focuses on is complex logical reasoning for knowledge graphs, that is, first-order logic queries, whose logical operators include existential quantifiers. Conjunction (∧), Disjunction (∨), and Negation like Figure 1 As shown, the first-order logic query expression for the question "Which universities did the Canadian Turing Award winners graduate from?" is Received (Turing Award, v) ∧ Nationality (Canada, v) ∧ Graduated from (v, V ? ), different relations have different semantic distributions, the relation representation is modeled as a Gaussian distribution, the logical query distribution is regarded as a mixed Gaussian distribution of three relations, and the reasoning of the knowledge graph generates a multi-semantic joint distribution of queries through multiple iterative processes. However, complex logical reasoning for knowledge graphs is a challenging task. First, multi-hop complex queries increase the difficulty of knowledge reasoning; second, most real-world knowledge graphs are large-scale; in addition, these knowledge graphs are even incomplete, making queries unanswerable.

[0003] In recent years, in order to meet these challenges, scholars have explored two research directions. The first direction is to improve the knowledge graph embedding method that has been successful in the knowledge graph completion task, by iteratively performing neural geometric logic operations on the query dependency graph to map complex logical queries to a low-dimensional continuous vector space. Such methods can efficiently retrieve the target answer to the query, but are difficult to generalize to more complex queries because the shallow embedding structure limits their expressive power. The other direction mainly uses a pre-trained transformer architecture to deeply explore richer semantics and intrinsic patterns, and is committed to integrating structural knowledge and semantic knowledge into the transformer. With the powerful semantic modeling and reasoning capabilities of advanced pre-trained base models, transformer-based knowledge graph multi-hop complex logical reasoning tasks have made significant progress.

[0004] Despite the above successes, there are still some difficulties and challenges in the existing incomplete knowledge graph reasoning methods. First, these methods use a neural network structure to assign a vector representation to each query, but ignore the uncertainty of entities and relations on the knowledge graph. In fact, different entities and relations may contain different semantic distributions. For example, in the inference query (Geoffrey Hinton, birthplace,?), the semantic distribution of "nationality" is obviously closer to the semantic distribution of the given query than "graduation". Therefore, existing methods have limitations in capturing the uncertainty of logical queries with multiple relational semantics. Secondly, most methods use a discriminant representation framework to encode complex logical queries, but this framework only retrieves answers and cannot understand the semantics of the entire query. In contrast, the present invention believes that the generative model can well learn the joint distribution of queries and answers, which makes it have unique advantages in modeling complex semantics and generating coherent answers. Recently, generative models have achieved impressive results in many fields such as image generation, video generation, and language understanding. However, how to use generative models to capture the potential joint distribution of complex queries on knowledge graphs remains an unknown challenge. Summary of the invention

[0005] The present invention regards the complex logical reasoning task of knowledge graph as a novel generative question-answering task, and models the multi-semantic joint distribution of complex logical queries on knowledge graph through a structure-enhanced diffusion model. The present invention proposes a generative method for complex logical reasoning of knowledge graph.

[0006] The technical solution of the present invention is:

[0007] A generative method for complex logical reasoning of knowledge graphs, the steps of which include:

[0008] 1) Establishing a reasoning model, the reasoning model includes a query conversion module and a diffusion reasoning module; the diffusion reasoning module includes a forward process and a backward process of the diffusion model and a transformer with a structure-enhanced self-attention mechanism in the backward process; for complex logical reasoning query sets For each query Q in the query Q, for each anchor entity e in the query Q i From the knowledge graph Extract the k-hop neighbor node set Among them, i∈{1,2,..,n e},n e is the number of anchor entities in the query Q;

[0009] 2) The query conversion module queries the intersection of the k-hop neighboring node sets of all anchor entities in Q

[0010] The nodes in the local subgraph are used to construct Nodes, using knowledge graph The node relationships in the query Q are used to construct a local subgraph in, For local subgraph The entity set in For local subgraph The set of relations in ; for a local subgraph Each triple (u, r, v) in Entities in, r is the relationship set The triple (u, r, v) indicates that there is a relationship r between entity u and entity v, that is,

[0011] r(u,v)=True;

[0012] 3) The query conversion module is based on the local subgraph For each relation r in the , create a relation type node r uv And connect with entity u and entity v respectively to construct the context subgraph And get the context subgraph The adjacency matrix A of Edge Set

[0013]

[0014] 4) The query conversion module converts the context subgraph Serialize to get the input sequence of query Q

[0015] In the input sequence Add an answer node at the end and send it to the diffusion reasoning module;

[0016] Among them, e i Representing context subgraph The i-th node in , i∈{1,2,..,s}, s represents the context subgraph The total number of nodes in ;

[0017] 5) The diffusion inference module inputs the sequence Map to continuous representation and add β 0 The noise size is Then, the forward process is used to gradually move to the original Add noise to get the query representation at time T Using the backward process Iterative sampling to reconstruct the target query representation In the backward process, the query at each time t is represented as The hidden state obtained by the i-th transformation layer of the self-attention mechanism is recorded as h i , i∈{1,2,...,L}, the transformer is based on the hidden state h of the i-1th transformation layer i-1 and context diagram The adjacency matrix A is used to obtain the hidden state h of the i-th transformation layer that incorporates the structural features. i ;

[0018] 6) Calculate the loss function Optimizing the parameters of the inference model according to the loss value; wherein,

[0019] represents the output of the diffusion model at time t, is the regularization term used to regularize representation learning;

[0020] in, is the set of answers to query Q, P(a|Q) represents the probability that entity a is the correct answer, and P(a′|Q) represents the probability that entity a′ is the correct answer. for Continuous representation of ;

[0021] 7) For a query Q 1 , using the trained query conversion module to convert it into a query sequence Then the discrete sequence Map to continuous representation and add β 0 The noise size is Input the trained diffusion reasoning module; the trained diffusion reasoning module uses the backward process to Processing generates query representation in a given knowledge graph Query and get the predicted answer.

[0022] Furthermore, the token embedding function EMB(·) is used to embed the input sequence Map to continuous representation and add β 0 The noise size is

[0023] Furthermore, a token generation step is added in the backward process Used to remap the last recovered query representation to discrete tokens; where p θ (s i |x i ) is a softmax distribution.

[0024] Furthermore, in the forward process, a partial noise strategy is used to Apply noise to different parts of the

[0025] Furthermore, the forward process uses the formula Gradually towards the original Add noise to get the query representation at time t in, represents Gaussian distribution, I represents the identity matrix, forms a Markov chain, and β t ∈(0,1) is a noise table used to set the noise scale injected at each step.

[0026] A server, characterized in that it comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing each step in the above method.

[0027] A computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the above method when executed by a processor.

[0028] This paper considers complex logical reasoning tasks as a generative question-answering task. Inspired by the diffusion model, this paper attempts to integrate the diffusion model into knowledge graph reasoning to model the joint distribution of queries and answers. The diffusion model is a new and promising generative model paradigm that not only provides an elegant way to inject uncertainty into the model through Gaussian distribution, but also uses a multi-step generation process to improve the distribution representation and ensure the controllability and interpretability of the model's intermediate process.

[0029] The technical solution adopted by the present invention is to model the entity and relationship representation of the knowledge graph as a Gaussian distribution to take into account the uncertainty of entities and relationships, and then use the multi-step generation process of the generative diffusion model to learn the multi-semantic joint distribution of complex logical queries, and finally improve the performance of the knowledge graph logical reasoning task through multi-task joint optimization. In addition, the controllability and interpretability of the model are further guaranteed by the multi-granularity control of the diffusion intermediate process.

[0030] According to the above technical solution, the present invention consists of two parts: a query conversion module and a diffusion reasoning module. The overall framework of the model is as follows: Figure 2As shown in the figure, the model includes a query conversion module and a diffusion reasoning module. The logical query conversion module converts the first-order logic query into an input sequence. The diffusion reasoning module shows the forward and backward bidirectional generation process and designs a transformer with a structure-enhanced self-attention mechanism. The query conversion module converts the symbolic first-order logic query into a natural language input sequence. The diffusion reasoning module captures the compound distribution of complex logical queries through a multi-step generation process of forward and backward processes. At the same time, a structure-enhanced self-attention mechanism is designed in the transformer of the diffusion model to effectively integrate important structural features in the knowledge graph.

[0031] 1. Query conversion module

[0032] Knowledge Graph is a heterogeneous graph network representing the real world, where ε is the knowledge graph The entity set in Knowledge Graph The relation set in , e∈ε represents an entity, r:ε×ε→{True,False} is a binary function indicating an entity pair (e i ,e j ) whether a relation r is established between them. The logical operations of first-order logic queries include existential quantifiers Conjunction (∧), Disjunction (∨), and Negation The expression of the conjunction query Q is as follows:

[0033]

[0034] Among them, E ? represents the target variable of the logical query, E 1 ,…,E m refers to a set of existing variables, e a Represents a non-variable anchor entity. The goal of complex logic query in knowledge graph is to find The target entity set So that iff Q[E ? ] is true. In addition, the expression of the disjunctive query can be converted into a disjunctive normal form by an existing method. It should be noted that the present invention does not consider a first-order logic query containing a negated form.

[0035] In order to meet the input constraints of the transformer-based diffusion model, the present invention converts the first-order logic query into an input sequence in the query conversion module. Considering that the knowledge graph is heterogeneous and structured, it is challenging to encode the logical query while retaining the structural information of the knowledge graph. Therefore, the present invention designs a query conversion strategy to convert complex logical queries into input sequences by dynamically constructing context subgraphs.

[0036] Specifically, for a logical query Q, the present invention first constructs a local subgraph of the query Q in For local subgraph The entity set in For local subgraph For each anchor entity e in the query Q i , from the knowledge graph Upper extraction e i The set of k-hop neighboring nodes where i = {1,2,..,n e},n e is the set of k-hop neighbor nodes Then, the present invention selects the intersection of the k-hop neighboring node sets of all anchor entities and treat them as local subgraphs Nodes of the local subgraph Entity Sets in Finally, the present invention utilizes these entity nodes and their dependencies in the knowledge graph To construct a local subgraph And prune isolated nodes or nodes whose distance to any anchor entity is greater than k.

[0037] Next, in order to better integrate the heterogeneous information from entities and relationships in the knowledge graph, the present invention combines the local subgraph Each relationship edge in is regarded as a node of a relationship type, and a context subgraph is further constructed. For local subgraphs Each triple (u, r, v) in Entities in, r is the relationship set The triple indicates that there is a relationship r between entity u and entity v. When r(u,v)=True, the present invention creates a node r of the relationship type. uv , used to connect entity u and entity v. Therefore, the context subgraph The nodes include the original entity type nodes and the newly created relationship type nodes. The edges between the nodes represent the relationship between the entity nodes and the relationship nodes. Therefore, the context subgraph Middle Node Set and edge sets r(u,r uv ) represents node r uv There is a connection relationship (that is, there is an edge) with entity u, r(r uv ,v) represents node r uv There is a connection relationship with entity v (that is, there is an edge).

[0038] Finally, according to the constructed context graph The present invention serializes it to obtain the input sequence of the logical query Q Where s represents the length of the sequence, and an answer node is added at the end of the sequence. In addition, the present invention also introduces a special node type encoding scheme to distinguish the types of nodes, where "0" represents an entity node and "1" represents a relationship node. The present invention additionally stores the context graph The adjacency matrix A of is used to retain the structural characteristics of the context graph. This structural information will be used in the subsequent diffusion inference model.

[0039] 2. Diffusion Reasoning Module

[0040] The diffusion model is a probabilistic generative model that estimates the distribution of the target data to generate the desired samples. Usually, the diffusion model consists of a forward process and a backward process. Specifically, given a sample The forward process generates a Markov chain containing T latent variables by adding Gaussian noise at each time step t∈{1,2,…,T} At the last time step t = T, Destroyed to an isotropic Gaussian distribution Here the forward process is recorded as After the forward process is completed, the backward process predicts the learnable distribution by training the diffusion model Reverse iteration to regenerate the original data In other words, through fine-grained control over the generation process, the diffusion model demonstrates its ability to capture implicit dependencies and intrinsic patterns in the data distribution.

[0041] In the diffusion reasoning module, in order to better characterize the uncertainty of entities and relations, the present invention does not model entity and relation representations as fixed vectors, but instead regards them as Gaussian distributions. Different distributions represent different semantics, and uses the multi-step generation process of the diffusion model to learn the multi-semantic joint distribution of complex logical queries. Specifically, based on the context query sequence In the forward process, the initial representation of the query embedding is first obtained, and the embedding is converted to a Gaussian distribution by injecting noise. In the backward process stage, the Gaussian noise is iteratively inverted to restore the target query representation. In particular, the present invention designs a structure-enhanced self-attention mechanism in the converter to integrate the extremely important structural features in the knowledge graph.

[0042] Forward process: In the forward process q of the diffusion model, given the input sequence The present invention first uses a token embedding function EMB(·) to embed the discrete sequence Map to continuous representation and add β 0The noise size is and The formal expression of the relationship between the two is: Then through the formula Gradually towards the original Add noise:

[0043]

[0044] in, represents Gaussian distribution, I represents the identity matrix, forms a Markov chain, and β t ∈(0,1) is a noise table that sets the noise scale injected at each step. Note that the traditional diffusion model will destroy the entire However, considering the heterogeneity of knowledge graphs, the present invention explores whether distinguishing different types of nodes (entities or relationships) is helpful for the generation of query distribution. Therefore, the present invention adopts a partial noise strategy to Apply noise to different parts of the

[0045] Backward process: After the forward process is completed, the goal of the backward process is to The target query representation is gradually reconstructed through iterative sampling of learnable transformations

[0046]

[0047] Among them, μ θ (·) and σ θ (·) is the forward process The predicted mean and standard deviation are calculated using Bayes' rule and applied to the transformer model f θ In the backward process of the diffusion model, the present invention also adds a token generation step where p θ (s i |x i ) is a softmax distribution used to remap the final recovered query representation to discrete tokens.

[0048] Structure-enhanced self-attention: Due to the nature of traditional diffusion models, an input token can pay attention to all other tokens in the sequence through a full self-attention mechanism, just like a fully connected graph neural network. However, the present invention needs to encode the weighted structural features of the knowledge graph, where the structural features of entity relationships are very important information in the complex logical reasoning of the knowledge graph.

[0049] To this end, the present invention designs a structure-enhanced self-attention mechanism in the backward process of the diffusion model, such as Figure 3 As shown in Figure 2, important structural knowledge facts are incorporated into the model to better understand the semantics of logical queries. Specifically, in the backward process, for each query representation at time t, The hidden state obtained by the i-th transformation layer of the self-attention mechanism is recorded as h i , i∈{1,2,...,L}. In order to better integrate the structural features of the knowledge graph, the present invention proposes a structure-enhanced self-attention mechanism, including L transformation layers. For the i-th transformation layer, the input is the hidden state h of the i-1-th transformation layer. i-1 and context diagram The adjacency matrix A of the i-th transformation layer is output as the hidden state h of the i-th transformation layer that incorporates the structural features. i Finally, after L transformation layers, the hidden state h is obtained. L , which is the query representation at time t-1 Therefore, the present invention integrates the structural features into the self-attention layer in the transformer:

[0050] Q i+1 ,K i+1 ,V i+1 =h i W q ,h i W k ,h i W v

[0051]

[0052] h i+1 =S i+1 V i+1

[0053] Among them, h i is the hidden state of the i-th transformation layer, W q , W k and W v is a learnable parameter. k is the dimension of K, used for numerical scaling. By means of attention bias, the present invention adds context subgraph The dependencies between entities and relationships in the graph are realized, which integrates the structural features in the recognition graph and improves the reasoning ability of the model.

[0054] 3. Model training and inference

[0055] During the model training process, based on the original diffusion model, the present invention calculates the variational lower bound to minimize the difference between the generated target distribution and the real data. Diffusion loss function of the diffusion model The definition is as follows:

[0056]

[0057] in, represents the output of the diffusion model at time t, is a mathematically equivalent regularization term used to regularize representation learning. Then, the knowledge graph inference loss function is trained by minimizing the cross entropy loss.

[0058]

[0059] in, is the set of answers to the complex query Q, and P(a|Q) represents the probability that entity a is the correct answer. The diffusion module reconstructs the query sequence representation The predicted answer representation is included in the answer representation, and the probability of the correct answer P(a|Q) is obtained by calculating the similarity between the predicted answer representation and the target answer representation. Finally, the joint training objective of the model is defined as the diffusion loss function And the inference loss function Combination of:

[0060]

[0061] The model is trained according to the above loss function to obtain the optimal model parameters. In the model testing phase, the predicted answer on the knowledge graph reasoning task test set is calculated based on the representation generated by the backward process of the diffusion model.

[0062] The beneficial effects of the present invention are:

[0063] The present invention designs a generative method for complex logical reasoning of knowledge graphs. In order to consider the uncertainty of entities and relationships, the entity and relationship representations of the knowledge graph are modeled with Gaussian distribution, and then the multi-semantic joint distribution of complex logical queries is learned through the multi-step generation process of the generative diffusion model, and finally the performance of knowledge graph logical reasoning tasks is improved by multi-task joint optimization. The present invention evaluates the effect of the model on two common knowledge graph reasoning datasets (NELL995 and FB15k237). Experimental results show that the present invention achieves better knowledge graph reasoning results compared with other baseline methods.

[0064] Table 1 Performance comparison of different models on knowledge graph reasoning tasks on two datasets

[0065] BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Figure 1 It is a motivational illustration of complex logical reasoning in knowledge graphs.

[0067] Figure 2 It is the overall structural diagram of the present invention.

[0068] Figure 3 is the structure-enhanced self-attention map in the Transformer. DETAILED DESCRIPTION

[0069] The present invention is further described in detail below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention but not to limit the scope of the present invention.

[0070] This embodiment discloses a generative method for complex logical reasoning of knowledge graphs, including the following steps:

[0071] Assuming that the knowledge graph is given Complex logical reasoning query set (including training samples and test samples), the model f with initialization parameters θ θ , the answer prediction process for complex logical queries is as follows:

[0072] 1. For each query For each anchor entity e in the query Q, the present invention i , from the knowledge graph Extract the k-hop neighbor node set where i∈{1,2,..,n e} and n e is the number of anchor entities in the query.

[0073] 2. The present invention selects the intersection of the k-hop neighboring node sets of all anchor entities in the query Q

[0074] Treat them as local subgraphs , and use the node relationships in the knowledge graph to build a local subgraph of query Q

[0075] 3. By placing the local subgraph Each node relationship in is regarded as a node, and the present invention further constructs a context subgraph The node set and edge sets

[0076] 4. Based on the constructed context subgraph The present invention serializes it to obtain the input sequence of query Q

[0077] Among them, e i Representing context subgraph The middle node, i∈{1,2,..,s}, s represents the length of the sequence, and an answer node is added at the end of the sequence.

[0078] 5. In the diffusion reasoning module, for each query Q input sequence The present invention first uses the token embedding function EMB(·) to embed the query sequence Map to continuous representation and add β 0 The noise size is Then, in the forward process of the diffusion model, gradually move to the original Add noise, through the formula Get the query representation at time t

[0079] Finally, in the backward process of the diffusion model, the Gaussian white noise By Model

[0080] Iterative sampling to reconstruct the target query representation

[0081] 6. In the backward process of the diffusion model, for each query at time t, The hidden state obtained by the i-th transformation layer of the self-attention mechanism is recorded as h i , i∈{1,2,...,L}. In order to better integrate the structural features of the knowledge graph, the present invention proposes a structure-enhanced self-attention mechanism, including L transformation layers. For the i-th transformation layer, the input is the hidden state h of the i-1-th transformation layer. i-1 and context diagram The adjacency matrix A of the i-th transformation layer is output as the hidden state h of the i-th transformation layer that incorporates the structural features. i Finally, after L transformation layers, the hidden state h is obtained. L , which is the query representation at time t-1

[0082] 7. During the model training phase, from the training set Sample a batch query The present invention uses the above method to obtain the predicted answer, according to the loss function To calculate the loss of the model, we further adopt the gradient descent method To optimize the model parameters θ. Repeat this step until the model converges.

[0083] 8. In the inference phase of the model, from the test set Sample a query Q in the training set, and iteratively calculate the query from time T to time 1 based on the trained model. Based on the query representation generated by the backward process of the diffusion model at time t = 1, calculate the predicted answer on the knowledge graph reasoning task test set. Repeat this step until all test data traversal is completed.

[0084] 9. Finally, the average reciprocal ranking test indicator is used to evaluate the performance of complex logical reasoning tasks for knowledge graphs.

[0085] In the actual application stage, for a query Q (non ), first use the query conversion module to convert it into a query sequence Then, the token embedding function EMB(·) is used to transform the discrete sequence Map to continuous representation and add β 0 The noise size is And input the trained diffusion reasoning module, the trained diffusion reasoning module uses the backward process to process it to generate query representation, and finally in the given knowledge graph Query and get the predicted answer.

[0086] Regarding the specific application fields and application scenarios of the present invention:

[0087] The present invention targets important knowledge reasoning tasks in the field of graph data mining. The knowledge reasoning tasks oriented to knowledge graphs aim to infer new knowledge or identify erroneous knowledge based on existing facts, and have played a vital role in application fields such as intelligent question answering and vertical search.

[0088] In intelligent question answering, for subtasks such as user query understanding, entity relationship characterization and answer generation, the method of the present invention can better understand the complex queries raised by users and provide multi-semantic representations of entities and relationships, thereby providing users with accurate search results or answering questions.

[0089] In smart healthcare, for tasks such as symptom-disease association, diagnosis and treatment plan recommendation, the method of the present invention can be used to integrate medical knowledge and patient clinical data, and knowledge reasoning technology can be used to infer possible diseases and optimal treatment plans.

[0090] Although the specific embodiments of the present invention are disclosed for the purpose of illustration, the purpose is to help understand the content of the present invention and implement it accordingly, those skilled in the art will understand that various substitutions, changes and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the present invention should not be limited to the content disclosed in the best embodiment, and the scope of the present invention is subject to the scope defined in the claims.

Claims

1. A generative method for complex logical reasoning of knowledge graphs, comprising the following steps: 1) establishing a reasoning model, wherein the reasoning model includes a query conversion module and a diffusion reasoning module; The diffusion reasoning module includes a forward process and a backward process of the diffusion model, and a transformer with a structure-enhanced self-attention mechanism in the backward process; for complex logical reasoning query sets For each query Q in the query Q, for each anchor entity e in the query Q i From the knowledge graph Extract the k-hop neighbor node set Among them, i∈{1,2,..,n e },n e is the number of anchor entities in the query Q; 2) The query conversion module queries the intersection of the k-hop neighborhood node sets of all anchor entities in Q The nodes in the local subgraph are used to construct Nodes, using knowledge graph The node relationships in the query Q are used to construct a local subgraph in, For local subgraph The entity set in For local subgraph The set of relations in ; for a local subgraph Each triple (u, r, v) in Entities in, r is the relationship set The triple (u, r, v) indicates that there is a relationship r between entity u and entity v, that is, r(u, v) = True; 3) The query conversion module is based on the local subgraph For each relation r in the , create a relation type node r uv And connect with entity u and entity v respectively to construct the context subgraph And get the context subgraph The adjacency matrix A of Edge Set 4) The query conversion module converts the context subgraph Serialize to get the input sequence of query Q In the input sequence Add an answer node at the end of the answer node and send it to the diffusion reasoning module; where e i Representing context subgraph The i-th node in , i∈{1,2,..,s}, s represents the context subgraph The total number of nodes in ; 5) The diffusion inference module inputs the sequence Mapped to a continuous representation, and adding noise of size β0 to obtain Then, the forward process is used to gradually move to the original Add noise to get the query representation at time T Using the backward process Iterative sampling to reconstruct the target query representation In the backward process, the query at each time t is represented by The hidden state obtained by the i-th transformation layer of the self-attention mechanism is recorded as h i , i∈{1,2,...,L}, the transformer is based on the hidden state h of the i-1th transformation layer i-1 and context diagram The adjacency matrix A is used to obtain the hidden state h of the i-th transformation layer that incorporates the structural features. i ; 6) Calculate the loss function Optimizing the parameters of the inference model according to the loss value; wherein, represents the output of the diffusion model at time t, is the regularization term used to regularize representation learning; in, is the set of answers to query Q, P(a|Q) represents the probability that entity a is the correct answer, and P(a′|Q) represents the probability that entity a′ is the correct answer. for Continuous representation of ; 7) For a query Q 1 , using the trained query conversion module to convert it into a query sequence Then the discrete sequence Mapping to a continuous representation and adding noise of size β0 gives Input the trained diffusion reasoning module; the trained diffusion reasoning module uses the backward process to Processing generates query representation in a given knowledge graph Query and get the predicted answer.

2. The method according to claim 1, characterized in that The token embedding function EMB(·) is used to embed the input sequence Mapping to a continuous representation and adding noise of size β0 gives 3. The method according to claim 2, characterized in that Added a token generation step in the backward process Used to remap the last recovered query representation to discrete tokens; where p θ (s i |x i ) is a softmax distribution.

4. The method according to claim 1, 2 or 3, characterized in that: In the forward process, a partial noise strategy is used to Apply noise to different parts of the 5. The method according to claim 1, 2 or 3, characterized in that: The forward process uses the formula Gradually towards the original Add noise to get the query representation at time t in, represents Gaussian distribution, I represents the identity matrix, constitutes a Markov chain, and β t ∈(0,1) is a noise table used to set the noise scale injected at each step.

6. A server, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing each step in the method according to any one of claims 1 to 5.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Cited By

  • Logical reasoning question answering method, related device, equipment and storage medium

    CN119917609A