A knowledge graph reasoning completion method and system based on reinforcement learning

By applying reinforcement learning and the TranE model in the knowledge graph, and combining multiple reward functions to retrain the policy network, the problem of the diversity of entity relationships in the knowledge graph being ignored is solved, and efficient and diverse completion of the knowledge graph is achieved. Improved the reliability of reasoning.

CN112434171BInactive Publication Date: 2024-09-24SUN YAT SEN UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202011345623.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-26
Publication Date
2024-09-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing knowledge graph representation learning models ignore the diversity of relationships between entities, resulting in poor knowledge graph reasoning completion effects.

Method used

Using a method based on reinforcement learning, entities and relationships are embedded into a low-dimensional vector space through the TranE model, and multiple reward functions (global reward, path efficiency reward, path diversity reward, and effective action reward) are designed to retrain the policy network. , find diverse and efficient relationship paths, and complete the knowledge graph.

Benefits of technology

Through the path finding and reward mechanism of the reinforcement learning model, the reliability and diversity of knowledge graph completion are improved, the validity and diversity of relationship paths are ensured, and the accuracy of reasoning is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112434171B
    Figure CN112434171B
Patent Text Reader

Abstract

The present invention discloses a method and system for knowledge graph reasoning and completion based on reinforcement learning, the method comprising: loading and parsing data to obtain vector representations of entities and relationships of the knowledge graph; embedding entities and relationships based on the TranE model and pre-training a pre-built policy network to obtain a pre-trained policy network; retraining the pre-trained policy network through multiple reward functions to obtain a trained policy network; inputting the knowledge graph to be tested into the trained policy network to complete the knowledge graph. The system comprises: a parsing module, a pre-training module, a retraining module and a completion module. The present invention makes the completed relational reasoning path more reliable and diverse by designing the reward function. As a method and system for knowledge graph reasoning and completion based on reinforcement learning, the present invention can be widely used in the field of knowledge graphs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of knowledge graphs, and in particular, relates to a knowledge graph reasoning and completion method and system based on reinforcement learning. Background Art

[0002] The knowledge graph is a large-scale semantic network, including entities, concepts and various semantic relations between them. Among them, the reinforcement learning method for knowledge graph reasoning is path-based reasoning. Through the reinforcement learning method, the path between two entities is inferred, that is, the set of relations between entities, so as to find a reliable prediction path between entity pairs and complete the knowledge graph. However, the current knowledge graph representation learning model ignores this aspect and lacks consideration of the diversity of relations between entities in the knowledge graph. Summary of the invention

[0003] In order to solve the above technical problems, the purpose of the present invention is to provide a knowledge graph reasoning and completion method and system based on reinforcement learning, which realizes the method of knowledge graph completion by taking the found relationship path as a feature to learn the target relationship.

[0004] The first technical solution adopted by the present invention is: a knowledge graph reasoning and completion method based on reinforcement learning, comprising the following steps:

[0005] Load and parse the data to obtain vector representations of entities and relationships in the knowledge graph;

[0006] Based on the TranE model, entities and relations are embedded and the pre-built policy network is pre-trained to obtain a pre-trained policy network.

[0007] Retrain the pre-trained policy network through multiple reward functions to obtain a trained policy network;

[0008] Input the knowledge graph to be tested into the trained strategy network to complete the knowledge graph.

[0009] Furthermore, the step of loading and parsing the data to obtain vector representations of entities and relationships of the knowledge graph specifically includes:

[0010] Load and parse the data to obtain triple data of the knowledge graph;

[0011] Encode and initialize the vector representations of entities and relations in the triple data of the knowledge graph.

[0012] Furthermore, after obtaining the trained policy network, the method further includes verifying the trained policy network and evaluating the completion effect of the policy network.

[0013] Furthermore, the step of embedding entities and relationships based on the TranE model and pre-training the pre-built policy network to obtain the pre-trained policy network specifically includes:

[0014] Embedding based on the TranE model maps the knowledge graph into a low-dimensional vector space;

[0015] A path finding method based on reinforcement learning finds the relationship path between entities;

[0016] For the relationship path, the Monte Carlo policy gradient is used to maximize the expected cumulative reward and update the policy network to obtain the pre-trained policy network.

[0017] Furthermore, the expression of using Monte Carlo policy gradient to maximize the expected cumulative reward and update the policy network is as follows:

[0018]

[0019] In the above formula, J(θ) is the expected total reward value, θ is the gradient, T is the total number of events in finding the path, and R(S T |e S ,r) is the corresponding reward value, π θ (a t |s t ) is the probability of action selection output by the policy network, e s is the head entity, r is the query relationship, a t is the current action, S t is the current status.

[0020] Furthermore, the multiple reward functions include a global reward function, a path efficiency reward function, a path diversity reward function and an effective action reward function.

[0021] Furthermore, the step of retraining the pre-trained policy network by using multiple reward functions to obtain a trained policy network specifically includes:

[0022] Give rewards based on the length of the found path through the global reward function and update the pre-trained policy network;

[0023] The path efficiency reward function is used to give rewards based on the efficiency of the found path and update the pre-trained strategy network.

[0024] The path diversity reward function is used to give rewards based on the similarity of the found paths and update the pre-trained strategy network;

[0025] Give rewards based on the effective actions of the found path through the effective action reward function, and update the pre-trained strategy network;

[0026] Get the trained policy network.

[0027] Furthermore, the input layer of the pre-constructed training network is an LSTM neural network, and the output layer is normalized by a softmax function and a REINFORCE algorithm gradient update strategy network.

[0028] The second technical solution adopted by the present invention is: a knowledge graph reasoning and completion system based on reinforcement learning, comprising the following modules:

[0029] The parsing module is used to load and parse the data to obtain the vector representation of entities and relationships in the knowledge graph;

[0030] The pre-training module embeds entities and relations based on the TranE model and pre-trains the pre-built policy network to obtain a pre-trained policy network;

[0031] A retraining module is used to retrain the pre-trained policy network through multiple reward functions to obtain a trained policy network;

[0032] The completion module is used to input the knowledge graph to be tested into the trained strategy network to complete the knowledge graph.

[0033] The beneficial effects of the method and system of the present invention are as follows: the present invention applies the technology in the field of reinforcement learning to knowledge graph reasoning and completion, designs a specific reward function and an algorithm for path finding, and adds LSTM and graph attention mechanisms on the basis of the reinforcement learning model. The relational path reasoning controlled by a specific reward function is more reliable and diverse. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 This is a flowchart of the steps of a knowledge graph reasoning and completion method based on reinforcement learning in a specific embodiment of the present invention;

[0035] Figure 2 It is a structural block diagram of a knowledge graph reasoning and completion system based on reinforcement learning in a specific embodiment of the present invention. DETAILED DESCRIPTION

[0036] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The step numbers in the following embodiments are only provided for the convenience of explanation and description, and the order between the steps is not limited in any way. The execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.

[0037] like Figure 1 As shown, the present invention provides a knowledge graph reasoning completion method based on reinforcement learning, which includes the following steps:

[0038] S1, load and parse the data to obtain the vector representation of entities and relationships in the knowledge graph;

[0039] S2, embed entities and relations based on the TranE model and pre-train the pre-built policy network to obtain a pre-trained policy network;

[0040] S3, retraining the pre-trained policy network through multiple reward functions to obtain a trained policy network;

[0041] S4. Input the knowledge graph to be tested into the trained strategy network to complete the knowledge graph.

[0042] As a further preferred embodiment of the method, the step of loading and parsing the data to obtain vector representations of entities and relationships of the knowledge graph specifically includes:

[0043] Load and parse the data to obtain triple data of the knowledge graph;

[0044] Encode and initialize the vector representations of entities and relations in the triple data of the knowledge graph.

[0045] Further as a preferred embodiment of the method, after obtaining the trained policy network, the step of verifying the trained policy network and evaluating the completion effect of the policy network is also included.

[0046] As a further preferred embodiment of the present invention, the step of embedding entities and relationships based on the TranE model and pre-training the pre-built policy network to obtain the pre-trained policy network specifically includes:

[0047] Embedding based on the TranE model maps the knowledge graph into a low-dimensional vector space;

[0048] A path finding method based on reinforcement learning finds the relationship path between entities;

[0049] For the relationship path, the Monte Carlo policy gradient is used to maximize the expected cumulative reward and update the policy network to obtain the pre-trained policy network.

[0050] Specifically, in order to capture the semantic information between entities and relations, the TranE model is used for embedding and mapping them into a low-dimensional vector space. In this framework, each state captures the position of the agent in the knowledge graph. After performing an action, the agent moves from one entity to another, and the two states are connected by the agent through the action just performed. The state vector of entity i at step t includes:

[0051] s i,t =[mi,t ;h t ; a i ]

[0052] In the above formula, m i,t It represents the entity embedding part, using TranE to embed entities and relations, h t is the hidden vector output by the LSTM neural network, responsible for recording historical information, a i It is the attention vector output by the graph attention neural network, representing the weights corresponding to the entities adjacent to entity i.

[0053] As a further preferred embodiment of the present invention, the expression of using the Monte Carlo policy gradient to maximize the expected cumulative reward and update the policy network is as follows:

[0054]

[0055] In the above formula, J(θ) is the expected total reward value, θ is the gradient, T is the total number of events in finding the path, and R(S T |e S ,r) is the corresponding reward value, π θ (a t |st) is the probability of action selection output by the policy network, e s is the head entity, r is the query relationship, a t is the current action, S t is the current status.

[0056] Specifically, for each relation, we first use a subset of all positive samples (entity pairs) to learn a supervised policy. For each positive sample, a two-ended BFS is used to find the correct path between entities.

[0057] Further as a preferred embodiment of the present invention, the multiple reward functions include a global reward function, a path efficiency reward function, a path diversity reward function and an effective action reward function.

[0058] Specifically, through reward retraining, in order to find the reasoning path controlled by the reward function, the reward function is used to constrain the supervised policy network. For each relationship, the reasoning of an entity pair is regarded as an episode. Starting from the source node, the agent selects a relationship according to a random policy, which is a probability distribution over all relationships, to extend the reasoning path. The relationship link may lead to a new entity or fail, and these failed steps will cause the agent to receive negative rewards.

[0059] As a further preferred embodiment of the method, the step of retraining the pre-trained policy network by using multiple reward functions to obtain a trained policy network specifically includes:

[0060] Give rewards based on the length of the found path through the global reward function and update the pre-trained policy network;

[0061] Specifically, for the current reinforcement learning environment, the number of actions that the agent can perform may be very large, and there are many more wrong sequential decisions than correct sequential decisions. The number of these wrong decision sequences will grow exponentially with the length of the path, so the global reward function is defined as follows:

[0062] r GLOBAL =+1

[0063] The path efficiency reward function is used to give rewards based on the efficiency of the found path and update the pre-trained strategy network.

[0064] Specifically, the second reward function is the path efficiency reward function. Short paths usually provide more reliable reasoning evidence than long paths, so the reward is defined as:

[0065]

[0066] The path diversity reward function is used to give rewards based on the similarity of the found paths and update the pre-trained strategy network;

[0067] Specifically, the third reward function is the path diversity reward function. In order to encourage the agent to find diverse paths, a diverse reward function is defined using the cosine similarity between the current path and the existing path:

[0068]

[0069] Give rewards based on the effective actions of the found path through the effective action reward function, and update the pre-trained strategy network;

[0070] Specifically, the fourth reward function is the effective action reward function. When the path search fails, the effective actions in the failed path are selected and rewarded by an algorithm:

[0071] r valid =+1

[0072] Get the trained policy network.

[0073] Specifically, one of the main features of this patent is the design of the reward function, which rewards the efficiency, length, and similarity of the path found, so that the found paths have diversity, the path finding rate, and the path length meet specific requirements.

[0074] As a further preferred embodiment of the method, the input layer of the pre-constructed training network is an LSTM neural network, and the output layer is normalized by a softmax function and a REINFORCE algorithm gradient update strategy network.

[0075] like Figure 2 As shown in the figure, a knowledge graph reasoning and completion system based on reinforcement learning includes the following modules:

[0076] The parsing module is used to load and parse the data to obtain the vector representation of entities and relationships in the knowledge graph;

[0077] The pre-training module embeds entities and relations based on the TranE model and pre-trains the pre-built policy network to obtain a pre-trained policy network;

[0078] A retraining module is used to retrain the pre-trained policy network through multiple reward functions to obtain a trained policy network;

[0079] The completion module is used to input the knowledge graph to be tested into the trained strategy network to complete the knowledge graph.

[0080] As a further preferred embodiment of the present system, the parsing module further includes the following submodules:

[0081] The loading submodule is used to load and parse the data to obtain the triple data of the knowledge graph;.

[0082] The initialization submodule is used to encode the entities and relations in the triple data of the knowledge graph and initialize the vector representation of the entities and relations.

[0083] As a further preferred embodiment of the present system, the pre-training module further includes the following sub-modules:

[0084] The embedding submodule embeds the knowledge graph into a low-dimensional vector space based on the TranE model.

[0085] The path finding submodule finds the relationship path between entities based on the path finding method of reinforcement learning;

[0086] Policy update submodule, for the relationship path, uses Monte Carlo policy gradient to maximize the expected cumulative reward and update the policy network to obtain the pre-trained policy network.

[0087] The contents of the above system embodiments are all applicable to the present method embodiments. The functions specifically implemented by the present method embodiments are the same as those of the above system embodiments, and the beneficial effects achieved are also the same as those achieved by the above system embodiments.

[0088] The above is a specific description of the preferred implementation of the present invention, but the invention is not limited to the embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.

Claims

1. A knowledge graph reasoning completion method based on reinforcement learning, It is characterized in that The following steps are involved: Load and parse the data to obtain vector representations of entities and relationships in the knowledge graph; Based on the TranE model, entities and relations are embedded and the pre-built policy network is pre-trained to obtain a pre-trained policy network. Retrain the pre-trained policy network through multiple reward functions to obtain a trained policy network; Input the knowledge graph to be tested into the trained strategy network to complete the knowledge graph; The multiple reward functions include a global reward function, a path efficiency reward function, a path diversity reward function and an effective action reward function; The step of retraining the pre-trained policy network by using multiple reward functions to obtain a trained policy network specifically includes: Give rewards based on the length of the found path through the global reward function and update the pre-trained policy network; The path efficiency reward function is used to give rewards based on the efficiency of the found path and update the pre-trained strategy network. The path diversity reward function is used to give rewards based on the similarity of the found paths and update the pre-trained strategy network; The formula of the path diversity reward function is as follows: Give rewards based on the effective actions of the found path through the effective action reward function, and update the pre-trained strategy network; Get the trained policy network.

2. According to the knowledge graph reasoning and completion method based on reinforcement learning according to claim 1, It is characterized in that The step of loading and parsing the data to obtain vector representations of entities and relationships in the knowledge graph specifically includes: Load and parse the data to obtain triple data of the knowledge graph; Encode and initialize the vector representations of entities and relations in the triple data of the knowledge graph.

3. According to the knowledge graph reasoning and completion method based on reinforcement learning as described in claim 2, It is characterized in that The step of obtaining the trained policy network also includes verifying the trained policy network and evaluating the completion effect of the policy network.

4. According to the knowledge graph reasoning and completion method based on reinforcement learning as claimed in claim 3, It is characterized in that The step of embedding entities and relationships based on the TranE model and pre-training the pre-built policy network to obtain the pre-trained policy network specifically includes: Embedding based on the TranE model maps the knowledge graph into a low-dimensional vector space; A path finding method based on reinforcement learning finds the relationship path between entities; For the relationship path, the Monte Carlo policy gradient is used to maximize the expected cumulative reward and update the policy network to obtain the pre-trained policy network.

5. According to the knowledge graph reasoning and completion method based on reinforcement learning according to claim 4, It is characterized in that The expression of using Monte Carlo policy gradient to maximize the expected cumulative reward and update the policy network is as follows: In the above formula, J(θ) is the expected total reward value, θ is the gradient, T is the total number of events in finding the path, and R(S T |e S ,r) is the corresponding reward value, π θ (a t |s t ) is the probability of action selection output by the policy network, e s is the head entity, r is the query relationship, a t is the current action, S t is the current status.

6. According to the knowledge graph reasoning and completion method based on reinforcement learning as claimed in claim 1, It is characterized in that The input layer of the pre-built policy network is an LSTM neural network, and the output layer is normalized by the softmax function and the REINFORCE algorithm gradient updates the policy network.

7. A knowledge graph reasoning and completion system based on reinforcement learning, It is characterized in that The method for performing the knowledge graph reasoning and completion method based on reinforcement learning as claimed in claim 1 comprises the following modules: The parsing module is used to load and parse the data to obtain the vector representation of entities and relationships in the knowledge graph; The pre-training module embeds entities and relations based on the TranE model and pre-trains the pre-built policy network to obtain a pre-trained policy network; A retraining module is used to retrain the pre-trained policy network through multiple reward functions to obtain a trained policy network; The completion module is used to input the knowledge graph to be tested into the trained strategy network to complete the knowledge graph.

Citation Information

Patent Citations

  • Regional industry association effect trend prediction method based on knowledge graph

    CN111104522A

  • Method for selecting reward function in adversarial imitation learning

    CN111401556A

  • Reinforced learning knowledge graph reasoning method and device based on graph convolutional neural network

    CN111581343A

  • Entity and relationship joint extraction method based on reinforcement learning

    CN111914091A

  • Multi-hop knowledge graph reasoning with reward shaping

    US20190362246A1