Knowledge graph embedding method and system based on semantic and structure unified modeling

By fusing semantic and structural information to generate entity augmentation representations, and utilizing complex transformations and attention mechanisms to dynamically adapt to the knowledge graph context, the model adaptively generates negative samples and sets a loss function, thus solving the problems of missing links and dynamic changes in the knowledge graph and improving the model's adaptability and robustness.

CN121743508APending Publication Date: 2026-03-27Chinese People's Liberation Army Cyberspace Force Information Engineering University
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511715684.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-21
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing knowledge graphs suffer from missing links, resulting in insufficient knowledge graph integrity. Traditional methods struggle to effectively utilize the topological context and dynamic changes of the graph. Furthermore, the negative sample generation strategy is static and cannot adapt to different relational logics. The loss function is sensitive to fixed interval parameters and is difficult to adapt to different training scenarios.

Method used

By employing a knowledge graph embedding method based on unified semantic and structural modeling, we integrate the semantic and local topological information of the knowledge graph to generate entity augmentation representations. We dynamically adapt to the structural context using complex transformations and attention mechanisms, adaptively generate candidate negative samples, and set an adaptive loss function for comparative learning, thereby achieving flexible adaptation to different relation types.

Benefits of technology

It significantly improves the representation quality of sparse entities, enhances the dynamic adaptability and robustness of the model, can update the graph structure in a timely manner, generate reasonable negative samples, improve the generalization ability and training efficiency of the model, and solves the limitations of traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121743508A_ABST
    Figure CN121743508A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, in particular to a knowledge graph embedding method and system based on semantic and structure unified modeling, and the method comprises the steps: generating entity enhanced representation through fusing semantic and local topological information in a knowledge graph; performing complex number transformation on the entity enhancement representation, and dynamically adapting to the structural context of the knowledge graph based on an attention mechanism to obtain a final transformation representation; candidate negative samples are dynamically generated in a self-adaptive mode according to the relation attributes, hard negative samples are mined, and negative samples are obtained by randomly sampling the candidate negative samples and splicing the candidate negative samples with the hard negative samples; and setting a loss function according to the negative sample scale and a preset loss type, and performing comparative learning on the knowledge graph embedding model by using positive and negative samples based on the loss function. Through unified modeling of semantic information and graph structure embedding of entities and relationships in the knowledge graph, the method can be suitable for application of knowledge graph completion in scenes such as intelligent questions and answers and service recommendation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a knowledge graph embedding method and system based on unified semantic and structural modeling. Background Technology

[0002] Knowledge graphs, as a structured semantic information storage and representation model, integrate massive amounts of entities and relationships between them, and have been widely used in scenarios such as intelligent search, recommendation systems, and intelligent question-answering systems. However, due to limitations in data collection methods, manual annotation costs, and the speed of knowledge updates, existing knowledge graphs generally suffer from the problem of "missing links"—that is, some relationships that should exist between entities are not recorded, resulting in insufficient completeness of the knowledge graph and directly affecting the reliability of downstream applications.

[0003] To address the issue of incomplete knowledge graphs, "knowledge graph link prediction (also known as knowledge graph completion)" has become a research hotspot. Its core objective is to predict missing entities or relations based on existing triples and complete the semantic relationships in the knowledge graph. Among these techniques, Knowledge Graph Embedding (KGE) is widely considered an effective means of achieving link prediction due to its high modeling efficiency and superior inference performance.

[0004] Knowledge graph embedding aims to map entities and relations to a continuous vector space, quantifying the validity of triples through vector operations to support knowledge reasoning. Existing research mainly follows two directions: one is triple-based modeling methods, such as TransE and RotatE, which learn semantic associations within individual triples by designing scoring functions; the other is graph neural network-based methods, such as R-GCN and CompGCN, which capture local topological structures by aggregating information from an entity's direct neighbors. While both approaches have achieved significant success, they both have limitations: the former ignores the rich graph structural context in which an entity exists, while the latter is usually limited to shallow neighborhood information. In fact, triples in knowledge graphs do not exist in isolation but constitute complex topological contexts such as paths and subgraphs. These contexts contain key relational patterns and semantic mapping rules, directly affecting the specific meaning of entities. How to effectively model and utilize this topological context that transcends local neighbors remains a challenge for current research. Summary of the Invention

[0005] To address the problems of insufficient utilization of structural information, rigid fusion mechanisms, and difficulty in adapting to dynamic changes in knowledge graphs in existing knowledge graph embedding methods, this invention provides a knowledge graph embedding method and system based on unified semantic and structural modeling. This method can uniformly model the semantic information of entities and relationships in knowledge graphs and embed the graph structure, making it suitable for knowledge graph completion applications in scenarios such as intelligent question answering and service recommendation.

[0006] According to the design scheme provided by the present invention, on the one hand, a knowledge graph embedding method based on unified semantic and structural modeling is provided, comprising:

[0007] Complete triples are extracted from the target knowledge graph as positive samples, and entity-enhanced representations are generated based on the positive samples by fusing semantic and local topological information from the knowledge graph.

[0008] The entity augmentation representation is subjected to complex transformation and dynamically adapted to the structural context of the knowledge graph based on the attention mechanism to obtain the final transformed representation;

[0009] Candidate negative samples are dynamically generated adaptively based on relational attributes, and hard negative samples are mined from the candidate negative samples based on the similarity with positive samples. Negative samples are obtained by randomly sampling from the candidate negative samples and concatenating them with hard negative samples. The relational attributes include symmetric relational attributes and asymmetric relational attributes. The hard negative samples are negative samples whose similarity with positive samples is greater than a threshold.

[0010] A loss function is set according to the negative sample size and a preset loss type. Based on the loss function and using positive and negative samples, the knowledge graph embedding model is compared and learned to obtain a knowledge graph embedding target model. The knowledge graph embedding target model is then used to predict and output missing links in a given triple. The missing links are either the head entity or the tail entity of the triple. The preset loss type includes cross-entropy loss and boundary loss.

[0011] As a knowledge graph embedding method based on unified semantic and structural modeling of the present invention, further, entity-enhanced representations are generated based on positive samples by fusing semantic and local topological information in the knowledge graph, including:

[0012] Obtain the neighboring entities of an entity, and obtain the degree centrality feature of the entity based on the number of its direct neighbor entities;

[0013] Obtain the entity embedding vector of the entity's neighborhood, and cluster and fuse all the entity embedding vectors of the entity's neighborhood to obtain the neighborhood aggregation vector;

[0014] The original entity embedding vector, neighborhood aggregation vector, and degree centrality features are concatenated, and the corresponding entity augmentation representation is generated through a nonlinear transformation function.

[0015] As a knowledge graph embedding method based on unified semantic and structural modeling of the present invention, further, complex number transformations are performed on the entity augmentation representation, including:

[0016] By using scaling, rotation, and translation parameters to form a pair of complex vectors, the entity relationships in the entity augmentation representation can be represented using these complex vectors.

[0017] Based on complex vectors, the head and tail entities in the entity augmentation representation are embedded into the complex space through complex number operations.

[0018] As a knowledge graph embedding method based on unified semantic and structural modeling of the present invention, further comprising dynamically adapting the structural context of the knowledge graph based on an attention mechanism, including:

[0019] Apply opposite rotation transformations to the augmented head entity, thereby generating two alternative intermediate representations;

[0020] The attention coefficients of the intermediate representation are calculated using a pre-defined relation-specific attention mechanism and then weighted and fused to obtain the final transformed representation of the head entity.

[0021] The ultimate goal is to make the transformed head entity representation as close as possible to the true tail entity representation in the vector space, so as to evaluate the reasonableness of the triple (h,r,t) by measuring the closeness between the head entity and the tail entity.

[0022] As a knowledge graph embedding method based on unified semantic and structural modeling of the present invention, further, candidate negative samples are adaptively and dynamically generated based on relation attributes, including:

[0023] Construct a relation attribute dictionary for each relation in the entity, and use the relation attribute dictionary to mark whether the relation is symmetric;

[0024] Sample from the relation attribute dictionary. If the sampled relation attribute is a symmetric relation, randomly replace the head entity or the tail entity and generate candidate negative samples. If the relation attribute is an asymmetric relation, fix the tail entity and generate candidate negative samples.

[0025] As a knowledge graph embedding method based on unified semantic and structural modeling of this invention, further, hard negative samples are mined from candidate negative samples based on positive sample similarity, including:

[0026] In each training cycle, the similarity between candidate negative samples and positive samples is evaluated;

[0027] The candidate negative sample with the highest similarity is selected as the hard negative sample.

[0028] As a knowledge graph embedding method based on unified semantic and structural modeling of this invention, further, a loss function is set according to the negative sample size and a preset loss type, including:

[0029] Based on the differentiated requirements of knowledge graphs for random negative sampling and hard negative samples, the training loss is set to include cross-entropy loss and margin loss;

[0030] If negative samples exist in the batch of the knowledge graph, switch the training loss to cross-entropy loss; if the target knowledge graph explicitly specifies the training loss as Margin loss, then switch the training loss to Margin loss.

[0031] The loss function for Margin loss is expressed as: in, Where γ is the training batch size, and γ represents an adjustable boundary parameter. and Let represent the reasonableness scores of the i-th positive and negative examples, respectively.

[0032] Furthermore, this invention also provides a knowledge graph embedding system based on unified semantic and structural modeling, comprising: an entity enhancement module, an entity transformation module, a sample mining module, and a contrastive learning module, wherein...

[0033] The entity augmentation module is used to extract complete triples from the target knowledge graph as positive samples, and generate entity augmentation representations based on the positive samples by fusing semantic and local topological information in the knowledge graph.

[0034] The entity transformation module is used to perform complex transformations on the entity augmentation representation and dynamically adapt it to the structural context of the knowledge graph based on the attention mechanism to obtain the final transformed representation.

[0035] The sample mining module is used to adaptively and dynamically generate candidate negative samples based on relational attributes, and mine hard negative samples from the candidate negative samples based on the similarity with positive samples. Negative samples are obtained by randomly sampling from the candidate negative samples and concatenating them with hard negative samples. The relational attributes include symmetric relational attributes and asymmetric relational attributes. The hard negative samples are negative samples whose similarity with positive samples is greater than a threshold.

[0036] The contrastive learning module is used to set a loss function based on the size of the negative samples and a preset loss type. Based on the loss function and using positive and negative samples, the module performs contrastive learning on the knowledge graph embedding model to obtain a knowledge graph embedding target model. The module then uses the knowledge graph embedding target model to predict and output missing links in a given triple. The missing links are either the head entity or the tail entity of the triple. The preset loss type includes cross-entropy loss and boundary loss.

[0037] The beneficial effects of this invention are:

[0038] 1. This invention overcomes the limitations of traditional techniques in utilizing insufficient entity structure information by deeply fusing graph structure and semantic information, significantly improving the representation quality of sparse entities. It can dynamically adjust the utilization ratio of structural and semantic information according to different relation types, solving the problem of rigidity in the original fusion mechanism and making relation representation more accurate. Furthermore, it possesses strong dynamic adaptability, effectively responding to dynamic changes in the knowledge graph and updating the graph structure and entity representation in a timely manner, thus compensating for the shortcomings of existing technologies in handling dynamic graphs. Simultaneously, by intelligently adjusting the dependence on neighborhood information according to the sparsity of entities, it significantly enhances the ability to resist noise interference, ensuring robustness in modeling sparse entities.

[0039] 2. This invention solves the problem that traditional static strategies cannot adapt to different relational logics by introducing a dynamic negative sampling strategy based on relational attributes. It can generate more reasonable negative samples and overcome the efficiency and stability problems of hard negative sample mining. Through priority progression and backup mechanism, it ensures a stable supply of high-quality hard negative samples and avoids training fluctuations.

[0040] 3. This invention, through adaptive loss function design, achieves automatic switching of loss functions under different negative sampling strategies and training scenarios, meeting the needs of differentiated training. The improved adaptive margin loss overcomes the sensitivity of traditional margin loss to fixed interval parameters, and can flexibly adapt to different relation types, thereby achieving optimization and adaptation under all training stages and strategies, improving model performance and generalization ability. Attached image description:

[0041] Figure 1 This is a schematic diagram of the knowledge graph embedding process based on unified semantic and structural modeling in the embodiment;

[0042] Figure 2 This is a schematic diagram of the overall framework of the SumKGE model algorithm in the embodiment. Detailed implementation method:

[0043] To make the objectives, technical solutions, and advantages of this invention clearer and more understandable, the invention will be further described in detail below with reference to the accompanying drawings and technical solutions.

[0044] Existing knowledge graph embedding techniques underutilize the entity graph structure information in triples, resulting in poor quality sparse entity representations. Furthermore, they lack deep fusion mechanisms when integrating graph structure and semantic information, failing to dynamically adjust the utilization ratio based on relation type. Most techniques target static knowledge graphs, making it difficult to adapt to dynamic changes and timely updates to graph structure and entity embedding representations. They are also susceptible to noise interference when processing sparse entities and cannot reasonably adjust the dependence on neighborhood aggregation and original embedding based on entity sparsity. When dealing with sparse knowledge graphs, traditional negative sampling strategies are static, unable to dynamically adjust negative sample generation logic based on relation attributes. They also suffer from low efficiency in hard negative sample mining, difficulty in guaranteeing discriminative power, lack of effective backup strategies when high-similarity candidate entities are insufficient, and unstable hard negative sample quantity. They cannot simultaneously address the differentiated needs of random negative sampling and hard negative sampling under different knowledge graph characteristics, and cannot automatically switch loss functions to match training scenarios. Traditional Margin loss is sensitive to fixed interval parameters, making it difficult to flexibly adapt to different relation types and achieve self-adaptation across different training stages, relation types, and negative sampling strategies. Therefore, this invention provides embodiments, see [link to embodiments]. Figure 1 As shown, a knowledge graph embedding method based on unified semantic and structural modeling is provided, which specifically includes the following:

[0045] S101. Extract complete triples from the target knowledge graph as positive samples, and generate entity-enhanced representations based on the positive samples by fusing semantic and local topological information in the knowledge graph.

[0046] Specifically, entity augmentation representations generated based on positive samples by fusing semantic and local topological information from the knowledge graph can be designed to include:

[0047] Obtain the neighboring entities of an entity, and obtain the degree centrality feature of the entity based on the number of its direct neighbor entities;

[0048] Obtain the entity embedding vector of the entity's neighborhood, and cluster and fuse all the entity embedding vectors of the entity's neighborhood to obtain the neighborhood aggregation vector;

[0049] The original entity embedding vector, neighborhood aggregation vector, and degree centrality features are concatenated, and the corresponding entity augmentation representation is generated through a nonlinear transformation function.

[0050] In the exemplary embodiment of this case, when the target knowledge graph is an intelligent question-answering knowledge graph about historical figures, entities are used to represent specific objects such as historical figures, events, times, and places. Edges are used to represent the relationships between entities, such as "participated," "occurred in," and "led." Attributes describe the specific characteristics of the entities.

[0051] like Figure 2The SumKGE model shown demonstrates its ability to construct enhanced entity representations that simultaneously encode semantics and local topological structure for a given knowledge graph. (where ε is the entity set,) For a set of relations, (a set of triplets) where any entity e∈ε, is represented by the structure-enhanced representation. The generation process can be summarized as follows:

[0052] 1. Neighborhood Feature Extraction: First, calculate the degree centrality feature 0 (i.e., the number of neighbors) d(e) of an entity, which is the number of its direct neighbors. This scalar feature serves as a preliminary measure of the connectivity of entities in the graph.

[0053] 2. Neighborhood Semantic Aggregation: Next, mean pooling is used as the basic aggregation function (AGGREGATE) for all neighboring entities of entity e. The embedded vectors are fused to generate a neighborhood aggregation vector. This step encodes the collective semantic information of the local neighborhood into a unified vector representation, enabling the representation of the target entity to perceive local topological relationships.

[0054] 3. Adaptive Information Fusion: Finally, the original entity embedding vector e and the neighborhood aggregation vector are combined... The degree centrality features d(e) (mapped to vectors via embedding) are concatenated. This involves concatenating vectors and generating structure-enhanced entity representations using a nonlinear transformation function φ (such as ReLU).

[0055]

[0056] By fusing semantic and local topological information, a structure-enhanced entity representation is constructed. The model performs a three-step enhancement for each entity: first, it extracts its degree centrality features; then, it aggregates the embeddings of its neighboring entities to obtain topological associations; finally, it concatenates the original embeddings, the aggregated neighborhood vectors, and the degree centrality vectors and performs a nonlinear transformation to generate the enhanced representation.

[0057] S102. Perform complex transformations on the entity augmentation representation and dynamically adapt it to the structural context of the knowledge graph based on the attention mechanism to obtain the final transformed representation.

[0058] Specifically, a pair of complex vectors can be formed using scaling, rotation, and translation parameters. The complex vectors can be used to represent entity relationships in entity augmentation representation. Based on the complex vectors, the head entity and tail entity in entity augmentation representation can be embedded into the complex space through complex number operations.

[0059] The augmented head entity is then subjected to opposite rotational transformations (up and down), generating two alternative intermediate representations. Subsequently, a relation-specific attention module computes the attention coefficients of these two representations and weights them together to form the final transformed representation of the head entity.

[0060] To achieve accurate modeling of complex relational patterns (such as symmetric and antisymmetric) and enable them to dynamically adapt to different structural contexts, SumKGE integrates structurally enhanced entities into an innovative complex transformation and attention mechanism.

[0061] First, the augmented head entity h and tail entity t are embedded into the n-dimensional complex space. In this context, the relation r is determined by a pair of complex vectors. It means that a r ,b r These represent the scaling, rotation, and translation parameters, respectively. The core process of complex transformation is to embed the entity and transform it relationally. That is, by using complex number operations, the head entity h is rotated by an angle θ and scaled by |a r |times, then shift by b r .

[0062]

[0063] Here, ⊙ represents element-wise complex multiplication, which rotates the entity vector (by a). r The argument is determined by the angle of the scale (and the scaling is determined by a). r (The length of the model is determined by the model length); To perform element-wise complex number addition, a translation transformation is implemented.

[0064] This operation supports relationships that preserve symmetry, antisymmetry, combination, hierarchy, and other patterns. For example, symmetric relationships can be achieved by "rotating angle θ≈0 and scaling |a|≈1", while antisymmetric relationships can be achieved by "rotating angle θ≈π".

[0065] Then, to dynamically capture the most critical transformation patterns in different scenarios, SumKGE further introduces an attention mechanism on top of the structure-enhanced entity representation, dynamically fusing multiple potential transformation patterns. Specifically, the model pre-sets a set of basic rotation operations for each relation r, generating multiple candidate transformation results. Finally, the query vector is obtained:

[0066]

[0067] in, It is the attention coefficient of subject h under relation r, where k = u represents upward rotation of h. u k = d indicates a downward rotation h d h uThis indicates the embedding of the main body after it has been rotated upwards; h d This indicates the embedding of the main body after it has been rotated downwards.

[0068] Through the above design, the mechanism achieves a balance between interpretability and adaptability: the final transformed entity retains the set interpretability of complex transformations, and also achieves dynamic adaptation to the structural context through the attention mechanism, thereby improving the model's ability to handle complex relationships.

[0069] S103. Adaptively and dynamically generate candidate negative samples based on relational attributes, and mine hard negative samples from the candidate negative samples according to the similarity with positive samples. Obtain negative samples by randomly sampling from the candidate negative samples and concatenating them with hard negative samples. The relational attributes include symmetric relational attributes and asymmetric relational attributes. The hard negative samples are negative samples whose similarity with positive samples is greater than a threshold.

[0070] Specifically, a relation attribute dictionary can be constructed for each relation in the entity to mark whether the relation is symmetric; samples are taken from the relation attribute dictionary. If the sampled relation attribute is a symmetric relation, the head entity or tail entity is randomly replaced and candidate negative samples are generated; if the relation attribute is an asymmetric relation, the corresponding tail entity is fixedly replaced and candidate negative samples are generated.

[0071] When mining hard negative samples from candidate negative samples based on positive sample similarity, the similarity between candidate negative samples and positive samples can be evaluated in each training cycle; the candidate negative sample with the highest similarity is selected as the hard negative sample.

[0072] To effectively address the data sparsity of knowledge graphs and improve training efficiency, the SumKGE model introduces an adaptive negative sampling module and a multi-level hard negative sample mining technique during the training phase. Its core principle is to dynamically adjust the generation logic of negative samples based on relational attributes.

[0073] First, for each relation r i Construct a relation attribute dictionary Where symmetric∈{True,False} is used to indicate whether the relation is symmetric.

[0074] During sampling, the model dynamically determines whether to replace the head entity or the tail entity to generate negative examples based on the symmetry property of the relationship:

[0075]

[0076] Here, replace_pos = 0 indicates replacing the head entity, and replace_pos = 2 indicates replacing the tail entity. If symmetric = True (symmetric relation), the head or tail entity is randomly replaced with a uniform probability of 0.5; if symmetric = False (asymmetric relation), the tail entity is fixed to be replaced to avoid generating false negatives such as (Beijing, Capital, China) which are logically reversed, for example, (China, Capital, Beijing).

[0077] Secondly, to further enhance the model's ability to distinguish subtle semantic differences, this invention designs a progressive hard negative sample introduction mechanism. Balancing early-stage stability with later-stage fine-tuning, the proportion of hard negative samples (negative examples with high similarity to positive examples) introduced by the model is ρ. h With the starting round E s The negative sample set is defined as random negative samples. With hard negative samples Union of:

[0078]

[0079] The number of hard negative samples is K is the total number of negative samples corresponding to each positive example. Here, E is the indicator function, and E is the current training round.

[0080] Adaptive negative sampling addresses the data sparsity problem in knowledge graphs by dynamically adjusting the negative sample generation strategy based on relation attributes: for symmetric relations, the head or tail entity is randomly replaced; for asymmetric relations, the tail entity is fixed, thus avoiding false negatives with logical errors. A three-level sampling architecture with "priority progression" is constructed, integrating a scale-based dynamic index selection mechanism to obtain high-quality hard negative samples. This architecture first uses FAISS for approximate nearest neighbor search to quickly locate high-similarity candidates; if the results are insufficient, random selection is made from a dynamically constructed pool of high-similarity candidates; if the last two levels fail, it reverts to random sampling to ensure stable acquisition of hard negative samples while maintaining high discriminative power. Simultaneously, the optimal FAISS index (such as FlatIP, IVFFlat, IVFPQ) is dynamically selected based on the entity scale of the knowledge graph, and GPU acceleration is supported. This reduces the time complexity of hard negative sample search from O(∣E∣) to O(log∣E∣), solving the efficiency bottleneck of hard negative sample mining in large-scale knowledge graphs and providing key support for efficient model training.

[0081] S104. Set the loss function according to the negative sample size and the preset loss type. Based on the loss function and using positive and negative samples, perform comparative learning on the knowledge graph embedding model to obtain the knowledge graph embedding target model. Use the knowledge graph embedding target model to predict and output the missing links in the given triples. The missing links are the head entity or tail entity of the triples. The preset loss type includes cross-entropy loss and boundary loss.

[0082] Specifically, based on the differentiated requirements of the knowledge graph for random negative sampling and hard negative samples, the training loss can be set to include cross-entropy loss and margin loss; if there are negative samples in the current batch of the knowledge graph, the training loss can be switched to cross-entropy loss; if the target knowledge graph explicitly specifies the training loss as margin loss.

[0083] To address the varying needs of random negative sampling and hard negative samples under different knowledge graph characteristics (sparseness, relation type), SumKGE proposes an adaptive loss function module. Its principle is to automatically switch the loss function based on the negative sample size and a preset loss type to match the training scenario. When negative samples are present in the batch, cross-entropy loss is activated. If the margin type is explicitly specified (loss_type = 'margin'), then the loss mode is switched to Margin loss.

[0084] To overcome the sensitivity of traditional Margin loss to fixed interval parameters, SumKGE designed an enhanced Margin loss, making the loss function more flexible and adaptable to different relation types: For strong constraints such as symmetric and antisymmetric relationships, a larger γ is assigned to force the model to learn clearer decision boundaries on key relationships; for weak or sparse relationships, γ is appropriately reduced to avoid underfitting caused by excessive penalty.

[0085] Based on the number and preset type of negative samples, it automatically switches between cross-entropy loss and boundary loss. More importantly, it enhances traditional boundary loss by dynamically adjusting boundary parameters for different relationship types: setting larger boundaries for strong constraints to strengthen decision differentiation, and reducing boundaries for sparse or weak relationships to prevent overfitting. This design allows the loss function to flexibly respond to different training scenarios, relationship logic, and sampling strategies, achieving true adaptive optimization.

[0086] After sufficient training, embedding vectors for entities and relations are obtained. These embedding vectors contain semantic representations of entities and relations in a low-dimensional vector space, capturing the topological context between them and enhancing the model's ability to understand and extract entities and relations from text. The link prediction task can then be performed.

[0087] Furthermore, based on the above method, this invention also provides a knowledge graph embedding system based on unified semantic and structural modeling, comprising: an entity enhancement module, an entity transformation module, a sample mining module, and a contrastive learning module, wherein...

[0088] The entity augmentation module is used to extract complete triples from the target knowledge graph as positive samples, and generate entity augmentation representations based on the positive samples by fusing semantic and local topological information in the knowledge graph.

[0089] The entity transformation module is used to perform complex transformations on the entity augmentation representation and dynamically adapt it to the structural context of the knowledge graph based on the attention mechanism to obtain the final transformed representation.

[0090] The sample mining module is used to adaptively and dynamically generate candidate negative samples based on relational attributes, and mine hard negative samples from the candidate negative samples based on the similarity with positive samples. Negative samples are obtained by randomly sampling from the candidate negative samples and concatenating them with hard negative samples. The relational attributes include symmetric relational attributes and asymmetric relational attributes. The hard negative samples are negative samples whose similarity with positive samples is greater than a threshold.

[0091] The contrastive learning module is used to set a loss function based on the size of the negative samples and a preset loss type. Based on the loss function and using positive and negative samples, the module performs contrastive learning on the knowledge graph embedding model to obtain a knowledge graph embedding target model. The module then uses the knowledge graph embedding target model to predict and output missing links in a given triple. The missing links are either the head entity or the tail entity of the triple. The preset loss type includes cross-entropy loss and boundary loss.

[0092] Unless otherwise specifically stated, the relative steps, numerical expressions, and values ​​of the components and steps described in these embodiments do not limit the scope of the invention.

[0093] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.

[0094] The units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations are not considered to be beyond the scope of this invention.

[0095] Those skilled in the art will understand that all or part of the steps in the above methods can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk. Optionally, all or part of the steps in the above embodiments can also be implemented using one or more integrated circuits. Accordingly, each module / unit in the above embodiments can be implemented in hardware or as a software functional module. This invention is not limited to any particular combination of hardware and software.

[0096] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, 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, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A knowledge graph embedding method based on unified semantic and structural modeling, characterized in that, Include: Complete triples are extracted from the target knowledge graph as positive samples, and entity-enhanced representations are generated based on the positive samples by fusing semantic and local topological information from the knowledge graph. The entity augmentation representation is subjected to complex transformation and dynamically adapted to the structural context of the knowledge graph based on the attention mechanism to obtain the final transformed representation; Candidate negative samples are dynamically generated adaptively based on relational attributes, and hard negative samples are mined from the candidate negative samples based on the similarity with positive samples. Negative samples are obtained by randomly sampling from the candidate negative samples and concatenating them with hard negative samples. The relational attributes include symmetric relational attributes and asymmetric relational attributes. The hard negative samples are negative samples whose similarity with positive samples is greater than a threshold. A loss function is set according to the negative sample size and a preset loss type. Based on the loss function and using positive and negative samples, the knowledge graph embedding model is compared and learned to obtain a knowledge graph embedding target model. The knowledge graph embedding target model is then used to predict and output missing links in a given triple. The missing links are either the head entity or the tail entity of the triple. The preset loss type includes cross-entropy loss and boundary loss.

2. The knowledge graph embedding method based on unified semantic and structural modeling according to claim 1, characterized in that, Based on positive samples, entity augmentation representations are generated by fusing semantic and local topological information from the knowledge graph, including: Obtain the neighboring entities of an entity, and obtain the degree centrality feature of the entity based on the number of its direct neighbor entities; Obtain the embedding vectors of neighboring entities, and cluster and fuse all the embedding vectors of neighboring entities of an entity to obtain the neighborhood aggregation vector; The original entity embedding vector, neighborhood aggregation vector, and degree centrality features are concatenated, and the corresponding entity augmentation representation is generated through a nonlinear transformation function.

3. The knowledge graph embedding method based on unified semantic and structural modeling according to claim 1, characterized in that, Complex transformations are performed on the entity augmentation representation, including: A pair of complex vectors is formed using scaling, rotation, and translation parameters, and these complex vectors are used to represent entity relationships in entity augmentation representation. Based on complex vectors, the head and tail entities in the entity augmentation representation are embedded into the complex space through complex number operations.

4. The knowledge graph embedding method based on unified semantic and structural modeling according to claim 1 or 3, characterized in that, Dynamically adapting the structural context of the knowledge graph based on the attention mechanism, including: Apply opposite rotation transformations to the augmented head entity, thereby generating two alternative intermediate representations; The attention coefficients of the intermediate representation are calculated using a pre-defined relation-specific attention mechanism and then weighted and fused to obtain the final transformed representation of the head entity.

5. The knowledge graph embedding method based on unified semantic and structural modeling according to claim 1, characterized in that, Candidate negative samples are dynamically generated adaptively based on relational attributes, including: Construct a relation attribute dictionary for each relation in the entity, and use the relation attribute dictionary to mark whether the relation is symmetric; Sample from the relation attribute dictionary. If the sampled relation attribute is a symmetric relation, randomly replace the head entity or the tail entity and generate candidate negative samples. If the relation attribute is an asymmetric relation, fix the tail entity and generate candidate negative samples.

6. The knowledge graph embedding method based on unified semantic and structural modeling according to claim 1, characterized in that, Hard negative samples are extracted from candidate negative samples based on positive sample similarity, including: In each training cycle, the similarity between candidate negative samples and positive samples is evaluated; The candidate negative sample with the highest similarity is selected as the hard negative sample.

7. The knowledge graph embedding method based on unified semantic and structural modeling according to claim 1, characterized in that, The loss function is set according to the negative sample size and the preset loss type, including: Based on the differentiated requirements of knowledge graphs for random negative sampling and hard negative samples, the training loss is set to include cross-entropy loss and margin loss; If negative samples exist in the batch of the knowledge graph, switch the training loss to cross-entropy loss; if the target knowledge graph explicitly specifies the training loss as Margin loss, then switch the training loss to Margin loss. The loss function for Margin loss is expressed as: in, Where γ is the training batch size, and γ represents an adjustable boundary parameter. and Let represent the reasonableness scores of the i-th positive and negative examples, respectively.

8. A knowledge graph embedding system based on unified semantic and structural modeling, characterized in that, It includes: an entity augmentation module, an entity transformation module, a sample mining module, and a contrastive learning module. The entity augmentation module is used to extract complete triples from the target knowledge graph as positive samples, and generate entity augmentation representations based on the positive samples by fusing semantic and local topological information in the knowledge graph. The entity transformation module is used to perform complex transformations on the entity augmentation representation and dynamically adapt it to the structural context of the knowledge graph based on the attention mechanism to obtain the final transformed representation. The sample mining module is used to adaptively and dynamically generate candidate negative samples based on relational attributes, and mine hard negative samples from the candidate negative samples based on the similarity with positive samples. Negative samples are obtained by randomly sampling from the candidate negative samples and concatenating them with hard negative samples. The relational attributes include symmetric relational attributes and asymmetric relational attributes. The hard negative samples are negative samples whose similarity with positive samples is greater than a threshold. The contrastive learning module is used to set a loss function based on the size of the negative samples and a preset loss type. Based on the loss function and using positive and negative samples, the module performs contrastive learning on the knowledge graph embedding model to obtain a knowledge graph embedding target model. The module then uses the knowledge graph embedding target model to predict and output missing links in a given triple. The missing links are either the head entity or the tail entity of the triple. The preset loss type includes cross-entropy loss and boundary loss.

9. An electronic device, characterized in that, include: At least one processor, and a memory coupled to said at least one processor; The memory stores a computer program that can be executed by the at least one processor to implement the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed, enables the implementation of the method as described in any one of claims 1 to 7.