A knowledge graph joint construction method and device, equipment and medium
Patent Information
- Application Number
- CN202611037104.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-13
- Publication Date
- 2026-10-20
AI Technical Summary
[0004]有鉴于此,本发明的目的在于提供一种知识图谱联合构建方法、装置、设备及介质,以缓解以非结构化自然语言形式存在,人工抽取效率低下且主观性强,难以满足大规模文献分析的需求的技术问题
[0014]本发明的其他特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明而了解。本发明的目的和其他优点在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the field of knowledge graph construction technology, and in particular to a method, apparatus, device and medium for joint construction of knowledge graphs. Background Technology
[0002] Scientific literature contains a wealth of valuable structured knowledge, including entities, relationships, and attributes. This knowledge is crucial for subject knowledge management, literature retrieval, and hypothesis generation. While rule-based methods can handle structured knowledge, they suffer from high domain adaptability costs, insufficient ontology coverage, and difficulties in rule maintenance. Secondly, traditional machine learning methods require large amounts of high-quality domain-annotated data, which is costly to acquire, has low ontology coverage, and lacks traceability in extraction results. Furthermore, while deep learning methods reduce some feature engineering costs, their reliance on labeled data remains fundamentally unchanged, the model inference process is uninterpretable, and multi-model adaptation is complex. Finally, methods that directly use general-purpose large language models suffer from poor ontology adaptability, inability to proactively discover new concepts, and uncontrollable extraction quality.
[0003] However, existing technologies have the following problems: they exist in the form of unstructured natural language, manual extraction is inefficient and highly subjective, making it difficult to meet the needs of large-scale document analysis. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a method, apparatus, device and medium for the joint construction of knowledge graphs, so as to alleviate the technical problem that knowledge graphs exist in the form of unstructured natural language, and manual extraction is inefficient and highly subjective, making it difficult to meet the needs of large-scale document analysis.
[0005] In a first aspect, embodiments of this application provide a method for the joint construction of a knowledge graph, the method comprising: Extract the plain text content of the document to be parsed, divide the plain text content into multiple text blocks according to preset block parameters, and record the source block index of each text block; A hierarchical dual-axis ontology is constructed based on the observable axis determined by the plain text content and the interpretive axis determined by the inference interpretation. When the hierarchical dual-axis ontology changes, the structured data corresponding to the hierarchical dual-axis ontology is stored in the version snapshot list. Read the corresponding fields of the hierarchical dual-axis ontology to generate customized prompts for the hierarchical dual-axis ontology; The customized prompt words and the text block are input into the large language model to perform joint knowledge extraction, and the extraction results are saved to the draft data structure. For each element in the entity set and relation set of the draft data structure, add the original text reference and the source block index, and perform cross-block alignment and merging on the multiple text blocks to obtain the aligned entity set and the aligned relation set; A knowledge graph is jointly constructed based on the aligned entity set and the aligned relation set.
[0006] In one implementation of the first aspect, the input of the customized prompt word and the text block into a large language model to perform joint knowledge extraction includes two extraction modes: The joint mode is used to complete entity extraction, relation extraction and pattern discovery simultaneously in a single large language model call; The pipeline pattern is used to first call the entity extraction template to obtain a list of entity names, and then inject the list of entity names into the relationship extraction template for another call.
[0007] In one implementation of the first aspect, the extraction process of the joint pattern includes: The segmented text and the interpolated customized prompts are encapsulated into a request message, which then calls the unified scheduling module. The unified scheduling module routes to the corresponding adaptation function based on the provider identifier in the configuration; Each adapter function constructs a request body that conforms to the corresponding provider's application programming interface specification; The large language model returns structured text, calls the response parsing module to extract the pure structured data string, and parses it through the parsing function; Assign a globally unique identifier to each entity to record the source block sequence number; During relation extraction, the large language model outputs entity names, and the corresponding internal entity identifiers are found based on name matching to establish relation connections.
[0008] In one implementation of the first aspect, the pipeline pattern extraction process includes: Call the entity extraction template, pass only the chunked text, and it returns an array of entities; The entity names are flattened into comma-separated strings, and valid entity placeholders from the relation extraction template are injected. The large language model is then called again to extract the relations.
[0009] In one implementation of the first aspect, the process of appending a source text reference and the source block index to each element in the entity set and relation set of the draft data structure, and performing cross-block alignment and merging of the multiple text blocks, includes: Cross-block merging is performed based on exact match of entity names. During merging, the average confidence of all candidate entities is taken to update the entity confidence. Retain the list of source block numbers for all source blocks, and remove all duplicate relationships related to the entities being merged.
[0010] One implementation of the first aspect also includes draft review, which temporarily stores the aligned entity set, the aligned relation set, and the schema suggestion as an extraction draft. After manual review, the approved entities and relations are merged into the main knowledge base.
[0011] Secondly, embodiments of this application provide a knowledge graph joint construction apparatus, the apparatus comprising: The document parsing and intelligent chunking module is used to extract the plain text content of the document to be parsed, divide the plain text content into multiple text chunks according to preset chunking parameters, and record the source block index of each text chunk. The hierarchical dual-axis ontology management module is used to jointly construct a hierarchical dual-axis ontology based on the observable axis determined by the plain text content and the interpretation axis determined by the reasoning interpretation, and to store the structured data corresponding to the hierarchical dual-axis ontology into the version snapshot list when the hierarchical dual-axis ontology changes. The prompt word template engine module is used to read the corresponding fields of the hierarchical dual-axis ontology to generate customized prompt words for the hierarchical dual-axis ontology; The large language model joint extraction module is used to input the customized prompt words and the text blocks into the large language model to perform joint knowledge extraction and save the extraction results to the draft data structure. The evidence tracing and cross-block alignment module is used to attach original text references and source block indexes to each element in the entity set and relation set of the draft data structure, and to perform cross-block alignment and merging of the multiple text blocks to obtain the aligned entity set and the aligned relation set. The knowledge graph construction module is used to jointly construct a knowledge graph based on the aligned entity set and the aligned relation set.
[0012] Thirdly, embodiments of this application provide an electronic device, including: a processor, a memory, and a communication bus, wherein the processor and the memory communicate with each other through the communication bus; the memory stores program instructions executable by the processor, and the processor can execute the method provided in the first aspect or any possible implementation of the first aspect by calling the program instructions.
[0013] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer instructions that cause a computer to perform the method provided in the first aspect or any possible implementation thereof.
[0014] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0015] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0016] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0017] Figure 1 A flowchart illustrating a knowledge graph joint construction method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a knowledge graph joint construction device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] Please see Figure 1 As shown, it is a flowchart illustrating a knowledge graph joint construction method provided by an embodiment of the present invention.
[0020] To facilitate understanding of this embodiment, a detailed description of a knowledge graph joint construction method disclosed in this embodiment of the invention will be provided first, including: Step S1: Extract the plain text content of the document to be parsed, divide the plain text content into multiple text blocks according to the preset block division parameters, and record the source block index of each text block; Step S2: Construct a hierarchical dual-axis ontology based on the observable axis determined by the plain text content and the interpretive axis determined by the inference interpretation. When the hierarchical dual-axis ontology changes, store the structured data corresponding to the hierarchical dual-axis ontology into the version snapshot list. Step S3: Read the corresponding fields of the hierarchical dual-axis ontology to generate customized prompts for the hierarchical dual-axis ontology; Step S4: Input the customized prompt words and the text block into the large language model to perform joint knowledge extraction, and save the extraction results to the draft data structure; Step S5: Add original text references and source block indexes to each element in the entity set and relation set of the draft data structure, and perform cross-block alignment and merging on the multiple text blocks to obtain the aligned entity set and the aligned relation set. Step S6: Construct a knowledge graph based on the aligned entity set and the aligned relation set.
[0021] Specifically, this invention constructs a hierarchical dual-axis ontology based on observable facts and inferential explanations by segmenting plain text documents into multiple text blocks and managing version snapshots. Customized prompts are then generated using ontology fields, and joint knowledge extraction is performed in conjunction with a large language model. The results are temporarily stored in a draft data structure, and original text citations and source block indexes are added to the extracted entities and relations. Cross-block alignment and merging are then performed to eliminate redundancy and conflicts. Finally, a knowledge graph is jointly constructed based on the aligned set of entities and relations. This hierarchical dual-axis ontology separates and associates shallow factual knowledge with deep logical reasoning knowledge, enhancing the depth of knowledge and its decision support value. Through the version snapshot mechanism of ontology changes, the entire lifecycle of knowledge structure can be traced. When documents are iterated or rules are updated, the differences between old and new versions can be clearly compared, ensuring the compliance and auditability of the knowledge graph's evolution. Customized prompt words generated based on ontology fields are goal-oriented and can guide large language models to accurately extract knowledge in specific dimensions, suppressing illusions and noise in general extraction, and improving the recall and accuracy of extraction in low-resource or specialized vertical fields. The cross-block alignment and merging and original text citation backtracking mechanism solves the entity ambiguity and relationship breakage caused by the block cutting of long documents, ensuring the global semantic consistency of the graph, thereby meeting the needs of large-scale document analysis.
[0022] Please see Figure 2 As shown, this is a schematic diagram of a knowledge graph joint construction device provided in an embodiment of the present invention. The device includes: The document parsing and intelligent chunking module is used to extract the plain text content of the document to be parsed, divide the plain text content into multiple text chunks according to preset chunking parameters, and record the source block index of each text chunk. The hierarchical dual-axis ontology management module is used to jointly construct a hierarchical dual-axis ontology based on the observable axis determined by the plain text content and the interpretation axis determined by the reasoning interpretation, and to store the structured data corresponding to the hierarchical dual-axis ontology into the version snapshot list when the hierarchical dual-axis ontology changes. The prompt word template engine module is used to read the corresponding fields of the hierarchical dual-axis ontology to generate customized prompt words for the hierarchical dual-axis ontology; The large language model joint extraction module is used to input the customized prompt words and the text blocks into the large language model to perform joint knowledge extraction and save the extraction results to the draft data structure. The evidence tracing and cross-block alignment module is used to attach original text references and source block indexes to each element in the entity set and relation set of the draft data structure, and to perform cross-block alignment and merging of the multiple text blocks to obtain the aligned entity set and the aligned relation set. The knowledge graph construction module is used to jointly construct a knowledge graph based on the aligned entity set and the aligned relation set.
[0023] Specifically, in this embodiment of the invention, the input document to be parsed (PDF scientific research document) is parsed through the document parsing module to extract the plain text content of the scientific research document, and the source page index of each paragraph is recorded according to the page number for evidence tracing. For plain text input, it is directly segmented according to a fixed length or paragraph boundary.
[0024] In this embodiment of the invention, the document parsing module is set up based on the pdfjs-dist (v4) library.
[0025] Specifically, in this embodiment of the invention, the extracted plain text is segmented into text chunks of fixed size. The segmentation parameters of the text chunks include chunk size and overlap. When segmenting, chunks are broken at natural breakpoints to preserve the semantic integrity of sentences and paragraphs to the greatest extent.
[0026] In this embodiment of the invention, if a piece of text exceeds the block size, it is backtracked to the nearest natural breakpoint for truncation. Each text block records the global start index and end index of the text, as well as the chunk index.
[0027] In this embodiment of the invention, natural breakpoints are newline characters "\n" and spaces.
[0028] In a preferred embodiment, the block parameters are: block size of 30,000 characters and overlap parameter of 500 characters.
[0029] In this embodiment of the invention, the number of text blocks is dynamically calculated based on the total length of the text, and approximately 34 blocks are needed to process a document with 1 million characters.
[0030] Specifically, in this embodiment of the invention, the text after being segmented is normalized. The process includes replacing multiple consecutive spaces with a single space, removing non-printable characters, and retaining paragraph newline characters for semantic boundary judgment.
[0031] Specifically, this invention extracts the plain text content of PDF scientific research documents and records the source index by page number to establish a source tracing baseline. Then, with a fixed block size and overlap parameters, the text is preferentially segmented into multiple semantically complete text blocks at natural breakpoints such as line breaks, and the global start and end indexes and block numbers of each block are recorded. Finally, the segmented text is cleaned by continuous space normalization, removal of non-printable characters, etc., while retaining paragraph line breaks as the basis for semantic boundary judgment. The strategy of segmenting at natural breakpoints preserves the semantic integrity of sentences and paragraphs to the maximum extent, avoiding entity fragmentation and context loss caused by abrupt truncation. The overlap parameters allow adjacent blocks to share some context, alleviating information breaks at the boundaries and ensuring coherent recognition and alignment of cross-block entities, thereby meeting the needs of large-scale document analysis.
[0032] Specifically, the hierarchical dual-axis ontology of this invention adopts a hierarchical dual-axis structure, which includes the following core fields: Observable Axis, Interpretive Axis, Predicates, Alias Map, Constraints, and Schema History.
[0033] Specifically, the hierarchical biaxial structure of this invention consists of an observable axis and an interpretable axis.
[0034] Specifically, the observable axis in this embodiment of the invention includes an entity type hierarchy tree that can be directly obtained from the text. The root node of the entity type hierarchy tree is the root type of the observable axis, and the main types include: time type, space type, geological object type, geological unit type, and atom description type.
[0035] In this embodiment of the invention, time types include absolute age values (e.g., "Early Cambrian") and geologic time unit names (e.g., "Ediacaran System"); spatial types include location types (e.g., "Tarim Basin"), geometry types, and coordinate reference system types (CRS); geological object types include rock objects, outcrop sections, and wellbore holes; geological unit types include lithologic strata and chronostrata, where lithologic strata include supergroup, group, format, member, and bed types, and chronostrata include system, series, and stage types; and atomic description types include grain size (e.g., "fine sand"), sorting, and other basic sedimentary descriptive units.
[0036] Specifically, the interpretation axis of this invention includes a hierarchical tree of entity types that need to be reasoned and interpreted. The root node of the hierarchical tree of entity types is the root type of the interpretation axis. The main types include: Realm type, Environment Systems type, Rock Origin type, and Biostratigraphy type.
[0037] In this embodiment of the invention, the domain type includes terrestrial, transitional, and marine types; the environmental system type includes depositional environment and fluvial system type; the lithogenetic type includes sedimentary, igneous, and metamorphic rocks; and the biostratigraphic type includes taxon and biozone.
[0038] Specifically, the predicate classification in this embodiment of the invention divides relation types into several major categories according to semantics, including taxonomic and definitive relations, stratigraphic and spatial relations, genetic and processual relations, and temporal relations.
[0039] In this embodiment of the invention, the classification and definition relationship can be an instance relationship (instanceOf) or a part relationship (partOf); the stratigraphic and spatial relationship can be an occurrence relationship (occursIn), a located relationship (locatedIn), or an adjacent relationship (adjacentTo); the genetic and process relationship can be a formed relationship (formedBy) or a deposited relationship (depositedIn); and the temporal relationship can be a preceding relationship (precedes) or a synchronous relationship (synchronousWith).
[0040] Specifically, the alias mapping in this embodiment of the invention configures multiple natural language synonym lists for each relation label, so as to generate diverse expressions when interpolating prompt words, thereby improving the recognition recall rate of the large language model for the same relation type.
[0041] In this embodiment of the invention, the natural language synonym list can be such that the occurrence relation (occursIn) can be mapped to various expressions such as ["occurs at", "occur in", "developed in", "present in"].
[0042] Specifically, the constraint rules in this embodiment define type-level constraints to prevent large language models from generating unreasonable relationships.
[0043] In this embodiment of the invention, the constraint can be that the source of the relation inRealm must be a Depositional Environment and the target must be a Realm.
[0044] Specifically, the version snapshot list of this embodiment of the invention automatically saves a complete snapshot each time the ontology is changed, including the change timestamp, change description and complete ontology data before the change.
[0045] In this embodiment of the invention, ontology changes can include adding or deleting entity types, relation types, alias mappings, and constraint rules.
[0046] In this embodiment of the invention, the complete ontology data is stored in the structured data format JSON.
[0047] Specifically, when the ontology changes, the embodiments of the present invention automatically serialize the current ontology into structured data (JSON), generate a timestamp and change note, store it in the version snapshot list, and support version rollback, which can restore the ontology to any historical version.
[0048] Specifically, this invention constructs a hierarchical dual-axis ontology system comprising an observable axis and an interpretable axis, and is equipped with multiple semantic predicates, alias mappings, and type-level constraint rules. Simultaneously, it automatically stores complete structured data in a version snapshot list and supports version rollback during each ontology change. The dual-axis design explicitly separates shallow facts from deep reasoning knowledge, enabling the knowledge graph to record both geological and spatiotemporal observational information and expert reasoning interpretations of sedimentary environments and petrogenesis, thereby enhancing the depth of knowledge and its decision support value. It also generates diverse natural language from prompt words, improving the large language model's recall rate for identifying the same relation type and its cross-document generalization ability, thus meeting the needs of large-scale document analysis.
[0049] Specifically, embodiments of the present invention include various prompt word templates, covering the following task types: Joint Extraction is used to perform entity extraction, relation extraction, and pattern discovery simultaneously. Entity Extraction template is used only for extracting entities. Relation Extraction template extracts relations from a given list of entities; Pattern discovery templates are used to identify important concepts in the ontology that are not covered. Wiki entry generation templates are used to generate encyclopedia descriptions for entities.
[0050] Specifically, in the prompt word template of this embodiment of the invention, placeholders are used to mark the content to be replaced. At runtime, the corresponding fields of the ontology are read, the corresponding fields are flattened into comma-separated strings, the placeholders are replaced, and customized prompt words based on the ontology are generated.
[0051] In this embodiment of the invention, the double curly brace placeholder can be {{entity_types}}, {{relations}}, or {{valid_entities}}.
[0052] Specifically, each prompt word template in this embodiment of the invention independently maintains a version history list (VersionsList), and automatically generates a new version entry each time it is edited and saved, supporting rollback of any version.
[0053] In this embodiment of the invention, the new version entry includes a timestamp, a content snapshot, and a change description.
[0054] Specifically, this embodiment of the invention supports two extraction modes, which are selected by the user in the settings interface. The two extraction modes are as follows: Joint Mode (fast) allows entity extraction, relation extraction, and pattern discovery to be completed simultaneously in a single large language model call, making it suitable for processing large batches of documents. Pipeline Mode (Precise) is called in two steps. The first step calls the entity extraction template to obtain a list of entity names, and the second step injects the list of entity names into the relationship extraction template and calls it again. It is suitable for professional review scenarios with strict accuracy requirements.
[0055] Specifically, the detailed process of the joint mode in this embodiment of the invention is as follows: The first step is to encapsulate the segmented text and the interpolated customized prompts into a request message and call the unified dispatch module (Dispatch Generation). The second step is for the unified scheduling module to route to the corresponding adaptation function based on the provider identifier in the configuration. The third step involves each adapter function constructing a request body that conforms to the corresponding provider's application programming interface (API) specification. The request body contains key parameters that control the generation behavior of the large language model. The fourth step involves the large language model returning structured text (JSON Text), which is then processed by the response parsing module (containing the cleanJson function) to extract the pure structured data string, and finally parsed using the parsing function (JSON.parse). The fifth step is that the parsed data structure contains three fields: an array of entities, an array of relations, and an array of suggestions. Each entity contains a name, a type, a confidence level (a floating-point number between 0 and 1), and an evidence (optional). The sixth step is to assign a globally unique identifier (Global Unique ID) to each entity and record the source chunk index. In the seventh step, during relation extraction, the large language model outputs entity names. Based on the name matching, the corresponding internal entity identifier is found, and relation connections are established.
[0056] In this embodiment of the invention, the provider identifier can be gemini, openai, DeepSeek, anthropic, or local.
[0057] In this embodiment of the invention, key parameters include a temperature parameter (Temperature), which is set to a low randomness value (e.g., 0.1) to ensure sampling consistency; a maximum output length parameter (Max Tokens), which can be set to 8192; and a response format parameter (Response Format), which is a structured data format JSON. In this embodiment of the invention, the format of the globally unique identifier is a name connected by lowercase hyphens and a random suffix.
[0058] In this embodiment of the invention, the entity name includes the source entity name and the target entity name.
[0059] The detailed process of the pipeline mode in this embodiment of the invention is as follows: The first step is to call the entity extraction template, passing only the chunked text, and return an array of entities; The second step is to flatten the entity names into comma-separated strings, inject the valid entity placeholders from the relation extraction template, and then call the large language model again to extract the relations.
[0060] The large language model preprocessing in this embodiment of the invention involves calling the first step separately for multiple blocks, summarizing to obtain a global entity candidate list, and then aligning entities with the same name across blocks.
[0061] In this embodiment of the invention, the operation steps for aligning entities with the same name across blocks include merging entities with exactly matching names, fusing confidence scores, and then taking the average value.
[0062] Understandably, since all entity names are known, the relationships extracted by the large language model will not suffer from the phantom entity problem, and its accuracy is higher than that of the joint model.
[0063] Specifically, in this embodiment of the invention, the call to the unified scheduling module is wrapped by the automatic retry module (With Retry), which exponentially backs off and retryes recoverable errors.
[0064] The recoverable errors in this invention include HTTP 5xx server errors, overloaded errors, internal errors, and network errors (such as connection errors).
[0065] The retry parameters for the exponential backoff retries in this embodiment of the invention are as follows: the maximum number of retries is 3, the basic backoff delay is 1000 milliseconds, and the delay doubles with each retry (from 1000 milliseconds to 2000 milliseconds to 4000 milliseconds).
[0066] In this embodiment of the invention, unrecoverable errors (such as 401 authentication failure or 400 parameter error) are thrown directly without retrying.
[0067] Specifically, this invention generates customized ontology-oriented prompts by pre-setting multiple prompt word templates and dynamically reading and injecting fields such as entity type and relation type from a hierarchical dual-axis ontology using placeholders. It supports two extraction strategies: union mode and pipeline mode. The binding of templates to the ontology ensures that the prompts always maintain semantic consistency with the current knowledge model. The union mode completes multiple extraction tasks in a single call, shortening the processing time for large batches of documents. The pipeline mode improves the extraction accuracy and entity consistency in professional review scenarios through a step-by-step strategy of entity first and relation later and alignment fusion. The matching and merging strategy of cross-block entities with the same name and the confidence fusion strategy eliminate entity redundancy and ambiguity caused by long document block division, ensuring the global semantic consistency of the knowledge graph, thereby meeting the needs of large-scale document analysis.
[0068] Specifically, in this embodiment of the invention, when the evidence tracing function is enabled (Enable Evidence = true), each entity and relation output by the large language model contains an Evidence Field, which is a verbatim quote. At the same time, the source block number of each entity is recorded. By multiplying the block number by the block size and adding the character offset, the precise location of the evidence fragment in the original text can be uniquely determined.
[0069] In this embodiment of the invention, the length of the original text referenced is typically controlled between 20 and 150 characters.
[0070] Specifically, in this embodiment of the invention, the same entity may appear in multiple text blocks. The system performs cross-block merging by matching entity names exactly (case-insensitive). During merging, the average confidence of all candidate entities is taken, and the entity confidence is updated; the source chunk index list of all source chunks is retained. At the same time, all duplicate relationships related to the merged entity are removed.
[0071] Specifically, the relation deduplication method in this embodiment of the invention is based on a complete match of the source entity name, the target entity name, and the relation label triplet, and retains the relation with the highest confidence after deduplication.
[0072] Specifically, the extraction results of this embodiment of the invention are not directly written to the main knowledge base, but are saved to the extraction draft object, which includes a list of extracted entities, a list of extracted relations, and a list of schema suggestions.
[0073] Specifically, in this embodiment of the invention, users can view the extraction draft on the Extraction Pipeline Page. The interface provides three display areas (Tabs): the entity display area, the relationship display area, and the pattern suggestion display area.
[0074] In this embodiment of the invention, the entity display area includes displaying the entity name, type, confidence level, and original evidence fragments; the relationship display area includes displaying the source entity, target entity, relationship label, confidence level, and evidence fragments; and the pattern suggestion display area includes displaying the name, category (Entity / Relation), parent category, reason, and confidence level of new concepts discovered by the large language model.
[0075] Specifically, in this embodiment of the invention, the user can perform an accept or reject operation on each entity; an accept or reject operation on each relation; and an accept and incorporate operation or a reject operation on each schema suggestion.
[0076] In this embodiment of the invention, accepting and incorporating the ontology operation means adding a new type to the ontology and triggering a mode version snapshot.
[0077] Specifically, after the user completes the review in this embodiment of the invention, a merge operation is triggered, which moves all approved entities to the entity set (Current Project Entities) in the main knowledge base, moves all approved relations to the relation set (Current Project Relations) in the main knowledge base, clears the extraction draft, records the audit log (Audit Log, Draft Merge event), and triggers a schema version snapshot if the ontology has changed.
[0078] Specifically, the unified scheduling module in this embodiment of the invention is the core of the unified adaptation layer. The input parameters of the unified scheduling module include: Model Config object, Task Type, System Instruction, User Prompt, and optional structured data schema parameters (ResponseSchema, optional JSON schema). Then, the output is a structured text string (JSON TextString) generated by the large language model.
[0079] Specifically, this invention requires the large language model to output a source citation field for each entity and relation and record the source block number when evidence tracing is enabled. The source text position of the evidence can be located by calculating the block number and character offset. The extraction results are first stored in a draft data structure. Users can review and accept or reject each result on the extraction pipeline page. After the review is approved, a merging operation is triggered to move the entity and relation into the main knowledge base. For the same entity that appears in multiple text blocks, cross-block merging is performed by name matching. The cross-block entity merging and relation deduplication strategy eliminates entity redundancy and relation fragmentation caused by long document blocks, while retaining multiple source numbers and average confidence, ensuring the global consistency of the graph, and completely preserving the distribution information of entities in the document, thereby meeting the needs of large-scale document analysis.
[0080] Specifically, this embodiment of the invention uses Data-Driven Documents (D3.js) to render a force-directed graph based on the merged entity-relationship data. Nodes represent entities, and their size is positively correlated with confidence; lines represent relationships, with labels displayed in the middle of the lines. Nodes are colored according to entity type, as illustrated in the legend. Interactive functions include: node dragging, canvas zooming (d3.Zoom), node hover highlighting (displaying full attributes), and node search and positioning (Search & Highlighting).
[0081] Specifically, in this embodiment of the invention, for each entity in the main knowledge base, a large language model is invoked to infer the encyclopedia description for each entity. The entity name, type, and all text blocks containing this entity are passed as context to the Wiki Prompt Template, requiring the large language model to generate a concise definition of 1 to 3 sentences. If the context information is insufficient, an explicit "Insufficient information in source text" is displayed, and the generation of illusory content without source text support is prohibited.
[0082] In this embodiment of the invention, insufficient context information means that the entity appears only once and the amount of context information is small.
[0083] Specifically, this invention generates encyclopedic descriptions for each entity in the main knowledge base by calling a large language model, using the entity name, type, and all related text blocks as context. It also mandates explicit labeling when the original text information is insufficient and prohibits the generation of unfounded illusory content. Interactive functions such as hover highlighting and search positioning accurately focus on target entities and their related networks in a large-scale knowledge graph, improving the efficiency of knowledge retrieval and analysis. The entity encyclopedia generation based on the original text context is based on verifiable facts, thus meeting the needs of large-scale document analysis.
[0084] Please see Figure 3 As shown, it is a schematic diagram of an electronic device provided in an embodiment of the present invention. Figure 3 The electronic device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0085] Specifically, the electronic device 200 includes a processor 210, a memory 220, and a communication interface 230, which are interconnected and communicate with each other via a communication bus 240 and / or other forms of connection mechanism (not shown).
[0086] The memory 220 includes one or more (only one is shown in the figure), which may be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc. The processor 210 and other possible components may access the memory 220 to read and / or write data therein.
[0087] Processor 210 includes one or more (only one is shown in the figure), which can be an integrated circuit chip with signal processing capabilities. The processor 210 described above can be a general-purpose processor, including a central processing unit (CPU), a microcontroller unit (MCU), a network processor (NP), or other conventional processors; it can also be a special-purpose processor, including a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0088] The communication interface 230 includes one or more (only one is shown in the figure) and can be used to communicate directly or indirectly with other devices to exchange data. For example, the communication interface 230 can be an Ethernet interface; it can be a mobile communication network interface, such as an interface for 3G, 4G, or 5G networks; or it can be other types of interfaces with data transmission and reception functions.
[0089] One or more computer program instructions may be stored in memory 220, and processor 210 may read and run these computer program instructions to implement the knowledge graph joint construction method provided in the embodiments of this application and other desired functions.
[0090] This application also provides a computer-readable storage medium storing computer program instructions. These instructions are read and executed by a computer's processor to perform the knowledge graph joint construction method provided in this application. For example, the computer-readable storage medium can be implemented as follows: Figure 3 The memory 220 in the electronic device 200.
[0091] Example 1: Knowledge extraction from fossil stratigraphic literature of the Burgess Shale: Taking Whittington's (1985) classic paper on the Burgess Shale fossil strata in the Canadian Rocky Mountains, "Exceptional preservation of fossils from the Burgess Shale, Canadian Rocky Mountains" (Philosophical Transactions of the Royal Society B, 1985, 311:1-25, DOI:10.1098 / rstb.1985.0116), as an example, the specific implementation process of the method of this invention is illustrated: Step 1: The user uploads a PDF file (approximately 2.3MB in size, 42 pages in total). The plain text is extracted using the document parsing module, with a total character count of approximately 85,000. Step 2: Perform intelligent chunking, with a chunk size of 30,000 and an overlap parameter of 500, generating 3 chunks (chunk numbers: 0, 1, 2, corresponding to character ranges of 0~30,000, 29,500~59,500, and 59,000~85,000 respectively). Step 3: Load the current ontology and insert the entity types and relation types from the ontology into the joint extraction template; Step 4: Select the joint mode, call the Gemini API (gemini-2.0-flash), set the temperature parameter to 0.1, and call the unified scheduling module → Gemini generation function (generateWithGemini) for each of the three blocks. Step 5: The large language model returns structured data, which, after parsing, yields 47 entities, 31 relations, and 3 pattern suggestions. Step 6, cross-block alignment: The Burgess Shale appears once in both block 0 and block 2, and the system is merged into a unique entity with an average confidence level of 0.94. Step 7: The user reviews the draft through the draft review interface, accepting all 47 entities and 29 relationships, and rejecting 2 relationships with too low confidence (<0.5); Step 8: The user accepts the "predator" pattern suggestion, adds it to the ontology's interpretation axis / behavioral role, and triggers a pattern version snapshot; Step 9: Trigger the merge draft operation to merge entities and relationships into the main knowledge base; Step 10: Data-driven document rendering knowledge graph, displaying 47 nodes and 29 edges; Step 11: Use the large language model to generate a Wikipedia entry for "Burgess Shale": "The Burgess Shaleis is a Cambrian-age fossiliferous deposit exposed in the Canadian Rocky Mountains (Yoho National Park, British Columbia), famous for its exceptional preservation of soft-bodied organisms and contributing fundamentally to our understanding of the Cambrian Explosion (Whittington, 1985)." Example 2: Switching to the DeepSeek model: Users wishing to use the DeepSeek model for extraction to reduce costs can proceed on the Settings page as follows: Step 1, switch the provider identifier to "DeepSeek"; Step 2, configure the access key and base address; Step 3, select extraction model="DeepSeek-chat" and processing model="DeepSeek-chat". The unified scheduling module detects that the provider identifier is DeepSeek and routes the request to an OpenAI-compatible generator function. The base address is automatically switched to "https: / / api.deepseek.com", and the request format is fully compatible with OpenAI, requiring no modification to any extraction logic code.
[0092] Example 3: High-precision extraction of paleogeographic documents using a pipeline model: The user performed pipelined extraction on the paper "A new Burgess Shale-type fauna from the early Cambrian of the Siberian Platform" by Ivantsov et al. (2019) (Palaeogeography, Palaeoclimatology, Palaeoecology, 2019, 534: 109323, DOI: 10.1016 / j.palaeo.2019.109323, total character count 45,000, divided into 2 blocks): Step 1, the entity extraction template was called for both block 0 and block 1, returning a total of 62 entity candidates; Step 2, after cross-block alignment, 48 unique entities were obtained (such as "Siberian Platform" → geological unit type, "Early Cambrian" → geological period type, "Burgess Shale-type fossil" → fossil type, etc.).
[0093] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present application should be included within the scope of protection of the present application.
Claims
1. A method for jointly constructing a knowledge graph, characterized in that, include: Extract the plain text content of the document to be parsed, divide the plain text content into multiple text blocks according to preset block parameters, and record the source block index of each text block; A hierarchical dual-axis ontology is constructed based on the observable axis determined by the plain text content and the interpretive axis determined by the inference interpretation. When the hierarchical dual-axis ontology changes, the structured data corresponding to the hierarchical dual-axis ontology is stored in the version snapshot list. Read the corresponding fields of the hierarchical dual-axis ontology to generate customized prompts for the hierarchical dual-axis ontology; The customized prompt words and the text block are input into the large language model to perform joint knowledge extraction, and the extraction results are saved to the draft data structure. For each element in the entity set and relation set of the draft data structure, add the original text reference and the source block index, and perform cross-block alignment and merging on the multiple text blocks to obtain the aligned entity set and the aligned relation set; A knowledge graph is jointly constructed based on the aligned entity set and the aligned relation set.
2. The knowledge graph joint construction method according to claim 1, characterized in that, The process of inputting the customized prompt words and the text block into the large language model to perform joint knowledge extraction includes two extraction modes: The joint mode is used to complete entity extraction, relation extraction and pattern discovery simultaneously in a single large language model call; The pipeline pattern is used to first call the entity extraction template to obtain a list of entity names, and then inject the list of entity names into the relationship extraction template for another call.
3. The knowledge graph joint construction method according to claim 2, characterized in that, The extraction process of the joint pattern includes: The segmented text and the interpolated customized prompts are encapsulated into a request message, which then calls the unified scheduling module. The unified scheduling module routes to the corresponding adaptation function based on the provider identifier in the configuration; Each adapter function constructs a request body that conforms to the corresponding provider's application programming interface specification; The large language model returns structured text, calls the response parsing module to extract the pure structured data string, and parses it through the parsing function; Assign a globally unique identifier to each entity to record the source block sequence number; During relation extraction, the large language model outputs entity names, and the corresponding internal entity identifiers are found based on name matching to establish relation connections.
4. The knowledge graph joint construction method according to claim 2, characterized in that, The extraction process of the pipeline pattern includes: Call the entity extraction template, pass only the chunked text, and it returns an array of entities; The entity names are flattened into comma-separated strings, and valid entity placeholders from the relation extraction template are injected. The large language model is then called again to extract the relations.
5. The knowledge graph joint construction method according to claim 4, characterized in that, The process of appending original text references and source block indexes to each element in the entity set and relation set of the draft data structure, and performing cross-block alignment and merging of the multiple text blocks, includes: Cross-block merging is performed based on exact match of entity names. During merging, the average confidence of all candidate entities is taken to update the entity confidence. Retain the list of source block numbers for all source blocks, and remove all duplicate relationships related to the entities being merged.
6. The knowledge graph joint construction method according to any one of claims 1 to 5, characterized in that, It also includes draft review, which temporarily stores the aligned entity set, the aligned relation set, and the schema suggestion as extraction drafts. After manual review, the approved entities and relations are merged into the main knowledge base.
7. A knowledge graph joint construction apparatus, employing the knowledge graph joint construction method according to any one of claims 1-6, characterized in that, include: The document parsing and intelligent chunking module is used to extract the plain text content of the document to be parsed, divide the plain text content into multiple text chunks according to preset chunking parameters, and record the source block index of each text chunk. The hierarchical dual-axis ontology management module is used to jointly construct a hierarchical dual-axis ontology based on the observable axis determined by the plain text content and the interpretation axis determined by the reasoning interpretation, and to store the structured data corresponding to the hierarchical dual-axis ontology into the version snapshot list when the hierarchical dual-axis ontology changes. The prompt word template engine module is used to read the corresponding fields of the hierarchical dual-axis ontology to generate customized prompt words for the hierarchical dual-axis ontology; The large language model joint extraction module is used to input the customized prompt words and the text blocks into the large language model to perform joint knowledge extraction and save the extraction results to the draft data structure. The evidence tracing and cross-block alignment module is used to attach original text references and source block indexes to each element in the entity set and relation set of the draft data structure, and to perform cross-block alignment and merging of the multiple text blocks to obtain the aligned entity set and the aligned relation set. The knowledge graph construction module is used to jointly construct a knowledge graph based on the aligned entity set and the aligned relation set.
8. An electronic device, characterized in that, include: A processor, a memory, and a communication bus, wherein the processor and the memory communicate with each other via the communication bus; The memory stores program instructions that can be executed by the processor, and the processor can execute the knowledge graph joint construction method as described in any one of claims 1 to 6 by calling the program instructions.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause the computer to perform the knowledge graph joint construction method as described in any one of claims 1 to 6.