Heterogeneous knowledge fusion construction method based on large model
By constructing a heterogeneous knowledge fusion method based on a large model, multi-source heterogeneous data is classified and processed to generate a knowledge graph. This solves the problems of insufficient automation and difficulty in cross-domain transfer in existing technologies, and achieves efficient and accurate knowledge graph construction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INST OF WAR STUDIES ACAD OF MILITARY SCI OF THE CHINESE PEOPLES LIBERATION ARMY
- Filing Date
- 2026-05-15
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies struggle to efficiently process multi-source, heterogeneous, and multimodal data, lack sufficient automation, rely heavily on manual labor, are difficult to transfer across domains, and have weak generalization capabilities.
A heterogeneous knowledge fusion construction method based on a large model is adopted to classify multi-source heterogeneous data, obtain a suitable large model processing strategy, and combine it with a knowledge graph generation model for analysis and processing to generate a knowledge graph.
It enables efficient and automated construction of multi-source heterogeneous data, reduces reliance on manual annotation, lowers labor costs, adapts to the structural characteristics of different types of data, and achieves accurate knowledge graph construction.
Smart Images

Figure CN122491450A_ABST
Abstract
Description
Technical Field
[0001] This application generally relates to the field of artificial intelligence technology. More specifically, this application relates to a method for constructing heterogeneous knowledge fusion based on a large model. Background Technology
[0002] Simulation platforms across multiple domains generate massive amounts of data before and after simulations, requiring unified storage in knowledge graphs. This data is not only voluminous but also diverse in type. Traditional knowledge graphs for this data primarily rely on manual construction or can only handle single-modality data, making it difficult to handle multi-source, heterogeneous, and multimodal data.
[0003] In view of this, there is an urgent need to provide a heterogeneous knowledge fusion construction scheme based on a large model, so as to combine the structural characteristics of each type of data to achieve the automated construction of knowledge graphs accurately and efficiently. Summary of the Invention
[0004] To address at least one or more of the technical problems mentioned above, this application proposes a heterogeneous knowledge fusion construction method based on a large model in several aspects.
[0005] In a first aspect, this application provides a method for constructing heterogeneous knowledge fusion based on a large model, comprising: classifying multi-source heterogeneous data to be processed to obtain classification results; obtaining a large model processing strategy adapted to the classification results, wherein the large model processing strategy includes a task configuration based on a knowledge graph generation model; and combining the large model processing strategy and the knowledge graph generation model to analyze and process the data to be processed to generate a knowledge graph about the data to be processed.
[0006] In some embodiments, the classification results include structured data, unstructured data, and semi-structured data. Classifying multi-source heterogeneous data to be processed includes: obtaining the file extension and / or content format of the data to be processed; and classifying the data to be processed based on the file extension and / or content format.
[0007] In some embodiments, the classification result is structured data, and obtaining a large model processing strategy adapted to the classification result includes: obtaining a first task configuration corresponding to the structured data, wherein the first task configuration includes metadata extraction script generation, structured data ontology design, triple extraction script generation, and knowledge graph import script generation, and the metadata extraction script generation, triple extraction script generation, and knowledge graph import script generation are obtained based on the code generation capability of the knowledge graph generation model, and the structured data ontology design is obtained based on the natural language understanding capability of the knowledge graph generation model; wherein analyzing and processing the data to be processed to generate a knowledge graph about the data to be processed includes: sequentially executing metadata extraction script generation, structured data ontology design, triple extraction script generation, and knowledge graph import script generation based on the knowledge graph generation model to obtain the knowledge graph.
[0008] In some embodiments, the generation of the metadata extraction script corresponding to the structured data includes: obtaining a first prompt word template corresponding to the structured data and used to assist in data extraction; inputting the first prompt word template and the structured data into the knowledge graph generation model to extract metadata from the structured data based on the knowledge graph generation model, wherein the metadata includes table name, column name, data type, primary key, foreign key constraint, index, annotation and multi-row sample data.
[0009] In some embodiments, the structured data ontology design corresponding to the structured data includes: obtaining a second prompt word template corresponding to the structured data and used to assist in data recognition; inputting the second prompt word template and the metadata into the knowledge graph generation model to identify entity types and relation types from the metadata based on the knowledge graph generation model, wherein the entity types include entity tags, source tables, and attribute lists, and the relation types include relation names, starting entities, ending entities, and mapping relationships.
[0010] In some embodiments, the generation of the triple extraction script corresponding to the structured data includes: obtaining a third prompt word template corresponding to the structured data and used to assist in triple extraction; inputting the third prompt word template and the structured data ontology into the knowledge graph generation model to extract corresponding entities, relations, and entity attributes from the structured data ontology based on the knowledge graph generation model; wherein the generation of the knowledge graph import script corresponding to the structured data includes: obtaining a fourth prompt word template corresponding to the structured data and used to assist in the generation of the import script; inputting the fourth prompt word template, the entities, and the relations into the knowledge graph generation model, and importing the entities and the relations into a specified graph database based on the knowledge graph generation model to complete the generation of the knowledge graph.
[0011] In some embodiments, where the classification result is semi-structured data, obtaining a large-scale model processing strategy adapted to the classification result includes: obtaining a second task configuration corresponding to the semi-structured data, wherein the second task configuration includes data structure parsing script generation, semi-structured data ontology design, triple extraction script generation, and knowledge graph import script generation, and the data structure parsing script generation, triple extraction script generation, and knowledge graph import script generation are obtained based on the code generation capability of the knowledge graph generation model, and the semi-structured data ontology design is obtained based on the natural language understanding capability of the knowledge graph generation model; wherein analyzing and processing the data to be processed to generate a knowledge graph about the data to be processed includes: sequentially executing data structure parsing script generation, semi-structured data ontology design, triple extraction script generation, and knowledge graph import script generation based on the knowledge graph generation model to obtain the knowledge graph.
[0012] In some embodiments, where the classification result is unstructured data, obtaining a large model processing strategy adapted to the classification result includes: obtaining a third task configuration corresponding to the unstructured data, wherein the third task configuration includes semantic reference resolution, domain knowledge constraint triple extraction, and knowledge graph import script generation, and the semantic reference resolution and domain knowledge constraint triple extraction are obtained based on the natural language understanding capability of the knowledge graph generation model, and the knowledge graph import script generation is obtained based on the code generation capability of the knowledge graph generation model; wherein analyzing and processing the data to be processed to generate a knowledge graph about the data to be processed includes: sequentially executing semantic reference resolution, domain knowledge constraint triple extraction, and knowledge graph import script generation based on the knowledge graph generation model to obtain the knowledge graph.
[0013] In a second aspect, this application provides an electronic device, comprising: a memory storing computer instructions for constructing heterogeneous knowledge based on a large model; and a processor executing the computer instructions, causing the electronic device to perform the heterogeneous knowledge fusion construction method based on a large model as described in the preceding and following embodiments.
[0014] In a third aspect, this application provides a computer-readable storage medium including program instructions for constructing heterogeneous knowledge fusion based on a large model, which, when executed by a processor, enables the implementation of the heterogeneous knowledge fusion construction method based on a large model as described in the foregoing and the following embodiments.
[0015] Using the heterogeneous knowledge fusion construction method based on a large model provided above, this application embodiment obtains the large model processing strategy corresponding to the classification results of multi-source heterogeneous data to be processed. This strategy is then combined with a knowledge graph generation model to analyze and process the data, generating a knowledge graph about the data. It can be seen that the technical solution of this application can overcome the problem of inconsistent and efficient processing of diverse and heterogeneous data in vertical domains. By utilizing the zero-shot and few-shot learning capabilities of the knowledge graph generation model, it reduces reliance on manually labeled data, achieving end-to-end automated construction and reducing labor costs. Furthermore, a differentiated processing mechanism can be established based on data classification to accurately and efficiently achieve automated knowledge graph construction. Attached Figure Description
[0016] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, and the same or corresponding reference numerals denote the same or corresponding parts, wherein: Figure 1 A flowchart illustrating a heterogeneous knowledge fusion construction method based on a large model, according to an embodiment of this application, is shown. Figure 2 A flowchart illustrating another embodiment of the heterogeneous knowledge fusion construction method based on a large model is shown; and Figure 3 A schematic block diagram of the structure of an electronic device according to an embodiment of this application is shown. Detailed Implementation
[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0018] It should be understood that the terms "comprising" and "including" used in the specification and claims of this application indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0019] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application. As used in this specification and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this specification and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.
[0020] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."
[0021] Exemplary application scenarios In related technologies, knowledge graph construction mainly includes the following methods: (1) Rule-based construction method: Relying on domain experts to write data extraction rules (such as regular expressions, template matching rules, etc.). Experts manually design rule sets based on data characteristics and business logic, and construct the graph manually.
[0022] (2) Machine learning-based construction methods: feature engineering and supervised learning models (such as Conditional Random Fields (CRF), Support Vector Machines (SVM), etc.). These models require a large amount of labeled training data and automatically identify entities and relationships by learning feature patterns in training samples.
[0023] (3) Deep learning-based construction method: Neural network models such as BiLSTMCRF and BERT are used for sequence labeling. Although the work of feature engineering is reduced, domain-related labeled data is still required for fine-tuning, and it can usually only handle a single type of data.
[0024] The above-mentioned knowledge graph construction methods have the following drawbacks: (1) Insufficient automation and heavy reliance on manual labor. Rule-based methods require experts to spend a lot of time writing and maintaining rules, and the rules need to be redesigned whenever new data types or application scenarios need to be handled. Machine learning / deep learning-based methods require professionals to annotate data, which is time-consuming and labor-intensive.
[0025] (2) Difficulty in handling the fusion of multi-source heterogeneous data. Traditional methods are usually designed for a specific type of data and are difficult to flexibly adapt to the mixed processing of structured, semi-structured, and unstructured data. For vertical domain data (including text, tables, nested JSON, etc.), separate processing modules need to be developed, which is highly complex and makes data fusion between modules difficult.
[0026] (3) Weak generalization ability and difficulty in cross-domain transfer. Deep learning models trained with specific labeled data often only perform well in the same domain and with the same data distribution, and are difficult to generalize to other domains or new application scenarios. In some vertical domains, the knowledge system and data structure may change with business updates, and traditional models are difficult to adapt to these changes quickly.
[0027] To address the problems in the aforementioned scenarios, the inventors discovered that different types of data have different processing needs. By combining the data type with the zero-shot and few-shot learning capabilities of large language models, differentiated processing mechanisms can be constructed for different data types. This fully utilizes the structural characteristics of each data type to achieve efficient and automated knowledge graph construction. Based on this, a heterogeneous knowledge fusion construction scheme based on large models is proposed. Differentiated large model processing strategies are adopted according to the data type to achieve automated construction of a unified knowledge graph from multi-source heterogeneous data.
[0028] The following combination Figures 1-3 The scheme of this application is described in detail.
[0029] Figure 1 A flowchart illustrating a heterogeneous knowledge fusion construction method 100 based on a large model, according to an embodiment of this application, is shown.
[0030] like Figure 1 As shown, in step S101, the heterogeneous data to be processed from multiple sources can be classified to obtain the classification results.
[0031] In step S102, a large model processing strategy adapted to the aforementioned classification results can be obtained. This large model processing strategy includes task configurations for knowledge graph-based model generation.
[0032] In step S103, the data to be processed is analyzed and processed by combining the large model processing strategy and the knowledge graph generation model to generate a knowledge graph about the data to be processed.
[0033] In this application, multi-source heterogeneous data to be processed can be understood as data from different sources with different structures and formats. The sources of this data may include, but are not limited to, sensors, databases, social media, API interfaces, and file systems. Its structure or type may include, but is not limited to, structured data (such as database tables), semi-structured data (such as JSON, XML, etc.), and unstructured data (such as text, images, videos, logs, etc.). Furthermore, the knowledge graph generation model in this embodiment may include a general-purpose large model with semantic parsing and code generation capabilities, possessing zero-shot and few-shot learning capabilities. In addition, in some embodiments, the task configuration based on the knowledge graph generation model may include the tasks to be executed by the knowledge graph generation model and / or the execution sequence. The execution sequence here may be an explicit task execution time order or task execution priority, or it may be an implicit execution order, such as the output of the current task being used as the input of the next task.
[0034] Furthermore, the above classification results can be specifically divided into structured data, unstructured data, and semi-structured data. In some embodiments, classifying multi-source heterogeneous data to be processed specifically involves: obtaining the file extension and / or content format of the data to be processed, and classifying the data to be processed based on the file extension and / or content format. In this embodiment, data classification can be achieved in various ways. For example, different types of data usually have corresponding file extensions, and type identification can be achieved through the file extension. Another example is that different types of data correspond to different content formats (e.g., structured data generally has a fixed format, while semi-structured data may contain tags or labels, etc.), and data types can also be distinguished by content format. Yet another example is that the file extension and content format can be combined to more accurately distinguish data types.
[0035] In some embodiments, when the classification result of the data to be processed is structured data, obtaining a large model processing strategy that is compatible with the classification result specifically involves: obtaining a first task configuration corresponding to the structured data, wherein the first task configuration includes metadata extraction script generation, structured data ontology design, triple extraction script generation, and knowledge graph import script generation, and the metadata extraction script generation, triple extraction script generation, and knowledge graph import script generation are obtained based on the code generation capability of the aforementioned knowledge graph generation model, and the structured data ontology design is obtained based on the natural language understanding capability of the knowledge graph generation model.
[0036] In this implementation scenario, the analysis and processing of the data to be processed to generate a knowledge graph about the data to be processed specifically involves: based on the aforementioned knowledge graph generation model, sequentially executing the metadata extraction script generation, structured data ontology design, triple extraction script generation, and knowledge graph import script generation to obtain the knowledge graph.
[0037] The metadata extraction script generation for structured data specifically includes: obtaining a first prompt word template corresponding to the structured data and used to assist in data extraction; then, inputting the first prompt word template and the structured data into a knowledge graph generation model to extract metadata from the structured data based on the knowledge graph generation model. The specific format of the first prompt word template can be set in advance and can include the role, task, and requirements of the knowledge graph generation model. Metadata includes table names, column names, data types, primary keys, foreign key constraints, indexes, comments, and multiple rows of sample data.
[0038] The structured data ontology design specifically includes: obtaining a second prompt word template corresponding to the structured data and used to assist data recognition; and inputting the second prompt word template and the aforementioned metadata into a knowledge graph generation model to identify entity types and relationship types from the metadata based on the knowledge graph generation model. The specific format of the second prompt word template can be pre-set and may include the role, specific tasks, input and output formats, and requirements of the knowledge graph generation model. Entity types and relationship types are elements required for constructing a knowledge graph. Entity types include entity labels, source tables, and attribute lists; relationship types include relationship names, starting entities, ending entities, and mapping relationships.
[0039] The process of generating a triple extraction script for structured data includes: obtaining a third prompt word template corresponding to the structured data and used to assist in triple extraction; inputting the third prompt word template and the structured data ontology into the knowledge graph generation model to extract corresponding entities, relations, and entity attributes from the structured data ontology based on the knowledge graph generation model. The specific format of the third prompt word template can be pre-set and may include the role, specific tasks, input and output formats, and requirements of the knowledge graph generation model.
[0040] In addition, in this embodiment, the entities, relationships, and entity attributes output by the knowledge graph generation model can be in code form, such as a CSV file.
[0041] The knowledge graph import script generation process for structured data includes obtaining a fourth prompt word template corresponding to the structured data and used to assist in the script generation; inputting the fourth prompt word template, entities, and relations into the knowledge graph generation model; and importing the entities and relations into a specified graph database based on the knowledge graph generation model to complete the knowledge graph generation. The specific format of the fourth prompt word template can be pre-set and may include the role, specific tasks, input format, and requirements of the knowledge graph generation model. A batch import method is used to import entities and relations into the specified graph database to improve overall data processing performance.
[0042] In some embodiments, when the classification result of the data to be processed is semi-structured data, obtaining a large-scale model processing strategy adapted to the classification result specifically involves: obtaining a second task configuration corresponding to the semi-structured data. This second task configuration includes data structure parsing script generation, semi-structured data ontology design, triple extraction script generation, and knowledge graph import script generation. The data structure parsing script generation, triple extraction script generation, and knowledge graph import script generation are based on the code generation capabilities of the knowledge graph generation model, while the semi-structured data ontology design is based on the natural language understanding capabilities of the knowledge graph generation model.
[0043] In this implementation scenario, the analysis and processing of the data to be processed to generate a knowledge graph about the data to be processed specifically involves: based on the knowledge graph generation model, sequentially executing the data structure parsing script generation, semi-structured data ontology design, triple extraction script generation, and knowledge graph import script generation to obtain the knowledge graph.
[0044] The data structure parsing script generation specifically includes: obtaining a fifth prompt word template corresponding to the structured data and used to assist in data parsing; and inputting the fifth prompt word template and the semi-structured data into a knowledge graph generation model to extract corresponding metadata from the semi-structured data based on the knowledge graph generation model. The metadata corresponding to the semi-structured data may include field paths, data types, sample values, etc., and the extraction of this metadata can provide a basis for subsequent semi-structured data ontology design. The specific format of the fifth prompt word template can be set in advance and may include the role positioning, specific tasks, input and output content, and requirements of the knowledge graph generation model.
[0045] The semi-structured data ontology design specifically involves: obtaining a sixth prompt word template corresponding to the semi-structured data and used to assist data recognition; and inputting the sixth prompt word template and the aforementioned metadata into a knowledge graph generation model to identify entity types and relation types from the metadata based on the knowledge graph generation model. The specific format of the sixth prompt word template can be pre-set and may include the role, specific tasks, input and output formats, and requirements of the knowledge graph generation model. Entity types and relation types are elements required for constructing a knowledge graph. Entity types include entity labels, source tables, and attribute lists; relation types include relation names, starting entities, ending entities, and mapping relationships.
[0046] The specific processes for generating the triple extraction script for semi-structured data and the knowledge graph import script can be found in the previous descriptions of generating the triple extraction script for structured data and the knowledge graph import script, and will not be repeated here.
[0047] In some embodiments, when the classification result of the data to be processed is unstructured data, obtaining a large model processing strategy that is compatible with the classification result specifically involves: obtaining a third task configuration corresponding to the unstructured data, wherein the third task configuration includes semantic reference resolution, extraction of triples of domain knowledge constraints, and generation of knowledge graph import scripts, and the semantic reference resolution and extraction of triples of domain knowledge constraints are obtained based on the natural language understanding ability of the knowledge graph generation model, and the generation of knowledge graph import scripts is obtained based on the code generation ability of the knowledge graph generation model.
[0048] In this implementation scenario, the analysis and processing of the data to be processed to generate a knowledge graph about the data to be processed includes: performing semantic reference resolution, extraction of triples based on domain knowledge constraints, and generation of a knowledge graph import script based on a knowledge graph generation model to obtain the knowledge graph.
[0049] Semantic referencing resolution can be understood as restoring pronouns, zero referents, or indicator phrases in the source data (i.e., the data to be processed) to their corresponding specific entity names, thus preventing a large number of pronouns from being misidentified as new entities. The specific execution process of semantic referencing resolution involves: obtaining a seventh prompt word template corresponding to the unstructured data and used to assist in the data referencing resolution process; then, inputting this seventh prompt word template and the unstructured data into a knowledge graph generation model, which uses the knowledge graph generation model to restore the pronouns, zero referents, or indicator phrases in the unstructured data to their corresponding specific entity names. The specific format of the seventh prompt word template can be pre-set and may include the role, specific tasks, output format, and requirements of the knowledge graph generation model.
[0050] Specifically, the extraction of triples based on domain knowledge constraints involves: forming a domain ontology model by extracting entity types, relation types, and attribute definitions from existing structured or semi-structured data; obtaining an eighth prompt word template corresponding to unstructured data and used to assist data recognition; and then inputting the eighth prompt word template, unstructured data, and domain ontology model into a knowledge graph generation model. The knowledge graph generation model then extracts entities and relations from the unstructured metadata based on the domain ontology model. The specific format of the eighth prompt word template can be pre-defined and may include the role, specific tasks, input and output formats, extraction rules, and requirements of the knowledge graph generation model.
[0051] Among them, entity extraction in unstructured metadata based on the knowledge graph generation model and the domain ontology model includes: extracting only the entity types defined in the domain ontology model, and for each extracted entity, further extraction of the entity's original expression in the original text, inferring the ontology entity type to which the entity belongs, extracting the corresponding attribute values from the original text based on the attribute list defined by the entity in the domain ontology model, and extracting the original text evidence sentences containing the entity.
[0052] Among them, the knowledge graph-based generation model extracts relations from unstructured metadata based on the domain ontology model, including: extracting only the relation types defined in the domain ontology model, and further extracting the head entity's description in the original text, the relation type, the tail entity's description in the original text, and the original text evidence sentence for the existence of the relation for the extracted relation types.
[0053] Figure 2 A flowchart illustrating another embodiment of the heterogeneous knowledge fusion construction method 200 based on a large model of this application is shown. It should be noted that... Figure 2 Method 200 in the middle can be understood as a... Figure 1 This is a specific technical implementation of Chinese method 100. Therefore, the preceding text combines... Figure 1The relevant descriptions also apply to the following text.
[0054] like Figure 2 As shown, in step S201, input source data.
[0055] Step S202: Determine the data type of the source data. The source data is categorized as structured data, unstructured data, or semi-structured data. This can be achieved using methods such as file extension recognition and content format detection, serving as a prerequisite for subsequent differential processing. If the source data is determined to be structured data, proceed to steps S203, S204, and S209-S211; if the source data is determined to be semi-structured data, proceed to steps S205, S206, and S209-S211; if the source data is determined to be unstructured data, proceed to steps S207-S211.
[0056] Step S203: For structured data, a metadata extraction script is generated.
[0057] Taking a MySQL database as the source data as an example, this describes how to extract complete metadata from a structured data source, including table names, column names, data types, primary keys, foreign key constraints, indexes, comments, and multiple rows of sample data (e.g., 5 rows of sample data). The metadata extraction code is generated based on a knowledge graph generation model. The prompt words used (i.e., the first prompt word template mentioned earlier) contain the role positioning, tasks, and requirements of the large model. The following example demonstrates the designed prompt word template: [Role Positioning] You are a Python development expert.
[0058]
Task
[0059] 2. Retrieve all table names.
[0060] 3. For each table, obtain its column information (column name, data type, whether it is a primary key, and comments).
[0061] 4. For each table, retrieve the first 5 rows of sample data (stored as a dictionary list).
[0062] 5. Save the metadata and sample data in JSON format to the file 'metadata.json'.
[0063]
Require
[0064] 2. Add an if __name__ == "__main__" block at the end of the script to demonstrate how to call it.
[0065] 3. Parameterized configuration makes it easy for users to configure database connections.
[0066] 4. Please only output the code, without explanation.
[0067] It should be noted that the content of the prompt word template here is only an illustrative example, and the technical solution of this application does not limit it. The specific content of the prompt word template can be adjusted according to actual needs.
[0068] Step S204: For structured data, perform structured data ontology design.
[0069] After extracting metadata from the aforementioned database, a knowledge graph generation model is used to parse semantics and identify entity types and relationship types. The knowledge graph generation model includes labels, source tables, and attribute lists for each entity. Relationship types include relationship names, starting entities, and ending entities. The prompt word templates involved (i.e., the second prompt word template mentioned earlier) contain the role positioning, input and output formats, and requirements of the large model. The following is an example of the designed prompt word templates: [Role Positioning] You are a knowledge graph engineer.
[0070]
Task
[0071]
enter
Require
[0072] 2. For each entity, provide the label, source table, and attribute list (extract meaningful attributes from the table, excluding foreign keys as attributes).
[0073] 3. Identify the relationship type, specify the relationship name (uppercase with underscore), starting entity, ending entity, and which foreign key is used for association (or how it is mapped).
[0074] 4. The output format is strict JSON, containing two arrays: "entities" and "relations".
[0075] 5. Please only output JSON, and do not include other content.
[0076] It should be noted that the content of the prompt word template here is only an illustrative example, and the technical solution of this application does not limit it. The specific content of the prompt word template can be adjusted according to actual needs.
[0077] Step S205: For semi-structured data, execute the data structure parsing script to generate the data structure.
[0078] Taking semi-structured data in JSON format as an example, a data structure parsing script is generated based on a knowledge graph generation model to analyze the data structure (nesting levels, field types, array elements, etc.) and output metadata descriptions, including field paths, data types, and sample values, providing a basis for subsequent ontology design. The prompt word templates involved (i.e., the fifth prompt word template mentioned earlier) clearly define the role, task, input, output content, and requirements of the large model. The following is an example of the designed prompt word templates: [Role Definition] You are a Python development expert.
[0079] [Task] Please write a Python script that reads a JSON file (path provided by the user) and outputs its metadata.
[0080] [Input] JSON file Output content 1. JSONPath of all fields 2. Field data type (string, number, array, object) 3. Sample values for the field (taken from the first element or the root level) 4. For array types, describe the field structure of the objects within the array. 5. For nested objects, recursive analysis
Require
[0081] 2. Output metadata in JSON format and save it to the file "json_metadata.json".
[0082] 3. The code should include error handling (file not found, JSON parsing error).
[0083] 4. Add an if __name__ == "__main__" block at the end of the script to demonstrate how to call it.
[0084] 5. Please only output the code, without explanation.
[0085] It should be noted that the content of the prompt word template here is only an illustrative example, and the technical solution of this application does not limit it. The specific content of the prompt word template can be adjusted according to actual needs.
[0086] Step S206: For semi-structured data, perform semi-structured data ontology design.
[0087] Based on metadata extracted from the database, a knowledge graph generation model is used to parse semantics and identify entity types and relationship types. Entity types include each entity's label, source table, and attribute list. Relationship types include relationship name, starting entity, and ending entity. The prompt word template involved (i.e., the sixth prompt word template mentioned earlier) contains the role positioning, input and output formats, and requirements of the large model. The following is an example of the designed prompt word template: [Role Definition] You are a knowledge graph engineer.
[0088] [Task] Based on the input metadata JSON file (including field paths, types, and examples), please design the ontology of the knowledge graph.
[0089] [Input] Metadata content: {metadata} Output Format Entity object structure: {{ "label": "Entity Label", "extraction_path": "JSONPath expression", "properties": ["property1", "property2", ...] }} Relational object structure: {{ "type": "relation type", "from_entity": "Starting entity tag", "to_entity": "Endpoint entity label", "extraction": "How to establish relationships from data (e.g., through array nesting, field referencing)" }}
Require
[0090] 2. Each entity must provide a label, the corresponding source table, and a list of attributes.
[0091] 3. Identify the relationship type, specify the relationship name, starting entity, ending entity, and how to extract it from the JSON data (through nesting or referencing).
[0092] 4. The output format is strict JSON, containing two arrays: "entities" and "relations".
[0093] 5. Please only output JSON, and do not include other content.
[0094] It should be noted that the content of the prompt word template here is only an illustrative example, and the technical solution of this application does not limit it. The specific content of the prompt word template can be adjusted according to actual needs.
[0095] Step S207: For unstructured data, perform semantic reference resolution.
[0096] Semantic referencing resolution leverages the natural language understanding capabilities of knowledge graph generation models to restore pronouns, zero referents, or indicator phrases in the source data to their corresponding specific entity names, preventing a large number of pronouns from being misidentified as new entities. The relevant prompt word template (i.e., the seventh prompt word template mentioned earlier) includes the role positioning, task, output format, and requirements of the large model. The following example demonstrates the designed prompt word template: [Role Positioning] You are a professional natural language processing assistant.
[0097] [Task] Please perform referential resolution on the following text, replacing all pronouns (such as "he", "she", "it", "its", "that", "this", "the former", "the latter", etc.) and zero referential subjects with the specific entity names or noun phrases that they clearly refer to in the context.
[0098] [Output to Form] The input text is: The processed text is:
Require
[0099] 2. If the referent cannot be uniquely determined from the context, please retain the original word and add square brackets after it to indicate "[Uncertain]".
[0100] 3. The replaced entity name should be consistent with the name that first appears in the original text.
[0101] 4. The output contains only the processed text and requires no additional interpretation.
[0102] It should be noted that the content of the prompt word template here is only an illustrative example, and the technical solution of this application does not limit it. The specific content of the prompt word template can be adjusted according to actual needs.
[0103] Step S208: For unstructured data, perform triple extraction with domain knowledge constraints.
[0104] In structured / semi-structured data, information such as field names, foreign key constraints, and enumeration value ranges typically contains operational business logic that has reached a consensus among domain experts, possessing a certain degree of authority and completeness. Therefore, a domain ontology model can be formed based on the entity types, relation types, and attribute definitions extracted from existing structured / semi-structured data. The knowledge graph generation model uses this domain ontology model as its framework to drive the large-scale acquisition and anchoring of knowledge from unstructured data, fundamentally suppressing semantic drift and illusion generation caused by unconstrained extraction. The prompt word template involved (i.e., the eighth prompt word template mentioned earlier) includes the role positioning, tasks, input and output formats, extraction rules, and requirements of the large model. The following example demonstrates the designed prompt word template: [Role Positioning] You are a knowledge graph information extraction expert.
[0105] [Task] Read the text below and extract the entities, relationships, and attributes contained in the text based on the given domain ontology model. Your output will be directly used to build a knowledge graph, so you must strictly adhere to the ontology definition.
[0106]
enter
[0107] 2. Generate a CSV file for each relation, named "{relationship type}.csv", containing columns: "START_ID", "END_ID", ":TYPE", and optional attributes.
[0108]
Extraction Rules and Requirements
[0109] It should be noted that the content of the prompt word template here is only an illustrative example, and the technical solution of this application does not limit it. The specific content of the prompt word template can be adjusted according to actual needs.
[0110] Step S209: Execute the triplet extraction script to generate triples.
[0111] Based on the aforementioned knowledge graph ontology design (e.g., structured data ontology, semi-structured data ontology), a knowledge graph generation model is used to generate a knowledge graph triple extraction script, which extracts corresponding entities, relations, and entity attributes from the database. The relevant prompt word template (i.e., the third prompt word template mentioned earlier) includes the role positioning, task, input, output format, and requirements of the large model. The following example demonstrates the designed prompt word template: [Role Positioning] You are a Python development expert.
[0112]
Task
[0113]
enter
[0114] 2. Generate a CSV file for each relation, named "{relationship type}.csv", containing columns: "START_ID", "END_ID", ":TYPE", and optional attributes.
[0115]
Require
[0116] 2. The code should include the necessary SQL queries to convert the data to CSV.
[0117] 3. Consider foreign key mapping to ensure entity ID consistency.
[0118] 4. Use the Python standard libraries csv and pymysql.
[0119] 5. The code should have good error handling.
[0120] 6. Please only output the code, without explanation.
[0121] It should be noted that the content of the prompt word template here is only an illustrative example, and the technical solution of this application does not limit it. The specific content of the prompt word template can be adjusted according to actual needs.
[0122] Step S210: Execute the knowledge graph import script to generate.
[0123] Based on the extracted triple information, a knowledge graph import script is generated using a knowledge graph generation model. This script imports the previously generated CSV files of entities and relationships into a specified graph database (e.g., Neo4j). The relevant prompt word template (i.e., the fourth prompt word template mentioned earlier) contains the role positioning, tasks, and requirements of the large model. The following is an example of the designed prompt word template: [Role Definition] You are a Python development expert.
[0124] [Task] Please write a Python script to import a CSV file (entities and relationships) into a Neo4j graph database using the Neo4j library.
[0125]
enter
Require
[0126] 2. If using LOAD CSV, you need to create constraints (unique constraints) to avoid duplicates.
[0127] 3. The code should include database connection configuration (URI, username, password).
[0128] 4. Considering performance, use transaction batch commit.
[0129] 5. Provide necessary error handling.
[0130] 6. Please only output the code, without explanation.
[0131] It should be noted that the content of the prompt word template here is only an illustrative example, and the technical solution of this application does not limit it. The specific content of the prompt word template can be adjusted according to actual needs.
[0132] Step S211: Complete the knowledge graph import.
[0133] In the above process, differentiated large-scale model processing strategies are adopted according to the type of input data. After triple generation and fusion, scripts are automatically generated to complete data entry, realizing the automated construction of a unified knowledge graph from multi-source heterogeneous data. Specifically, for structured data, a complete processing flow is constructed, including metadata extraction script generation, structured data ontology design, triple extraction script generation, and knowledge import script generation. The metadata extraction script generation, structured data ontology design, triple extraction script generation, and knowledge graph import script generation are based on the code generation capabilities of the knowledge graph generation model, while the structured data ontology design is based on the natural language understanding capabilities of the knowledge graph generation model. For semi-structured data, a complete processing flow is constructed, including data structure parsing script generation, semi-structured data ontology design, triple extraction script generation, and knowledge graph import script generation. The data structure parsing script generation, triple extraction script generation, and knowledge graph import script generation are based on the code generation capabilities of the knowledge graph generation model, while the semi-structured data ontology design is based on the natural language understanding capabilities of the knowledge graph generation model. For unstructured data, taking text data as an example, a complete processing flow was constructed, including semantic reference resolution, domain knowledge constraint triple extraction, and knowledge graph import script generation. Semantic reference resolution and domain knowledge constraint triple extraction are based on the natural language understanding capabilities of the knowledge graph generation model, while knowledge graph import script generation is based on the code generation capabilities of the knowledge graph generation model. Furthermore, the various scripts output by the aforementioned knowledge graph generation model include complete logic for database connections, data queries, format conversions, and batch imports.
[0134] The technical solution of this application has the following beneficial effects: (1) Achieve fully automated construction and significantly reduce labor costs. Traditional methods require experts to manually write rules and label data, which requires a large investment of manpower. This application utilizes the zero-shot and few-shot learning capabilities of the knowledge graph generation model, eliminating the need for labeled data and manually writing complex rules. It can automatically complete knowledge extraction by providing only data and simple prompts.
[0135] (2) Unify the processing of multi-source heterogeneous data to improve data utilization efficiency.
[0136] This application designs differentiated processing mechanisms for three types of data: structured, semi-structured, and unstructured. For structured data, it fully utilizes the table structure information to quickly derive the ontology; for semi-structured data, it uses the nested structure and key name semantics to infer implicit relationships; and for unstructured data, it utilizes the natural language understanding capabilities of the knowledge graph generation model to perform deep knowledge extraction.
[0137] (3) It has strong scalability and is easy to apply to new fields. The solution presented in this application is general and does not rely on specific domain-specific rules or labeled data. The same processes and prompting mechanisms can be directly applied to other fields (such as engineering management, healthcare, and education).
[0138] After introducing the methods of exemplary embodiments of this application, the following references are made. Figure 3 This application describes related products of the heterogeneous knowledge fusion construction method based on a large model, which is an exemplary embodiment of this application.
[0139] Figure 3 A schematic block diagram of an electronic device 300 according to one embodiment of this application is shown. Specifically, as follows... Figure 3 As shown, the electronic device 300 may include a processor 301 and a memory 302. The memory 302 stores computer instructions constructed from heterogeneous knowledge fusion based on a large model. When the computer instructions are executed by the processor 301, the electronic device 300 performs the following actions: classifying multi-source heterogeneous data to be processed to obtain classification results; acquiring a large model processing strategy adapted to the classification results, wherein the large model processing strategy includes a task configuration based on a knowledge graph generation model; and combining the large model processing strategy and the knowledge graph generation model to analyze and process the data to be processed to generate a knowledge graph about the data to be processed.
[0140] Through the above implementation methods, electronic devices can leverage the zero-shot and few-shot learning capabilities of knowledge graph generation models, reducing reliance on manually labeled data and achieving end-to-end automated construction, thus lowering labor costs. Furthermore, differentiated processing mechanisms can be established based on data classification to achieve precise and efficient automated knowledge graph construction.
[0141] It should be noted that the specific details of the operating method and steps of this electronic device are combined with the foregoing. Figures 1-2 The specific implementation methods described are the same or similar, so they will not be elaborated here.
[0142] Furthermore, this application also provides a computer-readable storage medium storing program instructions configured to execute at runtime. Figures 1-2 The method for constructing heterogeneous knowledge fusion based on a large model is shown.
[0143] Specifically, in this embodiment, the storage medium may include, but is not limited to, USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks, and other media capable of storing computer programs.
[0144] While numerous embodiments of this application have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will arise for those skilled in the art without departing from the spirit and intent of this application. It should be understood that various alternatives to the embodiments of this application described herein may be employed in the practice of this application. The appended claims are intended to define the scope of protection of this application and therefore cover equivalents or alternatives within the scope of these claims.
Claims
1. A method for constructing heterogeneous knowledge fusion based on a large model, characterized in that, include: The heterogeneous data from multiple sources is classified to obtain classification results; Obtain a large model processing strategy that is compatible with the classification results, wherein the large model processing strategy includes a task configuration for generating a model based on a knowledge graph; By combining the large model processing strategy and the knowledge graph generation model, the data to be processed is analyzed and processed to generate a knowledge graph about the data to be processed.
2. The heterogeneous knowledge fusion construction method according to claim 1, characterized in that, The classification results include structured data, unstructured data, and semi-structured data. Classification of multi-source, heterogeneous data to be processed includes: Obtain the file extension and / or content format of the data to be processed; and The data to be processed is classified based on the file extension and / or content format.
3. The heterogeneous knowledge fusion construction method according to claim 2, characterized in that, The classification results are structured data, and the large model processing strategies adapted to the classification results include: Obtain the first task configuration corresponding to the structured data, wherein the first task configuration includes metadata extraction script generation, structured data ontology design, triple extraction script generation, and knowledge graph import script generation, and the metadata extraction script generation, the triple extraction script generation, and the knowledge graph import script generation are obtained based on the code generation capability of the knowledge graph generation model, and the structured data ontology design is obtained based on the natural language understanding capability of the knowledge graph generation model; The process of analyzing and processing the data to be processed to generate a knowledge graph about the data to be processed includes: Based on the knowledge graph generation model, the metadata extraction script generation, structured data ontology design, triple extraction script generation, and knowledge graph import script generation are executed sequentially to obtain the knowledge graph.
4. The heterogeneous knowledge fusion construction method according to claim 3, characterized in that, The metadata extraction script generation for the structured data includes: Obtain the first prompt word template corresponding to the structured data and used to assist in data extraction; The first prompt word template and the structured data are input into the knowledge graph generation model to extract metadata from the structured data based on the knowledge graph generation model. The metadata includes table name, column name, data type, primary key, foreign key constraint, index, annotation, and multiple rows of sample data.
5. The heterogeneous knowledge fusion construction method according to claim 4, characterized in that, The structured data ontology design corresponding to the structured data includes: Obtain the second prompt word template corresponding to the structured data and used to assist in data recognition; The second prompt word template and the metadata are input into the knowledge graph generation model to identify entity types and relationship types from the metadata based on the knowledge graph generation model. The entity types include entity tags, source tables, and attribute lists, and the relationship types include relationship names, starting entities, ending entities, and mapping relationships.
6. The heterogeneous knowledge fusion construction method according to claim 5, characterized in that, The triple extraction script generation for the structured data includes: Obtain the third prompt word template corresponding to the structured data and used to assist in triple extraction; The third prompt word template and the structured data ontology are input into the knowledge graph generation model to extract the corresponding entities, relationships, and entity attributes from the structured data ontology based on the knowledge graph generation model. The knowledge graph import script generation for the structured data includes: Obtain the fourth prompt word template corresponding to the structured data, which is used to assist the import script in generating the script; The fourth prompt word template, the entity, and the relationship are input into the knowledge graph generation model, and the entity and the relationship are imported into the specified graph database based on the knowledge graph generation model to complete the generation of the knowledge graph.
7. The heterogeneous knowledge fusion construction method according to claim 2, characterized in that, The classification results are semi-structured data, and the large model processing strategies adapted to the classification results include: Obtain the second task configuration corresponding to the semi-structured data, wherein the second task configuration includes data structure parsing script generation, semi-structured data ontology design, triple extraction script generation, and knowledge graph import script generation, and the data structure parsing script generation, the triple extraction script generation, and the knowledge graph import script generation are obtained based on the code generation capability of the knowledge graph generation model, and the semi-structured data ontology design is obtained based on the natural language understanding capability of the knowledge graph generation model; The process of analyzing and processing the data to be processed to generate a knowledge graph about the data to be processed includes: Based on the knowledge graph generation model, the data structure parsing script generation, semi-structured data ontology design, triple extraction script generation, and knowledge graph import script generation are executed sequentially to obtain the knowledge graph.
8. The heterogeneous knowledge fusion construction method according to claim 2, characterized in that, The classification results are unstructured data, and the large model processing strategies adapted to the classification results include: Obtain the third task configuration corresponding to the unstructured data, wherein the third task configuration includes semantic reference resolution, domain knowledge constraint triple extraction, and knowledge graph import script generation, and the semantic reference resolution and domain knowledge constraint triple extraction are obtained based on the natural language understanding ability of the knowledge graph generation model, and the knowledge graph import script generation is obtained based on the code generation ability of the knowledge graph generation model. The process of analyzing and processing the data to be processed to generate a knowledge graph about the data to be processed includes: Based on the knowledge graph generation model, semantic reference resolution, domain knowledge constraint triple extraction, and knowledge graph import script generation are performed sequentially to obtain the knowledge graph.
9. An electronic device, characterized in that, include: The memory stores computer instructions built upon the fusion of heterogeneous knowledge based on a large model; A processor that executes the computer instructions, causing the electronic device to perform the heterogeneous knowledge fusion construction method based on a large model according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that, It includes program instructions for constructing heterogeneous knowledge fusion based on a large model, which, when executed by a processor, enable the implementation of the heterogeneous knowledge fusion construction method based on any one of claims 1 to 8.