Knowledge graph embedding method and device
By employing multi-space representation learning and rule enhancement strategies, the ability to model complex relationships in knowledge graph embedding and the embedding accuracy in sparse data scenarios are improved. This addresses the issues of insufficient relationship adaptation and dynamic adaptability in existing technologies, and achieves high-quality knowledge graph embedding results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINESE PEOPLES LIBERATION ARMY UNIT 61618
- Filing Date
- 2026-02-07
- Publication Date
- 2026-04-24
AI Technical Summary
Existing knowledge graph embedding methods lack precision when adapting to different types of relationships, cannot effectively utilize hidden logical rules, and fail to effectively capture the timeliness characteristics of entities and relationships in dynamic knowledge graphs, resulting in poor embedding performance in complex relationship modeling and data sparse scenarios.
Employing a multi-space representation learning and rule enhancement strategy, this approach combines preprocessing and multi-space representation processing with rule mining and attribute completion to improve the ability to model complex relationships and the embedding accuracy in sparse data scenarios, while also possessing dynamic adaptability.
It improves the ability to model complex relationships in knowledge graph embedding and the embedding accuracy in sparse data scenarios. It can fully preserve the topological structure and semantic associations and is suitable for tasks such as link prediction, intelligent question answering and entity alignment.
Smart Images

Figure CN121920492A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a knowledge graph embedding method and apparatus. Background Technology
[0002] Knowledge graphs, as a structured form of knowledge representation, use triples (head entity, relation, tail entity) as basic units to clearly describe the semantic relationships between entities, and have wide application value in fields such as intelligent question answering, recommendation systems, and semantic retrieval. However, the symbolic representation of traditional knowledge graphs suffers from problems such as low computational efficiency, data sparsity, and insufficient ability to model complex relationships, which limits their application in large-scale scenarios.
[0003] Knowledge graph embedding (KGE) technology maps entities and relations to a low-dimensional continuous vector space, transforming symbolic knowledge into computationally efficient vector representations, thus providing an effective approach to solving the aforementioned problems. Existing knowledge graph embedding methods are mainly divided into distance-based models (such as TransE) and semantic matching-based models (such as RESCAL). Distance-based models measure the rationality of triple combination through the idea of vector translation, while semantic matching-based models evaluate the confidence of triples through semantic similarity.
[0004] However, existing technologies still have many shortcomings: a single representation space (such as Euclidean space or complex space) is difficult to adapt to different types of relationships (such as one-to-one, one-to-many, and many-to-many), resulting in insufficient accuracy in modeling complex relationships; existing methods mostly rely on observed facts in knowledge graphs for training, failing to fully utilize the hidden logical rules, leading to poor embedding performance in data-sparse scenarios; in dynamic knowledge graphs, the time-sensitivity characteristics of entities and relationships are not effectively captured, and static embedding methods cannot adapt to the needs of knowledge evolution over time. Therefore, there is an urgent need for a knowledge graph embedding method that can integrate multi-source information, adapt to complex relationships, and possess dynamic adaptability. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a knowledge graph embedding method and apparatus, which improves the ability to model complex relationships and the embedding accuracy in data sparse scenarios by integrating multi-space representation learning and rule enhancement strategies, while also having dynamic knowledge adaptation capabilities.
[0006] To address the aforementioned technical problems, a first aspect of the present invention discloses a knowledge graph embedding method, the method comprising: S1, Obtain the original knowledge graph data information; the original knowledge graph data information includes N triples, entity attribute information, and entity relationship information; S2, preprocess the original knowledge graph data information to obtain preprocessed knowledge graph data information; S3, perform multi-space representation processing on the preprocessed knowledge graph data information to obtain entity initial vectors and relation initial vectors; S4, process the initial vector of the entity and the initial vector of the relationship to obtain the knowledge graph embedding result.
[0007] As an optional implementation, in the first aspect of the present invention, the preprocessing of the original knowledge graph data information to obtain preprocessed knowledge graph data information includes: S21, Encode the original knowledge graph data information to obtain encoded data information; S22, invalid data is removed from the encoded data information to obtain optimized knowledge graph data information; S23, perform knowledge enhancement on the optimized knowledge graph data information to obtain preprocessed knowledge graph data information.
[0008] As an optional implementation, in the first aspect of the present invention, the invalid data removal from the encoded data information to obtain optimized knowledge graph data information includes: S221, Process the encoded data information for null value detection to obtain first encoded data information; S222, Perform attribute detection on the first encoded data information to obtain the second encoded data information; S223, Perform relational logic conflict detection on the second encoded data information to obtain the third encoded data information; S224, perform isolated entity detection on the third encoded data information to obtain optimized knowledge graph data information.
[0009] As an optional implementation, in the first aspect of the present invention, the step of performing isolated entity detection on the third encoded data information to obtain optimized knowledge graph data information includes: S2241, The third encoded data information is processed to obtain an undirected graph G=(V,E). Let vi be the set of all entities, n be the number of entities, and vi be the i-th entity. Let be a set of edges, with a total of m edges, where ej is the j-th edge; S2242, Store the undirected graph to obtain the adjacency list data structure; S2243, perform isolated entity detection on the adjacency list data structure and delete isolated entities to obtain optimized knowledge graph data information.
[0010] As an optional implementation, in the first aspect of the present invention, the step of performing knowledge enhancement on the optimized knowledge graph data information to obtain preprocessed knowledge graph data information includes: S231, perform correlation analysis on the optimized knowledge graph data information to obtain rule information; S232, Instantiate the rule information to obtain a new triplet; S233, perform entity completion on the new triplet to obtain an optimized new triplet; S234, integrate the optimized new triplet and the optimized knowledge graph data information to obtain preprocessed knowledge graph data information.
[0011] As an optional implementation, in the first aspect of the present invention, the step of performing entity completion on the new triple to obtain an optimized new triple includes: S2331, Process the new triplet to obtain a candidate triplet set; S2332, Process the set of candidate triples to obtain the fit score of each candidate triple; S2333, Based on the fitting score of each candidate triplet, the candidate triplet set is sorted in descending order of score to obtain an ordered triplet set; S2334, Process the ordered set of triples to obtain optimized new triples.
[0012] As an optional implementation, in the first aspect of the present invention, the step of performing multi-space representation processing on the preprocessed knowledge graph data information to obtain entity initial vectors and relation initial vectors includes: S31, perform relation type classification processing on the preprocessed knowledge graph data information to obtain entity relation information; the entity relation information includes one-to-one relation, one-to-many relation, many-to-one relation, and many-to-many relation. S32, Perform spatial adaptation processing on the entity relationship information to obtain spatially adapted entity relationship information; S33, Perform vector initialization and normalization processing on the spatial adaptation entity relationship information to obtain the entity initial vector and the relationship initial vector.
[0013] A second aspect of this invention discloses a knowledge graph embedding device, the device comprising: The information acquisition module is used to acquire raw knowledge graph data information; the raw knowledge graph data information includes N triples, entity attribute information, and entity relationship information. The preprocessing module is used to preprocess the original knowledge graph data to obtain preprocessed knowledge graph data. The multi-space representation processing module is used to perform multi-space representation processing on the preprocessed knowledge graph data information to obtain entity initial vectors and relation initial vectors. The knowledge graph embedding module is used to process the entity initial vector and the relation initial vector to obtain the knowledge graph embedding result.
[0014] As an optional implementation, in the second aspect of the present invention, the preprocessing of the original knowledge graph data information to obtain preprocessed knowledge graph data information includes: S21, Encode the original knowledge graph data information to obtain encoded data information; S22, invalid data is removed from the encoded data information to obtain optimized knowledge graph data information; S23, perform knowledge enhancement on the optimized knowledge graph data information to obtain preprocessed knowledge graph data information.
[0015] As an optional implementation, in the second aspect of the present invention, the invalid data removal process for the encoded data information to obtain optimized knowledge graph data information includes: S221, Process the encoded data information for null value detection to obtain first encoded data information; S222, Perform attribute detection on the first encoded data information to obtain the second encoded data information; S223, Perform relational logic conflict detection on the second encoded data information to obtain the third encoded data information; S224, perform isolated entity detection on the third encoded data information to obtain optimized knowledge graph data information.
[0016] As an optional implementation, in a second aspect of the present invention, the step of performing isolated entity detection on the third encoded data information to obtain optimized knowledge graph data information includes: S2241, The third encoded data information is processed to obtain an undirected graph G=(V,E). Let vi be the set of all entities, n be the number of entities, and vi be the i-th entity. Let be a set of edges, with a total of m edges, where ej is the j-th edge; S2242, Store the undirected graph to obtain the adjacency list data structure; S2243, perform isolated entity detection on the adjacency list data structure and delete isolated entities to obtain optimized knowledge graph data information.
[0017] As an optional implementation, in a second aspect of the present invention, the step of performing knowledge enhancement on the optimized knowledge graph data information to obtain preprocessed knowledge graph data information includes: S231, perform correlation analysis on the optimized knowledge graph data information to obtain rule information; S232, Instantiate the rule information to obtain a new triplet; S233, perform entity completion on the new triplet to obtain an optimized new triplet; S234, integrate the optimized new triplet and the optimized knowledge graph data information to obtain preprocessed knowledge graph data information.
[0018] As an optional implementation, in the second aspect of the present invention, the entity completion of the new triplet to obtain an optimized new triplet includes: S2331, Process the new triplet to obtain a candidate triplet set; S2332, Process the set of candidate triples to obtain the fit score of each candidate triple; S2333, Based on the fitting score of each candidate triplet, the candidate triplet set is sorted in descending order of score to obtain an ordered triplet set; S2334, Process the ordered set of triples to obtain optimized new triples.
[0019] As an optional implementation, in the second aspect of the present invention, the step of performing multi-space representation processing on the preprocessed knowledge graph data information to obtain entity initial vectors and relation initial vectors includes: S31, perform relation type classification processing on the preprocessed knowledge graph data information to obtain entity relation information; the entity relation information includes one-to-one relation, one-to-many relation, many-to-one relation, and many-to-many relation. S32, Perform spatial adaptation processing on the entity relationship information to obtain spatially adapted entity relationship information; S33, Perform vector initialization and normalization processing on the spatial adaptation entity relationship information to obtain the entity initial vector and the relationship initial vector.
[0020] A third aspect of the present invention discloses another knowledge graph embedding device, the device comprising: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute some or all of the steps in the knowledge graph embedding method disclosed in the first aspect of the present invention.
[0021] The fourth aspect of the present invention discloses a computer-storable medium storing computer instructions, which, when invoked, are used to execute some or all of the steps in the knowledge graph embedding method disclosed in the first aspect of the present invention.
[0022] Compared with the prior art, the embodiments of the present invention have the following beneficial effects: This invention discloses a knowledge graph embedding method that combines rule mining, attribute completion, and other knowledge enhancement strategies to fully explore latent knowledge, effectively alleviate data sparsity problems, and provide a high-quality data foundation for embedding modeling. The low-dimensional vectors obtained from the embedding can completely preserve the topological structure and semantic relationships of the knowledge graph, and can be directly applied to downstream tasks such as link prediction, intelligent question answering, and entity alignment, making it applicable to a wide range of scenarios. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a flowchart illustrating a knowledge graph embedding method disclosed in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a knowledge graph embedding device disclosed in an embodiment of the present invention; Figure 3 This is a schematic diagram of another knowledge graph embedding device disclosed in an embodiment of the present invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects and not to describe a particular order. Furthermore, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such processes, methods, products, or devices.
[0027] References to embodiments herein mean that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0028] In all embodiments of the present invention, the variables involved in all computational expressions or mathematical functions are dimensionless before calculation. The values of the independent variables in all computational expressions or mathematical functions in these embodiments conform to the reasonable requirements of the input range of the computational expression or mathematical function, ensuring that the computational expression or mathematical function can be calculated smoothly without violating physical laws or mathematical rules.
[0029] This invention discloses a knowledge graph embedding method and apparatus. The method includes acquiring original knowledge graph data information; the original knowledge graph data information includes N triples, entity attribute information, and entity relation information; preprocessing the original knowledge graph data information to obtain preprocessed knowledge graph data information; performing multi-space representation processing on the preprocessed knowledge graph data information to obtain initial entity vectors and initial relation vectors; and processing the initial entity vectors and initial relation vectors to obtain the knowledge graph embedding result. This invention combines knowledge enhancement strategies such as rule mining and attribute completion to fully explore latent knowledge, effectively alleviate the data sparsity problem, and provide a high-quality data foundation for embedding modeling. The low-dimensional vectors obtained by embedding can completely preserve the topological structure and semantic associations of the knowledge graph, and can be directly applied to downstream tasks such as link prediction, intelligent question answering, and entity alignment, with a wide range of applicable scenarios. Detailed descriptions follow.
[0030] Example 1 Please see Figure 1 , Figure 1 This is a flowchart illustrating a knowledge graph embedding method disclosed in an embodiment of the present invention. Figure 1The described knowledge graph embedding method is applied in the field of artificial intelligence technology, and the embodiments of this invention are not limited thereto. Figure 1 As shown, this knowledge graph embedding method can include the following operations: S1, Obtain the original knowledge graph data information; the original knowledge graph data information includes N triples, entity attribute information, and entity relationship information; S2, preprocess the original knowledge graph data information to obtain preprocessed knowledge graph data information; S3, perform multi-space representation processing on the preprocessed knowledge graph data information to obtain entity initial vectors and relation initial vectors; 1) Perform text preprocessing and feature encoding on the preprocessed knowledge graph data; The preprocessed knowledge graph data is segmented at the character level to obtain character sequences. , The length of the character sequence is given; the preprocessed knowledge graph data is segmented to obtain a word sequence. , The length of the word sequence records the word position mapping relationship for each character. ; Constructing a multi-dimensional initial feature set: The character sequence C is encoded using the pre-trained Chinese character vector model FastText to obtain character embedding features. ; The word sequence W is encoded using the pre-trained Chinese word vector model Word2Vec, and word embedding features are obtained by combining the positional mapping relationship M. ; Part-of-speech tagging is performed on the vocabulary sequence W to obtain the part-of-speech sequence. After encoding through the part-of-speech embedding layer and combining it with the mapping relationship M, we obtain the character-dimensional part-of-speech embedding features. ; Character embedding features Word embedding features Part-of-speech embedding features The fusion process is performed to obtain the fusion characteristics; The specific fusion method expression is as follows: Norm represents standardization. , express Length; in, express function, and These are preset, learnable model parameters. Initializing with a normal distribution ensures stable variance of the initial output, preventing gradient vanishing or exploding. For bias information, tanh is the hyperbolic tangent function; 2) Input the fused features into a pre-trained Chinese language model to obtain the basic semantic features H; 3) Enhance the long-distance dependency of the basic semantic feature H by introducing a multi-head self-attention mechanism to perform secondary feature extraction on H, focusing on capturing the cross-positional association features of entities in long texts to obtain enhanced semantic features. ; in, This is a weight matrix for attention queries, keys, and values; 4) Enhanced semantic features By performing residual connections and layer normalization, the gradient vanishing problem in deep models is alleviated, and pre-trained fusion features are obtained. ; 5) Integrate pre-trained features The input is fed into a bidirectional long short-term memory network (BiLSTM) to further capture the contextual sequence dependencies of the features, thus obtaining the sequence features L. 6) Then, the sequence features L are mapped to the label space through a linear transformation layer to obtain the label probability distribution G for each character; 7) Use conditional random fields to solve for the optimal label sequence Y; 8) Perform entity parsing on the optimal label sequence Y, extract the start position, end position and entity category of the entity, and obtain the named entity recognition result R.
[0031] The named entity recognition result R is subjected to multi-space representation processing to obtain the initial entity vector and the initial relation vector; S4, process the initial vector of the entity and the initial vector of the relationship to obtain the knowledge graph embedding result.
[0032] S41, process the entity initial vector and the relation initial vector to obtain structured data in the knowledge graph, extract positive triples composed of head entity, relation and tail entity, and construct positive triple dataset; S42, collect all entities in the knowledge graph, and use a clustering algorithm to cluster the entities to obtain multiple entity clusters, each entity cluster containing entities with similar semantics or attributes; The clustering method is as follows: (1) For the initial data points The (entity set) is processed to obtain the median of all point pairs. ; Calculate the local density of each point (entity). , This represents the local density at the i-th point; Calculate the score for the initial center of each point. , This represents the score of the i-th point; right Sort by largest to smallest, and take the first few. These points are used as the initial cluster center set. , (2) Calculate all points within the threshold distance range of the cluster center and classify them into clusters. (representing the k-th cluster in the t-th iteration), the distance metric is: For the t-th iteration cluster The distance value, For the first Data points, For the t-th iteration A cluster; (3) For each cluster center Collect a set of points within its threshold distance range. ; Calculate offset , in For weight values, , Let be the current average distance of cluster j.
[0033] (4) The cluster center moves along the direction of the offset vector, and the distance moved is: (5) Repeat steps (2), (3), and (4) until the offset vector value reaches the threshold set by the termination condition, and record the cluster center at this time; (6) Repeat steps (1) to (5) until all data points have been traversed; (7) Finally, calculate the number of times each element is accessed by each class, and classify the element into the cluster class that is accessed the most.
[0034] S43, for each positive triplet constructed in S41, perform similarity negative sampling to generate negative triplets: Determine the target head entity cluster to which the head entity belongs and the target tail entity cluster to which the tail entity belongs in the positive example triple; Randomly select an entity from the target head entity cluster that is different from the original head entity as a replacement entity, and replace the head entity in the positive example triplet to obtain the first type of negative example triplet; and / or randomly select an entity from the target tail entity cluster that is different from the original tail entity as a replacement entity, and replace the tail entity in the positive example triplet to obtain the second type of negative example triplet. S44. Construct the knowledge graph embedding model TransE-SNS that integrates similarity negative sampling. Input the positive triplet from S41 and the negative triplet generated in S43 as training data into the model. Define the energy function and the target loss function. Optimize the model parameters through the gradient descent algorithm to complete the model training. S45 uses the trained TransE-SNS model to output low-dimensional vector representations of all entities and relations in the knowledge graph, thus obtaining the knowledge graph embedding result.
[0035] Optionally, the preprocessing of the original knowledge graph data to obtain preprocessed knowledge graph data includes: S21, Encode the original knowledge graph data information to obtain encoded data information; A unique entity-relationship ID mapping algorithm is adopted to standardize the encoding of entity names and relationship types, thereby eliminating data ambiguity caused by homonyms and synonyms. S22, invalid data is removed from the encoded data information to obtain optimized knowledge graph data information; S23, perform knowledge enhancement on the optimized knowledge graph data information to obtain preprocessed knowledge graph data information.
[0036] Optionally, an association rule mining algorithm (such as the AMIE+ algorithm) is used to perform association analysis on the cleaned triples to uncover hidden logical rules (such as if (h, belongs to, t) and (t, contains, s), then (h, associated, s)). Then, a forward linking reasoning algorithm is used to reason about the mined rules to generate new rules. The entity variables in the new rules are instantiated to obtain new triples. The new triples are then merged with the original triples to obtain an enhanced knowledge graph (preprocessing knowledge graph data information).
[0037] Optionally, the step of removing invalid data from the encoded data to obtain optimized knowledge graph data includes: S221, Process the encoded data information for null value detection to obtain first encoded data information; Remove invalid triples: Entity / relation null value judgment: Define a triple validity indicator function (V(h,r,t)). If (h=null) or (r=null) or (t=null), then (V(h,r,t)=0) (invalid), otherwise (V(h,r,t)=1) (temporarily valid). S222, Perform attribute detection on the first encoded data information to obtain the second encoded data information; Given the attribute set of an entity, define an attribute consistency function to remove data with conflicting attributes and obtain the second encoded data information; for example, if the attribute set of entity Zhang San is {age:100, age:20}, and there is an attribute conflict, then all triples containing Zhang San are determined to be invalid. S223, Perform relational logic conflict detection on the second encoded data information to obtain the third encoded data information; Detect logical conflicts in relationships that possess characteristics such as antisymmetry and transitivity; S224, perform isolated entity detection on the third encoded data information to obtain optimized knowledge graph data information.
[0038] Optionally, the step of performing isolated entity detection on the third encoded data information to obtain optimized knowledge graph data information includes: S2241, The third encoded data information is processed to obtain an undirected graph G=(V,E). Let vi be the set of all entities, n be the number of entities, and vi be the i-th entity. Let be a set of edges, with a total of m edges, where ej is the j-th edge; S2242, Store the undirected graph to obtain the adjacency list data structure; S2243, perform isolated entity detection on the adjacency list data structure and delete isolated entities to obtain optimized knowledge graph data information.
[0039] Step 1: Graph Structure Construction: The knowledge graph after triple validity verification is abstracted into an undirected graph G=(V,E), where For the set of all entities, Let the set be an edge (each edge corresponds to a valid triple, ignoring the relation type and only retaining the connection relationship between entities, that is, if there is a triple ((h,r,t)), then an undirected edge (h,t) is established between (h) and (t); Step 2: Data structure storage: An adjacency list is used to store the undirected graph G. Each node in the adjacency list corresponds to an entity v in the knowledge graph. The node stores all the adjacent entities of the entity (i.e., entities that are connected to the entity by an edge), denoted as adj(v). If entity v has no adjacent entities, then adj(v) = empty. Step 3: Graph Traversal Detection: Initialize the access flag of all entities to unvisited, denoted as visited(v)=False. Traverse each entity v in the entity set V. If visited(v)=False and adj(v)=empty: Use depth-first search to traverse the connected components where v is located, and mark all traversed entities as visited (visited(v)=True). Such entities are non-isolated entities. If visited(v)=False and adj(v)=empty, directly mark the entity as an isolated entity, delete it directly, and clean up all data records related to these entities. Optionally, the step of performing knowledge enhancement on the optimized knowledge graph data to obtain preprocessed knowledge graph data includes: S231, perform correlation analysis on the optimized knowledge graph data information to obtain rule information; S232, Instantiate the rule information to obtain a new triplet; S233, perform entity completion on the new triplet to obtain an optimized new triplet; S234, integrate the optimized new triplet and the optimized knowledge graph data information to obtain preprocessed knowledge graph data information.
[0040] Optionally, the step of performing entity completion on the new triple to obtain an optimized new triple includes: S2331, Process the new triplet to obtain a candidate triplet set; Mapping the new triples yields a low-dimensional semantic space representation; The new triplet is processed to obtain neighbor information (based on the structural information of the knowledge graph, its multi-hop neighbor entities and relationships are extracted, and a local subgraph is constructed). The neighbor information is processed to obtain a low-dimensional semantic space representation, including structural semantic embedding representation and text semantic embedding representation. The low-dimensional semantic space representation is processed to obtain matching information; 1) Calculate the semantic similarity score of the text: This is the weight matrix of the neural network (Adaptive Cross-Modal Feedforward Network ACM-MLP). d Let be the dimension of the matrix. r For neighbor information, Embed vectors for predefined task relationships. For the information of the i-th neighbor, This refers to the bias information of the hybrid neural network. Score the semantic similarity of the text; Calculate the semantic attention weights of the text; For the first The textual semantic attention weights of each neighboring node, For the first Pre-defined task relationship embedding vectors: Text semantic entity embedding is performed to obtain text semantic embedding result e1; Let be the embedding vector of the adjacent entities of the i-th query head node; 2) Calculate the text structure similarity score; Given a node and its neighbor node set Then its population coefficient for: in, l This represents the actual number of edges that exist between a node and its neighboring nodes. d The number of neighboring nodes. Population coefficient. The value ranges from [0,1], and a higher value indicates that the neighbors of the node are more closely connected; Assign a score based on the similarity of the text structure. For query header entities, weight matrix Bias terms are used to learn the relationships between different dimensions. Used to adjust the model's output. Attention weights of the text structure of each neighboring node for: Text structure entity embedding is performed to obtain text structure embedding result e2; The semantic embedding result e1 and the structural embedding result e2 are fused to obtain the entity embedding result; Swish is the activation function of the adaptive cross-modal feedforward network ACM-MLP. For entity embedding results, , , , , and The weight matrices are preset and independent. , ≠ , ).
[0041] The entity embedding results are processed using a Transformer encoder to obtain candidate triples. ; , For the tail entity embedding result, For relational embedding, This represents the concatenation operation; the calculation methods for tail entity embedding and relation embedding, and The calculation method is the same, and this embodiment does not impose any limitations. Candidate triples constitute a candidate triplet set; S2332, Process the set of candidate triples to obtain the fit score of each candidate triple; The triplet information is processed to obtain the query triplet embedding vector. q ; in This indicates a dynamic routing feedforward network. This indicates domain-aware multi-head attention.
[0042] Query triple embedding vector q The process is performed to obtain a matching score; The matching score expression is: Where is the dot product symbol, q To query the triple embedding vector, To match scores, The preset balance coefficient, For entities The domain weights are either predefined or learned from domain data; The matching score is processed to obtain a normalized matching score; in To normalize the matching information, is a preset learnable parameter, and margin is a hyperparameter used to introduce a penalty term for negative samples in the denominator to enhance the ability to distinguish negative samples. S2333, Based on the fitting score of each candidate triplet, the candidate triplet set is sorted in descending order of score to obtain an ordered triplet set; S2334, Process the ordered set of triples to obtain optimized new triples.
[0043] Select the top D triplet pairs to form an optimized new triplet pair.
[0044] Optionally, the step of performing multi-space representation processing on the preprocessed knowledge graph data to obtain initial entity vectors and initial relation vectors includes: S31, perform relation type classification processing on the preprocessed knowledge graph data information to obtain entity relation information; the entity relation information includes one-to-one relation, one-to-many relation, many-to-one relation, and many-to-many relation. S32, Perform spatial adaptation processing on the entity relationship information to obtain spatially adapted entity relationship information; S33, Perform vector initialization and normalization processing on the spatial adaptation entity relationship information to obtain the entity initial vector and the relationship initial vector.
[0045] A representation framework composed of multiple heterogeneous vector spaces (Euclidean space, complex space, and hyperplane space) is constructed, which is divided into three sub-steps: Relationship type classification: A type-aware assignment algorithm is used to traverse all relations, count the number of head entity-tail entity mappings, and classify relations into four categories: one-to-one (1:1), one-to-many (1:N), many-to-one (N:1), and many-to-many (N:N); Spatial adaptation and allocation: Euclidean space adapts to simple 1:1 relationships (such as ID number-corresponding-person), simplifying calculations by utilizing translation invariance; complex space adapts to 1:N / N:1 relationships (such as author-writing-paper), characterizing multi-entity associations through phase properties; hyperplane space adapts to complex N:N relationships (such as student-selection-course), distinguishing multi-semantic relationships by utilizing the separation properties of hyperplane. Vector initialization and normalization: For entities and relations in each space, an initial vector with uniform dimension (64-512 dimensions, which can be adjusted according to the size of the graph) is generated through a random initialization algorithm; the L2 norm normalization algorithm is used to process the vectors so that the vector magnitude is uniformly 1, ensuring consistent scale.
[0046] S232, Entity Attribute Completion: Based on entity type similarity, attribute completion is performed for entities with missing attributes. For example, if the entity Beijing belongs to the city type, the missing attributes such as the country and climate type of Beijing can be completed by referring to the attributes of the similar entity Shanghai. S233, Relationship Confidence Calibration: For relations containing confidence attributes, the relationship confidence is calibrated using a weighted average algorithm, taking into account the frequency of triple occurrence and the strength of entity association, and low-confidence triples with confidence levels below a preset threshold (e.g., 0.6) are removed.
[0047] As can be seen, this invention combines knowledge enhancement strategies such as rule mining and attribute completion to fully explore latent knowledge, effectively alleviate the data sparsity problem, and provide a high-quality data foundation for embedding modeling. The low-dimensional vectors obtained from embedding can completely preserve the topological structure and semantic relationships of the knowledge graph, and can be directly applied to downstream tasks such as link prediction, intelligent question answering, and entity alignment, with a wide range of applicable scenarios.
[0048] Example 2 Please see Figure 2 , Figure 2 This is a schematic diagram of the structure of a knowledge graph embedding device disclosed in an embodiment of the present invention. Figure 2 The described knowledge graph embedding device is applied in the field of artificial intelligence technology, and the embodiments of the present invention are not limited thereto. Figure 2 As shown, the knowledge graph embedding device may include the following operations: S301, Information Acquisition Module, used to acquire raw knowledge graph data information; the raw knowledge graph data information includes N triples, entity attribute information, and entity relationship information; S302, Preprocessing module, used to preprocess the original knowledge graph data information to obtain preprocessed knowledge graph data information; S303, Multi-space Representation Processing Module, is used to perform multi-space representation processing on the preprocessed knowledge graph data information to obtain entity initial vectors and relation initial vectors; S304, Knowledge Graph Embedding Module, is used to process the entity initial vector and the relation initial vector to obtain the knowledge graph embedding result.
[0049] Example 3 Please see Figure 3 , Figure 3 This is a schematic diagram of another knowledge graph embedding device disclosed in an embodiment of the present invention. Figure 3 The described knowledge graph embedding device is applied in the field of artificial intelligence technology, and the embodiments of the present invention are not limited thereto. Figure 3 As shown, the knowledge graph embedding device may include the following operations: Memory 401 storing executable program code; Processor 402 coupled to memory 401; The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the knowledge graph embedding method described in Embodiment 1.
[0050] Example 4 This invention discloses a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform the steps in the knowledge graph embedding method described in Embodiment 1.
[0051] The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0052] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0053] Finally, it should be noted that the knowledge graph embedding method and apparatus disclosed in the embodiments of the present invention are merely preferred embodiments of the present invention and are only used to illustrate the technical solutions of the present invention, not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A knowledge graph embedding method, characterized in that, The method includes: S1, Obtain the original knowledge graph data information; the original knowledge graph data information includes N triples, entity attribute information, and entity relationship information; S2, preprocess the original knowledge graph data information to obtain preprocessed knowledge graph data information; S3, perform multi-space representation processing on the preprocessed knowledge graph data information to obtain entity initial vectors and relation initial vectors; S4, process the initial vector of the entity and the initial vector of the relationship to obtain the knowledge graph embedding result.
2. The knowledge graph embedding method according to claim 1, characterized in that, The preprocessing of the original knowledge graph data to obtain preprocessed knowledge graph data includes: S21, Encode the original knowledge graph data information to obtain encoded data information; S22, invalid data is removed from the encoded data information to obtain optimized knowledge graph data information; S23, perform knowledge enhancement on the optimized knowledge graph data information to obtain preprocessed knowledge graph data information.
3. The knowledge graph embedding method according to claim 2, characterized in that, The process of removing invalid data from the encoded data to obtain optimized knowledge graph data includes: S221, Process the encoded data information for null value detection to obtain first encoded data information; S222, Perform attribute detection on the first encoded data information to obtain the second encoded data information; S223, Perform relational logic conflict detection on the second encoded data information to obtain the third encoded data information; S224, perform isolated entity detection on the third encoded data information to obtain optimized knowledge graph data information.
4. The knowledge graph embedding method according to claim 3, characterized in that, The process of performing isolated entity detection on the third encoded data information to obtain optimized knowledge graph data information includes: S2241, The third encoded data information is processed to obtain an undirected graph G=(V,E). Let vi be the set of all entities, n be the number of entities, and vi be the i-th entity. Let be a set of edges, with a total of m edges, where ej is the j-th edge; S2242, Store the undirected graph to obtain the adjacency list data structure; S2243, perform isolated entity detection on the adjacency list data structure and delete isolated entities to obtain optimized knowledge graph data information.
5. The knowledge graph embedding method according to claim 2, characterized in that, The step of enhancing the optimized knowledge graph data to obtain preprocessed knowledge graph data includes: S231, perform correlation analysis on the optimized knowledge graph data information to obtain rule information; S232, Instantiate the rule information to obtain a new triplet; S233, perform entity completion on the new triplet to obtain an optimized new triplet; S234, integrate the optimized new triplet and the optimized knowledge graph data information to obtain preprocessed knowledge graph data information.
6. The knowledge graph embedding method according to claim 5, characterized in that, The step of performing entity completion on the new triplet to obtain an optimized new triplet includes: S2331, Process the new triplet to obtain a candidate triplet set; S2332, Process the set of candidate triples to obtain the fit score of each candidate triple; S2333, Based on the fitting score of each candidate triplet, the candidate triplet set is sorted in descending order of score to obtain an ordered triplet set; S2334, Process the ordered set of triples to obtain optimized new triples.
7. The knowledge graph embedding method according to claim 5, characterized in that, The process of performing multi-space representation processing on the preprocessed knowledge graph data to obtain initial entity vectors and initial relation vectors includes: S31, perform relation type classification processing on the preprocessed knowledge graph data information to obtain entity relation information; the entity relation information includes one-to-one relation, one-to-many relation, many-to-one relation, and many-to-many relation. S32, Perform spatial adaptation processing on the entity relationship information to obtain spatially adapted entity relationship information; S33, Perform vector initialization and normalization processing on the spatial adaptation entity relationship information to obtain the entity initial vector and the relationship initial vector.
8. A knowledge graph embedding device, characterized in that, The device includes: The information acquisition module is used to acquire raw knowledge graph data information; the raw knowledge graph data information includes N triples, entity attribute information, and entity relationship information. The preprocessing module is used to preprocess the original knowledge graph data to obtain preprocessed knowledge graph data. The multi-space representation processing module is used to perform multi-space representation processing on the preprocessed knowledge graph data information to obtain entity initial vectors and relation initial vectors. The knowledge graph embedding module is used to process the entity initial vector and the relation initial vector to obtain the knowledge graph embedding result.
9. A knowledge graph embedding device, characterized in that, The device includes: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the knowledge graph embedding method as described in any one of claims 1-7.
10. A computer-storable medium, characterized in that, The computer storage medium stores computer instructions, which, when invoked, are used to execute the knowledge graph embedding method as described in any one of claims 1-7.