Knowledge reasoning method based on deep migration reinforcement learning
Through the deep transfer reinforcement learning method, the problem of low success rate of agent path mining in the knowledge graph is solved, the multi-step reasoning ability is improved, and more efficient knowledge graph reasoning is achieved.
Patent Information
- Application Number
- CN202410800036.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-10-01
AI Technical Summary
In the existing technology, in the knowledge graph reasoning, the agent chooses invalid actions in the early stage of reasoning, resulting in a low success rate of path mining, and the multi-step reasoning ability is insufficient, making it difficult to effectively process complex knowledge graphs.
Using a method based on deep transfer reinforcement learning, we perform single-step search training in the pre-task, establish a reinforcement learning environment, construct a state space and action space, set up a reward mechanism, pre-train the agent, and then migrate to the target task for fine-tuning training. Optimize path search and multi-step reasoning capabilities.
It significantly improves the agent's path search success rate and multi-step reasoning ability in the knowledge graph, improves the accuracy of fact prediction and link prediction, simplifies the model training process, and improves generalization capabilities.
Smart Images

Figure CN118734968A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of artificial intelligence and relates to a knowledge reasoning method based on deep transfer reinforcement learning. Background Art
[0002] Knowledge graph reasoning can be roughly divided into embedding-based, neural network-based and path-based methods. The premise of all three methods is to embed entities and relationships into vector space. The application of deep reinforcement learning and transfer learning in the field of knowledge graphs provides a solution to the problem that intelligent agents choose a large number of invalid actions in the early stage of reasoning. Common methods and applications mainly include embedding-based knowledge graph reasoning methods, tensor decomposition-based knowledge reasoning models, reinforcement learning-based knowledge graph reasoning models, random walk-based knowledge graph reasoning models, and reinforcement learning-based transfer learning applications.
[0003] (1) Knowledge graph reasoning method based on embedding
[0004] Among the embedding-based knowledge graph reasoning methods, the TransE model proposed by Bordes et al. (reference: Bordes et al., 2013, NIPS) is a classic model in this category. This model represents entities and relations as vectors in the same low-dimensional space, and the relations between entities are interpreted as the translation distance of embeddings in the low-dimensional space. The embedding vector of the head entity needs to be close to the embedding vector of the tail entity after the transfer of the relations. Compared with traditional knowledge reasoning methods, TransE modeling is simple and efficient, and it handles asymmetric relations and one-to-one semantic relations well, which quickly aroused the enthusiasm of related research. However, this model has some shortcomings that need to be optimized, and many variant models of TransE have been proposed. For example, TransD (reference: Ji et al., 2015, AAAI), TransR (reference: Lin et al., 2015, AAAI), TransH (reference: Wang et al., 2014, AAAI), etc. These models have shown good results in knowledge graph reasoning and completion tasks, but most of these translation distance-based models are shallow representation learning models and are not yet capable of knowledge graph multi-hop reasoning tasks.
[0005] (2) Knowledge Reasoning Model Based on Tensor Decomposition
[0006] The knowledge reasoning model based on tensor decomposition first models the knowledge graph as a tensor, and then learns the latent representation of entities and relations through tensor decomposition to measure the rationality of the potential semantics of triples in the graph. The RESCAL model proposed by Nickel et al. associates each entity with a vector to capture its latent semantics (reference: Nickel et al., 2011, ICML). The DisMult model proposed by Yang et al. alleviates the problem of excessive parameters by constraining the relationship matrix to be a diagonal matrix, thereby greatly improving the learning efficiency (reference: Yang et al., 2015, ICLR). The ComplEx model proposed by Trouillon et al. further extends the DistMult model and models asymmetric and reverse relations by introducing complex-valued embeddings (reference: Trouillon et al., 2016, ICML). The ANALOGY model proposed by Liu et al., based on the RESCAL model, sets the linear mapping of relations to be mutually interchangeable, so as to better model the analogy properties of entities and relations (reference: Liu et al., 2017, AAAI). Compared with the model based on translation distance, the model based on tensor decomposition can use tensor transformation to express the relational transformation of the knowledge graph, and can also make a reasonable geometric representation of the semantics, so it has better interpretability.
[0007] (3) Knowledge graph reasoning model based on reinforcement learning
[0008] Xiong et al. first proposed a reinforcement learning model DeepPath for knowledge graph reasoning in 2017, using reinforcement learning methods to solve the multi-hop reasoning problem in knowledge graphs (reference: Xiong et al., 2017, EMNLP). The model uses reinforcement learning methods to evaluate sampled paths, greatly reducing the search space. In the process of path reasoning, the reinforcement learning environment is modeled as a Markov decision process (MDP), and the multi-hop reasoning problem in knowledge reasoning is transformed into a serialized decision problem. In this problem, each reasoning chain can be represented as a series of decision-making processes. The reinforcement learning agent learns how to find a path to obtain high rewards through interaction and feedback with the environment. It continuously optimizes the strategy during the path exploration process to achieve modeling and knowledge reasoning of multi-hop decision problems in knowledge graphs. In this way, the agent autonomously learns how to choose the next action based on previous decisions and feedback obtained, and updates the strategy based on feedback, gradually mastering how to perform multi-hop reasoning in knowledge graphs. Das et al. proposed a deep reinforcement learning method MINERVA, which guides the agent based on the input query, finds the prediction path, and obtains the correct answer entity based on the given head entity and query relationship (reference: Das et al., 2018, ICLR). Lei et al. proposed a knowledge graph multi-hop reasoning model RuleGuider combined with rules, which improves the interpretability of reasoning (reference: Lei et al., 2020, ACL). Wang et al. proposed AttnPath based on LSTM and graph attention to add memory units to DeepPath, and proposed a forced backoff reasoning mechanism to improve the agent's ability to obtain rewards and the success rate of reasoning (reference: Wang et al., 2019, WWW).
[0009] (4) Knowledge graph reasoning model based on random walk
[0010] The random walk-based method uses the path as a feature to predict the reasoning result. Since the path feature is interpretable, people can understand its meaning more easily. The path ranking algorithm (PRA) proposed by Lao et al. is a classic knowledge reasoning method based on random walk (reference: Lao et al., 2011, EMNLP). PRA first walks to discover the edge type sequence, and uses these edge types as features through the logistic regression model to predict the missing edges in the graph structure. In order to further learn the semantics of the relationship and improve the reasoning performance, Wang et al. proposed a new PRA multi-task learning framework called coupled PRA (CPRA). CPRA uses a multi-task mechanism to perform reasoning and consists of two modules (relation clustering and relationship coupling). The former is used to automatically discover highly related relationships, and the latter is used to couple these relationships for learning (reference: Wang et al., 2016, AAAI). Knowledge reasoning methods based on random walks can obtain specific reasoning paths for prediction results and improve the interpretability of the results. However, the path selection process of most of these methods is heuristic traversal, and aimless random walks are inefficient in mining valuable reasoning paths and may even introduce incorrect reasoning rules. At the same time, when the knowledge graph is sparse and poorly connected, the extraction of path features is inefficient and time-consuming.
[0011] (5) Transfer learning applications based on reinforcement learning
[0012] Transfer learning refers to applying existing knowledge or models to new tasks or environments. Through transfer learning, part of the model's knowledge can be applied to new tasks or environments without retraining the entire model, and the performance of the model can be improved. In 2018, Yaser et al. applied transfer learning to text summarization scenarios and proposed a reinforcement learning framework based on the self-critical policy gradient method. After pre-training, only a few fine-tuning samples can achieve optimal performance (reference: Yaser et al., 2018, ACL). In 2019, Ammanabrolu et al. applied transfer learning to text adventure games based on knowledge graphs. In many computer-generated and artificially created games, not only can reinforcement learning strategies be learned faster, but also the quality of agent strategies can be improved (reference: Ammanabrolu et al., 2019, AAAI). In 2019, Liu et al. applied transfer learning to multi-agent reinforcement learning and proposed a scalable transfer learning method based on the new MDP similarity concept, which significantly accelerated multi-agent reinforcement learning and had better performance (reference: Liu et al., 2019, ICML).
[0013] From the above research work, it can be found that transfer learning is suitable for scenarios where pre-task samples are abundant but target task samples are scarce. In the knowledge graph scenario, although it is difficult for the agent to obtain successful samples on the target task, each triple (h, r, t) in the knowledge graph contains two successful single-step walk samples (h, r) and (t, r-1), and the source task samples are abundant and easy to obtain. Therefore, in order to effectively solve the problem of the agent selecting a large number of invalid actions in the early stage of reasoning, the present invention takes single-step walk as a pre-task and multi-step reasoning as a target task, and proposes a knowledge reasoning method DTRL-path based on deep transfer reinforcement learning. Summary of the invention
[0014] Purpose of the invention: The technical problem to be solved by the present invention is to provide a knowledge reasoning method based on deep transfer reinforcement learning (DTRL-path) in view of the shortcomings of the prior art. The method allows the agent to search for the target in a single step in the pre-task for training, and then migrates the agent to the target reasoning task for fine-tuning, and applies it to the path search of the knowledge graph, and performs fact prediction and link prediction based on the path, which can effectively improve the path search success rate of the agent in the early stage of reasoning. The present invention includes the following steps:
[0015] Step 1: Reinforcement learning environment modeling, including: constructing a knowledge graph reinforcement learning environment, and completing reinforcement learning environment modeling based on state space, action space, training reward setting and strategy neural network;
[0016] Step 2, pre-task training, including: driving the reinforcement learning agent to perform effectiveness pre-training, based on the pre-processing of the training set (generally using FB15K-237, NELL-995), the reward function of the pre-task and the pre-training algorithm, to help the agent learn to choose effective actions and improve the success rate of single-step walking;
[0017] Step 3: Fine-tune the target task, including: migrating the agent to the reasoning task, fine-tuning the target task based on the reasoning task, reward function, and fine-tuning training algorithm. The agent learns how to choose effective actions in the pre-training stage, and after fine-tuning training, it migrates to the specific reasoning task. In the knowledge graph environment, the agent will continue to learn how to complete the reasoning task;
[0018] Step 4, constructing a model algorithm evaluation standard, including: constructing a deep reinforcement learning knowledge reasoning model algorithm evaluation standard, based on the path finding success rate (PFSR) and the mean average precision (MAP), to evaluate the knowledge reasoning performance based on deep reinforcement learning;
[0019] Step 5, verification experiment and result analysis, including: constructing algorithm effectiveness verification experiments, collecting experimental data and conducting result verification analysis based on data set selection and analysis, path search experiments, fact prediction experiments, link prediction experiments, and transfer learning ablation experiments.
[0020] Step 1 includes:
[0021] Step 1-1, through the state space, the semantics of the knowledge graph entity set is represented in the state space;
[0022] The state space representation adopts the embedding representation model TransE, in which the entity is represented as a continuous embedding vector:
[0023] s t =Trans(e t ) (1)
[0024] where e t is the specific entity where the agent is located at the current time step t, s t is the state representation vector of the current entity, and Trans() is the embedding representation function;
[0025] Step 1-2: Take the relationship set R in the knowledge graph as the action space of the agent. The process of the agent (the subject that performs actions and interacts with the environment in the reinforcement learning environment) selecting actions through the action space is the transition from the current state to the next state. The action space is defined as:
[0026]
[0027] in Represents the relationship |R| The inverse relation of , A represents the action space, |R| represents the number of relations in the relation set R;
[0028] Steps 1-3, the training reward setting, is set in the training of a self-driving car model, and the reward setting may be as follows: positive reward (safe driving to the destination: +1000; compliance with traffic rules (such as traffic lights, speed limits, etc.): +10 each time; successful avoidance of obstacles: +5 each time), negative reward (collision: -1000; speeding: -20 each time; running a red light: -50 each time), intermediate reward (every meter driven without violation: +1), the positive and negative rewards should be balanced to avoid the model being biased towards one side, and the reward should be able to immediately reflect the pros and cons of the behavior to help the model learn quickly. As the training progresses, the reward mechanism can gradually become more stringent to improve model performance.
[0029] Introduce a reward mechanism to enable the environment to evaluate the agent's reward for task completion or failure, and update the agent's strategy based on the positive or negative feedback of the reward to maximize the reward;
[0030] Steps 1-4, the strategy neural network is used to convert the input e through a fully connected network t , mapped to the probability vector strategy neural network of each action; the strategy neural network includes two hidden layers and an output layer, the output layer is normalized using the softmax function, for s t , the policy neural network will output the corresponding probability distribution:
[0031] d(s t )=softmax(f(f(s t ×w1+b1)×w2+b2)) (3)
[0032] Where f is the activation function, w1 and w2 are the weights of the first hidden layer and the second hidden layer, b1 and b2 are the bias of the first hidden layer and the second hidden layer, respectively; d(s t ) is a |A|×1 matrix, each bit represents the probability of selecting an action;
[0033] The policy gradient descent algorithm is used to update the parameters of the policy neural network:
[0034]
[0035] Where θ is the parameter to be updated, logπ(a=a t |s t ; θ) is in state s t When the policy neural network selects action a t The probability of executing this action a t The reward obtained, t is the time step, T is the total number of time steps, Represents the gradient of J(θ) with respect to the parameter θ (specifically, it means that the parameter θ of the policy neural network needs to be updated according to the gradient information to optimize the policy network so that the agent can obtain higher cumulative rewards in the reinforcement learning environment).
[0036] Step 2 includes:
[0037] Step 2-1, training set preprocessing: In the knowledge graph state space, obtain all combinations of states and valid actions through the fact triple set V, and convert each triple in V (e h ,r,e t ) is split into two state and action tuples (e h , r) and (e t , r -1), where e h represents the head entity, r represents the association between the head entity and the tail entity, and then merges the same bigrams to obtain the pre-trained effective action training set T valid , training set T valid Used to train a model to predict effective actions in a given state, where the model is a deep reinforcement learning model for knowledge graph reasoning; Step 2-2, determine the reward function of the pre-task:
[0038] When the agent is in e t Action a is selected t If the tuple (e t , a t ) is included in the training set T valid , a positive reward is given to the agent to help it learn to choose effective actions; otherwise, no reward is given, and the reward Y(e t ,a t ) is defined as:
[0039]
[0040] Step 2-3: Build a pre-training algorithm, train the agent offline, and input the pre-training training set T valid , outputs the policy neural network parameters of the reinforcement learning (RL) agent.
[0041] Step 2-3 includes the following steps:
[0042] Step 2-3-1, for each bigram (e t ,a t ), t Set to the tth entity e t The embedding representation Trans(e t ):
[0043] s t ←Trans(e t )
[0044] Step 2-3-2, update the policy neural network parameters, use logarithmic probability and reward to adjust the parameters of the policy neural network:
[0045]
[0046] Where θ is the parameter to be updated, logπ(a=a t ∣s t ; θ) is in state s t When the policy neural network selects action a t The probability of executing this action at Rewards received, Represents the gradient of J(θ) with respect to the parameter θ (specifically, it means that the parameter θ of the policy neural network needs to be updated according to the gradient information to optimize the policy network so that the agent can obtain higher cumulative rewards in the reinforcement learning environment).
[0047] In general, this step mainly describes how to use the preprocessed training set T valid To update the policy neural network parameters of the reinforcement learning agent. Each training sample (e t ,a t ) is used to calculate s t And the corresponding logarithmic probability and reward, and update the parameters of the policy neural network accordingly.
[0048] The target task fine-tuning training described in step 3 specifically includes:
[0049] Step 3-1: The goal of the reasoning task is to find a path connecting two entities: given a fact, including the starting node e start , reasoning task node r task and the target node e target , the agent needs to start searching from the starting node and find all nodes except the reasoning task node r task The paths of all reachable target nodes other than the target node are optimized to improve the agent's performance in the reasoning task by optimizing the target of the reasoning task;
[0050] Step 3-2: Based on the global accuracy dimension, construct a path-end-based reward function r in the RL model GLOBAL :
[0051]
[0052] When the environment finds that the relationship selected by the agent does not exist, it will abandon the current choice and select another action until the number of selections reaches the upper limit of the preset number of steps; when the number of selections reaches the upper limit of the preset number of steps, set r GLOBAL =0.05;
[0053] When the agent successfully reaches the target node or the number of choices reaches the upper limit of the predetermined number of steps, a reward function γ is constructed based on the Monte Carlo method dimension. For each state and relationship binary (e t ,a t ) Rewards:
[0054]
[0055] Where length(p) is the length of the path;
[0056] Based on the path diversity dimension, a reward function r is constructed based on the agent finding paths with similar syntax and semantics. DIVERSITY :
[0057]
[0058] Among them, F is the set of existing paths, P is the newly found path instance, and P t is an existing path instance; cos(P,P t ) represents the newly found path instance P and the existing path instance P t The cosine similarity of
[0059] Step 3-3, build a fine-tuning training algorithm, migrate the agent to the target task, input the target task training set trainSet, and output the policy neural network parameters of the reinforcement learning agent.
[0060] Step 3-3 includes:
[0061] Step 3-3-1, overload pre-training the RL strategy neural network;
[0062] Step 3-3-1, for each triplet (e start , T task , e target ), where e start is the starting entity, T task is the relation of the reasoning task (the relation between the starting entity and the target entity), e target is the target entity, and the following steps are performed:
[0063] Step 3-3-1-1, set the current entity state s t Initialize to Trans(e t );
[0064] Step 3-3-1-2, initialize the step count steps = 0, and mark the task success flag as false;
[0065] Step 3-3-1-3, when the count steps is less than the preset maximum number of steps maxsteps and is unsuccessful, perform the following loop:
[0066] Step 3-3-1-3-1, calculate the action probability vector d(s t )=softmax(f(f(s t ×w1+b1)×w2+b2));
[0067] Step 3-3-1-3-2, according to the vector d(s t ) Randomly select an action at , terminate if an invalid action is selected;
[0068] Step 3-3-1-3-3, record the state and action pairs (e t , a t ) to the set T;
[0069] Step 3-3-1-3-4, perform action a t Jump to the next entity e next ;
[0070] Step 3-3-1-3-5, if e next = =e target , then mark success as true and end the loop;
[0071] Step 3-3-1-3-6, update the current entity status s t For Trans(e t );
[0072] Step 3-3-1-4, calculate each (e t , a t )
[0073] Step 3-3-1-5, update the policy neural network parameters:
[0074]
[0075] The model algorithm evaluation criteria described in step 4 are constructed, specifically including:
[0076] Step 4-1, the path search success rate PFSR is:
[0077]
[0078] Among them, SuccNum is the number of samples that successfully searched for the path in each round epoch, BatchSize is the batch size; the path search success rate PFSR reflects the ability of the agent to explore and identify effective paths;
[0079] Step 4-2, the average precision mean MAP (which represents the average precision of all queries and is used to evaluate the accuracy of the prediction results of the model under given query conditions) is used to evaluate the effects of fact prediction FP (Fact Prediction, FP) and link prediction LP (Link Prediction, LP), and to measure the accuracy of the model in fact prediction and link prediction tasks. Specifically, MAP means taking the average of the average precision of all queries, and the calculation formula is as follows:
[0080]
[0081] Among them, |Q| is the total number of queries, which means how many queries there are in total during the evaluation process; AP(q) is the average precision of the qth query, which is the average precision value calculated for each query q.
[0082] Step 5 includes:
[0083] Step 5-1, data set selection and analysis: select and analyze (referring to using specific methods to process and evaluate the data set in detail, these analysis methods usually include data preprocessing, feature extraction, statistical analysis, etc., in order to provide support for subsequent experiments and model training) two common benchmark data sets in the field of knowledge reasoning, FB15K-237 and NELL-995;
[0084] Step 5-2, the path search experiment is used to evaluate the performance of the DTRLpath model in path search;
[0085] Step 5-3, the fact prediction experiment refers to judging the given triple (e h ,r,e) authenticity, including:
[0086] Step 5-3-1, use e h is the starting node, and the state vector is input into the policy neural network;
[0087] Step 5-3-2, the policy neural network maps the vector of the current state to the probability of selecting each action, and selects an action accordingly;
[0088] Step 5-3-3, the agent performs actions in the knowledge graph environment and moves to the next node;
[0089] Step 5-3-4, if the action chain you have walked through at this time forms a path that has been mined, determine whether the current node is e target , if yes, the score is +1 and the process ends, otherwise the score is -1 and the process ends;
[0090] Step 5-3-5, repeat steps 5-3-2 to 5-3-4. If the maximum number of steps is reached, terminate and record the score as 0;
[0091] Step 5-4, the link prediction experiment is used to predict missing entities: pre-train a neural network classification model based on TransE embedding on the training set, and use the neural network classification model to calculate the similarity scores of candidate tail entities of the head entity and relationship pairs in the test set, and sort the candidate tail entities according to the scores to predict the most likely missing entity;
[0092] Step 5-5, the transfer learning ablation experiment includes:
[0093] Step 5-5-1, delete the pre-task: train the reinforcement learning agent directly on the target task to obtain the onlyTarget model. After training, test the onlyTarget model on the path search task and the single-step walking task;
[0094] Step 5-5-2, delete the fine-tuning training of the target task: GLOBAL ,γ,r DIVERSITY Delete it, and get the onlyPre model after completing the pre-training on the pre-task. Then directly use the onlyPre model for the path search task and the single-step walking task.
[0095] In step 5-5-3, the onlyTarget model, onlyPre model and the original model DTRLpath are used to conduct comparative experiments on path search and fact prediction on the reasoning tasks of the dataset.
[0096] Step 5-2 includes:
[0097] Step 5-2-1, initialization:
[0098] Training set preparation: extract all triplets containing the target task from the data set to form the training set trainSet, and set the maximum number of steps maxSteps;
[0099] Model initialization: Initialize the policy network parameters of the reinforcement learning agent, overload pre-train the policy network, and improve the initial performance;
[0100] Step 5-2-2, path search:
[0101] Traverse the training set: For each triple in trainSet (e start , T task , e target ) to perform the operation;
[0102] State initialization: Initialize the current entity state st to Trans(e start ), initialize the step count steps = 0, and mark success as false;
[0103] Execute path search: loop within the maximum number of steps maxSteps until the path is successfully found or the maximum number of steps is reached;
[0104] Reward calculation and strategy update: Calculate each (e t ,a t ) and update the policy network parameters;
[0105] Step 5-2-3, evaluation of experimental results.
[0106] Calculate the number of samples SuccessNum that successfully searched the path in each epoch, and calculate the path search success rate PFSR;
[0107] Experimental record and analysis: record the PFSR value of each epoch, draw a curve of PFSR changing with training rounds, analyze the path search success rate of different models on different data sets, and compare the performance of DTRLpath with other methods.
[0108] In step 5-5-1, the specific method for completing the path search task is the same as step 5-2;
[0109] The specific methods for completing the single-step walk task (the single-step walk task is to evaluate the effectiveness of the agent in performing a step action from a node in the knowledge graph. In the pre-training stage, the agent learns to select effective single-step actions to improve the success rate of single-step walks.) include:
[0110] Initialization: Extract the triples containing the target task from the training set trainSet (e start , T task , e target ), and then initialize the state of the reinforcement learning agent to the head entity e start Embedding representation of ;
[0111] Single-step action selection: Use the policy network to calculate the action probability vector d(s t ), select an action a according to the action probability vector t And perform the action a t Then check whether the selected action is valid, that is, whether the agent is successfully moved to a new entity;
[0112] Evaluation: Record the success rate of single-step actions and evaluate the agent’s performance in the single-step walking task.
[0113] The present invention also provides a method for predicting the use of new drugs based on deep transfer reinforcement learning, which is implemented based on the knowledge reasoning method based on deep transfer reinforcement learning, including: setting a need to infer the relationship between the new drug and its potential therapeutic disease in a knowledge graph containing drug, disease, gene and symptom entities;
[0114] Dataset construction: Use a knowledge graph dataset containing drug, disease, gene, and symptom entities, with new drugs as an entity and potential therapeutic diseases as target disease entities;
[0115] Reinforcement learning environment modeling: Construct a knowledge graph reinforcement learning environment, define the state space, action space, training reward settings, and policy neural network; the state space is represented by all entities in the knowledge graph, and the action space is the relationship between entities and their inverse relationship;
[0116] Pre-mission training:
[0117] Training set preprocessing: extract the relationship between drugs and genes, genes and diseases from the knowledge graph to generate effective action training sets;
[0118] Pre-task reward function: defines the reward for the agent to select valid actions in the training set;
[0119] Pre-training algorithm: offline training of the agent so that it can learn to choose effective actions in single-step search and improve the success rate of preliminary path search;
[0120] Target task fine-tuning training:
[0121] Reasoning task setting: The agent needs to start from the new drug in the knowledge graph and find the path to the target disease entity through genes and symptoms;
[0122] Reward function: Set a global accuracy reward function based on the end of the path and a reward function based on path diversity;
[0123] Fine-tune the training algorithm: transfer the agent to the target task, perform multi-step path exploration and strategy optimization;
[0124] Experiment and result analysis:
[0125] Path search experiment: evaluate the success rate of the agent in finding the path from the new drug to the target disease entity in the knowledge graph;
[0126] Fact prediction experiment: In the test set, the accuracy of the agent in predicting the relationship between new drugs and diseases is verified through path scoring;
[0127] Link prediction experiments: predict missing entities in the knowledge graph, and given new drug and gene relationships, predict potential related diseases.
[0128] Beneficial effects:
[0129] (1) The present invention effectively solves the problem of a sharp drop in the success rate of path mining due to invalid actions selected by reinforcement learning agents in the early stage of knowledge graph reasoning through the method of deep transfer reinforcement learning. It significantly improves the agent's path search success rate in complex knowledge graph environments and provides strong technical support for efficient knowledge graph reasoning.
[0130] (2) The DTRL-path method of the present invention not only optimizes the single-step decision-making ability of the intelligent agent, but also significantly improves the multi-step reasoning ability through target task fine-tuning training, enabling the intelligent agent to perform more complex reasoning tasks in the knowledge graph, further improving the accuracy of fact prediction and link prediction, and providing an effective technical approach to solving knowledge graph reasoning problems in practical applications.
[0131] (3) By introducing pre-task training and target task fine-tuning training, the method of the present invention can effectively utilize transfer learning to optimize model performance while maintaining model flexibility, shorten model training time, and improve the generalization ability of the model, so that it can adapt to knowledge graphs of different scales and structures.
[0132] (4) The model algorithm evaluation standard construction and verification experimental design proposed in this invention provide a scientific and systematic methodology for evaluating the knowledge reasoning performance based on deep reinforcement learning, enabling researchers to accurately quantify model performance and guide subsequent model optimization and algorithm improvement.
[0133] (5) Verification experiments based on the FB15K-237 and NELL-995 datasets show that the performance of the present invention in major reasoning tasks is better than that of similar methods, confirming that the present method is effective in improving the ability of intelligent agents in knowledge graph path search, fact prediction, and link prediction, and has important theoretical and practical significance for promoting the development of knowledge graph reasoning technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0134] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and the above and / or other advantages of the present invention will become more clear.
[0135] Figure 1 It is a schematic diagram of the overall process of the present invention.
[0136] Figure 2 This is a schematic diagram of the average success rate results of NELL-995 path search.
[0137] Figure 3 It is a schematic diagram of the average success rate of path search in the DTRLpath ablation experiment. DETAILED DESCRIPTION
[0138] The present invention relates to a knowledge graph reasoning method DTRL-path based on deep transfer reinforcement learning, which aims to improve the accuracy and efficiency of path search, fact prediction and link prediction of intelligent agents in complex knowledge graph environments. This technical solution can be widely used in the fields of intelligent search, data mining, semantic analysis, etc., and the relevant technical features can be applied to intelligent application scenarios based on knowledge graphs. The specific steps are as follows:
[0139] Step 1, reinforcement learning environment modeling, including:
[0140] Step 1-1, the state space representation can realize the state space representation of the semantics of the knowledge graph entity set;
[0141] The state space representation uses the embedding representation model TransE to represent the semantics of the entity set E in the knowledge graph. In the TransE model, entities are represented as continuous embedding vectors. This embedding representation model can capture their semantic associations by learning the relationships between entities. By representing entities as embedding vectors, entities in the knowledge graph can be better processed and used as part of the state space of the agent:
[0142] s t =Trans(e t ) (1)
[0143] where e t is the current entity, s t A vector representing the state of the current entity.
[0144] Step 1-2, the action space represents that the process of the agent selecting an action is the transition from the current state to the next state. The relationship set R in the knowledge graph is used as the action space of the agent.
[0145] However, in order to enable the agent to reverse reasoning, it is necessary to allow the agent to consider the inverse relationship of the relationship. The so-called inverse relationship means that if there is a relationship in the knowledge graph (for example, A and B have a relationship R), then there is also its inverse relationship (for example, B and A have an inverse relationship R-1). The addition of inverse relationships can help the agent consider different possibilities more comprehensively during the reasoning process. Therefore, in the action space, in addition to the original relationship set R, the inverse relationships of all relationships need to be added to the action space. In this way, the agent can consider the reverse reasoning path when choosing the next action, thereby searching the solution space more comprehensively and improving the agent's reasoning ability in the knowledge graph. The action space is defined as:
[0146]
[0147] where r x -1 Represents the relationship x The inverse relationship.
[0148] Steps 1-3, the training reward setting, can enable the environment to evaluate the agent's reward for task completion or failure, and update the agent's strategy based on the positive or negative feedback of the reward to maximize the reward;
[0149] In the training reward setting, the environment evaluates the agent's reward for completing or failing a task, and updates the agent's strategy based on the positive or negative feedback of the reward to maximize the reward. The tasks corresponding to the pre-training and fine-tuning training stages are different, so the applicable reward methods are also different.
[0150] Steps 1-4, the strategy neural network construction and parameter optimization can realize the strategy neural network through the fully connected network (FCN) to represent the input state e t Mapped to the probability vector of selecting each action;
[0151] The strategy neural network is constructed and its parameters are optimized. The strategy neural network represents the input state through a fully connected network (FCN). t Mapped to the probability vector of selecting each action. The neural network consists of two hidden layers and an output layer, and the output layer is normalized using the softmax function. t , the policy neural network will output the corresponding probability distribution:
[0152] d(s t )=softmax(f(f(s1×w1+b1)×w2+b2)) (3)
[0153] Where f is the activation function, w x and b x are the weights and biases of the hidden layer. t ) is a |A|×1 matrix, where each bit represents the probability of selecting an action.
[0154] The model uses the policy gradient descent algorithm to update the parameters of the policy neural network:
[0155]
[0156] Where θ is the parameter to be updated, logπ(a=a t |s t ; θ) is in state s t When the policy neural network selects action a t γ is the reward for executing this action.
[0157] In step 2, pre-task training, including:
[0158] Step 2-1, the training set preprocessing can realize using the training set to train the model to predict the effective action under a given state;
[0159] The training set preprocessing, in the knowledge graph state space, can obtain all combinations of states and valid actions through the fact triple set V. Each triple in V (eh ,r,e t ) is split into two state-action pairs (e h , r) and (e t , r -1 ), and then merge the same two-tuples to obtain the pre-trained effective action training set T valid , this training set can be used to train a model to predict valid actions for a given state.
[0160] Step 2-2, determine the reward function of the pre-task:
[0161] The goal of the pre-training task is to learn to select effective actions. t Action a is selected t When the binary group (e t ,a t ) is included in T valid If , the agent is given a positive reward; otherwise, no reward. The reward is defined as follows:
[0162]
[0163] Build a positive reward mechanism to help the agent learn to choose effective actions;
[0164] Step 2-3, the pre-training algorithm selection includes: constructing a pre-training algorithm and training the agent offline;
[0165] Since the knowledge graph already contains all combinations of states and valid actions, the agent does not need to interact with the environment to obtain rewards. valid As a training set, train the agent offline.
[0166] Step 3: Target task fine-tuning training
[0167] Step 3-1, the reasoning task analysis can realize finding a path connecting two entities;
[0168] The reasoning task analysis, the goal of the reasoning task is to find the path connecting two entities, which is more complex than the pre-trained single-step task. Given a fact, including the starting node (e start ), reasoning task node (r task ) and the target node (e target ), the agent needs to start searching from the starting node and find task By optimizing this goal, the agent can improve its performance in reasoning tasks.
[0169] Step 3-2, the reward function is determined, and the reward function can be constructed based on three dimensions: global accuracy, Monte Carlo method, and path diversity to optimize the performance of the intelligent agent;
[0170] The global accuracy dimension constructs a reward function based on the path ending;
[0171] The Monte Carlo method dimension constructs a reward function based on when the agent successfully reaches the target node or reaches a predetermined upper limit of the number of steps;
[0172] The path diversity dimension constructs a reward function based on the agent finding paths with similar syntax and semantics;
[0173] The reward function determines that in order to optimize the performance of the agent, three reward functions are designed for fine-tuning training of the target task:
[0174] (1) Global accuracy: For the environment setting, the number of actions that the agent can take can be very large. That is, there are many more wrong sequential decisions than correct ones, and the number of wrong decision sequences grows exponentially with the length of the path. The first reward function added to the RL model is defined as follows:
[0175]
[0176] There are three situations when the path ends. The first is when the agent reaches the target entity, and the reward +1 is given by the outside world instead of the environment. The reward for the sample storage used to train the agent is the reward 0 given by the environment. In the second case, when the environment finds that the relationship selected by the agent does not exist, the environment will return -1. In this process, the non-existence of the relationship selected by the agent does not mean that the search is over. The current choice will be abandoned and the action will be selected again until the number of choices reaches the preset step limit. The third case is that the agent's search reaches the preset step limit. At this time, the reward returned by the environment is still 0, but the outside world will set r GLOBAL =0.05;
[0177] (2) Timely reward: Considering that fine-tuning training is a multi-step task, the environment cannot immediately respond to each action of the agent with instant rewards. The Monte Carlo method is used to complete it. When the agent successfully reaches the target node or the number of choices reaches the upper limit of the predetermined number of steps, for each state-relation tuple (e t ,a t ) to give rewards. The rewards are set as:
[0178]
[0179] Where length(p) is the length of the path. For relational reasoning tasks, short paths often provide more reliable reasoning evidence than long paths. Shorter relation chains can also improve the efficiency of reasoning by limiting the length of interaction between RL and the environment.
[0180] (3) Path diversity: When searching for paths in each relationship, the agent is trained using positive samples. Considering that these training samples have similar state representations in the vector space, the agent tends to find paths with similar syntax and semantics. Since some of these paths may be related, these paths usually contain redundant information.
[0181] To encourage the agent to find different paths, a diversity reward function is defined using the cosine similarity between the current path and the existing paths:
[0182]
[0183] Among them, F is the set of existing paths, P is the newly found path instance, and P t Is an existing path instance.
[0184] Step 3-3, the fine-tuning training algorithm selection can construct a fine-tuning training algorithm to migrate the agent to the target task;
[0185] The fine-tuning training algorithm is selected. After completing the pre-training, the agent needs to migrate to the target task. Each target task represents a relationship in the knowledge graph. The agent learns to search for paths that can connect the target relationship through fine-tuning training. In order to perform fine-tuning training, all triples containing the target task are extracted from the data set to form the training set trainset of the target task. The following is the fine-tuning training algorithm for the target task:
[0186] Algorithm 2: Selection of fine-tuning training algorithm for target task;
[0187] Step 4: Model algorithm evaluation standard construction
[0188] Step 4-1, the path finding success rate (PFSR) can measure the effectiveness of the reinforcement learning agent in the path finding task;
[0189] The path search success rate (PFSR) is an indicator that measures the effectiveness of reinforcement learning agents in path finding tasks. It specifically evaluates the ratio of the number of instances in which the agent successfully finds a path to the target node from the starting node to the total number of instances in each iteration of training. This indicator reflects the ability of the agent to explore and identify valid paths.
[0190]
[0191] Among them, SuccNum is the number of samples that successfully searched the path in each epoch, and BatchSize is the batch size. The larger the PFSR, the stronger the path search ability of the reinforcement learning agent.
[0192] Step 4-2, the Mean Average Precision (MAP) can be used to evaluate the effects of Fact Prediction (FP) and Link Prediction (LP);
[0193] The average precision, mean average precision (MAP), is a key indicator for evaluating the effectiveness of fact prediction (FP) and link prediction (LP). In fact prediction, MAP measures the accuracy of a given triple (e h ,r,e t ), the accuracy of predicting whether the triple is correct. For link prediction, this metric evaluates the triple (e h ,r,e t ) case, the ability to correctly predict the tail entity.
[0194] During the evaluation process, the ratio of positive and negative samples used for testing in each dataset is approximately 1:10. Negative samples are generated by replacing the tail entity of positive samples, which can comprehensively evaluate the predictive ability of the model in different situations.
[0195] Step 5: Verification experiment and result analysis
[0196] Step 5-1, the data set selection and analysis, selects and analyzes two common benchmark data sets FB15K-237 and NELL-995 in the field of knowledge reasoning;
[0197] The data set selection and analysis, when conducting experimental performance analysis, two common benchmark data sets in the field of knowledge reasoning were selected, namely FB15K-237 and NELL-995. These data sets are widely used in knowledge reasoning research and can provide rich information about knowledge graphs. By using these two data sets for experiments, different reasoning models are compared and evaluated. Among them, FB15K-237 contains 14.5k entities, 237 relations, 310.1k triple facts and 20 reasoning tasks, which is obtained by deleting redundant triples in FB15K. NELL-995 contains 7.5k entities, 200 relations, 154.2k triple facts and 12 reasoning tasks. Taking FB15K-237 as an example, it is split into three subsets of train, valid and test for training and verification. The statistical data are shown in Table 1 below.
[0198] Table 1
[0199] property train verify test headings 13781 7652 8171 triad 272115 17535 20466 relationship 237 223 224 averTriple 19.75 2.29 2.50 averRelationship 6.78 1.58 1.68 averEntity 2.91 1.45 1.49
[0200] When training the model here, the last layer of the policy neural network uses the softmax function as the activation function, and the two fully connected hidden layers use ReLu as the activation function. The number of nodes is set to 1024 and 2048 respectively. Adam is selected as the training optimization algorithm, and the initial learning rate is set to 0.001. Here, the TransE model is trained according to the method in Fast-TransX1, and the embedding dimension is set to 100 dimensions; the pre-training batchsize on the source task is set to 1000, and the training is 2000 epochs; the fine-tuning training batchsize on the target task is set to 500, and the training is 500 epochs.
[0201] The proposed DTRLpath model is implemented based on the TensorFlow framework and trained on an NVIDIA1080 GPU.
[0202] Step 5-2, the path search experiment can evaluate the performance of the DTRLpath model in path search;
[0203] The path search experiment, in order to evaluate the performance of the DTRLpath model in path search, compared it with other similar methods, such as DeepPath and AttnPath. The basis of the comparison is the path search success rate (PFSR), which is an important indicator to measure the model's ability to find a valid path from the start node to the target node.
[0204] After pre-training for the preset task, the agent was further trained for the target task for 500 training cycles (epochs). The results of this training phase are crucial to understanding and analyzing the performance of the DTRLpath model in the path search task. The training results are shown in Table 2 (values are percentages):
[0205] Table 2
[0206] Model Name FB15K-237 NELL-995 DeepPathNoPre 7.3 27.8 DeepPath 17.7 37.8 AttnPathForce 30.4 48.1 DTRLpath 18.2 30.3 AttnPath 66.1 62.8
[0207] Among them, DeepPathNoPre means that there is no pre-trained model in the DeepPath method, and AttnPathForce means that the AttnPath method contains a version of forced walking. According to the experimental results in Table 2, in the absence of a forced walking mechanism, the DTRLpath method significantly surpasses these two methods in terms of path search success rate. In particular, on the FB15K-237 dataset, the success rate of the DTRLpath method reached 66.1%, which is significantly higher than other methods. This significant performance improvement is mainly due to the pre-training of the agent in the pre-task stage, which enables it to select actions more effectively when walking in a single step, thereby greatly improving the single-step success rate in the path search task.
[0208] We selected 12 inference tasks from NELL-995 and plotted the average success rate of path search during fine-tuning training on these tasks. Figure 2 shown.
[0209] according to Figure 2 The results show that the path search success rate of DTRLpath on the 12 reasoning tasks of the NELL-995 dataset is good, which depends on the pre-training on the pre-task. And due to the pre-training on the pre-task, the proposed method can quickly achieve a high success rate in the first 0-100 training cycles (epochs). Transfer learning not only improves the success rate of path search, but also makes the initial stage of training start faster.
[0210] Step 5-3, the fact prediction experiment can judge the given triple (e h ,r,e) authenticity;
[0211] The fact prediction experiment aims to determine the given triple (e h ,r,e). The model evaluates whether the triple is a true fact by scoring. The traditional deep reinforcement learning-based method continues the evaluation method in PRA, that is, using the mined path as the scoring basis, and the number of paths that meet the triple is used as the score. The higher the score, the more likely the triple is to be a positive sample.
[0212] Use reinforcement learning agents to directly h ,r,e t ) Scoring, the scoring steps are as follows:
[0213] (1) e h is the starting node, and the state vector is input into the policy neural network;
[0214] (2) The policy neural network maps the vector of the current state to the probability of selecting each action and selects an action accordingly;
[0215] (3) The reinforcement learning agent performs actions in the knowledge graph environment and moves to the next node;
[0216] (4) If the action chain at this time forms a path that has been mined, determine whether the current node is e t , if yes, the score is +1 and the process ends, otherwise the score is -1 and the process ends;
[0217] (5) Repeat steps (2) to (4). If the maximum number of steps is reached, terminate the process and record the score as 0.
[0218] The effectiveness of DTRLpath comes from pre-training on pre-tasks, which greatly improves the path search success rate of the agent in fact prediction. During testing, the retrained agent is used to find the corresponding feature path. Although it is a test, there is still a parameter update, which uses the path diversity reward function formula (8), so the experiment compares the path search success rate of the DTRLpath model in multiple tests. The experimental results of fact prediction are shown in Table 3, where the number after DTRLpath indicates the number of tests.
[0219] Table 3
[0220] Model Name FB15K-237 NELL-995 TransE 0.277 0.383 TransD 0.303 0.413 TransR 0.302 0.406 TransH 0.309 0.389 DeepPath 0.339 0.494 AttnPath 0.315 0.598 AttnPathForce 0.379 0.693 DTRLpath-1 0.341 0.632 DTRLpath-200 0.412 0.724 DTRLpath-500 0.426 0.774
[0221] According to the experimental results in Table 3, it can be concluded that the proposed method achieves the best fact prediction performance on both datasets. When the number of tests is 500, the result of the method on the FB15K-237 dataset is about 0.426 and on the NELL-995 dataset is about 0.774, which exceeds the DeepPath method and the AttnPath method.
[0222] Step 5-4, the link prediction experiment can predict the missing entities;
[0223] In the link prediction experiment, link prediction aims to predict missing entities. Specifically, given a test sample (eh, r, ex), the goal is to predict the missing tail entity ex. The model ranks the candidate tail entities by scoring them. In the link prediction experiment, negative samples were generated and the data set was divided into a training set and a test set. The test method in DeepPath is used here, and whether each path of the sample is adapted is used as a binary feature. First, a classification model is pre-trained on the training set, and the model is used to score the tail entities in the test set. Then the candidate tail entities are ranked according to the scores to obtain the most likely missing entity prediction. As shown in Table 4 (Link Prediction MAP (Average Precision)).
[0224] Table 4
[0225] Model Name FB15K-237 FB15K-237 TransE 0.532 0.532 TransD 0.505 0.505 TransR 0.540 0.540 TransH 0.566 0.566 DeepPath 0.635 0.635 AttnPath 0.661 0.661 DTRLpath-1 0.655 0.655 DTRLpath-200 0.669 0.669 DTRLpath-500 0.687 0.687
[0226] As shown in Table 4, DTRLpath achieved optimal performance in the link prediction experiment on the FB15K-237 dataset. At the same time, good results were also achieved on the NELL-995 dataset. It is worth noting that on the FB15K-237 dataset, the method here has a more obvious performance improvement compared to the performance on the NELL-995 dataset. This result can be explained by multiple factors. First, the average path length in the FB15K-237 dataset is larger than that in the NELL-995 dataset, and the reward sparsity caused by invalid actions is also more serious. The method here has certain advantages in alleviating the problem of invalid actions, so the effect improvement on the FB15K-237 dataset is more obvious.
[0227] Secondly, the method here is improved on the basis of DeepPath, and the training and testing process is similar to the DeepPath method. This shows that although there is still room for optimization for certain specific data sets, the method proposed here has shown obvious advantages in enhancing path search capabilities, especially when dealing with complex knowledge graph reasoning tasks.
[0228] Step 5-5, the transfer learning ablation experiment can further study the impact of pre-task pre-training and target task fine-tuning training on knowledge reasoning in transfer learning;
[0229] In order to further study the impact of pre-task pre-training and target task fine-tuning training on knowledge reasoning in transfer learning, the following ablation experiment was conducted on the proposed DTRLpath method:
[0230] (1) Delete the pre-task: Train the reinforcement learning agent directly on the target task to obtain the model onlyTarget. After training, test this model on the path search task and the single-step walking task.
[0231] (2) Deleting fine-tuning training for the target task: In order to study the impact of fine-tuning training for the target task, we delete the fine-tuning learning and improved reward function on the target task, obtain the model onlyPre after completing pre-training on the pre-task, and directly use the model for the path search task and single-step walking task.
[0232] The two generated incomplete models and the original DTRLpath model were subjected to comparative experiments on path search and fact prediction on 12 reasoning tasks of the NELL-995 dataset. The results of the ablation experiments are shown in Table 5 (Ablation Experiment Results of DTRLpath (MAP)), where the number of tests of the three models on the fact prediction task is uniformly set to 1.
[0233] Table 5
[0234]
[0235] According to Table 5 and Figure 3 The results show that the onlyPre model performs poorly in the fact prediction experiment, and performs better than DTRLpath in the path search experiment at the beginning, but the path search success rate stabilizes and does not improve in subsequent training. This is mainly because the onlyPre model is only trained through a single-step pre-task, while the path search and fact prediction tasks need to be based on multi-step reasoning tasks. Therefore, the onlyPre model has a high path search success rate at the beginning, but can only learn to select effective tasks, and cannot perform efficient multi-step reasoning. On the other hand, although the onlyTarget model is trained on the target task, the lack of pre-task training leads to insufficient ability of the model to select effective actions, resulting in a low path search success rate. The path search success rate of the complete DTRLpath model starts higher and improves faster than the onlyTarget model trained with only the target task. It can basically achieve optimal performance in the first 100 epochs, and its performance is still significantly better than the onlyTarget model after sufficient training. Therefore, pre-tasks not only significantly accelerate the reinforcement learning of the agent, but also make the model have better performance. Therefore, the experimental results show that pre-training of pre-tasks has a significant effect on improving the ability to complete the target task, and only conducting a single target task training cannot fully improve the model performance.
[0236] Example:
[0237] Taking the FB15K-237 knowledge graph dataset as an example, it contains a large number of entities and relationships, which is suitable as a dataset for verifying the application of deep transfer reinforcement learning in the field of knowledge graph reasoning. This embodiment first constructs a reinforcement learning environment based on the dataset, and then designs pre-tasks to train the agent to learn how to make effective decisions in single-step search. Afterwards, by migrating the agent to complex reasoning tasks and performing fine-tuning training, the multi-step path search capability of the agent in the knowledge graph is effectively improved. Finally, through the constructed evaluation criteria and the verification experiments conducted, the effectiveness and superiority of the method of the present invention in improving the success rate of path search and prediction accuracy are demonstrated.
[0238] Specific application scenarios:
[0239] In this embodiment, the method of the present invention is applied to the knowledge graph reasoning of drug development in the medical field to provide a method for predicting the use of new drugs. It is assumed that the relationship between a new drug (NewDrug) and its potential therapeutic disease (TargetDisease) needs to be inferred in a knowledge graph containing entities such as drugs, diseases, genes, and symptoms.
[0240] Dataset construction: We use a knowledge graph dataset containing entities such as drugs, diseases, genes, and symptoms, similar to the data structure of FB15K-237, but focusing on the biomedical field. In this example, NewDrug is used as a new drug entity and TargetDisease is used as a target disease entity.
[0241] Reinforcement learning environment modeling: Construct a knowledge graph reinforcement learning environment, define the state space, action space, training reward settings, and policy neural network. The state space is represented by all entities in the knowledge graph, and the action space is the relationship between entities and their inverse relationship.
[0242] Pre-mission training:
[0243] (1) Training set preprocessing: Extract the relationships between drugs and genes, genes and diseases, etc. from the knowledge graph to generate effective action training sets.
[0244] (2) Pre-task reward function: defines the reward for the agent to select effective actions in the training set. For example, a positive reward is given when the agent successfully selects the relevant gene from NewDrug.
[0245] (3) Pre-training algorithm: Offline training of the intelligent agent enables it to learn to choose effective actions in a single-step search, thereby improving the success rate of the initial path search.
[0246] Target task fine-tuning training:
[0247] (1) Reasoning task setting: The agent needs to start from NewDrug in the knowledge graph and find the path to TargetDisease through intermediate entities such as genes and symptoms.
[0248] (2) Reward function: Set a global accuracy reward function based on the end of the path, a reward function based on the diversity of the path, etc.
[0249] (3) Fine-tune the training algorithm: transfer the agent to the target task and perform multi-step path exploration and strategy optimization.
[0250] Experiment and result analysis:
[0251] (1) Path search experiment: evaluate the success rate of the agent in finding the path from NewDrug to TargetDisease in the knowledge graph. In the pre-training stage, the path search success rate increased from the initial 10% to 50%; after fine-tuning training, the success rate was further increased to 80%.
[0252] (2) Fact prediction experiment: In the test set, the accuracy of the agent in predicting the relationship between new drugs and diseases was verified by path scoring, and the mean average precision (MAP) was improved from 0.65 to 0.85.
[0253] (3) Link prediction experiment: predict missing entities in the knowledge graph. For example, given the relationship between NewDrug and gene, predict potential related diseases. The experimental results show that the prediction accuracy of the intelligent agent reaches 90%.
[0254] Results and Applications:
[0255] Through the method of the present invention, an effective knowledge graph reasoning model was successfully constructed, which can accurately predict the potential relationship between new drugs and target diseases. This result not only significantly improves the accuracy of path search and prediction, but also helps biomedical researchers to discover new uses of drugs more quickly in practical applications, and promote the process of drug development, thus solving the specific problem of knowledge reasoning in the biomedical field.
[0256] The present invention provides a knowledge reasoning method based on deep transfer reinforcement learning. There are many methods and ways to implement the technical solution. The above is only a preferred implementation of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the protection scope of the present invention. All components not specified in this embodiment can be implemented using existing technologies.
Claims
1. A knowledge reasoning method based on deep transfer reinforcement learning, characterized in that: The following steps are involved: Step 1: Reinforcement learning environment modeling, including: constructing a knowledge graph reinforcement learning environment, and completing reinforcement learning environment modeling based on state space, action space, training reward setting and strategy neural network; Step 2, pre-task training, including: driving the reinforcement learning agent to perform effectiveness pre-training, based on training set pre-processing, pre-task reward function and pre-training algorithm, to help the agent learn to choose effective actions and improve the success rate of single-step walking; Step 3: fine-tuning the target task, including: migrating the agent to the reasoning task, performing fine-tuning training on the target task based on the reasoning task, reward function, and fine-tuning training algorithm, and migrating to the specific reasoning task after fine-tuning training; Step 4, constructing a model algorithm evaluation standard, including: constructing a deep reinforcement learning knowledge reasoning model algorithm evaluation standard, based on the path search success rate and average precision mean, to evaluate the knowledge reasoning performance based on deep reinforcement learning; Step 5, verification experiment and result analysis, including: constructing algorithm effectiveness verification experiments, collecting experimental data and conducting result verification analysis based on data set selection and analysis, path search experiments, fact prediction experiments, link prediction experiments, and transfer learning ablation experiments.
2. The method according to claim 1, characterized in that Step 1 includes: Step 1-1, through the state space, the semantics of the knowledge graph entity set is represented in the state space; The state space representation adopts the embedding representation model TransE, in which the entity is represented as a continuous embedding vector: s t =Trans(e t ) (1) where e t is the specific entity where the agent is located at the current time step t, s t is the state representation vector of the current entity, and Trans() is the embedding representation function; Step 1-2: Take the relationship set R in the knowledge graph as the action space of the agent. The process of the agent selecting an action through the action space is the transition from the current state to the next state. The action space is defined as: in Represents the relationship |R| The inverse relation of , A represents the action space, |R| represents the number of relations in the relation set R; Steps 1-3, introduce a reward mechanism to enable the environment to evaluate the agent's reward for task completion or failure, and update the agent's strategy based on the positive or negative feedback of the reward to maximize the reward; Steps 1-4, the strategy neural network is used to convert the input e through a fully connected network t , mapped to the probability vector strategy neural network of each action; the strategy neural network includes two hidden layers and an output layer, the output layer is normalized using the softmax function, for s t , the policy neural network will output the corresponding probability distribution: d(s t )=softmax(f(f(s t ×w1+b1)×w2+b2)) (3) Where f is the activation function, w1 and w2 are the weights of the first hidden layer and the second hidden layer, b1 and b2 are the bias of the first hidden layer and the second hidden layer, respectively; d(s t ) is a |A|×1 matrix, each bit represents the probability of selecting an action; The policy gradient descent algorithm is used to update the parameters of the policy neural network: Where θ is the parameter to be updated, logπ(a=a t |s t ; θ) is in state s t When the policy neural network selects action a t The probability of executing this action a t The reward obtained, t is the time step, T is the total number of time steps, represents the gradient of J(θ) with respect to the parameter θ.
3. The method according to claim 2, characterized in that Step 2 includes: Step 2-1, training set preprocessing: In the knowledge graph state space, obtain all combinations of states and valid actions through the fact triple set V, and convert each triple in V (e h ,r,e t ) is split into two state and action tuples (e h , r) and (e t , r -1 ), where e h represents the head entity, r represents the association between the head entity and the tail entity, and then merges the same bigrams to obtain the pre-trained effective action training set T valid , training set T valid Used to train a model to predict effective actions in a given state, where the model is a deep reinforcement learning model for knowledge graph reasoning; Step 2-2, determine the reward function of the pre-task: When the agent is in e t Action a is selected t If the tuple (e t , a t ) is included in the training set T valid , a positive reward is given to the agent to help it learn to choose effective actions; otherwise, no reward is given, and the reward Y(e t ,a t ) is defined as: Step 2-3: Build a pre-training algorithm, train the agent offline, and input the pre-training training set T valid , output the policy neural network parameters of the reinforcement learning agent.
4. The method according to claim 3, characterized in that Step 2-3 includes the following steps: Step 2-3-1, for each bigram (e t ,a t ), t Set to the tth entity e t The embedding representation Trans(e t ): s t ←Trans(e t ) Step 2-3-2, update the policy neural network parameters, use logarithmic probability and reward to adjust the parameters of the policy neural network: Where θ is the parameter to be updated, logπ(a=a t ∣s t ; θ) is in state s t When the policy neural network selects action a t The probability of executing this action a t Rewards received, represents the gradient of J(θ) with respect to the parameter θ.
5. The method according to claim 4, characterized in that The target task fine-tuning training described in step 3 specifically includes: Step 3-1: The goal of the reasoning task is to find a path connecting two entities: given a fact, including the starting node e start , reasoning task node r task and the target node e target , the agent needs to start searching from the starting node and find all nodes except the reasoning task node r task The paths of all reachable target nodes other than the target node are optimized to improve the agent's performance in the reasoning task by optimizing the target of the reasoning task; Step 3-2: Based on the global accuracy dimension, construct a path-end-based reward function r in the RL model GLOBAL : When the environment finds that the relationship selected by the agent does not exist, it will abandon the current choice and select another action until the number of selections reaches the upper limit of the preset number of steps; when the number of selections reaches the upper limit of the preset number of steps, set r GLOBAL ; When the agent successfully reaches the target node or the number of choices reaches the upper limit of the predetermined number of steps, a reward function γ is constructed based on the Monte Carlo method dimension. For each state and relationship binary (e t ,a t ) Rewards: Where length(p) is the length of the path; Based on the path diversity dimension, a reward function r is constructed based on the agent finding paths with similar syntax and semantics. DIVERSITY : Among them, F is the set of existing paths, P is the newly found path instance, and P t is an existing path instance; cos(P,P t ) represents the newly found path instance P and the existing path instance P t The cosine similarity of Step 3-3, build a fine-tuning training algorithm, migrate the agent to the target task, input the target task training set trainSet, and output the policy neural network parameters of the reinforcement learning agent.
6. The method according to claim 5, characterized in that Step 3-3 includes: Step 3-3-1, overload pre-training the RL strategy neural network; Step 3-3-1, for each triplet (e start , T task , e target ), where e start is the starting entity, T task is the relationship of the reasoning task, e target is the target entity, and the following steps are performed: Step 3-3-1-1, set the current entity state s t Initialize to Trans(e t ); Step 3-3-1-2, initialize the step count steps = 0, and mark the task success flag as false; Step 3-3-1-3, when the count steps is less than the preset maximum number of steps maxsteps and is unsuccessful, perform the following loop: Step 3-3-1-3-1, calculate the action probability vector d(s t )=softmax(f(f(s t ×w1+b1)×w2+b2)); Step 3-3-1-3-2, according to the vector d(s t ) Randomly select an action a t , terminate if an invalid action is selected; Step 3-3-1-3-3, record the state and action pairs (e t , a t ) to the set T; Step 3-3-1-3-4, perform action a t Jump to the next entity e next ; Step 3-3-1-3-5, if e next = =e target , then mark success as true and end the loop; Step 3-3-1-3-6, update the current entity status s t For Trans(e t ); Step 3-3-1-4, calculate each (e t , a t ) Step 3-3-1-5, update the policy neural network parameters:
7. The method according to claim 6, characterized in that The model algorithm evaluation criteria described in step 4 are constructed, specifically including: Step 4-1, the path search success rate PFSR is: Among them, SuccNum is the number of samples that successfully searched for the path in each round epoch, BatchSize is the batch size; the path search success rate PFSR reflects the ability of the agent to explore and identify effective paths; Step 4-2, the average precision mean MAP is used to evaluate the effect of fact prediction FP and link prediction LP, and measure the accuracy of the model in fact prediction and link prediction tasks. The calculation formula is as follows: Where |Q| is the total number of queries; AP(q) is the average precision of the qth query.
8. The method according to claim 7, characterized in that Step 5 includes: Step 5-1, data set selection and analysis: select and analyze the benchmark data set; Step 5-2, the path search experiment is used to evaluate the performance of the DTRLpath model in path search; Step 5-3, the fact prediction experiment refers to judging the given triple (e h ,r,e) authenticity, including: Step 5-3-1, use e h is the starting node, and the state vector is input into the policy neural network; Step 5-3-2, the policy neural network maps the vector of the current state to the probability of selecting each action and selects an action; Step 5-3-3, the agent performs actions in the knowledge graph environment and moves to the next node; Step 5-3-4, if the action chain you have walked through at this time forms a path that has been mined, determine whether the current node is e target , if yes, the score is +1 and the process ends, otherwise the score is -1 and the process ends; Step 5-3-5, repeat steps 5-3-2 to 5-3-4. If the maximum number of steps is reached, terminate and record the score as 0; Step 5-4, the link prediction experiment is used to predict missing entities: pre-train a neural network classification model based on TransE embedding on the training set, and use the neural network classification model to calculate the similarity scores of candidate tail entities of the head entity and relationship pairs in the test set, and sort the candidate tail entities according to the scores to predict the most likely missing entity; Step 5-5, the transfer learning ablation experiment includes: Step 5-5-1, delete the pre-task: train the reinforcement learning agent directly on the target task to obtain the onlyTarget model. After training, test the onlyTarget model on the path search task and the single-step walking task; Step 5-5-2, delete the fine-tuning training of the target task: GLOBAL ,γ,r DIVERSITY Delete it, and get the onlyPre model after completing the pre-training on the pre-task. Then directly use the onlyPre model for the path search task and the single-step walking task. In step 5-5-3, the onlyTarget model, onlyPre model and the original model DTRLpath are used to conduct comparative experiments on path search and fact prediction on the reasoning tasks of the dataset.
9. The method according to claim 8, characterized in that Step 5-2 includes: Step 5-2-1, initialization: Training set preparation: extract all triplets containing the target task from the data set to form the training set trainSet, and set the maximum number of steps maxSteps; Model initialization: Initialize the policy network parameters of the reinforcement learning agent, overload pre-train the policy network, and improve the initial performance; Step 5-2-2, path search: Traverse the training set: For each triple in trainSet (e start , T task , e target ) to perform the operation; State initialization: Initialize the current entity state st to Trans(e start ), initialize the step count steps = 0, and mark success as false; Execute path search: loop within the maximum number of steps maxSteps until the path is successfully found or the maximum number of steps is reached; Reward calculation and strategy update: Calculate each (e t ,a t ) and update the policy network parameters; Step 5-2-3, evaluation of experimental results: Calculate the number of samples SuccessNum that successfully searched the path in each epoch, and calculate the path search success rate PFSR; Experimental records and analysis: record the PFSR value of each epoch, draw a curve of PFSR changing with training rounds, analyze the path search success rate of different models on different data sets, and compare the performance of DTRLpath with other methods; In step 5-5-1, the specific method for completing the path search task is the same as step 5-2; The specific methods to complete the single-step walking task include: Initialization: Extract the triples containing the target task from the training set trainSet (e start , T task , e target ), and then initialize the state of the reinforcement learning agent to the head entity e start Embedding representation of ; Single-step action selection: Use the policy network to calculate the action probability vector d(s t ), select an action a according to the action probability vector t And perform the action a t Then check whether the selected action is valid, that is, whether the agent is successfully moved to a new entity; Evaluation: Record the success rate of single-step actions and evaluate the agent’s performance in the single-step walking task.
10. A method for predicting the use of new drugs based on deep transfer reinforcement learning, implemented based on the method described in any one of claims 1 to 9, characterized in that: include: The setting requires inferring the relationship between new drugs and their potential therapeutic diseases in a knowledge graph containing drug, disease, gene and symptom entities; Dataset construction: Use a knowledge graph dataset containing drug, disease, gene, and symptom entities, with new drugs as an entity and potential therapeutic diseases as target disease entities; Reinforcement learning environment modeling: build a knowledge graph reinforcement learning environment, define the state space, action space, training reward settings and policy neural network; The state space is represented by all entities in the knowledge graph, and the action space is the relationship between entities and their inverse relationship; Pre-mission training: Training set preprocessing: extract the relationship between drugs and genes, genes and diseases from the knowledge graph to generate effective action training sets; Pre-task reward function: defines the reward for the agent to select valid actions in the training set; Pre-training algorithm: offline training of the agent so that it can learn to choose effective actions in single-step search and improve the success rate of preliminary path search; Target task fine-tuning training: Reasoning task setting: The agent needs to start from the new drug in the knowledge graph and find the path to the target disease entity through genes and symptoms; Reward function: Set a global accuracy reward function based on the end of the path and a reward function based on path diversity; Fine-tune the training algorithm: transfer the agent to the target task, perform multi-step path exploration and strategy optimization; Experiment and result analysis: Path search experiment: evaluate the success rate of the agent in finding the path from the new drug to the target disease entity in the knowledge graph; Fact prediction experiment: In the test set, the accuracy of the agent in predicting the relationship between new drugs and diseases is verified through path scoring; Link prediction experiments: predict missing entities in the knowledge graph, and given new drug and gene relationships, predict potential related diseases.
Citation Information
Cited By
Scientific discovery intelligent system embedded with scientific and technological text reverse reasoning mechanism
CN120146190A
An intelligent scientific discovery system embedded with reverse reasoning mechanism of scientific and technological texts
CN120146190B
Data migration method of heterogeneous database based on reinforcement learning
CN120179629A
Data migration method for heterogeneous databases based on reinforcement learning
CN120179629B
Content recommendation method and system based on industry knowledge graph and reinforcement learning
CN120994903A
