Knowledge graph completion method and device, electronic equipment, computer storage medium and program product
Patent Information
- Application Number
- CN202611007561.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-07
- Publication Date
- 2026-10-16
AI Technical Summary
但现有技术在实际应用过程中,仍存在较多缺陷,易出现大模型领域幻觉、语义与结构信息脱节、补全结果虚假匹配的问题,对垂直专业领域的适配性不足,难以同时保障知识图谱补全的精准度与泛化能力
[0019]The knowledge graph completion method, apparatus, electronic device, and computer storage medium of this application embodiment obtain triples from a domain knowledge graph, construct a corresponding domain knowledge base based on the triples in the domain knowledge graph, and provide a unique and compliant source of professional knowledge for large models by obtaining domain knowledge graph triples and constructing a dedicated domain knowledge base. This not only avoids the domain illusion problem of general large models from the root, but also realizes the pre-textualization of the inherent structural information of the knowledge graph. By generating entity descriptions, relation descriptions, and natural language text sequences corresponding to the triples through the large model, the low semantic density structured triples are transformed into continuous text rich in professional semantics and structural information. This makes up for the shortcomings of traditional triples, such as insufficient semantic information and deviation between professional semantics and general semantics. Text vectorization is completed through a pre-trained embedding model. Combined with joint optimization of structural information learning and supervised contrastive learning, a fused vector that integrates semantic and structural information is generated. This solves the problems of semantic and structural disconnect and false matching in traditional semantic embedding methods. It can be adapted to completion scenarios in various vertical professional fields, thereby improving the accuracy and generalization ability of domain knowledge graph completion.
Smart Images

Figure CN122927477A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a knowledge graph completion method, apparatus, electronic device, computer storage medium, and program product. Background Technology
[0002] Knowledge graphs are a structured knowledge organization form with triples as the core knowledge unit. They are widely used in artificial intelligence scenarios such as knowledge management, intelligent decision-making, and intelligent question answering. Vertical domain knowledge graphs are the core foundational support for the intelligent construction of various industries. Knowledge graph completion technology is used to predict and supplement missing triples in a knowledge graph, and is a key technology for improving the knowledge graph system and mining implicit related knowledge.
[0003] Currently, knowledge graph completion technologies have developed multiple implementation paths and have been applied to some extent in general knowledge graph scenarios. However, existing technologies still have many shortcomings in practical applications, such as domain illusions in large models, disconnect between semantic and structural information, and false matching of completion results. They also lack adaptability to vertical professional fields and cannot simultaneously guarantee the accuracy and generalization ability of knowledge graph completion. Summary of the Invention
[0004] This application provides a knowledge graph completion method, apparatus, electronic device, computer storage medium, and program product, which can improve the accuracy and generalization ability of domain knowledge graph completion.
[0005] On one hand, embodiments of this application provide a knowledge graph completion method. The method includes: obtaining triples in a domain knowledge graph; constructing a corresponding domain knowledge base based on the triples in the domain knowledge graph; obtaining entity descriptions and relation descriptions of the triples in the domain knowledge base through a large model; generating natural language text sequences corresponding to the triples based on the entity descriptions and relation descriptions; generating text embedding vectors corresponding to the natural language text sequences based on a pre-trained embedding model; and performing structural information learning and supervised comparative learning of positive and negative samples based on the text embedding vectors and the inherent structural information of the domain knowledge graph to obtain semantic structure fusion vectors corresponding to the triples.
[0006] In some possible approaches, entity and relation descriptions of triples in a domain knowledge base are obtained through a large model, and natural language text sequences corresponding to the triples are generated based on the entity and relation descriptions. Specifically, this includes generating entity and relation descriptions for triples based on a preset instruction template and a domain knowledge base, using the domain expert roles in the preset instruction template, and obtaining the corresponding natural language text sequences.
[0007] In some possible approaches, based on a preset instruction template and a domain knowledge base, entity descriptions and relation descriptions are generated for triples using domain expert roles in the preset instruction template, resulting in a corresponding natural language text sequence. Specifically, this includes: extracting the head entity domain information, relation domain information, and tail entity domain information of the corresponding triples from the domain knowledge base; extracting the head entity description, relation description, and tail entity description of the corresponding triples based on the head entity domain information, relation domain information, and tail entity domain information; and generating a natural language text sequence based on the head entity, head entity description, relation, relation description, tail entity, and tail entity description.
[0008] In some possible approaches, based on the professional domain information of the head entity, the professional domain information of the relationship, and the professional domain information of the tail entity, the head entity description, relationship description, and tail entity description of the corresponding triples are extracted respectively. Specifically, this includes: extracting the core domain definition of the head entity from the professional domain information of the head entity, and obtaining the associated neighbor entities and associated domain attribute information of the corresponding head entity in the domain knowledge graph, and generating the head entity description based on the core domain definition, associated neighbor entities, and associated domain attribute information; extracting the core domain definition of the relationship and associated business rules and constraints information from the professional domain information of the relationship, and generating the relationship description based on the core domain definition and associated business rules and constraints information; extracting the core domain definition of the tail entity from the professional domain information of the tail entity, and obtaining the associated neighbor entities and associated domain attribute information of the corresponding tail entity in the domain knowledge graph, and generating the tail entity description based on the core domain definition, associated neighbor entities, and associated domain attribute information.
[0009] In some possible ways, text embedding vectors corresponding to natural language text sequences are generated based on pre-trained embedding models. Specifically, this includes: obtaining preset sequence markers, which include at least sequence start markers, sequence segment markers, and domain-specific markers; generating standardized input sequences by sequentially inserting sequence start markers and sequence segment markers into multiple natural language sequence segments and assigning domain-specific markers to each natural language sequence segment; and inputting the standardized input sequences into the pre-trained embedding model.
[0010] In some possible approaches, the joint loss function of the pre-trained embedding model includes a structural loss term and a supervised contrastive loss term. The process involves generating text embedding vectors corresponding to natural language text sequences based on the pre-trained embedding model, and then performing structural information learning and supervised contrastive learning of positive and negative samples based on the inherent structural information of the text embedding vectors and the domain knowledge graph to obtain the semantic structure fusion vector corresponding to the triples. Specifically, this includes: generating text embedding vectors corresponding to natural language text sequences based on the pre-trained embedding model; calculating the structural loss value corresponding to the inherent structural information of the domain knowledge graph using the structural loss term in the joint loss function of the pre-trained embedding model; calculating the contrastive loss value between the text embedding vectors corresponding to the positive and negative samples of the triples using the supervised contrastive loss term in the joint loss function of the pre-trained embedding model; determining the joint loss value of the joint loss function based on the structural loss value and the contrastive loss value; and adjusting the model parameters of the pre-trained embedding model based on the joint loss value until the iteration stopping condition is met to obtain the semantic structure fusion vector of the triples.
[0011] In some possible approaches, before calculating the structural loss value corresponding to the text embedding vector and the inherent structural information of the domain knowledge graph, the following steps are included: extracting entity association features and topological structure features from the text embedding vector; and generating the inherent structural information of the domain knowledge graph based on the entity association features and topological structure features.
[0012] In some possible approaches, before calculating the contrastive loss between the text embedding vectors corresponding to the positive and negative samples of the triples, the following steps are taken: identifying all real-world triples in the domain knowledge graph as positive samples; and generating negative samples by performing entity replacement processing based on the positive samples.
[0013] In some possible ways, entity replacement processing is performed based on positive samples to generate negative samples. Specifically, this includes: selecting entities other than the original tail entity of the corresponding positive sample from the full entity set of the domain knowledge graph, replacing the tail entity of the corresponding positive sample, and generating the corresponding negative sample; and / or, using the head entity of the corresponding positive sample as the replacement entity to replace the tail entity of the corresponding positive sample and generating the corresponding negative sample.
[0014] In some possible ways, the joint loss function is calculated as follows: Where L is the joint loss value corresponding to the joint loss function, G is the set of all real triples in the domain knowledge graph, h is the head entity of the triple, r is the relation of the triple, and t is the tail entity of the triple; Pr(h|r,t) is the matching probability of head entity h given relation r and tail entity t, Pr(r|h,t) is the matching probability of relation r given head entity h and tail entity t, and Pr(t|h,r) is the matching probability of tail entity t given head entity h and relation r; P is the set of positive samples, N is the set of negative samples, score(h,r,t) is the structure score of positive sample triples, score(h,r,t′) is the structure score of negative sample triples, y is the sample label, y=1 for positive samples and y=0 for negative samples, used to distinguish between positive and negative samples, and τ is the temperature hyperparameter.
[0015] On the other hand, embodiments of this application provide a knowledge graph completion device, which includes: a first acquisition unit, used to acquire triples in a domain knowledge graph and construct a corresponding domain knowledge base based on the triples in the domain knowledge graph; a first processing unit, used to obtain entity descriptions and relation descriptions of triples in the domain knowledge base through a large model, and generate natural language text sequences corresponding to the triples based on the entity descriptions and relation descriptions; and a second processing unit, used to generate text embedding vectors corresponding to the natural language text sequences based on a pre-trained embedding model, and perform structural information learning and supervised comparative learning of positive and negative samples based on the text embedding vectors and the inherent structural information of the domain knowledge graph to obtain semantic structure fusion vectors corresponding to the triples.
[0016] In another aspect, embodiments of this application provide an electronic device, which includes: a processor and a memory storing computer program instructions; the processor executes the computer program instructions to implement a knowledge graph completion method.
[0017] In another aspect, embodiments of this application provide a computer storage medium on which computer program instructions are stored, and when the computer program instructions are executed by a processor, a knowledge graph completion method is implemented.
[0018] In another aspect, embodiments of this application provide a computer program product in which instructions are executed by the processor of an electronic device, causing the electronic device to perform a knowledge graph completion method.
[0019] The knowledge graph completion method, apparatus, electronic device, and computer storage medium of this application embodiment obtain triples from a domain knowledge graph, construct a corresponding domain knowledge base based on the triples in the domain knowledge graph, and provide a unique and compliant source of professional knowledge for large models by obtaining domain knowledge graph triples and constructing a dedicated domain knowledge base. This not only avoids the domain illusion problem of general large models from the root, but also realizes the pre-textualization of the inherent structural information of the knowledge graph. By generating entity descriptions, relation descriptions, and natural language text sequences corresponding to the triples through the large model, the low semantic density structured triples are transformed into continuous text rich in professional semantics and structural information. This makes up for the shortcomings of traditional triples, such as insufficient semantic information and deviation between professional semantics and general semantics. Text vectorization is completed through a pre-trained embedding model. Combined with joint optimization of structural information learning and supervised contrastive learning, a fused vector that integrates semantic and structural information is generated. This solves the problems of semantic and structural disconnect and false matching in traditional semantic embedding methods. It can be adapted to completion scenarios in various vertical professional fields, thereby improving the accuracy and generalization ability of domain knowledge graph completion. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating a knowledge graph completion method provided in one embodiment of this application; Figure 2 This is a schematic diagram illustrating the specific process of generating semantic structure fusion vectors corresponding to triples according to an embodiment of this application; Figure 3 A flowchart illustrating a specific embodiment of the knowledge graph completion method according to this application is shown. Figure 4 This is a schematic diagram of the knowledge graph completion device provided in the embodiments of this application; Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0022] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0023] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0024] It should be noted that the acquisition, storage, use, and processing of data in this application embodiment all comply with the relevant provisions of national laws and regulations.
[0025] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.
[0026] Knowledge graphs are a form of knowledge organization that uses triples as core knowledge units to structurally represent the relationships between entities. Vertical domain knowledge graphs, such as those in telecommunications, industrial manufacturing, and financial risk control, serve as the core foundation for AI applications like intelligent decision-making, knowledge management, and intelligent question answering. Knowledge graph completion technology, used to predict and supplement missing triples in a knowledge graph, is a core technology for improving knowledge graph coverage, uncovering implicit connections, and enhancing the application value of knowledge graphs. Existing technologies, traditional knowledge graph completion techniques are mainly divided into translation model-based completion methods and graph neural network-based completion methods. Translation model-based completion methods, by mapping entities and relations to low-dimensional vectors, can only capture the structured topological information of the knowledge graph and cannot uncover the deep semantic information behind entities and relations. Especially in vertical professional domains, entities and relations have strong domain-specific semantics and business constraints. This type of method cannot eliminate the discrepancy between general semantics and professional semantics, and its completion accuracy and generalization ability drop significantly when dealing with sparse domain knowledge graphs. Although graph neural network-based completion methods can capture the global topological features of the graph, they still suffer from insufficient semantic information mining and poor adaptability to domain business rules, thus failing to meet the completion needs of vertical domain knowledge graphs.
[0027] With the development of large language model technology, knowledge graph completion methods based on large language models have emerged. These methods leverage the semantic understanding and generation capabilities of large language models to convert structured triples into natural language text and then embed them semantically. However, general-purpose large language models lack the constraints of dedicated vertical domain knowledge bases, making them prone to domain illusions. The generated content does not conform to domain professional standards and business rules, resulting in a lack of professional accuracy in the completion results. Existing methods only perform simple textual conversion on the triples, failing to integrate the inherent topological structure information of the knowledge graph, entity neighbor relationships, and domain business rules into the text content beforehand. This leads to a disconnect between the generated text embedding vectors and the structural information of the knowledge graph, failing to simultaneously consider semantic representation and structural constraints. The structural rationality of the completion results is insufficient. Existing methods have a single model training and optimization objective, focusing only on semantic matching degree or structural fit degree, without achieving end-to-end joint optimization of structural information learning and supervised comparative learning. This makes them prone to false matching due to high text overlap, further affecting the accuracy of knowledge graph completion, and they cannot flexibly adapt to completion scenarios in different vertical domains.
[0028] The following description, in conjunction with the accompanying drawings, details a knowledge graph completion method, apparatus, electronic device, computer storage medium, and computer program product provided in this application, through specific embodiments and application scenarios.
[0029] This application provides a knowledge graph completion method, such as... Figure 1As shown, the method includes the following steps: S100: Obtain triples from the domain knowledge graph and construct the corresponding domain knowledge base based on the triples from the domain knowledge graph; In this context, a triple in a domain knowledge graph refers to the smallest structured knowledge representation unit of a knowledge graph within a specific professional domain. Specifically, it can consist of a head entity, a relation, and a tail entity, used to accurately describe the directional and interpretable relationships between two entities within that professional domain. It should be understood that the head and tail entities are professional entities with unique business identifiers within that specific professional domain, such as "optical fiber," "5G core network," "base station," and "broadband access server" in the communications field. Relationships are professional predicates describing directional relationships between two entities, such as business logic, attribute associations, hierarchical affiliation, causal effects, and deployment dependencies, for example, "promote," "provide," "include," "deployed in," and "support." Triples are the core processing object of the knowledge graph completion method in this application. The core objective of this method is to predict and supplement missing triples in the domain knowledge graph through model learning.
[0030] The domain knowledge base is a dedicated collection of professional knowledge built for a single professional domain. It serves as a specialized knowledge base for providing precise domain knowledge to the large model in this application, constructed based on the full set of triples in the domain knowledge graph and accompanying domain-specific materials. Specifically, the domain knowledge base may include official standard definitions and professional definitions of entities and relationships corresponding to the full set of triples in the domain knowledge graph; unstructured professional materials such as standards, business rules, technical documents, equipment parameters, and attribute descriptions within the domain; structured topological knowledge such as the associated neighboring entities, topological association information, and hierarchical relationships of each entity in the triple in the domain knowledge graph; and supplementary information such as business background and application scenarios corresponding one-to-one with the triples in the domain knowledge graph. In this application, the domain knowledge base is the sole compliant knowledge source for generating entity and relationship descriptions for triples in the large model. Specifically, through retrieval-enhanced generation technology, the large model is constrained to generate descriptive text solely based on precise domain knowledge within the knowledge base, fundamentally avoiding the domain illusion problem inherent in general large models. Meanwhile, the structural information such as entity neighbors and topological relationships stored in the knowledge base is used to transform the inherent structural information of the knowledge graph into text semantics and integrate it into the natural language text sequence, making up for the shortcomings of traditional semantic embedding methods in making insufficient use of the structural information of the knowledge graph.
[0031] S110: Through a large model, obtain entity descriptions and relation descriptions of triples in the domain knowledge base, and generate natural language text sequences corresponding to the triples based on the entity descriptions and relation descriptions; The large-scale model in this application is an artificial intelligence model pre-trained on massive amounts of text data, possessing natural language understanding, contextual reasoning, and text generation capabilities. In this solution, the large-scale model is the core execution entity for converting structured triples into semantic text. Specifically, it can work with pre-defined instruction templates, prompts, and domain expert role-playing constraints to generate content according to specified formats, professional perspectives, and word count limits, ensuring that the output conforms to domain-specific professional standards. It should be understood that the large-scale model transforms highly structured, low-semantic-density triples in a knowledge graph into natural language text rich in domain-specific semantics while incorporating graph structure information, providing high-quality input for subsequent semantic embedding.
[0032] The entity description, specifically, refers to the head and tail entities in the triplet. It is a textual interpretation and supplementary explanation generated from a domain knowledge base, conforming to the specifications of the corresponding professional domain. It supplements the semantic and structured information of the structured entity identifier. Specifically, it can include the core domain definition of the entity in the corresponding professional domain, such as the technical definition of "optical fiber" in the telecommunications field; and the entity's associated neighboring entities and related domain attribute information in the domain knowledge graph, such as the associated entities "5G core network" and "broadband access server" for "optical fiber." This transforms the inherent structural information of the knowledge graph into textual semantics. Specifically, it can be generated by a large model based on the domain knowledge base and according to preset domain expert roles, strictly adhering to the professional domain context and containing no false content beyond the domain knowledge base. On the one hand, it compensates for the low semantic information density of traditional structured triplets, enhancing the generalization of subsequent semantic embedding; on the other hand, it integrates the topological structure information of the knowledge graph into the text, solving the problem that traditional semantic embedding methods cannot directly capture graph structure information.
[0033] The relation description, generated from a domain knowledge base, is a textual interpretation of the relation predicates within the triples, corresponding to the business rules and constraints of the relevant professional domain. It serves as a professional semantic supplement to the structured relation identifiers. Specifically, it includes the core domain meaning of the relation within its corresponding professional domain, as well as the associated business rules, constraints, and applicable scenarios. For example, in the telecommunications field, "promote" corresponds to the technical support logic and business association rules. This can be achieved by having the relation originate from the entity description, generated by a large model based on the domain knowledge base and according to domain expert roles. This ensures that the semantics of the relation conform to the business logic of the professional domain, rather than the broad semantics of general natural language. This eliminates the discrepancy between general semantics and domain-specific semantics, allowing the pre-trained embedding model to accurately capture the professional semantic features of the relation, further improving the accuracy of triple semantic embedding.
[0034] The natural language text sequence in this application is a complete, fluent natural language text string that conforms to domain-specific expression norms, organized according to preset format rules, consisting of head entity, head entity description, relation, relation description, tail entity, and tail entity description of the triple. It serves as the standardized input for a pre-trained embedding model. Specifically, it can be generated by a large model based on the head entity, head entity description, relation, relation description, tail entity, and tail entity description according to preset instruction templates. This results in a complete natural sentence that conforms to the expression habits of domain experts, such as the example in the telecommunications field: "Optical fiber is a technology that uses light to transmit data through flexible glass or plastic, promoting ultra-high bandwidth communication systems and enabling large-scale data transmission." This transforms discrete, highly structured triples of head entities, relations, and tail entities in a knowledge graph into continuous natural language text rich in semantic and structural information.
[0035] S120: Generate text embedding vectors corresponding to natural language text sequences based on pre-trained embedding models, and perform structural information learning and supervised comparative learning of positive and negative samples based on the inherent structural information of text embedding vectors and domain knowledge graphs to obtain semantic structure fusion vectors corresponding to triples.
[0036] Among them, pre-trained embedding models refer to pre-trained language representation models that have been pre-trained on massive amounts of text and possess powerful text semantic understanding and encoding capabilities. They are used to map continuous natural language text into low-dimensional, dense real-number vectors that the model can compute, thereby realizing the vectorized representation of text semantic information. Specifically, bidirectional pre-trained language models based on the Transformer architecture, such as BERT, can be used to accurately capture contextual semantics, domain-specific semantics, and implicit association information in natural language text sequences.
[0037] The text embedding vector is a low-dimensional dense real-number vector output by a pre-trained embedding model, corresponding to the input natural language text sequence. It is a digital and vectorized representation of the text's semantic information. Distance and similarity in the vector space directly reflect the degree of semantic association between texts. Specifically, it can be generated by encoding the standardized input sequence by the pre-trained embedding model and then fusing global features through average pooling, possessing complete global semantic representation capabilities rather than a single fragmented vector.
[0038] The inherent structural information refers to the structured topological rules and triple constraint rules naturally possessed by the domain knowledge graph itself, which do not change with the embedding method or model. It is the core attribute that distinguishes knowledge graphs from pure text corpora and is also the core supervisory signal for knowledge graph completion tasks. Specifically, it can include the inherent constraint rules of triples and graph topological structure information. The inherent constraint rules of triples refer to the structural rules that real and valid triples satisfy between the head entity vector, relation vector, and tail entity vector, as well as the bidirectional matching dependencies among the head entity, relation, and tail entity. Graph topological structure information can include the association relationships between entities, the set of neighboring entities of an entity, the hierarchical affiliation of entities, the topological connection features between entities, and entity association features. Its core function is to provide structural-level supervisory constraints for the model, enabling the model to learn vector representations that conform to the real structure of the knowledge graph, thus addressing the core deficiency of traditional semantic embedding methods that ignore graph structural information.
[0039] Structural information learning is the training process in this scheme where the model learns and reconstructs the inherent structural information of the domain knowledge graph. The core objective is to enable text embedding vectors, which originally only possess semantic information, to reconstruct the true structural patterns of the knowledge graph in the vector space, ensuring that the vector representation fully conforms to the inherent structural constraints of the graph. Specifically, the matching error between the text embedding vectors and the inherent structure of the graph can be quantified using a structural loss term. The training process aims to minimize this error and continuously optimize the vector representation. Supervised contrastive learning is the process in this scheme where the model is trained under supervision using labeled positive and negative samples. The core objective is to enhance the model's ability to distinguish between real and fake triples, optimize the vector distribution in the space, amplify the representational differences between positive and negative samples, and further strengthen the learning effect of structural information. Specifically, this can be achieved by constraining the model to bring the vector distance between positive samples closer and push the vector distance between negative samples further apart in the vector space, amplifying the vector distribution differences between positive and negative samples, and reducing the model's dependence on fake text matching.
[0040] The semantic structure fusion vector refers to a low-dimensional dense vector obtained after joint optimization through structural information learning and supervised contrastive learning. This vector integrates domain-specific semantic information of the triples with the inherent structural information of the knowledge graph. Based on the distance and matching degree of this vector in space, the model can accurately predict missing head entities, relations, or tail entities in the domain knowledge graph and complete the missing triples.
[0041] In this embodiment, triples from the domain knowledge graph are obtained, and a corresponding domain knowledge base is constructed based on these triples. By obtaining domain knowledge graph triples and constructing a dedicated domain knowledge base, a unique and compliant source of professional knowledge is provided for the large model. This not only avoids the domain illusion problem of general large models at its root but also achieves the pre-textualization of the inherent structural information of the knowledge graph. The large model generates entity descriptions, relation descriptions, and natural language text sequences corresponding to the triples, transforming low-semantic-density structured triples into continuous text rich in professional semantics and structural information. This compensates for the shortcomings of traditional triples, such as insufficient semantic information and discrepancies between professional and general semantics. Text vectorization is completed through a pre-trained embedding model. Combined with joint optimization of structural information learning and supervised contrastive learning, a fused vector that integrates both semantic and structural information is generated. This solves the problems of semantic and structural disconnect and false matching in traditional semantic embedding methods. It can be adapted to completion scenarios in various vertical professional fields, thereby improving the accuracy and generalization ability of domain knowledge graph completion.
[0042] In any of the above embodiments, optionally, entity descriptions and relation descriptions of triples in the domain knowledge base are obtained through a large model, and natural language text sequences corresponding to the triples are generated based on the entity descriptions and relation descriptions, specifically including: S1101: Based on a preset instruction template and domain knowledge base, generate entity descriptions and relation descriptions using the domain expert roles in the preset instruction template as triples, and obtain the corresponding natural language text sequence.
[0043] The preset instruction template refers to a custom-designed template specifically for the semantic transformation of knowledge graph triples. The preset instruction template in this application is a standardized prompt instruction framework pre-designed and solidified to constrain the generation behavior of large models. The domain expert role in this application is a pre-set identity setting within the instruction template, used to limit the professional perspective, knowledge boundaries, and expression style of the content generated by the large model. It is the core identity constraint that constrains the large model to generate content that conforms to the professional norms, business logic, and technical standards of the corresponding professional field, acting as a senior practitioner in that field. It is perfectly matched to the professional field to which the domain knowledge graph and domain knowledge base of this application belong.
[0044] In this embodiment, based on a preset instruction template and a domain knowledge base, entity descriptions, relation descriptions, and corresponding natural language text sequences are generated using domain expert roles within the instruction template as triples. This achieves standardized constraints and precise control over the entire process of content generation by the large model. The preset instruction template, by solidifying knowledge sources, generation rules, output formats, and prohibited items, fundamentally avoids the instability and domain illusion inherent in general large models, ensuring that the generated content is entirely based on compliant domain expertise. The setting of domain expert roles limits the generation perspective and knowledge boundaries of the large model, eliminating the deviation between general semantics and domain-specific semantics. Simultaneously, the inherent structural information of the knowledge graph is integrated into the generated text sequence, providing high-quality input for subsequent semantic embedding and joint learning, effectively improving the accuracy of vector representation, and providing core support for optimizing the knowledge graph completion effect.
[0045] In any of the above embodiments, optionally, based on a preset instruction template and a domain knowledge base, entity descriptions and relation descriptions are generated using the domain expert roles in the preset instruction template as triples to obtain the corresponding natural language text sequence, specifically including: S1101a: Extract the head entity domain information, relation domain information, and tail entity domain information of the corresponding triples from the domain knowledge base. Based on the head entity domain information, relation domain information, and tail entity domain information, extract the head entity description, relation description, and tail entity description of the corresponding triples respectively. Among them, the professional domain information of the head entity refers to the set of standardized professional information extracted from the domain knowledge base constructed in this application for the head entity in the triplet. This set represents the complete set of information within the corresponding professional domain for that entity and is the sole compliant source of information for generating the head entity description. It is fully bound to the unique identifier and topological association of the head entity in the domain knowledge graph. Specifically, it may include the official standard definition and core technology interpretation of the head entity in its professional domain, the professional technical parameters, business attributes, applicable scenarios, and relevant industry standards and specifications corresponding to the head entity, the inherent topological information of the head entity in the domain knowledge graph, including structural information such as associated neighboring entities, association relationships, hierarchical affiliation, and topological connection characteristics, and supplementary information such as the business constraints and association rules of the head entity within the domain.
[0046] The tail entity's professional domain information refers to the set of standardized professional information extracted from the domain knowledge base constructed in this application for the tail entity in the triplet. This set represents the complete set of information within the corresponding professional domain for that entity and serves as the sole compliant source of information for generating the tail entity description. It is fully bound to the unique identifier and topological association of the tail entity in the domain knowledge graph. Specifically, it may include the official standard definition, core technology interpretation, professional technical parameters, business attributes, and industry standards of the tail entity in its professional domain, as well as the inherent structural information of the tail entity in the domain knowledge graph, such as its associated neighboring entities, topological connection characteristics, and hierarchical affiliation.
[0047] Among them, the relation domain information is a set of professional information extracted from the domain knowledge base constructed in this application for the relation predicate in the triple. This information includes standardized interpretations, business rules, and constraints of the relation within the corresponding professional domain. It is the sole compliant source of information for generating relation descriptions and is used to eliminate the discrepancy between the general natural language semantics of the relation and the domain-specific semantics. Specifically, it may include the precise professional interpretation of the relation within its respective professional domain, clarifying its core meaning in the domain's business scenario; applicable constraints of the relation, including adaptable head entity types and tail entity types, clarifying the applicable boundaries of the relation, avoiding generalization ambiguity of general semantics; the domain business rules, technical specifications, associated constraints, and industry standard basis corresponding to the relation; and supplementary information such as typical application scenarios, positive and negative examples of the relation in the domain knowledge graph.
[0048] S1101b: Generate natural language text sequences based on head entities, head entity descriptions, relations, relation descriptions, tail entities, and tail entity descriptions.
[0049] The head entity description refers to the head entity in the triple, and the tail entity description refers to the tail entity in the triple. Both are based solely on the domain knowledge base constructed in this application as the sole compliant information source. Specifically, they are textual interpretations and supplementary explanations generated by the domain expert role according to the preset instruction template through the large model, integrating domain-specific semantic information and knowledge graph topology information. They complete the semantic and structural information of the structured head and tail entity identifiers and are also the core component for generating natural language text sequences. The relation description refers to the relation predicate in the triple. Based solely on the domain knowledge base constructed in this application as the sole compliant information source, it is generated by the domain expert role according to the preset instruction template through the large model, conforming to domain business rules. It completes the domain-specific semantics of the structured relation identifiers and is primarily used to eliminate the discrepancy between the general natural language semantics and the domain-specific semantics of the relation. Only professional information of the corresponding head entity can be extracted from the domain knowledge base for generation. The use of content outside the knowledge base is prohibited, fundamentally avoiding the domain illusion problem of the large model and ensuring the professional accuracy of the content.
[0050] In this embodiment, by selectively extracting the domain-specific information of the head entity, relation, and tail entity of the corresponding triples from the domain knowledge base, and using this as the sole compliant information source to generate corresponding entity and relation descriptions, the professional accuracy of the generated content is ensured, fundamentally avoiding the domain illusion problem of large models. Furthermore, the inherent topological structure information of the knowledge graph, domain business rules, and constraints are pre-integrated into the text description, eliminating the discrepancy between the general semantics of relations and the domain-specific semantics. Based on the head entity, relation, tail entity, and their corresponding descriptions, a complete natural language text sequence is generated, transforming discrete structured triples into continuous semantic text. This provides high-quality input carrying both semantic and structural information for subsequent pre-training embeddings, effectively improving the accuracy of vector representation and laying a solid foundation for optimizing the knowledge graph completion effect.
[0051] In any of the above embodiments, optionally, based on the head entity domain information, relation domain information, and tail entity domain information, the head entity description, relation description, and tail entity description of the corresponding triples are extracted respectively, specifically including: S1101a1: Extract the core domain definition of the head entity from the professional domain information of the head entity, and obtain the related neighbor entities and related domain attribute information of the corresponding head entity in the domain knowledge graph, and generate the head entity description based on the core domain definition, related neighbor entities and related domain attribute information; S1101a2: Extract the core domain definition, related business rules and constraint information of the relationship from the professional domain information, and generate the relationship description based on the core domain definition, related business rules and constraint information; S1101a3: Extract the core domain definition of the tail entity from the professional domain information of the tail entity, and obtain the related neighbor entities and related domain attribute information of the corresponding tail entity in the domain knowledge graph, and generate the tail entity description based on the core domain definition, related neighbor entities and related domain attribute information.
[0052] Specifically, as an example, taking the telecommunications field as the relevant domain and the triple <fiber optic, facilitation, ultra-high bandwidth communication system> as an example, from the perspective of a telecommunications expert, we first extract the core domain definition from the telecommunications professional information of the head entity "fiber optic," then supplement it with core technical attributes, and finally generate a head entity description. For example, fiber optic is a technology that uses light to transmit data through flexible glass or plastic. From the telecommunications professional information of the tail entity "ultra-high bandwidth communication system," we extract the core domain definition, supplement it with corresponding business value and application scenarios, and finally generate a tail entity supplementary description. For example, ultra-high bandwidth communication systems enable large-scale data transmission and support advanced applications such as 4K video streaming and cloud computing. Finally, as a telecommunications expert, I would describe this triple as follows: Fiber optic is a technology that uses light to transmit data through flexible glass or plastic, facilitating ultra-high bandwidth communication systems, enabling large-scale data transmission, and supporting advanced applications such as 4K video streaming and cloud computing.
[0053] In this embodiment, core domain definitions are extracted from the corresponding professional domain information for the head entity, relation, and tail entity of the triple. Simultaneously, the associated neighbor entities, associated domain attribute information, and associated business rules and constraints of the relation in the domain knowledge graph are supplemented to generate corresponding head entity descriptions, relation descriptions, and tail entity descriptions. By limiting the source of professional information to a single, compliant source, the professional accuracy of the generated content is ensured, fundamentally avoiding the domain illusion problem of large models. Furthermore, the inherent topological structure information of the knowledge graph and domain-specific business rules are pre-integrated into the text content, eliminating the discrepancy between the general semantics of relations and the professional semantics of the domain. This allows the generated natural language text sequence to simultaneously carry the professional semantics and structural association information of the triple, providing high-quality input for subsequent semantic embedding and joint optimization, effectively improving the accuracy and generalization ability of knowledge graph completion.
[0054] In any of the above embodiments, optionally, generating text embedding vectors corresponding to natural language text sequences based on pre-trained embedding models specifically includes: S1201: Obtain preset sequence markers, which include at least a sequence start marker, a sequence segmentation marker, and a domain-specific marker; Among them, the pre-defined sequence markers are standardized special control symbols that are predefined and fixed, and can be accurately recognized by the pre-trained embedding model. They are used to perform structured segmentation, semantic boundary delineation, and domain attribute labeling of natural language text sequences. They are the core carrier for converting unstructured natural language text into standardized input that can be adapted to the pre-trained embedding model. By using pre-defined markers, the model can accurately distinguish the three core semantic segments of triples: head entity, relation, and tail entity. At the same time, it enhances the model's ability to capture domain-specific semantics and solves the problems of semantic bias and segment boundary confusion in general pre-trained models when dealing with professional domain texts.
[0055] The sequence start marker is a special marker that is always placed at the very beginning of the entire input sequence. For example, it is usually denoted as ** in general pre-trained models and is used by the pre-trained embedding model to identify the beginning of the input sequence. The sequence segmentation marker is a special marker used to segment different independent semantic segments. For example, it is usually denoted as [SEP] in general pre-trained models and is used to clearly define the boundaries of different semantic units. The domain-specific marker is a special marker defined in this application and specifically corresponding to a professional field. It is used to mark the professional field to which the input text belongs and the type attributes of the semantic segments, and is used to adapt to the professional scenarios of the domain knowledge graph of this application.
[0056] S1202: By sequentially inserting sequence start markers and sequence segment markers into multiple natural language sequence segments, and assigning domain-specific markers to each natural language sequence segment, a standardized input sequence is generated; Specifically, as an example, taking the input triple: <fiber optic, facilitator, ultra-high bandwidth communication system> as an example, a sequence start marker ** is inserted at the very beginning of the sequence, and a global domain-specific marker [TEL] is added to identify the beginning of the sequence and its domain. A domain-specific marker [HEAD] is added before the head entity description fragment, and a sequence segmentation marker [SEP] is inserted at the end of the fragment, completing the boundary division and attribute marking of the head entity fragment. A domain-specific marker [REL] is added before the relation description fragment, and a sequence segmentation marker [SEP] is inserted at the end of the fragment, completing the boundary division and attribute marking of the relation fragment. A domain-specific marker [TAIL] is added before the tail entity description fragment, and a sequence segmentation marker [SEP] is inserted at the end of the fragment, completing the normalization process of the entire sequence. The final generated normalized input sequence is: ** [TEL] [HEAD] Fiber optic is a technology that uses light to transmit data through flexible glass or plastic [SEP] [REL] Facilitator ultra-high bandwidth communication system [SEP] [TAIL] Enables large-scale data transmission, supporting advanced applications such as 4K video streaming and cloud computing [SEP]. On the one hand, global domain labeling explains the professional domain to which the pre-trained embedding model belongs to the current text, such as the telecommunications domain, guiding the model to strengthen the capture of domain-specific semantics and weaken the interference of general natural language semantics. On the other hand, fragment attribute labeling clearly marks whether the current fragment is a head entity / relation / tail entity, further strengthening the model's ability to perceive triple structure.
[0057] S1203: Input the standardized input sequence into the pre-trained embedding model.
[0058] Specifically, as an example, the standardized input sequence generated above is input into the BERT-base pre-trained embedding model. The model first performs triple encoding of each token and text token in the sequence, including word embedding, segment embedding, and position embedding, to generate an initial token-level vector. Through multiple Transformer bidirectional encoding layers, it captures the contextual semantics, domain-specific semantics, and correlation information between triplet segments of the sequence. It extracts the output features corresponding to the sequence start token, performs global feature fusion through average pooling, and finally generates a text embedding vector corresponding to the natural language text sequence of the triplet.
[0059] In this embodiment, a standardized control carrier is provided for the conversion of unstructured natural language text into an input that can be adapted to a pre-trained embedding model by acquiring a preset sequence marker containing a sequence start marker, a sequence segment marker, and a domain-specific marker. By sequentially inserting sequence start markers and sequence segment markers into multiple natural language sequence segments and assigning domain-specific markers to each segment, a standardized input sequence is generated. This clearly delineates the semantic segment boundaries of the head entity, relation, and tail entity of the triplet, avoiding information confusion between different semantic units. Furthermore, the custom domain-specific markers guide the model to strengthen its capture of professional domain semantics, improving the model's ability to perceive triplet structures. The standardized input sequence is then input into the pre-trained embedding model for encoding, generating a text embedding vector that accurately carries semantic and structural information. This effectively solves the problem of bias in the understanding of professional domain text semantics by general pre-trained models, providing a high-quality vector foundation for subsequent joint learning and knowledge graph completion.
[0060] In any of the above embodiments, optionally, after inputting the standardized input sequence into the pre-trained embedding model, the method further includes: S1204: After encoding the standardized input sequence, the encoded output is fused using average pooling to generate a text embedding vector.
[0061] Specifically, as an example, after the pre-trained embedding model encodes the standardized input sequence, it generates a 5-dimensional feature vector for each token in the sequence. In this example, the total number of tokens in the sequence is 28, and the final encoded output feature matrix has the following dimensions: 28 (sequence length) × 5 (feature dimension). The 5-dimensional feature vectors of the above 28 tokens are then averaged according to each feature dimension. After average pooling and global feature fusion, the complete text embedding vector corresponding to the triple is obtained: [0.25, 0.48, 0.32, 0.67, 0.39].
[0062] In the practical application of this solution, when using the standard BERT-base model, the feature dimension is the industry-standard 768 dimensions. After the above processing steps, a 1×768-dimensional dense real-number vector is finally generated. This vector fully integrates the global semantics, telecommunications domain professional information, and triple structure information of the entire input sequence, which is the text embedding vector corresponding to the triple, serving as the core input for subsequent structural information learning and supervised contrastive learning.
[0063] In this embodiment, a pre-trained embedding model encodes the standardized input sequence, transforming the text sequence into a feature vector that the model can compute. This fully captures the contextual semantics, domain-specific information, and triplet structure association information of the input sequence, achieving the basic transformation for vectorized representation of natural language text. The fragmented features of the encoded output are then fused globally using average pooling, integrating discrete vectors into a unified global text embedding vector. This process fully preserves the overall semantic and structural information of the input sequence, avoiding feature fragmentation and information bias.
[0064] In any of the above embodiments, optionally, as Figure 2 As shown, the joint loss function of the pre-trained embedding model includes a structural loss term and a supervised contrastive loss term. Based on the pre-trained embedding model, text embedding vectors corresponding to natural language text sequences are generated. Then, based on the inherent structural information of the text embedding vectors and the domain knowledge graph, structural information learning and supervised contrastive learning of positive and negative samples are performed to obtain the semantic structure fusion vector corresponding to the triples, specifically including: S300: Generates text embedding vectors corresponding to natural language text sequences based on pre-trained embedding models; S310: Calculate the structural loss value corresponding to the inherent structural information of the text embedding vector and the domain knowledge graph by using the structural loss term in the joint loss function of the pre-trained embedding model; The structural loss term, a core component of the joint loss function in this application, is a standardized loss calculation rule used to constrain the model's learning of the inherent structural rules of the domain knowledge graph. It serves as the core supervisory signal in the structural information learning process, its core function being to enable the model-generated text embedding vectors to reconstruct the underlying structural matching logic of the knowledge graph's real triples in the vector space. In this scheme, the structural loss term uses the real triples of the domain knowledge graph as supervisory samples, based on the inherent structural rules of the head entity, relation, and tail entity of the triples. Specifically, the loss calculation logic can be constructed through the bidirectional matching probabilities of the three elements of the triples. The structural loss value is a quantifiable numerical result calculated through the structural loss term, used to accurately measure the matching error between the text embedding vectors generated by the current model and the inherent structural information of the domain knowledge graph. It is a direct quantitative indicator of the structural information learning effect. The magnitude of the structural loss value is directly negatively correlated with the model's structural learning effect; that is, the larger the value, the greater the deviation between the text embedding vector and the true structural rules of the knowledge graph, and the worse the model's learning effect on the graph structure. Conversely, the smaller the value, the closer the text embedding vector is to the inherent structural rules of the knowledge graph, and the better the model's structural learning effect.
[0065] S320: Calculate the contrastive loss value between the text embedding vectors corresponding to the positive and negative samples of the triple by using the supervised contrastive loss term in the joint loss function of the pre-trained embedding model; The supervised contrastive loss term is another core component of the joint loss function in this application. Based on labeled positive and negative samples, it constrains the model to distinguish between real and fake triples using standardized loss calculation rules. It is the core supervisory signal in the supervised contrastive learning process, and its core function is to optimize the distribution of vectors in space, amplify the representational differences between positive and negative samples, and strengthen the model's ability to distinguish between real and fake triples. In this scheme, positive and negative samples can be used as supervisory data, sharing the same structural scoring function as the structural loss term. The loss calculation logic is constructed by constraining the model to bring positive sample vectors closer and widen the distance between negative sample vectors. The contrastive loss value is a quantifiable numerical result calculated through the supervised contrastive loss term, used to accurately measure the current model's ability to distinguish between positive and negative triples, and is a direct quantitative indicator of the supervised contrastive learning effect. In this scheme, the magnitude of the contrastive loss value is directly negatively correlated with the model's sample discrimination ability. That is, the larger the value, the less the model can distinguish between real triples and fake triples, the smaller the difference in vector distribution between positive and negative samples, and the worse the contrastive learning effect. The smaller the value, the higher the model's ability to distinguish between real and fake triples, the clearer the boundary of vector distribution between positive and negative samples, and the better the contrastive learning effect.
[0066] S330: Determine the joint loss value of the joint loss function based on the structural loss value and the contrastive loss value; The joint loss value, which is the total loss obtained by fusing the structural loss value and the contrastive loss value, is the sole global optimization objective in the training process of the pre-trained embedded model in this application. It drives the backpropagation update of model parameters and constrains the model's structural learning ability and sample discrimination ability. In this scheme, the joint loss value can be specifically calculated by fusing the structural loss value and the contrastive loss value. The core objective of the training process is to minimize this value. The smaller the value, the more accurate the model's graph structure learning ability and true / false triplet discrimination ability are, and the generated vectors simultaneously integrate domain-specific semantics and knowledge graph structure information.
[0067] S340: Adjust the model parameters of the pre-trained embedding model based on the joint loss value until the iteration stopping condition is met, and obtain the semantic structure fusion vector of the triples.
[0068] It should be understood that this value is the sole basis for iterative updates of the model parameters. Each training iteration adjusts the weight parameters of the pre-trained embedding model based on this value until the iteration stopping condition is met, ultimately resulting in a semantic structure fusion vector that meets the requirements. The iteration stopping condition is a pre-defined standardized judgment rule used to terminate the training iteration process of the pre-trained embedding model. It controls the model's training convergence, balances the model's fitting effect and generalization ability, and avoids underfitting or overfitting. In this scheme, the iteration stopping condition can adopt any one or more of the following combinations of rules: Evolution threshold rule: The model training iteration reaches a preset maximum number of training epochs, such as 100 training epochs; Loss convergence rule: The joint loss value decreases for a consecutive preset number of epochs, such as 10 consecutive epochs, if the decrease is less than a preset convergence threshold (e.g., less than 1e-6), indicating that the model has converged; Indicator threshold rule: The model's knowledge graph completion accuracy and triplet classification accuracy on the independent validation set reach preset accuracy thresholds; Overfitting protection rule: The completion accuracy on the validation set continuously decreases for a consecutive preset number of epochs, indicating that the model is overfitting, and training is terminated early. When the training process meets any preset iteration stopping condition, the model parameter update is terminated, and the semantic structure fusion vector corresponding to the triples generated by the current model is output.
[0069] In this embodiment, text embedding vectors corresponding to natural language text sequences are generated based on a pre-trained embedding model, providing core input for subsequent joint learning. The structural loss value is calculated using the structural loss term of the joint loss function. Real triples from the domain knowledge graph serve as supervision signals, constraining the model to learn the inherent structural rules of the graph and measuring the matching error between the vector representation and the graph structure, thus addressing the deficiency of traditional semantic embedding in ignoring graph structural information. The contrastive loss value is calculated using a supervised contrastive loss term, constraining the model to optimize the vector space distribution based on positive and negative samples, strengthening the model's ability to distinguish between real and false triples, and addressing the problem of false matching in semantic embedding. The joint loss value is obtained by fusing the two types of loss values and is used as the sole global optimization objective to drive model parameter updates until a preset iteration stopping condition is met. Finally, a semantic structure fusion vector that simultaneously integrates domain-specific semantics and graph structural information is obtained, significantly improving the accuracy and generalization ability of domain knowledge graph completion.
[0070] In any of the above embodiments, optionally, before calculating the structural loss value corresponding to the inherent structural information of the text embedding vector and the domain knowledge graph, the method further includes: S3101: Extract entity association features and topological structure features from text embedding vectors based on text embedding vectors; Among them, entity association features are core features extracted from the text embedding vectors generated by this solution. These features are used to quantify the domain semantic matching degree, business association tightness, and attribute adaptability among the head entity, relation, and tail entity within a triple. They are vectorized representations of the direct association relationships between entities within a triple and are also the core basis for reconstructing the true association logic between entities in the knowledge graph. The entity association features in this solution are not discrete association identifiers directly extracted from a pure structured graph, but rather extracted from text embedding vectors that integrate entity descriptions and relation descriptions. Specifically, they can include domain semantic similarity features between head and tail entities, business rule adaptability features between relations and head-tail entity pairs, and directional association constraints and business dependency features between entities. For example, the semantic similarity between the head entity "optical fiber" and the tail entity "ultra-high bandwidth communication system" in the telecommunications domain is 0.89, indicating a strong semantic association between them. The business rule fit between the relationship "promote" and the entity pair "optical fiber-ultra-high bandwidth communication system" is 0.92, which fully conforms to the business logic of "transmission media supporting the improvement of communication system capabilities" in the telecommunications domain. The association between "optical fiber" and "ultra-high bandwidth communication system" is a one-way support association, with the head entity being the capability provider and the tail entity being the capability beneficiary. The association direction is irreversible.
[0071] Among them, the topological structure features are core features extracted from the text embedding vectors generated by this scheme. These features are used to quantitatively represent the positional attributes, connectivity characteristics, and structural roles of entities in the global / local topological network of the entire domain knowledge graph. They are vectorized representations of the topological environment in which entities reside within the knowledge graph and are also the core basis for reconstructing the inherent structural rules of the global knowledge graph. The topological structure features in this scheme are extracted from text embedding vectors that incorporate entity neighbor information and graph association information. Specifically, they can include the local connectivity features of entities in the graph, such as the number of neighboring entities and the distribution of association types; the global structural features of entities in the graph, such as degree centrality, hierarchical affiliation, subgraph category; and the topological path associations and connectivity features between entities. For example, local connectivity features: the head entity "Fiber Optic" has 12 neighboring entities, with core associations including "deployed at", "connected to", and "contains", and associated entities including "optical module", "communication room", and "transmission network equipment"; the tail entity "Ultra-High Bandwidth Communication System" has 8 neighboring entities, with core associated entities including "5G core network", "cloud computing platform", and "edge computing node". Global structural features: "Fiber Optic" belongs to the bottom-level transmission medium type entity in the graph, ranks in the top 15% in degree centrality, and is a core basic node in the telecommunications network topology; "Ultra-High Bandwidth Communication System" belongs to the upper-level business system type entity, located in the business layer of the topology network. Topology path features: "Fiber Optic" and "Ultra-High Bandwidth Communication System" have a direct topology connection in the graph, and also have 2 indirect association paths, with extremely strong topology connectivity.
[0072] S3102: Generate inherent structural information of domain knowledge graphs based on entity association features and topological structure features.
[0073] Specifically, as an example, taking the triple <fiber optic, facilitation, ultra-high bandwidth communication system> as an example, we extract the core features of entity associations within the triple from its text embedding vector, and extract the core features of the entity's topological structure in the telecommunications domain knowledge graph from its text embedding vector. The triple <fiber optic, facilitation, ultra-high bandwidth communication system> is a real and valid triple in the telecommunications domain knowledge graph, satisfying the core structural rule of "head entity vector + relation vector ≈ tail entity vector", thus generating the inherent structural information of the domain knowledge graph corresponding to this triple.
[0074] In this embodiment, based on the text embedding vectors generated by the pre-trained embedding model, corresponding entity association features and topological structure features are extracted. Entity association features accurately quantify the domain semantic matching degree, business association tightness, and directional constraint relationships of the head entity, relation, and tail entity within a triplet. Topological structure features completely reconstruct the positional attributes, connectivity characteristics, and structural roles of entities in the global and local topological networks of the domain knowledge graph. Both types of features are extracted from text embedding vectors that integrate semantic and structural information, rather than discrete identifiers from a purely structured graph, ensuring a deep binding between structural features and semantic representation. The inherent structural information of the domain knowledge graph generated by fusing these two types of features provides a precise and semantically relevant supervisory signal for subsequent structural loss value calculation. This addresses the shortcomings of traditional methods where structural information and semantic embedding are disconnected, effectively improving the accuracy of structural information learning and laying a solid foundation for joint model optimization and improved knowledge graph completion.
[0075] In any of the above embodiments, optionally, before calculating the contrast loss value between the text embedding vectors corresponding to the positive and negative samples of the triples, the method includes: S3201: Identify all real-world triples in the domain knowledge graph as positive samples; Specifically, as an example, all valid triples that have been included, exist in reality, and conform to the domain's business rules in the aforementioned telecommunications domain knowledge graph are identified as positive samples for supervised contrastive learning. For example, the positive sample set may include <fiber optic, promoting, ultra-high bandwidth communication systems>, <5G macro base stations, deployed in, edge communication equipment rooms>, <optical modules, contained in, fiber optic transmission equipment>, and <edge computing servers, supporting, low-latency services>. These are the valid samples that the model needs to learn, conforming to its inherent structural rules, and are used to provide positive supervisory signals for supervised contrastive learning.
[0076] S3202: Perform entity replacement processing based on positive samples to generate negative samples.
[0077] Specifically, as an example, the negative sample size can be expanded by performing full tail entity replacement on the positive samples. All generated negative samples are spurious triples that do not conform to the inherent structure of the domain knowledge graph. Together with the positive samples, they constitute a complete sample set for supervised contrastive learning, which is used for subsequent calculation of the contrastive loss value.
[0078] In this embodiment, all real-world, valid triples conforming to domain business rules in the domain knowledge graph are identified as positive samples for supervised contrastive learning. This provides positive supervision signals that align with the inherent structural rules of the knowledge graph for model training, guiding the model to learn standardized vector representations of valid triples and clarifying the positive objective of model optimization. Based on the positive samples, entity replacement is performed to generate negative samples, constructing a complete set of positive and negative samples. This effectively expands the scale of negative samples, providing sufficient supervision data for contrastive learning. Furthermore, entity replacement generates false triples that do not conform to the graph structure and business rules, helping the model clarify the representational boundaries between valid and false samples and addressing the flaw of false matching in traditional semantic embedding. The complete sample set provides accurate supervision for subsequent calculation of contrastive loss values, effectively strengthening the model's sample discrimination ability and providing core support for vector representation optimization and improved knowledge graph completion effects.
[0079] In any of the above embodiments, optionally, entity replacement processing is performed based on positive samples to generate negative samples, specifically including: S3202a: Select entities other than the original tail entity of the corresponding positive sample from the full entity set of the domain knowledge graph, replace the tail entity of the corresponding positive sample, and generate the corresponding negative sample. Specifically, as an example, this example uses the core positive sample <fiber optic, facilitation, ultra-high bandwidth communication system> as a foundation. For instance, from the full entity set of the telecommunications domain knowledge graph, all entities other than the original tail entity "ultra-high bandwidth communication system" of the positive sample are selected, and the tail entities of the positive sample are replaced one-to-one to generate a batch of negative samples. These negative samples are all spurious triples that do not conform to the knowledge graph structure or the business rules of the telecommunications domain. Their core function is to expand the scale of negative samples, allowing the model to learn the mismatch between the head entity-relationship and the erroneous tail entity, and strengthening the model's ability to judge the rationality of the triple structure.
[0080] S3202b: Use the head entity of the corresponding positive sample as the replacement entity to replace the tail entity of the corresponding positive sample, and generate the corresponding negative sample.
[0081] Specifically, as an example, continuing with the previous example, the head entity "optical fiber" of the positive sample is used as the replacement entity to directly replace the tail entity "ultra-high bandwidth communication system" of the positive sample, generating a difficult negative sample. In this example, the negative sample generated after replacement is: <optical fiber, promotion, optical fiber>. This type of negative sample is a difficult negative example that the model is extremely prone to misclassifying: because the replaced tail entity is completely identical to the original head entity, the text overlap is 100%, and traditional semantic embedding methods are very likely to give this fake triple a high score; generating negative samples in this way can specifically solve the model's dependence on fake text matching, further improving the accuracy of contrastive learning.
[0082] In this embodiment, entities other than the original tail entities of the corresponding positive samples are selected from the full entity set of the domain knowledge graph to replace the tail entities of the positive samples, generating a batch of negative samples. This effectively expands the scale of negative samples for supervised contrastive learning, providing sufficient supervised data for model training. It also allows the model to fully learn the mismatch between head entities and relation combinations and incorrect tail entities, strengthening the model's basic ability to discriminate the rationality of triple structures. By replacing the tail entities with the head entities of the corresponding positive samples, difficult negative samples are generated, specifically addressing the false matching problem caused by high text overlap in traditional semantic embedding methods. This helps the model clarify the boundary between semantic similarity and structural rationality, further improving the accuracy of contrastive learning. The two types of negative samples together constitute a complete supervised sample set, providing comprehensive supervision for subsequent calculation of contrastive loss values, effectively improving the model's ability to distinguish between true and false triples.
[0083] In any of the above embodiments, optionally, the formula for calculating the joint loss function is: Where L is the joint loss value corresponding to the joint loss function, G is the set of all real triples in the domain knowledge graph, h is the head entity of the triple, r is the relation of the triple, and t is the tail entity of the triple; Pr(h|r,t) is the matching probability of head entity h given relation r and tail entity t, Pr(r|h,t) is the matching probability of relation r given head entity h and tail entity t, and Pr(t|h,r) is the matching probability of tail entity t given head entity h and relation r; P is the set of positive samples, N is the set of negative samples, score(h,r,t) is the structure score of positive sample triples, score(h,r,t′) is the structure score of negative sample triples, y is the sample label, y=1 for positive samples and y=0 for negative samples, used to distinguish between positive and negative samples, and τ is the temperature hyperparameter.
[0084] This embodiment uses knowledge graphs in the telecommunications field as an application scenario. The core processing triple is <fiber optic, facilitation, ultra-high bandwidth communication system>. The implementation details, calculation logic, and technical role of the joint loss function are fully explained below, based on this scenario. The first part of the complete formula is the structural loss term, corresponding to the core constraint in the structural information learning stage of this method, and is the basis for calculating the structural loss value. It constrains the model to learn the inherent structural rules of the knowledge graph in the domain, ensuring that the generated text embedding vector perfectly matches the triple.<h,r,t> The underlying structure matching logic corresponds to the calculation of structural loss values.
[0085] In this context, G represents the complete set of all valid triples that have been verified by domain experts and are truly existing in the telecommunications knowledge graph. ∑G represents the logarithmic loss of the three-way matching probability calculated for each valid triple in set G and then summed to ensure that the model fully learns the structural patterns of all valid triples in the graph. h is the head entity of the triple, r is the relation of the triple, and t is the tail entity of the triple. In this embodiment, h represents "optical fiber", r represents "facilitator", and t represents "ultra-high bandwidth communication system".
[0086] Pr(h|r,t) is the matching probability of the head entity h given the relation r and the tail entity t. Given the relation "promote" and the tail entity "ultra-high bandwidth communication system", the matching probability of the head entity being "fiber optic" is measured. It measures the accuracy of the model's backward inference of the head entity. Pr(r|h,t) is the matching probability of relation r given head entity h and tail entity t. Given head entity "fiber optic" and tail entity "ultra-high bandwidth communication system", it is the matching probability of relation "promotion". It measures the accuracy of the model in identifying professional relationships between entities. Pr(t|h,r) represents the matching probability of tail entity t given head entity h and relation r. It represents the matching probability of tail entity "ultra-high bandwidth communication system" given head entity "fiber optic" and relation "promote". This measure of the accuracy of the model's forward inference of tail entities is a core objective of the knowledge graph completion task. The logarithm of the three matching probabilities is summed and then negative to form the structural loss term. During model training, minimizing this loss term helps to make the three-way matching probability of the true triples as close to 1 as possible, thus allowing the model to fully learn the bidirectional structural association patterns of the knowledge graph.
[0087] P represents the set of positive samples, which consists of all real triples in the telecommunications domain knowledge graph. |P| represents the number of positive samples, used to normalize the contrastive loss and avoid the impact of sample size differences between different training batches on the stability of loss calculation.
[0088] N is the set of negative samples, containing two types of negative samples: full tail entity replacement negative samples generated by batch negative sampling, such as <fiber optic, promotion, 5G macro base station>, <fiber optic, promotion, home router>, etc.; head entity self-replacement difficult negative samples generated by self-negative sampling, such as <fiber optic, promotion, fiber optic>; t′ is the replaced tail entity in the negative sample.
[0089] score(h,r,t) is the structure score of positive sample triples, which is calculated based on the structural rule that "head entity embedding vector + relation embedding vector ≈ tail entity embedding vector". The higher the structure score of the real triple, the more it conforms to the inherent structural rules of the knowledge graph. score(h,r,t′) is the structure score of negative sample triples. The lower the structure score of false triples, the stronger the discriminative ability of the model.
[0090] y is the sample label. In this embodiment, positive samples <fiber optic, promotion, ultra-high bandwidth communication system> correspond to y=1, and all negative samples correspond to y=0, providing clear supervision signals for comparative learning and accurately distinguishing between positive and negative samples.
[0091] τ is a temperature hyperparameter, which is preset to 0.1 in this embodiment. It can be adjusted according to the range of the spectrum size and is used to scale the score difference between positive and negative samples. The smaller τ is, the more it amplifies the score difference between positive and negative samples, making the model more strict in distinguishing between true and false triples. The larger τ is, the more moderate the discrimination.
[0092] In actual calculations, the numerator is the logarithm of the indexed scores of positive samples, and the denominator is the sum of the indexed scores of positive samples and all negative samples. The negative value of the sum constitutes the supervised contrastive loss term. During model training, minimizing this loss term maximizes the proportion of positive sample scores in the total scores of all samples. This constrains the model to bring positive samples closer and push negative samples further away in the vector space, optimizing the vector space distribution and enhancing the learning of structural information.
[0093] In this embodiment, the joint loss is the direct sum of the structural loss term and the supervised contrastive loss term, and is the sole global optimization objective for model training. In each training iteration, based on the current pre-trained embedding model, text embedding vectors corresponding to triples are generated. The structural loss value for this round is calculated using the first part of the formula, and the contrastive loss value is calculated using the second part of the formula. The structural loss value and the contrastive loss value are summed to obtain the joint loss value for this iteration. Backpropagation is performed based on the joint loss value to adjust the weight parameters of the pre-trained embedding model. The above iterative process is repeated until the preset iteration stopping conditions are met, such as loss convergence or reaching the maximum number of training rounds. Finally, a semantic-structural fusion vector of triples that integrates semantic and structural information is obtained. This achieves end-to-end joint optimization of structural information learning and supervised contrastive learning, eliminating the need for staged training and simplifying the model training process. It also allows for deep integration of semantic and structural representations. Through the structural loss term of the three-way matching probability, the model learns the bidirectional structural association of triples completely. Compared with the traditional loss function that only predicts the tail entity in the positive direction, structural learning is more comprehensive. It specifically addresses the false matching problem caused by text overlap in traditional semantic embedding methods, uncovers difficult negative examples, and significantly improves the accuracy of knowledge graph completion. Through normalization processing and temperature hyperparameter, it enhances the stability and generalization ability of model training, and can be adapted to domain knowledge graphs of different sizes.
[0094] Figure 3 The flowchart illustrating a specific embodiment of the knowledge graph completion method according to this application is shown. This specific embodiment is a knowledge graph completion scheme for the telecommunications field. The steps are described in detail below: S400: RAG preprocessing stage for large language models; This stage corresponds to Figure 3 The core of the process on the left is to transform discrete, low-semantic-density structured triples in the domain knowledge graph into natural language text rich in domain-specific semantics and graph structure information through Retrieval-Enhanced Generation (RAG) technology. This fundamentally avoids the domain illusion problem of large models and provides high-quality input for subsequent embedding learning. The specific implementation steps are as follows: S4001: First, obtain the full set of structured triples of the knowledge graph in the telecommunications field. A triple is the smallest knowledge unit in this knowledge graph, fixedly composed of <head entity h, relation r, tail entity t>. In this embodiment, the core processing triple is <fiber optic, facilitating, ultra-high bandwidth communication system>, also including <5G macro base station, deployed in, edge communication equipment room>, <optical module, contained in, fiber optic transmission equipment>, and other full set of valid triples. Based on the full set of triples in the aforementioned knowledge graph, and combined with industry standards, technical documents, equipment parameters, business rules, and other field documents in the telecommunications field, construct a dedicated telecommunications field knowledge base. This knowledge base is the sole compliant knowledge source for generating content for the large model, specifically including: official professional definitions of the entities corresponding to the triples, the entities' associated neighboring entities and topology information in the knowledge graph, the business rules and constraints corresponding to the relations, and full set of professional information such as domain technical specifications.
[0095] S4002: Preset command templates and domain expert role settings. This embodiment pre-fixes standardized command templates adapted to the telecommunications field. Table 1. Example Table of Instruction Templates in the Telecommunications Field S4003: Entity and Relationship Description Generation. Based on the aforementioned instruction template and domain knowledge base, generate corresponding entity and relation descriptions for the target triple. Based on the above header entity, header entity description, relation, relation description, tail entity, and tail entity description, generate a complete natural language text sequence, for example: "As a telecommunications expert, I would describe this triple as follows: Optical fiber is a technology that uses light to transmit data through flexible glass or plastic, facilitating ultra-high bandwidth communication systems, enabling large-scale data transmission, and supporting advanced applications such as 4K video streaming and cloud computing." Figure 3 The natural language text S is divided into three independent semantic segments: head entity text, relation text, and tail entity text, in preparation for subsequent embedding.
[0096] S410: Pre-trained model embedding stage; This stage corresponds to Figure 3The core of the intermediate process is to transform the natural language text sequence generated in the previous stage into text embedding vectors that can be computed by the pre-trained embedding model, simultaneously incorporating semantic and structural information, thus providing the core input for subsequent joint learning. The specific implementation steps are as follows: S4101: This embodiment predefines standardized sequence markers that can be recognized by the pre-trained embedding model. Sequence start marker**: identifies the beginning of the input sequence and is used to aggregate global semantics; Sequence segmentation marker [SEP]: used to segment the boundaries of three independent semantic segments: head entity, relation, and tail entity; Domain-specific marker [TEL]: global domain marker, identifying the text as telecommunications domain professional content; Domain-specific marker [HEAD]: segment attribute marker, identifying the current segment as head entity text; Domain-specific marker [REL]: segment attribute marker, identifying the current segment as relation text; Domain-specific marker [TAIL]: segment attribute marker, identifying the current segment as tail entity text.
[0097] S4102: Generate a standardized input sequence. According to preset rules, insert sequence markers and assign domain-specific markers to the three semantic segments of the natural language text sequence in sequence to generate a standardized input sequence.
[0098] S4103: For the token-level features of the encoded output, average pooling is used for global feature fusion to finally generate a 1×768-dimensional text embedding vector corresponding to the triple. Figure 3 The vector contains head entity embedding, relation embedding, and tail entity embedding, and simultaneously includes the domain-specific semantics of the triple and the implicit graph structure information.
[0099] S420: Collaborative learning phase; This stage corresponds to Figure 3 The core of the process on the right is to optimize the text embedding vector by combining structural information learning and supervised comparative learning in two directions. This allows the text embedding vector to simultaneously conform to the inherent structural rules of the knowledge graph and the requirements for distinguishing between real and fake samples, ultimately generating a semantic structure fusion vector to complete the knowledge graph.
[0100] This embodiment solves the core problems of semantic and structural information disconnect, domain illusion of general large models, and false matching of semantic embedding in traditional knowledge graph completion methods through a three-stage end-to-end process. It achieves deep integration of domain-specific semantics and knowledge graph structural information, which greatly improves the accuracy and generalization ability of knowledge graph completion in the telecommunications field and can be adapted to knowledge graph completion scenarios of different scales in vertical fields.
[0101] like Figure 4 As shown, this application embodiment provides a knowledge graph completion device 200, the device 200 including: The first acquisition unit 202 is used to acquire triples in the domain knowledge graph and construct a corresponding domain knowledge base based on the triples in the domain knowledge graph. The first processing unit 204 is used to obtain entity descriptions and relation descriptions of triples in the domain knowledge base through a large model, and generate natural language text sequences corresponding to the triples based on the entity descriptions and relation descriptions. The second processing unit 206 is used to generate text embedding vectors corresponding to natural language text sequences based on pre-trained embedding models, and to perform structural information learning and supervised comparative learning of positive and negative samples based on the inherent structural information of the text embedding vectors and the domain knowledge graph, so as to obtain the semantic structure fusion vectors corresponding to the triples.
[0102] The knowledge graph completion device 200 provided in this application acquires triples from a domain knowledge graph and constructs a corresponding domain knowledge base based on these triples. By acquiring domain knowledge graph triples and constructing a dedicated domain knowledge base, it provides a unique and compliant source of professional knowledge for large models, fundamentally avoiding the domain illusion problem of general large models and realizing the pre-textualization of the inherent structural information of the knowledge graph. The device generates entity descriptions, relation descriptions, and natural language text sequences corresponding to the triples through the large model, transforming low-semantic-density structured triples into continuous text rich in professional semantics and structural information. This overcomes the shortcomings of traditional triples, such as insufficient semantic information and discrepancies between professional and general semantics. Text vectorization is completed through a pre-trained embedding model, and combined with joint optimization of structural information learning and supervised contrastive learning, a fused vector that integrates both semantic and structural information is generated. This solves the problems of semantic and structural disconnect and false matching in traditional semantic embedding methods, making it adaptable to completion scenarios in various vertical professional fields. Therefore, it can improve the accuracy and generalization ability of domain knowledge graph completion.
[0103] Figure 5 A schematic diagram of the hardware structure of the electronic device provided in an embodiment of this application is shown.
[0104] The electronic device may include a processor 601 and a memory 602 storing computer program instructions.
[0105] Specifically, the processor 601 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0106] Memory 602 may include mass storage for data or instructions. For example, and not limitingly, memory 602 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 602 may include removable or non-removable (or fixed) media. Where appropriate, memory 602 may be internal or external to the integrated gateway. In a particular embodiment, memory 602 is non-volatile solid-state memory.
[0107] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the methods according to one aspect of this disclosure.
[0108] The processor 601 reads and executes computer program instructions stored in the memory 602 to implement any of the knowledge graph completion methods in the above embodiments.
[0109] In one example, the electronic device may also include a communication interface 603 and a bus 610. For example, Figure 5 As shown, the processor 601, memory 602, and communication interface 603 are connected through bus 610 and complete communication with each other.
[0110] The communication interface 603 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0111] Bus 610 includes hardware, software, or both, that couples components of an electronic device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 610 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, this application contemplates any suitable bus or interconnect.
[0112] Furthermore, in conjunction with the knowledge graph completion methods described in the above embodiments, this application embodiment can provide a computer storage medium for implementation. This computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the knowledge graph completion methods described in the above embodiments.
[0113] This application also provides a computer program product, including a computer program that, when executed by a processor, implements any of the knowledge graph completion methods described in the above embodiments.
[0114] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0115] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0116] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0117] The above are merely specific embodiments of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A knowledge graph completion method, characterized in that, The method includes: Obtain triples from the domain knowledge graph, and construct a corresponding domain knowledge base based on the triples from the domain knowledge graph; Using a large model, entity descriptions and relation descriptions of the triples in the domain knowledge base are obtained, and natural language text sequences corresponding to the triples are generated based on the entity descriptions and relation descriptions. Based on the pre-trained embedding model, text embedding vectors corresponding to the natural language text sequence are generated. Based on the text embedding vectors and the inherent structural information of the domain knowledge graph, structural information learning and supervised comparative learning of positive and negative samples are performed to obtain the semantic structure fusion vector corresponding to the triple.
2. The method according to claim 1, characterized in that, The process of obtaining entity and relation descriptions of the triples in the domain knowledge base through a large model, and generating natural language text sequences corresponding to the triples based on the entity and relation descriptions, specifically includes: Based on a preset instruction template and the domain knowledge base, entity descriptions and relation descriptions are generated for the triples using the domain expert roles in the preset instruction template, resulting in the corresponding natural language text sequence.
3. The method according to claim 2, characterized in that, The process, based on a preset instruction template and the domain knowledge base, generates entity and relation descriptions for the triples using domain expert roles within the preset instruction template, resulting in the corresponding natural language text sequence. Specifically, this includes: Extract the head entity domain information, relation domain information, and tail entity domain information of the corresponding triples from the domain knowledge base. Based on the head entity domain information, relation domain information, and tail entity domain information, extract the head entity description, relation description, and tail entity description of the corresponding triples respectively. The natural language text sequence is generated based on the head entity, head entity description, relation, relation description, tail entity, and tail entity description.
4. The method according to claim 3, characterized in that, The step of extracting the head entity description, relation description, and tail entity description of the corresponding triples based on the head entity domain information, relation domain information, and tail entity domain information specifically includes: Extract the core domain definition of the head entity from the professional domain information of the head entity, and obtain the associated neighbor entities and associated domain attribute information of the corresponding head entity in the domain knowledge graph. Generate the head entity description based on the core domain definition, the associated neighbor entities and the associated domain attribute information. Extract the core domain definition, associated business rules and constraint information of the relationship from the professional domain information, and generate the relationship description based on the core domain definition, associated business rules and constraint information; Extract the core domain definition of the tail entity from the tail entity's professional domain information, and obtain the associated neighbor entities and associated domain attribute information of the corresponding tail entity in the domain knowledge graph. Generate the tail entity description based on the core domain definition, the associated neighbor entities, and the associated domain attribute information.
5. The method according to claim 1, characterized in that, The process of generating the text embedding vector corresponding to the natural language text sequence based on the pre-trained embedding model specifically includes: Obtain preset sequence markers, which include at least a sequence start marker, a sequence segmentation marker, and a domain-specific marker; By sequentially inserting the sequence start marker and the sequence segment marker into multiple natural language sequence segments, and assigning a domain-specific marker to each natural language sequence segment, a standardized input sequence is generated; The standardized input sequence is input into the pre-trained embedding model.
6. The method according to claim 5, characterized in that, After inputting the standardized input sequence into the pre-trained embedding model, the method further includes: After encoding the standardized input sequence, the encoded output is fused using average pooling to generate the text embedding vector.
7. The method according to claim 1, characterized in that, The joint loss function of the pre-trained embedding model includes a structural loss term and a supervised contrastive loss term; The process involves generating text embedding vectors corresponding to the natural language text sequence based on a pre-trained embedding model, and performing structural information learning and supervised comparative learning of positive and negative samples based on the text embedding vectors and the inherent structural information of the domain knowledge graph to obtain the semantic structure fusion vector corresponding to the triples. Specifically, this includes: The text embedding vectors corresponding to the natural language text sequence are generated based on the pre-trained embedding model. The structural loss value corresponding to the inherent structural information of the text embedding vector and the domain knowledge graph is calculated by using the structural loss term in the joint loss function of the pre-trained embedding model. The contrastive loss value between the text embedding vectors corresponding to the positive and negative samples of the triple is calculated using the supervised contrastive loss term in the joint loss function of the pre-trained embedding model. Based on the structural loss value and the comparative loss value, the joint loss value of the joint loss function is determined; The model parameters of the pre-trained embedding model are adjusted based on the joint loss value until the iteration stopping condition is met, thereby obtaining the semantic structure fusion vector of the triple.
8. The method according to claim 7, characterized in that, Before calculating the structural loss value corresponding to the inherent structural information of the text embedding vector and the domain knowledge graph, the method further includes: Based on the text embedding vector, entity association features and topological structure features are extracted from the text embedding vector; Based on the entity association features and the topological structure features, the inherent structural information of the domain knowledge graph is generated.
9. The method according to claim 7, characterized in that, Before calculating the contrastive loss value between the text embedding vectors corresponding to the positive and negative samples of the triples, the following steps are included: All real-world triples in the domain knowledge graph are identified as positive samples. The negative sample is generated by performing entity replacement processing based on the positive sample.
10. The method according to claim 9, characterized in that, The step of performing entity replacement processing based on the positive samples to generate the negative samples specifically includes: From the full entity set of the domain knowledge graph, select entities other than the original tail entity of the corresponding positive sample, replace the tail entity of the corresponding positive sample, and generate the corresponding negative sample; and / or, The head entity of the corresponding positive sample is used as the replacement entity to replace the tail entity of the corresponding positive sample, thus generating the corresponding negative sample.
11. The method according to claim 7, characterized in that, The formula for calculating the joint loss function is as follows: Where L is the joint loss value corresponding to the joint loss function, G is the set of all real triples in the domain knowledge graph, h is the head entity of the triple, r is the relation of the triple, and t is the tail entity of the triple; Pr(h|r,t) is the matching probability of the head entity h given relation r and tail entity t, Pr(r|h,t) is the matching probability of relation r given head entity h and tail entity t, and Pr(t|h,r) is the matching probability of tail entity t given head entity h and relation r; P is the set of positive samples, N is the set of negative samples, score(h,r,t) is the structural score of the positive sample triple, score(h,r,t′) is the structural score of the negative sample triple, y is the sample label, y=1 for positive samples and y=0 for negative samples, used to distinguish between positive and negative samples, and τ is the temperature hyperparameter.
12. A knowledge graph completion device, characterized in that, The device includes: The first acquisition unit is used to acquire triples in the domain knowledge graph and construct a corresponding domain knowledge base based on the triples in the domain knowledge graph. The first processing unit is used to obtain entity descriptions and relation descriptions of the triples in the domain knowledge base through a large model, and generate natural language text sequences corresponding to the triples based on the entity descriptions and relation descriptions; The second processing unit is used to generate text embedding vectors corresponding to the natural language text sequence based on the pre-trained embedding model, and to perform structural information learning and supervised comparative learning of positive and negative samples based on the text embedding vectors and the inherent structural information of the domain knowledge graph, so as to obtain the semantic structure fusion vector corresponding to the triple.
13. An electronic device, characterized in that, The electronic device includes: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements the knowledge graph completion method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the knowledge graph completion method as described in any one of claims 1 to 11.
15. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the electronic device, the electronic device performs the knowledge graph completion method as described in any one of claims 1 to 11.