Knowledge graph completion method based on ant colony algorithm and related equipment

Through the knowledge graph completion method based on ant colony algorithm, the motion probability is calculated using entity and edge embedding vectors, and iterative reasoning is used to find the shortest path in the knowledge graph, which solves the problem of low computational efficiency and difficulty in finding the global optimal solution in the existing technology. The problem has improved the efficiency of knowledge graph completion.

CN114840682BActive Publication Date: 2025-01-03华润数字科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210403609.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-18
Publication Date
2025-01-03
Estimated Expiration
2042-04-18

Smart Images

  • Figure CN114840682B_ABST
    Figure CN114840682B_ABST
Patent Text Reader

Abstract

The embodiment of the present application belongs to the field of artificial intelligence technology, and relates to a knowledge graph completion method based on an ant colony algorithm and related equipment, including performing entity recognition operations on corpus documents to obtain entities, constructing a knowledge graph based on the entities, and the knowledge graph includes entity nodes and edge nodes; inputting the entity nodes and edge nodes into a vector conversion model to obtain entity embedding vectors and edge embedding vectors; based on the entity embedding vectors and edge embedding vectors, calculating the movement probability of the inference model from the current entity node to the next entity node, and iteratively reasoning the inference model according to the movement probability until a stop condition is reached; after iterative reasoning, determining the shortest path from the path passed by the inference model, judging whether the maximum number of iterations has been reached, and if so, completing the knowledge graph according to the shortest path to obtain the target knowledge graph. The present application improves the efficiency of completing the knowledge graph.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a knowledge graph completion method based on an ant colony algorithm and related equipment. Background Art

[0002] In recent years, knowledge graphs have been widely used in many fields such as finance, e-commerce, and medical care. However, the cost of building a knowledge graph is very high, and it is easy to have missing relationships between nodes. For example, in the famous knowledge graph Freebase, 66% of people are missing the relationship of birthplace. Therefore, knowledge graph entity completion (also called knowledge graph reasoning) is needed. Given a triple that needs to be completed in the knowledge graph <head entity h, relationship r,?>, it is necessary to search in the entire knowledge graph, and after passing through several intermediate entities, finally find the tail entity t that meets the requirements of relationship r, thus forming a complete triple.<h,r,t> .

[0003] The PRA (Path Ranking Algorithm) algorithm is currently a representative method for knowledge graph completion. The main idea of ​​the algorithm is: starting from a certain node, a random walk (a node connected to the previous node is selected at each step) is used to perform a depth-first search to obtain a candidate path, and the path connecting two entities is used as a feature to predict the relationship between the two entities. The learning phase is divided into three parts: feature extraction, feature calculation, and classifier construction. When the number of knowledge graph nodes is huge, the random walk method used by the PRA algorithm has low computational efficiency and poor results. Summary of the invention

[0004] The purpose of the embodiments of the present application is to propose a knowledge graph completion method based on ant colony algorithm and related equipment, so as to improve the efficiency of computer knowledge graph completion.

[0005] In order to solve the above technical problems, the embodiment of the present application provides a knowledge graph completion method based on ant colony algorithm, which adopts the following technical solution:

[0006] A knowledge graph completion method based on ant colony algorithm includes the following steps:

[0007] Receiving a corpus document, performing an entity recognition operation on the corpus document to obtain a plurality of entities, and constructing a knowledge graph based on the entities, wherein the knowledge graph includes entity nodes and edge nodes;

[0008] Inputting the entity node and the edge node into a pre-trained vector conversion model respectively, and obtaining output entity embedding vectors and edge embedding vectors respectively;

[0009] Based on the entity embedding vector and the edge embedding vector, the movement probability of the inference model from the current entity node to the next entity node is calculated, and the inference model starts from any entity node and performs iterative inference in the knowledge graph according to the corresponding movement probability until a preset stop condition is reached, thereby completing the current iterative inference;

[0010] After each iterative reasoning, the shortest path is determined from all the paths passed by the reasoning model, and it is determined whether the maximum number of iterations has been reached. If not, the iterative reasoning is continued until the maximum number of iterations is reached. If so, the knowledge graph is completed according to the shortest path to obtain the target knowledge graph.

[0011] Furthermore, the step of determining the shortest path from the paths passed by all the inference models includes:

[0012] The semantic distance of the total path passed by each of the inference models is calculated, and the total path with the smallest semantic distance is taken as the shortest path.

[0013] Furthermore, the step of calculating the movement probability of the inference model from the current entity node to the next entity node based on the entity embedding vector and the edge embedding vector includes:

[0014] Calculating the semantic distance between the entity nodes based on the entity embedding vector and the edge embedding vector, and calculating the residual strength of the pheromone of the edge between the entity nodes;

[0015] The movement probability is calculated according to the semantic distance and the residual strength of the pheromone.

[0016] Furthermore, the step of calculating the residual strength of the pheromone of the edge between the entity nodes includes:

[0017] Calculate the increment of pheromone contributed by each inference model to the edges between entity nodes after one iterative inference.

[0018] Calculate the residual strength of the pheromone of each of the reasoning models on the edge between the entity nodes according to the increment of the pheromone as the residual strength of the pheromone of a single model;

[0019] The residual strength of the single model pheromone corresponding to each edge is summed up respectively to obtain the residual strength of the pheromone.

[0020] Furthermore, the single model pheromone residual intensity is calculated according to the following formula:

[0021] in, After the t+1th iteration reasoning, the edge e between the entity node i and the entity node j ij The residual strength of the single model pheromone, ρ is the preset parameter, After one round of iterative reasoning, a reasoning model calculates the edge e between entity node i and entity node j. ij The increase in the contribution of pheromones, After the tth iteration reasoning, the edge e between the entity node i and the entity node j ij Single model pheromone residual intensity.

[0022] Furthermore, the step of calculating the movement probability according to the semantic distance and the residual strength of the pheromone includes:

[0023] The motion probability is calculated according to the following formula:

[0024]

[0025] in, is the motion probability, AllowedNodes is a set of entity nodes that are not in the preset taboo table, and the taboo table stores the entity nodes that each of the inference models has passed through, τ ij (t) is the edge e between entity node i and entity node j ij The residual strength of the pheromone on ij is the inverse of the semantic distance between entity node i and entity node j, and α and β are preset parameters.

[0026] Furthermore, after the step of inputting the entity node and the edge node into the pre-trained vector conversion model to obtain the output entity embedding vector and edge embedding vector respectively, the method further includes:

[0027] Calculate the semantic distance between entity nodes based on the entity embedding vector and the edge embedding vector;

[0028] Determine a neighbor node of each of the entity nodes according to a preset area of ​​interest and the semantic distance;

[0029] The step of completing the current iterative reasoning until the preset stop condition is reached includes:

[0030] Until the length of the formed path is equal to the number of adjacent nodes of the starting node or the movement probability is 0, the current iterative reasoning is completed.

[0031] In order to solve the above technical problems, the embodiment of the present application also provides a knowledge graph completion method device based on ant colony algorithm, which adopts the following technical solution:

[0032] A knowledge graph completion method and device based on ant colony algorithm, comprising:

[0033] A receiving module, used to receive a corpus document, perform entity recognition operation on the corpus document, obtain multiple entities, and construct a knowledge graph based on the entities, wherein the knowledge graph includes entity nodes and edge nodes;

[0034] An input module, used to input the entity node and the edge node into a pre-trained vector conversion model, respectively, to obtain output entity embedding vectors and edge embedding vectors, respectively;

[0035] A calculation module, used to calculate the movement probability of the reasoning model from the current entity node to the next entity node based on the entity embedding vector and the edge embedding vector, and to iteratively reason the reasoning model from any entity node according to the corresponding movement probability in the knowledge graph until a preset stop condition is reached to complete the current iterative reasoning;

[0036] The judgment module is used to determine the shortest path from all the paths passed by the reasoning model after each iterative reasoning, and to judge whether the maximum number of iterations has been reached. If not, the iterative reasoning is continued until the maximum number of iterations is reached. If so, the knowledge graph is completed according to the shortest path to obtain the target knowledge graph.

[0037] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0038] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the above-mentioned knowledge graph completion method based on ant colony algorithm are implemented.

[0039] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0040] A computer-readable storage medium having computer-readable instructions stored thereon, wherein the computer-readable instructions, when executed by a processor, implement the steps of the above-mentioned knowledge graph completion method based on ant colony algorithm.

[0041] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0042] This application constructs a knowledge graph and abstracts the completion task in the knowledge graph into the task of ants finding the best path in the ant colony algorithm. The motion probability is calculated, and multiple reasoning models are iteratively reasoned in the knowledge graph according to the corresponding motion probability, and then the shortest path is determined. The relationship between the missing entities in the knowledge graph is discovered based on the shortest path. The method of this application is easier to find the global optimal solution than the existing method, which improves the search efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0044] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0045] Figure 2 is a flowchart of an embodiment of a knowledge graph completion method based on ant colony algorithm according to the present application;

[0046] Figure 3 It is a structural schematic diagram of an embodiment of a knowledge graph completion method device based on ant colony algorithm according to the present application;

[0047] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application.

[0048] Attached figures: 200, computer equipment; 201, memory; 202, processor; 203, network interface; 300, knowledge graph completion method device based on ant colony algorithm; 301, receiving module; 302, input module; 303, calculation module; 304, judgment module. DETAILED DESCRIPTION

[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0050] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0051] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0052] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, 103, network 104 and server 105. Network 104 is used to provide a medium for communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0053] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Terminal devices 101, 102, 103 can be installed with various communication client applications, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0054] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.

[0055] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0056] It should be noted that the knowledge graph completion method based on ant colony algorithm provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the knowledge graph completion method device based on ant colony algorithm is generally set in the server / terminal device.

[0057] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0058] Continue to refer Figure 2 , shows a flow chart of an embodiment of a knowledge graph completion method based on an ant colony algorithm according to the present application. The knowledge graph completion method based on an ant colony algorithm comprises the following steps:

[0059] S1: receiving a corpus document, performing entity recognition operation on the corpus document to obtain multiple entities, and constructing a knowledge graph based on the entities, wherein the knowledge graph includes entity nodes and edge nodes;

[0060] In this embodiment, the construction of the knowledge graph is as follows: a corpus document Di is received, and the i-th sentence in Di is set to xi. Named entity recognition technology is used to identify entities in the document. A knowledge graph is constructed based on the entities. A knowledge graph G is constructed, where the set of all entity nodes in G is E, and the set of all edge nodes is R.

[0061] It should be noted that the above-mentioned named entity recognition technology is relatively mature. The present invention does not limit the specific method, and a model based on the Bi-LSTM+CRF algorithm or a Bert pre-training model can be used.

[0062] The ant colony algorithm parameter definition of this application is: the inference model forms a program for executing the ant colony algorithm, and multiple inference models work simultaneously.

[0063] Ant Colony Optimization (ACO) is a probabilistic algorithm used to find optimized paths in a graph. The algorithm has many excellent properties: (1) It uses a positive feedback mechanism to make the search process converge continuously and eventually approach the optimal solution; (2) Each individual can change the surrounding environment by releasing pheromones, and each individual can perceive the real-time changes of the surrounding environment, and individuals communicate indirectly through the environment; (3) The search process uses a distributed computing method, and multiple individuals perform parallel computing at the same time, and the algorithm has high computing power and operating efficiency; (4) The heuristic probabilistic search method is not easy to fall into the local optimum and is easy to find the global optimal solution.

[0064] In this embodiment, the knowledge graph completion method based on the ant colony algorithm is run on the electronic device (for example Figure 1The server / terminal device shown in the figure can receive the corpus document through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0065] S2: Input the entity node and the edge node into a pre-trained vector conversion model respectively, and obtain output entity embedding vectors and edge embedding vectors respectively.

[0066] In this embodiment, for all entity nodes and edge nodes, TransE and its subsequent improved methods or Bert model commonly used in this field are used to obtain respective entity embedding vectors and edge embedding vectors.

[0067] Specifically, after the step of inputting the entity node and the edge node into the pre-trained vector conversion model respectively to obtain the output entity embedding vector and edge embedding vector respectively, the method further includes:

[0068] Calculate the semantic distance between entity nodes based on the entity embedding vector and the edge embedding vector;

[0069] Determine a neighbor node of each of the entity nodes according to a preset area of ​​interest and the semantic distance;

[0070] The step of completing the current iterative reasoning until the preset stop condition is reached includes:

[0071] Until the length of the formed path is equal to the number of adjacent nodes of the starting node or the movement probability is 0, the current iterative reasoning is completed.

[0072] In this embodiment, the preset stopping condition is: the length of the formed path is equal to the number of adjacent nodes of the starting node or the movement probability is 0. After stopping, a feasible path is formed. Neighbor entity discovery: All entity nodes and edge nodes in the knowledge graph G are input into the Bert model, which outputs the entity embedding vector and edge embedding vector corresponding to the node. Without loss of generality, for any entity node E i , initially specify a semantic distance as the radius to form an area of ​​interest (AOI). iNodes with direct connections are the neighbor nodes of Ei. The role of neighbor nodes in reasoning is only used to limit the maximum length of each path in the future. Specifically: set the maximum length of each path (i.e. Pmax) to prevent infinite search. Stop when Pmax is equal to the number of neighbor nodes in the AOI (i.e. area of ​​interest). The length of the path traversed is added by 1 when an edge is traversed.

[0073] The step of calculating the semantic distance between entity nodes based on the entity embedding vector and the edge embedding vector comprises:

[0074] The semantic distance is calculated according to the following formula:

[0075] Ds(E i , E j )=sim(E i , E j )×sim(∑R Ei ,∑R Ej ), where E i 、E j is the entity node, Ds(E i , E j ) is the semantic distance, sim is the cosine similarity, ∑R Ei For E i The sum of the edge embedding vectors of all connected edges, ∑R Ej For E j The sum of the edge embedding vectors of all connected edges.

[0076] In this embodiment, Ds(E i , E j ) is the entity node E i and E j The semantic distance between sim(E i , E j ) is the cosine similarity of the entity embedding vectors of two entity nodes, ∑R Ei For E i The sum of the edge embedding vectors of all connected edges.

[0077] S3: Based on the entity embedding vector and the edge embedding vector, calculate the movement probability of the reasoning model from the current entity node to the next entity node, start the reasoning model from any entity node, and perform iterative reasoning in the knowledge graph according to the corresponding movement probability until the preset stop condition is reached, completing the current iterative reasoning.

[0078] In this embodiment, all entity nodes that are directly connected to the current entity node are used as the next entity node. The step of iteratively reasoning the inference model in the knowledge graph according to the corresponding motion probability includes: under the constraint of a preset taboo table, iteratively reasoning the inference model in the knowledge graph according to the corresponding motion probability, wherein the taboo table stores the entity nodes that each inference model has passed through. The passed path cannot return to the starting point, which will form a closed loop. The taboo table stores the passed path and is used to constrain the selection of nodes.

[0079] Specifically, the step of calculating the movement probability of the inference model from the current entity node to the next entity node based on the entity embedding vector and the edge embedding vector includes:

[0080] Calculating the semantic distance between the entity nodes based on the entity embedding vector and the edge embedding vector, and calculating the residual strength of the pheromone of the edge between the entity nodes;

[0081] The movement probability is calculated according to the semantic distance and the residual strength of the pheromone.

[0082] In this embodiment, the motion probability is calculated by the semantic distance and the residual strength of the pheromone.

[0083] The step of calculating the residual strength of the pheromone of the edge between the entity nodes comprises:

[0084] Calculate the increment of pheromone contributed by each inference model to the edges between entity nodes after one iterative inference.

[0085] Calculate the residual strength of the pheromone of each of the reasoning models on the edge between the entity nodes according to the increment of the pheromone as the residual strength of the pheromone of a single model;

[0086] The residual strength of the single model pheromone corresponding to each edge is summed up respectively to obtain the residual strength of the pheromone.

[0087] In this embodiment, τ ij (t): After the tth iteration, the edge e between entity node i and entity node j in the knowledge graph ij The residual intensity of the pheromone above is a two-dimensional array, and the initial value of the elements of the two-dimensional array is 0. Among them, e ij Refers to the edge node between entity node i and entity node j. The residual strength of the single model pheromone corresponding to each edge is summed up to obtain τ ij (t) (i.e., the residual intensity of pheromone).

[0088] Furthermore, the single model pheromone residual intensity is calculated according to the following formula:

[0089] in, After the t+1th iteration reasoning, the edge e between the entity node i and the entity node j ij The residual strength of the single model pheromone, ρ is the preset parameter, After one round of iterative reasoning, a reasoning model calculates the edge e between entity node i and entity node j. ij The increase in the contribution of pheromones, After the tth iteration reasoning, the edge e between the entity node i and the entity node j ij Single model pheromone residual intensity.

[0090] In this embodiment, from the tth to the t+1th iteration, the pheromone update is performed in the following manner:

[0091] When a reasoning model passes through entity node i and entity node j, it calculates the edge e between them. ij The contribution increment is Q is the total amount of pheromone information, L k is the total length of the path that the inference model passes through in this iteration (the total length of the path refers to the number of edges of the knowledge graph passed through). That is, we can know that in one reasoning, the increment of pheromone corresponding to each edge passed by the inference model is the same.

[0092]

[0093] Among them, Δτ ij Indicates that after one iteration e ij The increase of pheromones. Represents the inference model k for edge e in the knowledge graph after one inference ij The increment of pheromone contribution.

[0094] ρ: Pheromone residual coefficient. Since the amount of information released by the inference model will gradually evaporate over time, the pheromone on the path cannot increase infinitely. If the coefficient is too small, the global search ability of the algorithm will be reduced. If it is too large, the algorithm will easily fall into the local optimum and affect the global search ability. It is usually set to [0.1, 0.99].

[0095] Δτ ij :After one iteration, e ij The increase of pheromones. After one round of reasoning, the inference model k is used to calculate the edge e in the knowledge graph. ijThe contribution of pheromones.

[0096] Q: Total pheromone information, which is the total amount of pheromone released to the path after one round of iteration of the inference model, usually takes the value [10, 1000].

[0097] m: The total number of inference models. In each iterative inference, each path taken by each inference model is a candidate solution. The m paths taken by m inference models after one round of iteration are a solution subset.

[0098] In addition, the step of calculating the movement probability according to the semantic distance and the residual strength of the pheromone includes:

[0099] The motion probability is calculated according to the following formula:

[0100]

[0101] in, is the motion probability, AllowedNodes is a set of entity nodes that are not in the preset taboo table, and the taboo table stores the entity nodes that each of the inference models has passed through, τ ij (t) is the edge e between entity node i and entity node j ij The residual strength of the pheromone on ij is the inverse of the semantic distance between entity node i and entity node j, and α and β are preset parameters.

[0102] In this embodiment, n ij : The visibility between entity nodes i and j reflects the degree of inspiration transferred from entity node i to entity node j. Visibility is the inverse of the semantic distance between the two.

[0103] α: Information heuristic factor, with a value of [0, 5], which reflects the degree of randomness of the pheromone accumulated on the edge between two entity nodes in guiding the reasoning model to select entity nodes when the reasoning model moves from one entity node to another. α is a custom randomization parameter.

[0104] β: Expected value heuristic factor, with values ​​of [0, 5], reflecting the relative importance of the expected value in guiding the search of the inference model program when the inference model transfers from one entity node to another. Its size reflects the strength of the a priori, deterministic and other factors of the inference model program in the path search. β is a custom randomization parameter.

[0105] The inference model k determines the movement probability from the current entity node to the next entity node, where the next entity node is all nodes connected to the current node by edges.

[0106] tabu(k): Taboo table, used to store entity nodes that have been passed by the kth reasoning model. AllowedNodes is the set of entity nodes that are not in the taboo table.

[0107] It should be noted that after each iterative reasoning is completed, the pheromone on the path passed by each reasoning model needs to be updated to facilitate the calculation of the residual strength of the pheromone in the next iterative reasoning.

[0108] S4: After each iterative reasoning, determine the shortest path from all the paths passed by the reasoning model, and judge whether the maximum number of iterations is reached. If not, continue the iterative reasoning until the maximum number of iterations is reached. If so, complete the knowledge graph according to the shortest path to obtain the target knowledge graph.

[0109] In this embodiment, the specific steps of completing the knowledge graph according to the shortest path include: determining the starting entity node and the last entity node of the shortest path. The relationship between the last entity node and the penultimate entity node is used as the target edge relationship, and the target edge relationship is used as the relationship between the starting entity node and the last entity node, thereby supplementing the knowledge graph and obtaining the target knowledge graph. In this application, there was originally no edge between the first node and the last node in the shortest path. This application establishes an edge through the shortest path, and the relationship on the edge is the relationship between the penultimate entity node and the last entity node. For example: assuming that the path is: <Wang XX-colleague->Zhang XX, <Zhang XX-subordinate-Zheng XX>,..., <Zhao XX-works in-the United States>, and finally a new edge <Wang XX-works in-the United States> can be formed, the knowledge graph is completed, and the target knowledge graph is obtained.

[0110] The step of determining the shortest path from among all the paths passed by the inference models includes:

[0111] The semantic distance of the total path passed by each of the inference models is calculated, and the total path with the smallest semantic distance is taken as the shortest path.

[0112] In this embodiment, the total path with the smallest semantic distance (ie, the smallest edge weight) is taken as the shortest path.

[0113] When the present application is applied to the medical field, the initial training corpus is medical-related training corpus, and the vector conversion model is trained by the medical-related training corpus to obtain a pre-trained vector conversion model. In actual application, a medical-related corpus document is received as the corpus document of the present application, and subsequent knowledge graph completion is performed according to the above process to obtain a medical knowledge graph. The medical knowledge graph can be applied to various aspects related to medical treatment, such as the diagnosis of the condition, recommending departments to patients, etc., and the medical knowledge graph can be used.

[0114] This application constructs a knowledge graph and abstracts the completion task in the knowledge graph into the task of ants finding the best path in the ant colony algorithm. The motion probability is calculated, and multiple reasoning models are iteratively reasoned in the knowledge graph according to the corresponding motion probability, and then the shortest path is determined. The relationship between the missing entities in the knowledge graph is discovered based on the shortest path. The method of this application is easier to find the global optimal solution than the existing method, which improves the search efficiency.

[0115] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0116] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0117] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. The aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0118] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0119] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a knowledge graph completion method device based on an ant colony algorithm. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0120] like Figure 3 As shown, the knowledge graph completion method device 300 based on ant colony algorithm described in this embodiment includes: a receiving module 301, an input module 302, a calculation module 303 and a judgment module 304. Among them: A receiving module 301 is used to receive a corpus document, perform entity recognition operations on the corpus document, obtain multiple entities, and construct a knowledge graph based on the entities, wherein the knowledge graph includes entity nodes and edge nodes; an input module 302 is used to input the entity node and the edge node into a pre-trained vector conversion model, respectively, to obtain output entity embedding vectors and edge embedding vectors, respectively; a calculation module 303 is used to calculate the movement probability of the inference model from the current entity node to the next entity node based on the entity embedding vector and the edge embedding vector, and start the inference model from any entity node, and perform iterative inference in the knowledge graph according to the corresponding movement probability until a preset stop condition is reached to complete the current iterative inference; a judgment module 304 is used to determine the shortest path from all the paths passed by the inference model after each iterative inference, and judge whether the maximum number of iterations has been reached. If not, continue the iterative inference until the maximum number of iterations has been reached. If so, complete the knowledge graph according to the shortest path to obtain the target knowledge graph.

[0121] In this embodiment, the present application constructs a knowledge graph and abstracts the completion task in the knowledge graph into the task of ants finding the best path in the ant colony algorithm. The motion probability is calculated, and multiple reasoning models are iteratively reasoned in the knowledge graph according to the corresponding motion probability, and then the shortest path is determined. The relationship between the missing entities in the knowledge graph is discovered based on the shortest path. The method of the present application is easier to find the global optimal solution than the existing method, and the search efficiency is improved.

[0122] In some optional implementations of this embodiment, the above-mentioned device 300 also includes: a semantic distance calculation module and an adjacent node determination module, the semantic distance calculation module is used to calculate the semantic distance between entity nodes based on the entity embedding vector and the edge embedding vector. The adjacent node determination module is used to determine the neighboring nodes of each of the entity nodes according to the preset area of ​​interest and the semantic distance. The calculation module 303 is further used to complete the current iterative reasoning until the length of the formed path is equal to the number of adjacent nodes of the starting node or the motion probability is 0.

[0123] The semantic distance calculation module is further used to calculate the semantic distance according to the following formula:

[0124] Ds(E i , E j )=sim(E i , E j )×sim(∑R Ei ,∑R Ej ), where E i 、E j is the entity node, Ds(E i , E j ) is the semantic distance, sim is the cosine similarity, ∑R Ei For E i The sum of the edge embedding vectors of all connected edges, ∑R Ej For E j The sum of the edge embedding vectors of all connected edges.

[0125] The calculation module 303 includes a first calculation submodule and a second calculation submodule, wherein the first calculation submodule is used to calculate the semantic distance between the entity nodes based on the entity embedding vector and the edge embedding vector, and calculate the residual strength of the pheromone of the edge between the entity nodes; the second calculation submodule is used to calculate the motion probability according to the semantic distance and the residual strength of the pheromone.

[0126] The first calculation submodule includes a first calculation unit, a second calculation unit and a third calculation unit, wherein the first calculation unit is used to calculate the increment of pheromone contributed by each inference model to the edges between entity nodes after one iterative reasoning; the second calculation unit is used to calculate the residual strength of the pheromone of each inference model to the edges between entity nodes according to the increment of the pheromone as the single model pheromone residual strength; the third calculation unit is used to sum the single model pheromone residual strength corresponding to each edge respectively to obtain the residual strength of the pheromone.

[0127] The second calculation unit is further used to calculate the residual strength of the single model pheromone according to the following formula:

[0128] in, After the t+1th iteration reasoning, the edge e between the entity node i and the entity node j ij The residual strength of the single model pheromone, ρ is the preset parameter, After one round of iterative reasoning, a reasoning model calculates the edge e between entity node i and entity node j. ij The increase in the contribution of pheromones, After the tth iteration reasoning, the edge e between the entity node i and the entity node j ij Single model pheromone residual intensity.

[0129] In some optional implementations of this embodiment, the second calculation submodule is further configured to calculate the motion probability according to the following formula:

[0130]

[0131] in, is the motion probability, AllowedNodes is a set of entity nodes that are not in the preset taboo table, and the taboo table stores the entity nodes that each of the inference models has passed through, τ ij (t) is the edge e between entity node i and entity node j ij The residual strength of the pheromone on ij is the inverse of the semantic distance between entity node i and entity node j, and α and β are preset parameters.

[0132] In some optional implementations of this embodiment, the judgment module 304 is further used to calculate the semantic distance of the total path passed by each of the inference models, and take the total path with the smallest semantic distance as the shortest path.

[0133] This application constructs a knowledge graph and abstracts the completion task in the knowledge graph into the task of ants finding the best path in the ant colony algorithm. The motion probability is calculated, and multiple reasoning models are iteratively reasoned in the knowledge graph according to the corresponding motion probability, and then the shortest path is determined. The relationship between the missing entities in the knowledge graph is discovered based on the shortest path. The method of this application is easier to find the global optimal solution than the existing method, which improves the search efficiency.

[0134] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0135] The computer device 200 includes a memory 201, a processor 202, and a network interface 203 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 200 having components 201-203, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASlC), programmable gate arrays (Field--Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0136] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0137] The memory 201 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 201 can be an internal storage unit of the computer device 200, such as a hard disk or memory of the computer device 200. In other embodiments, the memory 201 can also be an external storage device of the computer device 200, such as a plug-in hard disk equipped on the computer device 200, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 201 can also include both the internal storage unit of the computer device 200 and its external storage device. In this embodiment, the memory 201 is generally used to store the operating system and various application software installed on the computer device 200, such as computer-readable instructions of the knowledge graph completion method based on the ant colony algorithm. In addition, the memory 201 can also be used to temporarily store various data that have been output or are to be output.

[0138] The processor 202 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 202 is generally used to control the overall operation of the computer device 200. In this embodiment, the processor 202 is used to run the computer-readable instructions stored in the memory 201 or process data, such as computer-readable instructions for running the knowledge graph completion method based on the ant colony algorithm.

[0139] The network interface 203 may include a wireless network interface or a wired network interface. The network interface 203 is generally used to establish a communication connection between the computer device 200 and other electronic devices.

[0140] The present application also provides another implementation, namely, providing a computer-readable storage medium, which stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the knowledge graph completion method based on ant colony algorithm as described above.

[0141] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0142] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A knowledge graph completion method based on ant colony algorithm, characterized in that: The steps include: Receiving a corpus document, performing an entity recognition operation on the corpus document to obtain a plurality of entities, and constructing a knowledge graph based on the entities, wherein the knowledge graph includes entity nodes and edge nodes; Inputting the entity node and the edge node into a pre-trained vector conversion model respectively, and obtaining output entity embedding vectors and edge embedding vectors respectively; Based on the entity embedding vector and the edge embedding vector, the movement probability of the inference model from the current entity node to the next entity node is calculated, and the inference model is started from any entity node, and iterative inference is performed in the knowledge graph according to the corresponding movement probability until the preset stop condition is reached, and the current iterative inference is completed; After each iterative reasoning, the shortest path is determined from all the paths passed by the reasoning model, and it is determined whether the maximum number of iterations has been reached. If not, the iterative reasoning is continued until the maximum number of iterations has been reached. If so, the knowledge graph is completed according to the shortest path to obtain the target knowledge graph; After the step of inputting the entity node and the edge node into the pre-trained vector conversion model to obtain the output entity embedding vector and edge embedding vector respectively, the method further includes: Calculate the semantic distance between entity nodes based on the entity embedding vector and the edge embedding vector; Determine a neighbor node of each of the entity nodes according to a preset region of interest and the semantic distance; The step of completing the current iterative reasoning until the preset stop condition is reached includes: Until the length of the formed path is equal to the number of adjacent nodes of the starting node or the movement probability is 0, the current iterative reasoning is completed.

2. The knowledge graph completion method based on ant colony algorithm according to claim 1 is characterized in that: The step of determining the shortest path from the paths passed by all the inference models comprises: The semantic distance of the total path passed by each of the inference models is calculated, and the total path with the smallest semantic distance is taken as the shortest path.

3. The knowledge graph completion method based on ant colony algorithm according to claim 1 is characterized in that: The step of calculating the movement probability of the inference model from the current entity node to the next entity node based on the entity embedding vector and the edge embedding vector comprises: Calculating the semantic distance between the entity nodes based on the entity embedding vector and the edge embedding vector, and calculating the residual strength of the pheromone of the edge between the entity nodes; The movement probability is calculated according to the semantic distance and the residual strength of the pheromone.

4. The knowledge graph completion method based on ant colony algorithm according to claim 3 is characterized in that: The step of calculating the residual strength of the pheromone of the edge between the entity nodes comprises: Calculate the increment of pheromone contributed by each inference model to the edges between entity nodes after one iterative inference. Calculate the residual strength of the pheromone of each of the reasoning models on the edge between the entity nodes according to the increment of the pheromone as the residual strength of the pheromone of a single model; The residual strength of the single model pheromone corresponding to each edge is summed up respectively to obtain the residual strength of the pheromone.

5. The knowledge graph completion method based on ant colony algorithm according to claim 4 is characterized in that: The single model pheromone residual intensity is calculated according to the following formula: ,in, After the t+1th iteration reasoning, the edge between the entity node i and the entity node j The single model pheromone residual strength, is the preset parameter, After one round of iterative reasoning, a reasoning model calculates the edge between entity node i and entity node j. The increase in the contribution of pheromones, After the tth iteration reasoning, the edge between the entity node i and the entity node j Single model pheromone residual intensity.

6. The knowledge graph completion method based on ant colony algorithm according to claim 3 is characterized in that: The step of calculating the movement probability according to the semantic distance and the residual strength of the pheromone comprises: The motion probability is calculated according to the following formula: ; in, is the motion probability, is a set of entity nodes that are not in a preset taboo table, wherein the taboo table stores entity nodes that each of the inference models has passed through respectively, is the edge between entity node i and entity node j The residual strength of pheromones on is the inverse of the semantic distance between entity node i and entity node j, and They are preset parameters respectively.

7. A knowledge graph completion method and device based on ant colony algorithm, characterized in that: include: A receiving module, used to receive a corpus document, perform entity recognition operation on the corpus document, obtain multiple entities, and construct a knowledge graph based on the entities, wherein the knowledge graph includes entity nodes and edge nodes; An input module, used to input the entity node and the edge node into a pre-trained vector conversion model, respectively, to obtain output entity embedding vectors and edge embedding vectors, respectively; A calculation module, used to calculate the movement probability of the reasoning model from the current entity node to the next entity node based on the entity embedding vector and the edge embedding vector, and to iteratively reason the reasoning model from any entity node according to the corresponding movement probability in the knowledge graph until a preset stop condition is reached to complete the current iterative reasoning; A judgment module, used to determine the shortest path from all the paths passed by the reasoning model after each iterative reasoning, and judge whether the maximum number of iterations has been reached. If not, continue the iterative reasoning until the maximum number of iterations has been reached. If so, complete the knowledge graph according to the shortest path to obtain the target knowledge graph; The knowledge graph completion method device based on ant colony algorithm also includes a semantic distance calculation module and an adjacent node determination module, wherein: The semantic distance calculation module is used to calculate the semantic distance between entity nodes based on the entity embedding vector and the edge embedding vector; The adjacent node determination module is used to determine the neighboring nodes of each of the entity nodes according to the preset interest area and the semantic distance; The calculation module is further used to complete the current iterative reasoning until the length of the formed path is equal to the number of adjacent nodes of the starting node or the movement probability is 0.

8. A computer device, characterized in that: It includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, it implements the steps of the knowledge graph completion method based on ant colony algorithm as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the knowledge graph completion method based on an ant colony algorithm as described in any one of claims 1 to 6.