A knowledge graph embedding method and device based on neighborhood information
By determining and utilizing the neighborhood information of entities in the knowledge graph, the problem of existing methods ignoring neighborhood information is solved, and more effective knowledge representation and reasoning capabilities are achieved.
Patent Information
- Application Number
- CN202210531210.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-16
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-05-16
AI Technical Summary
Existing knowledge graph embedding methods ignore neighborhood information around triples, making it difficult to effectively deal with rare entities with less associated knowledge, thereby limiting the ability of knowledge reasoning and fusion.
By obtaining entities, relationships and neighbors in the knowledge graph, determine the neighbors of the same relationship and different relationships corresponding to the entity, and calculate the Pearson correlation coefficient based on these neighbors, sort and select the final neighbors to determine the rich neighbor information. Based on this information, the entity representation vector of the entity is calculated and the entity representation and the entity itself are fused through the gate mechanism.
The neighborhood information of triples is effectively utilized, providing more semantic information for entities, improving the performance of knowledge representation, and thus enhancing the ability of knowledge reasoning and fusion.
Smart Images

Figure CN115203426B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graph technology, and in particular to a knowledge graph embedding method and device based on neighborhood information. Background Art
[0002] The concept of the Knowledge Graph (KG) was formally proposed in 2012, primarily for improving search engine performance. Essentially, a knowledge graph is a semantic network that represents various types of entities and the semantic relationships between them. A knowledge graph is a directed graph with different types of entities as nodes and various relationships between entities as edges. It is typically stored using the Resource Description Framework (RDF) standard in the form of triples (head, relation, tail), abbreviated as (h, r, t), where h represents the head entity, t represents the tail entity, and r represents the relationship between the head entity h and the tail entity t. Knowledge graphs currently play a vital role in fields such as data mining and artificial intelligence, promoting the development of artificial intelligence applications such as intelligent question-answering and personalized travel recommendations.
[0003] With the advent of the big data era, the scale of knowledge graphs has grown rapidly, with the emergence of various large-scale knowledge graphs, such as Freebase, WordNet, and DBpedia. In recent years, methods for learning vector representations of entities and relationships in knowledge graphs have become extremely popular. Translation models, such as TransE, model relationships as translation vectors from the head entity to the tail entity. Due to their simplicity and effectiveness, they have become a representative model for knowledge representation learning. Other models extending TransE, such as TransH, TransR, CTransR, and TransD, have also achieved excellent results. However, these models all assume that triplets are independent of each other and ignore the neighborhood information surrounding the triplets during modeling. Therefore, they are unable to handle rare entities with less associated knowledge.
[0004] The field equipment entity is a combination of multiple attributes. When it acts as a neighbor node of different entities through different relationships, the attribute information provided should be different. The model should select the most relevant attributes of the neighbor node as the neighborhood information based on the neighbor edge relationship of the field equipment entity. Intuitively speaking, the entity with more associated triples has richer neighborhood information, and the influence of a single neighborhood information will be reduced. Therefore, it will rely more on the neighborhood structure and select the neighborhood information that has a greater impact on it. Entities with fewer associated triples have a greater scarcity of neighborhood information, resulting in a single neighborhood information having a greater impact on them. Therefore, they will rely more on the neighborhood information provided by their neighbor nodes. The model should flexibly adjust the selection of the entity's neighbor nodes to balance the information in the above two situations to obtain more valuable semantic representations, thereby improving the ability of knowledge reasoning and fusion.
[0005] To sum up, how to improve the ability of knowledge reasoning and integration has become an urgent problem to be solved. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to provide a knowledge graph embedding method and device based on neighborhood information, which can improve the ability of knowledge reasoning and fusion.
[0007] In order to solve the above technical problems, a technical solution adopted by the present invention is:
[0008] A knowledge graph embedding method based on neighborhood information, comprising the steps of:
[0009] Obtaining a knowledge graph, the knowledge graph including entities, relationships corresponding to the entities, and neighboring nodes;
[0010] Determining neighboring nodes with the same relationship and neighboring nodes with different relationships corresponding to the entity based on the entity, the relationship, and the neighboring nodes, and determining neighborhood information according to the neighboring nodes with the same relationship and the neighboring nodes with different relationships;
[0011] An entity representation of the entity is determined based on the neighborhood information.
[0012] In order to solve the above technical problems, another technical solution adopted by the present invention is:
[0013] A knowledge graph embedding device based on neighborhood information, comprising:
[0014] A data acquisition module is used to acquire a knowledge graph, wherein the knowledge graph includes entities, relationships corresponding to the entities, and neighboring nodes;
[0015] A domain information determination module is configured to determine, based on the entity, the relationship, and the neighboring nodes, neighboring nodes of the same relationship and neighboring nodes of different relationships corresponding to the entity, and determine neighborhood information based on the neighboring nodes of the same relationship and neighboring nodes of different relationships;
[0016] An entity representation determination module is configured to determine an entity representation of the entity based on the neighborhood information.
[0017] Furthermore, the domain information determination module includes:
[0018] A calculation module, configured to calculate the Pearson correlation coefficient between the entity and each of the neighboring nodes;
[0019] A neighbor node determination module, configured to determine neighbor nodes of the same relationship and neighbor nodes of different relationships corresponding to the entity;
[0020] A sorting module, configured to sort the neighboring nodes with the same relationship in a preset order according to the Pearson correlation coefficient to obtain sorted neighboring nodes with the same relationship;
[0021] a selection module, configured to determine a ratio of the neighboring nodes with the same relationship to the neighboring nodes with different relationships, and select final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the ratio;
[0022] The domain aggregation module is used to perform neighborhood aggregation based on the final neighboring nodes with the same relationship to obtain neighborhood information.
[0023] Furthermore, the calculation module for calculating the Pearson correlation coefficient between the entity and each of the neighboring nodes includes:
[0024]
[0025] Wherein, pcc(e,e′) represents the Pearson correlation coefficient, e represents the entity, e′ represents the neighboring node, σ e represents the standard deviation of the entity, σ e′ Represents the standard deviation of the neighboring nodes.
[0026] Furthermore, the selection module is further used to:
[0027] determining the number of nodes according to the ratio;
[0028] Selecting final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the number of nodes;
[0029] The number of nodes d′ is:
[0030]
[0031] Where, Represents the same relationship r a The number of neighboring nodes under Represents r aThe number of neighbor nodes under different relationships, [] represents the rounding function.
[0032] Furthermore, the domain aggregation module is further used to:
[0033] Determining a correlation coefficient between the entity and each of the final neighboring nodes having the same relationship according to the Pearson correlation coefficient;
[0034] determining a correlation coefficient threshold corresponding to the correlation coefficient;
[0035] It is determined whether the association coefficient is less than or equal to the association coefficient threshold; if so, the final neighboring nodes with the same relationship corresponding to the association coefficient are aggregated, and the weight corresponding to each of the final neighboring nodes with the same relationship is obtained.
[0036] Furthermore, the domain aggregation module is further configured to determine, based on the Pearson correlation coefficient, a correlation coefficient between the entity and each of the final neighboring nodes having the same relationship, including:
[0037]
[0038] Where, Re i represents the correlation coefficient, r i Represents the relationship between the entity and the i-th final neighbor node with the same relationship;
[0039]
[0040] In the formula, R′e represents the association coefficient threshold, n represents the number of neighboring nodes with the same relationship, N e Indicates the number of triples associated with the entity, N * It represents the maximum number of associated triples in the entity, and δ represents the margin coefficient;
[0041] The weight a i for:
[0042]
[0043] Where a i represents the weight.
[0044] Furthermore, the entity representation determination module is further configured to:
[0045] Calculating an entity representation vector of the entity based on the neighborhood information according to the weight;
[0046] The entity representation vector and the entity are fused using a gate mechanism to obtain an entity representation of the entity.
[0047] Furthermore, the entity representation determination module is further configured to calculate, according to the weight, an entity representation vector of the entity based on the neighborhood information, including:
[0048]
[0049] Where, e e,r represents the entity representation vector, M r′ Represents the projection matrix of the final neighboring nodes of the same relationship, N e (ξ e ) represents a subset of the neighbor node set of the entity, including ξ neighbor nodes;
[0050]
[0051] Wherein, e″ represents the entity representation of the entity, ge represents the entity representation vector and the gating vector of the entity, Represents vector element-wise multiplication.
[0052] Furthermore, it also includes:
[0053] A function definition module, used to define a scoring function and a loss function corresponding to the entity representation;
[0054] An optimization module is used to optimize the scoring function and the loss function using a stochastic gradient descent method.
[0055] The beneficial effects of the present invention are: based on entities, relationships and neighboring nodes, the neighboring nodes of the same relationship and the neighboring nodes of different relationships corresponding to the entity are determined, and the neighborhood information is determined based on the neighboring nodes of the same relationship and the neighboring nodes of different relationships, and the entity representation of the entity is determined based on the neighborhood information. Regardless of whether the entity is associated with more or fewer triples, the most relevant attributes on the corresponding neighboring nodes can be selected as the neighborhood information of the entity according to the neighboring edge relationship, effectively utilizing the neighborhood information of the triples, providing more semantic information for the entity, improving the knowledge representation performance, and thus improving the ability of knowledge reasoning and fusion. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 This is a flowchart of the steps of a knowledge graph embedding method based on neighborhood information according to an embodiment of the present invention;
[0057] Figure 2 Schematic diagram of the structure of a knowledge graph embedding device based on neighborhood information according to an embodiment of the present invention;
[0058] Figure 3 This is a schematic diagram of a knowledge graph example in the knowledge graph embedding method based on neighborhood information in an embodiment of the present invention;
[0059] Figure 4This is a schematic diagram of the neighborhood structure corresponding to a certain entity in the knowledge graph in the knowledge graph embedding method based on neighborhood information in an embodiment of the present invention. DETAILED DESCRIPTION
[0060] To illustrate the technical content, achieved objectives and effects of the present invention in detail, the following description is given in conjunction with the embodiments and accompanying drawings.
[0061] Please refer to Figure 1 , an embodiment of the present invention provides a knowledge graph embedding method based on neighborhood information, comprising the steps of:
[0062] Obtaining a knowledge graph, the knowledge graph including entities, relationships corresponding to the entities, and neighboring nodes;
[0063] Determining neighboring nodes with the same relationship and neighboring nodes with different relationships corresponding to the entity based on the entity, the relationship, and the neighboring nodes, and determining neighborhood information according to the neighboring nodes with the same relationship and the neighboring nodes with different relationships;
[0064] An entity representation of the entity is determined based on the neighborhood information.
[0065] From the above description, it can be seen that the beneficial effects of the present invention are: based on entities, relationships and neighboring nodes, the neighboring nodes of the same relationship and the neighboring nodes of different relationships corresponding to the entity are determined, and the neighborhood information is determined based on the neighboring nodes of the same relationship and the neighboring nodes of different relationships. The entity representation of the entity is determined based on the neighborhood information. Regardless of whether the entity is associated with more or fewer triples, the most relevant attributes on the corresponding neighboring nodes can be selected as the neighborhood information of the entity according to the neighboring edge relationship, which effectively utilizes the neighborhood information of the triples, provides more semantic information for the entity, improves the knowledge representation performance, and thus improves the ability of knowledge reasoning and fusion.
[0066] Furthermore, the determining, based on the entity, the relationship, and the neighboring nodes, the neighboring nodes with the same relationship and the neighboring nodes with different relationships corresponding to the entity includes:
[0067] Calculating the Pearson correlation coefficient between the entity and each of the neighboring nodes;
[0068] Determine neighboring nodes with the same relationship and neighboring nodes with different relationships corresponding to the entity;
[0069] Sorting the neighboring nodes with the same relationship in a preset order according to the Pearson correlation coefficient to obtain sorted neighboring nodes with the same relationship;
[0070] Determining the ratio of the neighboring nodes with the same relationship to the neighboring nodes with different relationships, and selecting final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the ratio;
[0071] The determining of neighborhood information based on the neighboring nodes with the same relationship and the neighboring nodes with different relationships includes:
[0072] Neighborhood aggregation is performed based on the final neighboring nodes with the same relationship to obtain neighborhood information.
[0073] Furthermore, the calculating of the Pearson correlation coefficient between the entity and each of the neighboring nodes includes:
[0074] The Pearson correlation coefficient pcc(e,e′) is:
[0075]
[0076] In the formula, e represents the entity, e′ represents the neighboring node, σ e represents the standard deviation of the entity, σ e′ Represents the standard deviation of the neighboring nodes.
[0077] From the above description, it can be seen that in the neighborhood structure of an entity, the greater the degree of association between the neighboring nodes and the entity and the closer the distance, the greater the influence of the neighboring nodes on the entity and the greater the proportion of information aggregation. The Pearson (PCC) correlation coefficient can be used as an important indicator to measure the correlation of neighboring nodes. The neighboring nodes with the same relationship are sorted in a preset order according to the Pearson correlation coefficient to obtain the sorted neighboring nodes with the same relationship, and the ratio of neighboring nodes with the same relationship to neighboring nodes with different relationships is determined. The final neighboring nodes with the same relationship are selected from the sorted neighboring nodes according to the ratio, and neighborhood aggregation is performed based on the final neighboring nodes with the same relationship to obtain neighborhood information. In this way, the selection of neighboring nodes with the same relationship and different relationships in the domain structure of the entity is accurately and effectively realized.
[0078] Furthermore, selecting the final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the ratio includes:
[0079] determining the number of nodes according to the ratio;
[0080] Selecting final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the number of nodes;
[0081] The number of nodes d′ is:
[0082]
[0083] Where, Represents the same relationship r a The number of neighboring nodes under Represents r a The number of neighbor nodes under different relationships, [] represents the rounding function.
[0084] From the above description, it can be seen that determining the number of nodes according to the proportion and selecting the final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the number of nodes can avoid invisibly increasing the proportion of attributes corresponding to the same relationship during the information aggregation process and suppressing other neighborhood information attributes, thereby improving the richness and enrichment of neighborhood information.
[0085] Furthermore, performing neighborhood aggregation based on the final neighboring nodes with the same relationship to obtain neighborhood information includes:
[0086] Determining a correlation coefficient between the entity and each of the final neighboring nodes having the same relationship according to the Pearson correlation coefficient;
[0087] determining a correlation coefficient threshold corresponding to the correlation coefficient;
[0088] It is determined whether the association coefficient is less than or equal to the association coefficient threshold; if so, the final neighboring nodes with the same relationship corresponding to the association coefficient are aggregated, and the weight corresponding to each of the final neighboring nodes with the same relationship is obtained.
[0089] Furthermore, determining the correlation coefficient between the entity and each of the final neighboring nodes having the same relationship according to the Pearson correlation coefficient includes:
[0090] The correlation coefficient Re i for:
[0091]
[0092] Where r i Represents the relationship between the entity and the i-th final neighbor node with the same relationship;
[0093] The correlation coefficient threshold R′e is:
[0094]
[0095] In the formula, n represents the number of neighboring nodes with the same relationship, N e Indicates the number of triples associated with the entity, N * It represents the maximum number of associated triples in the entity, and δ represents the margin coefficient;
[0096] The weight a i for:
[0097]
[0098] From the above description, it can be seen that neighborhood aggregation selects the most relevant attributes of neighboring nodes as neighborhood information. Intuitively, the larger the Pearson correlation coefficient between the neighboring node and the entity in the neighborhood information, the more relevant the attributes are to a certain extent, the closer the distance (i.e., relationship), and the greater the influence that the node can exert on the entity. Therefore, the association coefficient between the entity and each final neighboring node with the same relationship is determined according to the Pearson correlation coefficient; the smaller the association coefficient, the greater the influence of the neighboring node. However, for large knowledge graphs, the number of neighboring nodes is large and the computational efficiency is very low. Therefore, it is necessary to determine the association coefficient threshold corresponding to the association coefficient. When the association coefficient is less than or equal to the association coefficient threshold, the final neighboring nodes with the same relationship corresponding to the association coefficient are aggregated, and the weight corresponding to each final neighboring node with the same relationship is obtained. By setting the threshold, the situation where a large resultant force may be formed in a certain direction due to the large number of neighboring nodes is avoided, and a large amount of calculation is avoided, thereby achieving efficient neighborhood aggregation.
[0099] Furthermore, determining the entity representation of the entity based on the neighborhood information includes:
[0100] Calculating an entity representation vector of the entity based on the neighborhood information according to the weight;
[0101] The entity representation vector and the entity are fused using a gate mechanism to obtain an entity representation of the entity.
[0102] Furthermore, calculating the entity representation vector of the entity based on the neighborhood information according to the weight includes:
[0103] The entity represents the vector e e,r for:
[0104]
[0105] Where M r′ Represents the projection matrix of the final neighboring nodes of the same relationship, N e (ξ e ) represents a subset of the neighbor node set of the entity, including ξ neighbor nodes;
[0106] The entity representation e″ of the entity is:
[0107]
[0108] Where ge represents the entity representation vector and the entity gating vector, Represents vector element-wise multiplication.
[0109] From the above description, it can be seen that the entity representation vector of the entity based on the neighborhood information is calculated according to the weight, and the entity representation vector and the entity are fused using the gate mechanism to obtain the entity representation of the entity, thereby effectively realizing the fusion of domain information and entities.
[0110] Furthermore, the determining the entity representation of the entity based on the neighborhood information includes:
[0111] Defining a scoring function and a loss function corresponding to the entity representation;
[0112] The scoring function and the loss function are optimized using stochastic gradient descent.
[0113] From the above description, we can see that defining the scoring function and loss function corresponding to the entity representation and using the stochastic gradient descent method to optimize the scoring function and loss function can ensure better training results to obtain the optimal model, thereby accurately utilizing neighborhood information.
[0114] Please refer to Figure 2 Another embodiment of the present invention provides a knowledge graph embedding device based on neighborhood information, comprising:
[0115] A data acquisition module is used to acquire a knowledge graph, wherein the knowledge graph includes entities, relationships corresponding to the entities, and neighboring nodes;
[0116] A domain information determination module is configured to determine, based on the entity, the relationship, and the neighboring nodes, neighboring nodes of the same relationship and neighboring nodes of different relationships corresponding to the entity, and determine neighborhood information based on the neighboring nodes of the same relationship and neighboring nodes of different relationships;
[0117] An entity representation determination module is configured to determine an entity representation of the entity based on the neighborhood information.
[0118] From the above description, it can be seen that the beneficial effects of the present invention are: based on entities, relationships and neighboring nodes, the neighboring nodes of the same relationship and the neighboring nodes of different relationships corresponding to the entity are determined, and the neighborhood information is determined based on the neighboring nodes of the same relationship and the neighboring nodes of different relationships. The entity representation of the entity is determined based on the neighborhood information. Regardless of whether the entity is associated with more or fewer triples, the most relevant attributes on the corresponding neighboring nodes can be selected as the neighborhood information of the entity according to the neighboring edge relationship, which effectively utilizes the neighborhood information of the triples, provides more semantic information for the entity, improves the knowledge representation performance, and thus improves the ability of knowledge reasoning and fusion.
[0119] Furthermore, the domain information determination module includes:
[0120] A calculation module, configured to calculate the Pearson correlation coefficient between the entity and each of the neighboring nodes;
[0121] A neighbor node determination module, configured to determine neighbor nodes of the same relationship and neighbor nodes of different relationships corresponding to the entity;
[0122] A sorting module, configured to sort the neighboring nodes with the same relationship in a preset order according to the Pearson correlation coefficient to obtain sorted neighboring nodes with the same relationship;
[0123] a selection module, configured to determine a ratio of the neighboring nodes with the same relationship to the neighboring nodes with different relationships, and select final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the ratio;
[0124] The domain aggregation module is used to perform neighborhood aggregation based on the final neighboring nodes with the same relationship to obtain neighborhood information.
[0125] Furthermore, the calculation module for calculating the Pearson correlation coefficient between the entity and each of the neighboring nodes includes:
[0126]
[0127] Wherein, pcc(e,e′) represents the Pearson correlation coefficient, e represents the entity, e′ represents the neighboring node, σ e represents the standard deviation of the entity, σ e′ Represents the standard deviation of the neighboring nodes.
[0128] From the above description, it can be seen that in the neighborhood structure of an entity, the greater the degree of association between the neighboring nodes and the entity and the closer the distance, the greater the influence of the neighboring nodes on the entity and the greater the proportion of information aggregation. The Pearson (PCC) correlation coefficient can be used as an important indicator to measure the correlation of neighboring nodes. The neighboring nodes with the same relationship are sorted in a preset order according to the Pearson correlation coefficient to obtain the sorted neighboring nodes with the same relationship, and the ratio of neighboring nodes with the same relationship to neighboring nodes with different relationships is determined. The final neighboring nodes with the same relationship are selected from the sorted neighboring nodes according to the ratio, and neighborhood aggregation is performed based on the final neighboring nodes with the same relationship to obtain neighborhood information. In this way, the selection of neighboring nodes with the same relationship and different relationships in the domain structure of the entity is accurately and effectively realized.
[0129] Furthermore, the selection module is further used to:
[0130] determining the number of nodes according to the ratio;
[0131] Selecting final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the number of nodes;
[0132] The number of nodes d′ is:
[0133]
[0134] Where, Represents the same relationship r a The number of neighboring nodes under Represents r a The number of neighbor nodes under different relationships, [] represents the rounding function.
[0135] From the above description, it can be seen that determining the number of nodes according to the proportion and selecting the final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the number of nodes can avoid invisibly increasing the proportion of attributes corresponding to the same relationship during the information aggregation process and suppressing other neighborhood information attributes, thereby improving the richness and enrichment of neighborhood information.
[0136] Furthermore, the domain aggregation module is further used to:
[0137] Determining a correlation coefficient between the entity and each of the final neighboring nodes having the same relationship according to the Pearson correlation coefficient;
[0138] determining a correlation coefficient threshold corresponding to the correlation coefficient;
[0139] It is determined whether the association coefficient is less than or equal to the association coefficient threshold; if so, the final neighboring nodes with the same relationship corresponding to the association coefficient are aggregated, and the weight corresponding to each of the final neighboring nodes with the same relationship is obtained.
[0140] Furthermore, the domain aggregation module is further configured to determine, based on the Pearson correlation coefficient, a correlation coefficient between the entity and each of the final neighboring nodes having the same relationship, including:
[0141]
[0142] Where, Re i represents the correlation coefficient, r i Represents the relationship between the entity and the i-th final neighbor node with the same relationship;
[0143]
[0144] In the formula, R′e represents the association coefficient threshold, n represents the number of neighboring nodes with the same relationship, N e Indicates the number of triples associated with the entity, N * It represents the maximum number of associated triples in the entity, and δ represents the margin coefficient;
[0145] The weight a i for:
[0146]
[0147] Where a i represents the weight.
[0148] From the above description, it can be seen that neighborhood aggregation selects the most relevant attributes of neighboring nodes as neighborhood information. Intuitively, the larger the Pearson correlation coefficient between the neighboring node and the entity in the neighborhood information, the more relevant the attributes are to a certain extent, the closer the distance (i.e., relationship), and the greater the influence that the node can exert on the entity. Therefore, the association coefficient between the entity and each final neighboring node with the same relationship is determined according to the Pearson correlation coefficient; the smaller the association coefficient, the greater the influence of the neighboring node. However, for large knowledge graphs, the number of neighboring nodes is large and the computational efficiency is very low. Therefore, it is necessary to determine the association coefficient threshold corresponding to the association coefficient. When the association coefficient is less than or equal to the association coefficient threshold, the final neighboring nodes with the same relationship corresponding to the association coefficient are aggregated, and the weight corresponding to each final neighboring node with the same relationship is obtained. By setting the threshold, the situation where a large resultant force may be formed in a certain direction due to the large number of neighboring nodes is avoided, and a large amount of calculation is avoided, thereby achieving efficient neighborhood aggregation.
[0149] Furthermore, the entity representation determination module is further configured to:
[0150] Calculating an entity representation vector of the entity based on the neighborhood information according to the weight;
[0151] The entity representation vector and the entity are fused using a gate mechanism to obtain an entity representation of the entity.
[0152] Furthermore, the entity representation determination module is further configured to calculate, according to the weight, an entity representation vector of the entity based on the neighborhood information, including:
[0153]
[0154] Where, e e,r represents the entity representation vector, M r′ Represents the projection matrix of the final neighboring nodes of the same relationship, N e (ξ e ) represents a subset of the neighbor node set of the entity, including ξ neighbor nodes;
[0155]
[0156] Wherein, e″ represents the entity representation of the entity, ge represents the entity representation vector and the gating vector of the entity, Represents vector element-wise multiplication.
[0157] From the above description, it can be seen that the entity representation vector of the entity based on the neighborhood information is calculated according to the weight, and the entity representation vector and the entity are fused using the gate mechanism to obtain the entity representation of the entity, thereby effectively realizing the fusion of domain information and entities.
[0158] Furthermore, it also includes:
[0159] A function definition module, used to define a scoring function and a loss function corresponding to the entity representation;
[0160] An optimization module is used to optimize the scoring function and the loss function using a stochastic gradient descent method.
[0161] From the above description, we can see that defining the scoring function and loss function corresponding to the entity representation and using the stochastic gradient descent method to optimize the scoring function and loss function can ensure better training results to obtain the optimal model, thereby accurately utilizing neighborhood information.
[0162] Device
[0163] The above-mentioned knowledge graph embedding method and device based on neighborhood information of the present invention can be applied to scenarios where the number and structure of neighbors need to be balanced, especially to the knowledge graph of station equipment. The following is an explanation through specific implementation methods:
[0164] Example 1
[0165] Please refer to Figure 1 、 Figure 3 and Figure 4 , a knowledge graph embedding method based on neighborhood information in this embodiment includes the steps of:
[0166] S0. Define common symbols for knowledge graphs;
[0167] Specifically, E represents the entity set, R represents the relationship set, G represents the knowledge graph, the knowledge graph contains the correct triples (h, r, t), and G′ represents the set of incorrect triples, where h, t∈E, r∈R; r -1 Indicates the inverse relationship, R -1 Represents the inverse relation set, which is defined as R -1 ={r -1 |r∈R}; K represents the knowledge graph containing the inverse relationship, which is defined as K={(h, r, t), (t, r -1 ,h)|(h,r,t)∈G},N e Represents the set of neighboring nodes of entity e, defined as N e ={(e′, r′)|r′∈R∪R -1 , (e′, r′, e)∈K}, where e′ represents the neighboring node of entity e, and r′ represents the neighboring edge relationship corresponding to entity e, referred to as relationship;
[0168] S1. Obtain a knowledge graph, where the knowledge graph includes entities, relationships corresponding to the entities, and neighboring nodes;
[0169] S2. Determining neighboring nodes with the same relationship and neighboring nodes with different relationships corresponding to the entity based on the entity, the relationship, and the neighboring nodes, and determining neighborhood information based on the neighboring nodes with the same relationship and the neighboring nodes with different relationships, specifically including:
[0170] Neighbor nodes should be effectively selected according to the neighborhood structure of the entity. Because an entity is a combination of multiple attributes, when it acts as a neighbor node of different entities through different relationships, the attribute information provided should be different. The model should select the most relevant attributes of the neighbor node as the neighborhood information based on the neighbor relationship of the entity. Intuitively speaking, the entity with more associated triples has richer neighborhood information, and the influence of a single neighborhood information will be reduced. Therefore, it will rely more on the neighborhood structure and select the neighborhood information that has a greater impact on it. Entities with fewer associated triples have a greater scarcity of neighborhood information, resulting in a single neighborhood information having a greater impact on them. They will rely more on the neighborhood information provided by their neighbor nodes. The model should flexibly adjust the selection of the entity's neighbor nodes to balance the above two types of information to obtain more valuable semantic representations.
[0171] Generally speaking, when we talk about the correlation between two variables, we are referring, in some sense, to their relationship; correlated variables are variables that contain information about each other; the stronger the correlation between two variables, the more information one variable tells us about the other;
[0172] In the neighborhood structure of an entity, the greater the degree of association between a neighboring node and the entity and the closer the distance, the greater its influence on the entity and the greater its weight in aggregating information. The Pearson correlation coefficient (PCC) is a widely used measure of linear correlation. Therefore, the Pearson correlation coefficient can be used as an important indicator to measure the weight of neighboring nodes.
[0173] S21. Calculate the Pearson correlation coefficient between the entity and each of the neighboring nodes;
[0174] Wherein, the Pearson correlation coefficient pcc(e,e′) is:
[0175]
[0176] In the formula, e represents the entity, e′ represents the neighboring node, σ e represents the standard deviation of the entity, σ e′ represents the standard deviation of the neighboring nodes;
[0177] S22. Determine neighboring nodes with the same relationship and neighboring nodes with different relationships corresponding to the entity;
[0178] like Figure 3 As shown in Figure 2, it can be seen that the knowledge graph has heterogeneity, that is, some entities are associated with a lot of triples, while some entities are associated with very few triples. Figure 3 It can be seen that entity e2 is associated with 8 triples, namely r0, r2, r3, r4, r4, r5, r7 and r8, among which two neighboring nodes e5 and e9 are associated with each other through the same relationship r4. The situation of entity e1 is similar.
[0179] Therefore, we can consider whether we can aggregate and filter neighboring nodes with the same relationship to simplify the neighborhood structure of nodes with a large number of associated triples. This can reduce the amount of computation and improve the model speed for large knowledge graphs.
[0180] S23, sorting the neighboring nodes with the same relationship in a preset order according to the Pearson correlation coefficient to obtain sorted neighboring nodes with the same relationship;
[0181] Wherein, the preset order is from largest to smallest;
[0182] S24: Determine the ratio of the neighboring nodes with the same relationship to the neighboring nodes with different relationships, and select final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the ratio, specifically including:
[0183] S241. Determine the number of nodes according to the ratio;
[0184] S242. Selecting final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the number of nodes;
[0185] like Figure 4 As shown, Figure 4 It is the neighborhood structure corresponding to a certain entity in the knowledge graph; Figure 4 The entity "Fuzhou" is associated with the three neighboring nodes "Fujian", "Southeast Coast of China" and "China" through the relationship "affiliation". Since they have the same neighboring edge relationship, it can be inferred that "Fujian", "Southeast Coast of China" and "China" have similar attributes in this relationship; compared with other relationship information associated with this entity, the relationship "affiliation" appears repeatedly, which will invisibly increase the proportion of the attributes corresponding to this relationship during the information aggregation process, causing the suppression of the attributes of other neighboring information, and to a certain extent reducing the richness and enrichment of the neighborhood information; therefore, the neighboring nodes under the same relationship can be sorted from large to small according to the Pearson correlation coefficient, and the number of nodes with the same relationship to be selected can be determined according to the ratio of different relationships to the same relationship, and the final neighboring nodes with the same relationship can be selected from the sorted neighboring nodes with the same relationship according to the number of nodes;
[0186] Wherein, the number of nodes d′ is:
[0187]
[0188] Where, Represents the same relationship r a The number of neighboring nodes under Represents r a The number of neighbor nodes under different relationships, [] represents the rounding function;
[0189] The more different relationships there are, the richer the central node information is, and the fewer nodes with the same relationship are selected. The core idea of this model is based on TransE. The distance between neighboring nodes with the same relationship is very close, and the difference between them is very small compared to neighboring nodes with different relationships. This is improved.
[0190] S25. Perform neighborhood aggregation based on the final neighboring nodes with the same relationship to obtain neighborhood information, specifically including:
[0191] Neighborhood aggregation selects the most relevant attributes of neighboring nodes as neighborhood information. Intuitively, the larger the Pearson correlation coefficient between the neighboring node and the entity in the neighborhood information, the more relevant the attributes are to a certain extent. The closer the distance (i.e., the relationship), the greater the influence that the neighboring node can exert on the entity.
[0192] S251. Determine, based on the Pearson correlation coefficient, a correlation coefficient between the entity and each of the final neighboring nodes having the same relationship.
[0193] Among them, the correlation coefficient Re i for:
[0194]
[0195] Where r i Represents the relationship between the entity and the i-th final neighbor node with the same relationship;
[0196] R ei The smaller it is, the greater the influence of the neighboring nodes. However, for large knowledge graphs, there are many neighboring nodes, and there may be many different relationship nodes that are far away. If all are aggregated without setting a threshold, although the weights of these different relationship nodes are small and very different from the central node, they may form a large combined force in a certain direction due to their large number. In addition, the amount of calculation is large and the operation efficiency is very low. Therefore, the correlation coefficient threshold R′e is also determined;
[0197] S252, determining a correlation coefficient threshold corresponding to the correlation coefficient;
[0198] The correlation coefficient threshold R′e is:
[0199]
[0200] In the formula, n represents the number of neighboring nodes with the same relationship, N e Indicates the number of triples associated with the entity, N * It represents the maximum number of associated triples in the entity, and δ represents the margin coefficient;
[0201] S253: Determine whether the association coefficient is less than or equal to the association coefficient threshold; if so, aggregate the final neighboring nodes with the same relationship corresponding to the association coefficient, and obtain a weight corresponding to each of the final neighboring nodes with the same relationship;
[0202] The weight a i for:
[0203]
[0204] S3. Determining an entity representation of the entity based on the neighborhood information, specifically comprising:
[0205] S31, calculating an entity representation vector of the entity based on the neighborhood information according to the weight;
[0206] Wherein, the entity represents the vector e e,r for:
[0207]
[0208] Where M r′ Represents the projection matrix of the final neighboring nodes of the same relationship, N e (ξ e ) represents a subset of the neighbor node set of the entity, including ξ neighbor nodes;
[0209] S32. Using a gate mechanism, fuse the entity representation vector and the entity to obtain an entity representation of the entity;
[0210] Wherein, the entity representation e″ of the entity is:
[0211]
[0212] Where ge represents the entity representation vector and the entity gating vector, Represents vector element-wise multiplication;
[0213] Take entity e as the subject, and entity representation vector e e,r As a supplement to the entity attributes, each dimension of ge is constrained to be between [0.5, 1], which can be constructed using the Tanh function, that is,
[0214] S4. Define a scoring function and a loss function corresponding to the entity representation;
[0215] Wherein, the scoring function f r (h,r,t) is:
[0216]
[0217] Where (h, r, t) represents the correct triple, h represents the head entity, t represents the tail entity, r represents the relationship between the head entity and the tail entity, h″ represents the head entity after neighborhood aggregation, and t″ represents the tail entity after neighborhood aggregation;
[0218] The loss function L is:
[0219]
[0220] Where G represents the knowledge graph, G′ represents the set of error triples, γ represents the boundary parameter, h′ represents the head entity of the error triple set, and t′ represents the tail entity of the error triple set;
[0221] Constraints ||h||2≤1,||r||2≤1,||t||2≤1,||h″||2≤1,||t||2≤1;
[0222] S5. Optimizing the scoring function and the loss function using stochastic gradient descent method;
[0223] The present invention adopts the "bern" strategy in TransH to reduce the probability of generating false erroneous triples. A probability value is set for each relationship according to the relationship category, and the head entity or tail entity of the triple corresponding to the relationship is replaced according to the value; for one-to-many relationships, the head entity is replaced with a higher probability; for many-to-one relationships, the tail entity is replaced with a higher probability; for all triples under the same relationship, the average number of tail entities corresponding to each head entity, tph, and the average number of head entities corresponding to each tail entity, hpt, are obtained respectively. Select p = tph / (tph+hpt) for Bernoulli sampling; in the process of constructing negative triples, replace the head entity h with the probability value p, and replace the tail entity t with the probability value 1-p; when tph < 1.5 and hpt < 1.5, it is considered to be a one-to-one relationship; when tph > 1.5 and hpt > 1.5, it is considered to be a many-to-many relationship; if tph ≥ 1.5 and hpt < 1.5, it is considered to be a one-to-many relationship; if tph < 1.5 and hpt ≥ 1.5, it is considered to be a many-to-one relationship;
[0224] When training the model, the Stochastic Gradient Descent method is used to optimize the aforementioned objective functions, namely the scoring function and the loss function. Multiple random traversals are performed on the triples in the knowledge graph. When a correct triple is accessed, a negative triple is generated simultaneously. After a mini-batch, the gradient and model parameters are automatically updated. To accelerate convergence and avoid overfitting, the model uses the training results of TransE to initialize entity and relationship vectors. After training is completed, the model can obtain the most appropriate neighborhood information for an input entity e.
[0225] The present invention takes into account the use of neighborhood information around the station equipment triples, and can effectively use the neighborhood information to assist in modeling the triples based on the station equipment, providing more semantic information for the entity, improving the knowledge representation performance, and thus improving the ability of knowledge reasoning and fusion.
[0226] Example 2
[0227] Please refer to Figure 2 , a knowledge graph embedding device based on neighborhood information in this embodiment includes:
[0228] A data acquisition module is used to acquire a knowledge graph, wherein the knowledge graph includes entities, relationships corresponding to the entities, and neighboring nodes;
[0229] A domain information determination module is configured to determine, based on the entity, the relationship, and the neighboring nodes, neighboring nodes of the same relationship and neighboring nodes of different relationships corresponding to the entity, and determine neighborhood information based on the neighboring nodes of the same relationship and neighboring nodes of different relationships;
[0230] an entity representation determining module, configured to determine an entity representation of the entity based on the neighborhood information;
[0231] In some embodiments, the domain information determination module includes:
[0232] A calculation module, configured to calculate the Pearson correlation coefficient between the entity and each of the neighboring nodes;
[0233] A neighbor node determination module, configured to determine neighbor nodes of the same relationship and neighbor nodes of different relationships corresponding to the entity;
[0234] A sorting module, configured to sort the neighboring nodes with the same relationship in a preset order according to the Pearson correlation coefficient to obtain sorted neighboring nodes with the same relationship;
[0235] a selection module, configured to determine a ratio of the neighboring nodes with the same relationship to the neighboring nodes with different relationships, and select final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the ratio;
[0236] A domain aggregation module is used to perform neighborhood aggregation based on the final neighboring nodes with the same relationship to obtain neighborhood information;
[0237] In some embodiments, the calculation module for calculating the Pearson correlation coefficient between the entity and each of the neighboring nodes includes:
[0238]
[0239] Wherein, pcc(e,e′) represents the Pearson correlation coefficient, e represents the entity, e′ represents the neighboring node, σ e represents the standard deviation of the entity, σ e′ represents the standard deviation of the neighboring nodes;
[0240] In some embodiments, the selection module is further configured to:
[0241] determining the number of nodes according to the ratio;
[0242] Selecting final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the number of nodes;
[0243] The number of nodes d′ is:
[0244]
[0245] Where, Represents the same relationship r a The number of neighboring nodes under Represents r a The number of neighbor nodes under different relationships, [] represents the rounding function;
[0246] In some embodiments, the domain aggregation module is further configured to:
[0247] Determining a correlation coefficient between the entity and each of the final neighboring nodes having the same relationship according to the Pearson correlation coefficient;
[0248] determining a correlation coefficient threshold corresponding to the correlation coefficient;
[0249] Determine whether the association coefficient is less than or equal to the association coefficient threshold; if so, aggregate the final neighboring nodes with the same relationship corresponding to the association coefficient, and obtain a weight corresponding to each of the final neighboring nodes with the same relationship;
[0250] In some embodiments, the domain aggregation module is further configured to determine, based on the Pearson correlation coefficient, a correlation coefficient between the entity and each of the final neighboring nodes having the same relationship, including:
[0251]
[0252] Where, Re i represents the correlation coefficient, r i Represents the relationship between the entity and the i-th final neighbor node with the same relationship;
[0253]
[0254] In the formula, R′e represents the association coefficient threshold, n represents the number of neighboring nodes with the same relationship, N e Indicates the number of triples associated with the entity, N * It represents the maximum number of associated triples in the entity, and δ represents the margin coefficient;
[0255] The weight a i for:
[0256]
[0257] Where a i represents the weight;
[0258] In some embodiments, the entity representation determination module is further configured to:
[0259] Calculating an entity representation vector of the entity based on the neighborhood information according to the weight;
[0260] fusing the entity representation vector and the entity using a gate mechanism to obtain an entity representation of the entity;
[0261] In some embodiments, the entity representation determination module is further configured to calculate, according to the weight, an entity representation vector of the entity based on the neighborhood information, including:
[0262]
[0263] Where, e e,r represents the entity representation vector, M r′ Represents the projection matrix of the final neighboring nodes of the same relationship, N e (ξ e ) represents a subset of the neighbor node set of the entity, including ξ neighbor nodes;
[0264]
[0265] Wherein, e″ represents the entity representation of the entity, ge represents the entity representation vector and the gating vector of the entity, Represents vector element-wise multiplication;
[0266] In some embodiments, it further includes:
[0267] A function definition module, used to define a scoring function and a loss function corresponding to the entity representation;
[0268] An optimization module is used to optimize the scoring function and the loss function using a stochastic gradient descent method.
[0269] In summary, the present invention provides a knowledge graph embedding method and device based on neighborhood information, which obtains a knowledge graph, wherein the knowledge graph includes entities, relationships corresponding to the entities, and neighboring nodes; calculates the Pearson correlation coefficient between the entity and each of the neighboring nodes; determines the neighboring nodes of the same relationship and the neighboring nodes of different relationships corresponding to the entity; sorts the neighboring nodes of the same relationship in a preset order according to the Pearson correlation coefficient to obtain the sorted neighboring nodes of the same relationship; determines the ratio of the neighboring nodes of the same relationship to the neighboring nodes of different relationships, and selects the best neighboring nodes from the sorted neighboring nodes of the same relationship according to the ratio. The final neighboring nodes with the same relationship are obtained; neighborhood aggregation is performed on the final neighboring nodes with the same relationship to obtain neighborhood information, and the Pearson correlation coefficient is introduced to accurately and effectively realize the selection of neighboring nodes with the same relationship and different relationships in the domain structure of the entity; the entity representation of the entity is determined based on the neighborhood information, no matter whether the entity is associated with more or fewer triples, the most relevant attributes on the corresponding neighboring nodes can be selected as the neighborhood information of the entity according to the neighboring edge relationship, which effectively utilizes the neighborhood information of the triples, provides more semantic information for the entity, improves the knowledge representation performance, and thus improves the ability of knowledge reasoning and fusion.
[0270] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code. The scheme in the embodiments of the present application can be implemented in various computer languages, for example, object-oriented programming language Java and directly interpreted scripting language JavaScript, etc.
[0271] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0272] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0273] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0274] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0275] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A knowledge graph embedding method based on neighborhood information, characterized in that: Includes steps: Obtain a knowledge graph, wherein the knowledge graph includes entities, relationships corresponding to the entities, and neighboring nodes; Determine neighboring nodes with the same relationship and neighboring nodes with different relationships corresponding to the entity based on the entity, the relationship and the neighboring nodes, and determine neighborhood information according to the neighboring nodes with the same relationship and the neighboring nodes with different relationships; determining an entity representation of the entity based on the neighborhood information; The determining, based on the entity, the relationship and the neighboring nodes, the neighboring nodes of the same relationship and the neighboring nodes of different relationships corresponding to the entity comprises: Calculating the Pearson correlation coefficient between the entity and each of the neighboring nodes; Determine neighboring nodes of the same relationship and neighboring nodes of different relationships corresponding to the entity; Sorting the neighboring nodes with the same relationship in a preset order according to the Pearson correlation coefficient to obtain sorted neighboring nodes with the same relationship; Determine the ratio of the neighboring nodes with the same relationship to the neighboring nodes with different relationships, and select the final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the ratio; The determining of neighborhood information according to the neighboring nodes of the same relationship and the neighboring nodes of different relationships includes: Performing neighborhood aggregation according to the final neighboring nodes with the same relationship to obtain neighborhood information; The selecting the final neighboring nodes of the same relationship from the sorted neighboring nodes of the same relationship according to the proportion comprises: determining the number of nodes according to the ratio; Selecting final neighboring nodes of the same relationship from the sorted neighboring nodes of the same relationship according to the number of nodes; The number of nodes is: ; In the formula, Indicates the number of nodes, Indicates the same relationship The number of neighboring nodes under Representation and The number of neighbor nodes under different relationships, [ ] represents the rounding function; The performing neighborhood aggregation according to the final neighboring nodes of the same relationship to obtain neighborhood information includes: Determine, according to the Pearson correlation coefficient, a correlation coefficient between the entity and each of the final neighboring nodes of the same relationship; determining a correlation coefficient threshold value corresponding to the correlation coefficient; Determine whether the association coefficient is less than or equal to the association coefficient threshold, and if so, aggregate the final neighboring nodes with the same relationship corresponding to the association coefficient, and obtain the weight corresponding to each of the final neighboring nodes with the same relationship; The determining of the correlation coefficient between the entity and each of the final neighboring nodes of the same relationship according to the Pearson correlation coefficient includes: The correlation coefficient is: ; In the formula, Re i represents the correlation coefficient, r i Represents the relationship between the entity and the i-th final neighbor node with the same relationship; The correlation coefficient threshold is: ; In the formula, represents the association coefficient threshold, n represents the number of neighboring nodes with the same relationship, N e Represents the number of triples associated with the entity, N * Indicates the maximum number of associated triples in the entity. represents the margin factor; The weights are: ; In the formula, a i Represents weight.
2. According to the knowledge graph embedding method based on neighborhood information according to claim 1, it is characterized in that: The calculating of the Pearson correlation coefficient between the entity and each of the neighboring nodes comprises: The Pearson correlation coefficient is: ; In the formula, represents the Pearson correlation coefficient, e represents the entity, represents neighboring nodes, represents the standard deviation of the entity, Represents the standard deviation of the neighboring nodes.
3. According to the knowledge graph embedding method based on neighborhood information in claim 1, it is characterized in that: The determining the entity representation of the entity based on the neighborhood information comprises: Calculate an entity representation vector of the entity based on the neighborhood information according to the weight; The entity representation vector and the entity are fused using a gate mechanism to obtain an entity representation of the entity.
4. A knowledge graph embedding method based on neighborhood information according to claim 3, characterized in that: The calculating, according to the weight, the entity representation vector of the entity based on the neighborhood information comprises: The entity representation vector is: ; In the formula, represents the entity representation vector, Represents the projection matrix of the final neighboring nodes of the same relationship, Represents a subset of the neighbor node set of the entity, including neighbor nodes; The entity representation of the entity is: ,ge R n ; In the formula, represents the entity representation of the entity, ge represents the entity representation vector and the gating vector of the entity, Represents vector element-wise multiplication.
5. The knowledge graph embedding method based on neighborhood information according to claim 1, characterized in that: The determining of the entity representation of the entity based on the neighborhood information then comprises: Define a scoring function and a loss function corresponding to the entity representation; The scoring function and the loss function are optimized using stochastic gradient descent.
6. A knowledge graph embedding device based on neighborhood information, characterized in that: include: A data acquisition module, used to acquire a knowledge graph, wherein the knowledge graph includes entities, relationships corresponding to the entities, and neighboring nodes; A domain information determination module, configured to determine neighboring nodes of the same relationship and neighboring nodes of different relationships corresponding to the entity based on the entity, the relationship and the neighboring nodes, and determine neighborhood information according to the neighboring nodes of the same relationship and the neighboring nodes of different relationships; An entity representation determination module, configured to determine an entity representation of the entity based on the neighborhood information; The determining, based on the entity, the relationship and the neighboring nodes, the neighboring nodes of the same relationship and the neighboring nodes of different relationships corresponding to the entity comprises: Calculating the Pearson correlation coefficient between the entity and each of the neighboring nodes; Determine neighboring nodes of the same relationship and neighboring nodes of different relationships corresponding to the entity; Sorting the neighboring nodes with the same relationship in a preset order according to the Pearson correlation coefficient to obtain sorted neighboring nodes with the same relationship; Determine the ratio of the neighboring nodes with the same relationship to the neighboring nodes with different relationships, and select the final neighboring nodes with the same relationship from the sorted neighboring nodes with the same relationship according to the ratio; The determining of neighborhood information according to the neighboring nodes of the same relationship and the neighboring nodes of different relationships includes: Performing neighborhood aggregation according to the final neighboring nodes with the same relationship to obtain neighborhood information; The selecting the final neighboring nodes of the same relationship from the sorted neighboring nodes of the same relationship according to the proportion comprises: determining the number of nodes according to the ratio; Selecting final neighboring nodes of the same relationship from the sorted neighboring nodes of the same relationship according to the number of nodes; The number of nodes is: ; In the formula, Indicates the number of nodes, Indicates the same relationship The number of neighboring nodes under Representation and The number of neighbor nodes under different relationships, [ ] represents the rounding function; The performing neighborhood aggregation according to the final neighboring nodes of the same relationship to obtain neighborhood information includes: Determine, according to the Pearson correlation coefficient, a correlation coefficient between the entity and each of the final neighboring nodes of the same relationship; determining a correlation coefficient threshold value corresponding to the correlation coefficient; Determine whether the association coefficient is less than or equal to the association coefficient threshold, and if so, aggregate the final neighboring nodes with the same relationship corresponding to the association coefficient, and obtain the weight corresponding to each of the final neighboring nodes with the same relationship; The determining of the correlation coefficient between the entity and each of the final neighboring nodes of the same relationship according to the Pearson correlation coefficient includes: The correlation coefficient is: ; In the formula, Re i represents the correlation coefficient, r i Represents the relationship between the entity and the i-th final neighbor node with the same relationship; The correlation coefficient threshold is: ; In the formula, represents the association coefficient threshold, n represents the number of neighboring nodes with the same relationship, N e Represents the number of triples associated with the entity, N * Indicates the maximum number of associated triples in the entity. represents the margin factor; The weights are: ; In the formula, a i Represents weight.
Citation Information
Patent Citations
Multi-level knowledge graph construction method and system for field of chemical engineering
CN111694966A
Knowledge graph joint representation learning method fusing graph convolution and translation model
CN113254663A