Multi-language knowledge graph completion method for non-aligned entity scene
By constructing a graph neural network with an alignment entity acquisition module and a multi-graph attention mechanism, the problem of aligning entities in multilingual knowledge graph completion is solved, achieving high-quality alignment and completion under no-alignment conditions, and improving the completeness and accuracy of the knowledge graph.
Patent Information
- Application Number
- CN202411357451.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-01-10
AI Technical Summary
Existing multilingual knowledge graph completion methods require pre-aligned entities, making them difficult to apply effectively in real-world scenarios.
We design a multilingual knowledge graph completion method for unaligned entity scenarios. This method involves constructing an aligned entity acquisition module and a graph neural network based on a multi-graph attention mechanism. By combining alignment loss function and completion loss function, we can perform joint training and iterative generation to produce high-quality aligned entities.
Obtaining high-quality aligned entities under the condition of no aligned entities improves the performance of multilingual knowledge graph completion and meets the needs of practical application scenarios.
Smart Images

Figure CN119294490A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a knowledge graph completion method, and in particular to a multilingual knowledge graph completion method for unaligned entity scenarios. Background Art
[0002] This section merely provides background information related to the present disclosure and is not necessarily prior art.
[0003] Knowledge graph completion is a very important task in the knowledge graph construction process. Its goal is to fill the gaps in the knowledge graph, correct errors, and expand the content of the knowledge graph through automated methods, combining the existing knowledge graph and external information to make it more complete and accurate.
[0004] With the development of globalization and informatization, knowledge sharing and transfer between knowledge graphs in different languages have become increasingly important. In order to utilize the knowledge graph information in different languages to enhance the completion performance of the target knowledge graph, multilingual knowledge graph completion technology has gradually developed in recent years. At present, the main methods include integration methods, methods of joint training with entity alignment, and graph neural network modeling. However, all existing methods require the use of pre-aligned entity pairs between different knowledge graphs as a medium for knowledge transfer, which is usually difficult to obtain in actual scenarios, making these methods limited in practical applications.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] Purpose of the invention: The technical problem to be solved by the present invention is to provide a multilingual knowledge graph completion method for non-aligned entity scenarios in view of the shortcomings of the prior art.
[0007] In order to solve the above technical problems, the present invention discloses a multilingual knowledge graph completion method for unaligned entity scenarios, comprising the following steps:
[0008] Step 1: Build an alignment entity acquisition module to find the alignment entities between knowledge graphs in different languages;
[0009] Step 2: Design a graph neural network based on multi-graph attention mechanism;
[0010] Step 3: construct an entity alignment model and a multilingual knowledge graph completion model based on the graph neural network described in step 2, and jointly train the entity alignment model and the multilingual knowledge graph completion model based on the alignment loss function and the completion loss function;
[0011] Step 4, using the entity alignment model initialized by joint training in step 3, regenerating aligned entities between knowledge graphs of different languages;
[0012] Step 5, adjusting the filter parameters according to the number of iterations, and using the filter to filter the aligned entities generated in step 4;
[0013] Step 6, adding the aligned entities filtered in step 5 to the training samples, and using the method described in step 3 to train the entity alignment model and the multilingual knowledge graph completion model to obtain a new entity alignment model and a multilingual knowledge graph completion model;
[0014] Step 7, repeat steps 4 to 6 until the number of iterations meets the preset requirements and the training is completed;
[0015] Step 8: Use the trained entity alignment model and multilingual knowledge graph completion model to perform entity alignment on knowledge graphs in multiple different languages, and use the alignment results to complete the knowledge graphs.
[0016] Furthermore, the construction of the alignment entity acquisition module described in step 1 specifically includes the following steps:
[0017] Step 1-1, for a given knowledge graph in multiple different languages, obtain the text name and text description of each entity therein;
[0018] Step 1-2, converting the text name and text description into text in the same language using a multilingual translator;
[0019] Step 1-3, encoding the text in the same language through the pre-trained language model mBERT to obtain the text features of the entity;
[0020] Step 1-4, create an empty set of aligned entity pairs;
[0021] Steps 1-5, for any two entities s in the knowledge graph i and j , calculate the CSLS distance between them, if the two entities are nearest neighbors in terms of CSLS distance, then take the two entities as an aligned entity pair and add them to the aligned entity pair set;
[0022] The CSLS distance is calculated by:
[0023]
[0024] Among them, CSLS (s i ,e j ) represents any two entities e in the knowledge graph iand entity e j The CSLS distance, and Entity e i and entity e j The corresponding text description feature, r j (s i ) represents entity e i The average distance to the nearest neighbor entity in its knowledge graph; N(e i ) is to use the entity e in vector space i The text feature vector With entity e i The text feature vectors of all entities in the knowledge graph are used to calculate the distance, and a set of K nearest neighbor entities is selected, where K is N(s i ) is set as a hyperparameter.
[0025] Furthermore, the design of the graph neural network based on the multi-graph attention mechanism described in step 2 specifically includes:
[0026] Step 2-1: Treat the given N knowledge graphs as N independent graphs and build a unified graph G;
[0027] Step 2-2: Use a multi-layer graph neural network to encode the entity vectors and entity relationship vectors in the graph G.
[0028] Furthermore, the joint mapping described in step 2-1, i.e., using the alignment entities obtained in step 1 to connect the N independent graphs into a unified graph, specifically includes:
[0029] Step 2-1-1, construct a relationship set;
[0030] Step 2-1-2, adding an alignment relationship, that is, the alignment entity pair (e i ,e j ), converted to a triple (e i ,Alignment relationship,e j ), and add the above triples to the relationship set;
[0031] Step 2-1-3, connect all knowledge graphs through the relationship set to obtain a unified graph G;
[0032] Step 2-1-4: Based on graph G, randomly initialize all entities and relationships in the knowledge graph in the same vector space to obtain the initial entity vector representation h 0 And the relationship vector represents r.
[0033] Furthermore, the multi-layer graph neural network described in step 2-2 is used to encode the entity vectors and entity relationship vectors in the graph G, specifically including:
[0034] Step 2-2-1, construct a multi-layer graph neural network, the network structure is as follows:
[0035] The transmission process from the lth layer network to the l+1th layer network is defined as follows:
[0036]
[0037] in, and They are the central entities e i The hidden layer representation of the lth layer and the l+1th layer of the network; σ(·) is a nonlinear activation function implemented using the GELU function; N(e i ) is entity e i The neighborhood entity set of j For entity e i The neighbor entity of i and e j The relationship between , that is, the relationship between triples in the knowledge graph; For entity e j The hidden layer representation after being associated with the relation r; is the attention function, which is used to calculate the attention weight of the central entity to the neighboring entity;
[0038] Step 2-2-2: For each knowledge graph, maintain different query transformation matrices, key transformation matrices, and value transformation matrices W. q , W k and W v , the specific calculation method of the attention weight of the knowledge graph is as follows:
[0039]
[0040] Among them, W qi , W kj and W vj Entity e i The query transformation matrix and entity e corresponding to the knowledge graph j The key transformation matrix and value transformation matrix corresponding to the knowledge graph; d is the dimension of the hidden layer representation; β r is a learnable relation variable corresponding to relation r, used to measure the weight of relation r; λ is used to weigh the reliability of the pseudo-aligned entity obtained by the above method. When relation r is an aligned relation, Otherwise it is 1; [·] is the vector concatenation function.
[0041] Furthermore, the construction of the entity alignment model and the multilingual knowledge graph completion model described in step 3 specifically includes:
[0042] Step 3-1: Build an entity alignment model, as follows:
[0043] Select two entities e from the graph G described in step 2-1-3 that belong to two knowledge graphs i and e j , the structural features generated after processing by the graph neural network generated in step 2-2 and Calculate the Euclidean distance between the two features. If the Euclidean distance is lower than a threshold, the two entities are determined to be aligned entities.
[0044] Step 3-2, build a multilingual knowledge graph completion model, that is, for two known elements in a triple in the same knowledge graph, calculate the third element, as follows:
[0045] Step 3-2-1: Given the head entity and relationship, find the best matching tail entity in all entity sets in the knowledge graph. The method is as follows:
[0046] Using graph neural network to calculate the head entity structure features h s The structural characteristics of the relationship s , then the predicted tail entity structure features are:
[0047]
[0048] Calculate the structural features e of each entity in all entity sets in the same knowledge graph i s , i=0,1,2..and i≠h, select the entity e with the smallest Euclidean distance t , and the Euclidean distance between the structural features of the entity and the predicted tail entity is less than the threshold, then the tail entity is selected as entity e t , otherwise there is no tail entity that meets the conditions;
[0049] Step 3-2-2: Given the head entity and the tail entity, find the best matching relationship in all relationship sets in the knowledge graph. The method is as follows:
[0050] Using graph neural network to calculate the head entity structure features h s Structural features of the tail entity t s , then the predicted relationship structure characteristics are:
[0051]
[0052] Calculate the structural feature r of each relation in all relation sets in the same knowledge graph i s , i=0,1,2.., select the relationship r with the smallest Euclidean distance s , and the Euclidean distance between the structural features of the relationship and the predicted relationship If the value is less than the threshold, the corresponding relationship between the head entity and the tail entity is selected as relationship r, otherwise there is no relationship that meets the condition;
[0053] Step 3-2-3, given the relationship and tail entity, find the best matching head entity in all entity sets in the knowledge graph;
[0054] Using graph neural network to calculate tail entity structure features e t s The structural characteristics of the relationship s , then the predicted head entity structure features are:
[0055]
[0056] Calculate the structural features e of each entity in all entity sets in the same knowledge graph i s , i=0,1,2..and i≠t, select the entity e with the smallest Euclidean distance h , and the Euclidean distance between the structural features of the entity and the predicted tail entity is less than the threshold, then the head entity is selected as entity e h , otherwise there is no qualifying header entity.
[0057] Furthermore, the alignment loss function and completion loss function described in step 3 specifically include:
[0058] The alignment loss function Used to shorten the distance between aligned entities, as follows:
[0059]
[0060] Among them, P ij For any two knowledge graphs G i and G j The set of aligned entity pairs between γ A is the interval hyperparameter of the contrastive loss;
[0061] The completion loss function Used to predict missing entities in triples, including:
[0062]
[0063] φ(h,r,t)=-‖eh s +r s -e t s ‖2
[0064] Among them, γ K is the interval hyperparameter of the completion loss, is any triple in the training dataset, including the head entity e h , tail entity e t and the relationship r, e h s 、e t s and r s The initial vectors of the three respectively represent the structural features after being encoded by the multi-layer graph neural network.
[0065] Furthermore, the joint training described in step 3 specifically includes:
[0066] Based on the alignment loss function and completion loss function, the entity alignment model and the multilingual knowledge graph completion model are jointly trained. The total loss function for:
[0067]
[0068] That is, the sum of the alignment losses of all aligned entity pairs between N knowledge graphs plus the sum of the completion losses of all triples in the N knowledge graphs.
[0069] Furthermore, the regeneration of the aligned entities between the knowledge graphs of different languages described in step 4 specifically includes:
[0070] Step 4-1, entity e i and e j After the entity alignment model is used, the corresponding structural feature representation is obtained after encoding, which is recorded as and
[0071] Step 4-2, calculate the CSLS distance between all entities in the knowledge graphs of different languages, as follows:
[0072]
[0073] in, Representing entity e i The structural characteristics of Representing entity e i Text features of
[0074] In step 4-3, if the two entities are each other's nearest neighbors in terms of CSLS distance, the two entities are added to the set of aligned entity pairs.
[0075] Further, the filtering described in step 5 specifically includes:
[0076] Step 5-1, construct the filter and calculate the filter parameter θ as follows:
[0077] θ=min(θ0+δ×s,θ max )
[0078] Among them, θ0 is the initial value of the filter, θ max is the maximum value of the filter, δ is the value by which the filter threshold increases in each iteration, and s is the number of iterations, starting from 0;
[0079] Step 5-2, calculate the CSLS distance of the aligned entity pairs in the aligned entity set generated in step 4, retain the entity pairs whose CSLS distance is less than the filter parameter θ, and constitute the aligned entity pairs Pair of the sth iteration s .
[0080] Beneficial effects:
[0081] 1. The present invention proposes a multilingual knowledge graph completion method for scenarios without aligned entities. It can obtain high-quality aligned entities by combining a translation module, a pre-trained language model and an entity filtering algorithm without the need for pre-aligned entities, which is more in line with actual application scenarios.
[0082] 2. The present invention designs a graph neural network based on multi-graph attention, and uses it to construct an alignment model and a knowledge model respectively. The graph neural network based on multi-graph attention can combine the representation of the alignment model and the pre-trained language model to iteratively generate new alignment entities. The multi-graph attention mechanism can also aggregate information from knowledge graphs from different sources into the target knowledge graph in a specific way, improving the performance of multilingual knowledge graph completion. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and the above and / or other advantages of the present invention will become more clear.
[0084] Figure 1 It is a schematic diagram of the overall framework of the present invention. DETAILED DESCRIPTION
[0085] The design idea of the present invention is as follows: in the scenario without aligned entities, the semantic information of the pre-trained language model and the structural information encoded by the graph neural network are integrated to generate pseudo-aligned entities and filter out high-quality aligned entities. On this basis, knowledge transfer between multiple knowledge graphs is completed, thereby improving the performance of multilingual knowledge graph completion.
[0086] In order to improve the accuracy of multilingual knowledge graph completion in scenarios without aligned entities, the present invention provides a method for multilingual knowledge graph completion in scenarios without aligned entities. In this method, first, an aligned entity acquisition module combining a translation module and a pre-trained language model is designed, which can obtain high-quality aligned entities in the initial stage. Secondly, a graph neural network based on multi-graph attention is designed, and an alignment model and a knowledge model are constructed respectively. The graph neural network based on multi-graph attention can combine the representations of the alignment model and the pre-trained language model to iteratively generate new aligned entities. Use the knowledge model to aggregate the information of knowledge graphs from different sources onto the target knowledge graph, thereby improving the performance of multilingual knowledge graph completion. The overall model structure diagram of the present invention is shown in the attached figure. Figure 1 shown.
[0087] The multilingual knowledge graph completion method for a scenario without aligned entities of the present invention is mainly implemented by the following steps: Step 1: Construct an aligned entity acquisition module, the goal of which is to find aligned entities between different knowledge graphs.
[0088] At the initial stage of the task, there are no pre-given aligned entities. However, for the given knowledge graphs in multiple different languages, the text name and text description of each entity are easy to obtain. The text description of each entity is converted into an English text description through a multilingual translator, and then encoded through the pre-trained language model mBERT, which can capture the rich semantic information in the entity text, and then obtain the text features of the entity. Then, for any two entities e in the knowledge graph, i and e j , calculate the CSLS distance (Cross-domain Similarity Local Scaling) between them. If the two entities are nearest neighbors in terms of CSLS distance, the two entities are added to the set of aligned entity pairs.
[0089] The CSLS distance specifically includes:
[0090]
[0091] Where: and Entity e i and e jThe corresponding text description is the feature representation after being encoded by the mBERT model; N j (e i ) is entity e i The set of neighbor entities in the jth knowledge graph; K is N j (e i )
[0092] Step 2: Design a graph neural network based on multi-graph attention mechanism:
[0093] The given N knowledge graphs are constructed as independent and disconnected graphs to form a unified graph; a multi-layer graph neural network is used to encode the entity vectors and entity relationship vectors in the constructed graph G.
[0094] Because the given N knowledge graphs are independent and disconnected, it is impossible to directly use the graph neural network for effective information dissemination. The N independent graphs can be connected into a unified graph using the alignment entities initially obtained in step 1. Specifically, an alignment relationship is added to the relationship set, and the alignment entity pair (e i ,e j ) is converted to a triple (e i ,align,e j ), all knowledge graphs are connected by adding these triples to obtain the large graph G. Based on this unified large graph, all entities and relationships in the knowledge graph are randomly initialized in the same vector space with a feature dimension of d to obtain the initial entity vector representation h 0 And the relationship vector represents r.
[0095] After building the graph G and initializing the entity relationship vector, a multi-layer graph neural network is used to encode the entities and relationships. The transfer process from the lth layer network to the l+1th layer network is as follows:
[0096]
[0097] Where: and They are the central entities e i The hidden layer representation of the lth layer and the l+1th network; σ(·) is the nonlinear activation function implemented by GELU (GELU, Gaussian Error Linear Unit, reference Hendrycks D, Gimpel K.Gaussian error linear units (gelus) [J]. arXiv preprintarXiv: 1606.08415, 2016.); N(e i ) is entity e iThe neighborhood entity set of j For entity e i The neighbor entity of i and e j the relationship between; For entity e j The hidden layer representation after being associated with the relation r; is the attention function, which is used to calculate the attention weight of the central entity to the neighboring entities.
[0098] For each knowledge graph, a different query-key-value transformation matrix W is maintained. q , W k , W v , and then the attention weight is calculated as follows:
[0099]
[0100] Where: W qi , W kj , W vj Entity e i The query transformation matrix corresponding to the knowledge graph, entity e j The key transformation matrix and value transformation matrix corresponding to the knowledge graph; d is the dimension of the hidden layer representation; β r is a learnable relation variable corresponding to relation r, used to measure the weight of relation r; λ is used to weigh the reliability of the pseudo-aligned entity obtained by the above method. When relation r is an aligned relation, Otherwise, 1. The text features encoded by the mBERT model for entity text description, The entity vector represents h 0 The features are encoded using a multi-layer graph neural network; finally, [·] is the vector concatenation function.
[0101] Step 3: Build a model for entity alignment and a model for multilingual knowledge graph completion based on graph neural network. Based on the alignment loss function and the completion loss function, initialize the joint training of the alignment model and the knowledge model:
[0102] The construction of the entity alignment model and the multilingual knowledge graph completion model described in step 3 specifically includes:
[0103] Step 3-1: Build an entity alignment model, as follows:
[0104] Select two entities e from the graph G described in step 2-1-3 that belong to two knowledge graphs i and e j , the structural features generated after processing by the graph neural network generated in step 2-2 and Calculate the Euclidean distance between the two features. If the Euclidean distance is lower than a threshold, the two entities are determined to be aligned entities.
[0105] Step 3-2, build a multilingual knowledge graph completion model, that is, for two known elements in a triple in the same knowledge graph, calculate the third element, as follows:
[0106] Step 3-2-1: Given the head entity and relationship, find the best matching tail entity in all entity sets in the knowledge graph. The method is as follows:
[0107] Using graph neural network to calculate the head entity structure features h s The structural characteristics of the relationship s , then the predicted tail entity structure features are:
[0108]
[0109] Calculate the structural features e of each entity in all entity sets in the same knowledge graph i s , i=0,1,2..and i≠h, select the entity e with the smallest Euclidean distance t , and the Euclidean distance between the structural features of the entity and the predicted tail entity is less than the threshold, then the tail entity is selected as entity e t , otherwise there is no tail entity that meets the conditions;
[0110] Step 3-2-2: Given the head entity and the tail entity, find the best matching relationship in all relationship sets in the knowledge graph. The method is as follows:
[0111] Using graph neural network to calculate the head entity structure features h s Structural features of the tail entity t s , then the predicted relationship structure characteristics are:
[0112]
[0113] Calculate the structural feature r of each relation in all relation sets in the same knowledge graph i s , i=0,1,2.., select the relationship r with the smallest Euclidean distance s , and the Euclidean distance between the structural features of the relationship and the predicted relationship If the value is less than the threshold, the corresponding relationship between the head entity and the tail entity is selected as relationship r, otherwise there is no relationship that meets the condition;
[0114] Step 3-2-3, given the relationship and tail entity, find the best matching head entity in all entity sets in the knowledge graph;
[0115] Using graph neural network to calculate tail entity structure features e t s The structural characteristics of the relationship s , then the predicted head entity structure features are:
[0116]
[0117] Calculate the structural features e of each entity in all entity sets in the same knowledge graph i s , i=0,1,2..and i≠t, select the entity e with the smallest Euclidean distance h , and the Euclidean distance between the structural features of the entity and the predicted tail entity is less than the threshold, then the head entity is selected as entity e h , otherwise there is no qualifying header entity.
[0118] After using the above method to build a model for entity alignment and a model for multilingual knowledge graph completion, the final loss function used for model training consists of two parts. One is the alignment loss function used to shorten the distance between aligned entities:
[0119]
[0120] Where: P ij For any two knowledge graphs G i and G j The set of aligned entities between γ a is the interval hyperparameter of the contrastive loss, and is the multi-layer graph neural network encoding feature of two entities with alignment relationship, and It is the multi-layer graph neural network encoding feature of two entities without alignment relationship.
[0121] The other is the completion loss function for predicting missing entities in triples:
[0122]
[0123] φ(h,r,t)=-‖e h s +r s -e t s ‖2
[0124] Where: γ K is the interval hyperparameter of the completion loss, is any triple in the training dataset, including the head entity e h , tail entity e t and the relationship r, e h s 、e t s and r s The initial vectors of the three respectively represent the structural features after being encoded by the multi-layer graph neural network.
[0125] Based on the above loss function, the alignment model and the knowledge model are jointly trained, and the total loss function is:
[0126]
[0127] That is, the sum of the alignment losses of all aligned entity pairs between N knowledge graphs plus the sum of the completion losses of all triples in the N knowledge graphs.
[0128] Step 4 uses the entity alignment model trained in step 3 to iteratively generate aligned entities:
[0129] The number of aligned entities obtained in the initial stage is small, so in the model training stage, the alignment model obtained by step 3 is used to iteratively generate new aligned entities. i and e j After encoding by the alignment model, the corresponding structural feature representation is obtained, denoted as and Then, the text description features and structural features of the entity are combined, and the CSLS distance between all entities between the two knowledge graphs is calculated according to the following formula. If the two entities are nearest neighbors in terms of CSLS distance, the two entities are added to the aligned entity pair set.
[0130]
[0131] in Representing entity e i The structural characteristics of Representing entity e i The text features of .
[0132] Step 5: Adjust the filter parameters according to the number of iterations to filter the newly generated aligned entities:
[0133] The filter parameter θ is calculated according to the following formula:
[0134] θ=min(θ0+δ×s,θ max )
[0135] Where θ0 is the initial value of the filter. Since the alignment accuracy of the alignment model is low in the first iteration, it is set to be relatively small. max is the maximum value of the filter, which prevents too many incorrectly aligned entity pairs from being added to the training samples, δ is the value by which the filter threshold increases in each iteration, and s is the number of iterations, starting from 0, i.e., s is 0 in the first iteration, 1 in the second, and so on;
[0136] Calculate the CSLS distance of the aligned entity pairs in the aligned entity set generated in step 4, and retain the entity pairs whose CSLS distance is less than the filter parameter θ to form the aligned entity pairs Pair of the sth iteration s .
[0137] Step 6: Add the filtered aligned entities to the training samples and train the entity alignment model and multilingual knowledge graph completion model:
[0138] Pair s Add to the training set and use the training method in step 3 to generate a new alignment model and knowledge completion model.
[0139] Step 7, repeat steps 4, 5 and 6 until the number of iterations meets the requirement;
[0140] Step 8: Use the trained entity alignment model and multilingual knowledge graph completion model to perform entity alignment on knowledge graphs in multiple different languages and use the alignment results to complete the knowledge graphs.
[0141] Example:
[0142] An embodiment of the present invention provides a multilingual knowledge graph completion method for an unaligned entity scenario, which aggregates information from knowledge graphs from different sources onto a target knowledge graph in a specific manner, thereby improving the performance of multilingual knowledge graph completion.
[0143] An embodiment of a multilingual knowledge graph completion method for an unaligned entity scenario of the present invention is mainly implemented by the following steps.
[0144] Step 1: Build an alignment entity acquisition module to find the alignment entities between different knowledge graphs.
[0145] At the initial stage of the task, there are no pre-given alignment entities. Instead, for the given knowledge graph dataset DBP-5L constructed from Wikipedia in five different languages (Greek, English, Spanish, French, and Japanese), it contains multiple entities and multiple relationship types, as well as triples consisting of two entities and relationships (see Table 1). Each entity in DBP-5L has its text name and text description. The text information of each entity is converted into an English text description through a multilingual translator (Google Translate is used in this embodiment), and then encoded through the pre-trained language model mBERT, which can capture rich semantic information in the entity text, and then obtain the text features of the entity. After that, for any two entities e in the knowledge graphs of different languages, i and e j , calculate the CSLS distance between them, if the two are each other's nearest neighbors in terms of CSLS distance (i.e., the CSLS distance is the smallest), then add the two entities to the set of aligned entity pairs.
[0146] The statistics of the DBP-5L dataset are as follows:
[0147] Table 1 Dataset statistics
[0148]
[0149] Examples of triplets in DBP-5L are as follows:
[0150] (2**_(TV_series), executiveProducer, M**o) means the producer of the TV series "2**" is Man**do (S**_Pictures_Entertainment, owner, S**) means the owner of S** Pictures Entertainment is S**
[0151] Examples of entities in DBP-5L are as follows:
[0152] 2**_(TV_series), the TV series 2**
[0153] M**o, that is, more
[0154] Examples of relationships in DBP-5L are as follows:
[0155] executiveProducer, i.e. supervisor
[0156] manufacturer, that is, manufacturer
[0157] An example of entity description in DBP-5L is as follows:
[0158] M**o: M**l H**r "M**y" C**o (born June 10, 1961) is an A**n writer, director and producer of films and television programs. Coto was the executive producer and showrunner of Star Trek: Enterprise in its final season, and executive producer of four seasons of 24. He was an executive producer and writer for the fifth season of the Showtime TV series Dexter.
[0159] The CSLS distance specifically includes:
[0160]
[0161] Where: and Entity e i and e j The descriptions of N are represented by text features encoded by the mBERT model; j (e i ) is entity e i The set of neighbor entities in the jth knowledge graph; K is N j (e i )
[0162] Step 2: Design a graph neural network based on multi-graph attention mechanism:
[0163] The five given knowledge graphs are united as independent and disconnected graphs to form a unified graph G; a multi-layer graph neural network is used to encode the entity vectors and entity relationship vectors in the constructed graph G.
[0164] Because the given N knowledge graphs are independent and disconnected graphs, it is impossible to directly use the graph neural network for effective information dissemination. The N independent graphs can be connected into a unified graph using the alignment entities initially obtained in step 1. Specifically, an alignment relationship is added to the relationship set of the knowledge graph dataset, and the alignment entity pair (e i ,e j ) is converted to a triple (e i ,align,e j), all knowledge graphs are connected by adding these triples to obtain the large graph G. Based on this unified large graph, all entities and relationships in the knowledge graph are randomly initialized in the same vector space with a feature dimension of 256 to obtain the initial entity vector representation h 0 (a vector of dimension 256) and the relationship vector representation r (a vector of dimension 256).
[0165] After building the graph G and initializing the entity relationship vector, a two-layer graph neural network is used to encode the entities and relationships. The transfer process from the lth layer network to the l+1th layer network is as follows:
[0166]
[0167] Where: and Entity e i The hidden layer representation of the lth layer and the l+1th layer of the network; σ(·) is the nonlinear activation function implemented by GELU; N(e i ) is entity e i The set of neighbor entities; e j For entity e i The neighbor entity of i and e j the relationship between; For entity e j The hidden layer representation after being associated with the relation r; is the attention function, which is used to calculate the attention weight of the central entity to the neighboring entities.
[0168] For each knowledge graph, a different query-key-value transformation matrix W is maintained. q , W k , W v , and then the attention weight is calculated as follows:
[0169]
[0170] Where: W qi , W kj , W vj Entity e i The query transformation matrix corresponding to the knowledge graph, entity e j The key transformation matrix and value transformation matrix corresponding to the knowledge graph; d is the dimension of the hidden layer representation; β r is a learnable relation variable corresponding to relation r, used to measure the weight of relation r; λ is used to weigh the reliability of the pseudo-aligned entity obtained by the above method. When relation r is an aligned relation, Otherwise, 1. The text features encoded by the mBERT model for entity text description, The entity vector represents h 0 The encoding after encoding using a two-layer graph neural network; finally, [·] is the vector concatenation function.
[0171] Step 3: Build a model for entity alignment and a model for multilingual knowledge graph completion based on graph neural network. Based on the alignment loss function and the completion loss function, initialize the joint training of the alignment model and the knowledge model:
[0172] Based on the graph neural network in step 2, a model for entity alignment and a model for multilingual knowledge graph completion are constructed. The aligned entity acquisition module in step 1 is used to construct the aligned entity set P and train the model. The loss function used for model training contains two parts. One is the alignment loss function used to shorten the distance between aligned entities:
[0173]
[0174] Where: P ij To extract the information from P in two knowledge graphs G i and G j The set of aligned entities between γ A is the margin hyperparameter of the contrastive loss and is set to 0.5. and It is a two-layer graph neural network encoding feature of two entities with an alignment relationship. and It is a two-layer graph neural network encoding feature of two entities without alignment relationship.
[0175] The other is the completion loss function for predicting missing entities in triples:
[0176]
[0177] φ(h,r,t)=-‖e h s +r s -e t s ‖2
[0178] Where: γ K The interval hyperparameter for the completion loss is set to 0.5. is any triple in the training dataset, including the head entity e h , tail entity e t and the relationship r, e h s 、e t s and rs Two-layer graph neural network encoding features for the three respectively.
[0179] Based on the above loss function, the alignment model and the knowledge model are jointly trained, and the total loss function is:
[0180]
[0181] That is, the sum of the alignment losses of all aligned entity pairs between the five knowledge graphs plus the sum of the completion losses of all triples in the five knowledge graphs.
[0182] Step 4 uses the entity alignment model trained in step 3 to iteratively generate aligned entities:
[0183] The number of aligned entities obtained in the initial stage is small, so in the model training stage, the alignment model obtained by step 3 is used to iteratively generate new aligned entities. i and e j After encoding by the alignment model, the corresponding structural feature representation is obtained, denoted as and Then, the text description features and structural features of the entity are combined, and the CSLS distance between all entities between the two knowledge graphs is calculated according to the following formula. If the two entities are each other's nearest neighbors in terms of CSLS distance (that is, they are entities with the closest CSLS distance to each other), then the two entities are added to the set of aligned entity pairs.
[0184]
[0185] in Representing entity e i The structural characteristics of Representing entity e i The text features of .
[0186] Step 5: Adjust the filter parameters according to the number of iterations to filter the newly generated aligned entities:
[0187] The filter parameter θ is calculated according to the following formula:
[0188] θ=min(θ0+δ×s,θ max )
[0189] Where θ0 is the initial value of the filter, which is set to 0.1 here. Since the alignment accuracy of the alignment model is low in the first iteration, it is set to a smaller value. max is the maximum value of the filter, which is set to 0.4 here to prevent too many incorrectly aligned entity pairs from being added to the training samples. δ is the value by which the filter threshold is increased in each iteration, which is set to 0.06. s is the number of iterations, starting from 0, i.e., s is 0 in the first iteration, 1 in the second, and so on.
[0190] Calculate the CSLS distance of the aligned entity pairs in the aligned entity set generated in step 4, and retain the entity pairs whose CSLS distance is less than the filter parameter θ to form the aligned entity pairs Pair of the sth iteration s .
[0191] Step 6: Add the filtered aligned entities to the training samples and train the entity alignment model and multilingual knowledge graph completion model:
[0192] Pair s Add to the training set and use the training method in step 3 to generate a new alignment model and knowledge completion model.
[0193] Step 7, repeat steps 4, 5 and 6 until the number of iterations meets the requirement;
[0194] Step 8: Use the trained entity alignment model and multilingual knowledge graph completion model to perform entity alignment on the knowledge graphs of five different languages and use the alignment results to complete the knowledge graphs, that is, to discover new triples. For example, in the English knowledge graph, there is only one triple for the entity "The Tale of Genji", "type", "Monogatari", while in the Japanese knowledge graph, there are four triples for the entity "The Tale of Genji", ("The Tale of Genji", "type", "Monogatari"), ("The Tale of Genji", "type", "Love Story"), ("The Tale of Genji", "type", "Royal Family Related Story"), ("The Tale of Genji", "type", "Literature-Novel"). First, use the entity alignment module to align the two entities "The Tale of Genji" and "The Tale of Genji", that is, the two are descriptions of the same entity in different languages. Then the English knowledge graph is completed to obtain three new facts described by triples: ("The Tale of Genji", "Type", "Love Story"), ("The Tale of Genji", "Type", "Royal Family Related Story"), and ("The Tale of Genji", "Type", "Literature-Novel"), completing the English knowledge graph.
[0195] In a specific implementation, the present application provides a computer storage medium and a corresponding data processing unit, wherein the computer storage medium can store a computer program, and when the computer program is executed by the data processing unit, the invention content of a multilingual knowledge graph completion method for a non-aligned entity scenario provided by the present invention and some or all of the steps in each embodiment can be run. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0196] Those skilled in the art can clearly understand that the technical solutions in the embodiments of the present invention can be implemented by means of computer programs and their corresponding general hardware platforms. Based on such an understanding, the technical solutions in the embodiments of the present invention can be essentially or partly contributed to the prior art in the form of computer programs, i.e., software products, which can be stored in a storage medium and include several instructions for enabling a device including a data processing unit (which can be a personal computer, a server, a single-chip microcomputer, an MCU or a network device, etc.) to execute the methods described in various embodiments of the present invention or certain parts of the embodiments.
[0197] The present invention provides a method and idea for a multilingual knowledge graph completion method without aligned entity scenarios. There are many methods and approaches to implement the technical solution. The above is only a preferred implementation of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention. All components not specified in this embodiment can be implemented using existing technologies.
Claims
1. A multilingual knowledge graph completion method for non-aligned entity scenarios, characterized in that: The steps include: Step 1: Build an alignment entity acquisition module to find the alignment entities between knowledge graphs in different languages; Step 2: Design a graph neural network based on multi-graph attention mechanism; Step 3: construct an entity alignment model and a multilingual knowledge graph completion model based on the graph neural network described in step 2, and jointly train the entity alignment model and the multilingual knowledge graph completion model based on the alignment loss function and the completion loss function; Step 4, using the entity alignment model initialized by joint training in step 3, regenerating aligned entities between knowledge graphs of different languages; Step 5, adjusting the filter parameters according to the number of iterations, and using the filter to filter the aligned entities generated in step 4; Step 6, adding the aligned entities filtered in step 5 to the training samples, and using the method described in step 3 to train the entity alignment model and the multilingual knowledge graph completion model to obtain a new entity alignment model and a multilingual knowledge graph completion model; Step 7, repeat steps 4 to 6 until the number of iterations meets the preset requirements and the training is completed; Step 8: Use the trained entity alignment model and multilingual knowledge graph completion model to perform entity alignment on knowledge graphs in multiple different languages, and use the alignment results to complete the knowledge graphs.
2. According to the method of claim 1, the method is characterized in that: The construction of the alignment entity acquisition module described in step 1 specifically includes the following steps: Step 1-1, for a given knowledge graph in multiple different languages, obtain the text name and text description of each entity therein; Step 1-2, converting the text name and text description into text in the same language using a multilingual translator; Step 1-3, encoding the text in the same language through the pre-trained language model mBERT to obtain the text features of the entity; Step 1-4, create an empty set of aligned entity pairs; Steps 1-5, for any two entities e in the knowledge graph i and e j , calculate the CSLS distance between them, if the two entities are nearest neighbors in terms of CSLS distance, then take the two entities as an aligned entity pair and add them to the aligned entity pair set; The CSLS distance is calculated by: Among them, CSLS (e i ,e j ) represents any two entities e in the knowledge graph i and entity e j The CSLS distance, and Entity e i and entity e j The corresponding text description feature, r j (e i ) represents entity e i The average distance to the nearest neighbor entity in its knowledge graph; N(e i ) is to use the entity e in vector space i The text feature vector With entity e i The text feature vectors of all entities in the knowledge graph are used to calculate the distance, and a set of K nearest neighbor entities is selected, where K is N(e i ) is set as a hyperparameter.
3. According to the method of claim 2, the multilingual knowledge graph completion method for non-aligned entity scenarios is characterized in that: The design of the graph neural network based on the multi-graph attention mechanism described in step 2 specifically includes: Step 2-1: Treat the given N knowledge graphs as N independent graphs and build a unified graph G; Step 2-2: Use a multi-layer graph neural network to encode the entity vectors and entity relationship vectors in the graph G.
4. According to the method of claim 3, the multilingual knowledge graph completion method for non-aligned entity scenarios is characterized in that: The joint graph construction described in step 2-1, i.e., using the alignment entities obtained in step 1, connecting the N independent graphs into a unified graph, specifically includes: Step 2-1-1, construct a relationship set; Step 2-1-2, adding an alignment relationship, that is, the alignment entity pair (e i ,e j ), converted to a triple (e i ,Alignment relationship,e j ), and add the above triples to the relationship set; Step 2-1-3, connect all knowledge graphs through the relationship set to obtain a unified graph G; Step 2-1-4: Based on graph G, randomly initialize all entities and relationships in the knowledge graph in the same vector space to obtain the initial entity vector representation h 0 And the relationship vector represents r.
5. According to the method of claim 4, the multilingual knowledge graph completion method for non-aligned entity scenarios is characterized in that: The step 2-2 of using a multi-layer graph neural network to encode the entity vectors and entity relationship vectors in the graph G specifically includes: Step 2-2-1, construct a multi-layer graph neural network, the network structure is as follows: The transmission process from the lth layer network to the l+1th layer network is defined as follows: in, and They are the central entities e i The hidden layer representation of the lth layer and the l+1th layer of the network; σ(·) is a nonlinear activation function implemented by the GELU function; N(e i ) is entity e i The neighborhood entity set of j For entity e i The neighbor entity of i and e j The relationship between , that is, the relationship between triples in the knowledge graph; For entity e j The hidden layer representation after being associated with the relation r; is the attention function, which is used to calculate the attention weight of the central entity to the neighboring entity; Step 2-2-2: For each knowledge graph, maintain different query transformation matrices, key transformation matrices, and value transformation matrices W. q , W k and W v , the specific calculation method of the attention weight of the knowledge graph is as follows: Among them, W qi , W kj and W vj Entity e i The query transformation matrix and entity e corresponding to the knowledge graph j The key transformation matrix and value transformation matrix corresponding to the knowledge graph; d is the dimension of the hidden layer representation; β r is a learnable relation variable corresponding to relation r, used to measure the weight of relation r; λ is used to weigh the reliability of the pseudo-aligned entity obtained by the above method. When relation r is an aligned relation, Otherwise it is 1; [·] is the vector concatenation function.
6. According to the method of claim 5, the multilingual knowledge graph completion method for non-aligned entity scenarios is characterized in that: The construction of the entity alignment model and the multilingual knowledge graph completion model described in step 3 specifically includes: Step 3-1: Build an entity alignment model, as follows: Select two entities e from the graph G described in step 2-1-3 that belong to two knowledge graphs i and e j , the structural features generated after processing by the graph neural network generated in step 2-2 and Calculate the Euclidean distance between the two features. If the Euclidean distance is lower than a threshold, the two entities are determined to be aligned entities. Step 3-2, build a multilingual knowledge graph completion model, that is, for two known elements in a triple in the same knowledge graph, calculate the third element, as follows: Step 3-2-1: Given the head entity and relationship, find the best matching tail entity in all entity sets in the knowledge graph. The method is as follows: Using graph neural network to calculate the head entity structure features h s The structural characteristics of the relationship s , then the predicted tail entity structure features are: Calculate the structural features e of each entity in all entity sets in the same knowledge graph i s , i=0,1,2..and i≠h, select the entity e with the smallest Euclidean distance t , and the Euclidean distance between the structural features of the entity and the predicted tail entity is less than the threshold, then the tail entity is selected as entity e t , otherwise there is no tail entity that meets the conditions; Step 3-2-2: Given the head entity and the tail entity, find the best matching relationship in all relationship sets in the knowledge graph. The method is as follows: Using graph neural network to calculate the head entity structure features h s Structural features of the tail entity t s , then the predicted relationship structure characteristics are: Calculate the structural feature r of each relation in all relation sets in the same knowledge graph i s , i=0,1,2.., select the relationship r with the smallest Euclidean distance s , and the Euclidean distance between the structural features of the relationship and the predicted relationship If the value is less than the threshold, the corresponding relationship between the head entity and the tail entity is selected as relationship r, otherwise there is no relationship that meets the condition; Step 3-2-3, given the relationship and tail entity, find the best matching head entity in all entity sets in the knowledge graph; Using graph neural network to calculate tail entity structure features e t s The structural characteristics of the relationship s , then the predicted head entity structure features are: Calculate the structural features e of each entity in all entity sets in the same knowledge graph i s , i=0,1,2..and i≠t, select the entity e with the smallest Euclidean distance h , and the Euclidean distance between the structural features of the entity and the predicted tail entity If it is less than the threshold, the head entity is selected as entity e h , otherwise there is no qualifying header entity.
7. The method for completing a multilingual knowledge graph in a non-aligned entity scenario according to claim 6, characterized in that: The alignment loss function and completion loss function described in step 3 specifically include: The alignment loss function Used to shorten the distance between aligned entities, as follows: Among them, P ij For any two knowledge graphs G i and G j The set of aligned entity pairs between γ A is the interval hyperparameter of the contrastive loss; The completion loss function Used to predict missing entities in triples, including: φ(h,r,t)=-‖e h s +r s -e t s ‖2 Among them, γ K is the interval hyperparameter of the completion loss, is any triple in the training dataset, including the head entity e h , tail entity e t and the relationship r, e h s 、e t s and r s The initial vectors of the three respectively represent the structural features after being encoded by the multi-layer graph neural network.
8. The method for completing a multilingual knowledge graph in a non-aligned entity scenario according to claim 7, characterized in that: The joint training described in step 3 specifically includes: Based on the alignment loss function and completion loss function, the entity alignment model and the multilingual knowledge graph completion model are jointly trained. The total loss function for: That is, the sum of the alignment losses of all aligned entity pairs between N knowledge graphs plus the sum of the completion losses of all triples in the N knowledge graphs.
9. The method for completing a multilingual knowledge graph in a non-aligned entity scenario according to claim 8, characterized in that: The regeneration of the aligned entities between knowledge graphs in different languages described in step 4 specifically includes: Step 4-1, entity e i and e j After the entity alignment model is used, the corresponding structural feature representation is obtained after encoding, which is recorded as and Step 4-2, calculate the CSLS distance between all entities in the knowledge graphs of different languages, as follows: in, Representing entity e i The structural characteristics of Representing entity e i Text features of In step 4-3, if the two entities are each other's nearest neighbors in terms of CSLS distance, the two entities are added to the set of aligned entity pairs.
10. The method for completing a multilingual knowledge graph in a non-aligned entity scenario according to claim 9, characterized in that: The filtering described in step 5 specifically includes: Step 5-1, construct the filter and calculate the filter parameter θ as follows: θ=min(θ0+δ×s,θ max ) Among them, θ0 is the initial value of the filter, θ max is the maximum value of the filter, δ is the value by which the filter threshold increases in each iteration, and s is the number of iterations, starting from 0; Step 5-2, calculate the CSLS distance of the aligned entity pairs in the aligned entity set generated in step 4, retain the entity pairs whose CSLS distance is less than the filter parameter θ, and constitute the aligned entity pairs Pair of the sth iteration s .
Citation Information
Cited By
Reservoir intelligent inspection system based on knowledge graph and digital twinning
CN120111079A