Knowledge graph completion method, device, equipment and medium
By performing vector fusion and matrix calculation on the target nodes and relationships in the knowledge graph, and screening candidate and valid nodes, the low efficiency problem in the existing technology is solved, and efficient and accurate completion of the knowledge graph is achieved.
Patent Information
- Application Number
- CN202210506083.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2042-05-10
AI Technical Summary
Existing knowledge graph completion methods are inefficient and have high barriers to entry, especially in the process of completing node relationships in the economic field, which is difficult to complete efficiently and accurately.
By obtaining the target nodes and relationships in the knowledge graph to be completed, performing vector fusion and matrix calculation, and using segmented reasoning of node matching and relationship matching, candidate nodes and valid nodes are screened out to complete the knowledge graph.
It improves the accuracy and efficiency of knowledge graph completion, ensures the comprehensiveness of node relationship completion, and avoids the low efficiency of manual combing in traditional methods.
Smart Images

Figure CN114780689B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of communications, and more specifically, to a knowledge graph completion method, apparatus, computer device, and computer-readable storage medium. Background Art
[0002] A knowledge graph is a semantic network formed by a large number of entities and their relationships. Its purpose is to build a database of structured information. It represents concrete things in the world (such as proper nouns like names of people, places, and organizations) and abstract concepts as entities, and the interactions and connections between entities as relationships. The relationships between entities form a large graph, with entities as nodes and relationships as edges.
[0003] Whether there is a relationship between multiple different entities becomes a prerequisite for the further application of the knowledge graph, and therefore it is necessary to provide a knowledge graph completion mechanism that can support reasoning about unknown information on the knowledge graph. Summary of the Invention
[0004] In order to solve the above technical problems, the embodiments of the present application provide a knowledge graph completion method, apparatus, computer equipment and computer-readable storage medium to improve the efficiency of knowledge graph completion.
[0005] In a first aspect, the present application provides a knowledge graph completion method, including: obtaining a knowledge graph to be completed, wherein the knowledge graph to be completed includes a target node, a target relationship, and a pre-identified node; fusing the target node vector of the target node and the target relationship vector of the target relationship to obtain a fusion vector; and fusing the pre-identified node vector of each pre-identified node to obtain a pre-identified node fusion matrix; calculating the node matching degree between the target node and the pre-identified node based on the fusion vector and the pre-identified node fusion matrix, and taking the pre-identified nodes whose node matching degree meets the preset requirements as candidate nodes; fusing the candidate node vectors of each candidate node to obtain a candidate node fusion matrix; calculating the relationship matching degree between the target node and the candidate node based on the fusion vector and the candidate node fusion matrix, and taking the candidate nodes whose relationship matching degree meets the preset requirements as valid nodes; and taking the target relationship as the relationship between the target node and the valid node to complete the knowledge graph to be completed.
[0006] According to a preferred embodiment of the present invention, before fusing the target node vector of the target node and the target relationship vector of the target relationship, the method further includes: obtaining the node attribute information and node type information of the target node; performing vector conversion processing on each character and the position of each character in the node attribute information and the node type information to obtain a node attribute vector and a node type vector; and fusing the node attribute vector and the node type vector to obtain a target node vector.
[0007] According to a preferred embodiment of the present invention, after fusing the node attribute vector and the node type vector to obtain the target node vector, it also includes: obtaining the adjacency matrix and degree matrix corresponding to the target node; performing convolution processing on the target node vector according to the adjacency matrix and the degree matrix to obtain the convolved target node vector; and using the convolved target node vector as the target node vector of the target node.
[0008] According to a preferred embodiment of the present invention, the pre-identification node vectors of each pre-identification node are fused to obtain a pre-identification node fusion matrix, including: obtaining a weight coefficient of each pre-identification node, and performing weighted calculation on the pre-identification node vector of each pre-identification node according to the weight coefficient; splicing each pre-identification node vector after the weighted calculation to obtain an N-dimensional pre-identification node fusion matrix; wherein N is the number of pre-identification nodes.
[0009] According to a preferred embodiment of the present invention, the node matching degree between the target node and the pre-identified nodes is calculated based on the fusion vector and the pre-identified node fusion matrix, including: mapping the fusion vector to the pre-identified node fusion matrix to obtain the node matching score of the target node for each pre-identified node; normalizing the node matching score to obtain the node matching degree of the target node for each pre-identified node.
[0010] According to a preferred embodiment of the present invention, the candidate node vectors of each candidate node are fused to obtain a candidate node fusion matrix, including: obtaining a weight coefficient of each candidate node, and performing weighted calculation on the candidate node vector of each candidate node according to the weight coefficient; splicing each candidate node vector after the weighted calculation to obtain an M-dimensional candidate node fusion matrix; wherein M is the number of candidate nodes.
[0011] According to a preferred embodiment of the present invention, the relationship matching degree between the target node and the candidate nodes is calculated based on the fusion vector and the candidate node fusion matrix, including: mapping the fusion vector to the candidate node fusion matrix to obtain the relationship matching score of the target node and the target relationship for each candidate node; normalizing the relationship matching score to obtain the relationship matching degree of the target node and the target relationship for each candidate node.
[0012] In a second aspect, the present application provides a knowledge graph completion device, comprising: a graph acquisition module, configured to obtain a knowledge graph to be completed, wherein the knowledge graph to be completed includes a target node, a target relationship and a pre-identified node; a fusion vector acquisition module, configured to fuse the target node vector of the target node and the target relationship vector of the target relationship to obtain a fusion vector; and to fuse the pre-identified node vector of each pre-identified node to obtain a pre-identified node fusion matrix; a candidate node determination module, configured to calculate the node matching degree between the target node and the pre-identified node based on the fusion vector and the pre-identified node fusion matrix, and to use the pre-identified node whose node matching degree meets the preset requirements as a candidate node; a candidate node vector fusion module, configured to fuse the candidate node vectors of each candidate node to obtain a candidate node fusion matrix; a valid node confirmation module, configured to calculate the relationship matching degree between the target node and the candidate node based on the fusion vector and the candidate node fusion matrix, and to use the candidate node whose relationship matching degree meets the preset requirements as a valid node; a graph completion module, configured to use the target relationship as the relationship between the target node and the valid node to complete the knowledge graph to be completed.
[0013] In a third aspect, the present application provides a computer device, which includes a memory and a processor; the memory is used to store computer programs; the processor is used to execute the computer programs and implement the steps of the above-mentioned knowledge graph completion method when executing the computer programs.
[0014] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor implements the steps of the above-mentioned knowledge graph completion method.
[0015] The knowledge graph completion method, apparatus, computer device, and computer-readable storage medium disclosed in the embodiments of the present application perform a first screening operation by calculating the node matching degree between a fusion vector containing target node information and target relationship information and a preset identification node, thereby obtaining candidate nodes that have a relationship with the target node. Then, the relationship matching degree between the candidate nodes and the fusion vector is calculated to perform a second screening operation, thereby obtaining valid nodes that have a target relationship with the target node. The target relationship is then used as the relationship between the target node and the valid node to complete the knowledge graph, thereby improving the accuracy and efficiency of the relationship completion through a segmented reasoning method. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings are incorporated into and constitute a part of the specification, illustrating embodiments consistent with the present application and, together with the specification, serving to explain the principles of the present application. It is obvious that the drawings described below are merely some embodiments of the present application, and a person of ordinary skill in the art can derive other drawings based on these drawings without inventive effort. In the drawings:
[0017] Figure 1 This is a schematic diagram of the application environment of the knowledge graph completion method provided by an exemplary embodiment of the present application;
[0018] Figure 2 This is a flowchart of a knowledge graph completion method provided by an exemplary embodiment of the present application;
[0019] Figure 3 is a schematic diagram of a knowledge graph provided by an exemplary embodiment of the present application;
[0020] Figure 4 This is a schematic diagram of performing relationship completion on a knowledge graph to be completed, provided by an exemplary embodiment of the present application;
[0021] Figure 5 This is a flowchart of obtaining a target node vector provided by an exemplary embodiment of the present application;
[0022] Figure 6 is a schematic diagram of obtaining valid nodes provided by an exemplary embodiment of the present application;
[0023] Figure 7 This is a data flow diagram of a knowledge graph completion method disclosed in an exemplary embodiment of the present application;
[0024] Figure 8 is a schematic block diagram of a knowledge graph completion device provided by an exemplary embodiment of the present application;
[0025] Figure 9 It is a schematic block diagram of a computer device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0026] Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. When the following description refers to the drawings, identical numbers in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0027] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0028] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0029] It should also be noted that the term "plurality" used in this application refers to two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0030] Knowledge graphs are used to describe the relationships between various entities or concepts in the real world and have been widely used in fields such as automated question answering, information extraction, personalized recommendations, and data analysis. While knowledge graphs can provide high-quality structured data, current knowledge graphs are built manually or semi-automatically and are often incomplete, necessitating the need for knowledge graph completion.
[0031] Relationship completion in knowledge graphs is a crucial step in the field of graph data. Given a known knowledge graph, the primary process involves completing any missing relationships between nodes within it. Traditional graph relationship mining and completion are largely based on manual analysis based on expert experience, resulting in low efficiency and a high barrier to entry. This is particularly true for relationship completion in knowledge graphs in the economics field, where the sheer number and complexity of node relationships significantly increases the difficulty of reasoning about knowledge graph completion.
[0032] To solve the above problems, the embodiments of the present application propose a knowledge graph completion method, apparatus, computer equipment and computer-readable storage medium, which improve the efficiency and accuracy of knowledge graph completion.
[0033] The following describes some embodiments of the present application in detail with reference to the accompanying drawings. In the absence of conflict, the following embodiments and features of the embodiments may be combined with each other.
[0034] Figure 1 A schematic diagram of the system architecture of the operating environment of the exemplary embodiment of the present application is shown. Figure 1As shown, the system may include a terminal 110 and a server 120. The terminal 110 and the server 120 are connected via a network communication. The network may include various connection types, such as wired or wireless communication links or optical fiber cables.
[0035] The terminal 110 may be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, in-vehicle terminal, etc., but is not limited thereto. Those skilled in the art will appreciate that the number of terminals may be greater or lesser. For example, there may be only one terminal, or there may be dozens, hundreds, or even more terminals. In this case, the implementation environment of the image processing method may also include other terminals. The embodiments of this application do not limit the number of terminals or device types.
[0036] The server 120 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The server 120 is used to provide background services for applications running on the terminal 110.
[0037] Optionally, the above-mentioned wireless network or wired network uses standard communication technologies and / or protocols. The network is typically the Internet, but can also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or any combination of a virtual private network). In some embodiments, technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. are used to represent data exchanged over the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. can be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above-mentioned data communication technologies.
[0038] Optionally, the server 120 undertakes the main knowledge graph completion work, and the terminal 110 undertakes the secondary knowledge graph completion work; or, the server 120 undertakes the secondary knowledge graph completion work, and the terminal 110 undertakes the main knowledge graph completion work; or, the server 120 or the terminal 110 can each undertake the knowledge graph completion work independently.
[0039] See also Figure 2 , Figure 2 A flow chart of the knowledge graph completion method provided in the embodiment of this application. The knowledge graph completion method can be applied to Figure 1 The implementation environment shown in FIG. 1 is specifically executed by the server 120 in the implementation environment. It should be understood that the method can also be applied to other exemplary implementation environments and specifically executed by devices in other implementation environments. This embodiment does not limit the implementation environment to which the method is applicable. Figure 2 As shown, the method includes steps S210 to S260.
[0040] Step S210: obtaining a knowledge graph to be completed, wherein the knowledge graph to be completed includes target nodes, target relationships, and pre-identified nodes.
[0041] The knowledge graph to be completed in the embodiment of the present application refers to the knowledge graph that needs to perform relationship completion, the target node refers to the node that needs to perform target relationship completion, and the pre-identified node refers to the object that needs to perform knowledge graph completion calculation based on the target node and target relationship.
[0042] The knowledge graph effectively processes, handles and integrates the data of complex documents into simple and clear "entity object-association relationship-entity object" triples, and finally aggregates a large amount of knowledge to achieve rapid response and reasoning of knowledge. Figure 3 As shown, it is a schematic diagram of a knowledge graph in an embodiment of the present application. If there is a relationship between two nodes, they will be connected by an undirected edge. The two nodes are entity objects, and the edge between the two nodes is an association relationship. In other words, Figure 3 Each node in is an entity object, and the edges between entity objects are association relationships. For example, Figure 3 In the example, "Province A", "City B", "Output x", "Average price y" are all entity objects. The association relationship is used to connect different entity objects, such as Figure 3 "Region", "Economic Indicator 1", "Economic Indicator 2", etc.
[0043] Exemplarily, the nodes and relationships in the knowledge graph to be completed can be randomly selected and combined to obtain the target node and target relationship; the target node can also be selected based on the number of edges corresponding to each node in the knowledge graph to be completed, or the node type of each node, and then the target node and target relationship can be selected; the target node and target relationship can also be obtained by obtaining the user's input operation, and this application does not impose specific restrictions on this.
[0044] Exemplarily, there can be multiple pre-identification nodes, for example, all nodes of a certain type in the knowledge graph to be completed are used as pre-identification nodes, or all nodes in the knowledge graph to be completed except the target node are used as pre-identification nodes; the pre-identification node can also be single, for example, a node in the knowledge graph to be completed is randomly selected as a pre-identification node, and this application does not impose specific restrictions on this.
[0045] Step S220 , fusing the target node vector of the target node and the target relationship vector of the target relationship to obtain a fused vector; and fusing the pre-recognized node vector of each pre-recognized node to obtain a pre-recognized node fusion matrix.
[0046] The target node, target relationship and pre-identified node are encoded to obtain a target node vector, a target relationship vector and a pre-identified node vector. The encoding process refers to expressing discrete variables as continuous variables.
[0047] Exemplarily, the target node, target relationship and pre-identification node are input into the coding network so that the coding network encodes the target node, target relationship and pre-identification node, and outputs the target node vector, target relationship vector and pre-identification node vector. For example, the coding network can adopt a TransE network, or other network models, such as an MTransE network, which is not specifically limited in this application. Taking the TransE network as an example, the process of encoding the target node, target relationship and pre-identification node refers to: translating the target node, target relationship and pre-identification node into embedding word vectors, and using the embedding word vectors as the target node vector, target relationship vector and pre-identification node vector.
[0048] Exemplarily, the target node vector and the target relationship vector are fused to obtain a fused vector, such that the fused vector includes information about the target node and the target relationship. The pre-identified node vectors of each pre-identified node are fused to obtain a pre-identified node fusion matrix, such that the pre-identified node fusion matrix includes information about each pre-identified node.
[0049] For example, the target node vector and the target relationship vector can be fused using the following formula (1):
[0050] Formula (1),
[0051] Among them, e ij is the fusion vector, represents the i-th node, r j Represents the j-th type of relationship, and f represents a fusion method, such as vector splicing, weighted calculation, etc., which is not specifically limited in this application.
[0052] Step S230 , calculating the node matching degree between the target node and the pre-identified node according to the fusion vector and the pre-identified node fusion matrix, and taking the pre-identified node whose node matching degree meets the preset requirement as a candidate node.
[0053] Among them, candidate nodes refer to nodes in the identified knowledge graph to be completed that may have a relationship with the target node. The node matching degree is used to characterize the possibility of an association relationship between the pre-identified node and the target node. The higher the node matching degree, the higher the possibility of an association relationship between the pre-identified node and the target node. The lower the node matching degree, the lower the possibility of an association relationship between the pre-identified node and the target node.
[0054] In an embodiment of the present application, the node matching degree between the target node and the pre-identified node is calculated by combining the fusion vector and the pre-identified node fusion matrix. The pre-identified node whose node matching degree satisfies a preset requirement may be a pre-identified node whose node matching degree is greater than or equal to a node matching degree threshold. Alternatively, the node matching degrees may be sorted, and the pre-identified node whose node matching degree satisfies a preset requirement may be the pre-identified node with the highest node matching degree in the sorted result.
[0055] Optionally, the node matching threshold can be a set fixed threshold or a dynamic threshold. For example, the node matching threshold is dynamically calculated based on at least one of the completion status of the current knowledge graph to be completed, the information of the target node, the information of the target relationship, the number of pre-identified nodes, and the information of each pre-identified node, so that the obtained node matching threshold is more accurate, thereby making the candidate nodes obtained by screening more accurate. The completion status of the knowledge graph to be completed refers to the gap between the knowledge graph to be completed and the completion target. The completion target can be the relevant parameters of the set knowledge graph, such as the degree of each node, etc. The completion target can also be the number of executions of the preset knowledge graph completion method. For example, if the knowledge graph to be completed has a total of 10 nodes and 2 relationships, the number of executions of the preset knowledge graph completion method can be 20, in order to traverse the combination between each node and relationship. The node information refers to the relevant parameters of the node, such as the type of the node, the attributes of the node, the degree of the node, and other information. The relationship information refers to the relevant parameters of the relationship, such as the type of the relationship, the attributes of the relationship, and other information.
[0056] The pre-identified nodes whose node matching degrees meet the preset requirements are selected as candidate nodes to perform the first screening of the pre-identified nodes, and the node matching degrees are calculated based on the fusion vector and the pre-identified node fusion matrix. When calculating whether there is an association relationship between the target node and each pre-identified node, the information of the target relationship and the information of each pre-identified node are taken into account, so that the obtained node matching degree is more accurate.
[0057] Step S240 , fusing the candidate node vectors of each candidate node to obtain a candidate node fusion matrix.
[0058] Among them, the candidate node vector of the candidate node can be consistent with the pre-identified node vector corresponding to the candidate node, that is, the pre-identified node and the candidate node are encoded using the same encoding method; the candidate node vector of the candidate node can also be inconsistent with the pre-identified node vector corresponding to the candidate node, that is, the pre-identified node and the candidate node are encoded using different encoding methods. This application does not impose specific restrictions on this.
[0059] Exemplarily, the candidate node vectors of each candidate node are fused to obtain a candidate node fusion matrix, so that the candidate node fusion matrix contains information of each candidate node.
[0060] Step S250 , calculating the relationship matching degree between the target node and the candidate nodes according to the fusion vector and the candidate node fusion matrix, and taking the candidate nodes whose relationship matching degree meets the preset requirements as valid nodes.
[0061] Among them, a valid node refers to a node that has a target relationship with a target node. The relationship matching degree is used to characterize the possibility of a target relationship between a candidate node and a target node. The higher the relationship matching degree, the higher the possibility of a target relationship between the candidate node and the target node. The lower the relationship matching degree, the lower the possibility of a target relationship between the candidate node and the target node.
[0062] In an embodiment of the present application, the relationship matching degree between the target node and the target relationship and the pre-identified nodes is calculated by combining the fusion vector and the candidate node fusion matrix. The candidate nodes whose relationship matching degree meets the preset requirements may be candidate nodes whose relationship matching degree is greater than or equal to a relationship matching degree threshold. Alternatively, the relationship matching degrees may be ranked, and the candidate nodes whose relationship matching degree meets the preset requirements may be the candidate nodes with the highest relationship matching degree in the ranked results.
[0063] Among them, the relationship matching threshold can be a set fixed threshold or a dynamic threshold. For example, the relationship matching threshold is dynamically calculated based on at least one of the completion status of the current knowledge graph to be completed, the information of the target node, the information of the target relationship, the number of candidate nodes, and the information of the candidate nodes, so that the obtained relationship matching threshold is more accurate, and thus the effective nodes obtained by screening are more accurate.
[0064] The pre-identified nodes whose relationship matching degree meets the preset requirements are regarded as valid nodes to perform a second screening of the candidate nodes. The relationship matching degree is calculated based on the fusion vector and the candidate node fusion matrix. When calculating whether there is an association relationship between the target node and the target relationship and each candidate node, the information of each pre-identified node is taken into account to make the obtained relationship matching degree more accurate.
[0065] Step S260: Use the target relationship as the relationship between the target node and the valid node to complete the knowledge graph to be completed.
[0066] Among them, completing the knowledge graph to be completed refers to connecting the target node and the valid node with an undirected edge, and the undirected edge represents the target relationship.
[0067] For example, see Figure 4 , Figure 4 This is a schematic diagram of relationship completion for the knowledge graph to be completed. Figure 4As shown, the knowledge graph to be completed includes node A1, node A2, node A3, node B1, node B2, relationship 1 and relationship 2. Then, the target node of the knowledge graph to be completed is node A1, the target relationship is relationship 1, and the pre-identified nodes include node A2, node A3, node B1 and node B2. Then, the node matching degree between the target node and the pre-identified node is calculated based on the fusion vector corresponding to node A1 and relationship 1, and the candidate nodes obtained by screening according to the node matching degree include node A2 and node A3. Then, the relationship matching degree between the target node and the candidate nodes is calculated based on the fusion vector corresponding to node A1 and relationship 1, and the valid nodes obtained by screening according to the relationship matching degree include node A2. Therefore, an undirected edge is added between node A2 and node A1, and the undirected edge represents relationship 1, so as to obtain the knowledge graph after completion processing.
[0068] It is understandable that the above relationship completion process can be repeated for each node and relationship in the knowledge graph to be completed. For example, taking node A2 as the target node, relationship 1 as the target relationship, nodes A1, A3, B1, and B2 as pre-identified nodes, after reasoning on node A2 and relationship 1, there is relationship 1 between node A2 and node A3, and an undirected edge is added between node A2 and node A3, and the undirected edge represents relationship 1. Taking node A1 as the target node, relationship 2 as the target relationship, nodes A2, A3, B1, and B2 as pre-identified nodes, after reasoning on node A1 and relationship 2, there is relationship 2 between node A1 and node B1, and an undirected edge is added between node A1 and node B1, and the undirected edge represents relationship 2. Take node A2 as the target node, relationship 2 as the target relationship, node A1, node A3, node B1, and node B2 as pre-identified nodes. After reasoning about node A2 and relationship 2, there is relationship 2 between node A2 and node B2. An undirected edge is added between node A2 and node B2, and the undirected edge represents relationship 2. Finally, a knowledge graph is obtained after each node is completed.
[0069] By completing the relationships of each node and relationship, the knowledge graph obtained after completion is made more accurate, avoiding the omission of relationships between nodes, and improving the comprehensiveness of the relationship completion of the knowledge graph to be completed.
[0070] In the embodiment of the present application, the pre-identified nodes whose node matching degree meets the preset requirements are taken as candidate nodes to perform the first screening of the nodes, and then the candidate nodes whose relationship matching degree meets the preset requirements are taken as valid nodes to perform the second screening of the nodes, and the target relationship is taken as the relationship between the target node and the valid node to complete the knowledge graph, thereby improving the accuracy and efficiency of the relationship completion through the segmented reasoning method.
[0071] See also Figure 5 , Figure 5 This is a flowchart of a knowledge graph completion method shown in another exemplary embodiment. Figure 5 As shown, in an exemplary embodiment, before fusing the target node vector of the target node and the target relationship vector of the target relationship in step S220, the following steps may also be included:
[0072] Step S510: Acquire node attribute information and node type information of the target node.
[0073] The target node includes node attribute information and node type information. The node attribute information refers to the object referred to by the target node, and the node type information refers to the category to which the object referred to by the target node belongs. Figure 3 The node attribute information of the node "Province A" is "Province A", and the node type information is a regional node.
[0074] Step S520 , performing vector conversion processing on each character and the position of each character in the node attribute information and the node type information to obtain a node attribute vector and a node type vector.
[0075] At this time, for any character in the node attribute information and the node type information, the position of the character in the node attribute information and the node type information may be the position of the character in the text content to which it belongs.
[0076] In an embodiment of the present application, for each character in the node attribute information and the node type information, the position of the character in the text content to which it belongs can be vector-converted to obtain the position vector of the character, and the position vector and word vector of the character can be concatenated to obtain the character target vector of the character.
[0077] The character target vectors of each character in the node attribute information and node type information can be fused and feature extracted to obtain the node attribute vector and the node type vector, so that the node attribute vector and the node type vector contain the position and semantics of each character, so that the text vector can better express the information of the target node.
[0078] Among them, the fusion feature extraction can be to splice the position vector of the character before or after the word vector of the character. Of course, in the actual execution process, the method of splicing the position vector and the word vector can be omitted, but the set of the position vector and the word vector can be regarded as the first target vector, which is not limited here.
[0079] Step S530: Fusing the node attribute vector and the node type vector to obtain a target node vector.
[0080] For example, when fusing the node attribute vector and the node type vector, common fusion methods include: feature vector concatenation, dot product, weighted summation, etc., which are not specifically limited in this application.
[0081] For example, the weight coefficients of the node attribute vector and the node type vector are obtained, and the node attribute vector and the node type vector are weightedly summed according to the weight coefficient to obtain the target node vector, that is, the target node vector includes the attribute information and type information of the nodes in the target node. Then, the target node vector can accurately represent the target node, so that accurate relationship completion processing can be performed based on the target node vector in the future.
[0082] In some embodiments, after fusing the node attribute vector and the node type vector to obtain the target node vector, it also includes: obtaining the adjacency matrix and degree matrix corresponding to the target node; performing convolution processing on the target node vector according to the adjacency matrix and the degree matrix to obtain the convolved target node vector; and using the convolved target node vector as the target node vector of the target node.
[0083] The adjacency matrix represents the relationships between nodes in the knowledge graph to be completed. It is represented by an n-order square matrix, where n is the number of nodes. The value between connected nodes in the matrix is 1, and the value everywhere else is 0. The degree matrix is a diagonal matrix, and the elements on the diagonal are the degrees of each node. The degree of a node represents the number of edges associated with the node.
[0084] In the embodiment of the present application, the adjacency matrix, the degree matrix, and the target node vector are input into a convolutional network so that the convolutional network performs convolution processing on the target node vector and outputs the convolved target node vector. For example, the convolutional network is a graph convolutional network (GCN), and the adjacency matrix, the degree matrix, and the target node vector are input into the GCN for convolution processing. The convolution processing can be performed using the following formula (2):
[0085] Formula (2),
[0086] Among them, H (l) is the target node vector of the lth layer, H (l+1) is the target node vector after a convolution process on the target node vector of the lth layer, D is the dimension of each node feature vector, A is the adjacency matrix, W (l) is the weight parameter matrix of the lth layer, and σ is a nonlinear activation function, such as ReLU.
[0087] By performing convolution processing on the target node, the target node vector obtained after convolution is integrated with the relationship-level information. That is, after one convolution operation, each node information will interact with the surrounding node information with a degree of connection. After multiple convolution operations, even if each node information interacts with the surrounding node information with a degree of connection of two or more, the information in the target node vector obtained after convolution is richer, which facilitates the subsequent relationship completion processing.
[0088] For example, see Figure 6 , perform convolution processing on each target node in the knowledge graph to be completed so that information can be exchanged between target nodes, and obtain the target node vector of each target node, and encode each target relationship in the knowledge graph to be completed to obtain the target relationship vector of each target relationship. Then, select the target node and target relationship that need to be inferred at present, and then obtain the target node vector of the target node and the target relationship vector of the target relationship, fuse the target node vector and the target relationship vector to obtain the fusion vector. Furthermore, the knowledge graph to be completed includes multiple types of nodes, such as Figure 6 There are J types of nodes in , and nodes of a specified type are selected as pre-identified nodes, and the pre-identified nodes are calculated according to the fusion vector to obtain candidate nodes, and then the candidate nodes are calculated according to the fusion vector to obtain valid nodes.
[0089] In an exemplary embodiment, the process of fusing the pre-identification node vectors of each pre-identification node to obtain a pre-identification node fusion matrix may include the following steps: obtaining a weight coefficient of each pre-identification node, performing weighted calculation on the pre-identification node vector of each pre-identification node according to the weight coefficient, and splicing each pre-identification node vector after the weighted calculation to obtain an N-dimensional pre-identification node fusion matrix; wherein N is the number of pre-identification nodes.
[0090] Among them, the weight coefficient of each pre-recognition node can be a set fixed value. For example, if the weight coefficients of each pre-recognition node are the same, the weight coefficient of each pre-recognition node is 1 divided by the number of pre-recognition nodes; the weight coefficient of each pre-recognition node can also be a dynamically determined value. For example, the weight coefficient of each pre-recognition node is dynamically calculated based on at least one of the degree of each pre-recognition node, the attribute information of each pre-recognition node, the type information of each pre-recognition node, the similarity between each pre-recognition node and the target node, etc., so that the weight coefficient of each pre-recognition node obtained is more accurate, and thus the candidate nodes obtained by screening are more accurate.
[0091] For example, the pre-identification nodes include "node A", "node B" and "node C". Each pre-identification node is encoded to obtain the pre-identification node vector of each pre-identification node. Then, the weight coefficient of each pre-identification node package is confirmed according to the degree of each pre-identification node. For example, if the degree of "node A" is 3, the degree of "node B" is 1, and the degree of "node C" is 1, then the weight coefficient of "node A" is 0.2, the weight coefficient of "node B" is 0.4, and the weight coefficient of "node C" is 0.4. Then, the pre-identification node vectors of each pre-identification node are weightedly spliced to obtain a 3-dimensional pre-identification node fusion matrix, where 3 is the number of pre-identification nodes.
[0092] In an exemplary embodiment, the node matching degree between the target node and the pre-identified nodes is calculated based on the fusion vector and the pre-identified node fusion matrix, including: mapping the fusion vector to the pre-identified node fusion matrix to obtain the node matching score of the target node for each pre-identified node; normalizing the node matching score to obtain the node matching degree of the target node for each pre-identified node.
[0093] By mapping the fusion vector to the pre-identified node fusion matrix, a mapped vector is obtained, and the mapped vector is a node matching score corresponding to each pre-identified node.
[0094] Normalization refers to scaling the node matching scores so that they fall into a small specific range. For example, the node matching degree can be obtained using the following formula (3):
[0095] Formula (3),
[0096] in, is the node matching degree between the i-th node and the j-th relationship for the pre-identified node, sigmoid is the normalization function, W N is the N-dimensional pre-identified node fusion matrix, N is the number of pre-identified nodes, e ij is the fusion vector.
[0097] Furthermore, the pre-identified nodes are screened according to the node matching threshold to obtain candidate nodes, which can be screened using the following formula (4):
[0098] Formula (4),
[0099] Among them, k 1 Represents the index of pre-identified nodes of the selected type, that is, only judge under nodes of these types, is the node matching degree of the relationship between the i-th target node and the j-th type target for the pre-identified node, N is the number of pre-identified nodes, n is the serial number of the pre-identified node currently judged, t1 is the preset node matching degree threshold, and s is the candidate node whose node matching degree is greater than or equal to the node matching degree threshold.
[0100] In an exemplary embodiment, step S240 fuses the candidate node vectors of each candidate node to obtain a candidate node fusion matrix, which may include the following steps: obtaining a weight coefficient of each candidate node, and performing weighted calculation on the candidate node vector of each candidate node according to the weight coefficient; splicing each candidate node vector after weighted calculation to obtain an M-dimensional candidate node fusion matrix; wherein M is the number of candidate nodes.
[0101] Among them, the weight coefficient of each candidate node can be a set fixed value. If the weight coefficient of each candidate node is the same, the weight coefficient of each candidate node is 1 divided by the number of candidate nodes; the weight coefficient of each candidate node can also be a dynamically determined value. For example, the weight coefficient of each candidate node is dynamically calculated based on at least one of the degree of each candidate node, the attribute information of each candidate node, the type information of each candidate node, the similarity between each candidate node and the target node, etc., so that the weight coefficient of each candidate node obtained is more accurate, and thus the candidate nodes obtained by screening are more accurate.
[0102] The weight coefficient of each candidate node is obtained, and then the candidate node vector of each candidate node is weightedly calculated. Each candidate node vector after weighted calculation is spliced to obtain an M-dimensional candidate node fusion matrix, where M is the number of candidate nodes.
[0103] For example, the pre-identified nodes include "A node", "B node" and "C node", and the candidate nodes obtained after screening the preset nodes include "B node" and "C node". The node vectors corresponding to the candidate nodes "B node" and "C node" are weighted spliced to obtain a 2-dimensional candidate node vector, where 2 is the number of candidate nodes.
[0104] In an exemplary embodiment, step S250 calculates the relationship matching degree between the target node and the candidate nodes based on the fusion vector and the candidate node fusion matrix, including: mapping the fusion vector to the candidate node fusion matrix to obtain the relationship matching score of the target node and the target relationship for each candidate node; normalizing the relationship matching score to obtain the relationship matching degree of the target node and the target relationship for each candidate node.
[0105] By mapping the fusion vector to the candidate node fusion matrix, a mapped vector is obtained, which is the relationship matching score corresponding to each candidate node.
[0106] Normalization refers to scaling the relationship matching score so that it falls into a small specific range. For example, the node matching degree can be obtained using the following formula (5):
[0107] Formula (5),
[0108] in, is the relationship matching degree between the i-th node and the j-th relationship for the candidate node, sigmoid is the normalization processing function, W M is the M-dimensional candidate node fusion matrix, M is the number of candidate nodes, e ij is the fusion vector.
[0109] Furthermore, candidate nodes are screened according to the relationship matching threshold to obtain valid nodes. The following formula (6) can be used for screening:
[0110] Formula (6),
[0111] Among them, k 2 Represents the index of the candidate node obtained after screening, is the relationship matching degree between the i-th target node and the j-th type target relationship for the candidate node, M is the number of candidate nodes, m is the sequence number of the candidate node currently judged, t2 is the preset relationship matching degree threshold, and s is the valid node whose relationship matching degree is greater than the relationship matching degree threshold, that is, there is a target relationship between the obtained valid node and the target node.
[0112] In some embodiments, the valid node is obtained by calling a trained completion model to perform graph completion prediction on the knowledge graph to be completed; the method also includes: obtaining a sample knowledge graph triple, the sample knowledge graph triple includes a sample target node, a sample target relationship and a sample valid node; inputting the sample target node and the sample target relationship into the completion model for graph completion prediction processing to obtain a predicted valid node output by the completion model; according to the difference between the predicted valid node and the sample valid node, correcting the network parameters of the completion model to obtain a trained completion model.
[0113] Exemplarily, the sample knowledge graph triples include positive samples and negative samples. The positive samples in this embodiment refer to correct triples, which are triples that have been constructed in the sample knowledge graph. Then, this embodiment randomly replaces the sample target nodes, sample target relationships, or sample valid nodes in the positive samples to generate negative samples, that is, negative samples are samples where the facts are not true. For example, if the sample knowledge graph triple of the positive sample is (node A1, relationship 1, node B1), then the node A1 of the sample knowledge graph triple can be randomly replaced, and the resulting negative samples can include (node A2, relationship 1, node B1), (node A3, relationship 1, node B1), etc.
[0114] Furthermore, the positive samples and negative samples are input into the completion model for graph completion prediction processing to obtain the prediction results output by the completion model. For example, each group of samples includes a positive sample and multiple negative samples. The sample label for the positive sample can be 1, and the sample label for the negative sample can be 0, such as the positive sample is (node A1, relationship 1, node B1), the negative sample is (node A2, relationship 1, node B1), (node A3, relationship 1, node B1), etc. In the process of training the completion model, relationship 1 and node B1 are used as known information, so that the completion model predicts the probability that other nodes (such as node A1, node A2, node A3) have relationship 1 with node B1 based on relationship 1 and node B1, and uses the output probability as the prediction result. Among them, the specific implementation method of the completion model predicting the probability that other nodes have relationship 1 with node B1 can be found in the above Figure 2 Steps S210 to S250 in the present application will not be described in detail here.
[0115] Then, based on the difference between the prediction results and the sample labels, the network parameters of the completion model are updated to obtain the completed completion model. For example, the positive samples and negative samples are input into the first prediction network in the completion model to predict the candidate nodes, and the candidate nodes are output by the first prediction network. Then, the candidate nodes are input into the second prediction network in the completion model to predict the valid nodes, and the valid nodes are output by the second prediction network. Different loss functions L are set for the first prediction network and the second prediction network. 1 and L 2 .
[0116] Among them, the cross entropy loss function can be used to calculate the difference between the prediction result and the sample label. It can be understood that the triplet loss loss function (triplet loss function) can also be used, or other loss functions such as the logarithmic function can also be used to calculate the difference between the prediction result and the sample label. This application does not limit this.
[0117] For example, the loss function of the first prediction network can be expressed as follows:
[0118] Formula (7),
[0119] Among them, L 1 Calculate the node matching degree for the first prediction network and use the loss function of the process of screening candidate nodes based on the node matching degree. y is the sample label, the value of the sample label is 1 or 0, p is the prediction result, N is the number of pre-identified nodes, M is the number of candidate nodes, I is the number of target nodes, and J is the category of the target relationship.
[0120] The loss function formula of the second prediction network can be expressed as follows:
[0121] Formula (8),
[0122] Among them, L 2 Calculate the relationship matching degree for the second prediction network, and use the loss function of the process of screening valid nodes based on the relationship matching degree. L is the final loss function, y is the sample label, the value of the sample label is 1 or 0, p is the prediction result, N is the number of pre-identified nodes, M is the number of candidate nodes, I is the number of target nodes, and J is the category of the target relationship.
[0123] Then the objective loss function formula of the completion model can be adopted as the following formula (9):
[0124] Formula (9), L = L 1 +L 2
[0125] The parameters of the first prediction network and the second prediction network are adjusted according to their respective corresponding loss function values until the first prediction network and the second prediction network converge, thereby obtaining an updated trained completion model. The convergence goal of the first prediction network and the second prediction network may be: convergence of the loss function values of the loss functions to ensure that the error between the actual output value obtained by the first prediction network and the second prediction network processing the input target nodes and target relationships and the target output value converges.
[0126] In some embodiments, see Figure 7 , Figure 7 This is a data flow diagram of the knowledge graph completion method disclosed in one embodiment of this application. Figure 7As shown in the figure, the target node vector and the information between nodes are convolved through the GCN network to obtain the convolved target node vector, where the information between nodes is the adjacency matrix and degree matrix corresponding to the target node. The target node vector and the target relationship vector are fused to obtain a fused vector. Then, the fused vector is mapped to the pre-identified node fusion matrix to obtain candidate nodes. Furthermore, the fused vector is mapped to the candidate node fusion matrix to obtain valid nodes, and the target relationship between the valid nodes and the target node is completed.
[0127] The knowledge graph completion method disclosed in the embodiment of the present application performs a first screening operation by calculating the node matching degree between a fusion vector containing target node information and target relationship information and a preset identification node, thereby obtaining candidate nodes that have a relationship with the target node. Then, the relationship matching degree between the candidate nodes is calculated based on the fusion vector to perform a second screening operation to obtain valid nodes that have a target relationship with the target node, and then the target relationship is used as the relationship between the target node and the valid node to complete the knowledge graph, thereby improving the accuracy and efficiency of the relationship completion through the segmented reasoning method.
[0128] See also Figure 8 , Figure 8 It is a schematic block diagram of a knowledge graph completion device 800 provided in one embodiment of the present application. The knowledge graph completion device 800 can be configured in a server or terminal to execute the aforementioned knowledge graph completion method.
[0129] like Figure 8 As shown, the knowledge graph completion device 800 includes: a graph acquisition module 810, a fusion vector acquisition module 820, a candidate node determination module 830, a candidate node vector fusion module 840, a valid node confirmation module 850 and a graph completion module 860.
[0130] A graph acquisition module 810 is configured to acquire a knowledge graph to be completed, wherein the knowledge graph to be completed includes a target node, a target relationship, and a pre-identified node;
[0131] The fusion vector acquisition module 820 is configured to fuse the target node vector of the target node and the target relationship vector of the target relationship to obtain a fusion vector; and to fuse the pre-identified node vector of each pre-identified node to obtain a pre-identified node fusion matrix;
[0132] The candidate node determination module 830 is configured to calculate the node matching degree between the target node and the pre-identified node according to the fusion vector and the pre-identified node fusion matrix, and select the pre-identified node whose node matching degree meets the preset requirements as the candidate node;
[0133] The candidate node vector fusion module 840 is configured to fuse the candidate node vectors of each candidate node to obtain a candidate node fusion matrix;
[0134] The valid node confirmation module 850 is configured to calculate the relationship matching degree between the target node and the candidate node according to the fusion vector and the candidate node fusion matrix, and select the candidate node whose relationship matching degree meets the preset requirements as a valid node;
[0135] The graph completion module 860 is configured to use the target relationship as the relationship between the target node and the valid node to complete the knowledge graph to be completed.
[0136] In some embodiments, based on the aforementioned solution, the knowledge graph completion device 800 further includes a target node attribute and type information acquisition unit, a vector conversion unit, and an attribute and type fusion unit.
[0137] A target node attribute and type information acquisition unit configured to acquire node attribute information and node type information of the target node;
[0138] a vector conversion unit configured to perform vector conversion processing on each character and the position of each character in the node attribute information and the node type information to obtain a node attribute vector and a node type vector;
[0139] The attribute and type fusion unit is configured to fuse the node attribute vector and the node type vector to obtain a target node vector.
[0140] In some embodiments, based on the aforementioned solution, the knowledge graph completion device 800 further includes a matrix acquisition unit and a convolution unit.
[0141] a matrix acquisition unit configured to acquire an adjacency matrix and a degree matrix corresponding to a target node;
[0142] The convolution unit is configured to perform convolution processing on the target node vector according to the adjacency matrix and the degree matrix to obtain a convolved target node vector, so as to use the convolved target node vector as the target node vector of the target node.
[0143] In some embodiments, based on the aforementioned solution, the fusion vector acquisition module 820 includes a pre-identified node weight coefficient acquisition unit and a pre-identified node vector splicing unit.
[0144] a pre-identification node weight coefficient acquisition unit configured to acquire a weight coefficient of each pre-identification node and perform weighted calculation on a pre-identification node vector of each pre-identification node according to the weight coefficient;
[0145] The pre-identification node vector splicing unit is configured to splice each pre-identification node vector after weighted calculation to obtain an N-dimensional pre-identification node fusion matrix; wherein N is the number of pre-identification nodes.
[0146] In some implementations, based on the aforementioned solution, the candidate node determination module 830 includes a first mapping unit and a node matching degree acquisition unit.
[0147] a first mapping unit configured to map the fusion vector to a pre-identified node fusion matrix to obtain a node matching score of the target node for each pre-identified node;
[0148] The node matching degree obtaining unit is configured to normalize the node matching scores to obtain the node matching degree of the target node for each pre-identified node.
[0149] In some implementations, based on the aforementioned solution, the candidate node vector fusion module 840 includes a candidate node weight coefficient acquisition unit and a candidate node vector splicing unit.
[0150] a candidate node weight coefficient obtaining unit configured to obtain a weight coefficient of each candidate node and perform weighted calculation on a candidate node vector of each candidate node according to the weight coefficient;
[0151] The candidate node vector concatenation unit is configured to concatenate each candidate node vector after weighted calculation to obtain an M-dimensional candidate node fusion matrix, where M is the number of candidate nodes.
[0152] In some implementations, based on the aforementioned solution, the valid node confirmation module 850 includes a second mapping unit and a relationship matching degree acquisition unit.
[0153] A second mapping unit is configured to map the fusion vector to the candidate node fusion matrix to obtain a target node and a target relationship matching score for each candidate node;
[0154] The relationship matching degree obtaining unit is configured to normalize the relationship matching scores to obtain the relationship matching degree of the target node and the target relationship for each candidate node.
[0155] It should be noted that the knowledge graph completion device provided in the above embodiment and the knowledge graph completion method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here. In actual application, the knowledge graph completion device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0156] The methods and apparatus of the present application can be used in a variety of general-purpose or specialized computing system environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above.
[0157] Figure 9 A schematic diagram of the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present application is shown.
[0158] It should be noted that Figure 9 The computer system 900 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0159] like Figure 9 As shown, electronic device 900 is implemented as a general-purpose computing device. Components of electronic device 900 may include, but are not limited to, the at least one processing unit 910 described above, the at least one storage unit 920 described above, a bus 930 connecting various system components (including storage unit 920 and processing unit 910), and a display unit 940.
[0160] The storage unit stores program codes, which can be executed by the processing unit 910, so that the processing unit 910 performs the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.
[0161] The storage unit 920 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 921 and / or a cache memory unit 922 , and may further include a read-only memory unit (ROM) 923 .
[0162] The storage unit 920 may also include a program / utility 924 having a set (at least one) of program modules 925, such program modules 925 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include an implementation of a network environment.
[0163] Bus 930 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0164] The electronic device 900 can also communicate with one or more external devices 970 (e.g., a keyboard, a pointing device, a Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 900, and / or any device that enables the electronic device 900 to communicate with one or more other computing devices (e.g., a router, a modem, etc.). Such communication can occur via an input / output (I / O) interface 950. Furthermore, the electronic device 900 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 960. As shown, the network adapter 960 communicates with other modules of the electronic device 900 via a bus 930. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 900, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0165] In particular, according to embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for executing the method shown in the flowchart. When the computer program is executed by the processing unit 910, the various functions defined in the system of the present application are performed.
[0166] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0167] In this application, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable computer program. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination of the foregoing.
[0168] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of the systems, methods, and computer program products according to various embodiments of the present application. Each box in the flowchart or block diagram may represent a module, a program segment, or a portion of a code, and the above-mentioned module, program segment, or a portion of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings.
[0169] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. In some cases, the names of these units do not constitute limitations on the units themselves.
[0170] Another aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned knowledge graph completion method. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist independently without being incorporated into the electronic device.
[0171] Another aspect of the present application further provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the knowledge graph completion method provided in each of the above embodiments.
[0172] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. Ordinary technicians in this field can easily make corresponding changes or modifications based on the main ideas and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
Claims
1. A knowledge graph completion method, characterized in that: include: Obtaining a knowledge graph to be completed, wherein the knowledge graph to be completed includes a target node, a target relationship, and a pre-identified node; Obtaining node attribute information and node type information of the target node; For each character in the node attribute information and the node type information, performing vector conversion processing on the position of the character in the corresponding text content to obtain a position vector of the character; splicing the position vector and word vector of the character to obtain a character target vector of the character; the word vector is obtained by performing vector conversion processing on the semantics of the character; Performing fusion feature extraction on the character target vector to obtain a node attribute vector and a node type vector; Fusing the node attribute vector and the node type vector to obtain a target node vector of the target node; The target node vector of the target node and the target relationship vector of the target relationship are fused to obtain a fused vector; and the pre-identified node vector of each pre-identified node is fused to obtain a pre-identified node fusion matrix; the fused vector includes information about the target node and information about the target relationship; Calculating the node matching degree between the target node and the pre-identified node based on the fusion vector and the pre-identified node fusion matrix, and selecting the pre-identified node whose node matching degree meets the preset requirements as a candidate node; the node matching degree is used to indicate the possibility of an association relationship between the pre-identified node and the target node; Fusing the candidate node vectors of each candidate node to obtain a candidate node fusion matrix; Calculating the relationship matching degree between the target node and the candidate node based on the fusion vector and the candidate node fusion matrix, and taking the candidate node whose relationship matching degree meets the preset requirements as a valid node; the relationship matching degree is used to represent the possibility of a target relationship between the candidate node and the target node; The target relationship is used as the relationship between the target node and the valid node to complete the knowledge graph to be completed.
2. The method according to claim 1, characterized in that After fusing the node attribute vector and the node type vector to obtain the target node vector of the target node, the method further includes: Obtain the adjacency matrix and degree matrix corresponding to the target node; The target node vector is convolved according to the adjacency matrix and the degree matrix to obtain a convolved target node vector, and the convolved target node vector is used as the target node vector of the target node.
3. The method according to claim 1, characterized in that The fusing of the pre-identified node vectors of each of the pre-identified nodes to obtain a pre-identified node fusion matrix includes: Obtaining a weight coefficient of each of the pre-identified nodes, and performing weighted calculation on the pre-identified node vector of each of the pre-identified nodes according to the weight coefficient; Each of the weighted pre-identified node vectors is concatenated to obtain an N-dimensional pre-identified node fusion matrix, where N is the number of the pre-identified nodes.
4. The method according to claim 3, characterized in that The calculating the node matching degree between the target node and the pre-identified node according to the fusion vector and the pre-identified node fusion matrix includes: Mapping the fusion vector to the pre-identified node fusion matrix to obtain a node matching score of the target node for each pre-identified node; The node matching scores are normalized to obtain the node matching degree of the target node for each pre-identified node.
5. The method according to claim 1, wherein The candidate node vectors of each candidate node are fused to obtain a candidate node fusion matrix, including: Obtaining a weight coefficient of each candidate node, and performing weighted calculation on the candidate node vector of each candidate node according to the weight coefficient; Each of the candidate node vectors after weighted calculation is concatenated to obtain an M-dimensional candidate node fusion matrix; wherein M is the number of the candidate nodes.
6. The method according to claim 5, characterized in that The calculating the relationship matching degree between the target node and the candidate node according to the fusion vector and the candidate node fusion matrix includes: Mapping the fusion vector to the candidate node fusion matrix to obtain the target node and the target relationship matching score for each candidate node; The relationship matching scores are normalized to obtain the relationship matching degree of the target node and the target relationship for each candidate node.
7. A knowledge graph completion device, characterized in that: The device comprises: A graph acquisition module is configured to acquire a knowledge graph to be completed, wherein the knowledge graph to be completed includes a target node, a target relationship, and a pre-identified node; A fusion vector acquisition module is configured to obtain the node attribute information and node type information of the target node; for each character in the node attribute information and the node type information, perform vector conversion processing on the position of the character in the text content to which it belongs to obtain the position vector of the character; splice the position vector and the word vector of the character to obtain the character target vector of the character; the word vector is obtained by performing vector conversion processing on the semantics of the character; perform fusion feature extraction on the character target vector to obtain a node attribute vector and a node type vector; fuse the node attribute vector and the node type vector to obtain the target node vector of the target node; fuse the target node vector of the target node and the target relationship vector of the target relationship to obtain a fusion vector; and fuse the pre-recognized node vector of each of the pre-recognized nodes to obtain a pre-recognized node fusion matrix; the fusion vector contains information about the target node and information about the target relationship; a candidate node determination module configured to calculate a node matching degree between the target node and the pre-identified node based on the fusion vector and the pre-identified node fusion matrix, and select the pre-identified node whose node matching degree meets a preset requirement as a candidate node; the node matching degree is used to indicate the possibility of an association relationship between the pre-identified node and the target node; a candidate node vector fusion module configured to fuse the candidate node vectors of each candidate node to obtain a candidate node fusion matrix; a valid node confirmation module configured to calculate the relationship matching degree between the target node and the candidate node based on the fusion vector and the candidate node fusion matrix, and select the candidate node whose relationship matching degree meets the preset requirements as a valid node; the relationship matching degree is used to indicate the possibility of a target relationship between the candidate node and the target node; The graph completion module is configured to use the target relationship as the relationship between the target node and the valid node to complete the knowledge graph to be completed.
8. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is used to execute the computer program and implement the knowledge graph completion method as described in any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, enables the processor to implement the knowledge graph completion method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Knowledge graph completion method and device, computer equipment and storage medium
CN111814480A
Target relationship detection method and system based on space-time association, and storage medium
CN112052337A