Knowledge graph completion method, device, electronic device and storage medium
By guiding message delivery in the knowledge graph, using the semantic information and graph structure of the target knowledge text, combined with shortcut paths and labels, the problem of poor knowledge graph completion is solved, and more comprehensive knowledge graph completion and integrity is achieved. promote.
Patent Information
- Application Number
- CN202110851417.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-27
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2041-07-27
AI Technical Summary
In the prior art, the knowledge graph completion effect is poor, mainly because it only uses text-level information and fails to effectively utilize implicit information outside the knowledge graph.
By determining the semantic information of the target knowledge text, the knowledge graph is guided to transmit messages, obtain coding features, and complete them based on these features, integrating external text information and structural information of the knowledge graph, and adding shortcut paths and tags to optimize message delivery.
It improves the completion effect of the knowledge graph and enhances its integrity. It is suitable for static and dynamic knowledge graphs, and can capture implicit information related to the knowledge graph structure in the text.
Smart Images

Figure CN113569056B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a knowledge graph completion method, device, electronic device and storage medium. Background Art
[0002] With the development of computer science and the rise of artificial intelligence, the application of knowledge graphs has become more and more extensive. Knowledge graphs are used to collect and organize scattered knowledge to form a structured knowledge system. Knowledge exists in the form of triples (head entity, predicate, tail entity) in knowledge graphs. However, knowledge graphs are generally constructed manually, or manually edited knowledge graphs are directly crawled from the network platform. It is inevitable that the knowledge graph is imperfect, so it is necessary to complete the knowledge graph.
[0003] Currently, there are a small number of works that use entity description information outside the knowledge graph to generate entity representations to assist in knowledge graph completion. However, most of these works only use text-level information, and the knowledge graph completion effect is poor. Summary of the invention
[0004] The present invention provides a knowledge graph completion method, device, electronic device and storage medium, which are used to solve the defect of poor completion effect in the prior art and improve the effect of knowledge graph completion.
[0005] The present invention provides a knowledge graph completion method, comprising:
[0006] Determine the target knowledge text;
[0007] Based on the semantic information of the target knowledge text, the knowledge graph to be completed is guided to perform message transmission to obtain the encoding features of the knowledge graph;
[0008] Based on the encoding features, the knowledge graph is completed.
[0009] According to a knowledge graph completion method provided by the present invention, the knowledge graph to be completed is guided to perform message transmission based on the semantic information of the target knowledge text, including:
[0010] Obtaining a graph guide vector of the knowledge graph;
[0011] Based on the graph guidance vector and the semantic guidance vector, the knowledge graph to be completed is guided to perform message transmission, and the semantic guidance vector is determined based on the semantic information of the target knowledge text.
[0012] According to a knowledge graph completion method provided by the present invention, the semantic guidance vector is determined based on the following steps:
[0013] Encoding the target knowledge text to obtain a text representation sequence;
[0014] Based on the correlation between the semantic information of each word in the text representation sequence, a semantic guidance vector of the target knowledge text is determined.
[0015] According to a knowledge graph completion method provided by the present invention, the step of obtaining a graph guide vector of the knowledge graph includes:
[0016] Based on the correlation of the edges between the nodes in the knowledge graph, a graph guidance vector of the knowledge graph is determined.
[0017] According to a knowledge graph completion method provided by the present invention, the method guides the knowledge graph to be completed to perform message transmission based on the semantic information of the target knowledge text, and also includes:
[0018] Add shortcut paths between nodes in the knowledge graph.
[0019] According to a knowledge graph completion method provided by the present invention, a shortcut path is added between nodes in the knowledge graph, and then the method further includes:
[0020] Adding a label to the shortcut path between the nodes, wherein the label is an explicit label or a non-explicit label;
[0021] The tags are determined based on entities contained in the target knowledge text and the relationships between the entities.
[0022] According to a knowledge graph completion method provided by the present invention, the knowledge graph is completed based on the encoding feature, including:
[0023] Decoding the encoded features to obtain decoded graph information, wherein the graph information includes the existence probability of a triple constructed based on every two nodes in the knowledge graph;
[0024] Based on the graph information, the knowledge graph is completed.
[0025] The present invention also provides a knowledge graph completion device, comprising:
[0026] A determination module, used to determine the target knowledge text;
[0027] A guiding module, used to guide the knowledge graph to be completed to perform message transmission based on the semantic information of the target knowledge text, and obtain the encoding features of the knowledge graph;
[0028] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned knowledge graph completion methods are implemented.
[0029] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described knowledge graph completion methods.
[0030] The knowledge graph completion method, device, electronic device and storage medium provided by the present invention can guide the knowledge graph to perform message transmission by integrating external text information of the knowledge graph, and can capture implicit information related to the knowledge graph structure in the text. On this basis, the knowledge graph is guided to be completed based on the encoding features, which can improve the effect of knowledge graph completion and improve the integrity of the knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 It is one of the flow charts of the knowledge graph completion method provided by the present invention;
[0033] Figure 2 It is a flowchart of the knowledge graph encoding method provided by the present invention;
[0034] Figure 3 It is a flow chart of the method for determining a semantic guidance vector provided by the present invention;
[0035] Figure 4 This is the second flow chart of the knowledge graph completion method provided by the present invention;
[0036] Figure 5 It is a structural schematic diagram of the knowledge graph completion model provided by the present invention;
[0037] Figure 6 It is a schematic diagram of the structure of the knowledge graph completion device provided by the present invention;
[0038] Figure 7 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] According to existing research, knowledge graphs can be divided into static knowledge graphs and dynamic knowledge graphs. Dynamic knowledge graphs use quadruples containing valid time information instead of triples to express dynamic knowledge, namely (head entity, predicate, tail entity, time information). However, the quality maintenance of dynamic knowledge graphs is also more challenging. Existing dynamic knowledge graphs are still incomplete, and the missing dynamic factual knowledge needs to be supplemented to ensure the integrity of knowledge.
[0041] As the premise and support of knowledge graph completion, knowledge graph representation aims to map entities and relationships into a low-dimensional vector space, thereby realizing the representation of semantic information of entities and relationships. In recent years, researchers at home and abroad have begun to encode time information into knowledge graph representation to improve the performance of knowledge graph reasoning and completion. This knowledge graph representation containing time information can be called a dynamic knowledge graph representation, which is used for reasoning and completion of dynamic knowledge graphs. However, existing methods simply embed time information into knowledge representation, and rarely use other information outside the graph.
[0042] At present, there are a small number of works that use entity description information outside the knowledge graph to generate entity representations to assist in knowledge graph completion. However, most of these works are only aimed at static knowledge graph completion tasks, and only use information at the text level without considering implicit information that can be inferred from the text, resulting in poor knowledge graph completion. In fact, the implicit information behind the text is related to the structure of the knowledge graph. For example, a news text reports that star A was traded to team B in 2018. It can be inferred that star A’s teammates should also change accordingly, but this is not mentioned at all in the text. This is the so-called implicit information in this scenario.
[0043] In this regard, an embodiment of the present invention provides a knowledge graph completion method, which integrates external text information of the knowledge graph to guide the knowledge graph completion. In addition to considering the information directly extracted from the external text, the implicit information in the text related to the knowledge graph structure is also taken into account. Moreover, the method is applicable to both static knowledge graph completion tasks and dynamic knowledge graph completion tasks. Figure 1 is one of the flow charts of the knowledge graph completion method provided by the present invention, such as Figure 1 As shown, the method includes:
[0044] Step 110, determining the target knowledge text.
[0045] Specifically, the target knowledge text is the external text information used to guide the completion of the knowledge graph. The target knowledge text can be obtained by crawling through crawler technology, or it can be obtained according to the text or voice input by the user during the human-computer interaction process.
[0046] Step 120, based on the semantic information of the target knowledge text, guide the knowledge graph to be completed to perform message transmission to obtain the encoding features of the knowledge graph.
[0047] Specifically, the knowledge graph to be completed is the knowledge graph that needs to be completed. The knowledge graph is composed of nodes and edges connecting the nodes, where the nodes are used to represent various types of entities and the edges are used to represent the relationships between the nodes.
[0048] In order to effectively utilize the information covered in the target knowledge text for knowledge graph completion, an embodiment of the present invention integrates the semantic information of the target knowledge text into a graph-based message passing algorithm, and uses the semantic information to guide the message to be transmitted along the structure of the knowledge graph within the knowledge graph to be completed, so that each node in the knowledge graph can selectively collect neighbor information under the guidance of the semantic information of the target knowledge text, learn the potential knowledge graph representation, and thus obtain the encoding features of the knowledge graph.
[0049] Here, the semantic information of the target knowledge text can be obtained by semantically encoding each word in the target knowledge text, or after obtaining the semantic encoding of each word in the target knowledge text, context encoding is performed based on the semantic encoding of each word. Specifically, it can be achieved through neural network structures such as Long Short-Term Memory (LSTM) and Recurrent Neural Network (RNN), and the embodiments of the present invention do not make specific limitations on this.
[0050] The purpose of message passing for the knowledge graph to be completed is to encode the knowledge graph so that the encoded representation of each node can not only reflect the information of the entity corresponding to the node, but also reflect the connection relationship of the node in the knowledge graph, as well as the information of the entities corresponding to other nodes related to the node obtained by extending the connection relationship. In order to make the message passing of the knowledge graph more targeted and more conducive to the integration of external knowledge reflected by the target knowledge text, the semantic information of the target knowledge text can be used to guide the message passing within the knowledge graph, so that the semantic information can be combined with the structure of the knowledge graph, thereby improving the reliability and comprehensiveness of the encoding features of the knowledge graph.
[0051] Guiding the knowledge graph to be completed to pass messages can be achieved by adjusting the weight of a single node in the knowledge graph receiving information transmitted by each neighboring node, for example, by adjusting the adjacency matrix of each node based on semantic information. Here, when guiding message passing based on semantic information, message passing can be performed solely based on semantic information, or message passing can be performed in combination with semantic information and associated information of nodes in the knowledge graph itself, which is not specifically limited in the embodiments of the present invention.
[0052] Step 130, completing the knowledge graph based on the encoding features.
[0053] Under the guidance of the semantic information of the target knowledge text, the encoding features of the knowledge graph containing potential information related to the knowledge graph structure can be learned, and the encoding features also contain the information from the target knowledge text that is missing in the knowledge graph to be completed. Therefore, after obtaining the encoding features, the encoding features can be decoded to obtain a knowledge graph that integrates the external knowledge indicated by the target knowledge text, that is, to obtain the completed knowledge graph. Here, the decoding can obtain the existence probability of each triple or the correlation between every two nodes.
[0054] It should be noted that the embodiment of the present invention does not specifically limit the type of knowledge graph, which can be a static knowledge graph or a dynamic knowledge graph. When the knowledge graph to be completed is a dynamic knowledge graph, it can be divided into multiple static knowledge graphs for processing according to different time information, and the time sequence is used for reasoning and completion.
[0055] The method provided by the embodiment of the present invention can capture implicit information related to the knowledge graph structure in the text by integrating external text information of the knowledge graph and guiding the knowledge graph to perform message transmission. On this basis, the knowledge graph is guided to perform completion based on encoding features, which can improve the effect of knowledge graph completion and improve the integrity of the knowledge graph.
[0056] Based on any of the above embodiments, Figure 2 It is a flow chart of the knowledge graph encoding method provided by the present invention, such as Figure 2 As shown, step 120 includes:
[0057] Step 121, obtaining a graph guide vector of the knowledge graph;
[0058] Step 122, based on the graph guidance vector and the semantic guidance vector, guide the knowledge graph to be completed to perform message transmission, and the semantic guidance vector is determined based on the semantic information of the target knowledge text.
[0059] Specifically, when guiding the message transmission of the knowledge graph, not only the semantic information of the target knowledge text can be considered, but also the association between the nodes of the knowledge graph itself, that is, the structural information of the knowledge graph. Here, the importance of each edge can be measured according to the weight of each edge connected to each node in the knowledge graph and the information of the corresponding adjacent nodes, thereby encoding the graph guidance vector of the knowledge graph.
[0060] In addition, the semantic information of the target knowledge text may be feature encoded to obtain a semantic guidance vector that can be fused with the graph guidance vector. Here, the graph guidance vector and the semantic guidance vector may be fused with the semantic guidance vector and the graph guidance vector by simple linear calculation methods such as addition or weighted addition, and then the message transmission is guided based on the fused guidance vector. Alternatively, the semantic guidance vector and the graph guidance vector may be applied separately to guide the message transmission, which is not specifically limited in the embodiment of the present invention.
[0061] The method provided by the embodiment of the present invention, combining graph-guided vectors and semantic-guided vectors to guide the message passing of the knowledge graph, helps to further improve the reliability of the encoding features and thereby optimize the knowledge graph completion effect.
[0062] Based on any of the above embodiments, after determining the target knowledge text, the encoding features of the knowledge graph can be obtained in the following manner:
[0063] First, the knowledge graph is used to obtain the graph guidance vector for each edge in the knowledge graph, and it is used as the initial attention weight of each edge. The attention weight is used to characterize the importance of the corresponding edge. The higher the attention weight, the more attention will be paid to the edge during the learning process. The semantic information of the target knowledge text is used to obtain the semantic guidance vector that can characterize the contextual information. Here, the semantic guidance vector can be directly obtained according to the correlation between the semantic information of each word in the target knowledge text, or the target knowledge text can be first encoded to obtain a text representation sequence, and then obtained according to the correlation between the semantic information of each word in the text representation sequence.
[0064] Then, the graph guidance vector and the semantic guidance vector are combined to form the final attention weight, and the initial attention weight is replaced to control the selective message transmission of the knowledge graph to be completed, so that the encoding process can learn the text semantic information and the knowledge graph structure information at the same time, and learn selectively, thereby obtaining a more complete encoding feature of the knowledge graph, which can further improve the effect of knowledge graph completion.
[0065] Based on any of the above embodiments, Figure 3 is a flow chart of the method for determining the semantic guidance vector provided by the present invention, such as Figure 3 As shown, the semantic guidance vector is determined based on the following steps:
[0066] Step 210, encoding the target knowledge text to obtain a text representation sequence;
[0067] Step 220, determining the semantic guidance vector of the target knowledge text based on the correlation between the semantic information of each word in the text representation sequence.
[0068] Specifically, the semantic guidance vector can be obtained in the following way: first, the target knowledge text is encoded to obtain an encoded text representation sequence, the text representation sequence is based on the word segment in the target knowledge text, and sequentially contains the semantic information of each word segment. The encoding method here can be to encode the target knowledge text using Bi-GRU (Bidirectional-Gate Recurrent Unit) or to encode the target knowledge text using BERT (Bidirectional Encoder Representations from Transformer); then, according to the correlation between the semantic information of each word segment in the text representation sequence and the semantic information of the context word segment of each word segment, an attention representation corresponding to the semantic extraction of the target knowledge text, i.e., the semantic guidance vector, is obtained to selectively control the transmission of the message.
[0069] The method provided by the embodiment of the present invention determines the semantic guidance vector of the target knowledge text based on the correlation between the semantic information of each word in the text representation sequence, enriches and improves the semantic information represented by the semantic guidance vector, and helps to optimize the effect of knowledge graph completion.
[0070] Based on any of the above embodiments, the semantic guidance vector can be obtained based on the following steps:
[0071] First, use Bi-GRU to encode the given target knowledge text into a representation sequence {u1,u2,…,u |S|}, where S represents the length of the target knowledge text, u1,u2,…,u |S| It is the semantic information of each word in the target knowledge text.
[0072] Then the sequence attention mechanism can be used to calculate the semantic guidance vector c of the target knowledge text lr :
[0073]
[0074] in, Represents the text attention weight, which is calculated as follows:
[0075]
[0076] in, is a trainable guidance vector that guides the context of extracting dependencies.
[0077] Based on any of the above embodiments, step 121 includes:
[0078] Based on the correlation of the edges between the nodes in the knowledge graph, the graph guidance vector of the knowledge graph is determined.
[0079] Specifically, in the knowledge graph, the edges between nodes have their own attributes, such as the type of relationship between two entities, or the closeness of the relationship between two entities. After encoding each edge in the knowledge graph, the correlation between the edges can be calculated, and a graph guidance vector can be generated to guide the attention or more reception of messages transmitted by edges with higher correlation during the message transmission process, and weaken or receive less messages transmitted by edges with lower correlation, so that the knowledge graph can learn structural information more selectively and specifically during the encoding process.
[0080] Here, the graph guidance vector can be calculated using the attention mechanism, and the correlation between the edges of each node can be obtained by performing attention interaction on the encoded representation of the edges between each node.
[0081] Based on any of the above embodiments, the message passing guided by the semantic guidance vector and the graph guidance vector in step 122 can be implemented by a relational graph attention encoder (Relational Graph Attention layer, R-GAT) that combines R-GCN (Relational Graph Convolutional Networks) and GAT (Graph Attention Networks).
[0082] Typically, the layered propagation rule of R-GCN is defined as follows:
[0083]
[0084] in, is the normalized adjacency matrix of relation r, is the hierarchical trainable weight matrix of relation r, σ(·) represents the activation function, for example, ReLU (Rectified Linear Units, linear rectification function) can be used. l is the latent entity representation at layer l, H l+1 is the potential entity representation of the l+1th layer. On R-GCN, we can use the GAT attention function Introducing the attention mechanism, we get R-GAT. The definition is as follows:
[0085]
[0086] in, express The element in row i and column j, Represents the neighbor index set of node i under relation r. lr (·) represents the attention function. and They represent the i-th and j-th entity representations of the l-th layer respectively.
[0087] middle, The part can guide the hierarchical propagation of R-GCN. Therefore, the semantic guidance vector and the graph guidance vector can be combined to replace To achieve message passing guided by semantic guidance vectors and graph guidance vectors,
[0088] Furthermore, the graph guidance vector can be obtained through GAT The specific acquisition method can be seen in the following formula:
[0089]
[0090] in, is the attention representation calculated by GAT, || represents the concatenation operation, is a relation-specific trainable vector that acts as a graph guidance vector to decide which edges are worth noting.
[0091] On this basis, the semantic guidance vector and the graph guidance vector can be fused through the following formula to obtain To replace the R-GAT
[0092]
[0093] Among them, U lr is a trainable transformation matrix, α lr ∈[0,1] can be a fixed value or obtained through training. lr = 1, then the attention function degenerates to the attention function of GAT, and the encoder degenerates to R-GAT. R-GAT can be easily pre-trained to obtain better entity and relation embeddings when no text fragments are provided.
[0094] Based on any of the above embodiments, before step 120, the following step is further included:
[0095] Add shortcut paths between nodes in the knowledge graph.
[0096] Specifically, considering that the entities mentioned in the target knowledge text may be far apart or even unreachable in the knowledge graph, a single-layer or double-layer encoder can only ensure that nodes in the knowledge graph can collect information from nearby nodes. In order to enable more direct interaction through the graph structure, before encoding, the embodiment of the present invention adds shortcut paths between each node in the knowledge graph, links all nodes in the knowledge graph together, so that even if the nodes are far apart in the topological structure of the knowledge graph, messages can be transmitted to each other through shortcut paths, thereby greatly improving the completion effect of the knowledge graph.
[0097] Based on any of the above embodiments, a shortcut path is added between nodes in the knowledge graph, and then the following is further included:
[0098] Labels are added to the shortcut paths between nodes. The labels are explicit labels or implicit labels. The labels are determined based on the entities contained in the target knowledge text and the relationships between the entities.
[0099] Specifically, considering that the relationship between entities corresponding to each node may be different, even if the semantics of the target knowledge text guides message transmission, if the labels of the shortcut paths between nodes are unified, there may be cases of incorrect message transmission. After adding shortcut paths between nodes in the knowledge graph, it is also necessary to add relationship labels to each shortcut path to mark these links, so that in the process of message transmission, it can be distinguished which shortcut paths are only set up to facilitate message transmission, and which shortcut paths are not only for message transmission, but also link the two nodes corresponding to the knowledge that needs to be completed, which need to be paid special attention to.
[0100] Therefore, the labels of the shortcut paths set in the embodiment of the present invention are divided into two types: explicit labels ADD and non-explicit labels OTHER. Among them, the explicit label ADD reflects that the entities corresponding to the nodes at both ends of the shortcut path are mentioned in the target knowledge text, and there is a relationship between the two entities in the target knowledge text. The non-explicit label OTHER reflects that at least one of the entities corresponding to the nodes at both ends of the shortcut path is not mentioned in the target knowledge text, or although both entities are mentioned in the target knowledge text, there is no relationship between the two entities in the target knowledge text. For example, the target knowledge text is "Star A announced that he will join Team B". Since Star A and Team B are mentioned in the target knowledge text, and it is clear that there is a relationship between Star A and Team B, the label of the shortcut path between the two entities corresponding to Star A and Team B is marked as ADD, and the labels of the remaining shortcut paths are marked as OTHER.
[0101] The shortcut path marked with the explicit label ADD can reflect the external knowledge that needs to be supplemented in the target knowledge text, and needs to be paid attention to in message transmission, while the shortcut path marked with the non-explicit label OTHER is only used for the quick transmission of messages and does not need to be paid attention to. By adding the explicit label ADD and the non-explicit label OTHER, it is clear whether the shortcut paths between nodes need to be paid attention to during message transmission, which provides help to further improve the reliability of message transmission under semantic guidance.
[0102] Furthermore, the entities contained in the target knowledge text can be realized by performing entity extraction or entity linking on the target knowledge text. The relationship between entities can be obtained by inputting the extracted entities into an entity relationship judgment model pair by pair after the entities are extracted. Both entity extraction and relationship judgment can be realized by common entity processing techniques, which are not specifically limited in the embodiments of the present invention.
[0103] Based on any of the above embodiments, the addition of the shortcut path label can be implemented by a pre-trained model. For example, for each entity pair (e i ,e j ), where e i ,e j All are entities mentioned in the target knowledge text. The probability P(z) of each label can be obtained using a multi-layer perceptron classifier:
[0104] P(z)=softmax(MLP([h i ||h j ]))
[0105] Among them, the shortcut label z∈{ADD,OTHER}, h i and h j Entity e i and e j Representation of an entity. i and e j Entity representation i and h j It can be obtained by encoding separately, or it can be obtained by applying the encoder of step 120 to perform message transmission on the knowledge graph, and the embodiment of the present invention does not make specific limitations on this.
[0106] Based on any of the above embodiments, Figure 4 This is the second flow chart of the knowledge graph completion method provided by the present invention. Figure 4 As shown, step 130 includes:
[0107] Step 131, decoding the encoded features to obtain decoded graph information, where the graph information includes the existence probability of a triple constructed based on every two nodes in the knowledge graph;
[0108] Step 132, complete the knowledge graph based on the graph information.
[0109] Specifically, after obtaining the encoded features of the knowledge graph, the decoder can be used to decode the encoded features to obtain the decoded graph information. Here, the graph information may include the existence probability of each candidate triple predicted by the decoder. The candidate triple can be constructed based on every two nodes in the knowledge graph. The existence probability represents the probability that the corresponding candidate triple exists in the completed knowledge graph.
[0110] On this basis, the knowledge graph can be completed based on the graph information. The completion method here can be to set an existence probability threshold and add triples with an existence probability greater than the threshold to the knowledge graph. It can also be sorted according to the size of the existence probability and select triples with a higher existence probability to add to the knowledge graph. The embodiment of the present invention does not make specific limitations on this.
[0111] Based on any of the above embodiments, considering that DistMult has good performance in the knowledge graph completion task, the embodiment of the present invention uses DistMult as a decoder to perform step 131. For each possible triple (e i ,r k ,e j ), where e i ,e j is a node in the knowledge graph, r k For the relationship between nodes, DistMult can use the sigmoid function to calculate the probability P(y) of its existence in the completed knowledge graph. The specific formula is as follows:
[0112]
[0113] in, represents element-wise product, h i and h j They are the entity e in the encoding feature i and e j Representation of an entity.
[0114] Taking into account the probability of existence of a triple obtained by decoding, an embodiment of the present invention can treat knowledge graph completion as a binary classification task, and use cross entropy loss training to combine the encoding process in step 120 and the encoding and decoding model in the decoding process in step 131.
[0115] Based on any of the above embodiments, an embodiment of the present invention proposes a new knowledge graph completion model, which follows the encoder-decoder framework, which includes a graph-based encoder that learns potential knowledge graph representations under the guidance of external text, and a decoder that scores candidate triples.
[0116] Figure 5 It is a structural diagram of the knowledge graph completion model provided by the present invention, wherein the encoder is the Encoder in the figure, the decoder is the Decoder in the figure, the target knowledge text is the External text information in the figure, the shortcut path is the Shortcut in the figure, the attention mechanism based on the target knowledge text is the Text-based attention in the figure, the knowledge graph before encoding is executed is the Before in the figure, the knowledge graph during the encoding process is the Intermediatestate in the figure, and the knowledge graph after decoding is the After in the figure. Figure 5 As shown in the figure, by adding a shortcut, entity S can directly receive information about other textual mentions of entities in the graph. Then, under the guidance of Text-based attention and R-GAT, S selectively collects neighbor information and moves closer to the candidate entity. The dotted arrow indicates the direction of movement and the width indicates the weight. Finally, the decoder DistMult completes the knowledge graph.
[0117] The knowledge graph completion device provided by the present invention is described below. The knowledge graph completion device described below and the knowledge graph completion method described above can be referenced to each other.
[0118] Based on any of the above embodiments, Figure 6 is a schematic diagram of the structure of the knowledge graph completion device provided by the present invention, such as Figure 6 As shown, the device comprises:
[0119] A determination module 610 is used to determine a target knowledge text;
[0120] A guiding module 620 is used to guide the knowledge graph to be completed to perform message transmission based on the semantic information of the target knowledge text, and obtain the encoding features of the knowledge graph;
[0121] The completion module 630 is used to complete the knowledge graph based on the encoding features.
[0122] The device provided by the embodiment of the present invention can guide the knowledge graph to perform message transmission by integrating external text information of the knowledge graph, and can capture implicit information related to the knowledge graph structure in the text. On this basis, it can guide the knowledge graph to perform completion based on encoding features, which can improve the effect of knowledge graph completion and improve the integrity of the knowledge graph.
[0123] Based on any of the above embodiments, the guiding module 620 includes:
[0124] An acquisition unit, used to acquire a graph guide vector of a knowledge graph;
[0125] The guiding unit is used to guide the knowledge graph to be completed to perform message transmission based on the graph guiding vector and the semantic guiding vector. The semantic guiding vector is determined based on the semantic information of the target knowledge text.
[0126] Based on any of the above embodiments, the semantic guidance vector is determined based on the following steps:
[0127] Encode the target knowledge text to obtain a text representation sequence;
[0128] Based on the correlation between the semantic information of each word in the text representation sequence, the semantic guidance vector of the target knowledge text is determined.
[0129] Based on any of the above embodiments, the acquiring unit is used for:
[0130] Based on the correlation of the edges between the nodes in the knowledge graph, the graph guidance vector of the knowledge graph is determined.
[0131] Based on any of the above embodiments, the device further includes a shortcut path module, which is used to:
[0132] Add shortcut paths between nodes in the knowledge graph.
[0133] Based on any of the above embodiments, the device further includes a label module, which is used to:
[0134] Add labels to the shortcut paths between nodes. The labels can be explicit or implicit.
[0135] Tags are determined based on the entities contained in the target knowledge text and the relationships between entities.
[0136] Based on any of the above embodiments, the completion module 630 includes:
[0137] A decoding unit, used to decode the encoded features to obtain decoded graph information, where the graph information includes the existence probability of a triple constructed based on every two nodes in the knowledge graph;
[0138] The completion unit is used to complete the knowledge graph based on the graph information.
[0139] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the knowledge graph completion method, which includes: determining the target knowledge text; based on the semantic information of the target knowledge text, guiding the knowledge graph to be completed to perform message transmission to obtain the encoding features of the knowledge graph; based on the encoding features, completing the knowledge graph.
[0140] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0141] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the knowledge graph completion method provided by the above methods, and the method includes: determining the target knowledge text; based on the semantic information of the target knowledge text, guiding the knowledge graph to be completed to perform message transmission to obtain the encoding features of the knowledge graph; based on the encoding features, completing the knowledge graph.
[0142] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the knowledge graph completion method provided by the above-mentioned methods, the method comprising: determining the target knowledge text; based on the semantic information of the target knowledge text, guiding the knowledge graph to be completed to perform message transmission to obtain the encoding features of the knowledge graph; based on the encoding features, completing the knowledge graph.
[0143] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0144] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0145] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A knowledge graph completion method, characterized in that: include: Determine a target knowledge text, where the target knowledge text refers to external text information used to guide knowledge graph completion; Based on the semantic information of the target knowledge text, the guide message is transmitted along the structure of the knowledge graph in the knowledge graph to be completed, so that any node in the knowledge graph collects information transmitted by each neighboring node under the guidance of the semantic information of the target knowledge text to obtain the encoding features of the knowledge graph; Based on the encoding features, completing the knowledge graph; The guiding message to be transmitted along the structure of the knowledge graph in the knowledge graph to be completed based on the semantic information of the target knowledge text includes: Obtaining a graph guidance vector of the knowledge graph, wherein the graph guidance vector is determined based on the relevance of edges between nodes in the knowledge graph, wherein the relevance of edges between nodes is obtained by performing attention interaction on encoded representations of edges between nodes; Based on the graph guidance vector and the semantic guidance vector, the guidance message is transmitted along the structure of the knowledge graph within the knowledge graph to be completed, and the semantic guidance vector is determined based on the semantic information of the target knowledge text.
2. The knowledge graph completion method according to claim 1, characterized in that: The semantic guidance vector is determined based on the following steps: Encoding the target knowledge text to obtain a text representation sequence; Based on the correlation between the semantic information of each word in the text representation sequence, a semantic guidance vector of the target knowledge text is determined.
3. The knowledge graph completion method according to claim 1, characterized in that: The method of guiding the message to be transmitted along the structure of the knowledge graph in the knowledge graph to be completed based on the semantic information of the target knowledge text also includes: Add shortcut paths between nodes in the knowledge graph.
4. The knowledge graph completion method according to claim 3, characterized in that: The step of adding a shortcut path between nodes in the knowledge graph further includes: Adding a label to the shortcut path between the nodes, wherein the label is an explicit label or a non-explicit label; The tags are determined based on entities contained in the target knowledge text and the relationships between the entities.
5. The knowledge graph completion method according to any one of claims 1 to 4, characterized in that: The completing the knowledge graph based on the encoding feature includes: Decoding the encoded features to obtain decoded graph information, wherein the graph information includes the existence probability of a triple constructed based on every two nodes in the knowledge graph; Based on the graph information, the knowledge graph is completed.
6. A knowledge graph completion device, characterized in that: include: A determination module, used to determine a target knowledge text, wherein the target knowledge text refers to external text information used to guide knowledge graph completion; A guiding module, which is used to guide the message to be transmitted along the structure of the knowledge graph in the knowledge graph to be completed based on the semantic information of the target knowledge text, so that any node in the knowledge graph collects the information transmitted by each neighboring node under the guidance of the semantic information of the target knowledge text, and obtains the encoding features of the knowledge graph; A completion module, used to complete the knowledge graph based on the encoding features; The guiding module is specifically used for: Obtaining a graph guidance vector of the knowledge graph, wherein the graph guidance vector is determined based on the relevance of edges between nodes in the knowledge graph, wherein the relevance of edges between nodes is obtained by performing attention interaction on encoded representations of edges between nodes; Based on the graph guidance vector and the semantic guidance vector, the guidance message is transmitted along the structure of the knowledge graph within the knowledge graph to be completed, and the semantic guidance vector is determined based on the semantic information of the target knowledge text.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the knowledge graph completion method as described in any one of claims 1 to 5 are implemented.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the knowledge graph completion method as described in any one of claims 1 to 5 are implemented.
