Reinforcement learning knowledge graph reasoning method and system guided by confrontation and attention mechanism

Through the confrontation-guided Actor-Critic reinforcement learning framework and self-attention mechanism, the problem of insufficient exploration of a single agent and excessive action space in reinforcement learning knowledge graph reasoning is solved, and the reasoning performance and interpretability are improved.

CN118606485APending Publication Date: 2024-09-06BEIJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 8 Cited by

Patent Information

Application Number
CN202410720573.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing reinforcement learning knowledge graph reasoning methods have challenges in the limited exploration of a single agent and the excessively large action space in large-scale knowledge graphs, resulting in increased difficulty in model training.

Method used

Introducing reinforcement learning methods guided by confrontation and attention mechanisms, creating opponents for the agent through the confrontation-guided Actor-Critic reinforcement learning framework, and using soft reward mechanisms and self-attention mechanisms to improve exploration capabilities and action space pruning.

Benefits of technology

It improves the interpretability and reasoning performance of knowledge graph reasoning, reduces the training time cost, enhances the agent's path exploration ability in the knowledge graph, and solves the problems of insufficient exploration and excessive action space of a single agent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118606485A
    Figure CN118606485A
Patent Text Reader

Abstract

The invention discloses a reinforcement learning knowledge graph reasoning method and system guided by an adversarial and attention mechanism, and the method comprises the steps: constructing a knowledge graph environment, and carrying out the state coding of entities and relationships in a knowledge graph through a knowledge graph embedding model; calculating based on the triple relationship between the state code and the query to obtain an accumulated interaction weight value, and trimming the working space of the current state according to the accumulated interaction weight value; the intelligent agent selects one action from the space actions in each state according to a reasoning strategy, meanwhile, an exploration path of the intelligent agent is recorded by using LSTM, the selected action is returned to the knowledge graph environment, the state of the knowledge graph environment is updated, and whether a predicted target node is reached or not is judged according to the current state; the intelligent agent learns an optimal knowledge graph reasoning strategy through interaction with the environment so as to maximize long-term rewards. According to the method, the interpretability of the reasoning result is improved, and powerful support is provided for application and understanding of the reasoning model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning technology, and in particular to a reinforcement learning knowledge graph reasoning method and system guided by adversarial and attention mechanisms. Background Art

[0002] The Knowledge Graph (KG) was proposed by Google in 2012. It is a structured semantic knowledge base and a technical method that uses a graph model to describe knowledge and model the relationship between all things in the world. Its basic component is the (entity, relationship, entity) triple. The entity is the node in the graph, which represents the thing or concept. The directed edge between the nodes is the relationship, which represents the connection between entities. At present, many knowledge graphs have been constructed, such as FB15K-237, NELL-995, WN18RR, etc., and have been successfully applied to intelligent service fields such as information retrieval, recommendation system, question-answering system, etc. Because the large-scale knowledge graphs constructed are usually incomplete, they need to be continuously supplemented.

[0003] Knowledge reasoning is an important method for knowledge graph completion, which aims to infer unknown knowledge based on the existing knowledge in the knowledge graph, including entity prediction and relationship prediction. The reasoning method based on deep reinforcement learning expresses multi-hop reasoning as a Markov decision process and uses reinforcement learning to perform effective path search. It has better interpretability based on the advantages of neural network models. In recent years, due to the advantages of reinforcement learning in interpretability and performance, knowledge reasoning methods based on reinforcement learning have quickly become a research hotspot.

[0004] Tiwari et al. (Neural Networks, 2021) proposed a distance-aware reward to assign different rewards to different positions, and combined the graph self-attention mechanism to obtain more comprehensive entity information from adjacent entities and relations. Zhang et al. (AAAI Conference on Artificial Intelligence, 2022) proposed a collaborative dual-agent reinforcement learning framework CURL, in which two agents search at the cluster level and entity level respectively to solve the reasoning challenges in long paths. At the same time, the framework also proposed a new mutual reinforcement reward mechanism, in which the two agents learn knowledge from each other when the reasoning direction is consistent. Wang et al. (ACM Web Conference, 2022) proposed a multi-level recommendation reasoning reinforcement learning framework based on knowledge graphs. The framework uses ontology view knowledge graphs and instance view knowledge graphs to model multi-level user interests, effectively transfer high-level knowledge to low-level knowledge, and ensure convergence to more satisfactory solutions. At the same time, a multi-level reasoning path extraction method is proposed to automatically choose between high-level concepts and low-level concepts to form a reasoning path that can better reveal user interests. In order to solve the problem that the same head entity and relationship pair has multiple tail entities, Zhu et al. (Knowledge-Based Systems, 2022) proposed a new knowledge graph reasoning paradigm, decomposing knowledge graph reasoning into a two-layer hierarchical decision-making process, and using a hierarchical reinforcement learning framework to decompose the task into a high-level process for relationship detection and a low-level process for entity reasoning. In this way, the action space can be effectively restricted, thereby optimizing the strategy.

[0005] In order to make reinforcement learning models more resilient in complex, dynamic, and uncertain environments, and to bring new possibilities for improving model performance and adaptability, a lot of work has introduced the idea of ​​adversarial learning.

[0006] The DIVINE (the 9th International Joint Conference on Natural Language Processing, 2019) model is based on generative adversarial imitation learning, consisting of a generative adversarial reasoner and a demonstration sampler. The reasoner consists of a generator and a discriminator. The generator is any policy network-based agent in reinforcement learning, and the discriminator is an adaptive reward function. After sufficient adversarial training between the generator and the discriminator, the trained policy-based agent (i.e., the generator) is used to find evidence paths that match the distribution of the demonstrations, and predictions are made by synthesizing these evidence paths. In terms of question answering and recommendation, there have also been works that apply adversarial reinforcement learning. AR2N (Knowledge-Based Systems, 2023) is a multi-hop KGQA interpretable reasoning method based on adversarial reinforcement learning, consisting of two key components: an answer generator (i.e., a policy network of reinforcement learning) and a path discriminator. By alternating the updates of the two components in an adversarial manner, the generator is able to infer the answer entity by following the correct reasoning chain, and the discriminator is able to evaluate the rationality of the reasoning path. In Scratch-RL (International Journal of Intelligent Systems, 2022), the design of the agent includes a preference state function, a preference-based reward function, and a preference-conditional behavior pruning strategy. Through these designs, the agent can better understand the user's preferences. At the same time, the instruction discriminator network is used to evaluate the agent's recommendations and obtain additional guidance rewards to ensure that the agent can quickly and accurately understand user needs.

[0007] At the same time, there are many works that introduce attention mechanisms into knowledge graph reasoning based on reinforcement learning. Wang et al. (Knowledge Based Systems, 2020) proposed a deep reinforcement learning framework ADRL based on self-attention. First, convolutional neural networks and LSTM are used to encode entity information and agent historical path information as states. Secondly, due to the rich semantic information between entities in the knowledge graph, ADRL designs an entity relationship module based on the self-attention mechanism to guide the learning of the policy network according to the importance of these entities and the relationship between entities. In order to solve the problems of lack of memory components and complex training process in the research of deep reinforcement learning knowledge graph reasoning methods, the AttnPath (the 9th International Joint Conference on Natural Language Processing, 2019) model uses LSTM and graph attention mechanism as memory components to reduce the pre-training of the model. It also defines two indicators to measure the learning difficulty of the relationship, and uses them to fine-tune the training hyperparameters to improve the training efficiency. HackRL (Knowledge-Based Systems, 2021) combines long short-term memory and hierarchical graph attention mechanisms in policy networks to infer indicative cross-knowledge graph relationship paths from historical trajectories and heterogeneous environments to predict corresponding relationships. At the same time, using a representation learning method for entity alignment, different KGs are embedded into a unified vector space based on anchor links to reduce the influence of different vector spaces, and two training mechanisms, action masking and sampled path retraining, are proposed to optimize the training process and learn more successful indicative paths. The Ae2KGR (Information Sciences, 2024) model adopts two novel strategies, attention-based exploitation and attention-based exploration. The attention-based mining strategy combines historical information and query information with the neighborhood of the current entity, dynamically updates the current state during reasoning, and assigns different semantic information to entities to distinguish different triples. The attention-based exploration strategy designs a novel policy network and reward function to make decisions dynamically based on the changing state.

[0008] However, existing research still faces two major challenges: the exploration of a single agent in reinforcement learning is limited; and there is an overly large action space in large-scale knowledge graphs, which includes many actions that are irrelevant to the current query content.

[0009] In previous methods, in order to solve the problem of insufficient exploration of a single agent, knowledge graph reasoning algorithms based on reinforcement learning usually use multi-agent or multi-process training. In order to solve the problem of too large action space, hierarchical reinforcement learning can effectively decompose complex reinforcement learning problems into several sub-problems. However, these methods increase the difficulty of model training. Summary of the invention

[0010] To solve the above technical problems, the present invention proposes a reinforcement learning knowledge graph reasoning method and system guided by adversarial and attention mechanisms. The traceability and transparency of the exploration process of the present invention make the reasoning process clearly visible and improve the interpretability of the reasoning results.

[0011] On the one hand, to achieve the above-mentioned purpose, the present invention provides a reinforcement learning knowledge graph reasoning method guided by adversarial and attention mechanisms, comprising:

[0012] Build a knowledge graph environment and use the trained knowledge graph embedding model to encode the entities and relationships in the knowledge graph;

[0013] Calculating based on the triple relationship between the state code and the query to obtain a cumulative interaction weight value, and pruning the workspace of the current state according to the cumulative interaction weight value;

[0014] The agent selects an action from the spatial actions in each state according to the reasoning strategy, and uses LSTM to record the exploration path of the agent, and returns the selected action to the knowledge graph environment, which updates the state and determines whether it has reached the expected target node according to the current state;

[0015] The agent learns the optimal knowledge graph reasoning strategy through interaction with the environment to maximize long-term rewards.

[0016] Preferably, the agent selects an action from the spatial actions in each state according to the reasoning strategy, and uses LSTM to record the exploration path of the agent, including:

[0017] Will explore the history t Input into the trained knowledge graph embedding model to obtain the corresponding encoding, where the exploration history h t =(e s ,r1,e1,…,r t ,e t ) consists of a sequence of actions taken from the source node to step t, as follows:

[0018] h0=LSTM(0,[r0;e s ])

[0019] h t =LSTM(h t-1 ,a t-1 ),t>0

[0020] Among them, r0 is introduced with e s A special start relation that forms the start action, h t-1 is the search history at step t-1, a t-1 is the action taken at step t-1.

[0021] Preferably, judging whether the estimated target node has been reached according to the current state includes:

[0022] If the expected target node is reached, a reward of 1 is fed back, otherwise the score function value of the trained embedding representation is fed back as a reward;

[0023] The method for calculating the scoring function value is:

[0024] R s (e T )=R b (e T )+(1-R b (e T ))f s (e s ,r q ,e T )

[0025] in, f s (e s ,r q ,e T ) is the scoring function of the model by calculating the embedding representation, e s is the source entity, r q To query the relationship, e T is the target entity, R s (e T ) is the scoring function.

[0026] Preferably, the method for obtaining the cumulative interaction weight value is:

[0027] Map each entity state vector to a query vector, a key vector, and a value vector respectively;

[0028] Based on the dot product operation between the query vector and the key vectors of all entities, the similarity between each query vector and the key vectors of all other entities, i.e., the significant feature score, is calculated;

[0029] For each entity, the significant feature score is normalized by the Softmax function to obtain a normalized attention weight, and then the normalized attention weight is applied to the value vectors of all entities, and the cumulative interaction weight value is calculated by weighted average.

[0030] Preferably, the method further comprises counteracting the prediction of the opponent agent:

[0031] At the beginning of training, the intelligent agent is copied to obtain the opponent intelligent agent, wherein the opponent intelligent agent learns from the historical path of the intelligent agent, and the learning goal is to minimize the strategy difference between the two and predict the actions of the intelligent agent; the learning goal of the intelligent agent is to maximize the long-term reward and maximize the strategy difference between the two to offset the prediction of the opponent intelligent agent.

[0032] On the other hand, to achieve the above-mentioned purpose, the present invention also provides a reinforcement learning knowledge graph reasoning system guided by adversarial and attention mechanisms, including a knowledge graph environment module, a reinforcement learning module, a soft reward mechanism module and an attention mechanism module;

[0033] The knowledge graph environment module is used to transmit the state encoding of entities and relationships to the reinforcement learning module and the attention mechanism module;

[0034] The attention mechanism module is used to calculate the cumulative interaction weight value according to the current state and query information, and send the cumulative interaction weight value to the reinforcement learning module to prune the action space;

[0035] The reinforcement learning module is used to select actions according to a specific state and a corresponding action space through policy reasoning, and return the selected action to the knowledge graph environment module to calculate the next state;

[0036] The soft reward mechanism module is used to return the obtained soft reward to the reinforcement learning module.

[0037] Preferably, the knowledge graph environment module stores knowledge graph information and a trained knowledge graph embedding model. After reading the knowledge graph data, the knowledge graph environment module obtains the embedded representation of all entities and relationships according to the trained knowledge graph embedding module.

[0038] Preferably, the reinforcement learning module is an adversarially guided Actor-Critic reinforcement learning framework, wherein the Actor adopts a policy-based reinforcement learning algorithm for exploration, and the Critic uses an advantage function to evaluate the actions taken by the Actor;

[0039] The process of the reinforcement learning module for selecting actions according to a specific state and a corresponding action space through policy reasoning is as follows:

[0040] M=(A,S,P,R)

[0041] Among them, A is the set of actions imposed by the agent on the environment, S is the set of environmental states, P is the state transfer matrix, and R is the feedback of the environment to the action.

[0042] Preferably, the soft reward mechanism module uses an existing KG embedding model ConvE to estimate the soft reward for not correctly reaching the target entity position; wherein the scoring function of the ConvE is:

[0043]

[0044] In the formula, ψ r (e s ,e o ) is the scoring function of ConvE, is the embedding representation of the source entity after two-dimensional reshaping, is the embedding representation of the query relationship after two-dimensional reshaping. Two-dimensional reshaping is the operation of converting the original embedding representation into a two-dimensional matrix. f() is a nonlinear activation function, W is a weight matrix, and e o For the current entity.

[0045] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to run the computer program; by executing the computer program, the electronic device can implement a reinforcement learning knowledge graph reasoning method guided by adversarial and attention mechanisms.

[0046] Compared with the prior art, the present invention has the following advantages and technical effects:

[0047] The present invention draws on the idea of ​​adversarial learning and introduces the adversarially guided Actor-Critic reinforcement learning framework into knowledge graph reasoning for the first time, creating an opponent for the intelligent agent. The opponent does not need to conduct additional exploration and training, but only learns from the historical path of the intelligent agent. The intelligent agent distinguishes its own and the opponent's prediction areas through KL divergence, so that the intelligent agent can explore all paths of the knowledge graph to a greater extent and improve the model effect. At the same time, in order to solve the problem of sparse rewards in reinforcement learning knowledge graph reasoning, the present invention uses a soft reward mechanism, combines the scoring function of the embedded representation into the reward function of reinforcement learning, and gives the score calculated by the scoring function as a reward feedback to the intelligent agent when the target node is not reached; the traceability and transparency of the path exploration process make the reasoning process clearly visible, improve the interpretability of the reasoning results, and provide strong support for the application and understanding of the reasoning model.

[0048] The present invention introduces the self-attention mechanism as an auxiliary module to improve the effect of the reasoning model. At the same time, the pruning of the action space by the self-attention mechanism increases the basis for the agent to select actions, can select more relevant actions, and increases the interpretability of the algorithm.

[0049] The present invention solves the problem of insufficient exploration of a single agent by using an adversarially guided Actor-Critic reinforcement learning framework, and uses a self-attention mechanism to limit the size of the action space, thereby greatly improving the reasoning performance without increasing the training time cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0051] Figure 1 A flowchart of a method for reinforcement learning knowledge graph reasoning guided by an adversarial and attention mechanism according to an embodiment of the present invention;

[0052] Figure 2 A schematic diagram of a reinforcement learning knowledge graph reasoning system guided by an adversarial and attention mechanism according to an embodiment of the present invention. DETAILED DESCRIPTION

[0053] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0054] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0055] This paper proposes a reinforcement learning knowledge graph reasoning method guided by adversarial and attention mechanisms, such as Figure 1 ,include:

[0056] Step S1: Build a knowledge graph environment and use the trained knowledge graph embedding model to encode entities and relationships in the knowledge graph into states so that the agent can understand and process them;

[0057] Step S2: The current state encoding is input into the attention mechanism module, which will calculate according to the current state and the queried triple relationship (i.e., the specific relationship being processed in the current reasoning process and its corresponding head entity), and finally obtain the cumulative interaction weight value, and prune the action space of the current state according to the value;

[0058] Step S3: The agent selects an action in the action space in each state according to the reasoning strategy. The action can be to explore new entities or relationships, or to make decisions based on the current state. At the same time, LSTM is used to record the agent's exploration path.

[0059] Step S4: The agent returns the selected action to the knowledge graph environment, which updates the state and determines whether it has reached the expected target node based on the current state. If it has reached the target node, it will feedback a reward of 1. Otherwise, it will feedback the scoring function value of the trained embedding representation as a reward.

[0060] Step S5: The agent learns the optimal knowledge graph reasoning strategy through interaction with the environment to maximize the long-term reward. The opponent agent is trained using the agent's historical exploration path, and the agent must also counteract the opponent's prediction by maximizing the difference between its own strategy and the opponent's strategy.

[0061] The knowledge graph embedding model can choose the ConvE, Dismult and ComplEx models which are currently commonly used and have good effects.

[0062] S2 is specifically:

[0063] Map each entity state vector to query, key, and value vectors respectively;

[0064] Compare each query vector with the query vectors of all entities using a dot product to compute unnormalized salient features;

[0065] For each entity, the cumulative interaction weight is calculated by a weighted mixture of the value vectors of all entities;

[0066] The accumulated interaction weights are incorporated into the policy to prune the action space.

[0067] Furthermore, S3 is specifically:

[0068] Search History t =(e s ,r1,e1,…,r t ,e t ) consists of the sequence of actions taken from the source node to step t;

[0069] Will explore the history t Input LSTM and get the corresponding encoding:

[0070] h0=LSTM(0,[r0;e s ])

[0071] h t =LSTM(h t-1 ,at-1 ),t>0

[0072] Among them, r0 is introduced with e s A special start relation that forms a start action.

[0073] S4 is specifically:

[0074] Update the current state according to the action and determine whether the target node has been reached. The rewards are as follows:

[0075] R s (e T )=R b (e T )+(1-R b (e T ))f s (e s ,r q ,e T )

[0076] in,

[0077] f s (e s ,r q ,e T ) is estimated by calculating the scoring function of the embedding representation ConvE, ComplEx and other models (e s ,r q ,e T ) is true.

[0078] S5 is as follows:

[0079] At the beginning of training, copy the agent to get the opponent agent;

[0080] The opponent agent learns from the historical path of the agent, and the learning goal is to minimize the difference in their strategies to predict the actions of the agent.

[0081] The learning goal of the agent is to maximize the long-term reward while maximizing the difference in their strategies to offset the predictions of the opponent agent.

[0082] The present invention also provides a reinforcement learning knowledge graph reasoning system guided by adversarial and attention mechanisms, such as Figure 2 , mainly includes four modules, namely knowledge graph environment module, reinforcement learning module, soft reward mechanism module and attention mechanism module. The specific process and description are as follows:

[0083] The knowledge graph environment module transmits the state to the reinforcement learning module and the attention mechanism module. The attention mechanism module calculates the attention weight based on the current state and query information, and sends the attention weight to the reinforcement learning module to prune the action space. The reinforcement learning module selects actions based on the specific state and the corresponding action space through the strategy, and then returns the selected action to the knowledge graph environment module to calculate the next state and determine whether the target node has been reached. If it has been reached, a reward value of 1 is returned. Otherwise, the knowledge graph environment module sends the current state to the soft reward mechanism module to obtain a soft reward and return it to the reinforcement learning module.

[0084] The knowledge graph environment module stores the knowledge graph information and the trained knowledge graph embedding module. After reading the knowledge graph data, it will obtain the embedded representation of all entities and relationships based on the trained knowledge graph embedding module.

[0085] For the reinforcement learning module, the traversal process on the knowledge graph needs to be defined as a Markov decision process. According to the exploration process of the agent, the present invention formalizes it into a decision process: M = (A, S, P, R). Among them, the action space A represents the set of actions imposed by the agent on the environment, the state space S represents the set of environmental states, P is the state transfer matrix, and the reward R represents the feedback of the environment to the action.

[0086] States: Each state s t =(e t ,(e s ,r q ))∈S is a tuple where e t is the entity visited at step t, (e s ,r q ) is the source entity and the query relationship. t can be viewed as state-dependent information, while (e s ,r q ) is the global context shared by all states.

[0087] Actions: A set of possible actions at step t t ∈A is determined by e in G t The outgoing edges of A t ={(r′,e′)|(e t ,r′,e′)∈G}.

[0088] State transition: The state transition function δ:S×A→S is defined as δ(s t ,A t )=δ(e t ,(e s ,eq ),A t ). For the walking-based model, the state transition function is based on the knowledge graph G.

[0089] Reward: In the default formulation, the agent receives a final reward of 1 if it reaches the correct goal entity at the end of the search, and 0 otherwise.

[0090] R b (s T )=1{(e s ,r q ,e T )∈G}

[0091] An important part of the reinforcement learning module is what strategy the intelligent agent should follow to explore the environment. The present invention adopts an adversarially guided Actor-Critic reinforcement learning framework, in which the Actor adopts a strategy-based reinforcement learning algorithm for exploration, and the Critic part uses an advantage function to evaluate the actions taken by the Actor.

[0092] First, each entity and relation in G is assigned an embedding representation vector In the example above, a specific action a t =(r t+1 ,e t+1 )∈A t is represented as a concatenation of the relation embedding and the end node embedding a t =[r;e′ t ].

[0093] Search History t =(e s ,r1,e1,…,r t ,e t ) consists of the sequence of actions taken starting from the source node to step t and can be encoded using LSTM:

[0094] h0=LSTM(0,[r0;e s ])

[0095] h t =LSTM(h t-1 ,a t-1 ),t>0

[0096] Among them, r0 is introduced with e s A special start relation that forms a start action.

[0097] The action space is encoded by stacking the embeddings of all actions in it The definition of the policy network can be obtained:

[0098] π θ (a t |s t )=Softmax(A t ×W2ReLU(W1[e t ;h t ; r q ]))

[0099] Since the policy-based algorithm requires a complete state sequence and it is not easy to converge by iteratively updating the policy function alone, an additional value function is used as a Critic to evaluate the performance of the current Actor and guide the Actor's next action.

[0100] The Actor-Critic evaluation point used in the present invention is the advantage function:

[0101] A(s,a)=Q(s,a)-V(s)

[0102] The advantage function represents the advantage of taking a certain action relative to the average action. In order to better estimate the advantage function, GAE generalized advantage estimation is used:

[0103]

[0104] The policy network loss is as follows:

[0105]

[0106] in is the entropy of strategy π:

[0107]

[0108] The value function loss is as follows:

[0109]

[0110] in:

[0111]

[0112] In the adversarial guidance part, in order to make the Actor have diversified behaviors in the search trajectory, this paper draws on the idea of ​​adversarial learning, uses the AGAC framework, and introduces an adversary network for the Actor. The role of the adversary is to minimize its action distribution π adv The difference between π and the actor’s action distribution π accurately predicts the actor’s action. At the same time, in addition to finding the best action to maximize the sum of expected rewards, the actor must also maximize π and π advThe difference between the two is used to offset the opponent's prediction. This difference, as a form of reward, is defined as the difference in the log-probabilities of actions, whose expectation is the Kullback-Leibler divergence:

[0113]

[0114] In the loss of the policy network, the deviation of the logarithmic probability of the actions of the Actor network and Adversary network is added to the original GAE generalization advantage estimate, and the formula is as follows:

[0115]

[0116]

[0117] The value function loss adds the KL divergence of the Actor network and Adversary network on the original basis. The formula is as follows:

[0118]

[0119] The Adversary network minimizes its action distribution π adv The difference between the action distribution π of the Actor, so its loss function is as follows:

[0120]

[0121] The final loss of the model is as follows:

[0122] L AGAC =L PG +β V L V +β adv L adv

[0123] Soft reward mechanism module:

[0124] With binary rewards, the agent only gets a positive reward when it gets the correct answer. This means that the agent does not get any positive rewards in the early stages of exploration and treats false negative searches as true negatives. To address this issue, MultiHop proposes a soft reward mechanism that provides a soft reward f between 0 and 1 when the target entity is not reached correctly. s .f s (e s ,r q ,e T ) is estimated by calculating the scoring function of the embedding representation ConvE, ComplEx and other models (e s ,r q ,e T ) is true.s Defined as:

[0125] R s (e T )=R b (e T )+(1-R b (e T ))f s (e s ,r q ,e T )

[0126] In other words, when providing the answer e T When The agent receives a final reward of 1. Otherwise, the agent receives f calculated using the pre-trained embedding-based model. s (e s ,r q ,e T ).

[0127] In general, according to the default reward formula, the agent receives binary rewards based only on the answers observed in G. However, G is inherently incomplete, and this approach penalizes false negative search attempts as equivalent to true negatives. To alleviate this problem, the present invention adopts the existing KG embedding model ConvE to estimate the soft reward for not correctly reaching the location of the target entity. The scoring function of ConvE is as follows:

[0128]

[0129] Since there is rich semantic information between entities in knowledge graphs, the weights of entities and paths need to be estimated to infer the importance of these entities and relationships.

[0130] The self-attention mechanism maps the state vector of each entity to the query, key, and value vectors respectively. Each Q is compared with K of all entities using the dot product to calculate the unnormalized salient features. For each entity, the cumulative interaction is calculated by a weighted mixture of the value vectors of all entities, which can be calculated by the following formula:

[0131] similarity(Q,K i )=QK i T

[0132]

[0133] Among them, Q represents the query vector, K represents the key vector, V represents the value vector, λ is the scaling factor, and W is the cumulative interaction weight value.

[0134] The present invention introduces the cumulative interaction weight into the strategy, which can generate the following strategy:

[0135] π θ (a t |s t )=Softmax(A t ×WReLU[e t ;h t ; r q ])

[0136] Among them, A t Represents the action space. By accumulating the interaction weight W, the selection of highly relevant actions is improved and the possibility of the agent selecting irrelevant actions is reduced, thereby achieving the purpose of pruning the action space of the Actor network and Adversary network.

[0137] The present invention also provides an electronic device, comprising a memory and a processor. The memory is used to store computer programs, and the processor is used to run these computer programs. By executing the computer programs, the electronic device can implement the reinforcement learning knowledge graph reasoning method guided by adversarial and attention mechanisms.

[0138] The present invention also provides a computer-readable storage medium, in which specific computer programs are stored. When these computer programs are executed by a processor, a reinforcement learning knowledge graph reasoning method guided by adversarial and attention mechanisms can be implemented.

[0139] The knowledge graph reasoning method based on reinforcement learning is to interact with the environment through the agent, and constantly adjust the agent's own strategy through the reward feedback given by the environment to complete the final reasoning task. Therefore, the degree of exploration of the environment by the agent affects the accuracy of reasoning to a certain extent. However, the exploration of a single agent in reinforcement learning is limited. In order to solve this problem, previous methods usually use multi-agent or multi-process training, which undoubtedly increases the difficulty of model training.

[0140] In order to solve the problem of insufficient exploration of a single agent without increasing the difficulty of training, the present invention draws on the idea of ​​adversarial learning and introduces the adversarially guided Actor-Critic (AGAC) reinforcement learning framework into knowledge graph reasoning for the first time, creating an opponent for the agent. The opponent does not need to conduct additional exploration and training, and only learns from the historical path of the agent. The agent distinguishes its own and the opponent's prediction area through KL divergence, so that the agent can explore all paths of the knowledge graph to a greater extent and improve the model effect. At the same time, in order to solve the problem of sparse rewards in reinforcement learning knowledge graph reasoning, the present invention quotes a soft reward mechanism, combines the scoring function of the embedded representation into the reward function of reinforcement learning, and gives the score calculated by the scoring function as a reward feedback to the agent when the target node is not reached. In addition, knowledge graph reasoning based on reinforcement learning has significant advantages in interpretability. The traceability and transparency of its path exploration process make the reasoning process clearly visible, improve the interpretability of the reasoning results, and provide strong support for the application and understanding of the reasoning model.

[0141] Large-scale knowledge graphs often have more relationships, which will also lead to the problem of too large action space in reinforcement learning. It is necessary to prune the action space of the query relationship to improve the efficiency of action selection. To address this problem, the present invention introduces a self-attention mechanism. Attention mechanisms are now widely used in many fields of deep learning. The structural model based on the attention mechanism can not only record the positional relationship between information, but also measure the importance of different information features based on the weight of the information. By making relevant and irrelevant decisions on information features, dynamic weight parameters are established to strengthen key information and weaken useless information, thereby improving the efficiency of the deep learning algorithm and improving some defects of traditional deep learning.

[0142] The present invention introduces the self-attention mechanism as an auxiliary module to improve the effect of the reasoning model. At the same time, the pruning of the action space by the self-attention mechanism increases the basis for the agent to select actions, and can select more relevant actions, which increases the interpretability of the algorithm. The present invention solves the problem of insufficient exploration of a single agent by using the adversarially guided Actor-Critic reinforcement learning framework, and uses the self-attention mechanism to limit the size of the action space, which greatly improves the reasoning performance without increasing a lot of training time costs.

[0143] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A reinforcement learning knowledge graph reasoning method guided by adversarial and attention mechanisms, characterized in that: include: Build a knowledge graph environment and use the trained knowledge graph embedding model to encode the entities and relationships in the knowledge graph; Calculating based on the triple relationship between the state code and the query to obtain a cumulative interaction weight value, and pruning the workspace of the current state according to the cumulative interaction weight value; The agent selects an action from the spatial actions in each state according to the reasoning strategy, and uses LSTM to record the exploration path of the agent, and returns the selected action to the knowledge graph environment. The knowledge graph environment updates the state and determines whether it has reached the expected target node according to the current state; The agent learns the optimal knowledge graph reasoning strategy through interaction with the environment to maximize long-term rewards.

2. The method for reinforcement learning knowledge graph reasoning guided by adversarial and attention mechanisms according to claim 1, characterized in that: The agent selects an action from the spatial actions in each state according to the reasoning strategy, and uses LSTM to record the exploration path of the agent, including: Will explore the history t Input into the trained knowledge graph embedding model to obtain the corresponding encoding, where the exploration history h t =(e s ,r1,e1,…,r t ,e t ) consists of a sequence of actions taken from the source node to step t, as follows: h0=LSTM(0,[r0;e s ]) h t =LSTM(h t-1 ,a t-1 ),t>0 Among them, r0 is introduced with e s A special start relation that forms the start action, h t-1 is the search history at step t-1, a t-1 is the action taken at step t-1.

3. The method for reinforcement learning knowledge graph reasoning guided by adversarial and attention mechanisms according to claim 1, characterized in that: The step of judging whether the estimated target node has been reached according to the current state includes: If the expected target node is reached, a reward of 1 is fed back, otherwise the score function value of the trained embedding representation is fed back as a reward; The method for calculating the scoring function value is: R s (e T )=R b (e T )+(1-R b (e T ))f s (e s ,r q ,e T ) in, f s (e s ,r q ,e T ) is the scoring function of the model by calculating the embedding representation, e s is the source entity, r q To query the relationship, e T is the target entity, R s (e T ) is the scoring function.

4. The method for reinforcement learning knowledge graph reasoning guided by adversarial and attention mechanisms according to claim 1, characterized in that: The method for obtaining the cumulative interaction weight value is: Map each entity state vector to a query vector, a key vector, and a value vector respectively; Based on the dot product operation between the query vector and the key vectors of all entities, the similarity between each query vector and the key vectors of all other entities, i.e., the significant feature score, is calculated; For each entity, the significant feature score is normalized by the Softmax function to obtain a normalized attention weight, and then the normalized attention weight is applied to the value vectors of all entities, and the cumulative interaction weight value is calculated by weighted average.

5. The method for reinforcement learning knowledge graph reasoning guided by adversarial and attention mechanisms according to claim 1, characterized in that: The method also includes counteracting the opponent agent's prediction: At the beginning of training, the intelligent agent is copied to obtain the opponent intelligent agent, wherein the opponent intelligent agent learns from the historical path of the intelligent agent, and the learning goal is to minimize the strategy difference between the two and predict the actions of the intelligent agent; the learning goal of the intelligent agent is to maximize the long-term reward and maximize the strategy difference between the two to offset the prediction of the opponent intelligent agent.

6. A reinforcement learning knowledge graph reasoning system guided by adversarial and attention mechanisms, characterized in that: Including knowledge graph environment module, reinforcement learning module, soft reward mechanism module and attention mechanism module; The knowledge graph environment module is used to transmit the state encoding of entities and relationships to the reinforcement learning module and the attention mechanism module; The attention mechanism module is used to calculate the cumulative interaction weight value according to the current state and query information, and send the cumulative interaction weight value to the reinforcement learning module to prune the action space; The reinforcement learning module is used to select actions according to a specific state and a corresponding action space through policy reasoning, and return the selected action to the knowledge graph environment module to calculate the next state; The soft reward mechanism module is used to return the obtained soft reward to the reinforcement learning module.

7. The adversarial and attention mechanism guided reinforcement learning knowledge graph reasoning system according to claim 6, characterized in that: The knowledge graph environment module stores knowledge graph information and a trained knowledge graph embedding model. After reading the knowledge graph data, the knowledge graph environment module obtains the embedded representation of all entities and relationships according to the trained knowledge graph embedding module.

8. The adversarial and attention mechanism guided reinforcement learning knowledge graph reasoning system according to claim 6, characterized in that: The reinforcement learning module is an adversarially guided Actor-Critic reinforcement learning framework, in which the Actor adopts a policy-based reinforcement learning algorithm for exploration, and the Critic uses an advantage function to evaluate the actions taken by the Actor; The process of the reinforcement learning module for selecting actions according to a specific state and a corresponding action space through policy reasoning is as follows: M=(A,S,P,R) Among them, A is the set of actions imposed by the agent on the environment, S is the set of environmental states, P is the state transfer matrix, and R is the feedback of the environment to the action.

9. The adversarial and attention mechanism guided reinforcement learning knowledge graph reasoning system according to claim 6, characterized in that: The soft reward mechanism module uses the existing KG embedding model ConvE to estimate the soft reward for not correctly reaching the target entity position; wherein the scoring function of the ConvE is: In the formula, ψ r (e s ,e o ) is the scoring function of ConvE, is the embedding representation of the source entity after two-dimensional reshaping, is the embedding representation of the query relationship after two-dimensional reshaping. Two-dimensional reshaping is the operation of converting the original embedding representation into a two-dimensional matrix. f() is a nonlinear activation function, W is a weight matrix, and e o For the current entity.

10. An electronic device, characterized in that: It includes a memory and a processor, the memory is used to store a computer program, and the processor is used to run the computer program; by executing the computer program, the electronic device can implement the reinforcement learning knowledge graph reasoning method guided by the adversarial and attention mechanism as described in any one of claims 1 to 5.

Citation Information

Cited By

  • Equipment dynamic confrontation game decision-making method and device based on knowledge graph

    CN119294496A

  • Education system data dynamic optimization query method based on deep reinforcement learning

    CN119938702A

  • Decision optimization method fusing enhanced multi-modal learning and knowledge graph

    CN120409642A

  • Multi-agent reinforcement learning method, device, equipment, medium and product

    CN120633759A

  • Interaction task generation method and device and storage medium

    CN120822625A