Knowledge graph partitioning method, apparatus, device, and storage medium
By determining the semantic information and weights of nodes and edges in the knowledge graph and combining them with structural information for partitioning, the problem of real-time partitioning of newly added nodes in dynamic knowledge graphs is solved, thus improving processing efficiency.
Patent Information
- Application Number
- CN202211425870.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-14
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2042-11-14
AI Technical Summary
Existing knowledge graph partitioning algorithms cannot adapt to the real-time partitioning of newly added nodes in dynamic knowledge graphs, and fail to effectively utilize the semantic information of nodes and edges, resulting in low processing efficiency.
By determining node weights based on the semantic information of nodes and edges in the knowledge graph, and combining structural information for partitioning, the nodes to be partitioned are assigned to the target partitions using semantic similarity, thus achieving real-time partitioning of dynamic knowledge graphs.
It improves the efficiency of knowledge graph processing, can adapt to the division of newly added nodes in real time, and meets the needs of dynamic knowledge graphs.
Smart Images

Figure CN116775893B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for knowledge graph partitioning. Background Technology
[0002] With the rapid development of artificial intelligence (AI) in various fields, information and problems in different fields are becoming increasingly complex and the amount of data is enormous. A complete data model is needed to represent all resources, and knowledge graphs have emerged to meet this need.
[0003] Knowledge graphs, proposed by Google in 2012, are an extension of the graph G = (V, E), where V and E are sets of vertices and edges, representing entities and the relationships between them, respectively. Currently, knowledge graphs have reached the scale of millions of vertices and hundreds of millions of edges. RDF (Resource Description Framework) is the most widely used data type in knowledge graphs. It describes resources using triples (s, p, o), where s, p, and o represent subject, predicate, and object, respectively. For example, DBpedia (Wikipedia's knowledge graph) currently contains over 3 billion triples. Due to the rapid growth of RDF graph data, traditional single-machine data processing can no longer meet current demands, making distributed storage and processing of large-scale RDF graph data an inevitable choice. The main challenge in distributed storage and querying of RDF graph data is RDF graph partitioning, that is, dividing the RDF graph data into multiple subgraphs while meeting specific requirements, such as fewer crossed edges, high query efficiency, and low communication costs.
[0004] In related technologies, schemes for knowledge graph partitioning are mainly divided into two categories: one is based on distributed multi-level graph partitioning algorithms, and the other is based on local search and simulated annealing. However, nodes and edges in a knowledge graph are added over time. For example, in knowledge graphs applied to social networks, entities and the relationships between entities change. The above-mentioned schemes are not suitable for dynamic knowledge graphs and cannot partition newly added nodes in real time. Summary of the Invention
[0005] This disclosure provides a knowledge graph partitioning method, apparatus, device, and storage medium.
[0006] A first aspect of this disclosure provides a knowledge graph partitioning method, the method comprising:
[0007] The weights of the nodes in the knowledge graph are determined based on the semantic information of the nodes and the semantic information of the edges between the nodes.
[0008] The knowledge graph is partitioned based on the weights of the nodes and the structural information of the knowledge graph.
[0009] Based on the semantic similarity between the node to be partitioned in the knowledge graph and each partition of the knowledge graph, the node to be partitioned is assigned to the target partition.
[0010] In one embodiment, determining the weights of nodes in the knowledge graph based on the semantic information of the nodes and the semantic information of the edges between the nodes includes:
[0011] The initial weight of each edge is determined based on the semantic information of the edges in the knowledge graph.
[0012] The initial weight of each node is determined based on the semantic information of the nodes in the knowledge graph.
[0013] The weight of each node is determined based on the initial weight of each edge and the initial weight of each node.
[0014] In one embodiment, determining the initial weight of each edge based on the semantic information of the edges in the knowledge graph includes:
[0015] The first semantic hierarchy is determined based on the attribute information of the edges in the knowledge graph and the association between different edges;
[0016] Determine the weight of each edge in the first semantic hierarchy.
[0017] In one embodiment, determining the initial weight of each node based on the semantic information of the nodes in the knowledge graph includes:
[0018] The second semantic hierarchy is determined based on the attribute information of the nodes in the knowledge graph and the relationships between the nodes;
[0019] Determine the weight of each node in the second semantic hierarchy.
[0020] In one embodiment, determining the weight of each node based on the initial weight of each edge and the initial weight of each node includes:
[0021] For each of the nodes, perform the following operations:
[0022] When the set of outgoing edges of the node is not empty, the weight of the node is determined according to the initial weight of the node, the initial weight of the outgoing edges of the node, and the weight of the target node corresponding to the outgoing edge.
[0023] When the set of outgoing edges of a node is empty, the initial weight of the node is determined as the weight of the node.
[0024] In one embodiment, partitioning the knowledge graph according to the weights of nodes and the structural information of the knowledge graph includes:
[0025] Based on the preset number of partitions and the sorting of the nodes according to their weight from high to low, select multiple first nodes;
[0026] Using each of the first nodes as the starting nodes, and combining the structural information of the knowledge graph with the structural information of the preset query template, the knowledge graph is initialized and partitioned.
[0027] For each partition of the knowledge graph, when it is determined that there is a second node among the leaf nodes in the partition, the second node is repartitioned; wherein the semantic similarity between the second node and the partition is less than the similarity threshold.
[0028] In one embodiment, when it is determined that a second node exists among the leaf nodes of the knowledge graph in each partition, the repartitioning of the second node includes:
[0029] The semantic similarity between the leaf nodes in each partition and the partition where the leaf nodes are located is calculated in parallel by the slave nodes in the distributed system, and it is determined whether the second node exists among the leaf nodes in each partition.
[0030] When the master node in the distributed system receives the node information of the second node sent by the first slave node, it sends the node information of the second node to multiple second slave nodes in order to obtain the semantic similarity between the second node and the partitions stored by each second slave node.
[0031] The master node re-divides the second node based on the maximum value among multiple semantic similarities corresponding to the second node.
[0032] In one embodiment, classifying the node to be classified into a target partition based on the semantic similarity between the node to be classified in the knowledge graph and each partition of the knowledge graph includes:
[0033] Determine the maximum value of the semantic similarity between the node to be partitioned and each of the partitions;
[0034] The partition corresponding to the maximum value among the multiple semantic similarities is used as the target partition, and the node to be partitioned is assigned to the target partition.
[0035] In one embodiment, for any partition of the knowledge graph, the semantic similarity between a node in the knowledge graph and the partition is: the statistical value of the semantic similarity between the node and the nodes within the partition.
[0036] A second aspect of this disclosure provides a knowledge graph partitioning apparatus, the apparatus comprising:
[0037] The determination module is used to determine the weight of the nodes in the knowledge graph based on the semantic information of the nodes in the knowledge graph and the semantic information of the edges between the nodes;
[0038] The partitioning module is used to partition the knowledge graph into sections based on the weights of the nodes and the structural information of the knowledge graph.
[0039] The partitioning module is further configured to partition the node to be partitioned into a target partition based on the semantic similarity between the node to be partitioned in the knowledge graph and each partition of the knowledge graph.
[0040] A third aspect of this disclosure provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the knowledge graph partitioning method according to any one of the first aspects.
[0041] A fourth aspect of this disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the knowledge graph partitioning method described in any of the first aspects.
[0042] This disclosure provides a knowledge graph partitioning method, apparatus, device, and storage medium. By determining the weights of nodes in the knowledge graph based on the semantic information of the nodes and the semantic information of the edges between nodes, the weights of nodes in the knowledge graph can be varied across different domains when calculating node weights, taking into account the semantic information of both nodes and edges. Furthermore, by partitioning the knowledge graph according to the node weights and the knowledge graph's structural information, and assigning the node to be partitioned to a target partition based on the semantic similarity between the node to be partitioned and each partition of the knowledge graph, this method enables real-time partitioning of newly added nodes for dynamic knowledge graphs, improving processing efficiency. Attached Figure Description
[0043] Figure 1 A flowchart of a knowledge graph partitioning method provided in this embodiment of the disclosure;
[0044] Figure 2 A flowchart of a knowledge graph partitioning method provided in this embodiment of the disclosure;
[0045] Figure 3 A flowchart of a knowledge graph partitioning method provided in this embodiment of the disclosure;
[0046] Figure 4 A flowchart of a knowledge graph partitioning method provided in this embodiment of the disclosure;
[0047] Figure 5 This is a schematic diagram of a knowledge graph partitioning architecture provided in an embodiment of the present disclosure;
[0048] Figure 6 A flowchart of a knowledge graph partitioning method provided in this embodiment of the disclosure;
[0049] Figure 7 A structural diagram of a knowledge graph partitioning device provided in an embodiment of this disclosure;
[0050] Figure 8 This is a structural block diagram of a computer device provided in an embodiment of the present disclosure. Detailed Implementation
[0051] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this disclosure as detailed in the appended claims.
[0052] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the present disclosure. The singular forms “a,” “the,” and “the” as used in this disclosure and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0053] It should be understood that although the terms first, second, third, etc., may be used to describe various information in embodiments of this disclosure, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of embodiments of this disclosure, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0054] It is understood that the description of the various embodiments in this disclosure emphasizes the differences between the various embodiments, and the similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail.
[0055] In related technologies, knowledge graph partitioning schemes mainly involve parallelizing existing single-machine graph partitioning algorithms or proposing new algorithms directly within a distributed framework. Distributed graph partitioning algorithms are primarily divided into two categories: one is based on distributed multi-level graph partitioning algorithms, and the other is based on local search and simulated annealing.
[0056] A representative distributed multilevel graph partitioning algorithm is the KaPPa algorithm. This algorithm uses a matching algorithm in the coarsening stage, storing edge and node weights through an adjacency matrix and recording migrated vertices and associated edges through a hash table. Before performing local refinement, a breadth-first search algorithm is used to generate the vertex set corresponding to the boundary of each partition, and then these vertex sets are refined. The KaFFPa algorithm is proposed based on the KaPPa algorithm, extending the multilevel iterative algorithm. Its main contribution is performing multilevel iterations in the coarsening and de-coarsening stages. Once the graph is partitioned, the edges crossing different partitions do not shrink, thus ensuring partition quality. Traditional multilevel partitioning algorithms only perform coarsening and de-coarsening once, also known as the V-loop. KaFFPa uses two new global search methods: the F-loop and the W-loop.
[0057] A representative graph partitioning algorithm based on local search and simulated annealing is the JA-BE-JA distributed graph partitioning algorithm. This type of algorithm first randomly assigns a color to each node, where π_v represents the color of vertex v, and nodes with the same color belong to the same partition. N_v(c) represents the set of neighbors of node v with color c, and d_v represents the number of neighbors of node v, where d_v(c) = |N_v(c)| represents the number of neighbors with color c. The energy of the graph is defined as the number of edges between nodes with different colors. By searching for candidate nodes using adjacent nodes and the random node set, if swapping node colors reduces the energy of the graph, a swap is performed. The algorithm terminates when no vertices with swappable colors are found. Based on the JA-BE-JA-BE-JA-VC algorithm, its core idea is to modify vertex partitioning to edge partitioning. This algorithm randomly assigns all edges to different partitions, then defines an energy function for each edge and each partition, determines whether to swap edges based on the system energy, and then iteratively improves the initial partitioning by applying a local search algorithm.
[0058] However, the above methods ignore the semantic, structural, and attribute information contained in knowledge graphs.
[0059] The KaPPa graph partitioning algorithm introduces a distributed matching algorithm, which uses coarsening to transform large-scale graphs into smaller ones. Then, it partitions these smaller graphs using existing algorithms and finally transforms them back into the original graph through decoarsening. This type of algorithm requires pre-storing vertices and edges, and it doesn't consider the semantic information inherent in nodes and edges when calculating node and edge weights. When new nodes and edges are added, the graph needs to be repartitioned, making real-time partitioning of new nodes and edges impossible. Furthermore, during the iterative process of graph partitioning, the number of cut edges is chosen as the partitioning criterion. Considering the different edge weights in different domains, using the number of cut edges as the partitioning criterion is not suitable for RDF knowledge graph partitioning, meaning the final state of the partitioning algorithm differs.
[0060] Graph partitioning algorithms based on JA-BE-JA address the graph coloring problem. They are computationally simple, exhibit strong locality of reference, and can avoid local optima. However, their runtime gradually increases with the number of iterations, making them unsuitable for dynamic graphs like RDF knowledge graphs that grow larger over time. Furthermore, these algorithms primarily target undirected graphs and are not applicable to directed graphs such as RDF knowledge graphs. Additionally, different domains use different query structures, leading to variations in the semantic weights of nodes and edges.
[0061] Figure 1 A flowchart of a knowledge graph partitioning method provided in an embodiment of this disclosure is shown. Figure 1 As shown, this knowledge graph partitioning method may include the following steps:
[0062] 101. Determine the weights of nodes in the knowledge graph based on the semantic information of the nodes and the semantic information of the edges between the nodes.
[0063] 102. Based on the weights of the nodes in the knowledge graph and the structural information of the knowledge graph, the knowledge graph is partitioned.
[0064] 103. Based on the semantic similarity between the node to be partitioned in the knowledge graph and each partition of the knowledge graph, the node to be partitioned is assigned to the target partition.
[0065] The knowledge graph partitioning method provided in this disclosure can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities.
[0066] In this embodiment of the disclosure, the knowledge graph can be generated based on structured and / or unstructured data within a preset domain. The preset domain may include, but is not limited to, telecommunications, finance, healthcare, and / or insurance.
[0067] The knowledge graph can be an RDF graph. An RDF graph uses RDF triples to describe the relationships between entities, or the relationships between entity attribute values. Furthermore, the knowledge graph can also be other types of knowledge graphs, such as attribute graphs and directed label graphs.
[0068] Nodes in a knowledge graph represent entities. Edges in a knowledge graph have directions and are used to connect two nodes, representing relationships between entities or relationships between entity attribute values.
[0069] The semantic information of a node refers to the semantic features of its node information. Node information may include node attribute information and / or the relationships between nodes. Node attribute information may include node identifier, node name, node type, etc. A node identifier is an identifier that uniquely identifies a node in the knowledge graph. It can be a number assigned to the node according to a certain sorting rule. For example, the initial value can be set to v1, and the sequential numbering can be v1, v2, ..., etc.
[0070] The semantic information of an edge refers to the semantic features of its edge information. Edge information can include edge attribute information and / or edge relationships. Edge attribute information can include edge identifier, edge name, and edge type. An edge identifier is a unique identifier for an edge within the knowledge graph. It can be a number assigned to the edge according to a certain sorting rule; for example, the initial value can be set to e1, and sequential numbering can result in e1, e2, ..., etc.
[0071] Each node in a knowledge graph has a corresponding weight value, and the magnitude of the weight value of each node is used to reflect the weight relationship between the entities corresponding to each node.
[0072] Each edge in a knowledge graph has a corresponding weight value, and the magnitude of the weight value of each edge is used to reflect the weight relationship between the relationships corresponding to each edge.
[0073] In step 101 above, the initial weights of each node and each edge can be determined based on the semantic information of the nodes and the semantic information of the edges in the knowledge graph, and the weights of each node can be determined based on the initial weights of each edge and the initial weights of each node.
[0074] In this embodiment of the disclosure, the semantic information of nodes and edges in the RDF knowledge graph is taken into account when calculating the weight information of nodes, so that the weight of nodes in knowledge graphs of different domains can be different.
[0075] In step 102 above, the nodes in the knowledge graph can be sorted in descending order of their weights. The first K nodes in the sorted order are selected as the starting nodes. The knowledge graph is then partitioned by combining the structural information of the knowledge graph and the structural information of the preset query template, resulting in multiple non-overlapping partitions.
[0076] In step 103 above, for each node to be partitioned in the knowledge graph, the semantic similarity between the node to be partitioned and each partition of the knowledge graph can be determined, and the node to be partitioned can be assigned to the target partition corresponding to the largest semantic similarity based on the semantic similarity.
[0077] In some examples, the node to be partitioned can be a leaf node within any partition, and the semantic similarity between the leaf node and the partition to which the leaf node is located is less than the similarity threshold.
[0078] Here, a leaf node within a partition can be included in the set of nodes corresponding to the boundary of that partition.
[0079] In other examples, the nodes to be partitioned can be newly added nodes after the knowledge graph has been partitioned.
[0080] In some examples, for any partition of the knowledge graph, the semantic similarity between a node in the knowledge graph and that partition is: the statistical value of the semantic similarity between that node and the nodes within that partition.
[0081] Here, the statistical value of semantic similarity can be the average or median of semantic similarity, etc.
[0082] This disclosure provides a knowledge graph partitioning method. By determining the weights of nodes in the knowledge graph based on the semantic information of nodes and the semantic information of edges between nodes, it can reflect that the weights of nodes and edges differ in different domains, resulting in different partitioning results. This allows for the differentiation of semantic information of nodes and edges for different knowledge graphs. Furthermore, by partitioning the knowledge graph according to the weights of nodes and the structural information of the knowledge graph, and by assigning the node to be partitioned to the target partition based on the semantic similarity between the node to be partitioned and each partition of the knowledge graph, it can handle dynamic knowledge graphs and partition newly added nodes in real time, thereby improving processing efficiency.
[0083] In one embodiment, such as Figure 2 As shown, in step 101 above, the weights of nodes in the knowledge graph are determined based on the semantic information of the nodes and the semantic information of the edges between the nodes, including:
[0084] 201. Determine the initial weight of each edge based on the semantic information of the edges in the knowledge graph.
[0085] In some examples, the implementation of step 201 may include:
[0086] Based on the attribute information of the edges in the knowledge graph and the relationships between different edges, the first semantic hierarchy is determined; the weight of each edge in the first semantic hierarchy is determined.
[0087] Taking RDF knowledge graphs as an example, there exists a definition language called RDFS (RDFSchema, Resource Description Framework) to describe resources. This language includes a predicate called `rdfs:subPropertyOf`, which indicates an inheritance relationship between two relations. For example, the RDF triple `dbo:Champoi rdfs:subPropertyOf owl:hasParticipant` means that if someone is the champion of a sport, then it can be inferred that someone else is a participant in that sport. In other words, in an RDF knowledge graph, there is an inheritance relationship between edges, therefore the weights of edges cannot be uniformly initialized to the same weight.
[0088] In this embodiment, when dividing the knowledge graph, a tree-shaped first semantic hierarchy structure (i.e., the semantic hierarchy structure of the edges) can be formed based on the edges existing in the knowledge graph and the relationships between the edges. Then, the edges are initialized according to the weight of each edge in the first semantic hierarchy structure.
[0089] In this knowledge graph, all edges representing the same relationship correspond to the same edge in the first semantic hierarchy. For example, all edges in the knowledge graph representing the relationship between entities as "friends" correspond to the same edge in the first semantic hierarchy.
[0090] The determination of the weights of each edge in the first semantic hierarchy can include:
[0091] The initial weight of the current edge is determined based on the number of current edges, the total number of child nodes contained in the current edge in the first semantic hierarchy, and the total number of edges in the first semantic hierarchy.
[0092] The initial weight of the current edge can be: the ratio of the number of the current edge and the sum of the number of all child nodes contained in the current edge in the first semantic hierarchy to the total number of edges in the first semantic hierarchy.
[0093] For example, the initial weights of each edge can be calculated using the following formula:
[0094]
[0095] Where, ω(e i ) represents edge e i The initial weights, c(e) i ) represents edge e i The number of child nodes, |e i | represents the current number of edges, and c(E) represents the total number of edges in the semantic hierarchy of edges.
[0096] 202. Determine the initial weight of each node based on the semantic information of the nodes in the knowledge graph.
[0097] In some examples, the implementation of step 202 may include:
[0098] Based on the attribute information of the nodes in the knowledge graph and the relationships between the nodes, the second semantic hierarchy is determined; the weight of each node in the second semantic hierarchy is determined.
[0099] Taking RDF knowledge graphs as an example, there is a predicate called rdfs:subClassOf in RDFS, which is used to indicate that there is a certain inheritance relationship between two entities. For example, the RDF triple (dbo:SoftWare rdfs:subClassOf dbo:Work) means that if an event belongs to software engineering, then it can be inferred that the event belongs to a job. That is, in RDF knowledge graphs, there is also an inheritance relationship between entities, so the weight of a node cannot be uniformly initialized to 1 for calculation.
[0100] In this embodiment, when dividing the knowledge graph, the types of nodes existing in the current RDF knowledge graph and the relationships between nodes can be sorted out to form a tree-shaped second semantic hierarchy structure (i.e., the semantic hierarchy structure of nodes). Then, the nodes are initialized according to the weight of each node in the second semantic hierarchy structure.
[0101] In this knowledge graph, all nodes representing the same type correspond to the same node in the second semantic hierarchy. For example, all nodes representing the type "person" in the knowledge graph correspond to the same node in the second semantic hierarchy.
[0102] The determination of the weights of each node in the second semantic hierarchy can include:
[0103] The initial weight of the current node is determined based on the number of current nodes, the total number of child nodes contained in the current node in the second semantic hierarchy, and the total number of nodes in the second semantic hierarchy.
[0104] The initial weight of the current node can be the percentage of the sum of the number of the current node and the number of all child nodes contained in the current node relative to the total number of nodes in the second semantic hierarchy.
[0105] For example, the initial weights of each node can be calculated using the following formula (2):
[0106]
[0107] Where ω(v) i c(v) represents the initial weight of the node. i ) represents node v i The number of child nodes, |v i | represents the current number of nodes, and c(V) represents the total number of nodes in the semantic hierarchy of nodes.
[0108] 203. Determine the weight of each node based on the initial weight of each edge and the initial weight of each node.
[0109] In some examples, the following operations are performed for each node:
[0110] When the set of outgoing edges of a node is not empty, the weight of the node is determined based on the initial weight of the node, the initial weight of the outgoing edges of the node, and the weight of the target node corresponding to the outgoing edge; when the set of outgoing edges of a node is empty, the initial weight of the node is determined as the weight of the node.
[0111] In this embodiment, considering that in the RDF knowledge graph query process, a node is usually used as the starting point of the query and the outgoing edges are used as the direction of the query, the weight of the node can be determined based on the node's initial weight, the set of outgoing edges of the node, and the weight of the target node.
[0112] For example, the weight of a node can be calculated using the following formula (3):
[0113]
[0114] in, Let θ(v) represent the weight of node v, and let θ(v) represent the set of outgoing edges of node v. i ) represents edge e i The corresponding target node, Representing edge e i The weight of the target node. That is, the weight of node v is the initial weight of the node plus the normalized value obtained by combining the weights of the outgoing edges of node v and the weight of the target node. When the outgoing edge set of node v is empty, the weight of the node is the initial weight.
[0115] In this embodiment, during the weight calculation process of a node, nodes with empty outgoing edge sets can be selected first for weight assignment. Then, the weight of the node can be calculated based on the source node corresponding to the incoming edge of the node. If the weight of the target node corresponding to the outgoing edge of the calculated node is not assigned, the weight of the node can be calculated after the target node is assigned a weight.
[0116] In one embodiment, such as Figure 3 As shown, in step 102 above, the knowledge graph is partitioned according to the weights of the nodes and the structural information of the knowledge graph, including:
[0117] 301. Select multiple first nodes based on the preset number of partitions and the sorting of each node according to its weight from high to low.
[0118] Here, the preset number of partitions can be determined according to actual application needs. For example, the number of partitions can be set to 5, 6, or other suitable values.
[0119] In this embodiment, the first node can be selected based on the number of partitions and the weight of the top K nodes. Here, K is a positive integer greater than 1. For example, K can be equal to N times the number of partitions, where N is a positive integer greater than or equal to 1.
[0120] 302. Using each first node as the starting node, and combining the structural information of the knowledge graph with the structural information of the preset query template, the knowledge graph is initialized and partitioned.
[0121] The structural information of the query template may include, but is not limited to: chain structure and / or star structure.
[0122] In some examples, the first node can be used as the starting point. Based on the structure information of the preset query template, the outgoing edge structure corresponding to the first node can be searched from the knowledge graph. The knowledge graph can then be initialized and partitioned based on the search results.
[0123] In some examples, if the number of first nodes equals the number of partitions, then multiple first nodes correspond to the starting nodes of each partition. In other examples, if the number of first nodes is N times the number of partitions, then the number of first nodes serving as starting nodes is the same in each partition, and there are at least two first nodes serving as starting nodes in the same partition. Here, N is a positive integer greater than 1.
[0124] In some examples, when the number of nodes in the first node is N times the number of partitions, the difference between the sum of the weights of the first nodes in the nth partition and the sum of the weights of the first nodes in the (n-1)th partition is less than a preset threshold, where n is greater than 1 and less than or equal to the number of partitions, and N is a positive integer greater than 1.
[0125] Here, the preset threshold can be set according to the actual application needs. It is understandable that the smaller the preset threshold, the better the effect of initial partitioning of the knowledge graph.
[0126] In practical applications, when initializing partitions for a knowledge graph, the partitioning criterion can be minimizing the number of edges spanning the partition.
[0127] In this embodiment, by combining the structural information of the query template in the partitioning of the knowledge graph, the probability of cross-partition queries is reduced from the query level, thereby improving the efficiency of knowledge graph query processing.
[0128] 303. For each partition of the knowledge graph, when it is determined that there is a second node in the partition, the second node is repartitioned; wherein, the semantic similarity between the second node and the partition is less than the similarity threshold.
[0129] Here, the semantic similarity between the second node and the nth partition can be: the statistical value of the semantic similarity between the second node and the nodes in the nth partition. This statistical value can be the average or median of the semantic similarity between all nodes in the nth partition. Where n is a positive integer less than or equal to the number of partitions.
[0130] The similarity threshold can be determined based on expert experience or training with experimental data; no specific limit is set here.
[0131] In some examples, the semantic similarity can be one of the following:
[0132] Distance-based semantic similarity;
[0133] Attribute-based semantic similarity;
[0134] Based on adaptive weighted semantic similarity.
[0135] 1) Distance-based semantic similarity
[0136] Based on the semantic hierarchy of nodes, we can not only calculate the weight information of nodes in the semantic hierarchy, but also obtain the semantic similarity between sibling nodes based on the inheritance relationship between nodes.
[0137] Distance-based semantic similarity primarily calculates the semantic distance between two nodes by measuring the depth of nodes in the semantic hierarchy. That is, the similarity between two nodes is directly proportional to the depth of their nearest common ancestor and inversely proportional to their individual depths.
[0138] In some examples, distance-based semantic similarity can be calculated using the following formula (4):
[0139]
[0140] Where, σ D (v i ,v j ) is node v i ,v j Semantic similarity based on distance, NCA(v) i ,v j ) represents node v i ,v j In a semantic hierarchy graph, the furthest common ancestor of any two nodes is the root node, D. v This represents the path depth from the node to the root node. This represents the path depth from the nearest common ancestor to the root node. If the nearest common ancestor of two nodes is the root node, then their semantic similarity is 0.
[0141] 2) Attribute-based semantic similarity
[0142] In the RDFS resource description language, nodes typically have attributes, and these attributes, like nodes themselves, have inheritance relationships, i.e., a semantic hierarchy of edges. For example, child nodes usually inherit attributes from their parent nodes, while attributes of a parent node may not be possessed by a certain child node. The semantic similarity between nodes can be measured by the number of common attributes they share.
[0143] In some examples, attribute-based semantic similarity can be calculated using the following formula:
[0144]
[0145]
[0146] Where, σ P (v i ,v j ) is node v i ,v j The semantic similarity between nodes is based on attributes, where δ(v) represents the set of attributes possessed by node v, and α is the similarity based on node v. i ,v j The probability of depth calculation, δ(v) i )∩δ(v j ) represents node v i With node v j The set of attributes shared by all, δ(v) i ) / δ(v j ) represents node v i Owning node v j A set of attributes that do not exist.
[0147] 3) Adaptive weighted semantic similarity
[0148] Comprehensive semantic similarity algorithms in related technologies can improve the accuracy of similarity calculation to some extent. However, the weighting coefficients are usually determined by experts in the field, which involves a certain degree of subjectivity and uniqueness. They cannot be applied to semantic similarity calculation of RDF knowledge graphs in different fields. Furthermore, in the process of semantic similarity calculation, the actual structural information of the RDF knowledge graph is not taken into account. The above formulas (4) and (6) calculate the similarity at the semantic hierarchical structure level. In actual graph partitioning, the distance between nodes and the weight of the edges between nodes should be considered.
[0149] In some examples, adaptive weighted semantic similarity can be determined by weighted summation of distance-based semantic similarity and attribute-based semantic similarity, and then combining the weights of the edges between nodes with the weighted summation result.
[0150] In some examples, the formula for calculating semantic similarity based on adaptive weighting is shown below:
[0151]
[0152] Where, σ(v) i ,v j ) is node v i ,v j Based on adaptive weighted semantic similarity, λ(v) i ,v j ) indicates from node vi to v j The set of edges traversed, the size of the set is the sum of the edges traversed from v. i to v j The path length is given by β, and the weights of the edges between nodes are the average weights of the edges along the path. i ,v j Distance-based semantic similarity σ D (v i ,v j The weights corresponding to ) are γ, where γ is the weight of node v. i ,v j Attribute-based semantic similarity σ P (v i ,v j The weights corresponding to ) and β+γ=1.
[0153] In this embodiment, adaptive weighted semantic similarity calculation can be used in the re-partitioning stage, which can be applied to the semantic similarity calculation of knowledge graphs in different fields and improves the generalization ability.
[0154] It is worth noting that the partitioning of the knowledge graph requires multiple iterations. In this iteration, the partitioning information of each partition in this round is determined based on the partitioning results of the previous round, the structural information of the query template, and the structural information of the knowledge graph. For each partition in this round, when it is determined that there is a second node in the partition, the second node is repartitioned to obtain the partitioning result of this round.
[0155] For example, assuming a knowledge graph has 100 nodes and two partitions, with the top K nodes (K being 4) ranked by weight being nodes v1 to v4, then nodes v1 to v4 are used as starting nodes, and the knowledge graph is initialized into two partitions by combining the structural information of the query template and the structural information of the knowledge graph. If the partitioning result is: nodes in partition 1 include nodes v1, v3, v5, and v6, and nodes in partition 2 include nodes v2, v4, v7, and v8, and node v5, as a leaf node of partition 1, has a semantic similarity to partition 1 that is less than the similarity threshold, and node v7, as a leaf node of partition 2, has a semantic similarity to partition 2 that is less than the similarity threshold, then nodes v5 and v7 will be repartitioned. If node v5 is reassigned to partition 2 and node v7 is reassigned to partition 1, then the partitioning result of this iteration is: the nodes in partition 1 include nodes v1, v3, v7 and v6, and the nodes in partition 2 include nodes v2, v4, v5 and v8.
[0156] In some examples, after multiple iterations, if the semantic similarity between a leaf node in a partition and the partition is greater than or equal to the similarity threshold, the leaf node is not repartitioned. This effectively reduces the possibility of repartitioning getting stuck in a local optimum.
[0157] In one embodiment, such as Figure 4 As shown, in step 303 above, for each partition of the knowledge graph, when it is determined that there is a second node within the partition, the second node is repartitioned, including:
[0158] 401. The semantic similarity between the leaf nodes in each partition and the partition where the leaf nodes are located is calculated in parallel by the slave nodes in the distributed system, and it is determined whether there is a second node among the leaf nodes in each partition.
[0159] Different slave nodes are used to store different partitions of the knowledge graph.
[0160] In this embodiment, the master node in the distributed system can send the partition information of each partition of the knowledge graph to the slave nodes in the distributed system. The slave nodes can then calculate the semantic similarity between the leaf nodes in each partition and the partition in parallel, and compare the calculated semantic similarity with a similarity threshold to determine whether there is a second node in the leaf nodes of the partition with a semantic similarity less than the similarity threshold.
[0161] When any slave node determines that the partition it stores contains memory in the second node, the slave node will send the node information of the second node to the master node so that the master node can repartition the second node.
[0162] For example, the semantic similarity between the leaf nodes in each partition and the partition is calculated in parallel by the slave nodes, and the calculation formula is as follows (8):
[0163]
[0164] Among them, P t Represents partition t, Sim(v,P) t ) represents the semantic similarity between partition t and node v (which is a leaf node within partition t) and partition t, |P t | represents the number of nodes in partition t, that is, the semantic similarity between node v and partition t is the average of the semantic similarity between node v and every node in partition t.
[0165] 402. When the master node in the distributed system receives the node information of the second node sent by the first slave node, it sends the node information of the second node to multiple second slave nodes in order to obtain the semantic similarity between the second node and the partitions stored by each second slave node.
[0166] Here, the second slave node is a slave node in the distributed system that is different from the first slave node.
[0167] 403, the second node is re-segmented by the master node based on the maximum value among multiple semantic similarities corresponding to the second node.
[0168] In this embodiment, the master node can repartition the second node into the partition corresponding to the largest semantic similarity based on the maximum value among multiple semantic similarities corresponding to the second node.
[0169] In one embodiment, step 103 above, which assigns the node to be partitioned to the target partition based on the semantic similarity between the node to be partitioned in the knowledge graph and each partition of the knowledge graph, includes:
[0170] Determine the maximum semantic similarity among the nodes to be partitioned and each partition; use the partition corresponding to the maximum semantic similarity among multiple partitions as the target partition, and assign the node to be partitioned to the target partition.
[0171] For example, if the knowledge graph is divided into partitions 1, 2, 3 and 4, and the semantic similarity between the node to be divided and each partition is determined to be the greatest with partition 1, then the node to be divided will be assigned to partition 1.
[0172] The following is in conjunction with the appendix Figure 5 and attached Figure 6 The technical solution provided in this disclosure will be further described in detail.
[0173] The knowledge graph processing method disclosed herein can be applied to the partitioning of large-scale RDF knowledge graphs. This method mainly includes steps such as data preprocessing, initial partitioning, semantic similarity calculation, and repartitioning.
[0174] 1. Data Preprocessing
[0175] When initializing node weights, the semantic information of the nodes and edges is incorporated.
[0176] 1) Initialize edge weights
[0177] Depend on Figure 5The edge semantic information shown indicates the existence of a triple (dbo:Champoy rdfs:subPropertyOfowl:hasParticipant), meaning that if someone is the champion of a sport, then it can be inferred that someone else is a participant in that sport. In other words, in an RDF knowledge graph, there is an inheritance relationship between edges; therefore, the weight of an edge cannot be initialized to 1 or be the same for all edges. Different RDF knowledge graphs contain different edges. Therefore, for different RDF knowledge graph partitions, it is necessary to first organize the edges existing in the current RDF knowledge graph and the relationships between them, as shown in the following diagram. Figure 5 The tree structure shown is the semantic hierarchy of the edges. Then, the edges are initialized according to the weight of each edge in the current semantic hierarchy using the above calculation formula (1).
[0178] For example, the name of the current edge is Ow1:hasParticipant, and the current edge contains two child nodes, namely dbo:Champion and dbo:olympicOathSwornBy. Assuming that the number of the current edge (i.e., the number of the current edge in the knowledge graph) is 20, and the total number of edges in the semantic hierarchy of the edges is 100, then the initial weight of the current edge calculated using the above formula (1) is (20+2) / 100, which is 0.22.
[0179] 2) Initialization of node weights
[0180] Depend on Figure 5 The semantic information of the nodes shown indicates the existence of a triple (dbo:SoftWare rdfs:suhClassOfdbo:Work), meaning that if an event belongs to software engineering, then it can be inferred that the event belongs to a job. In the RDF knowledge graph, entities also have inheritance relationships, therefore the weights of nodes cannot be uniformly initialized to 1 for calculation. Different RDF knowledge graphs contain different nodes, so when partitioning different RDF knowledge graphs, it is necessary to first organize the node types existing in the current RDF knowledge graph and the relationships between nodes, as shown in the following... Figure 5 The tree structure shown is the semantic hierarchy of the nodes. Then, the nodes are initialized according to the weight of each node in the current semantic hierarchy using the above calculation formula (2).
[0181] For example, the name of the current node is Ow1:Thing, and the current node contains 3 child nodes, namely dbo:Place, dbo:Species, and dbo:Work. Assuming that the number of the current node (i.e., the number of the current node in the knowledge graph) is 30, and the total number of nodes in the semantic hierarchy of the nodes is 100, then the initial weight of the current node is calculated using the above formula (2) as (30+3) / 100, which is 0.33.
[0182] 3) Node weight calculation
[0183] In the process of querying an RDF knowledge graph, a node is often used as the starting point of the query, and the outgoing edges are used as the direction of the query. That is, the weight of the source node can depend on the number of outgoing edges and the weight of the target node.
[0184] After calculating the initial weights of edges and nodes based on the semantic hierarchy, the weights of nodes are recalculated using the above calculation formula (3).
[0185] During the calculation process, firstly, nodes with empty outgoing edge sets are selected and weights are assigned. Then, the source nodes of the incoming edges of that node are calculated. If the target node of the calculated node has an outgoing edge but the weight has not been assigned, the calculation is performed after the target node is assigned a weight.
[0186] 2. Initialize the partition
[0187] like Figure 6 As shown, after the node weights are calculated, the nodes with the top K weights are selected for partition initialization based on the actual number of partitions required.
[0188] Starting with the TopK nodes, combined with Figure 5 The query template shown is used to find the corresponding outgoing edge structure and partition it. During initial partitioning, the criterion is to reduce the number of crossed edges; subsequent partitioning is performed based on semantic similarity.
[0189] 3. Semantic similarity calculation
[0190] Based on the initial partitioning according to the TopK nodes and the query template, the information of each partition is sent to... Figure 5 In the distributed computing framework, each computing slave node performs parallel computation on the semantic similarity between the leaf nodes in each partition and the partition itself.
[0191] The semantic similarity between a leaf node in any partition and the partition itself can be the average of the semantic similarities between the leaf node and all nodes in the partition.
[0192] Here, the similarity can be based on adaptive weighted semantic similarity. That is, first, the distance-based semantic similarity is calculated using the above calculation formula (4), the attribute-based semantic similarity is calculated using the above calculation formulas (5) and (6), and then the adaptive weighted semantic similarity is calculated using the above calculation formula (7). After calculating the semantic similarity between the leaf node and each node in the partition, the average semantic similarity between the leaf node and each node in the partition is calculated using the above calculation formula (8), which is the semantic similarity between the leaf node and the partition.
[0193] 4. Re-partitioning
[0194] After the semantic similarity calculation is completed in each iteration, if the semantic similarity is less than the similarity threshold, the slave node will send the node information of the nodes with semantic similarity less than the similarity threshold to the master node. The master node will then re-divide the nodes and send the division results to each node, and proceed to the next round of calculation.
[0195] The process of re-partitioning the master node includes:
[0196] The master node sends the node information of the received node to each slave node to obtain the semantic similarity between the node and the partitions stored by each slave node. The master node re-partitions the node based on the maximum value of the semantic similarity and, in combination with the structural information of the query template and the structural information of the knowledge graph, obtains the partitioning result.
[0197] To avoid repartitioning getting stuck in local optima, this scheme supports threshold control of semantic similarity. After a certain number of iterations, if the semantic similarity of the leaf nodes in a partition is greater than or equal to the similarity threshold, then the node will not be repartitioned.
[0198] The technical solutions provided in this disclosure have at least the following beneficial effects:
[0199] 1. By incorporating the semantic hierarchy information of the RDF knowledge graph into the weight initialization of nodes and edges, the semantic information of nodes and edges can be distinguished for different RDF knowledge graphs.
[0200] 2. By incorporating the edge weights into the node weights and combining the structural information of commonly used knowledge graph query templates contained in different knowledge graphs in the initial partitioning, the high communication cost and query processing time caused by cross-partition queries are reduced from the query level, thereby improving query efficiency.
[0201] 3. During the repartitioning process, the semantic similarity between the leaf nodes within a partition and the partition itself is calculated, and nodes are migrated based on this semantic similarity. When new nodes and edges are introduced into the RDF knowledge graph after partitioning, real-time partitioning can also be performed by calculating semantic similarity with each partition, improving efficiency. Furthermore, the adaptive weighted semantic similarity calculation scheme can address the varying distance and attribute weight requirements of different knowledge graphs. Additionally, a similarity threshold can be set during iteration to prevent getting trapped in local optima and reduce communication costs and computation time.
[0202] Figure 7 A structural diagram of a knowledge graph partitioning apparatus provided in an embodiment of this disclosure is shown. Figure 7 As shown, the knowledge graph partitioning device 100 includes: a determination module 110 and a partitioning module 120, wherein:
[0203] The determining module 110 is used to determine the weight of the nodes in the knowledge graph based on the semantic information of the nodes in the knowledge graph and the semantic information of the edges between the nodes.
[0204] The partitioning module 120 is used to partition the knowledge graph into sections based on the weights of the nodes in the knowledge graph and the structural information of the knowledge graph.
[0205] The partitioning module 120 is further configured to partition the node to be partitioned into a target partition based on the semantic similarity between the node to be partitioned in the knowledge graph and each partition of the knowledge graph.
[0206] In one embodiment, the determining module 110 is used to:
[0207] The initial weight of each edge is determined based on the semantic information of the edges in the knowledge graph.
[0208] The initial weight of each node is determined based on the semantic information of the nodes in the knowledge graph.
[0209] The weight of each node is determined based on the initial weight of each edge and the initial weight of each node.
[0210] In one embodiment, the determining module 110 is used to:
[0211] The first semantic hierarchy is determined based on the attribute information of the edges in the knowledge graph and the association between different edges;
[0212] Determine the weight of each edge in the first semantic hierarchy.
[0213] In one embodiment, the determining module 110 is used to:
[0214] The second semantic hierarchy is determined based on the attribute information of the nodes in the knowledge graph and the relationships between the nodes;
[0215] Determine the weight of each node in the second semantic hierarchy.
[0216] In one embodiment, the determining module 110 is used to:
[0217] For each of the nodes, perform the following operations:
[0218] When the set of outgoing edges of the node is not empty, the weight of the node is determined according to the initial weight of the node, the initial weight of the outgoing edges of the node, and the weight of the target node corresponding to the outgoing edge.
[0219] When the set of outgoing edges of a node is empty, the initial weight of the node is determined as the weight of the node.
[0220] In one embodiment, the segmentation module 120 is used for:
[0221] The knowledge graph is partitioned based on the weights of the nodes, the structural information of the knowledge graph, and the structural information of the preset query template.
[0222] In one embodiment, the segmentation module 120 is used for:
[0223] Based on the preset number of partitions and the sorting of the nodes according to their weight from high to low, select multiple first nodes;
[0224] Using each of the first nodes as the starting nodes, and combining the structural information of the knowledge graph with the structural information of the preset query template, the knowledge graph is initialized and partitioned.
[0225] For each partition of the knowledge graph, when it is determined that there is a second node among the leaf nodes in the partition, the second node is repartitioned; wherein the semantic similarity between the second node and the partition is less than the similarity threshold.
[0226] In one embodiment, the segmentation module 120 is used for:
[0227] The semantic similarity between the leaf nodes in each partition and the partition where the leaf nodes are located is calculated in parallel by the slave nodes in the distributed system, and it is determined whether the second node exists among the leaf nodes in each partition.
[0228] When the master node in the distributed system receives the node information of the second node sent by the first slave node, it sends the node information of the second node to multiple second slave nodes in order to obtain the semantic similarity between the second node and the partitions stored by each second slave node.
[0229] The master node re-divides the second node based on the maximum value among multiple semantic similarities corresponding to the second node.
[0230] In one embodiment, the partitioning module 120 is used for:
[0231] Determine the maximum value of the semantic similarity between the node to be partitioned and each of the partitions;
[0232] The partition corresponding to the maximum value among the multiple semantic similarities is used as the target partition, and the node to be partitioned is assigned to the target partition.
[0233] In one embodiment, for any partition of the knowledge graph, the semantic similarity between a node in the knowledge graph and the partition is: the statistical value of the semantic similarity between the node and the nodes within the partition.
[0234] It should be noted that the image recognition processing device provided in the above embodiments is only illustrated by the division of the above program modules when implementing the image recognition processing method. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the image recognition processing device can be divided into different program modules to complete all or part of the processing described above. In addition, the image recognition processing device and the corresponding method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0235] Figure 8 A structural block diagram of a computer device provided in an embodiment of this disclosure; as shown Figure 8 As shown, the computer device 900 includes: a processor 901 and a memory 902 for storing computer programs that can run on the processor; wherein, the processor 901 is used to implement the steps in the knowledge graph partitioning method described above when running the computer program.
[0236] In practical applications, the computer device 900 may also include at least one network interface 903. The various components in the computer device 900 are coupled together via a bus system 904. It is understood that the bus system 904 is used to implement communication between these components. In addition to a data bus, the bus system 904 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 8All buses are labeled as bus system 904. The number of processors 901 can be at least one. Network interface 903 is used for wired or wireless communication between computer device 900 and other devices.
[0237] The memory 902 in this embodiment is used to store various types of data to support the operation of the computer device 900.
[0238] The methods disclosed in the above embodiments of this disclosure can be applied to or implemented by processor 901. Processor 901 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 901 or by instructions in software form. The processor 901 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 901 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this disclosure can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 902. Processor 901 reads the information in memory 902 and, in conjunction with its hardware, completes the steps of the aforementioned method.
[0239] In an exemplary embodiment, the computer device 900 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned method.
[0240] This disclosure also provides a computer-readable storage medium storing a computer program thereon; when the computer program is executed by a processor, it implements the steps of the aforementioned knowledge graph partitioning method.
[0241] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0242] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0243] In addition, each functional unit in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0244] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0245] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this disclosure, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0246] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.
Claims
1. A knowledge graph partitioning method, characterized in that, The method includes: The weights of the nodes in the knowledge graph are determined based on the semantic information of the nodes and the semantic information of the edges between the nodes. The knowledge graph is partitioned based on the weights of the nodes and the structural information of the knowledge graph. Based on the semantic similarity between the node to be partitioned in the knowledge graph and each partition of the knowledge graph, the node to be partitioned is assigned to the target partition; The step of partitioning the knowledge graph based on the weights of the nodes and the structural information of the knowledge graph includes: Based on the preset number of partitions and the sorting of the nodes according to their weight from high to low, select multiple first nodes; Using each of the first nodes as the starting nodes, and combining the structural information of the knowledge graph with the structural information of the preset query template, the knowledge graph is initialized and partitioned. The semantic similarity between the leaf nodes in each partition and the partition where the leaf nodes are located is calculated in parallel by the slave nodes in the distributed system, and it is determined whether there is a second node among the leaf nodes in each partition. When the master node in a distributed system receives node information of a second node sent by a first slave node, it sends the node information of the second node to multiple second slave nodes in order to obtain the semantic similarity between the second node and the partitions stored by each second slave node. The master node re-divides the second node based on the maximum value among multiple semantic similarities corresponding to the second node; Wherein, the semantic similarity between the second node and the partition is less than the similarity threshold.
2. The method according to claim 1, characterized in that, Determining the weights of nodes in the knowledge graph based on the semantic information of nodes in the knowledge graph and the semantic information of the edges between the nodes includes: The initial weight of each edge is determined based on the semantic information of the edges in the knowledge graph. The initial weight of each node is determined based on the semantic information of the nodes in the knowledge graph. The weight of each node is determined based on the initial weight of each edge and the initial weight of each node.
3. The method according to claim 2, characterized in that, The step of determining the initial weight of each edge based on the semantic information of the edges in the knowledge graph includes: The first semantic hierarchy is determined based on the attribute information of the edges in the knowledge graph and the association between different edges; Determine the weight of each edge in the first semantic hierarchy.
4. The method according to claim 2, characterized in that, The step of determining the initial weight of each node based on the semantic information of the nodes in the knowledge graph includes: The second semantic hierarchy is determined based on the attribute information of the nodes in the knowledge graph and the relationships between the nodes; Determine the weight of each node in the second semantic hierarchy.
5. The method according to claim 2, characterized in that, The step of determining the weight of each node based on the initial weight of each edge and the initial weight of each node includes: For each of the nodes, perform the following operations: When the set of outgoing edges of the node is not empty, the weight of the node is determined according to the initial weight of the node, the initial weight of the outgoing edges of the node, and the weight of the target node corresponding to the outgoing edge. When the set of outgoing edges of a node is empty, the initial weight of the node is determined as the weight of the node.
6. The method according to claim 1, characterized in that, The step of assigning the node to be partitioned to the target partition based on the semantic similarity between the node to be partitioned in the knowledge graph and each partition of the knowledge graph includes: Determine the maximum value of the semantic similarity between the node to be partitioned and each of the partitions; The partition corresponding to the maximum value among the multiple semantic similarities is used as the target partition, and the node to be partitioned is assigned to the target partition.
7. The method according to any one of claims 1 to 6, characterized in that, For any partition of the knowledge graph, the semantic similarity between a node in the knowledge graph and the partition is: the statistical value of the semantic similarity between the node and the nodes in the partition.
8. A knowledge graph partitioning device, characterized in that, The device includes: The determination module is used to determine the weight of the nodes in the knowledge graph based on the semantic information of the nodes in the knowledge graph and the semantic information of the edges between the nodes; The partitioning module is used to partition the knowledge graph into sections based on the weights of the nodes and the structural information of the knowledge graph. The partitioning module is further configured to partition the node to be partitioned into a target partition based on the semantic similarity between the node to be partitioned in the knowledge graph and each partition of the knowledge graph; The partitioning module is further configured to: select multiple first nodes based on a preset number of partitions and the nodes sorted by weight from high to low; initialize partitioning the knowledge graph using each first node as a starting node, combined with the structure information of the knowledge graph and the structure information of a preset query template; calculate the semantic similarity between the leaf nodes in each partition and the partition containing the leaf nodes in parallel using slave nodes in the distributed system, and determine whether there are second nodes among the leaf nodes in each partition; when the master node in the distributed system receives the node information of the second node sent by the first slave node, it sends the node information of the second node to multiple second slave nodes to obtain the semantic similarity between the second node and the partitions stored by each second slave node; and repartition the second node based on the maximum value among the multiple semantic similarities corresponding to the second node, wherein the semantic similarity between the second node and the partition is less than a similarity threshold.
9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the knowledge graph partitioning method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the knowledge graph partitioning method according to any one of claims 1 to 7.
Citation Information
Patent Citations
A semantic approximate query method for RDF knowledge map
CN108959613A
Semantic sensitive RDF knowledge graph approximate query method
CN109992786A