Knowledge graph representation learning method and device, and medium

By using preset stripping algorithm, graph attention network and clustering algorithm in knowledge graph representation learning, the shared feature vector is determined and nonlinear changes are performed, the problem of excessive parameter quantity in traditional methods is solved, and more efficient knowledge graph representation learning is achieved.

CN119622000AActive Publication Date: 2025-03-14SHENZHEN WHALE VISION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510153141.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-12
Publication Date
2025-03-14
Estimated Expiration
2045-02-12

AI Technical Summary

Technical Problem

Traditional knowledge graph representation learning methods are inefficient when processing large-scale knowledge graphs, making it difficult to perform complex reasoning, and the amount of parameters is proportional to the number of entities, resulting in excessive parameter volume.

Method used

The preset stripping algorithm is used to determine the core entity from the entity, and the initial feature vector is determined based on the distance between the entity and the core entity. The graph attention network is used to aggregate neighbor information, and the shared feature correlation is determined through the clustering algorithm, and the shared feature correlation degree is nonlinear to obtain the target feature vector.

Benefits of technology

The decoupling of the parameter quantity and the number of entities is realized, which significantly reduces the amount of parameters learned by the knowledge graph representation, and avoids the problem of excessive parameters caused by the individual definition of the representation vector for each entity in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119622000A_ABST
    Figure CN119622000A_ABST
Patent Text Reader

Abstract

The invention provides a knowledge graph representation learning method and device and a medium, and relates to the technical field of network information processing, the method comprises the following steps: obtaining a knowledge graph, the knowledge graph comprising N entities and relationships among the entities; determining M core entities from the N entities by adopting a preset stripping algorithm; determining an initial feature vector corresponding to each entity according to the distance between each entity and each core entity; aggregating neighbor information by adopting a graph attention network, and determining an aggregated feature vector corresponding to each entity; clustering the aggregated feature vectors, and determining each clustering center as a shared feature vector; determining the shared feature association degree of each aggregation feature vector according to the distance between each aggregation feature vector and each shared feature vector; and performing nonlinear change on each shared feature association degree to obtain a target feature vector corresponding to each entity. According to the method, decoupling of the parameter quantity and the entity quantity is realized, and the parameter quantity of knowledge graph representation learning is remarkably reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network information processing technology, and in particular to a knowledge graph representation learning method, device and medium. Background Art

[0002] At present, with the explosive growth of data volume, the scale of knowledge graphs continues to expand. Traditional knowledge graph representation learning methods face problems such as low efficiency and difficulty in complex reasoning when processing large-scale knowledge graphs. Although the existing lightweight knowledge graph representation learning methods have reduced parameters to a certain extent, they still cannot solve the problem that the parameters are proportional to the number of entities, resulting in the number of parameters being too high when facing large-scale knowledge graphs. Summary of the invention

[0003] In view of this, the purpose of the present invention is to overcome the deficiencies in the prior art and provide a knowledge graph representation learning method, device and medium. The present invention provides the following technical solutions: In a first aspect, the present invention provides a knowledge graph representation learning method, the method comprising: Obtain a knowledge graph, wherein the knowledge graph includes N entities and relationships between the entities; Determine M core entities from the N entities using a preset stripping algorithm, where M<N; Determine the initial feature vector corresponding to each of the entities according to the distance between each of the entities and each of the core entities; For the initial feature vector corresponding to the i-th entity, the graph attention network is used to aggregate the neighbor information to obtain the aggregated feature vector corresponding to the i-th entity, where 1≤i≤N; Using a preset clustering algorithm to divide each of the aggregated feature vectors into a plurality of clusters, and determining the cluster centers of each of the clusters as shared feature vectors; Determining the shared feature correlation of each of the aggregated feature vectors according to the distance between each of the aggregated feature vectors and each of the shared feature vectors; Nonlinear changes are performed on the correlation degrees of the shared features to obtain target feature vectors corresponding to the entities.

[0004] In one embodiment, the preset stripping algorithm is used to determine M core entities from the N entities, including: looping through each of the entities, and adding the entities that meet the preset conditions to the preset entity list in sequence according to the traversal order; and determining the last M entities in the preset entity list as core entities.

[0005] In one embodiment, the initial feature vector corresponding to each entity is determined based on the distance between each entity and each core entity, including: for the ith entity, determining the distance from the ith entity to each core entity respectively; and determining the initial feature vector corresponding to the ith entity based on the distance from the ith entity to each core entity respectively.

[0006] In one embodiment, for the initial feature vector corresponding to the i-th entity, aggregating neighbor information using a graph attention network to obtain an aggregated feature vector corresponding to the i-th entity includes: Determine a plurality of entities directly connected to the i-th entity as neighbor entities of the i-th entity; The attention weight of the i-th entity to each of the neighboring entities is determined respectively, and the calculation formula is:

[0007]

[0008] According to each of the attention weights, the aggregate feature vector corresponding to the i-th entity is determined, and the formula is:

[0009] in, Represents the relationship between the i-th entity and its neighbor entity The attention weight, represents the i-th entity, Indicates said neighbor entities, represents the relationship between the i-th entity and the neighbor entity, represents the set of neighbor entities, and are different trainable mapping matrices, It is a transformation vector related to the connection relationship, which is used to map the relationship between entities into the vector space of the preset relationship. represents the initial feature vector corresponding to the i-th entity, represents the initial feature vector corresponding to the neighbor entity e, Represents the aggregated feature vector corresponding to the i-th entity.

[0010] In one embodiment, the preset clustering algorithm is used to divide each of the aggregated feature vectors into multiple clusters, and the clustering loss function is:

[0011] in, Representing Entities to the shared feature vector distance, minpool represents the minimum pooling operation, V represents the entity set, and L represents the shared feature vector set.

[0012] In one embodiment, determining the shared feature association degree of each aggregated feature vector based on the distance between each aggregated feature vector and each shared feature vector includes: determining the distance from the aggregated feature vector to each shared feature vector respectively, and determining the minimum distance among the distances as the shared feature association degree of the aggregated feature vector.

[0013] In one embodiment, the non-linearly changing the correlation degrees of each of the shared features respectively includes: using a multi-layer perceptron to non-linearly change the correlation degrees of each of the shared features respectively.

[0014] In one embodiment, the knowledge graph further includes a positive triple set, the positive triple set includes a plurality of positive samples, and the method further includes: Based on the positive triplet set, construct a plurality of negative samples by random negative sampling, each of the negative samples constituting a negative triplet set; A ternary loss function is determined according to each of the positive samples in the positive triplet set and each of the negative samples in the negative triplet set, and the calculation formula is:

[0015]

[0016]

[0017] Among them, S represents the ternary loss function, Represents a positive sample of loss, Represents negative samples of loss, represents the set of positive triples, represents the negative triple set, represents the hyperparameter of the edge ranking loss, Represents a positive sample The head entity, Represents a positive sample relationship, Represents a positive sample The tail entity, Represents negative samples The head entity, Represents negative samples relationship, Represents negative samples The tail entity, Represents a positive sample The shared feature correlation of the head entity, Represents a positive sample The shared feature association of the tail entity, Represents negative samples The shared feature correlation of the head entity, Represents negative samples The shared feature association degree of the tail entity.

[0018] In a second aspect, the present invention provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program runs on the processor, the knowledge graph representation learning method described in the first aspect is executed.

[0019] In a third aspect, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, represents the knowledge graph learning method described in the first aspect.

[0020] The knowledge graph representation learning method, device and medium provided in the embodiments of the present application include: obtaining a knowledge graph, wherein the knowledge graph includes N entities and the relationship between each of the entities; using a preset stripping algorithm to determine M core entities from the N entities, wherein M<N; determining an initial feature vector corresponding to each of the entities according to the distance between each of the entities and each of the core entities; for the initial feature vector corresponding to the i-th entity, using a graph attention network to aggregate neighbor information to obtain an aggregated feature vector corresponding to the i-th entity, wherein 1≤i≤N; using a preset clustering algorithm to divide each of the aggregated feature vectors into multiple clusters, and determining the clustering centers of each of the clusters as shared feature vectors; determining the shared feature correlation of each of the aggregated feature vectors according to the distance between each of the aggregated feature vectors and each of the shared feature vectors; performing nonlinear changes on each of the shared feature correlations to obtain target feature vectors corresponding to each of the entities. This application achieves the decoupling of parameter quantity and entity quantity by constructing shared feature vectors between entities and representing each entity in the knowledge graph based on the shared feature vectors, significantly reducing the parameter quantity of knowledge graph representation learning and avoiding the problem of excessive parameters caused by separately defining representation vectors for each entity in traditional methods.

[0021] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and understandable, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0023] Figure 1 A schematic diagram of a process of a knowledge graph representation learning method provided in an embodiment of the present application is shown; Figure 2 Another schematic diagram of the process of the knowledge graph representation learning method provided by an embodiment of the present application is shown; Figure 3 Another schematic diagram of the process of the knowledge graph representation learning method provided in the embodiment of the present application is shown; Figure 4 Another schematic diagram of the process of the knowledge graph representation learning method provided in the embodiment of the present application is shown; Figure 5 Another schematic diagram of the process of the knowledge graph representation learning method provided in the embodiment of the present application is shown; Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown.

[0024] Description of main component symbols: 600 - electronic device; 601 - transceiver; 602 - processor; 603 - memory. DETAILED DESCRIPTION

[0025] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.

[0026] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of the template are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0028] Example 1 As a structured knowledge representation method, knowledge graph organizes entities and the relationships between entities in the form of a graph, where nodes represent entities and edges represent the relationships between entities. Traditional knowledge graph representation methods have problems such as low efficiency and difficulty in complex reasoning when dealing with large-scale knowledge graphs. As a result, knowledge graph representation learning came into being. Knowledge graph representation learning aims to map entities and relationships in knowledge graphs to status vector spaces to facilitate efficient storage, retrieval, and reasoning of data. Existing knowledge graph representation learning usually assigns one or more vector representations to each entity and relationship in the knowledge graph. In some cases, additional complex parameters are even required to describe specific relationship types or entity interaction methods. As the scale of knowledge graphs expands, existing knowledge graph representation learning faces the problem of too many parameters. For this, please refer to Figure 1 , this application proposes a lightweight knowledge graph representation learning method based on shared features, including steps S110~S170.

[0029] Step S110, obtaining a knowledge graph, wherein the knowledge graph includes N entities and the relationship between the entities.

[0030] Entities are the basic units in the knowledge graph and can be any object with independent existence, such as names of people, places, organizations, concepts, time, etc. Relationships are the semantic links between two entities and are used to describe the semantic associations between entities. Entities and the relationships between them constitute the knowledge graph.

[0031] In this embodiment, the knowledge graph is defined as ,in, Represents the N entities included in the knowledge graph, Represents the relationship between entities. Represents all triples. It should be noted that triples are the smallest semantic units in the knowledge graph, which are used to represent complete semantic facts in the knowledge graph. Triples are usually defined as ,in Represents the head entity, Represents the relationship between two entities. Represents the tail entity.

[0032] It can be understood that the goal of traditional knowledge graph representation learning is to learn vector representations for entities and relations based on triple information, that is, ,in, is the dimension of the vector, which can effectively reflect the structural information of the knowledge graph. Therefore, the number of parameters represented by the traditional knowledge graph is , and the number of entities Into a linear relationship.

[0033] In this embodiment, in order to decouple the number of parameters from the number of entities in the knowledge graph, a lightweight representation method based on shared features is adopted to represent entities as a combination of shared features, thereby avoiding the traditional method of defining a representation vector for each entity separately. See below for details.

[0034] Step S120: using a preset stripping algorithm to determine M core entities from the N entities, where M<N.

[0035] It should be noted that in traditional knowledge graph representation learning, the way to represent entity uniqueness is entity indexing, but the index cannot well reflect the structural characteristics of the entity in the knowledge graph.

[0036] In this embodiment, entity position identification is used to identify the uniqueness of an entity. Specifically, a preset stripping algorithm, such as the K-shell algorithm, is used to select core entities with important position structures from all entities in the knowledge graph, and then the uniqueness of each entity is characterized according to the distance between each entity and each core entity.

[0037] In one embodiment, see Figure 2 , step S120, includes steps S121~S122.

[0038] Step S121, looping through the entities, and adding the entities that meet the preset conditions to the preset entity list in sequence according to the traversal order.

[0039] Specifically, a preset entity list is defined, and it can be understood that the preset entity list is an empty list. Each entity in the knowledge graph is traversed in a loop, and in each loop, entities with a degree of 1 are added to the preset entity list in the order of traversal. This process continues to guide all entities with a degree of 1 in the knowledge graph.

[0040] Step S122: determine the last M entities in the preset entity list as core entities respectively.

[0041] It can be understood that the multiple entities included in the preset entity list obtained after the traversal are arranged in order of position structure importance from low to high, and the later the entity is, the more complex the connection structure it has. The last M entities in the position list are selected as core entities, and the uniqueness of the more entities is further characterized based on the distance between each entity and the core entity.

[0042] Step S130: determining an initial feature vector corresponding to each of the entities according to the distance between each of the entities and each of the core entities.

[0043] In this embodiment, the initial feature vector is a set of fixed low-dimensional vectors ,in, Indicates the corresponding entity to It can be understood that the distance between each entity and each core entity can not only effectively distinguish different entities, but also provide the location characteristics of the entity in the knowledge graph to a certain extent.

[0044] In one embodiment, see Figure 3 , step S130 includes steps S131~S132.

[0045] S131 : for the ith entity, determine the distances from the ith entity to each of the core entities.

[0046] Taking each core entity as a reference point, the shortest path distance from the ith entity to each core entity is calculated.

[0047] S132: Determine an initial feature vector corresponding to the ith entity according to the distances from the ith entity to each of the core entities.

[0048] For example, the knowledge graph includes the core entities: , and , the distances from the i-th entity to each core entity are: , , , then the initial feature vector corresponding to the i-th entity is: .

[0049] Step S140, for the initial feature vector corresponding to the i-th entity, a graph attention network is used to aggregate neighbor information to obtain an aggregated feature vector corresponding to the i-th entity, where 1≤i≤N.

[0050] In this embodiment, after the initial feature vector of the entity is obtained, the graph attention network is further used to aggregate the entity's neighbor information according to the entity's connection in the knowledge graph to enrich the entity's structural information.

[0051] In one embodiment, see Figure 4 , step S140 includes steps S141~S143.

[0052] S141, determining a plurality of entities directly connected to the i-th entity as neighboring entities of the i-th entity.

[0053] In this embodiment, represents the set of neighbor entities of the i-th entity, where e represents the neighbor entity.

[0054] S142, respectively determine the attention weight of the i-th entity to each of the neighboring entities, and the calculation formula is:

[0055]

[0056] in, Represents the relationship between the i-th entity and its neighbor entity The attention weight, represents the i-th entity, Indicates said neighbor entities, represents the relationship between the i-th entity and the neighbor entity, represents the set of neighbor entities, and are different trainable mapping matrices, It is a transformation vector related to the connection relationship, which is used to map the relationship between entities into the vector space of the preset relationship. represents the initial feature vector corresponding to the i-th entity, represents the initial feature vector corresponding to the neighbor entity e, Represents the aggregated feature vector corresponding to the i-th entity.

[0057] Understandably, is the attention score of the neighbor entity e, which is used to measure the importance of the neighbor entity to the central entity, that is, the i-th entity. The attention weight confirmation method provided in this application takes into account the relationship type between entities, so that the attention mechanism can better capture the semantic information in the heterogeneous graph.

[0058] S143, determining the aggregate feature vector corresponding to the i-th entity according to each of the attention weights, the formula is:

[0059] By aggregating neighbor information, we can obtain the aggregated feature vectors corresponding to each entity, and then characterize each entity with richer information.

[0060] Step S150: using a preset clustering algorithm to divide each of the aggregated feature vectors into a plurality of clusters, and determining the cluster center of each of the clusters as a shared feature vector.

[0061] In this embodiment, based on the aggregated feature vectors corresponding to all entities, a neural network-based clustering method is used to discover at least one shared feature vector. Specifically, it includes: clustering the aggregated feature vectors into multiple clusters, and determining the centers of each cluster as shared feature vectors. The clustering loss function is:

[0062] in, Representing Entities to the shared feature vector distance, minipool represents the minimum pooling operation, V represents the entity set, and L represents the shared feature vector set.

[0063] It should be noted that the number of clusters can be selected according to data characteristics, computational costs and application scenarios, such as the elbow method, silhouette coefficient, interval statistics or neural network-based methods, without specific restrictions.

[0064] Step S160: determining the shared feature association degree of each of the aggregated feature vectors according to the distance between each of the aggregated feature vectors and each of the shared feature vectors.

[0065] In this embodiment, a multilayer perceptron (MLP) is used to calculate the distances from each aggregated feature vector to each shared feature vector, and the shared feature relevance of each entity is further determined based on the calculated distances. .

[0066] In one embodiment, determining the shared feature association degree of each aggregated feature vector based on the distance between each aggregated feature vector and each shared feature vector includes: determining the distance from the aggregated feature vector to each shared feature vector respectively, and determining the minimum distance among the distances as the shared feature association degree of the aggregated feature vector.

[0067] It can be understood that, taking one of the entities as an example, the distance between the aggregated feature vector corresponding to the entity and each shared feature vector is calculated, and the shortest length distance is determined as the correlation between the entity and the shared feature vector, that is, the shared feature correlation. The shared feature correlation is a vector.

[0068] Step S170, performing nonlinear changes on the correlation degrees of the shared features respectively to obtain target feature vectors corresponding to the entities respectively.

[0069] In this embodiment, after obtaining the shared feature association degrees corresponding to each entity, each shared feature association degree is further nonlinearly transformed and mapped to the final representation vector, that is, the target feature vector, and the calculation formula is: ,in, Represents a multilayer perceptron.

[0070] In one embodiment, the non-linearly changing the correlation degrees of each of the shared features respectively includes: using a multi-layer perceptron to non-linearly change the correlation degrees of each of the shared features respectively.

[0071] The shared feature correlation corresponding to each entity is nonlinearly changed to further optimize the vector representation of each entity, so that the final target feature vector of each entity can better capture complex semantic information.

[0072] In one embodiment, the knowledge graph further includes a set of positive triples, wherein the set of triples includes a plurality of positive samples, see Figure 5 , the method also includes: steps S510~S520.

[0073] S510 , constructing a plurality of negative samples through random negative sampling based on the positive triplet set, each of the negative samples constituting a negative triplet set.

[0074] In this embodiment, the positive triplet set includes multiple original triples, namely, positive samples. Based on the positive samples in the original triplet, multiple negative samples are constructed by random negative sampling. ,in, , , They are , , Head entities, relations, and tail entities after random replacement.

[0075] S520, determining a ternary loss function according to each of the positive samples in the positive triplet set and each of the negative samples in the negative triplet set, wherein the calculation formula is:

[0076]

[0077]

[0078] Among them, S represents the ternary loss function, Represents a positive sample of loss, Represents negative samples of loss, represents the set of positive triples, represents the negative triple set, represents the hyperparameter of the edge ranking loss, Represents a positive sample The head entity, Represents a positive sample relationship, Represents a positive sample The tail entity, Represents negative samples The head entity, Represents negative samples relationship, Represents negative samples The tail entity, Represents a positive sample The shared feature correlation of the head entity, Represents a positive sample The shared feature association of the tail entity, Represents negative samples The shared feature correlation of the head entity, Represents negative samples The shared feature association degree of the tail entity.

[0079] Furthermore, the target loss function can be determined based on the ternary loss function and the clustering loss function. Specifically, the target loss function is equal to the sum of the ternary function and the clustering loss function. The core purpose of the target loss function is to measure the difference between the predicted value and the true value, and adjust the parameters by optimizing this difference, thereby improving the learning performance.

[0080] In order to verify the effect of the knowledge graph representation learning method proposed in this application in lightweight knowledge graph representation learning, the industry-standard WN18RR and FB15K237 datasets are used for verification. The verification indicators are MRR (Mean Reciprocal Rank) and Hits@10 of connection prediction. MRR is obtained by calculating the average of the sum of the reciprocals of the rankings of all query results, and Hits@10 checks whether the correct answer is in the top 10 positions of these candidate answers. Please see Table 1 below for the experimental results. According to the experimental results, the method proposed in the present invention has higher accuracy in connection prediction tasks than many existing latest lightweight learning methods, including methods based on knowledge distillation (DualDE), word-based (LightKG) and based on transfer to convolution (LN-TransE), indicating the excellent characteristics of shared features.

[0081] Table 1

[0082] At the same time, the method proposed in the present invention requires fewer parameters in these two data sets, which greatly improves the applicability of knowledge graph representation learning. Specifically, the parameter comparison results are shown in Table 2 below.

[0083] Table 2

[0084] The knowledge graph representation learning method provided in the embodiment of the present application includes: obtaining a knowledge graph, wherein the knowledge graph includes N entities and the relationship between each of the entities; using a preset stripping algorithm to determine M core entities from the N entities, wherein M<N; determining an initial feature vector corresponding to each of the entities based on the distance between each of the entities and each of the core entities; for the initial feature vector corresponding to the i-th entity, using a graph attention network to aggregate neighbor information to obtain an aggregated feature vector corresponding to the i-th entity, wherein 1≤i≤N; using a preset clustering algorithm to divide each of the aggregated feature vectors into multiple clusters, and determining the clustering centers of each of the clusters as shared feature vectors; determining the shared feature correlation of each of the aggregated feature vectors based on the distance between each of the aggregated feature vectors and each of the shared feature vectors; performing nonlinear changes on each of the shared feature correlations to obtain target feature vectors corresponding to each of the entities. This application achieves the decoupling of parameter quantity and entity quantity by constructing shared feature vectors between entities and representing each entity in the knowledge graph based on the shared feature vectors, thereby significantly reducing the parameter quantity of knowledge graph representation learning and avoiding the problem of excessive parameters caused by separately defining representation vectors for each entity in traditional methods.

[0085] Example 2 In addition, an embodiment of the present invention provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program runs on the processor, it executes the knowledge graph representation learning method provided in Example 1.

[0086] For details, see Figure 6The electronic device 600 includes: a transceiver 601, a bus interface and a processor 602, wherein the processor 602 is used to obtain a knowledge graph, wherein the knowledge graph includes N entities and the relationship between each of the entities; a preset stripping algorithm is used to determine M core entities from the N entities, wherein M<N; an initial feature vector corresponding to each of the entities is determined according to the distance between each of the entities and each of the core entities; for the initial feature vector corresponding to the i-th entity, a graph attention network is used to aggregate neighbor information to obtain an aggregated feature vector corresponding to the i-th entity, wherein 1≤i≤N; a preset clustering algorithm is used to divide each of the aggregated feature vectors into multiple clusters, and the clustering centers of each of the clusters are respectively determined as shared feature vectors; a shared feature correlation degree of each of the aggregated feature vectors is determined according to the distance between each of the aggregated feature vectors and each of the shared feature vectors; each of the shared feature correlation degrees is subjected to nonlinear changes to obtain a target feature vector corresponding to each of the entities.

[0087] In one embodiment, the preset stripping algorithm is used to determine M core entities from the N entities, including: looping through each of the entities, and adding the entities that meet the preset conditions to the preset entity list in sequence according to the traversal order; and determining the last M entities in the preset entity list as core entities.

[0088] In one embodiment, the initial feature vector corresponding to each entity is determined based on the distance between each entity and each core entity, including: for the ith entity, determining the distance from the ith entity to each core entity respectively; and determining the initial feature vector corresponding to the ith entity based on the distance from the ith entity to each core entity respectively.

[0089] In one embodiment, for the initial feature vector corresponding to the i-th entity, aggregating neighbor information using a graph attention network to obtain an aggregated feature vector corresponding to the i-th entity includes: Determine a plurality of entities directly connected to the i-th entity as neighbor entities of the i-th entity; The attention weight of the i-th entity to each of the neighboring entities is determined respectively, and the calculation formula is:

[0090]

[0091] According to each of the attention weights, the aggregate feature vector corresponding to the i-th entity is determined, and the formula is:

[0092] in, Represents the relationship between the i-th entity and its neighbor entity The attention weight, represents the i-th entity, Indicates said neighbor entities, represents the relationship between the i-th entity and the neighbor entity, represents the set of neighbor entities, and are different trainable mapping matrices, It is a transformation vector related to the connection relationship, which is used to map the relationship between entities into the vector space of the preset relationship. represents the initial feature vector corresponding to the i-th entity, represents the initial feature vector corresponding to the neighbor entity e, Represents the aggregated feature vector corresponding to the i-th entity.

[0093] In one embodiment, the preset clustering algorithm is used to divide each of the aggregated feature vectors into multiple clusters, and the clustering loss function is:

[0094] in, Representing Entities to the shared feature vector distance, minpool represents the minimum pooling operation, V represents the entity set, and L represents the shared feature vector set.

[0095] In one embodiment, determining the shared feature association degree of each aggregated feature vector based on the distance between each aggregated feature vector and each shared feature vector includes: determining the distance from the aggregated feature vector to each shared feature vector respectively, and determining the minimum distance among the distances as the shared feature association degree of the aggregated feature vector.

[0096] In one embodiment, the non-linearly changing the correlation degrees of each of the shared features respectively includes: using a multi-layer perceptron to non-linearly change the correlation degrees of each of the shared features respectively.

[0097] In one embodiment, the knowledge graph further includes a positive triple set, the positive triple set includes a plurality of positive samples, and the method further includes: Based on the positive triplet set, construct a plurality of negative samples by random negative sampling, each of the negative samples constituting a negative triplet set; A ternary loss function is determined according to each of the positive samples in the positive triplet set and each of the negative samples in the negative triplet set, and the calculation formula is:

[0098]

[0099]

[0100] Among them, S represents the ternary loss function, Represents a positive sample of loss, Represents negative samples of loss, represents the set of positive triples, represents the negative triple set, represents the hyperparameter of the edge ranking loss, Represents a positive sample The head entity, Represents a positive sample relationship, Represents a positive sample The tail entity, Represents negative samples The head entity, Represents negative samples relationship, Represents negative samples The tail entity, Represents a positive sample The shared feature correlation of the head entity, Represents a positive sample The shared feature association of the tail entity, Represents negative samples The shared feature correlation of the head entity, Represents negative samples The shared feature association degree of the tail entity.

[0101] In the embodiment of the present invention, the electronic device 600 further includes a memory 603. Figure 6 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically linking various circuits of one or more processors represented by processor 602 and memory represented by memory 603. The bus architecture may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The transceiver 601 may be a plurality of components, i.e., including a transmitter and a receiver, providing a unit for communicating with various other devices on a transmission medium. The processor 602 is responsible for managing the bus architecture and general processing, and the memory 603 may store data used by the processor 602 when performing operations.

[0102] The electronic device 600 provided in this embodiment of the present invention can execute the knowledge graph representation learning method provided in the above method embodiment 1, which will not be described again here to avoid repetition.

[0103] Example 3 In addition, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the knowledge graph representation learning method provided in Example 1 is implemented.

[0104] In this embodiment, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0105] The computer-readable storage medium provided in this embodiment can implement the knowledge graph representation learning method provided in Example 1. To avoid repetition, it will not be repeated here.

[0106] In all examples shown and described herein, any specific values ​​should be interpreted as merely exemplary and not as limiting, and thus other examples of the exemplary embodiments may have different values.

[0107] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0108] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.

Claims

1. A knowledge graph representation learning method, characterized in that: The method comprises: Obtain a knowledge graph, wherein the knowledge graph includes N entities and relationships between the entities; Determine M core entities from the N entities using a preset stripping algorithm, where M<N; Determine the initial feature vector corresponding to each of the entities according to the distance between each of the entities and each of the core entities; For the initial feature vector corresponding to the i-th entity, the graph attention network is used to aggregate the neighbor information to obtain the aggregated feature vector corresponding to the i-th entity, where 1≤i≤N; Using a preset clustering algorithm to divide each of the aggregated feature vectors into a plurality of clusters, and determining the cluster centers of each of the clusters as shared feature vectors; Determining the shared feature correlation of each of the aggregated feature vectors according to the distance between each of the aggregated feature vectors and each of the shared feature vectors; Nonlinear changes are performed on the correlation degrees of the shared features to obtain target feature vectors corresponding to the entities.

2. The knowledge graph representation learning method according to claim 1, characterized in that: The adopting a preset stripping algorithm to determine M core entities from the N entities includes: Loop through the entities, and add the entities that meet the preset conditions to the preset entity list in sequence according to the traversal order; The last M entities in the preset entity list are respectively determined as core entities.

3. The knowledge graph representation learning method according to claim 1, characterized in that: The determining, according to the distance between each of the entities and each of the core entities, an initial feature vector corresponding to each of the entities comprises: For the i-th entity, determine the distances from the i-th entity to each of the core entities; An initial feature vector corresponding to the ith entity is determined according to the distances from the ith entity to each of the core entities.

4. The knowledge graph representation learning method according to claim 1, characterized in that: The initial feature vector corresponding to the i-th entity is obtained by aggregating neighbor information using a graph attention network to obtain an aggregated feature vector corresponding to the i-th entity, including: Determine a plurality of entities directly connected to the i-th entity as neighbor entities of the i-th entity; The attention weight of the i-th entity to each of the neighboring entities is determined respectively, and the calculation formula is: According to each of the attention weights, the aggregate feature vector corresponding to the i-th entity is determined, and the formula is: in, Represents the relationship between the i-th entity and its neighbor entity The attention weight, represents the i-th entity, Indicates said neighbor entities, represents the relationship between the i-th entity and the neighbor entity, represents the set of neighbor entities, and are different trainable mapping matrices, It is a transformation vector related to the connection relationship, which is used to map the relationship between entities into the vector space of the preset relationship. represents the initial feature vector corresponding to the i-th entity, represents the initial feature vector corresponding to the neighbor entity e, Represents the aggregated feature vector corresponding to the i-th entity.

5. The knowledge graph representation learning method according to claim 1, characterized in that: The preset clustering algorithm is used to divide each of the aggregated feature vectors into multiple clusters, and the clustering loss function is: in, Representing Entities to the shared feature vector distance, minpool represents the minimum pooling operation, V represents the entity set, and L represents the shared feature vector set.

6. The knowledge graph representation learning method according to claim 1, characterized in that: The determining, according to the distance between each of the aggregated feature vectors and each of the shared feature vectors, the shared feature correlation of each of the aggregated feature vectors comprises: The distances from the aggregated feature vector to each of the shared feature vectors are determined, and the minimum distance among the distances is determined as the shared feature association degree of the aggregated feature vector.

7. The knowledge graph representation learning method according to any one of claims 1 to 6, characterized in that: The non-linearly changing the correlation degree of each shared feature respectively includes: A multi-layer perceptron is used to perform nonlinear changes on the correlation degree of each shared feature.

8. The knowledge graph representation learning method according to claim 1, characterized in that: The knowledge graph further includes a positive triple set, the positive triple set includes a plurality of positive samples, and the method further includes: Based on the positive triplet set, construct a plurality of negative samples by random negative sampling, each of the negative samples constituting a negative triplet set; A ternary loss function is determined according to each of the positive samples in the positive triplet set and each of the negative samples in the negative triplet set, and the calculation formula is: Among them, S represents the ternary loss function, Represents a positive sample of loss, Represents negative samples of loss, represents the set of positive triples, represents the negative triple set, represents the hyperparameter of the edge ranking loss, Represents a positive sample The head entity, Represents a positive sample relationship, Represents a positive sample The tail entity, Represents negative samples The head entity, Represents negative samples relationship, Represents negative samples The tail entity, Represents a positive sample The shared feature correlation of the head entity, Represents a positive sample The shared feature association of the tail entity, Represents negative samples The shared feature correlation of the head entity, Represents negative samples The shared feature association degree of the tail entity.

9. An electronic device, characterized in that: It includes a memory and a processor, the memory stores a computer program, and when the computer program runs on the processor, it executes the knowledge graph representation learning method described in any one of claims 1-8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the knowledge graph representation learning method described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Knowledge graph entity alignment method and device

    CN114036307A

  • Log anomaly detection method and system based on knowledge graph semantic embedding

    CN118860714A

  • Method and device for text-enhanced knowledge graph joint representation learning

    US20220147836A1