An ontology and large language model-based knowledge graph construction method
By combining ontology modeling and large language modeling with an adaptive chain-like reasoning strategy, this approach solves the problem of existing technologies relying on manual rules and labeled data for knowledge graph construction. It achieves automated generation of high-quality triples and semantic consistency, making it suitable for knowledge graph construction of multi-source heterogeneous data.
Patent Information
- Application Number
- CN202511486533.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-17
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2045-10-17
AI Technical Summary
Existing knowledge graph construction methods rely on manual rules and labeled data, making it difficult to achieve high semantic consistency and interpretability in specific domains. Furthermore, large language models have limited performance in specific domains and cannot meet the accuracy requirements in complex semantic scenarios.
By combining ontology modeling and large language models, and through an adaptive chain-thinking reasoning strategy, semantic knowledge is extracted from multi-source heterogeneous data to construct a consistent and reasonable knowledge graph, including initial ontology construction, expanded candidate set verification, triple extraction using an adaptive chain-thinking mechanism, and heterogeneous data fusion.
It enables the automatic generation and semantic verification of high-quality triples without requiring extensive manual annotation, improving the structural standardization, semantic consistency, and multi-source data processing capabilities of knowledge graphs, and is suitable for various application scenarios.
Smart Images

Figure CN120973960B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence and knowledge graph construction, specifically involving a knowledge graph construction method based on ontology and large language model. Background Technology
[0002] Knowledge graphs (KGs), as a structured semantic representation method, have been widely applied in various fields such as aerospace, industry, medicine, and agriculture. Knowledge graphs are typically represented in the form of triples (entity-relation-entity, i.e., relation triples) or attribute pairs (entity-attribute-attribute value, i.e., attribute triples) to capture semantic relationships between entities from massive amounts of data, improving information organization and machine understandability. The quality of its construction largely determines the performance of downstream applications, such as intelligent question answering, recommendation systems, and reasoning analysis.
[0003] Existing knowledge graph construction methods mainly fall into two categories: one is based on manually defined rules or ontology languages, which extract entities and relations from text through predefined rules or templates, emphasizing the consistency of semantic structure. Ontology, as a knowledge modeling tool, defines concepts, attributes, and their relationships, providing structural specifications and logical constraints for the extraction process. For example, the YAGO system proposed by Suchanek et al., by integrating Wikipedia and WordNet ontology, achieves accurate alignment of entity types and relations, enhancing the standardization of knowledge extraction. The other category is based on deep learning models, such as named entity recognition and relation extraction models, which have a certain degree of automation, but still rely on large amounts of labeled data in specific domains. The ACKG-LLM framework proposed by Wang et al. optimizes embedding representations through a phased strategy, improving extraction efficiency, but its support for prior knowledge remains weak, making it difficult to meet the accuracy requirements of complex semantic scenarios.
[0004] In recent years, the development of Large Language Models (LLMs) has brought new technical pathways to knowledge graph construction. LLMs are a class of deep neural network models trained on large-scale corpora, possessing powerful language understanding and generation capabilities. In knowledge extraction scenarios, LLMs can leverage prompts to complete entity recognition and relation generation tasks, significantly reducing the need for manual annotation. Li et al. combined LLMs with ontology prompts, extracting specialized triples from operation and maintenance manuals to construct reasonable knowledge networks. However, the performance of general-purpose LLMs in specific domains remains limited, prone to issues such as terminology comprehension bias and redundant extraction results, lacking clear structural constraint mechanisms, and exhibiting insufficient interpretability of results.
[0005] Therefore, current knowledge graph construction still faces many challenges, including: (1) how to reduce the dependence on manual rules and labeled data; (2) how to improve the semantic consistency and accuracy of extracting triples from unstructured data; and (3) how to improve the interpretability and logical traceability of the knowledge extraction process. These issues have become key factors restricting the automation and large-scale development of knowledge graph construction. Summary of the Invention
[0006] To overcome the problems of low automation and poor semantic consistency in existing technologies for knowledge graph construction, this invention proposes a knowledge graph construction method based on ontology and large language model. This method introduces ontology modeling and expansion mechanisms, integrates adaptive chain-like reasoning strategies, and extracts semantic knowledge from multi-source heterogeneous data to finally construct a knowledge graph with consistency and reasonability.
[0007] This invention provides the following technical solution:
[0008] A knowledge graph construction method based on ontology and large language model, the method comprising the following steps:
[0009] The first step, the initial ontology construction for the knowledge extraction task, includes the following sub-steps:
[0010] Step (1.1) Domain requirements analysis and scope definition;
[0011] Step (1.2) Ontology reuse;
[0012] Step (1.3) Concept classification and hierarchical structure construction;
[0013] Step (1.4) Relationship definition and attribute modeling: Based on the completed conceptual structure, define the semantic relationships between concepts and the attribute information of each concept to form a complete ontology structure framework;
[0014] Step (1.5) Attribute system design: Systematically design the attributes of each concept to define the key features of the entity and ensure the standardization and inheritability of the attributes;
[0015] The second step, the ontology expansion method based on the large language model, includes the following sub-steps:
[0016] Step (2.1) LLM automatically generates an expanded candidate set;
[0017] Step (2.2) Extend candidate consistency verification;
[0018] Step (2.3) Update the domain ontology;
[0019] The third step involves automatically extracting triples using an adaptive chain thinking mechanism.
[0020] The fourth step is to integrate triples and construct knowledge graphs for heterogeneous data.
[0021] Furthermore, the process of step (1.1) is as follows:
[0022] Step (1.1.1) involves a functional analysis of the application scenarios of the target knowledge graph, clarifying the core tasks that users are concerned with, and extracting the entity types, relation types, and their granularity levels that the target system needs to support, in order to determine the application goals of the knowledge graph; this goal is defined as... This indicates the functional orientation and usage scenario of the ontology construction task;
[0023] Step (1.1.2) involves performing domain boundary analysis on the knowledge scope involved in constructing the knowledge graph, including the types of original data sources and common terminology systems within the domain; this is used to comprehensively form the knowledge coverage of the domain, defined as... This indicates the professional field or topic that the knowledge graph addresses;
[0024] Step (1.1.3) builds upon the results of steps (1.1.1) and (1.1.2), clarifying the knowledge extraction boundaries and semantic representation constraints that the ontology should adhere to, defined as follows: This is used to limit the depth and precision of knowledge covered by the ontology; the final output domain-scope formalized triple is:
[0025] ;
[0026] in Scope It represents the semantic boundary of the domain on which the initial ontology construction depends.
[0027] The process of step (1.2) is as follows:
[0028] Step (1.2.1) Acquisition of candidate ontologies: Collect and organize existing domain-related ontologies, and establish an ontology candidate set, denoted as . ;
[0029] Step (1.2.2) is based on direct reuse of structure matching. If there are candidate ontologies that highly match the target task, semantic alignment is performed using the structure matching method, and the candidate ontology with the highest matching degree is selected as the basis for expansion. The specific process can be formally represented as follows:
[0030] ;
[0031] In the formula, This represents the newly constructed ontology structure. This represents the existing candidate ontology structure. The target task requires an ontology structure. EvaluateMatch(⋅) is a structure semantic matching function used to perform semantic alignment and structure mapping between the existing ontology and the target structure. Extension represents the ontology structure that needs to be further extended based on the matching results.
[0032] Step (1.2.3) involves indirect reuse based on the reference domain. If a highly matching ontology does not exist, suitable concepts, relationships, and attribute fragments are extracted by analyzing external ontology resources related to the target domain. Terminology mapping and semantic adjustment are then performed to complete the indirect construction of the domain ontology structure.
[0033] ;
[0034] In the formula, This represents the external reference ontology structure in the relevant domain. (⋅) represents a method for extracting transferable terminology definitions and structural elements from an external ontology of the reference domain. This refers to the structural fragment obtained after performing necessary semantic mapping and adjustments on the extracted terms and structures.
[0035] The process of step (1.3) is as follows:
[0036] Step (1.3.1) Extraction and confirmation of core domain concepts: Based on the domain scope constraints obtained in step (1.1) Scope Extracting a set of core terms directly related to the scope of the field from authoritative information, expert knowledge, and data resources, a preliminary concept set is formed. ConceptSet The extracted terms are deduplicated, ambiguous, and conceptually unified to ensure the accuracy and uniqueness of the initial concept set;
[0037] Step (1.3.2) Concept Semantic Classification: Define concept sets according to different knowledge granularities. ConceptSet Based on the concept categories, a preliminary semantic classification system is constructed, and a top-down approach is used to rationally organize and adjust the granularity of the concepts.
[0038] Step (1.3.3) Construction and optimization of the concept hierarchy: Based on the semantic classification obtained in step (1.3.2), the semantic hierarchy of domain concepts is constructed by clarifying the inheritance relationship between concepts, i.e., the is-a relationship. The specific process can be formally represented as follows:
[0039] ;
[0040] in, Representing sub-concepts, This formula indicates that all concepts with direct inheritance relationships in the ConceptSet constitute a concept hierarchy, where there is a clear generalization relationship between them. .
[0041] The process of step (1.4) is as follows:
[0042] Step (1.4.1) Construction and expression of object properties: Based on the concept set ConceptSet and its hierarchical structure obtained above, identify the multidimensional semantic relationships between different concept entities, including structural relationships, functional relationships, and logical relationships, and model them as object properties ObjectProperty;
[0043] Structural relationships refer to the semantic associations formed between conceptual entities based on compositional hierarchy, inclusion relationship, or subordinate structure, and are used to describe the structural connections between the whole and its parts;
[0044] Functional relationships refer to the functional associations formed between conceptual entities in the process of performing tasks or achieving specific goals, reflecting the semantic connections between entities in terms of functional division of labor, collaborative operation, etc.
[0045] Logical relationships refer to the semantic connections established between conceptual entities based on logical rules, used to express the inherent logical structure and reasoning path between knowledge;
[0046] Object properties need to explicitly define their scope (Domain), applicable object range (Range), and semantic relationship name, which can be formally represented as:
[0047] ;
[0048] in, For the object relation name, , These represent the starting and ending entities associated with the object's attributes, respectively.
[0049] Step (1.4.2) Introduction and Modeling of Semantic Constraint Types: To enhance the semantic expressive power of object attributes and improve the accuracy and consistency of knowledge reasoning, semantic constraint types are further introduced during the definition process of object attributes, and a set of constraint types is constructed. SemanticConstraintSet This set is used to regulate the logical behavior of each object attribute in semantic reasoning, and its formal definition is as follows:
[0050] ;
[0051] In the formula For the object relation name, ConstraintType This indicates the semantic feature type possessed by the attribute. Represents a set of constraint types, including symmetry. Symmetric Transitivity Transitive reflexivity Reflexive Antisymmetry Asymmetric and functionality Functional Its definition is as follows:
[0052] ;
[0053] Symmetry means that if there is a certain relationship between entity 1 and entity 2, then there is also the same relationship between entity 2 and entity 1.
[0054] Transitivity means that if there is a certain relationship between entity 1 and entity 2, and there is also a certain relationship between entity 2 and entity 3, then entity 1 and entity 3 also have that relationship.
[0055] Reflexivity refers to the fact that an entity itself also satisfies a certain relationship with itself, that is, the relationship is self-applicable to the same object;
[0056] Antisymmetry means that if a certain relationship exists between entity 1 and entity 2, then that relationship cannot exist between entity 2 and entity 1 at the same time. This property is used to express semantic connections that are highly directional and irreversible.
[0057] Functionality refers to the fact that a relation can only point to a single target entity for a given entity, that is, the relation has a single-value constraint.
[0058] In step (1.5), the formal representation of the attribute system is as follows:
[0059] ;
[0060] in, For concept class, For attributes, including name Data types Value range and constraints .
[0061] Furthermore, in step (2.1), to ensure logical consistency and domain adaptability of the extension, domain rules are introduced during the extension process. As a constraint framework;
[0062] ;
[0063] in, 、 、 These represent the concept set, attribute set, and object relation set, respectively. The specific rules include:
[0064] (1) Conceptual hierarchy constraints ;
[0065] (2) Limitations on the legality of the relationship ;
[0066] (3) Attribute assignment specification ;
[0067] (4) Inference rules ;
[0068] Among them, in the conceptual level constraints, Used to indicate a concept It is a concept Subclasses; Relationship legality rules Require each relationship It must have a clear and That is, its initial concept is The concept of termination is Attribute Assignment Rules Limited attributes The data type must belong to the data type set; the reasoning rule states that if the concept With concept Through some kind of relationship By making connections, new relationships can be inferred. To enhance the deductive ability of knowledge graphs;
[0069] Let the current domain ontology be represented as:
[0070] ;
[0071] in, This represents the current set of object relationships;
[0072] Will and rules As input to the LLM, the LLM uses this information to infer potential expansion directions and generate a set of expansion candidates:
[0073] ;
[0074] Each of them It represents a potentially new concept, attribute, or relationship.
[0075] Preferably, in step (2.2), for For each extension item in the domain, a domain rule validation function is introduced:
[0076] ;
[0077] If it satisfies all relevant domain rules, then ;otherwise, After verification, the high-quality extended set was retained:
[0078] ;
[0079] In step (2.3), the filtered extended content Merge into the original entity In this process, a new, updated ontology is formed:
[0080] ;
[0081] The entities, relations, attributes, and attribute value sets in the final new ontology are denoted as follows: and , This is used for the ontology constraints in the third step.
[0082] Furthermore, in the third step, For the head entity, For the relationship, For tail entities, Represents a possible set of entities. Represents the set of possible relationships. For entities, As an attribute, For attribute values, For the set of candidate attributes, The possible range of attribute values includes the following sub-steps:
[0083] Step (3.1) Initial generation of candidate triples, which involves processing the text. Input a large language model and extract candidate relation triples and attribute triples directly from the text using Zero-Shot-CoT:
[0084] ;
[0085] ;
[0086] Zero-Shot-CoT refers to automatically generating output containing intermediate reasoning processes for large language models by designing guiding prompts for them, without providing any human examples.
[0087] Step (3.2) Ontology constraint matching: Set ontology constraints for the knowledge graph and filter relation triples and attribute triples that meet the following conditions:
[0088] ;
[0089] ;
[0090] Step (3.3) Confidence calculation and high confidence screening: Calculate the confidence of each triple based on LLM. and set a threshold To screen for high-confidence candidates:
[0091] ;
[0092] ;
[0093] In this step, the The confidence score is calculated by LLM based on the internal probability distribution during its generation process. In the process of generating triples, LLM assigns a corresponding probability value to each component to measure its semantic rationality in the current context. The overall confidence score is calculated by combining the probabilities of each component to ensure that the value can accurately reflect the credibility of the triple.
[0094] Step (3.4) Knowledge base cross-validation: If a high-quality external knowledge base exists in the target domain, the authenticity of the triples is further verified.
[0095] ;
[0096] ;
[0097] in, It is a binary function that returns 1 if the knowledge base verifies that the triplet is valid, and 0 otherwise.
[0098] The triples obtained in this step will serve as high-quality Few-Shot example triples in step (3.5) Few-Shot-CoT;
[0099] Step (3.5) Few-Shot-CoT iterative inference, based on the high-quality Few-Shot examples automatically selected from the previous stage and the target text. Then, perform secondary reasoning to construct a new set of knowledge triples. :
[0100] ;
[0101] in, For the confidence function, here and in step (3.6) These are the head entity, relation, tail entity, entity, attribute, and attribute value generated after secondary reasoning.
[0102] Step (3.6) Error feedback and final correction, for All triples are then subjected to ontology verification and manual review to remove non-compliant or inaccurate items, resulting in the final output set of triples. :
[0103] ;
[0104] This set The triples extracted from unstructured text will be further processed in the fourth step.
[0105] The fourth step includes the following sub-steps:
[0106] Step (4.1) Mapping and transformation of structured data triples;
[0107] For structured data, the system integrates a D2R mapping mechanism to convert primary keys, foreign keys, and field names in tables into standardized triples according to mapping specifications, and then incorporate them into a unified semantic representation system;
[0108] Step (4.2) Parsing and extracting semi-structured data triples: For semi-structured data, the data fragments are mapped into standard "entity-relationship-entity" or "entity-attribute-attribute value" triples using Wrapper.
[0109] Step (4.3) Fusion and normalization of multi-source triples: This involves fusing and normalizing the triples extracted from the unstructured data source in the previous steps. The triples extracted from semi-structured and structured data sources are processed uniformly, and a set of triples with high consistency and semantic regularity is generated through redundancy elimination and format standardization strategies.
[0110] Step (4.4) Knowledge graph construction: Import the set of triples generated in the above steps into the graph database to construct a knowledge graph with a reasonable structure and complete semantics.
[0111] The beneficial effects of the present invention are as follows:
[0112] 1. This invention integrates ontology modeling mechanism with the reasoning ability of large language model, which can automatically identify and organize concepts, attributes and relationships within the domain, effectively improving the structural standardization and semantic consistency of knowledge graph construction.
[0113] 2. The Adaptive CoT mechanism proposed in this invention combines ontology-driven semantic verification and rule constraints to achieve automatic generation, optimization and semantic verification of high-quality triples without the need for a large number of manually labeled samples. This reduces construction costs and improves the accuracy and robustness of knowledge extraction.
[0114] 3. This invention supports unified processing capabilities for multi-source heterogeneous data, and can simultaneously adapt to unstructured text, semi-structured template information and structured databases, realizing the mapping of multi-source heterogeneous data to semantic graphs, thus enhancing the versatility and scalability of the method.
[0115] 4. This invention provides an end-to-end automated process from ontology modeling and knowledge extraction to graph construction, which is applicable to a variety of application scenarios and has good prospects for promotion and engineering implementation value. Attached Figure Description
[0116] Figure 1 This is a knowledge graph construction framework diagram based on ontology and large language model. Detailed Implementation
[0117] The present invention will now be further described with reference to the accompanying drawings.
[0118] Reference Figure 1 A knowledge graph construction method based on ontology and large language model, the method includes the following steps:
[0119] The first step is the initial ontology construction method for knowledge extraction tasks. This method uses the acquired ontology data and the following steps (such as...). Figure 1 As shown, steps 1-5 within the "Ontology" area corresponding to the "Ontology Data" are completed, including the following sub-steps:
[0120] Step (1.1) Domain requirements analysis and scope definition, including the following processes:
[0121] Step (1.1.1) involves a functional analysis of the application scenarios of the target knowledge graph, clarifying the core tasks that users are concerned with, and extracting the entity types, relation types, and their granularity levels that the target system needs to support, in order to determine the application goals of the knowledge graph; this goal is defined as... This indicates the functional orientation and usage scenario of the ontology construction task;
[0122] Ontology is a structured knowledge modeling approach that aims to formally define concepts, relationships, and attributes in a specific domain. Concepts refer to entity categories within the domain; relationships describe the semantic connections between different concepts; and attributes characterize the features of the entities themselves.
[0123] Step (1.1.2) involves performing domain boundary analysis on the knowledge scope involved in constructing the knowledge graph, including the types of original data sources and common terminology systems within the domain; this is used to comprehensively form the knowledge coverage of the domain, defined as... This indicates the professional field or topic that the knowledge graph addresses;
[0124] Step (1.1.3) builds upon the results of steps (1.1.1) and (1.1.2), clarifying the knowledge extraction boundaries and semantic representation constraints that the ontology should adhere to, defined as follows: This is used to limit the depth and precision of knowledge covered by the ontology; the final output domain-scope formalized triple is:
[0125] ;
[0126] in Scope It represents the semantic boundary of the domain on which the initial ontology construction depends.
[0127] Step (1.2) Ontology reuse includes the following process:
[0128] Step (1.2.1) Acquisition of candidate ontologies. By collecting Ontology Data and organizing existing domain-related ontologies, a candidate ontology set is established, denoted as […]. ;
[0129] Step (1.2.2) involves direct reuse based on structure matching. If a candidate ontology highly matches the target task, semantic alignment is performed using the structure matching method. The candidate ontology with the highest matching degree is selected as the basis for expansion. The specific process can be formally represented as follows:
[0130] ;
[0131] In the formula, This represents the newly constructed ontology structure. This represents the existing candidate ontology structure. The target task requires an ontology structure. EvaluateMatch(⋅) is a structure semantic matching function used to perform semantic alignment and structure mapping between the existing ontology and the target structure. Extension represents the ontology structure that needs to be further extended based on the matching results.
[0132] Step (1.2.3) involves indirect reuse based on the reference domain. If a highly matching ontology does not exist, suitable concepts, relations, and attribute fragments are extracted by analyzing external ontology resources related to the target domain. Terminology mapping and semantic adjustment are then performed to indirectly construct the domain ontology structure.
[0133] ;
[0134] In the formula, This represents the external reference ontology structure in the relevant domain. (⋅) represents a method for extracting transferable terminology definitions and structural elements from an external ontology of the reference domain. This refers to the structural fragment obtained after performing necessary semantic mapping and adjustments on the extracted terms and structures;
[0135] Step (1.3) Concept classification and hierarchical structure construction, the process is as follows:
[0136] Step (1.3.1) Extraction and confirmation of core domain concepts: Based on the domain scope constraints obtained in step (1.1) Scope The process involves extracting a set of core terms directly related to the domain from authoritative domain materials, expert knowledge, and data resources to form a preliminary concept set (ConceptSet). The extracted terms are then deduplicated, ambiguous, and conceptually unified to ensure the accuracy and uniqueness of the preliminary concept set.
[0137] Ambiguity resolution refers to determining the true semantic meaning of a term by analyzing the context and ontology knowledge when multiple meanings or referents exist, and then mapping it to a single standard concept to avoid ambiguity interfering with subsequent processing.
[0138] Step (1.3.2) Concept Semantic Classification: Define the concept categories of the ConceptSet according to different knowledge granularities to construct a preliminary semantic classification system. A top-down approach is used to rationally organize and adjust the granularity of the concepts.
[0139] The top-down approach refers to a construction strategy in ontology modeling that moves from macro to micro and from abstract to concrete. This method first defines high-level abstract concepts within the domain, then refines them layer by layer into more specific subclass concepts, and establishes inheritance relationships between each level.
[0140] Step (1.3.3) Construction and optimization of the concept hierarchy: Based on the semantic classification obtained in step (1.3.2), the semantic hierarchy of domain concepts is constructed by clarifying the inheritance relationship (is-a relationship) between concepts. The specific process can be formally represented as follows:
[0141] ;
[0142] in, Representing sub-concepts, This indicates its direct parent concept, and there is a clear generalization relationship between the two. This formula means that in the concept set ConceptSet, all concept pairs with direct inheritance relationships constitute a concept hierarchy. ;
[0143] Step (1.4) Relationship Definition and Attribute Modeling: Based on the completed conceptual structure, define the semantic relationships between concepts and the attribute information of each concept to form a complete ontology structure framework, including the following processes:
[0144] Step (1.4.1) Construction and expression of object properties: Based on the concept set ConceptSet and its hierarchical structure obtained above, identify the multidimensional semantic relationships between different concept entities, including structural relationships, functional relationships, and logical relationships, and model them as object properties ObjectProperty;
[0145] Structural relationships refer to the semantic associations formed between conceptual entities based on compositional hierarchy, inclusion relationship, or subordinate structure, and are used to describe the structural connections between the whole and its parts;
[0146] Functional relationships refer to the functional associations formed between conceptual entities in the process of performing tasks or achieving specific goals, reflecting the semantic connections between entities in terms of functional division of labor, collaborative operation, etc.
[0147] Logical relationships refer to the semantic connections established between conceptual entities based on logical rules, used to express the inherent logical structure and reasoning path between knowledge;
[0148] Object properties need to explicitly define their scope (Domain), applicable objects (Range), and semantic relationship name, which can be formally represented as follows:
[0149] ;
[0150] in, For the object relation name, , These represent the starting and ending entities associated with the object's attributes, respectively.
[0151] Step (1.4.2) Introduction and Modeling of Semantic Constraint Types: To enhance the semantic expressive power of object attributes and improve the accuracy and consistency of knowledge reasoning, semantic constraint types are further introduced during the definition process of object attributes, and a set of constraint types is constructed ( SemanticConstraintSet This set is used to regulate the logical behavior of each object attribute in semantic reasoning, and its formal definition is as follows:
[0152] ;
[0153] In the formula For the object relation name, ConstraintType This indicates the semantic feature type possessed by the attribute. A set representing constraint types, including symmetry ( Symmetric ), transitivity ( Transitive ), reflexivity ( Reflexive) Antisymmetry ( Asymmetric ) and functionality ( Functional) Its definition is as follows:
[0154] ;
[0155] Symmetry means that if there is a certain relationship between entity 1 and entity 2, then there is also the same relationship between entity 2 and entity 1.
[0156] Transitivity means that if there is a certain relationship between entity 1 and entity 2, and there is also a certain relationship between entity 2 and entity 3, then entity 1 and entity 3 also have that relationship.
[0157] Reflexivity refers to the fact that an entity itself also satisfies a certain relationship with itself, that is, the relationship is self-applicable to the same object;
[0158] Antisymmetry means that if a certain relationship exists between entity 1 and entity 2, then that relationship cannot simultaneously exist between entity 2 and entity 1. This property is used to express semantic connections that are highly directional and irreversible.
[0159] Functionality means that a relation can only point to a single target entity for a given entity, that is, the relation has a single-value constraint;
[0160] Step (1.5) Attribute System Design: Systematically design the attributes of each concept to define the key features of the entity and ensure the standardization and inheritability between attributes. The formal representation of the attribute system is as follows:
[0161] ;
[0162] in, For concept class, For attributes, including name ( ), data types ( ), range of values ( ) and constraints ( ).
[0163] Step 2: Ontology expansion based on a large language model, including the following sub-steps:
[0164] Step (2.1) LLM automatically generates an extended candidate set. This step is based on the existing ontology and uses LLM to generate potential new concepts, attributes, and relationships to further enrich the knowledge system. To ensure logical consistency and domain adaptability of the extension, domain rules are introduced in the extension process. As a constraint framework;
[0165] ;
[0166] in, , , These represent the concept set, attribute set, and object relation set, respectively. The specific rules include:
[0167] (1) Conceptual hierarchy constraints ;
[0168] (2) Limitations on the legality of the relationship ;
[0169] (3) Attribute assignment specification ;
[0170] (4) Inference rules ;
[0171] Among them, in the conceptual level constraints, Used to indicate a concept It is a concept Subclasses; Relationship legality rules Require each relationship It must have a clear and That is, its initial concept is The concept of termination is Attribute Assignment Rules Limited attributes The data type must belong to a set of data types, such as string type, integer type, etc.; the reasoning rule indicates that if the concept With concept Through some kind of relationship By making connections, new relationships can be inferred. To enhance the deductive ability of knowledge graphs;
[0172] Let the current domain ontology be represented as:
[0173] ;
[0174] in, This represents the current set of object relationships.
[0175] Will and rules As input to the LLM, the LLM uses this information to infer potential expansion directions and generate a set of expansion candidates:
[0176] ;
[0177] Each of them It represents a potentially new concept, attribute, or relationship.
[0178] Step (2.2) Extend candidate consistency verification. For For each extension item in the domain, a domain rule validation function is introduced:
[0179] ;
[0180] If it satisfies all relevant domain rules, then Otherwise, After verification, the high-quality extended set was retained:
[0181] ;
[0182] Step (2.3) Update the domain ontology, such as Figure 1 As shown. The filtered extended content Merge into the original entity In this process, a new, updated ontology is formed:
[0183] ;
[0184] The entities, relations, attributes, and attribute value sets in the final new ontology are denoted as follows: and , This is used for the ontology constraints in the third step.
[0185] The third step involves automatic triple extraction using an adaptive chain-thinking mechanism. To achieve automated and high-precision knowledge triple extraction, this invention proposes an automatic triple extraction method combining adaptive chain-thinking (Adaptive CoT). This method ensures semantic consistency and structural validity of the results while minimizing reliance on manual examples. Figure 1 The third step, as shown in the box labeled "Data for LLM Input," includes the following sub-steps:
[0186] In the following steps For the head entity, For the relationship, For tail entities, Represents a possible set of entities. Represents the set of possible relationships. For entities, As an attribute, For attribute values, For the set of candidate attributes, This represents the possible range of values for the attribute.
[0187] Step (3.1) Initial generation of candidate triples: The text to be processed... Input a large language model and extract candidate relation triples and attribute triples directly from the text using Zero-Shot-CoT:
[0188] ;
[0189] ;
[0190] Zero-Shot-CoT refers to automatically generating output containing intermediate reasoning processes for large language models by designing guided prompts for them, without providing any human examples.
[0191] Step (3.2) Ontology Constraint Matching: Set ontology constraints for the knowledge graph and filter relation triples and attribute triples that meet the following conditions:
[0192] ;
[0193] ;
[0194] Step (3.3) Confidence Calculation and High-Confidence Screening. Calculate the confidence score for each triple based on LLM. and set a threshold To screen for high-confidence candidates:
[0195] ;
[0196] ;
[0197] In this step, the The confidence score is calculated by LLM based on the internal probability distribution during its generation process. Specifically, during the generation of triples, LLM assigns a corresponding probability value to each component (including entities and relations) to measure its semantic reasonableness in the current context. The overall confidence score is calculated by combining the probabilities of each component to ensure that the value can accurately reflect the credibility of the triple.
[0198] Step (3.4) Knowledge Base Cross-Validation: If a high-quality external knowledge base exists in the target domain, the authenticity of the triples is further verified:
[0199] ;
[0200] ;
[0201] in, It is a binary function that returns 1 if the knowledge base verifies that the triplet is valid, and 0 otherwise.
[0202] The triples obtained in this step will serve as high-quality Few-Shot example triples in step (3.5) Few-Shot-CoT.
[0203] Step (3.5) Few-Shot-CoT Iterative Reasoning: Few-Shot-CoT refers to providing a small number of labeled "question-reasoning process-answer" examples to a large language model to guide the model to imitate the reasoning logic and thus complete the reasoning task for new inputs.
[0204] In this step, based on the high-quality Few-Shot examples automatically selected from the previous stage and the target text... Then, perform secondary reasoning to construct a new set of knowledge triples. :
[0205] ;
[0206] in, This is the confidence function. This is relevant here and in step (3.6). These are the head entity, relation, tail entity, entity, attribute, and attribute value generated after secondary reasoning.
[0207] Step (3.6) Error Feedback and Final Correction. All triples are then subjected to ontology verification and manual review to remove non-compliant or inaccurate items, resulting in the final output set of triples. :
[0208] ;
[0209] This set The triples extracted from unstructured text will be further processed in the fourth step.
[0210] The fourth step, triple fusion and knowledge graph construction for heterogeneous data, includes the following sub-steps:
[0211] Step (4.1) Mapping and transformation of structured data triples,
[0212] like Figure 1 As shown, for structured data, the system integrates a D2R (Data-to-RDF) mapping mechanism to convert the primary keys, foreign keys, and field names in the database table into standardized triples according to the mapping specification, and then incorporate them into a unified semantic representation system;
[0213] D2R mapping is a technique that automatically converts structured data into RDF format to achieve data integration from databases to the Semantic Web.
[0214] Step (4.2) Parsing and extraction of semi-structured data triples;
[0215] For semi-structured data, such as Infobox and JSON documents, Wrapper maps data fragments into standard "entity-relationship-entity" or "entity-attribute-attribute value" triples (collectively referred to as relation-attribute triples).
[0216] Wrappers are template-driven wrappers that can automatically identify entities, attributes, and relationships in data fragments, and implement a collaborative extraction strategy of pattern induction and semantic tag matching. They are especially suitable for scenarios with loose structures but well-organized information.
[0217] Step (4.3) Fusion and normalization of multi-source triples;
[0218] In this step, the triples extracted from the unstructured data source in the previous step are processed. And triples extracted from semi-structured and structured data sources (the three together are called the candidate triple set, such as...) Figure 1 (As shown) are processed uniformly, and through redundancy elimination and format standardization strategies, a set of triples with high consistency and semantic standardization is finally generated.
[0219] Redundancy elimination involves comparing the normalized triples and removing duplicates that are identical or semantically equivalent.
[0220] Format standardization refers to unifying the output format of triples to ensure that the format is consistent when entering data into the database and can be directly used for graph database modeling.
[0221] Step (4.4) Knowledge Graph Construction: Import the set of triples generated in the above steps into a graph database, such as Neo4j, to construct a knowledge graph with a reasonable structure and complete semantics.
[0222] The knowledge graph construction method based on ontology and large language model in this embodiment is compared and explained as follows:
[0223] Step 1 presents five methods for constructing knowledge graphs, as follows:
[0224] OpenIE 6: A knowledge graph construction method based on two-dimensional grid annotation, which generates multiple triples by predicting the sentence structure using labels.
[0225] Stanford OIE: A rule-based method for extracting triples from knowledge graphs. It first splits sentences into simplified clauses, and then extracts triples by matching preset templates.
[0226] DeepEx: A knowledge graph construction method based on language models that transforms information extraction tasks into text-to-trine translation problems.
[0227] PIVE: A knowledge graph construction method based on language models, which uses external small models to verify and correct the output of large models.
[0228] SAC-KG: A knowledge graph construction method based on language models, which gradually expands the triple information related to entities through generation, verification and pruning modules.
[0229] Step two, the experimental dataset is a public dataset, as follows:
[0230] OIE2016: This dataset contains a variety of sentence structures to test the ability of extraction systems to adapt to complex linguistic phenomena.
[0231] WEB: This dataset is derived from web page corpora, and its language expression is more free and colloquial;
[0232] NYT: News corpus taken from The New York Times, characterized by its complex semantic structure and dense entity content;
[0233] PENN: Originating from the semantic corpus of the University of Pennsylvania, it is often used for syntax and semantic annotation tasks.
[0234] Step 3, define the evaluation metrics F1 Score and AUC as follows:
[0235] F1 Score: This metric combines precision and recall to comprehensively reflect the overall performance of the model in the triplet extraction task.
[0236] The formula is expressed as follows:
[0237] ;
[0238] Precision and Recall are respectively:
[0239] ;
[0240] ;
[0241] In the formula, TP represents the number of correctly identified triples, FP represents the number of incorrectly extracted triples, and FN represents the number of unidentified triples.
[0242] AUC (Area Under Curve): This metric measures the confidence level of a model in ranking candidate triples and can effectively assess the reliability of the model's output confidence.
[0243] ;
[0244] in, This represents the set of positive samples (such as real triples). This represents the set of negative samples (such as incorrect triples). and These represent the model's performance on positive samples. and negative samples Confidence score, It is an indicator function that takes the value 1 when the score of a positive sample is higher than that of a negative sample, and 0 otherwise.
[0245] Step 4: Analyze and compare the results:
[0246] See Table 1 for the metrics of the knowledge graphs constructed by each method. The best experimental metrics are marked in bold in Table 1.
[0247]
[0248] Table 1
[0249] As shown in Table 1, the present invention achieves or surpasses the current state-of-the-art method in overall performance. Specifically, in the OIE2016, NYT, and PENN datasets, the present invention improves the F1 score by 1.4, 0.3, and 1.4 percentage points respectively compared to SAC-KG, and also improves the AUC score by 1.1, 0.8, and 1.1 percentage points respectively. These data not only demonstrate numerical improvements, but more notably, the improvements are more significant in datasets with high semantic complexity and structural diversity, namely NYT and PEN. This initially indicates that the present invention has a stronger adaptability to complex text data extraction. In the WEB dataset, although the F1 score of the present invention is slightly lower than that of SAC-KG, its AUC score is still slightly improved. This further reveals the robust performance of the present invention in confidence ranking, maintaining good output stability even when the extraction accuracy is close to saturation.
[0250] A thorough analysis of the differences between various methods reveals that while the OpenIE series of methods exhibits good recall performance, their extraction accuracy and generalization ability lag significantly behind language model-based methods. This is primarily due to the inability of traditional rule-driven methods to effectively address the semantic complexity and diversity of open text. In contrast, DeepEx and PIVE improve extraction performance through the powerful semantic understanding capabilities provided by language models, but still suffer from semantic ambiguity and error propagation issues. SAC-KG addresses this by introducing explicit validation and pruning modules, effectively mitigating this problem. However, the method proposed in this invention, by further integrating explicit ontology knowledge and the CoT inference mechanism, can more precisely constrain relation inference during the generation process, significantly reducing ambiguity and error propagation in relation and entity extraction. This advantage is particularly evident on datasets with higher complexity.
[0251] The knowledge graph construction method based on ontology and large language model in this embodiment is compared and explained as follows:
[0252] To further investigate the contribution of each core component in the proposed method to the knowledge graph construction performance, a series of ablation experiments were conducted. By systematically removing key modules from the framework, the contribution of each component to the overall performance of the method was quantitatively evaluated.
[0253] Step one, the constructed variant method is as follows:
[0254] (1) w / o Few-Shot-CoT: In the CoT mechanism, the Few-Shot-CoT stage is removed, and only Zero-Shot-CoT is retained; (2) w / o Ontology Validation: The ontology-based triple structure validation mechanism is removed; (3) w / o CoT: The CoT inference chain is completely removed, and only a simple prompt is used to complete the extraction task.
[0255] To ensure a fair comparison, all models were run with the same input text, model architecture, and parameter settings, with adjustments made only at the methodological level.
[0256] Step 2 uses four open-source OIE datasets: OIE2016, WEB, NYT, and PENN. The evaluation metrics are defined as F1 score and AUC score, which are used to measure the accuracy and overall discriminative ability of the model in the triplet extraction task.
[0257] Step 3: Analyze and compare the results:
[0258] See Table 2, which shows the metrics of the knowledge graphs constructed by each method. The best experimental metrics are marked in bold in the table.
[0259]
[0260] Table 2
[0261] As shown in Table 2, on the OIE2016 dataset, the complete method proposed in this invention achieved an F1 score of 76.1 and an AUC of 74.3, significantly outperforming all comparative variant methods. Removing the Few-Shot-CoT module reduced the F1 and AUC by 4.1 and 4.3 percentage points, respectively, indicating that example optimization plays a positive role in improving the contextual consistency and semantic accuracy of extraction. Further removal of the ontology verification mechanism caused the model's performance to decline further, with the AUC decreasing to 62.5 and the F1 score to 64.0, indicating that the lack of structural constraints allowed illegal or redundant triples to be mixed into the final output. The most significant performance degradation occurred when the CoT inference mechanism was completely removed: the F1 and AUC dropped to 50.0 and 48.5, respectively, a decrease of over 10 percentage points, reflecting the crucial role of the semantic inference chain in organizing information extraction.
[0262] This trend is also evident on the WEB, NYT, and PENN datasets. On the NYT dataset, removing the CoT module drops the F1 score to 58.0, a decrease of nearly 30 percentage points compared to the complete model. In the WEB dataset, the AUC drops from 96.1 to 67.0, showing that the inference chain mechanism is particularly crucial for extraction quality in complex scenarios. The PENN dataset also exhibits a performance degradation trend consistent with other datasets, further validating the universality and importance of each module. Overall, each module plays a significant role in improving model performance.
[0263] Overall, the removal of all three modules led to a performance decrease, but the magnitude of the decrease differed. Few-Shot-CoT primarily enhanced the model's refined understanding of semantic relationships between entities, while ontology verification was responsible for eliminating candidate triples that did not conform to format, semantics, or ontology. Together, they ensured the accuracy and structural regularity of the extraction results. In contrast, if CoT were completely removed, the model would be unable to construct a progressive inference path, and the extracted triples would exhibit loose structure and ambiguous relational expressions, validating the necessity of the CoT mechanism as a semantic guide.
[0264] In summary, this embodiment empirically verifies the independent value and complementarity of each module in the proposed method. Specifically, the CoT mechanism provides high-quality semantic path construction capabilities, while ontology verification constrains and corrects the structural results in a rule-based manner. This further confirms that the "reasoning + ontology" joint framework strategy integrated in the design of this invention has significant advantages in improving the quality and stability of triple extraction.
[0265] The embodiments described in this specification are merely examples of implementations of the inventive concept and are for illustrative purposes only. The scope of protection of this invention should not be considered limited to the specific forms described in these embodiments; rather, it extends to equivalent technical means conceived by those skilled in the art based on the inventive concept.
Claims
1. A method for constructing a knowledge graph based on ontology and a large language model, characterized in that, The method includes the following steps: The first step, the initial ontology construction for the knowledge extraction task, includes the following sub-steps: Step (1.1) Domain requirements analysis and scope definition; Step (1.2) Ontology reuse; Step (1.3) Concept classification and hierarchical structure construction; Step (1.4) Relationship definition and attribute modeling: Based on the completed conceptual structure, define the semantic relationships between concepts and the attribute information of each concept to form a complete ontology structure framework; Step (1.5) Attribute system design: Systematically design the attributes of each concept to define the key features of the entity and ensure the standardization and inheritability of the attributes; The second step, the ontology expansion method based on the large language model, includes the following sub-steps: Step (2.1) LLM automatically generates an expanded candidate set; Step (2.2) Extend candidate consistency verification; Step (2.3) Update the domain ontology; The third step involves the automatic extraction of triples using an adaptive chain-like thinking mechanism, including the following sub-steps: Step (3.1) Initial generation of candidate triples, which involves processing the text. Input a large language model and extract candidate relation triples and attribute triples directly from the text using Zero-Shot-CoT; Step (3.2) Ontology constraint matching: Set ontology constraints for the knowledge graph and filter triples and attribute triples that conform to the ontology constraint relationship; Step (3.3) Confidence calculation and high confidence screening: Calculate the confidence of each triple based on LLM. and set a threshold To screen for high-confidence candidates; Step (3.4) Knowledge base cross-validation: If a high-quality external knowledge base exists in the target domain, the authenticity of the triples will be further verified. Step (3.5) Few-Shot-CoT iterative inference, based on the high-quality Few-Shot examples automatically selected from the previous stage and the target text. Then, perform secondary reasoning to construct a new set of knowledge triples. ; Step (3.6) Error feedback and final correction, for All triples are then subjected to ontology verification and manual review to remove non-compliant or inaccurate items, resulting in the final output set of triples. ; The fourth step is to integrate triples and construct knowledge graphs for heterogeneous data.
2. The knowledge graph construction method based on ontology and large language model as described in claim 1, characterized in that, The process of step (1.1) is as follows: Step (1.1.1) involves a functional analysis of the application scenarios of the target knowledge graph, clarifying the core tasks that users are concerned with, and extracting the entity types, relation types, and their granularity levels that the target system needs to support, in order to determine the application goals of the knowledge graph; this goal is defined as... This indicates the functional orientation and usage scenario of the ontology construction task; Step (1.1.2) involves performing domain boundary analysis on the knowledge scope involved in constructing the knowledge graph, including the types of original data sources and common terminology systems within the domain; this is used to comprehensively form the knowledge coverage of the domain, defined as... This indicates the professional field or topic that the knowledge graph addresses; Step (1.1.3) builds upon the results of steps (1.1.1) and (1.1.2), clarifying the knowledge extraction boundaries and semantic representation constraints that the ontology should adhere to, defined as follows: This is used to limit the depth and precision of knowledge covered by the ontology; the final output domain-scope formalized triple is: ; in Scope It represents the semantic boundary of the domain on which the initial ontology construction depends.
3. The knowledge graph construction method based on ontology and large language model as described in claim 2, characterized in that, The process of step (1.2) is as follows: Step (1.2.1) Acquisition of candidate ontologies: Collect and organize existing domain-related ontologies, and establish an ontology candidate set, denoted as . ; Step (1.2.2) is based on direct reuse of structure matching. If there is a candidate ontology that is highly matched with the target task, semantic alignment is performed by the structure matching method, and the candidate ontology with the highest matching degree is selected as the basis for expansion. Step (1.2.3) is based on indirect reuse of the reference domain. If there is no highly matching ontology, then by analyzing external ontology resources related to the target domain, suitable concepts, relationships and attribute fragments are extracted, terminology system mapping and semantic adjustment are performed to complete the indirect construction of the domain ontology structure.
4. The knowledge graph construction method based on ontology and large language model as described in claim 3, characterized in that, The process of step (1.3) is as follows: Step (1.3.1) Extraction and confirmation of core domain concepts: Based on the domain scope constraints obtained in step (1.1) Scope We extract a set of core terms directly related to the scope of the field from authoritative information, expert knowledge, and data resources to form a preliminary concept set. We then perform deduplication, ambiguity resolution, and concept unification on the extracted terms to ensure the accuracy and uniqueness of the preliminary concept set. Step (1.3.2) Concept Semantic Classification: Define the concept categories of the concept set ConceptSet according to different knowledge granularities, construct a preliminary semantic classification system, and use a top-down approach to reasonably organize and adjust the granularity of concepts; Step (1.3.3) Construction and optimization of the concept hierarchy: Based on the semantic classification obtained in step (1.3.2), the semantic hierarchy of domain concepts is constructed by clarifying the inheritance relationship between concepts, i.e., the is-a relationship.
5. The knowledge graph construction method based on ontology and large language model as described in claim 4, characterized in that, The process of step (1.4) is as follows: Step (1.4.1) Construction and expression of object properties: Based on the concept set ConceptSet and its hierarchical structure obtained above, identify the multidimensional semantic relationships between different concept entities, including structural relationships, functional relationships, and logical relationships, and model them as object properties ObjectProperty; Step (1.4.2) Introduction and Modeling of Semantic Constraint Types: To enhance the semantic expressive power of object attributes and improve the accuracy and consistency of knowledge reasoning, semantic constraint types are further introduced during the definition process of object attributes, and a set of constraint types is constructed. SemanticConstraintSet This set is used to regulate the logical behavior of each object attribute in semantic reasoning; Symmetry means that if there is a certain relationship between entity 1 and entity 2, then there is also the same relationship between entity 2 and entity 1. Transitivity means that if there is a certain relationship between entity 1 and entity 2, and there is also a certain relationship between entity 2 and entity 3, then entity 1 and entity 3 also have that relationship. Reflexivity refers to the fact that an entity itself also satisfies a certain relationship with itself, that is, the relationship is self-applicable to the same object; Antisymmetry means that if a certain relationship exists between entity 1 and entity 2, then that relationship cannot exist between entity 2 and entity 1 at the same time. This property is used to express semantic connections that are highly directional and irreversible. Functionality refers to the fact that a relation can only point to a single target entity for a given entity, that is, the relation has a single-value constraint.
6. The knowledge graph construction method based on ontology and large language model as described in claim 5, characterized in that, In step (1.5), the formal representation of the attribute system is as follows: ; in, For concept class, For attributes, including name Data types Value range and constraints .
7. A knowledge graph construction method based on ontology and large language model as described in any one of claims 1 to 6, characterized in that, In step (2.1), to ensure logical consistency and domain adaptability of the extension, domain rules are introduced during the extension process. As a constraint framework; ; in, 、 , These represent the concept set, attribute set, and object relation set, respectively. The specific rules include: (1) Conceptual hierarchy constraints ; (2) Limitations on the legality of the relationship ; (3) Attribute assignment specification ; (4) Inference rules ; Among them, in the conceptual level constraints, Used to indicate a concept It is a concept Subclasses; Relationship legality rules Require each relationship It must have a clear and That is, its initial concept is The concept of termination is Attribute Assignment Rules Limited attributes The data type must belong to the data type set; the reasoning rule states that if the concept With concept Through some kind of relationship By making connections, new relationships can be inferred. To enhance the deductive ability of knowledge graphs; Let the current domain ontology be represented as ,Will and rules As input to LLM, LLM uses this information to infer potential expansion directions and generate a set of expansion candidates.
8. The knowledge graph construction method based on ontology and large language model as described in claim 7, characterized in that, In step (2.2), for For each extension item in the domain, a domain rule validation function is introduced: ; If it satisfies all relevant domain rules, then Otherwise, After verification, the high-quality extended set was retained: ; In step (2.3), the filtered extended content Merge into the original entity In this process, a new, updated ontology is formed: ; The entities, relations, attributes, and attribute value sets in the final new ontology are denoted as follows: and , This is used for the ontology constraints in the third step.
9. A knowledge graph construction method based on ontology and large language model as described in any one of claims 1 to 6, characterized in that, The fourth step includes the following sub-steps: Step (4.1) Mapping and transformation of structured data triples; For structured data, the system integrates a D2R mapping mechanism to convert primary keys, foreign keys, and field names in tables into standardized triples according to mapping specifications, and then incorporate them into a unified semantic representation system; Step (4.2) Parsing and extracting semi-structured data triples: For semi-structured data, the data fragments are mapped into standard "entity-relationship-entity" or "entity-attribute-attribute value" triples using Wrapper. Step (4.3) Fusion and normalization of multi-source triples: This involves fusing and normalizing the triples extracted from the unstructured data source in the previous steps. The triples extracted from semi-structured and structured data sources are processed uniformly, and a set of triples with high consistency and semantic regularity is generated through redundancy elimination and format standardization strategies. Step (4.4) Knowledge graph construction: Import the set of triples generated in the above steps into the graph database to construct a knowledge graph with a reasonable structure and complete semantics.
Citation Information
Patent Citations
Auditing domain knowledge graph ontology framework construction method based on large language model
CN119647580A
Automatic construction method and system for dynamic mode knowledge graph
CN120745784A