A knowledge reasoning method based on multi-training global perception

By building a knowledge inference model with multi-training global perception and using the global attention mechanism to perform inter-node calculations, the existing model's insufficient ability to read and control information in graph structures is solved, and the accuracy of knowledge inference is improved and reliability.

CN118674033BActive Publication Date: 2024-11-05CHENGDU XIEEN SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411163465.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-11-05
Estimated Expiration
2044-08-23

AI Technical Summary

Technical Problem

The existing knowledge graph model lacks the ability to effectively read graph structure information and control global information in knowledge inference tasks, resulting in poor performance in complex inference tasks.

Method used

Using knowledge inference methods based on multi-training global perception, a knowledge inference model including multi-semantic embedding module, global attention module, feedforward neural network module, context broadcast module, occlusion extractor and Softmax classifier are constructed, through self-supervised learning and Transformer architecture uses global attention mechanism to perform inter-node computing, improving the utilization and interpretability of inference context.

Benefits of technology

It improves the accuracy and reliability of knowledge reasoning, especially in scenarios with high error risk, and enhances the understanding and reasoning ability of knowledge graphs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118674033B_ABST
    Figure CN118674033B_ABST
Patent Text Reader

Abstract

The present invention relates to a knowledge reasoning method based on multi-training global perception, which belongs to the field of computer models, including: constructing a training data set for completing a knowledge graph reasoning task; constructing a knowledge reasoning model, and initializing the parameters of the knowledge reasoning model; pre-training the knowledge reasoning model for knowledge perception through the training data set to obtain an initial knowledge reasoning model with optimized and updated parameters; fine-tuning and updating the initial knowledge reasoning model to obtain a trained knowledge reasoning model; constructing context reasoning data for the triples to be reasoned, inputting the context reasoning data into the trained knowledge reasoning model, obtaining a reasoning probability distribution, and selecting the entity or relationship with the largest probability as the final reasoning result. The present invention adopts a global attention mechanism to complete the calculation between nodes in knowledge reasoning, characterizes the source of node information contribution with the relative importance of nodes, gives interpretability to the knowledge reasoning results, and improves the application of knowledge reasoning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer models, and in particular to a knowledge reasoning method based on multi-training global perception. Background Art

[0002] Knowledge graphs build complex networks in the form of triples, making them an important way to effectively organize the explosive growth of massive knowledge and information on the Internet. Knowledge graphs are extremely important resources in many tasks in the field of artificial intelligence, such as question-answering systems and natural language generation. In question-answering systems, knowledge graphs can improve the system's ability to understand complex problems, especially when it comes to factual and logical reasoning problems. Knowledge graphs provide a reliable factual basis and knowledge background for the model. Through the embedding and reasoning capabilities of knowledge graphs, question-answering systems can not only provide accurate answers, but also derive deeper knowledge based on related information, enhancing the understanding and processing capabilities of user questions. Although there are many huge knowledge graphs, there is still a lack of a lot of factual information in the knowledge graph. As a result, the graph completion task was born, which aims to learn and mine rule information and features from existing triples, and then predict new unknown facts; link prediction plays a pivotal role in the knowledge graph completion task, attracting a large number of scholars to study hard. Graph neural networks have achieved good results in the field of knowledge graph completion based on their unique convolution / message passing mechanism, but they are also limited to the convolution / message passing mechanism, and traditional graph neural networks also lack the ability to control global information. Transformer happens to rely on a unique global attention mechanism and has developed many variants that have made it uniquely dominant in the fields of CV and NLP. At the same time, people have also begun to study its variants that are adapted to the characteristics of graph structure tasks: KG-bert, Graphfomer, EGT, kgTransformer, etc. However, due to the uniqueness of graph structured information, existing models lack the ability to read and learn graph structure information, so it is difficult to use them in knowledge reasoning tasks. Summary of the invention

[0003] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a knowledge reasoning method based on multi-training global perception to solve the deficiencies of the prior art.

[0004] The object of the present invention is achieved by the following technical solution: a knowledge reasoning method based on multi-training global perception, the knowledge reasoning method comprising:

[0005] S1. Build a training dataset for completing knowledge graph reasoning tasks;

[0006] S2. Construct a knowledge reasoning model based on multi-training global attention perception and initialize the parameters of the knowledge reasoning model;

[0007] S3, pre-training the knowledge reasoning model for knowledge perception through the training data set to obtain an initial knowledge reasoning model with optimized and updated parameters;

[0008] S4, fine-tune and update the initial knowledge reasoning model to obtain a trained knowledge reasoning model;

[0009] S5. Construct contextual reasoning data for the triples to be reasoned in the question-answering system, input the contextual reasoning data into the trained knowledge reasoning model, obtain the reasoning probability distribution, and select the entity or relationship with the highest probability as the final reasoning result in the question-answering system.

[0010] The knowledge reasoning model includes: a multi-semantic embedding module, a global attention module, a feedforward neural network module, a context broadcasting module, a masking extractor, an inference linear transformation and a Softmax classifier connected in sequence;

[0011] The multi-semantic embedding module is used to receive knowledge graph data with masking marks;

[0012] The global attention module is used to complete global perception of hidden features and graph perception learning;

[0013] The feedforward neural network module is used to complete the feature space transformation of the hidden layer features;

[0014] The context broadcast module is used to complete the acquisition of hidden layer features;

[0015] The inference linear transformation is used to complete the spatial transformation of target hidden layer features into entity and relationship features;

[0016] The Softmax classifier is used to complete the hidden layer probability distribution calculation of the target to be inferred.

[0017] The S2 step includes the following:

[0018] S21. Build a multi-semantic embedding module to receive knowledge graph data with masking marks and complete parameter initialization to embed a single node as ,in, It is an embedding representation in the node attribute feature space for different nodes represented by existing entities and relationships. It is an embedded representation in the node semantic feature space, which is used to distinguish the semantic expressions of different nodes in the knowledge graph. It is a representation in the node type space, used to distinguish masked nodes from real nodes during training;

[0019] S22, build a global attention module, complete the global perception of hidden features and graph perception learning, and complete parameter initialization, through the formula Complete the attention calculation and update the single node embedding representation, where is attention, T is transposition, is the softmax normalization function, Q is the query vector, K is the keyword vector, is the keyword dimension;

[0020] S23, construct a feedforward neural network module, complete the feature space transformation of the hidden layer features, and complete the parameter initialization. The feedforward neural network module completes the calculation through feedforward propagation and residual links, and updates the data embedding representation. The embedding representation of the node in the kth layer network is represented as , ,in, is a feedforward neural network, W o , W1 and W2 are weight matrices in the feedforward neural network, is the activation function in the feedforward neural network, b2 and b1 are the bias terms in the feedforward neural network, H is the feature space dimension of the feedforward neural network;

[0021] S24, construct a context broadcast module, expressed as , complete the hidden layer feature distribution conversion and complete the parameter initialization, where N is the set of all nodes input to the model, is the embedding representation of the i-th node in the data after graph serialization, is the embedding representation of the jth node in the data after graph serialization, It is the context broadcast module;

[0022] S25. Construct a decoder including a mask extractor, an inference linear transformation, and a Softmax classifier to complete the classification of node hidden states and complete parameter initialization.

[0023] In the decoder, the nodes to be predicted in the sequence data are first extracted by a mask extractor, and then the predicted probability distribution is obtained by inference linear transformation and Softmax classifier normalization.

[0024] The S3 step includes the following:

[0025] S31, setting the first training round number of knowledge-aware pre-training;

[0026] S32, determining whether the current first training round number is greater than 0, if yes, proceeding to step S33, otherwise, proceeding to step S39;

[0027] S33, taking a batch from the training data set, and constructing a sampling subgraph for each triple in the batch;

[0028] S34. When it is necessary to train the relationship prediction, a relationship query subgraph is generated for the sampling subgraph, and the masked relationship is replaced by R_mask; when it is necessary to train the entity prediction, an entity query subgraph is generated for the sampling subgraph, and the masked entity is replaced by E_max, where R_mask is a special relationship masking node and E_max is a special entity masking node;

[0029] S35, performing graph serialization conversion on the relationship query subgraph to obtain first model input sequence data; performing graph serialization conversion on the entity query subgraph to obtain second model input sequence data;

[0030] S36, inputting the first model input sequence data and the second model input sequence data into the knowledge reasoning model to obtain a classification probability result;

[0031] S37, comparing the classification probability result with the correct answer of the corresponding entity prediction task and relationship prediction task, and completing the first model loss calculation;

[0032] S38, optimizing and updating the model parameters of the knowledge reasoning model according to the first model loss, reducing the number of the first training rounds by 1 and returning to step S32;

[0033] S39. Use the current knowledge reasoning model as the initial knowledge reasoning model for optimizing and updating model parameters.

[0034] The expression for damage calculation of the first model is:

[0035] ;

[0036] ;

[0037] in, Predict losses for entities, is the relationship prediction loss, λ is the hyperparameter task control ratio, Embedding representation for the entity node to be predicted, is the entity query subgraph input data, A is the query subgraph adjacency matrix, is the predicted probability, is any entity to be predicted, is the set of entities to be predicted, is the network output with parameter θ, Embedding representation for the relationship node to be predicted, Enter data for the relational query subgraph, is any relationship to be predicted, is the set of relations to be predicted.

[0038] The S4 step includes the following:

[0039] S41, setting the second training round number of knowledge-aware pre-training;

[0040] S42, determining whether the current second training round number is greater than 0, if yes, proceeding to step S43, otherwise, proceeding to step S49;

[0041] S43, taking a batch from the training data set, and performing one-hop neighbor sampling on the head entity and the tail entity of each triple in the batch, respectively, to obtain a head entity neighbor subgraph and a tail entity neighbor subgraph;

[0042] S44. When it is necessary to fine-tune the model relationship prediction, the head entity neighbor subgraph and the tail entity neighbor subgraph are merged to obtain a synthetic sampling subgraph, and a link is added to the synthetic sampling subgraph to obtain a first query subgraph; when it is necessary to fine-tune the model link prediction, a second query subgraph and a third query subgraph are obtained;

[0043] S45, performing graph serialization conversion on the first query subgraph to obtain third model input sequence data, and performing graph serialization conversion on the second query subgraph or the third query subgraph to obtain fourth model input sequence data;

[0044] S46, inputting the third model input sequence data and the fourth model input sequence data into the initial knowledge reasoning model to obtain a classification probability result;

[0045] S47, comparing the classification probability result with the correct answer of the corresponding link prediction and relationship prediction tasks, and completing the second model loss calculation;

[0046] S48, optimizing and updating the model parameters of the initial knowledge reasoning model according to the second model loss, reducing the second training round number by 1, and returning to step S42;

[0047] S49. Use the current initial knowledge reasoning model as the trained knowledge reasoning model.

[0048] When it is necessary to fine-tune the model link prediction in step S44, the following operations are performed:

[0049] When reasoning is needed for the triple head entity, a link is added to the tail entity neighbor subgraph to obtain the second query subgraph;

[0050] When reasoning is needed for the tail entity of the triple, a link is added to the tail entity neighbor subgraph to obtain the third query subgraph.

[0051] The expression for calculating the loss of the second model is:

[0052] ;

[0053] ;

[0054] ;

[0055] Among them, e is an entity, r is a relationship, Fine-tuning the loss for link prediction, Fine-tuning the loss for relation prediction, Predict the set of correct answers for the entity, is the embedding representation of the entity node in the L-th layer network, is the embedding representation of the entity node in the decoder, Predict the correct answer set for the relation, is the embedding representation of the relation nodes in the L-th layer network, is the relation embedding representation in the decoder, is the embedding representation of the L-th layer network relationship, is the embedding representation of the L-th layer network entity, is the decoder relation embedding representation, Relation embedding representation for the decoder.

[0056] The present invention has the following advantages: a knowledge reasoning method based on multi-training global perception aims to improve the effect of knowledge reasoning, avoids the limitations of the quality and proportion of contrast samples in contrastive learning in the traditional knowledge reasoning process by improving the utilization of the reasoning context, and completes the knowledge reasoning task by using the Transformer architecture and self-supervised learning; uses a global attention mechanism to complete the calculation between nodes in knowledge reasoning, and characterizes the source of node information contribution by the relative importance of the nodes, thereby giving the knowledge reasoning results interpretability and improving the application of knowledge reasoning in scenarios with high reliability requirements and high error risks. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 It is a schematic diagram of the process of the present invention;

[0058] Figure 2 This is a structural diagram of the knowledge reasoning model. DETAILED DESCRIPTION

[0059] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application provided below in conjunction with the drawings is not intended to limit the scope of protection of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application. The present invention is further described below in conjunction with the drawings.

[0060] like Figure 1 As shown, the present invention specifically relates to a knowledge reasoning method based on multi-training global perception, which solves the problems of insufficient use of reasoning context and poor interpretability in traditional knowledge reasoning methods; it specifically includes the following contents.

[0061] S1. Build a training dataset for completing knowledge graph reasoning tasks;

[0062] S2. Construct a knowledge reasoning model based on multi-training global attention perception and initialize the parameters of the knowledge reasoning model;

[0063] S3, pre-training the knowledge reasoning model for knowledge perception through the training data set to obtain an initial model with optimized model parameters;

[0064] S4, fine-tune and update the initial model to obtain a trained model;

[0065] S5. Construct contextual reasoning data for the triples to be reasoned in the question-answering system, input the contextual reasoning data into the trained model, obtain the reasoning probability distribution, and select the entity or relationship with the highest probability as the final reasoning result of the question-answering system.

[0066] The training data comes from the WN18RR dataset, which contains 40,943 entities and 11 types of relationships. It is a commonly used dataset in the field of link prediction tasks in the form of (head entity, relationship, tail entity). For example, given the known contextual reasoning data: (actor A, starred in, movie M), (director B, director, movie M), the possible relationship (actor A, has a cooperative relationship, director B) can be inferred.

[0067] Building an inference context dataset is simply to summarize and organize the triple data and construct a query structure: the relationship set of "head entity-tail entity", the tail entity set corresponding to "head entity-relationship", the head entity set corresponding to "relationship-tail entity", etc.

[0068] Among them, knowledge graphs are usually stored in the form of triples (h, r, t), where h represents the head entity, t represents the tail entity, and r represents the association between the two. When processing a data set, the entity set, relationship set, and the associations between them are saved in the form of a linked list to improve the accuracy of subsequent verification; at the same time, an index graph is built for each knowledge graph data set to achieve rapid generation of subgraphs, contexts, etc.

[0069] Furthermore, if Figure 2 As shown in the figure, L represents the number of layers of the neural network. The knowledge reasoning model builds the knowledge graph reasoning task on the basis of the masking model, completes the model design from the perspective of self-supervision, and the knowledge reasoning model is based on the Transformer architecture; the knowledge reasoning model includes a multi-semantic embedding module, a global attention module, a feedforward neural network module, a context broadcasting module, a mask extractor, an inference linear transformation, and a Softmax classifier; wherein, the multi-semantic embedding module is used to receive knowledge graph data with masking marks, the global attention module is used to complete the global perception of hidden features and graph-aware learning, the feedforward neural network module is used to complete the feature space transformation of hidden layer features, the context broadcasting module is used to complete the hidden layer feature distribution conversion, the mask extractor is used to complete the target hidden layer feature acquisition, the inference linear transformation is used to complete the spatial transformation of the target hidden layer features to entity and relationship features, and the Softmax classifier is used to complete the probability distribution calculation of the target hidden layer to be inferred.

[0070] Furthermore, S2 specifically includes the following contents:

[0071] S21, construct a multi-semantic embedding module to receive knowledge graph data with masking marks and complete parameter initialization;

[0072] ;

[0073] In the formula, Embedding representation for a single node, , is a space of dimension d, It is an embedding representation in the node attribute feature space for different nodes represented by existing entities and relationships. It is an embedded representation in the node semantic feature space, which is used to distinguish the semantic expressions of different nodes in the knowledge graph. It is a representation in the node type space, used to distinguish masked nodes from real nodes during training;

[0074] S22. Build a global attention module to complete global perception of hidden features and graph perception learning, and complete parameter initialization. This module completes attention calculation through the following formula and updates the embedding representation of a single node;

[0075] ;

[0076] In the formula, is attention, T is transposition, is the softmax normalization function, Q is the query vector, which is obtained by linear transformation from a single node embedding representation, K is the keyword vector, which is obtained by linear transformation from a single node embedding representation, is the keyword dimension;

[0077] S23, construct a feedforward neural network module, complete the feature space transformation of the hidden layer features, and complete parameter initialization; the feedforward neural network module completes the calculation through feedforward propagation and residual link, and updates the data embedding representation, as shown in the following formula;

[0078] ;

[0079] ;

[0080] In the formula, is the embedding representation of the node in the k-th layer network, is a feedforward neural network, W o , W1 and W2 are weight matrices in the feedforward neural network, is the activation function in the feedforward neural network, b2 and b1 are the bias terms in the feedforward neural network, H is the feature space dimension of the feedforward neural network;

[0081] S24, constructing a context broadcast module, completing hidden layer feature distribution conversion, and completing parameter initialization;

[0082] ;

[0083] Where N is the set of all nodes input into the model, is the embedding representation of the i-th node in the data after graph serialization, is the embedding representation of the jth node in the data after graph serialization, It is the context broadcast module;

[0084] Among them, the context broadcast module performs average smoothing operations on all nodes in the input knowledge data, so that the nodes can obtain global information, perceive the semantic space range information in the input data, improve node representation, and optimize the training steps.

[0085] S25, construct a decoder, including a mask extractor, an inference linear transformation, and a Softmax classifier, complete the classification of the node hidden state, and complete the parameter initialization;

[0086] In the decoder, the nodes to be predicted in the sequence data are first extracted through the mask extractor MaskCls(.); secondly, the predicted probability distribution is obtained through inference linear transformation and Softmax classifier normalization.

[0087] Furthermore, S3 specifically includes the following contents:

[0088] S31, setting the first training round number in the knowledge-aware pre-training;

[0089] S32, determine whether the current first training round number is greater than 0, if so, proceed to S33, if not, proceed to S39;

[0090] S33. Take out a batch from the training data set and construct a sampling subgraph for each triple in the batch; a batch is a batch of data, and the batch size can be set, which is generally set to 256 here.

[0091] The triplet includes a head entity, a tail entity, and an association relationship between the head entity and the tail entity;

[0092] Among them, the sampling subgraph regards each triple as an enhanced data element, and samples the meta-subgraph of links in units of triples through the RandomWalk with Restart (RWR) strategy and the Tree-based RWR strategy. Among them, the RandomWalk with Restart algorithm does not restrict the shape of subgraph sampling, so that the model can understand graphs with different structural features; while the Tree-based RWR strategy restricts the subgraph generated by sampling to the shape of a tree, thereby enhancing the model's adaptability to special structures.

[0093] S34, when it is necessary to train the relationship prediction, generate a relationship query subgraph for the sampling subgraph, and replace the masked relationship with R_mask;

[0094] Among them, the generation of the relationship query subgraph adopts a masking strategy similar to Bert, and performs the same masking operation on the entities and edges in the subgraph. For example, for entity prediction training, 20% of the entities in the subgraph are selected as entity masking objects, and further 80% of the entities in the entity masking objects are replaced by a special entity masking node Emask, 10% are replaced by other entity nodes, and the remaining 10% are not subjected to any operation.

[0095] When training for entity prediction is needed, an entity query subgraph is generated for the sampled subgraph, and the obscured entities are replaced with E_max; the method of replacing obscured entities is similar to replacing obscured relations.

[0096] Among them, R_mask is a special relational masking node, and E_max is a special entity masking node.

[0097] S35, performing graph serialization conversion on the relationship query subgraph to obtain first model input sequence data; performing graph serialization conversion on the entity query subgraph to obtain second model input sequence data;

[0098] S36, inputting the first model input sequence data and the second model input sequence data into the knowledge reasoning model to obtain a classification probability result;

[0099] S37. Compare the classification probability results with the correct answers of the corresponding entity prediction tasks and relationship prediction tasks to complete the first model loss Calculation of

[0100] ;

[0101] ;

[0102] In the formula, Predict losses for entities, is the relationship prediction loss, λ is the hyperparameter task control ratio, Embedding representation for the entity node to be predicted, is the entity query subgraph input data, A is the query subgraph adjacency matrix, is the predicted probability, is any entity to be predicted, is the set of entities to be predicted, is the network output with parameter θ, Embedding representation for the relationship node to be predicted, Enter data for the relational query subgraph, is any relationship to be predicted, is the set of relations to be predicted.

[0103] S38, optimizing and updating the model parameters of the knowledge reasoning model according to the first model loss, reducing the number of the first training round by 1, and returning to S32;

[0104] S39. Use the current knowledge reasoning model as the initial knowledge reasoning model for optimizing and updating model parameters.

[0105] Furthermore, S4 specifically includes the following contents:

[0106] S41, setting the number of second training rounds in the knowledge-aware pre-training;

[0107] S42, judging whether the current second training round number is greater than 0, if so, proceeding to S43, if not, proceeding to S49;

[0108] S43, taking a batch from the training data set, and performing one-hop neighbor sampling on the source entity and the tail entity of each triple in the batch, respectively, to obtain a head entity neighbor subgraph and a tail entity neighbor subgraph;

[0109] S44, when it is necessary to fine-tune the model relationship prediction, merge the head entity neighbor subgraph and the tail entity neighbor subgraph to obtain a synthetic sampling subgraph, and add a link to the synthetic sampling subgraph to obtain a first query subgraph;

[0110] When you need to fine-tune the model link prediction, do the following:

[0111] When reasoning is needed for the triple head entity, a link is added to the tail entity neighbor subgraph to obtain a second query subgraph; when reasoning is needed for the triple tail entity, a link is added to the tail entity neighbor subgraph to obtain a third query subgraph;

[0112] S45, performing graph serialization conversion on the first query subgraph to obtain third model input sequence data, and performing graph serialization conversion on the second query subgraph or the third query subgraph to obtain fourth model input sequence data;

[0113] S46, inputting the third model input sequence data and the fourth model input sequence data into the initial model to obtain a classification probability result;

[0114] S47. Compare the classification probability results with the correct answers of the corresponding link prediction tasks and relationship prediction tasks to complete the second model loss Calculation of

[0115] ;

[0116] ;

[0117] ;

[0118] In the formula, e is the entity, r is the relationship, Fine-tuning the loss for link prediction, Fine-tuning the loss for relation prediction, Predict the set of correct answers for the entity, is the embedding representation of the entity node in the L-th layer neural network, is the embedding representation of the entity node in the decoder, Predict the correct answer set for the relation, is the embedding representation of the relation nodes in the L-th layer network, is the relation embedding representation in the decoder, is the embedding representation of the L-th layer network relationship, is the L-th layer neural network entity embedding representation, is the decoder relation embedding representation, Relation embedding representation for the decoder.

[0119] S48, optimizing and updating the model parameters of the initial model according to the second model loss, reducing the second training round number by 1, and returning to S42;

[0120] S49. Use the current initial model as the trained model.

[0121] Based on pre-training, the present invention completes the knowledge reasoning fine-tuning training of the initial model and completes the model parameter fine-tuning update. By fine-tuning the model parameters, the initial model is transformed from broad knowledge perception to targeted knowledge reasoning tasks. This step improves information utilization by supplementing the unit group with context, thereby improving the model knowledge reasoning effect.

[0122] The above is only a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used for various other combinations, modifications and improvements, and can be modified within the scope of the concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not deviate from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.

Claims

1. A knowledge reasoning method based on multi-training global perception, characterized by: The knowledge reasoning method comprises: S1. Build a training dataset for completing knowledge graph reasoning tasks; S2. Construct a knowledge reasoning model based on multi-training global attention perception and initialize the parameters of the knowledge reasoning model; S3, pre-training the knowledge reasoning model for knowledge perception through the training data set to obtain an initial knowledge reasoning model with optimized and updated parameters; S4, fine-tune and update the initial knowledge reasoning model to obtain a trained knowledge reasoning model; The S4 step includes the following: S41, setting the second training round number of knowledge-aware pre-training; S42, determining whether the current second training round number is greater than 0, if yes, proceeding to step S43, otherwise, proceeding to step S49; S43, taking a batch from the training data set, and performing one-hop neighbor sampling on the head entity and the tail entity of each triple in the batch, respectively, to obtain a head entity neighbor subgraph and a tail entity neighbor subgraph; S44. When it is necessary to fine-tune the model relationship prediction, the head entity neighbor subgraph and the tail entity neighbor subgraph are merged to obtain a synthetic sampling subgraph, and a link is added to the synthetic sampling subgraph to obtain a first query subgraph; when it is necessary to fine-tune the model link prediction, a second query subgraph and a third query subgraph are obtained; S45, performing graph serialization conversion on the first query subgraph to obtain third model input sequence data, and performing graph serialization conversion on the second query subgraph or the third query subgraph to obtain fourth model input sequence data; S46, inputting the third model input sequence data and the fourth model input sequence data into the initial knowledge reasoning model to obtain a classification probability result; S47, comparing the classification probability result with the correct answer of the corresponding link prediction and relationship prediction tasks, and completing the second model loss calculation; S48, optimizing and updating the model parameters of the initial knowledge reasoning model according to the second model loss, reducing the second training round number by 1, and returning to step S42; S49, using the current initial knowledge reasoning model as a trained knowledge reasoning model; S5. Construct contextual reasoning data for the triples to be reasoned in the question-answering system, input the contextual reasoning data into the trained knowledge reasoning model, obtain the reasoning probability distribution, and select the entity or relationship with the highest probability as the final reasoning result of the question-answering system; The knowledge reasoning model includes: a multi-semantic embedding module, a global attention module, a feedforward neural network module, a context broadcasting module, a masking extractor, an inference linear transformation and a Softmax classifier connected in sequence; The multi-semantic embedding module is used to receive knowledge graph data with masking marks; The global attention module is used to complete global perception of hidden features and graph perception learning; The feedforward neural network module is used to complete the feature space transformation of the hidden layer features; The context broadcast module is used to complete the acquisition of hidden layer features; The inference linear transformation is used to complete the spatial transformation of target hidden layer features into entity and relationship features; The Softmax classifier is used to complete the hidden layer probability distribution calculation of the target to be inferred.

2. According to claim 1, a knowledge reasoning method based on multi-training global perception is characterized by: The S2 step includes the following: S21. Build a multi-semantic embedding module to receive knowledge graph data with masking marks and complete parameter initialization to embed a single node as ,in, It is an embedding representation in the node attribute feature space for different nodes represented by existing entities and relationships. It is an embedded representation in the node semantic feature space, which is used to distinguish the semantic expressions of different nodes in the knowledge graph. It is a representation in the node type space, used to distinguish masked nodes from real nodes during training; S22, build a global attention module, complete the global perception of hidden features and graph perception learning, and complete parameter initialization, through the formula Complete the attention calculation and update the single node embedding representation, where is attention, T is transposition, for softmax Normalization function, Q is the query vector, K is the keyword vector, is the keyword dimension; S23, construct a feedforward neural network module, complete the feature space transformation of the hidden layer features, and complete the parameter initialization. The feedforward neural network module completes the calculation through feedforward propagation and residual links, and updates the data embedding representation. The embedding representation of the node in the kth layer network is represented as , ,in, is a feed-forward neural network, W o , W 1 and W 2 is the weight matrix in the feedforward neural network, is the activation function in the feedforward neural network, b 2 and b 1 is the bias term in the feedforward neural network, H is the feature space dimension of the feedforward neural network; S24, construct a context broadcast module, expressed as , complete the hidden layer feature distribution conversion and complete the parameter initialization, where, N is the set of all nodes input to the model, The data after the graph is serialized i The embedding representation of nodes, The data after the graph is serialized j The embedding representation of nodes, It is the context broadcast module; S25. Construct a decoder including a mask extractor, an inference linear transformation, and a Softmax classifier to complete the classification of node hidden states and complete parameter initialization.

3. The knowledge reasoning method based on multi-training global perception according to claim 2 is characterized by: In the decoder, the nodes to be predicted in the sequence data are first extracted by a mask extractor, and then the predicted probability distribution is obtained by inference linear transformation and Softmax classifier normalization.

4. The knowledge reasoning method based on multi-training global perception according to claim 1 is characterized in that: The S3 step includes the following: S31, setting the first training round number of knowledge-aware pre-training; S32, determining whether the current first training round number is greater than 0, if yes, proceeding to step S33, otherwise, proceeding to step S39; S33, taking a batch from the training data set, and constructing a sampling subgraph for each triple in the batch; S34. When it is necessary to train the relationship prediction, a relationship query subgraph is generated for the sampling subgraph, and the masked relationship is replaced by R_mask; when it is necessary to train the entity prediction, an entity query subgraph is generated for the sampling subgraph, and the masked entity is replaced by E_max, where R_mask is a special relationship masking node and E_max is a special entity masking node; S35, performing graph serialization conversion on the relationship query subgraph to obtain first model input sequence data; performing graph serialization conversion on the entity query subgraph to obtain second model input sequence data; S36, inputting the first model input sequence data and the second model input sequence data into the knowledge reasoning model to obtain a classification probability result; S37, comparing the classification probability result with the correct answer of the corresponding entity prediction task and relationship prediction task, and completing the first model loss calculation; S38, optimizing and updating the model parameters of the knowledge reasoning model according to the first model loss, reducing the number of the first training rounds by 1 and returning to step S32; S39. Use the current knowledge reasoning model as the initial knowledge reasoning model for optimizing and updating model parameters.

5. The knowledge reasoning method based on multi-training global perception according to claim 4 is characterized in that: The expression for damage calculation of the first model is: ; ; in, Predict losses for entities, Predict the loss for the relationship, λ is the hyperparameter task control ratio, Embedding representation for the entity node to be predicted, is the entity query subgraph input data, A is the query subgraph adjacency matrix, is the predicted probability, is any entity to be predicted, is the set of entities to be predicted, is the network output with parameter θ, Embedding representation for the relationship node to be predicted, Enter data for the relational query subgraph, is any relationship to be predicted, is the set of relations to be predicted.

6. The knowledge reasoning method based on multi-training global perception according to claim 1 is characterized by: When it is necessary to fine-tune the model link prediction in step S44, the following operations are performed: When reasoning is needed for the triple head entity, a link is added to the tail entity neighbor subgraph to obtain the second query subgraph; When reasoning is needed for the tail entity of the triple, a link is added to the tail entity neighbor subgraph to obtain the third query subgraph.

7. The knowledge reasoning method based on multi-training global perception according to claim 1 is characterized by: The expression for calculating the loss of the second model is: ; ; ; in, e For entities, r For relationship, Fine-tuning the loss for link prediction, Fine-tune the loss for relation prediction, Predict the set of correct answers for the entity, is the embedding representation of the entity node in the L-th layer network, is the embedding representation of the entity node in the decoder, Predict the correct answer set for the relationship, is the embedding representation of the relation nodes in the L-th layer network, is the relation embedding representation in the decoder, is the L-th layer network relationship embedding representation, is the embedding representation of the L-th layer network entity, is the decoder relation embedding representation, Relation embedding representation for the decoder.