Path-aware knowledge graph completion method based on convolutional network and related equipment
By introducing path perception technology of convolutional networks into the knowledge graph completion method, taking into account the importance of triplets and paths, the problem of low accuracy caused by existing methods ignoring path information is solved, and more efficient knowledge graph completion is achieved.
Patent Information
- Application Number
- CN202111327210.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2041-11-10
AI Technical Summary
The existing neural network-based knowledge graph completion method ignores the rich path information in the knowledge graph, resulting in a low accuracy of completion.
A path perception method based on convolutional network is proposed. Through a pre-constructed sorting model, the local and global importance of triplet information and paths are comprehensively considered, and the relationship scores of candidate triplets are output to determine whether the triplet is established or not.
By introducing path information and considering its importance, the accuracy of knowledge graph completion is significantly improved and the characteristics of triples can be reflected more accurately.
Smart Images

Figure CN114297397B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data mining and deep learning technology, and in particular to a convolutional network-based path-aware knowledge graph completion method and related equipment. Background Art
[0002] Knowledge graph is a structured semantic knowledge base used to quickly describe concepts and their relationships in the physical world. Knowledge graph effectively processes, handles and integrates the data of complex documents and extracts them into simple and clear (head entity h, relationship r, tail entity t) triples. For example, if the capital of China is Beijing, it can be extracted as a triple (China, capital, Beijing).
[0003] Knowledge graph completion aims to mine implicit triples based on known triples in the knowledge graph. As an important means to improve the integrity of the knowledge graph, it has attracted widespread attention from researchers at home and abroad, and a large number of knowledge graph completion methods have emerged. The neural network-based knowledge graph completion method has developed into one of the most mainstream knowledge graph completion methods based on its advantage of being able to automatically extract deep features of data. However, the existing neural network-based knowledge graph completion methods usually only consider the entity and relationship information of triples in the knowledge graph, ignoring the path information in the knowledge graph that contains rich reasoning patterns, which seriously affects the accuracy of knowledge graph completion. Summary of the invention
[0004] In view of this, the purpose of the present disclosure is to propose a path-aware knowledge graph completion method and related equipment based on convolutional networks.
[0005] Based on the above objectives, the present disclosure provides a path-aware knowledge graph completion method based on a convolutional network, including:
[0006] Obtaining an initial set of triples from the knowledge graph;
[0007] Determine a candidate triple set based on the initial triple set;
[0008] Inputting the candidate triple set into a pre-built sorting model, outputting a relationship score of each candidate triple in the candidate triple set through the sorting model, determining at least one candidate triple from the candidate triple set based on the relationship score, and adding it to the knowledge graph;
[0009] Wherein, the sorting model is pre-trained.
[0010] Based on the same inventive concept, the present disclosure also provides a knowledge graph completion device based on path perception of convolutional neural network, comprising:
[0011] An acquisition set module is configured to acquire an initial triple set from the knowledge graph;
[0012] A determination set module, configured to determine a candidate triple set based on the initial triple set;
[0013] A determination and supplementation module is configured to input the candidate triple set into a pre-built sorting model, output a relationship score of each candidate triple in the candidate triple set through the sorting model, determine at least one candidate triple from the candidate triple set based on the relationship score, and supplement it into the knowledge graph;
[0014] Wherein, the sorting model is pre-trained.
[0015] Based on the same inventive concept, the present disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor implements any of the methods described above when executing the computer program.
[0016] Based on the same inventive concept, the present disclosure further provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute any of the methods described above.
[0017] As can be seen from the above, the present disclosure provides a path-aware knowledge graph completion method and related equipment based on a convolutional network. Through a pre-constructed sorting model, the relationship score of each candidate triple in the candidate triple set is output, and the relationship score is determined by comprehensively considering the triple information, the local importance of the triple path, and the global importance, so that the relationship score can accurately, comprehensively and deeply reflect the characteristics of each triple, so as to judge whether the triple is valid or not. Therefore, based on the relationship score, the candidate triple is determined from the candidate triple set and added to the knowledge graph, which greatly improves the accuracy of the knowledge graph completion. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present disclosure or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 A schematic diagram of the local and global importance of a triplet path according to an embodiment of the present disclosure;
[0020] Figure 2 A schematic diagram of a flow chart of a path-aware knowledge graph completion method based on a convolutional network according to an embodiment of the present disclosure;
[0021] Figure 3 A schematic diagram of triple classification experimental results of the completion method and the comparison method of the embodiment of the present disclosure on the data set WN18;
[0022] Figure 4 A schematic diagram of triple classification experimental results of the completion method and the comparison method of the embodiment of the present disclosure on the data set FB15k;
[0023] Figure 5 A schematic diagram of triple classification experimental results of the completion method and the comparison method of the embodiment of the present disclosure on the data set WN18RR;
[0024] Figure 6 A schematic diagram of triple classification experimental results of the completion method and the comparison method of the embodiment of the present disclosure on the data set FB15k-237;
[0025] Figure 7 It is a structural schematic diagram of a knowledge graph completion device based on path perception of a convolutional neural network according to an embodiment of the present disclosure;
[0026] Figure 8 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] In order to make the objectives, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0028] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the embodiments of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0029] Researchers explored the application of convolutional neural networks (CNN) in knowledge graph completion and achieved relevant experimental results. For example, they proposed a layered convolutional network model ConvE, which consists of a 2D convolutional layer, a mapping layer, and an inner product layer; they applied convolutional neural networks to knowledge graph completion and proposed a model ConvKB, which can model the translation characteristics and global features of triples; and a model CapsE, which introduced a capsule network based on ConvKB to further improve the feature extraction capability. However, as described in the background technology, these methods only consider the triple information in the knowledge graph, but ignore the rich path information in the knowledge graph, which seriously affects the accuracy of knowledge graph completion.
[0030] It is observed that the path of entity pairs in a triple describes the relationship of the connected entity pairs in a fine-grained way from some aspects, and the local and global importance of the path are different. Figure 1 As shown in Figure 1, the two paths of the entity pair (Tom, USA), birthplace->country and friends->nationality, describe the relationship nationality from the perspective of geographical location and social relationship, respectively. Given that the path birthplace->country describes the relationship nationality at a more essential level than the path friends->nationality, from a local perspective ( Figure 1 From the perspective of the dashed box, the path birthplace->country has a higher importance. Since the path friend->nationality also exists between the entity pairs connected by the relationship travel (Tom, UK), from the global perspective ( Figure 1 From the perspective of the solid box, the path friend-->nationality is less important than the path birthplace-->country. The string starting with “ / m / ” above the entity in the figure represents the entity’s ID in Freebase.
[0031] In view of this, one or more embodiments of the present disclosure provide a path-aware knowledge graph completion method based on a convolutional network and related devices. The completion method improves the accuracy of knowledge reasoning by introducing path information and further considering its local and global importance. Specifically, the local importance of each path between a given entity pair is automatically measured by using an attention mechanism, and a degree-guided inverse path frequency index (DIPF) is proposed to calculate the global importance of each path.
[0032] The technical solutions of one or more embodiments of the present disclosure are described in detail below through specific examples.
[0033] refer to Figure 2One or more embodiments of the present disclosure provide a path-aware knowledge graph completion method based on a convolutional network, comprising the following steps:
[0034] Step 101, obtaining an initial triple set from the knowledge graph.
[0035] In this step, the knowledge graph is a structured representation of the knowledge base. The knowledge base is composed of unstructured natural language. This organization method is very suitable for human reading but not for computer processing. Therefore, knowledge triples can be extracted from unstructured text through template extraction and model extraction to form a knowledge graph. The initial triple set can be easily obtained from the knowledge graph. Figure 1 The knowledge graph in can obtain 10 initial triple sets, namely: (Tom, nationality, United States), (Tom, birthplace, Syracuse), (Syracuse, country, United States), (Tom, friend, Smith), (Smith, nationality, United States), (Tom, travel, United Kingdom), (Tom, friend, David), (David, nationality, United Kingdom), (David, birthplace, Leytonstone), (Leytonstone, country, United Kingdom).
[0036] Step 102: Determine a candidate triple set based on the initial triple set.
[0037] In this step, the initial triple set contains multiple entities and multiple relationships. Multiple new triples are constructed based on the multiple entities and multiple relationships, and these new triples are used as candidate triples to be added to the knowledge graph.
[0038] Step 103, input the candidate triple set into a pre-built ranking model, output the relationship score of each candidate triple in the candidate triple set through the ranking model, determine at least one candidate triple from the candidate triple set based on the relationship score, and add it to the knowledge graph. The ranking model is pre-trained.
[0039] In this step, the pre-built sorting model performs feature extraction on the input candidate triples, mainly extracting characteristic information such as the head entity information, tail entity information, relationship information, path information, etc. of the triples. The features extracted for each candidate triple are different, and the relationship score of each candidate triple is different. Therefore, the candidate triples to be added to the knowledge graph can be determined based on the different relationship scores of each candidate triple.
[0040] In some embodiments, determining a candidate triple set based on the initial triple set includes:
[0041] Step 201 : extracting entities and relations from the initial triple set respectively to obtain an entity set and a relationship set.
[0042] In this step, all the head entities and tail entities in the initial triple set are extracted to obtain the entity set composed of the head entity and the tail entity, and the number of types of all relations is extracted to obtain the relationship set. New triples are constructed through the obtained entity set and relationship set for pre-filling into the knowledge graph. For example Figure 1 In the knowledge graph, there are 7 entities in the entity set, namely: Tom, United States, Syracuse, Smith, United Kingdom, David, Leytonstone, and there are 5 relationships in the relationship set, namely: Nationality, Place of Birth, Country, Friends, and Travel.
[0043] Step 202: Arrange and combine all entities in the entity set and all relations in the relation set to obtain a first triple set.
[0044] In this step, the permutation and combination method may be: select two entities from the entity set, select one relationship from the relationship set, and pair the two entities and one relationship to form a first triple. Figure 1 There are 7 entities: Tom, USA, Syracuse, Smith, UK, David, Leytonstone; 5 relations: nationality, birthplace, country, friends, travel; the permutations and combinations are (Tom, nationality, USA), (Tom, birthplace, USA), (Tom, country, USA), (USA, nationality, Tom), etc. 7×6×5=210 triples.
[0045] Step 203: Remove the triples included in the initial triple set from the first triple set to obtain the candidate triple set.
[0046] In this step, if there is a first triple in the first triple set, and the two entities, or two entities, or a relationship of this first triple are the same as an initial triple in the initial triple set, it should be removed. For example, if there is an initial triple (A, r, B) in the initial triple set, and there are two first triples (A, r, B) and (A, r', B) in the first triple set, then the two first triples (A, r, B) and (A, r', B) need to be removed from the first triple set. The specific reasons are: for the first triple (A, r, B), it already exists in the initial triple set, and there is no need to dig and supplement it, so it is removed; for the first triple (A, r', B), we know that if two entities are known, then the relationship between the two entities is definite and unique, and the relationship between entity A and entity B already exists in the initial triple set, so the first triple (A, r', B) is obviously wrong, so it is removed.
[0047] In some embodiments, outputting the relationship score of each candidate triple in the candidate triple set by the ranking model includes:
[0048] Step 301: Determine a path set corresponding to each entity pair in the candidate triplet.
[0049] In this step, there may be multiple paths from the head entity to the tail entity of a candidate triplet. The path between the head entity h and the tail entity t of the candidate triplet (h, r, t) can be marked as P(h, t) = {p1, p2, ..., p N}, where path p = (r1, ..., r m ) consists of a series of relationships between entities, namely Triples have rich path information. Integrating path information into triple feature extraction can represent triples at a deeper level. As mentioned above, Figure 1 The two paths for the entity pair (Tom, USA) in the graph are birthplace->country and friends->nationality, and these paths have different importance.
[0050] Step 302, obtaining a head entity vector, a tail entity vector, a relationship vector of the entity pair, and a path vector corresponding to each path in the path set through a convolutional neural network based on the entity pair and the path set;
[0051] In this step, the convolutional neural network has good fault tolerance, parallel processing and self-learning capabilities. It can handle problems with complex environmental information, unclear background knowledge and unclear reasoning rules. It has fast running speed, good adaptive performance and high resolution. With the help of the excellent processing power of the convolutional neural network, deep feature extraction can be performed on entity pairs and path sets. For example, the head entity h, relationship r, tail entity t and path set P(h, t) = {p1, p2, ..., p2, ..., p3, ..., p4, ..., p5, ..., p6, ..., p7, ..., p8, ..., p9, ..., p1, ..., p1, ..., p2 ... N The i-th path p in i , extract the input to the convolutional neural network, and encode it through the convolutional neural network to obtain the corresponding head entity vector v h , tail entity vector v t , relationship vector v r and the path vector p i .
[0052] Step 303: Calculate the local importance of each path in the path set through an attention mechanism to obtain a local weight of each path.
[0053] In this step, the importance of each path between entity pairs is often different. Finding paths that contain rich relational reasoning patterns is helpful for knowledge reasoning tasks. The attention mechanism can reflect the importance of different data by assigning different weights to different data. The present invention uses the attention mechanism to measure the local importance of paths between entities.
[0054] In some embodiments, for a candidate triple (h, r, t), the local weight of the i-th path It is expressed as: v r Represents the relation vector of the candidate triple (h, r, t), p i represents the path vector of the i-th path; W L ∈R k×k Represents the parameter matrix, and sigmoid represents the nonlinear activation function.
[0055] Step 304: perform global importance calculation on each path in the path set by using degree-guided inverse path frequency (DIPF) to obtain a global weight of each path.
[0056] In this step, since the path local importance only focuses on the path set of a given entity pair connected by a relationship, it ignores that the paths in the path set may also appear between entity pairs connected by other relationships. Generally, the more path sets a path appears in, the less important the path is. We propose a degree-guided inverse path frequency to determine the global importance of each path in the path set.
[0057] In some embodiments, the global weight of the i-th path of the candidate triple (h, r, t) is determined Specifically include:
[0058] (1) Obtain each relationship r in the candidate triple set, and determine the entity pair (h) corresponding to each relationship r r , t r ) i , where i = 1, 2, ..., n r , n r Represents the number of entity pairs connected by each relation r.
[0059] In this step, for example Figure 1 In the figure, the entity pairs corresponding to the relationship nationality are (Tom, United States), (Smith, United States) and (David, United Kingdom), so the number of entity pairs connected by the relationship nationality is 3.
[0060] (2) Based on the candidate triple set, calculate the entity pair (hr, tr) i The node degree of . The calculation formula is: Among them, NodeDegree(·) represents the function of calculating the node degree of entity pairs, represents the node degree of the head entity h, represents the node degree of the tail entity t, and deg(·) is used to solve the node degree of an entity, which is calculated as the number of edges connected to the entity in the set of candidate triples.
[0061] In this step, for example Figure 1 For the entity pair (Tom, USA) in the relationship nationality, there are 5 edges connected to the head entity Tom, so the node degree of the head entity Tom is 5; there are 3 edges connected to the tail entity USA, so the node degree of the tail entity USA is 3; adding the node degrees of the head entity Tom and the tail entity USA, the node degree of the entity pair (Tom, USA) is calculated to be 8.
[0062] (3) Based on the entity pair (h r , t r ) i The node degree of the entity pair with the maximum node degree (h r , t r ) b , expressed as: NodeDegree((h r , t r ) b )=max[NodeDegree((h r , t r )i ) ], i = 1, 2, ..., nr, where max[·] represents the maximization function.
[0063] In this step, the entity pair with the largest node degree is selected from all entity pairs (h r , t r ) b .
[0064] (4) Based on the candidate triple set, determine the entity pair P((h r , t r ) b ), expressed as: Among them, m r Represents an entity pair (h r , t r ) b The number of paths it has.
[0065] (5) Based on the entity r , t r ) b ) path set, and obtain the global weight of the i-th path of the candidate triple (h, r, t) It is expressed as:
[0066]
[0067] in, Indicates the total number of relations in the candidate triple set, pt i Represents the path p in the candidate triple (h, r, t) i In the path set P((h r , t r ) b ) appears in .
[0068] Step 305: Obtain a feature relationship vector by calculation based on the path vector, the relationship vector, the local weight and the global weight.
[0069] In this step, the feature relationship vector v of the candidate triple (h, r, t) r′ It is expressed as: in, represents the local weight of the i-th path of the candidate triple (h, r, t) represents the global weight of the i-th path of the candidate triple (h, r, t) p i represents the path vector of the i-th path of the candidate triple (h, r, t), v r Represents the relation vector of the candidate triple (h, r, t).
[0070] Step 306: Determine a score function based on the head entity vector, the tail entity vector, and the feature relationship vector.
[0071] In this step, the score function of the candidate triple (h, r, t) is expressed as:
[0072]
[0073] Among them, σ represents the nonlinear activation function sigmoid, ψ represents the average pooling operation, and v h The head entity vector of the candidate triple (h, r, t), p i represents the i-th path vector, which is calculated as Represents the composition path p i The vector representation of the relationship is represents the global weight of the i-th path of the candidate triple (h, r, t), represents the local weight of the i-th path of the candidate triple (h, r, t) v r Represents the relation vector of the candidate triple (h, r, t), v trepresents the tail entity vector of the candidate triple (h, r, t), * represents the convolution operator, and Ω and w represent the network parameters.
[0074] p i represents the i-th path vector, which is calculated as Further explanation is as follows: Figure 1 As shown, a path for the entity pair (Tom, United States) is: birthplace-->country, where the relationship r1 between the entity pair (Tom, Syracuse) is the birthplace, and the relationship r2 between (Syracuse, United States) is the country, V r1 It is to convert the birthplace of the relationship into a vector, V r2 That is, convert the relationship country into a vector, the i-th path vector p i is equal to V r1 +V r2 .
[0075] Step 307: Determine the relationship score of each of the candidate triples in the candidate triple set based on the score function.
[0076] In this step, the relationship score of each candidate triple is calculated by a score function.
[0077] In some embodiments, determining at least one candidate triple from the set of candidate triples based on the relationship score and adding it to the knowledge graph includes:
[0078] Step 401 : grouping candidate triples with the same entity pairs in the candidate triple set to obtain a plurality of grouped candidate triple sets.
[0079] In this step, in the knowledge graph completion, usually two entities are known, and the relationship between the two entities is completed. Thus, the candidate triples of the same entity pair are grouped to determine the relationship between the entity pair.
[0080] Step 402 , respectively remove the candidate triples whose relationship scores are greater than a preset threshold from the plurality of grouped candidate triple sets to obtain a plurality of remaining candidate triple sets.
[0081] In this step, in the knowledge graph completion, if a triple relationship is greater than a preset threshold, then this triple must not be true. Therefore, the candidate triples whose relationship scores are greater than the preset threshold are eliminated. It should be noted that there may be a set of grouped candidate triples, in which all the grouped candidate triple relationship scores are greater than the preset threshold, then the grouped candidate triple set is eliminated, and no grouped candidate triples in the grouped candidate triple set are selected for completion.
[0082] Step 403, selecting the candidate triple with the smallest relationship score from each of the remaining candidate triple sets and adding it to the knowledge graph.
[0083] In this step, the smaller the relationship score of the candidate triple is, the more likely it is that the candidate triple is valid or true, so the candidate triple with the smallest relationship score is selected and added to the knowledge graph.
[0084] In some embodiments, the pre-training of the ranking model includes:
[0085] Step 501, construct a pre-training model and a training set.
[0086] In this step, we select the ConvKB model as the pre-trained model, construct a training set to train and optimize the pre-trained model, and thus obtain the ranking model with better performance disclosed in the present invention, namely, the PConvKB model.
[0087] Step 502: extract entities from the training set to obtain a training set entity set.
[0088] Step 503: construct a set of perturbation triples corresponding to each training triple in the training set based on the training set and the training set entity set.
[0089] Step 504: Remove the triplets included in the training set from the perturbation triple set to obtain a perturbation candidate triple set.
[0090] In this step, if a perturbation triplet in the perturbation triplet set is the same as a triplet in the training set, the perturbation triplet is eliminated.
[0091] Step 505: Input the training triples and each perturbation candidate triple in the perturbation candidate triple set into the pre-trained model respectively, and output the training relationship scores and perturbation relationship scores corresponding to the training triples and the perturbation candidate triples respectively through the pre-trained model.
[0092] Step 506: determine a loss function based on the training relationship score and the perturbation relationship score, and minimize the loss function to obtain the ranking model.
[0093] In this step, the loss function is expressed as:
[0094]
[0095] in, represents the loss function; represents the training set, represents the set of perturbation candidate triplets; λ represents the L2 regularization term parameter, and w represents the weight vector.
[0096] In some embodiments, the step of constructing a set of perturbation triples corresponding to each training triple in the training set based on the training set and the training set entity set respectively includes:
[0097] For each triple in the training set, the head entity or the tail entity in the triple is replaced with each entity in the training set entity set, so as to construct a plurality of perturbation triples, and the plurality of perturbation triples constitute a perturbation triple set.
[0098] There are two ways to construct perturbation triples, and you can choose either one when constructing. The first is to replace the head entity in the training triple with each entity in the training set entity set; the second is to replace the tail entity in the training triple with each entity in the training set entity set. Suppose a training triple in the training set is (A, r, B), and all entities in the training set are A, B, C, and D. Using the first method, the perturbation triple constructed for the training triple (A, r, B) is: (A, r, B), (B, r, B), (C, r, B), (D, r, B). Using the second method, the perturbation triple constructed for the training triple (A, r, B) is: (A, r, A), (A, r, B), (A, r, C), (A, r, D).
[0099] In some embodiments, the training triples and each perturbation candidate triple in the set of perturbation candidate triples are respectively input into the pre-training model, and the training relationship scores and perturbation relationship scores corresponding to the training triples and the perturbation candidate triples are respectively output through the pre-training model, including:
[0100] According to the training entity pairs in the training triples and the perturbation entity pairs of each perturbation candidate triple in the perturbation candidate triple set, a training path set and a perturbation path set corresponding to the training entity pairs and the perturbation entity pairs are determined respectively.
[0101] Based on the perturbation entity pair and the perturbation path set, a perturbation head entity vector, a perturbation tail entity vector, a perturbation relationship vector of the perturbation entity pair and a perturbation path vector corresponding to each perturbation path in the perturbation path set are obtained through a convolutional neural network.
[0102] Based on the training entity pair and the training path set, a training head entity vector, a training tail entity vector, a training relationship vector of the training entity pair and a training path vector corresponding to each training path in the training path set are obtained through a convolutional neural network.
[0103] The local importance of each perturbation path in the perturbation path set is calculated through the attention mechanism to obtain the perturbation local weight of each perturbation path.
[0104] The local importance of each training path in the training path set is calculated through the attention mechanism to obtain the training local weight of each training path.
[0105] The global importance of each disturbance path in the disturbance path set is calculated by using the degree-guided inverse path frequency (DIPF) to obtain the disturbance global weight of each disturbance path.
[0106] The degree-guided inverse path frequency (DIPF) is used to calculate the global importance of each training path in the training path set, so as to obtain the training global weight of each training path.
[0107] A disturbance feature relationship vector is obtained by calculation based on the disturbance path vector, the disturbance relationship vector, the disturbance local weight and the disturbance global weight.
[0108] A training feature relationship vector is obtained by calculation based on the training path vector, the training relationship vector, the training local weight and the training global weight.
[0109] A disturbance score function is determined based on the disturbance head entity vector, the disturbance tail entity vector and the disturbance feature relationship vector.
[0110] A training score function is determined based on the training head entity vector, the training tail entity vector and the training feature relationship vector.
[0111] A perturbation relationship score of each of the perturbation candidate triples in the set of perturbation candidate triples is determined based on the perturbation score function.
[0112] A training relation score for each of the training candidate triples in the set of training candidate triples is determined based on the training score function.
[0113] In some embodiments, the pre-training of the ranking model further includes:
[0114] Construct a validation set;
[0115] Performing entity extraction on the verification set to obtain a verification set entity set;
[0116] Based on the verification set and the verification set entity set, respectively construct a verification perturbation triplet set corresponding to each verification triplet in the verification set;
[0117] Eliminating the triplets included in the verification set from the verification perturbation triple set to obtain a verification perturbation candidate triple set;
[0118] The verification triplet and each verification perturbation candidate triple in the verification perturbation candidate triplet set are respectively input into the pre-trained model, and the verification relationship score and the verification perturbation relationship score corresponding to the verification triplet and the verification perturbation candidate triplet are respectively output through the pre-trained model.
[0119] The preset threshold is determined based on maximizing the classification accuracy of the verification set, specifically: assuming that there are n verification triples in the verification set, each verification triplet constructs m verification perturbation candidate triples (in fact, for each verification triplet, since the number of triplets included in the verification set that are eliminated from the verification perturbation triple set is different, the number of verification perturbation candidate triples in the verification perturbation candidate triple set corresponding to each verification triplet may be different. Here, just for the sake of ease of explanation, it is assumed that each verification triplet constructs m verification perturbation candidate triples).
[0120] A verification triple and its corresponding m verification perturbation candidate triples are respectively input into the pre-trained model, and a verification relationship score and m verification perturbation relationship scores are obtained accordingly. The obtained verification relationship score and the m verification perturbation relationship scores are arranged in ascending order. If the verification relationship score is ranked first (i.e., the verification relationship score is the lowest), it means that the classification of the verification triple corresponding to the verification relationship score is correct, otherwise it is wrong.
[0121] Similarly, the same operation is performed on the remaining n-1 verification triples to obtain the classification correctness results of the n-1 verification triples.
[0122] The proportion of correctly classified verification triplets to n verification triplets is the classification accuracy of the verification set.
[0123] When the classification accuracy of the verification set is maximized, the preset threshold is equal to the smallest verification perturbation relationship score among the verification perturbation candidate triples corresponding to the correctly classified verification triples.
[0124] The performance test of the path-aware knowledge graph completion method based on convolutional networks disclosed in this disclosure is as follows:
[0125] By comparing with seven existing methods that have achieved advanced results, namely, TransE method, TransH method, TransD method, HolE method, ConvE method, ConvKB method, and CapsE method, we can determine the advantages of our invented path-aware knowledge graph completion method based on convolutional neural networks in link prediction and triple classification.
[0126] We use four public datasets, WN18, FB15k, WN18RR, and FB15k-237, to verify the effectiveness of the proposed model. WN18 is derived from WordNet and contains word concepts and the lexical relations between these concepts. FB15k is a subset of Freebase. WN18RR and FB15k-237 are revised versions of WN18 and FB15k, which are widely used in recent knowledge graph completion methods. Table 1 lists the statistical information of the datasets.
[0127] Table 1 Dataset statistics
[0128]
[0129] Similar to existing knowledge graph completion research, we evaluate the proposed method on link prediction and triple classification tasks. These two tasks reflect the accuracy of model prediction and reasoning triples from different perspectives. Link prediction aims to complete a binary that is missing a head entity or tail entity, that is, given a binary (r, t), predict the head entity h, or given a binary (h, r), predict the tail entity t; triple classification aims to determine whether a given triple (h, r, t) is correct, that is, the binary classification problem of triples.
[0130] For the link prediction task, the standard protocol used in existing work is followed. For each triple (h, r, t) in the test set, first replace the head entity h or the tail entity t with each entity in the entity set (except the head entity and the tail entity itself) to construct a set of perturbed triples. Secondly, the unexplainable score (i.e., the relationship score) of the perturbed triples is calculated. Finally, the scores are sorted in ascending order to obtain the ranking of the original triples (h, r, t). Please note that the perturbed triples may exist in the training set, validation set, or test set of the dataset, that is, the triples of the replaced head entity or tail entity are the same as a triple in the dataset. In order to avoid the influence of this situation, a filtering protocol is adopted to remove the perturbed triples that are the same as the triples in the dataset.
[0131] The evaluation indicators of link prediction are: Mean Rank (MR), Mean Reciprocal Rank (MRR) and Hits@N. Among them, MR refers to the average of the test triples ranking, MRR refers to the average of the reciprocal ranking of the test triples, and Hits@N (N = 1, 3, 10) refers to the proportion of the top N test triples to all test triples. The calculation methods are:
[0132]
[0133]
[0134]
[0135] Among them, Num test Indicates the number of triplets in the test set, rank i Indicates the rank of the i-th triple, |rank i ≥N| indicates the number of triples whose ranking is greater than or equal to N. indicates the number of triples whose ranking is greater than or equal to N.
[0136] In the triple classification task, for each triple in the test set and validation set, a negative sample triple is constructed by exchanging the head and tail entities. The decision rule for classification is: for a triple (h, r, t), if the unexplainable score is lower than the preset threshold, the prediction is positive, otherwise it is negative. The preset threshold is determined by maximizing the classification accuracy of the validation set.
[0137] The evaluation index of triple classification is: Accuracy, that is, the proportion of correctly classified triplets to test triplets.
[0138] In terms of parameter setting for link prediction, the widely used Bernoulli technique is used to generate the head entity or tail entity of the perturbed triple, and TransE is used to initialize the entity and relationship representation. TransE uses pre-trained 100-dimensional word vectors for model training. The learning rate selection range of the model PConvKB is: {5e -6 , 1e -5 , 5e -5 , 1e -4}, the number of convolution kernels is selected in the range of: {50, 100, 200, 400}. The batch size is fixed to 128, and the L2 regularization parameter in the objective function is set to 0.001. The parameter selection strategy uses the Adam function to iterate the model 150 times and monitor Hits@10 after every 10 iterations to select the best parameter value. When Hits@10 reaches the maximum value on the validation set, the learning rate corresponding to WN18 is 5e -5 , the number of convolution kernels is 400; the learning rate corresponding to FB15k is le -5 , the number of convolution kernels is 50; the learning rate corresponding to WN18RR is 5e -6 , the number of convolution kernels is 400; the learning rate corresponding to FB15k-237 is 1e -5 , the number of convolution kernels is 200.
[0139] In terms of parameter setting for triple classification, TransE is used to initialize entity and relation representations. The hyperparameter selection range is the same as that for link prediction, that is, the learning rate selection range is: {5e -6 , 1e -5 , 5e -5 , 1e -4}, the number of convolution kernels is selected in the range of: {50, 100, 200, 400}. The batch size is fixed to 128, and the L2 regularization parameter in the objective function is set to 0.001. The parameter selection strategy uses the Adam function to iterate the model 150 times, and monitors the classification accuracy after every 10 iterations to select the best parameter value. When the accuracy is maximized on the validation set, the learning rate corresponding to WN18 is 5e -5 , the number of convolution kernels is 400; the learning rate corresponding to FB15k is 1e -5 , the number of convolution kernels is 50; the learning rate corresponding to WN18RR is 5e -6 , the number of convolution kernels is 400; the learning rate corresponding to FB15k-237 is 1e -5 , the number of convolution kernels is 200.
[0140] The experimental results of link prediction of the invented method PConvKB and the comparative methods are shown in Tables 2 to 5, and the bold values are the best results.
[0141] Table 2 Link prediction MR experimental results
[0142] method WN18 FB15k WN18RR FB15k-237 TransE 733 168 5766 349 TransH 602 137 7019 358 TransD 617 151 7050 418 HolE 589 76 5992 369 ConvE 549 70 5385 286 CapsE 244 72 711 301 ConvKB 204 66 759 275 PConvKB 196 54 691 245
[0143] Table 3 Link prediction MRR experimental results
[0144] method WN18 FB15k WN18RR FB15k-237 TransE 0.368 0.382 0.127 0.265 TransH 0.386 0.381 0.152 0.237 TransD 0.394 0.355 0.148 0.240 HolE 0.704 0.471 0.325 0.266 ConvE 0.891 0.685 0.427 0.295 CapsE 0.910 0.671 0.415 0.526 ConvKB 0.922 0.726 0.338 0.475 PConvKB 0.947 0.762 0.437 0.535
[0145] Table 4 Hits@N results of PConvKB and comparison methods on WN18 and FB15k (%)
[0146]
[0147] Table 5 Hits@N results of PConvKB and comparison methods on WN18RR and FB15k-237 (%)
[0148]
[0149] Through the above link prediction experimental results, we can draw the following conclusions: First, PConvKB achieved the best MR and Hits@N values on four public datasets (in terms of MRR value, PConvKB achieved the best MRR value on the other three datasets except for the second best MRR value on the dataset WN18RR), which verifies the effectiveness of introducing relational paths in the knowledge reasoning process. Second, PConvKB performs better than ConvKB on all four datasets. In particular, in terms of MR value, the average ranking of PConvKB on the dataset FB15k increased by 275-245=30 places, with a relative improvement rate of about 30 / 275=10.9%; in terms of MRR value, PConvKB increased by 0.437-0.338=0.099 points on WN18RR, with a relative improvement rate of about 0.099 / 0.338=29.2%; in terms of Hits@N, PConvKB increased by 49.7%-42.3%=7.4% (Hits@1) on the dataset FB15k-237. This proves again that the introduction of path information helps to improve the accuracy of knowledge reasoning. In addition, it should be noted that the optimization algorithm used in the original text of the translation-based comparison methods TransE, TransH, TransD and HolE is the MBGD algorithm. In order to compare the model structure more fairly, the optimization algorithms of the comparison methods are replaced with the Adam algorithm.
[0150] The triple classification experimental results of the invented method PConvKB and the comparison method are shown in Figures 3 to 6 shown.
[0151] Through the experimental results of triple classification, we can draw the following conclusions: The experimental results of triple classification are basically consistent with the experimental results of link prediction. The classification accuracy of PConvKB on four public datasets is better than that of all the comparison methods. This shows that introducing path information and considering its local importance and global importance is conducive to improving the accuracy of reasoning. It is proved again that comprehensive consideration of the local importance and global importance of the path can greatly improve the accuracy of knowledge graph completion.
[0152] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present disclosure also provides a path-aware knowledge graph completion device based on convolutional neural networks.
[0153] refer to Figure 7 , the path-aware knowledge graph completion device based on convolutional neural network includes:
[0154] The acquisition set module 21 is configured to acquire an initial triple set from the knowledge graph.
[0155] The set determination module 22 is configured to determine a candidate triple set based on the initial triple set.
[0156] The determination and supplementation module 23 is configured to input the candidate triple set into a pre-built sorting model, output the relationship score of each candidate triple in the candidate triple set through the sorting model, determine at least one candidate triple from the candidate triple set based on the relationship score, and supplement it into the knowledge graph; wherein the sorting model is pre-trained
[0157] For the convenience of description, the above device is described by dividing it into various modules according to its functions. Of course, when implementing the present disclosure, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0158] The device of the above embodiment is used to implement the corresponding pointer meter reading recognition method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0159] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present disclosure also provides an electronic device, including 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 pointer meter reading recognition method of any of the above embodiments is implemented.
[0160] Figure 8 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.
[0161] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0162] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0163] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0164] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0165] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0166] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0167] The electronic device of the above embodiment is used to implement the corresponding pointer meter reading recognition method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0168] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present disclosure also provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute the pointer meter reading recognition method of any of the above embodiments.
[0169] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0170] The computer instructions stored in the storage medium of the above embodiments are used to enable a computer to execute the pointer meter reading recognition method of any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
Claims
1. A path-aware knowledge graph completion method based on convolutional networks, characterized in that: include: Acquire an initial triple set from the knowledge graph by template extraction or model extraction; Determine a candidate triple set based on the initial triple set; Inputting the candidate triple set into a pre-built sorting model, outputting a relationship score of each candidate triple in the candidate triple set through the sorting model, determining at least one candidate triple from the candidate triple set based on the relationship score, and adding it to the knowledge graph; Wherein, the sorting model is pre-trained; The pre-training of the sorting model includes: constructing a pre-training model and a training set; performing entity extraction on the training set to obtain a training set entity set; and constructing a perturbation triple set corresponding to each training triple in the training set based on the training set and the training set entity set, wherein the perturbation triple set includes a plurality of perturbation triples, and the perturbation triples are constructed in the following manner: replacing the head entity in the training triple with each entity in the training set entity set, or replacing the tail entity in the training triple with each entity in the training set entity set. each entity in the set; eliminating the triples contained in the training set from the perturbation triple set to obtain a perturbation candidate triple set; inputting the training triples and each perturbation candidate triple in the perturbation candidate triple set into the pre-training model respectively, and outputting the training relationship score and the perturbation relationship score corresponding to the training triples and the perturbation candidate triples respectively through the pre-training model; determining a loss function based on the training relationship score and the perturbation relationship score, and minimizing the loss function to obtain the sorting model.
2. The method according to claim 1, characterized in that The determining of a candidate triple set based on the initial triple set includes: Extracting entities and relationships from the initial triple set respectively to obtain an entity set and a relationship set; Arrange and combine all entities in the entity set and all relations in the relation set to obtain a first triple set; The candidate triple set is obtained by removing the triples included in the initial triple set from the first triple set.
3. The method according to claim 1, characterized in that Outputting the relationship score of each candidate triple in the candidate triple set by the ranking model includes: According to each entity pair in the candidate triple, determining a path set corresponding to the entity pair; Based on the entity pair and the path set, a convolutional neural network is used to obtain a head entity vector, a tail entity vector, a relationship vector of the entity pair, and a path vector corresponding to each path in the path set; Calculating the local importance of each path in the path set through an attention mechanism to obtain a local weight of each path; Calculating the global importance of each path in the path set by using the degree-guided inverse path frequency (DIPF) to obtain a global weight of each path; Obtaining a feature relationship vector by calculation based on the path vector, the relationship vector, the local weight and the global weight; Determine a score function based on the head entity vector, the tail entity vector and the feature relationship vector; The relationship score of each of the candidate triples in the set of candidate triples is determined based on the scoring function.
4. The method according to claim 1, characterized in that The determining at least one candidate triple from the candidate triple set based on the relationship score and adding it to the knowledge graph includes: Grouping candidate triples having the same entity pairs in the candidate triple set to obtain a plurality of grouped candidate triple sets; Respectively removing the candidate triples whose relationship scores are greater than a preset threshold from the plurality of grouped candidate triple sets to obtain a plurality of remaining candidate triple sets; The candidate triplet with the smallest relationship score is selected from each of the remaining candidate triplet sets and added to the knowledge graph.
5. The method according to claim 1, characterized in that The step of respectively constructing a set of perturbation triples corresponding to each training triple in the training set based on the training set and the training set entity set includes: For each triple in the training set, the head entity or the tail entity in the triple is replaced by each entity in the training set entity set to construct multiple perturbation triples, and the multiple perturbation triples are combined into a perturbation triple set.
6. The method according to claim 1, characterized in that Inputting the training triples and each perturbation candidate triple in the set of perturbation candidate triples into the pre-training model respectively, and outputting the training relationship scores and perturbation relationship scores corresponding to the training triples and the perturbation candidate triples respectively through the pre-training model, including: Determine, according to the training entity pairs in the training triples and the perturbation entity pairs of each perturbation candidate triple in the perturbation candidate triple set, the training path set and the perturbation path set corresponding to the training entity pairs and the perturbation entity pairs; Based on the perturbation entity pair and the perturbation path set, a perturbation head entity vector, a perturbation tail entity vector, a perturbation relationship vector of the perturbation entity pair and a perturbation path vector corresponding to each perturbation path in the perturbation path set are obtained through a convolutional neural network. Based on the training entity pair and the training path set, a training head entity vector, a training tail entity vector, a training relationship vector of the training entity pair and a training path vector corresponding to each training path in the training path set are obtained through a convolutional neural network; The local importance of each perturbation path in the perturbation path set is calculated through the attention mechanism to obtain the perturbation local weight of each perturbation path. Calculating the local importance of each training path in the training path set through an attention mechanism to obtain a training local weight of each training path; The global importance of each disturbance path in the disturbance path set is calculated by the degree-guided inverse path frequency DIPF to obtain the disturbance global weight of each disturbance path. Performing global importance calculation on each training path in the training path set by using degree-guided inverse path frequency (DIPF) to obtain a training global weight of each training path; A disturbance characteristic relationship vector is obtained by calculation based on the disturbance path vector, the disturbance relationship vector, the disturbance local weight and the disturbance global weight, Obtaining a training feature relationship vector by calculation based on the training path vector, the training relationship vector, the training local weight and the training global weight; determining a disturbance score function based on the disturbance head entity vector, the disturbance tail entity vector and the disturbance feature relationship vector, Determine a training score function based on the training head entity vector, the training tail entity vector and the training feature relationship vector; Determining a perturbation relationship score of each of the perturbation candidate triples in the set of perturbation candidate triples based on the perturbation score function; A training relation score for each of the training candidate triples in the set of training candidate triples is determined based on the training score function.
7. A path-aware knowledge graph completion device based on convolutional neural network, characterized in that: include: An acquisition set module is configured to acquire an initial triple set from the knowledge graph by template extraction or model extraction; A determination set module, configured to determine a candidate triple set based on the initial triple set; A determination and supplementation module is configured to input the candidate triple set into a pre-built sorting model, output a relationship score of each candidate triple in the candidate triple set through the sorting model, determine at least one candidate triple from the candidate triple set based on the relationship score, and supplement it into the knowledge graph; Wherein, the sorting model is pre-trained; The determination and supplementation module is further configured to construct a pre-training model and a training set; perform entity extraction on the training set to obtain a training set entity set; and construct a perturbation triple set corresponding to each training triple in the training set based on the training set and the training set entity set, wherein the perturbation triple set includes a plurality of perturbation triples, and the perturbation triples are constructed in the following manner: the head entity in the training triple is replaced by each entity in the training set entity set, or the tail entity in the training triple is replaced by each entity in the training set entity set. each entity in the set; eliminating the triples contained in the training set from the perturbation triple set to obtain a perturbation candidate triple set; inputting the training triples and each perturbation candidate triple in the perturbation candidate triple set into the pre-training model respectively, and outputting the training relationship score and the perturbation relationship score corresponding to the training triples and the perturbation candidate triples respectively through the pre-training model; determining a loss function based on the training relationship score and the perturbation relationship score, and minimizing the loss function to obtain the sorting model.
8. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the computer program.
9. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to execute the method according to any one of claims 1 to 6.