Knowledge graph construction method, device and equipment and readable storage medium

By using a large language model for subject-verb-object formatting and implicit relation reasoning, and combining semantic similarity to segment document fragments, the problems of high manpower cost and insufficient accuracy in knowledge graph construction are solved. This enables efficient and interpretable knowledge graph construction, improving the completeness and accuracy of the knowledge graph.

CN121327151APending Publication Date: 2026-01-13SICHUAN SHUTIANMENGTU DATA TECH CO LTD

Patent Information

Application Number
CN202511495859.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-20
Publication Date
2026-01-13

AI Technical Summary

Technical Problem

Existing technologies face problems such as high labor costs, low efficiency, and insufficient accuracy and completeness when constructing knowledge graphs. In particular, when dealing with complex sentence structures, sparse domain terminology, or text-level semantic relationships, the recognition accuracy is low, the relationships are fragmented, and the interpretability is poor.

Method used

We employ a large language model for subject-verb-object formatting, combine semantic similarity to segment document fragments, extract entities and relations, and reason about implicit relations. We construct a knowledge graph through normalization and utilize the implicit reasoning capabilities of the large language model for logical completion and implicit relation mining.

Benefits of technology

It enables the construction of high-quality, interpretable knowledge graphs without extensive annotation, improving the completeness and accuracy of knowledge graphs and solving the problem of insufficient integration of information across paragraphs and documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121327151A_ABST
    Figure CN121327151A_ABST
Patent Text Reader

Abstract

The invention discloses a knowledge graph construction method, device and equipment and a readable storage medium, and is applied to the technical field of natural language processing and knowledge engineering.The method comprises the steps that document content is divided to obtain initial document fragments, and all the initial document fragments are merged and divided based on semantic similarity to obtain target division blocks; based on the target division block, subject-predicate-object formatting processing is carried out to obtain a subject-predicate-object formatting result; entity and relation extraction is carried out according to the subject-predicate-object formatting result to obtain a display triple, implicit relation reasoning is carried out to obtain an implicit relation triple, entity and relation type normalization is carried out to obtain a normalized triple, and the knowledge graph is constructed based on the normalized triple. The block segmentation driven by semantic similarity is adopted to avoid sentence breakage, cascade errors are reduced based on subject-object formatting processing, and the problems of fragmentation, link missing and the like are solved based on implicit relations, so that the integrity and accuracy of knowledge graph construction are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of natural language processing and knowledge engineering, and particularly relates to a knowledge graph construction method, device and equipment and a readable storage medium. BACKGROUND

[0002] In the traditional knowledge graph construction process, in the face of massive unstructured documents (such as patent documents, technical reports, academic papers, etc.), it is usually necessary to rely on a large number of manual rules and field expert annotations to complete entity recognition, relationship extraction and graph construction. These processes not only require operators to have deep natural language processing and field knowledge background, but also need to invest high labor costs for data cleaning, template maintenance and quality checking. For enterprise-level application scenarios, this "heavy manual, low efficiency" construction method has been difficult to meet the needs of rapid updating and large-scale expansion. Although some automatic extraction tools and deep learning models are introduced into the knowledge graph construction process, there are still problems such as low recognition accuracy, fragmented relationships, many conflicts, and poor interpretability when dealing with complex sentence patterns, sparse domain terms or chapter-level semantic associations.

[0003] It can be seen that how to improve the completeness and accuracy of the knowledge graph is a technical problem that needs to be solved by those skilled in the art. SUMMARY

[0004] Therefore, the purpose of the present application is to provide a knowledge graph construction method, device, equipment and readable storage medium, which solves the technical problem of low accuracy and completeness of the knowledge graph construction in the prior art.

[0005] To solve the above technical problems, the present application provides a knowledge graph construction method, comprising:

[0006] The document content is divided using a set of rules to obtain initial document segments, and all initial document segments are merged and divided based on semantic similarity to obtain target division blocks;

[0007] The target division blocks are processed using a first large language model to obtain a subject-predicate-object format result;

[0008] According to the subject-predicate-object format result, a second large language model is used for entity and relationship extraction to obtain display triples, and implicit relationship reasoning is performed to obtain implicit relationship triples;

[0009] Based on the display triples and the implicit relationship triples, entity and relationship type normalization is performed to obtain normalized triples, and a knowledge graph is constructed based on the normalized triples.

[0010] Optionally, the document content is divided using a set of rules to obtain initial document segments, and all the initial document segments are merged and divided based on semantic similarity to obtain target division blocks, including:

[0011] The document content is sequentially divided in units of sentences or paragraphs to obtain a plurality of initial document segments;

[0012] A first vector corresponding to a first initial document segment is determined;

[0013] A second vector corresponding to a second initial document segment is determined, and a cosine similarity between the first vector and the second vector is calculated;

[0014] If the cosine similarity is greater than or equal to a set cosine similarity threshold, the second initial document segment is merged into the first initial document segment, and the first vector is updated to a vector of the merged document segment;

[0015] The above process is repeated until the cosine similarity between the merged document segment and the current initial document segment is less than the cosine similarity threshold, the current initial document segment is independently divided into a new first initial document segment for iteration, and the merging path, character offset, hierarchical title, and chart index are recorded. The target block with semantic coherence labels is output.

[0016] Optionally, the document content is divided using a set of rules to obtain initial document segments, and all the initial document segments are merged and divided based on semantic similarity to obtain target division blocks, including:

[0017] When the initial document segment is the hierarchical title and the chart index, it is determined that the current hierarchical title or the chart index is independently used as a target division block.

[0018] Optionally, a first large language model is used based on the target division block to perform subject-predicate-object formatting processing to obtain a subject-predicate-object formatting result, including:

[0019] A first preset prompt word is determined based on a first constraint rule; wherein the first constraint rule includes semantic consistency, term standardization, reference resolution, subject-object atomization, and subject-predicate-object format integrity; the reference resolution is a constraint rule for converting pronouns to specific entities; and the subject-object atomization is a rule for splitting the subject and the object into indivisible single entities;

[0020] The target division block and the first preset prompt word are input into the first large language model to obtain the subject-predicate-object formatting result.

[0021] Optionally, according to the subject-predicate-object formatting result, entity and relation extraction is performed by using a second large language model to obtain display triples, and implicit relation reasoning is performed to obtain implicit relation triples, including:

[0022] A second preset prompt word is determined based on a second constraint rule; the second constraint rule includes subject-predicate-object extraction integrity, entity expression consistency, subject-object atomization, reference resolution, term pair relation, predicate number limitation, term standardization, and associated relation integrity;

[0023] The subject-predicate-object formatting result and the second preset prompt word are input into the second large language model to obtain the display triples.

[0024] Optionally, according to the subject-predicate-object formatting result, entity and relation extraction is performed by using a second large language model to obtain display triples, and implicit relation reasoning is performed to obtain implicit relation triples, including:

[0025] The display triples, the subject-predicate-object formatting result, and a third preset prompt word are input into a third large language model to obtain a first implicit relation;

[0026] A second implicit relation is obtained by using a transitive logic rule, and the implicit relation triples are determined based on the first implicit relation and the second implicit relation.

[0027] Optionally, entity and relation type normalization is performed based on the display triples and the implicit relation triples to obtain normalized triples, and a knowledge graph is constructed based on the normalized triples, including:

[0028] All entity types and relation types in the display triples and the implicit relation triples are obtained;

[0029] The entity types, the relation types, and a fourth preset prompt word are synchronously input into a fourth large language model, similar entity types are divided into the same group, similar relation types are divided into the same group, a normalized type name corresponding to all entity types in each group is determined, and a normalized relation type corresponding to all relation types in each group is determined;

[0030] The normalized triples are constructed based on the normalized relation type and the normalized relation type.

[0031] The application further provides a knowledge graph construction method, including:

[0032] A target division block determination module is configured to divide document content by using a set rule to obtain initial document segments, and merge and divide all initial document segments based on semantic similarity to obtain target division blocks.

[0033] The subject-verb-object formatting result determination module is used to perform subject-verb-object formatting processing based on the target partition block using the first large language model to obtain the subject-verb-object formatting result.

[0034] The implicit relation triple determination module is used to extract entities and relations based on the subject-verb-object formatting results using the second largest language model to obtain explicit triples, and to perform implicit relation reasoning to obtain implicit relation triples.

[0035] The knowledge graph construction module is used to normalize the entity and relation types based on the explicit triples and the implicit relation triples to obtain normalized triples, and to construct a knowledge graph based on the normalized triples.

[0036] The present invention also provides a knowledge graph construction device, comprising:

[0037] Memory, used to store computer programs;

[0038] A processor for executing the computer program to implement the steps of the knowledge graph construction method described above.

[0039] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the knowledge graph construction method described above.

[0040] The present invention also provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the above-described knowledge graph construction method.

[0041] As can be seen, this invention divides document content using predefined rules to obtain initial document fragments, and merges and divides all initial document fragments based on semantic similarity to obtain target segmentation blocks; based on the target segmentation blocks, it performs subject-verb-object formatting using a first major language model to obtain subject-verb-object formatting results; based on the subject-verb-object formatting results, it extracts entities and relations using a second major language model to obtain explicit triples, and performs implicit relation reasoning to obtain implicit relation triples; based on the explicit triples and the implicit relation triples, it performs entity and relation type normalization to obtain normalized triples, and constructs a knowledge graph based on the normalized triples. The beneficial effects of this invention are as follows: Compared with the current difficulty in effectively integrating information across paragraphs and documents, which leads to insufficient completeness and accuracy of knowledge graphs, this invention firstly completes the unified loading of documents while preserving the original text format and chapter structure, ensuring that cross-paragraph and cross-page semantics are not lost during subsequent extraction; secondly, it adopts semantic similarity-driven block segmentation, which avoids sentence breaks caused by sliding windows and provides a "complete context" for subsequent large language model inference; thirdly, based on "subject-verb-object formatting processing," it allows the large language model to output subject-verb-object formatted text in parallel within the same context. As a result, simultaneous extraction of entities and relations is achieved, reducing cascading errors. Furthermore, the implicit reasoning capabilities of the large language model are utilized to logically complete existing triples and mine implicit relations, resolving issues such as fragmentation and missing links. Subsequently, semantic alignment of all entity / relation types is performed through normalization prompts, eliminating synonyms and homonyms, and improving graph consistency and interpretability. Finally, explicit and implicit triples are batch-written into the graph database, completing the construction of a scalable and evolvable knowledge graph, thereby improving the completeness and accuracy of knowledge graph construction.

[0042] In addition, the present invention also provides a knowledge graph construction apparatus, device and readable storage medium, which also have the above-mentioned beneficial effects. Attached Figure Description

[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0044] Figure 1 A flowchart of a knowledge graph construction method provided in an embodiment of the present invention;

[0045] Figure 2 This invention provides an optimized method for constructing knowledge graphs from unstructured documents based on a large language model.

[0046] Figure 3 A schematic diagram of the interaction method architecture for an optimized method of constructing a knowledge graph based on unstructured documents using a large language model, provided in an embodiment of the present invention;

[0047] Figure 4 This is a schematic diagram of the structure of a knowledge graph construction device provided in an embodiment of the present invention;

[0048] Figure 5 This is a schematic diagram of a knowledge graph construction device provided in an embodiment of the present invention. Detailed Implementation

[0049] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments 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, and 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.

[0050] In traditional knowledge graph construction, dealing with massive amounts of unstructured documents (such as patent documents, technical reports, and academic papers) typically requires extensive manual rule-making and domain expert annotation to complete entity recognition, relation extraction, and graph construction. These processes not only demand that operators possess strong natural language processing and domain knowledge backgrounds but also require significant investment in human resources for data cleaning, template maintenance, and quality verification. For enterprise-level applications, this "manually-intensive and inefficient" construction method is no longer sufficient to meet the demands of rapid updates and scalable expansion.

[0051] In recent years, although some automated extraction tools and deep learning models have been introduced into the knowledge graph construction process, they still generally suffer from low recognition accuracy, fragmented relationships, numerous conflicts, and poor interpretability when dealing with complex sentence structures, sparse domain terminology, or text-level semantic relationships. This is especially true when facing long, nested sentences, multi-step process logic, ellipsis structures, and multilingual content in Chinese patent texts, where the extraction performance of existing models is significantly reduced. Furthermore, traditional automated tools often lack a deep understanding of the overall semantic structure of documents, making it difficult to effectively integrate information across paragraphs and documents, resulting in insufficient completeness and accuracy of the knowledge graph.

[0052] In view of this, how to overcome the shortcomings of existing technologies, how to use large language models to achieve efficient, accurate and interpretable knowledge graph construction of unstructured documents, and how to solve key problems such as poor domain adaptability, high annotation costs and serious error cascading have become important technical problems that the industry urgently needs to solve.

[0053] Addressing the shortcomings and improvement needs of existing technologies—namely, the difficulty in eliminating manual rules and annotations, resulting in "heavy manual labor and low efficiency," low accuracy in extracting complex patent texts, fragmented relationships, and insufficient integration of cross-segment information—this invention provides an optimized method for constructing knowledge graphs from unstructured documents based on a large language model. This method solves the problem of "heavy manual labor and low efficiency" in constructing knowledge graphs from unstructured documents, proposing an optimized method for constructing knowledge graphs from unstructured documents based on a large language model. This achieves high-quality, scalable, and interpretable automatic graph construction without requiring extensive annotation.

[0054] Please refer to Figure 1 , Figure 1 A flowchart illustrating a knowledge graph construction method provided in an embodiment of the present invention. The method may include:

[0055] S101, the document content is divided according to the set rules to obtain initial document fragments, and all initial document fragments are merged and divided based on semantic similarity to obtain the target segmentation block.

[0056] The steps in this embodiment can be performed by a designated electronic device, which may be a server, a portable terminal, or other form. This embodiment does not limit the specific rules for setting the content. For example, the rule in this embodiment could be to divide the document content into paragraphs; or it could be to divide it by punctuation marks ".". This embodiment does not limit the specific method for determining the semantic similarity between the initial document fragments. For example, this embodiment could determine semantic similarity based on word overlap. Alternatively, this embodiment could determine semantic similarity based on statistical vector methods, converting the text into numerical vectors and calculating vector distances. Or, this embodiment could determine semantic similarity based on deep learning / neural network methods.

[0057] It should be further explained that, based on any of the above embodiments, the above-described method of dividing the document content using set rules to obtain initial document fragments, and merging and dividing all initial document fragments based on semantic similarity to obtain the target segmentation block, may include:

[0058] S1011, The document content is divided into multiple initial document fragments by dividing it into sentences or paragraphs in sequence;

[0059] S1012, Determine the first vector corresponding to the first initial document fragment;

[0060] S1013, determine the second vector corresponding to the second initial document fragment, and calculate the cosine similarity between the first vector and the second vector;

[0061] S1014, If the cosine similarity is greater than or equal to the set cosine similarity threshold, then merge the second initial document fragment into the first initial document fragment, and update the first vector to the vector of the merged document fragment;

[0062] S1015, repeat the above process until the cosine similarity between the merged document fragment and the current initial document fragment is less than the cosine similarity threshold. Then, the current initial document fragment is set as a new first initial document fragment and the iteration continues. At the same time, the merging path, character offset, hierarchical title and chart index are recorded, and the target block with semantic coherence label is output.

[0063] The rules in this embodiment are set at the sentence or paragraph level. This embodiment does not limit the specific method for determining the vectors corresponding to each initial document fragment. For example, this embodiment can determine the vectors based on the bag-of-words model; or it can determine the vectors based on word embedding averaging; or it can use a deep learning model to directly generate context-aware embedding vectors for the entire sentence or paragraph. This embodiment does not limit the specific cosine similarity threshold. For example, the cosine similarity threshold in this embodiment can be 0.7; or the cosine similarity threshold in this embodiment can be 0.8, etc. In this embodiment, the document is loaded sequentially by sentence or paragraph. The first unit is designated as `first_chunk` and a vector `v1` is generated. The next unit is then taken as `second_chunk` and a vector `v2` is generated. The cosine similarity (cosθ) between `v1` and `v2` is calculated. If `cosθ` is greater than or equal to a set cosine similarity threshold, `second_chunk` is merged into `first_chunk`, and `v1` is updated to the vector value of the merged text. This process is repeated until `cosθ` is less than the set threshold. Then, `second_chunk` becomes a new `first_chunk` and iteration continues. Simultaneously, the merging path, character offsets, hierarchical headings, and chart indexes are recorded, and a chunk object with semantic coherence labels is output. In this embodiment, the merging path can be understood as which chunk follows `first_chunk`, which is crucial for tracing the source. The character offsets in this embodiment determine the start and end positions of this chunk in the original document for precise location. Hierarchical headings in this embodiment typically represent strong semantic boundaries and should be treated as independent chunks. The graph index in this embodiment indicates that when a graph is encountered, it should also be treated as an independent semantic unit and formed into a separate chunk. The semantic coherence label in this embodiment is used to indicate that the constructed chunk has coherence. This embodiment can achieve dynamic chunking by automatically aggregating semantically smooth areas and immediately splitting semantically abrupt areas through the above process.

[0064] It should be further explained that, based on any of the above embodiments, the above-described method of dividing the document content using set rules to obtain initial document fragments, and merging and dividing all initial document fragments based on semantic similarity to obtain target partition blocks, may include: when the initial document fragment is a hierarchical heading and a chart index, determining that the current hierarchical heading or the chart index is a separate target partition block. In this embodiment, treating the hierarchical heading and chart index as separate blocks can preserve the original structure and semantic logic of the document, thereby significantly improving the performance of downstream tasks (such as knowledge graph construction).

[0065] It should be noted that this embodiment can combine different types of document loaders to uniformly load and preserve the article structure of multi-source unstructured documents. Specifically, it can include loading documents based on various document types such as patents, papers, and technical reports using different built-in document loaders. The loaders include at least five types of built-in loaders: PDF, Word, HTML (Hypertext Markup Language), XML (Extensible Markup Language), and Markdown (Lightweight Markup Language). At the same time, it calls the layout analysis engine and table recognition model to extract the main text, tables, figure captions, titles, paragraph numbers, and metadata. The paragraph levels, title numbers, figure indexes, and their semantic tags are serialized together and converted into a unified Document object (a piece of text + metadata) (metadata is the basic information of the file). This eliminates the need to parse the original format again in subsequent steps of segmentation, vectorization, retrieval, and tracing, and ensures the consistency of the chapter structure, citation information, and visual reading order.

[0066] S102, based on the target partitioning block, the first large language model is used to perform subject-verb-object formatting processing to obtain the subject-verb-object formatting result.

[0067] In this embodiment, the first, second, and third large language models can be of the same or different types. Large Language Models (LLMs) are a class of deep learning models with a large number of parameters. In the field of Natural Language Processing (NLP), they learn language patterns, syntax, and semantics by processing large amounts of text data, thereby understanding and generating human language. This embodiment is not limited to a specific large language model. For example, the large language model in this embodiment could also be GPT (Generative Pre-trained Transformer), Wenxin Large Model, Tongyi Qianwen, etc. The subject-predicate-object formatting processing in this embodiment refers to SPO (Subject-Predicate-Object) formatting. This embodiment performs subject-predicate-object formatting processing to convert the "natural language" that humans use for communication and narration into "data language" that machines use for storage, management, and reasoning.

[0068] It should be further explained that, based on any of the above embodiments, the above-mentioned subject-verb-object formatting processing based on the target segmentation block using the first large language model to obtain the subject-verb-object formatting result may include:

[0069] S1021, determine the first preset prompt word based on the first constraint rule; wherein, the first constraint rule includes semantic consistency, terminology standardization, reference resolution, subject-object atomization, and subject-verb-object format integrity; reference resolution is a constraint rule that converts pronouns into concrete entities; subject-object atomization is a rule that splits the subject and object into indivisible single entities;

[0070] S1022, input the target segmentation block and the first preset prompt word into the first large language model to obtain the subject-verb-object formatted result.

[0071] This embodiment synchronously inputs all target blocks and preset Prompts (first preset prompt words) into the large language model. The Prompt guides the rewriting with five constraint rules: ① Semantic consistency: The semantics of the rewritten SPO format must be consistent with the semantics of the original content, and arbitrary expansion and elaboration are not allowed, and the introduction of external knowledge is prohibited; ② Terminology standardization: When rewriting, the entire context should be considered, and the most common standard form should always be used for the same concept with slight differences; ③ Referential dissolution: The entire context should be deeply analyzed to understand the semantics of the content, and any pronouns should be replaced with the actual referents; ④ Subject-object atomization: When rewriting, multiple concepts should not be merged into one term. They should be atomized as much as possible, and S and O should be split into indivisible single entities; ⑤ SPO format integrity: The output should only contain text content containing SPO, filtering out other irrelevant facts and other content with the semantics of the original content, ensuring that all possible relationships have been identified in the text and are represented by SPO. Formal expression of relations: The original chunk content and the designed prompts are input into the large language model. The model's output is post-processed to ensure that the rewritten SPO format content conforms to the above five constraints, and each SPO format is output as a sentence. Semantic consistency in this embodiment ensures that the extracted triples (SPOs) are consistent with the contextual meaning of the original text. Terminology standardization in this embodiment unifies predicates (relations) with different expressions but the same meaning into a standard term, thereby avoiding a large number of relation edges with the same meaning but different expressions in the graph, making the graph structure clearer and more concise. Referential resolution in this embodiment replaces pronouns (it, he, she, its) or indicator words (the company, this device) with the specific entity names they refer to, so that all triples can be correctly connected by entity names to form an interconnected knowledge network, rather than a bunch of isolated fragments full of "it" and "its". Subject-object atomization in this embodiment splits the compound subject or object into the smallest indivisible independent entities, explicitly expressing multiple relations implicit in the compound phrase. The SPO format integrity in this embodiment ensures strict adherence to the (Subject, Predicate, Object) triple format, guaranteeing that each part is complete and accurate.

[0072] S103. Based on the subject-verb-object formatting results, the second largest language model is used to extract entities and relations to obtain explicit triples, and implicit relation reasoning is performed to obtain implicit relation triples.

[0073] In this embodiment, directly extracting entities and relations from the second largest language only yields the surface-level triples of the text, failing to capture the implicit content. This embodiment does not limit the specific method for implicit relation reasoning. For example, it can be based on a large language model; or it can determine implicit relations based on logical relation subjects; or it can be based on rule and pattern matching, such as identifying trigger words and sentence structures. For instance, the pattern "[Person A] is the CEO of [Company B]" can extract (Person A, position is, CEO) and (Person A, employed by, Company B), using syntactic analysis (dependency syntax, constituent syntax) to locate subject, verb, and object components, even if they are disrupted by passive voice or complex clauses. Alternatively, this embodiment can treat relation extraction as a classification problem based on machine learning and feature engineering to extract implicit relations; or it can also be based on knowledge graphs and large language models for implicit relation reasoning. This embodiment can combine multiple implicit relation reasoning methods simultaneously. Understandably, implicit relationships do not appear directly in the text and need to be inferred through background knowledge, logical reasoning, or context.

[0074] It should be further explained that, based on any of the above embodiments, entity and relation extraction is performed using the second largest language model based on the subject-verb-object formatting results to obtain explicit triples, and implicit relation reasoning is performed to obtain implicit relation triples, which may include:

[0075] S1031, determine the second preset prompt word based on the second constraint rule; wherein, the second constraint rule includes subject-verb-object extraction completeness, entity expression consistency, subject-object atomization, reference resolution, term pairing relationship, predicate number limit, term standardization and association relationship completeness;

[0076] S1032, input the subject-verb-object formatting result and the second preset prompt word into the second large language model to obtain the display triplet.

[0077] In this embodiment, the SPO-formatted chunk text and the preset Prompt (second preset prompt word) are synchronously input into the large language model. The Prompt guides the rewriting with eight constraint rules: ① Extraction completeness: Ensure that all subject-verb-object (SPO) relationships in each sentence are extracted; ② Entity consistency: The subject and object in the extracted triples use the same most complete form of entity expression; ③ Subject-object atomization: During rewriting, avoid merging multiple concepts into one term, and try to atomize them, splitting S and O into indivisible single entities; ④ Referential resolution: Deeply analyze the entire context content, understand the semantics of the content, and replace any pronouns with the actual referent entities; ⑤ Paired relations: When multiple terms appear simultaneously in the same sentence (or in a short paragraph that makes them related in the context), create a triple for each pair of terms with a meaningful relationship; ⑥ Verb restriction: The verb must be at most one word and cannot contain any punctuation marks, only Chinese characters are allowed, in order to ensure knowledge graph storage and semantic conciseness. ⑦ Terminology standardization: When rewriting, consider the entire context and always use the most common standard form for the same concept with slight differences; ⑧ Relationship integrity: If the context mentions someone's name and includes information about their location, occupation, and notable achievements (inventions, writings, creations, titles, etc.), then create an association between the name and this information; Input the SPO (Subject-Predicate-Object) formatted result along with the designed prompts into the large language model, post-process the model's output to ensure that the rewritten SPO formatted content conforms to the above eight constraints, assemble each triple into a JSON structure, and output it uniformly as a list structure. It is understandable that there are multiple overlapping rules with the previous five rules because: 1. Large language models sometimes produce illusions, i.e., generating content that does not conform to the input or common sense. By using consistent prompt rules, the model can be guided to more accurately understand and generate logically consistent content. 2. When processing continuous tasks, large language models need to maintain the consistency and coherence of their responses. Using the same prompt word rules ensures that the model follows the same logic and standards across multiple calls, resulting in consistent output, improved user experience, and reduced output inconsistencies caused by rule changes. 3. If the prompt word rules change with each call, the model may generate a large amount of repetitive or similar content. Using the same rules allows the model to know more explicitly when to generate new information, avoiding unnecessary repetition. 4. When performing a specific task, consistent rules help the model maintain a clear goal and action guide, ensuring the task can be completed successfully.

[0078] It should be further explained that, based on any of the above embodiments, the above-mentioned extraction of entities and relations using the second large language model based on the subject-verb-object formatting result to obtain explicit triples, and the inference of implicit relations to obtain implicit relation triples, may include: inputting the explicit triples, the subject-verb-object formatting result, and the third preset prompt word into the third large language model to obtain the first implicit relation; obtaining the second implicit relation using transitive logic rules; and determining the implicit relation triples based on the first and second implicit relations. This embodiment synchronously inputs the triple content, the SPO-formatted chunk text, and the preset prompt into the large language model. The large language model analyzes the SPO-formatted chunk text and triple content to infer possible implicit relationships by combining prompt words. In addition, it uses simple transitive logic rules to infer implicit relationships. In short, it uses a two-stage reasoning approach of logic rules + large language model to discover new triples in the graph that are not yet displayed or stored, but may be semantically or logically valid. The model's output is post-processed, and each implicit relationship triple after inference is assembled into a JSON structure and output in a unified list structure. This embodiment combines the large language model and transitive logic rules to determine implicit relationships, improving the accuracy of implicit relationship determination.

[0079] It should be noted that this embodiment can store the extracted explicit triples and the inferred implicit relation triples in a knowledge graph. Specifically, it can include: by writing Cypher (insertion statement writing strategy) statements to insert triple data, and using the driver call of GDMBASE (graph data management system), storing the triple data in the form of a graph structure in GDMBASE.

[0080] S104. Based on explicit triples and implicit relation triples, entity and relation types are normalized to obtain normalized triples, and a knowledge graph is constructed based on the normalized triples.

[0081] The normalization process in this embodiment aims to address the problem of "one relation, multiple textual expressions." Various verbs and phrases are normalized into a standard relation type. This embodiment does not limit the specific application domain of the knowledge graph. For example, the knowledge graph in this embodiment can be applied to the financial field; or it can be applied to the medical field; or it can be applied to the mathematical field. After obtaining the knowledge graph, this embodiment allows for retrieval based on it. This embodiment does not limit the specific process of retrieval based on the knowledge graph. For example, the retrieval process based on the knowledge graph in this embodiment may specifically include: User input: The user enters a natural language question in the search box, such as "Who is the founder of Company A?". Semantic similarity retrieval: The user's question is vectorized based on semantic similarity. The top k chunks similar to the user's input question are queried in the graph database based on semantic similarity. Query statement construction: Based on the top k chunks, the Cypher statement is used to query the association relationship between chunks and entities. Execute the query: The query engine (such as GDMBASE) executes the statement and retrieves the results from the graph; Assemble the results: Assemble chunks and information such as Entities and Relationships into a Context. Call the LLM to return the results: Submit the assembled results and specific prompts as a Prompt to the LLM, and encapsulate the results returned by the LLM ("XXX") into a user-friendly format (such as an answer box or card) and present it to the user.

[0082] It should be further explained that, based on any of the above embodiments, the above-mentioned normalization of entity and relation types based on explicit triples and implicit relation triples to obtain normalized triples, and the construction of a knowledge graph based on the normalized triples, may include:

[0083] S1041, retrieve all entity types and relation types in explicit triples and implicit relation triples;

[0084] S1042, input the entity type, relation type and the fourth preset prompt word into the fourth language model simultaneously, group similar entity types into the same group, group similar relation types into the same group, and determine the normalized type name corresponding to all entity types in each group, and the normalized relation type corresponding to all relation types in each group;

[0085] S1043, construct the normalized triples based on the normalized relation type and the normalized relation type.

[0086] This embodiment utilizes GDMBASE's driver calls to retrieve all entity and relation types from the GDMBASE library. The entity and relation types, along with a preset prompt, are simultaneously input into the Large Language Model (LLM). The LLM groups similar entity types based on their meaning or form, and selects a widely applicable type name from all entity types in that group as the type name for all entity types in that group. The same applies to relation types. The model's output is then post-processed, assembling the normalized entity and relation types into a JSON structure and outputting it as a list. This embodiment employs an automated scheme for entity and relation type standardization (normalization) using a Large Language Model (LLM), improving the accuracy of normalization.

[0087] The knowledge graph construction method provided in this embodiment of the invention may include: S101, dividing document content according to set rules to obtain initial document fragments, and merging and dividing all initial document fragments based on semantic similarity to obtain target partition blocks; S102, performing subject-verb-object formatting processing based on the target partition blocks using a first large language model to obtain subject-verb-object formatting results; S103, extracting entities and relations based on the subject-verb-object formatting results using a second large language model to obtain explicit triples, and performing implicit relation reasoning to obtain implicit relation triples; S104, normalizing entity and relation types based on explicit triples and implicit relation triples to obtain normalized triples, and constructing a knowledge graph based on the normalized triples. Compared to the current difficulty in effectively integrating information across paragraphs and documents, which leads to insufficient completeness and accuracy of knowledge graphs, this invention firstly achieves unified document loading while preserving the original text format and chapter structure, ensuring that subsequent extraction does not lose cross-paragraph and cross-page semantics. Secondly, it employs semantic similarity-driven block segmentation, avoiding sentence breaks caused by sliding windows and providing a "complete context" for subsequent large language model inference. Thirdly, based on "single-round subject-verb-object formatting prompts," it allows the large language model to output subject-verb-object formatting results in parallel within the same context, achieving synchronous extraction of entities and relations and reducing cascading errors. Furthermore, it utilizes the implicit reasoning capabilities of the large language model to logically complete existing triples and mine implicit relations, solving problems such as fragmentation and missing links. Subsequently, it performs semantic alignment of all entity / relation types through normalization prompts, eliminating synonyms and homonyms, and improving graph consistency and interpretability. Finally, it batches explicit and implicit triples into the graph database, completing the construction of a scalable and evolvable knowledge graph, thereby improving the completeness and accuracy of knowledge graph construction.

[0088] For ease of understanding, such as Figure 2 As shown, Figure 2This invention provides an optimized method for constructing knowledge graphs from unstructured documents based on a large language model. The specific steps are as follows:

[0089] Step 201: Combine different types of document loaders to uniformly record multi-source unstructured documents and preserve the article structure.

[0090] Different document loaders are used to load user-uploaded documents. For example, if the user-uploaded document is "Personal Information Introduction.md", then MarkDownDocumentLoader needs to be called to load the document, read the text content, and preserve its paragraph structure. Specifically, the content is as follows:

[0091] Zhang AB, 18 years old, worked at AAA Company in Beijing in 2017.

[0092] Xiao Zhang worked at BBB company in Beijing in 2018.

[0093] AB worked at CCC in Chengdu throughout 2019.

[0094] My name is Liu CD. I like running, and I'm 30 years old. Liu CD knows Zhang San. Zhang San knows Li Si.

[0095] Step 202: Use the cosine similarity method to perform semantic similarity-driven chunk iterative segmentation of the document, segmenting it into a list of chunk objects that match the semantic coherence labels.

[0096] Chunks are segmented based on semantic similarity.

[0097] Based on the text content obtained in step 201, assuming a similarity threshold of 0.7, it is initially divided into different coarse-grained chunks according to paragraph structure, namely:

[0098] Chunk 1: Zhang AB, 18 years old, worked at AAA company in Beijing in 2017.

[0099] Chunk 2: Xiao Zhang worked at BBB company in Beijing in 2018.

[0100] chunk3: AB has been working at CCC in Chengdu since 2019.

[0101] Chunk4: I'm Liu CD, I like running, and I'm 30 years old. Liu CD knows Zhang San. Zhang San knows Li Si.

[0102] First, take chunk1 as the first_chunk, vectorize it, and generate its vectorized value v1. Then, obtain chunk2, vectorize it, and generate its vectorized value v2. Calculate the cosine similarity between v1 and v2, which is 0.8. Since 0.8 is greater than or equal to the set similarity threshold of 0.7, chunk1 and chunk2 need to be merged into the first_chunk, and its vectorized value regenerated and assigned to v1. Then, obtain chunk3, vectorize it, and generate its vectorized value v2. Calculate the cosine similarity between v1 and v2. The similarity value is 0.78. Since 0.78 is greater than or equal to the set similarity threshold of 0.7, chunk1, chunk2, and chunk3 need to be merged into first_chunk and its vector value regenerated and assigned to v1. Then, chunk4 is obtained, vectorized, and its vectorized value v2 is generated. The cosine similarity value between v1 and v2 is calculated to be 0.36. Since 0.36 is less than the set similarity threshold of 0.7, chunk1, chunk2, and chunk3 are independent blocks, and chunk4 is an independent block.

[0103] Therefore, the final list of content segments based on semantic similarity is as follows:

[0104] "Zhang AB, 18 years old, worked at AAA company in Beijing in 2017. Xiao Zhang worked at BBB company in Beijing in 2018. AB has been working at CCC company in Chengdu since 2019."

[0105] "I am Liu CD, I like running, and I am 30 years old. Liu CD knows Zhang San. Zhang San knows Li Si."

[0106] Step 203: Using a large language model, perform SPO (Subject-Predicate-Object) formatting on the segmented chunk content.

[0107] Based on the list of chunks obtained from step 202 after semantic similarity segmentation, prompt words are constructed. Please refer to Table 1 for details; Table 1 is a schematic table of prompt words formatted using SPO provided in an embodiment of the present invention.

[0108] Table 1. A schematic table of prompts for SPO formatting.

[0109]

[0110] This prompt word can accurately rewrite the user-input chunk_text into SPO format. This prompt word allows the large language model to follow strict rewriting steps, ensuring that only information in the context is used and no irrelevant additions are made. It ensures that the final rewritten output is concise and clear, containing only the required SPO format without additional explanation information, and the output format is standardized, easy to understand and use.

[0111] For example: After rewriting, the final content is:

[0112] Zhang AB is 18 years old. Zhang AB started working in 2017. Zhang AB works for AAA Company. AAA Company is located in Beijing.

[0113] Xiao Zhang started working in 2018. Xiao Zhang worked for BBB Company. BBB Company is located in Beijing.

[0114] AB started working in 2019. AB worked at CCC Company, which is located in Chengdu.

[0115] Liu CD likes running. Liu CD is 30 years old. Liu CD knows Zhang San. Zhang San knows Li Si.

[0116] Step 204: Using a large language model, extract triples of entities and relationships from the SPO formatted content under specific prompts or constraints, and form a specific JSON data structure.

[0117] Based on the SPO format content obtained in step 203, a prompt is constructed. The specific prompts are shown in Table 2, which is a prompt for triple extraction provided by an embodiment of the present invention.

[0118] Table 2. Example of prompt words for triple extraction

[0119]

[0120] This prompt word can accurately extract entities and relations based on the user-input chunk_spo_text. This prompt word allows large language models to follow strict extraction steps, ensuring that only information in the context is used and no irrelevant interpretations are made. It ensures that the final extracted content output is concise and clear, containing only the required triplet format without additional explanation information, and the output format is standardized, easy to understand and use.

[0121] For example: After triplet extraction, the final content obtained is: [ { "subject": {"id":"Zhang AB","type":"employee"}, "predicate": {"type":"age"}, "object": {"id":"18","type":"number"} }, { "subject": {"id":"Zhang AB","type":"employee"}, "predicate": {"type":"working hours"}, "object": {"id":"2017","type":"time"} }, { "subject": {"id":"Zhang AB","type":"employee"}, "predicate": {"type":"Works at"}, "object": {"id":"AAA","type":"Company"} }, { "subject": {"id":"AAA","type":"company"}, "predicate": {"type":"located in"}, "object": {"id":"Beijing","type":"city"} }, { "subject": {"id":"Zhang AB","type":"employee"}, "predicate": {"type":"working hours"}, "object": {"id":"2018","type":"time"} }, { "subject": {"id":"Zhang AB","type":"employee"}, "predicate": {"type":"Works at"}, "object": {"id":"BBB","type":"company"} }, { "subject": {"id":"BBB","type":"company"}, "predicate": {"type": "Located in"}, "object": {"id": "Beijing", "type": "City"} }, { "subject": {"id": "Zhang AB", "type": "Employee"}, "predicate": {"type": "Working hours"}, "object": {"id": "2019", "type": "Time"} }, { "subject": {"id": "Zhang AB", "type": "Employee"}, "predicate": {"type": "Working at"}, "object": {"id": "CCC", "type": "Company"} }, { "subject": {"id": "CCC", "type": "Company"}, "predicate": {"type": "Located in"}, "object": {"id": "Chengdu", "type": "City"} }, { "subject": {"id": "Liu CD", "type": "Person"}, "predicate": {"type": "Like"}, "object": {"id": "Running", "type": "Sports event"} }, { "subject": {"id": "Liu CD", "type": "Person"}, "predicate": {"type": "Age"}, "object": {"id": "30", "type": "Number"} }, { "subject": {"id": "Liu CD", "type": "Person"}, "predicate": {"type": "Know"}, "object": {"id": "Zhang San", "type": "Person"} }, { "subject": {"id": "Zhang San", "type": "Person"}, "predicate": {"type": "Know"}, "object": {"id": "Li Si", "type": "Person"} }

[0123] Step 205: Use two - stage implicit relationship reasoning of logical rules + large - language model to construct implicit triples that are not shown in the stored graph but may hold semantically or logically, and form a specific JSON data structure.

[0124] After obtaining the triple information from step 204, construct a prompt. The specific prompt is Table 3, and Table 3 is a schematic table for extracting implicit relationships in an embodiment of the present invention.

[0125] Table 3 A Schematic Table for Extracting Implicit Relationships

[0126]

[0127] This prompt first gives the large - language model a relatively high role positioning, enabling the large - language model to exert its maximum ability in the corresponding role identity. By allowing the large - language model to judge and compare in turn from different implicit relationship classifications to infer implicit relationships, and restricting the large - language model to only output the inferred implicit relationship triples for convenient subsequent use.

[0128] For example: The result obtained after performing implicit relationship reasoning on the triples extracted in step 204 through step 205 is: { "subject": {"id": "Liu CD", "type": "Person"}, "predicate": {"type": "Know"}, "object": {"id": "Li Si", "type": "Person"} }

[0130] Step 206: Use GDMBASE driver call to store the extracted triple information in the form of a graph structure in GDMBASE.​​​

[0131] Based on the triplet information obtained in steps 205 and 206, the GDMBASE driver is invoked to batch insert the data into the GDMBASE graph database.

[0132] For example, the statement to insert the triples extracted in steps 205 and 206 into the GDMBASE graph database via step 106 is:

[0133] UNWIND $data AS row; MATCH (d: Chunk {ID: row.chunkId}); MERGE (e:Entity {id: row.entityId}); e += row.props; MERGE (d)-[:HAS_ENTITY]->(e).

[0134] Step 207: Using a large language model, perform type normalization on all entity types and relation types in the graph to achieve semantic alignment of all entity / relation types and eliminate synonyms and homonyms.

[0135] Based on all the entity and relation types stored in GDMBASE in step 206, the system retrieves them and constructs a prompt. The specific prompts are shown in Table 4, which is a prompt table for normalizing entity and relation types provided by an embodiment of the present invention.

[0136] Table 4. A sample of prompt words for normalizing entity and relation types.

[0137]

[0138] This prompt first gives the large language model a high role positioning, allowing it to exert its maximum capabilities under the corresponding role. It enables the large language model to find entities and relation types that can be normalized from different entity or relation types, and restricts the large language model to output results in a specific format for easy use later.

[0139] For example, the result obtained after entity relation normalization in step 207 is:

[0140] { "nodes": { "person": ["person", "employee"], "Company": ["Company"], "Number": ["Number"], "City": ["City"], "Time": ["Time"], "Sports": ["Sports"], }, "relationships": { "Age": ["Age"], "Working Hours": ["Working Hours"], "Working at": ["Working at"], "Knowledge": ["Knowledge"], "Like": ["Like"], "located in": ["located in"], } }

[0141] In summary, this invention provides an optimized method for constructing knowledge graphs from unstructured documents based on a large language model, aiming to achieve end-to-end automated construction of high-quality knowledge graphs from unstructured documents. The algorithm is constructed through the following steps: First, multiple document loaders are used to uniformly load unstructured documents from multiple sources, fully preserving the original text structure and layout features. Then, cosine similarity is used to perform semantic similarity-driven chunk iterative segmentation of the documents, dividing the text into a list of chunk objects that conform to semantic coherence labels. Next, the large language model is used to format the segmented chunk content using SPO (Semantic Proof-of-Stake). Then, with the help of the large language model and specific prompts or constraints, entity and relation triples are extracted from the SPO-formatted content to form a specific JSON data structure. Furthermore, using two-stage reasoning based on logical rules and the large language model, new triples that are not yet explicitly stored in the graph but are semantically or logically possible to be true are constructed, and a specific JSON data structure is output. Finally, through GDMBASE-driven calls, the extracted triple information is stored in GDMBASE in the form of a graph structure. Finally, a large language model is used to normalize all entity and relation types in the graph, achieving semantic alignment of all entity / relation types and eliminating synonyms and homonyms. In summary, this invention, by combining advanced large language model technology, overcomes the "manual and inefficient" construction methods of traditional solutions, providing users with an efficient, accurate, and interpretable method for constructing knowledge graphs. For easier understanding, please refer to... Figure 3 , Figure 3 This invention provides an optimized method for constructing knowledge graphs from unstructured documents based on a large language model, illustrated in the following diagram. The framework is similar to the one described above. Figure 2The methods shown correspond to those described.

[0142] Compared with existing technologies, the beneficial effects of this invention are as follows: This invention completely eliminates the need for traditional manual rules and tedious annotation through a "zero-annotation, full-link" large language model-driven solution, and realizes end-to-end automated construction of unstructured documents into high-quality knowledge graphs. First, a multi-source document loader is used to load documents uniformly while preserving the original format and chapter structure, ensuring that cross-segment and cross-page semantics are not lost during subsequent extraction. Second, semantic similarity-driven intelligent chunking avoids sentence fragmentation caused by brute-force sliding windows and significantly reduces redundancy, providing a "complete context" for subsequent large language model inference. Third, based on "single-round SPO formatting hints," the large language model outputs Subject-Predicate-Object structures in parallel within the same context, achieving synchronous extraction of entities and relations and reducing cascading errors. Furthermore, the implicit reasoning capabilities of the large language model are utilized to logically complete existing triples and mine implicit relations, solving problems such as fragmentation and missing links. Subsequently, normalization hints are used to semantically align all entity / relation types, eliminating synonyms and homonyms, and improving graph consistency and interpretability. Finally, explicit and implicit relation triples are written into the graph database in batches, completing the construction of a scalable and evolvable knowledge graph.

[0143] The knowledge graph construction apparatus provided in the embodiments of the present invention will be described below. The knowledge graph construction apparatus described below can be referred to in correspondence with the knowledge graph construction method described above.

[0144] Please refer to the details. Figure 4 , Figure 4 A schematic diagram of a knowledge graph construction device provided in an embodiment of the present invention may include:

[0145] The target segmentation block determination module 100 is used to segment the document content according to the set rules to obtain initial document fragments, and to merge and segment all the initial document fragments based on semantic similarity to obtain the target segmentation block;

[0146] The subject-verb-object formatting result determination module 200 is used to perform subject-verb-object formatting processing based on the target partition block using the first large language model to obtain the subject-verb-object formatting result.

[0147] The implicit relation triple determination module 300 is used to extract entities and relations based on the subject-verb-object formatting result using the second language model to obtain explicit triples, and to perform implicit relation reasoning to obtain implicit relation triples.

[0148] The knowledge graph construction module 400 is used to normalize the entity and relation types based on the explicit triples and the implicit relation triples to obtain normalized triples, and to construct a knowledge graph based on the normalized triples.

[0149] Furthermore, based on any of the above embodiments, the target partition block determination module 100 may include:

[0150] The initial document fragment determination unit is used to divide the document content into multiple initial document fragments by dividing it into sentences or paragraphs in sequence.

[0151] The vector determination unit is used to determine the first vector corresponding to the first initial document fragment;

[0152] The cosine similarity determination unit is used to determine the second vector corresponding to the second initial document fragment and calculate the cosine similarity between the first vector and the second vector.

[0153] The merging unit is configured to merge the second initial document fragment into the first initial document fragment and update the first vector to the vector of the merged document fragment if the cosine similarity is greater than or equal to a set cosine similarity threshold.

[0154] The final target segmentation block determination unit is used to repeat the above process until the cosine similarity between the merged document segment and the current initial document segment is less than the cosine similarity threshold. When the current initial document segment is isolated as a new first initial document segment and the iteration continues, the merging path, character offset, hierarchical title and chart index are recorded, and the target block with semantic coherence label is output.

[0155] Furthermore, based on any of the above embodiments, the target partition block determination module 100 may include:

[0156] The method for determining partitioning units based on hierarchical headings and chart indexes is used to determine whether the current hierarchical heading or the chart index is a separate target partitioning unit when the initial document fragment is the hierarchical heading and the chart index.

[0157] Furthermore, based on any of the above embodiments, the subject-verb-object formatting result determination module 200 may include:

[0158] The first preset prompt word determination unit is used to determine the first preset prompt word based on the first constraint rules; wherein, the first constraint rules include semantic consistency, terminology standardization, reference resolution, subject-object atomization, and subject-verb-object format integrity; the reference resolution is a constraint rule that converts pronouns into concrete entities; the subject-object atomization is a rule that splits the subject and object into indivisible single entities;

[0159] The subject-verb-object formatting result determination unit is used to input the target segmentation block and the first preset prompt word into the first large language model to obtain the subject-verb-object formatting result.

[0160] Furthermore, based on any of the above embodiments, the implicit relation triple determination module 300 may include:

[0161] The second preset prompt word determination unit is used to determine the second preset prompt word based on the second constraint rules; wherein, the second constraint rules include subject-verb-object extraction completeness, entity expression consistency, subject-object atomization, reference resolution, term pairing relationship, predicate number limit, term standardization and association relationship completeness;

[0162] The display triplet determination unit is used to input the subject-verb-object formatting result and the second preset prompt word into the second large language model to obtain the display triplet.

[0163] Furthermore, based on any of the above embodiments, the implicit relation triple determination module 300 may include:

[0164] The first implicit relation determination unit is used to input the displayed triplet, the subject-verb-object formatting result and the third preset prompt word into the third language model to obtain the first implicit relation;

[0165] The second implicit relation determination unit is used to obtain the second implicit relation using transitive logic rules, and to determine the implicit relation triple based on the first implicit relation and the second implicit relation.

[0166] Furthermore, based on any of the above embodiments, the knowledge graph construction module 400 may include:

[0167] The entity type and relation type acquisition unit is used to acquire all entity types and relation types in the explicit triplet and the implicit relation triplet;

[0168] The normalization type determination unit is used to simultaneously input the entity type, the relation type and the fourth preset prompt word into the fourth language model, group similar entity types into the same group, group similar relation types into the same group, and determine the normalization type name corresponding to all entity types in each group, and the normalization relation type corresponding to all relation types in each group.

[0169] A normalized triplet determination unit is used to construct the normalized triplet based on the normalized relation type and the normalized relation type.

[0170] It should be noted that the order of the modules and units in the above knowledge graph construction device can be changed without affecting the logic.

[0171] The knowledge graph construction device provided in this invention avoids sentence fragmentation by using semantic similarity-driven block segmentation, reduces cascading errors by subject-verb-object formatting, and solves problems such as fragmentation and missing links by using implicit relationships, thereby improving the completeness and accuracy of knowledge graph construction.

[0172] The following describes a knowledge graph construction device provided by an embodiment of the present invention. The knowledge graph construction device described below can be referred to in correspondence with the knowledge graph construction method described above.

[0173] Please refer to Figure 5 , Figure 5 A schematic diagram of a knowledge graph construction device provided in an embodiment of the present invention may include:

[0174] Memory 10 is used to store computer programs;

[0175] Processor 20 is used to execute computer programs to implement the knowledge graph construction method described above.

[0176] The memory 10, processor 20, and communication interface 30 all communicate with each other through the communication bus 40.

[0177] In this embodiment of the invention, the memory 10 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment of the invention, the memory 10 may store programs for implementing the following functions:

[0178] The document content is divided according to the set rules to obtain initial document fragments, and all initial document fragments are merged and divided based on semantic similarity to obtain the target segmentation block;

[0179] Based on the target block partitioning, the first language model is used to perform subject-verb-object formatting to obtain the subject-verb-object formatting result;

[0180] Based on the subject-verb-object formatting results, the second largest language model is used to extract entities and relations to obtain explicit triples, and implicit relation reasoning is performed to obtain implicit relation triples.

[0181] Based on the explicit triples and the implicit relation triples, entity and relation types are normalized to obtain normalized triples, and a knowledge graph is constructed based on the normalized triples.

[0182] In one possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.

[0183] Furthermore, memory 10 may include read-only memory and random access memory, providing instructions and data to the processor. A portion of the memory may also include NVRAM. The memory stores operating systems and operating instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and handling hardware-based tasks.

[0184] Processor 20 can be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic device. Processor 20 can be a microprocessor or any conventional processor. Processor 20 can call programs stored in memory 10.

[0185] The communication interface 30 can be an interface for the communication module, used to connect with other devices or systems.

[0186] Of course, it should be noted that, Figure 5 The structure shown does not constitute a limitation on the knowledge graph construction device in the embodiments of the present invention. In practical applications, the knowledge graph construction device may include more than Figure 5 More or fewer components as shown, or combinations of certain components.

[0187] The following describes the computer-readable storage medium provided in the embodiments of the present invention. The computer-readable storage medium described below can be referred to in correspondence with the knowledge graph construction method described above.

[0188] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the knowledge graph construction method described above.

[0189] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0190] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

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

[0192] Finally, it should be noted that in this document, relationships such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0193] The foregoing has provided a detailed description of a knowledge graph construction method, apparatus, device, and readable storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for constructing a knowledge graph, characterized in that, include: The document content is divided according to the set rules to obtain initial document fragments, and all initial document fragments are merged and divided based on semantic similarity to obtain the target segmentation block; Based on the target partition block, subject-verb-object formatting is performed using the first language model to obtain the subject-verb-object formatting result. Based on the subject-verb-object formatting results, entity and relation extraction is performed using the second language model to obtain explicit triples, and implicit relation reasoning is performed to obtain implicit relation triples. Based on the explicit triples and the implicit relation triples, entity and relation types are normalized to obtain normalized triples, and a knowledge graph is constructed based on the normalized triples.

2. The knowledge graph construction method according to claim 1, characterized in that, The document content is divided according to predefined rules to obtain initial document fragments. These initial fragments are then merged and divided based on semantic similarity to obtain the target segment, which includes: The document content is divided sequentially into sentences or paragraphs to obtain multiple initial document fragments; Determine the first vector corresponding to the first initial document fragment; Determine the second vector corresponding to the second initial document fragment; Calculate the cosine similarity between the first vector and the second vector; If the cosine similarity is greater than or equal to the set cosine similarity threshold, then the second initial document fragment is merged into the first initial document fragment, and the first vector is updated to be the vector of the merged document fragment; Repeat the above process until the cosine similarity between the merged document fragment and the current initial document fragment is less than the cosine similarity threshold. Then, treat the current initial document fragment as a new first initial document fragment and continue iterating. At the same time, record the merging path, character offset, hierarchical title and chart index, and output the target block with semantic coherence label.

3. The knowledge graph construction method according to claim 2, characterized in that, The document content is divided according to predefined rules to obtain initial document fragments. These initial fragments are then merged and divided based on semantic similarity to obtain the target segment, which includes: When the initial document fragment is the level heading and the chart index, it is determined that the current level heading or the chart index will be treated as a separate target partition block.

4. The knowledge graph construction method according to claim 1, characterized in that, Based on the target segmentation block, subject-verb-object formatting is performed using the first large language model to obtain the subject-verb-object formatting result, including: The first preset prompt word is determined based on the first constraint rule; wherein, the first constraint rule includes semantic consistency, terminology standardization, reference resolution, subject-object atomization, and subject-verb-object format integrity; the reference resolution is a constraint rule that converts pronouns into concrete entities; the subject-object atomization is a rule that splits the subject and object into indivisible single entities; The target segmentation block and the first preset prompt word are input into the first large language model to obtain the subject-verb-object formatting result.

5. The knowledge graph construction method according to any one of claims 1 to 4, characterized in that, Based on the subject-verb-object formatting results, entity and relation extraction is performed using the second largest language model to obtain display triples, including: The second preset prompt word is determined based on the second constraint rule; wherein, the second constraint rule includes subject-verb-object extraction completeness, entity expression consistency, subject-object atomization, reference resolution, term pairing relationship, predicate number limit, term standardization and association relationship completeness; The subject-verb-object formatting result and the second preset prompt word are input into the second large language model to obtain the display triplet.

6. The knowledge graph construction method according to claim 1, characterized in that, Based on the subject-verb-object formatting results, entity and relation extraction is performed using the second largest language model to obtain explicit triples, and implicit relation reasoning is performed to obtain implicit relation triples, including: The display triplet, the subject-verb-object formatting result, and the third preset prompt word are input into the third language model to obtain the first implicit relation; The second implicit relation is obtained using transitive logic rules, and the implicit relation triples are determined based on the first and second implicit relations.

7. The knowledge graph construction method according to claim 1, characterized in that, Based on the explicit triples and the implicit relation triples, entity and relation types are normalized to obtain normalized triples. A knowledge graph is then constructed based on these normalized triples, including: Obtain all entity types and relation types in the explicit triplet and the implicit relation triplet; The entity type, the relation type, and the fourth preset prompt word are simultaneously input into the fourth language model. Similar entity types are grouped into the same group, and similar relation types are grouped into the same group. The normalized type name corresponding to all entity types in each group and the normalized relation type corresponding to all relation types in each group are determined. The normalized triples are constructed based on the normalized relation type and the normalized relation type.

8. A method for constructing a knowledge graph, characterized in that, include: The target segmentation block determination module is used to divide the document content according to the set rules to obtain initial document fragments, and then merge and divide all the initial document fragments based on semantic similarity to obtain the target segmentation block; The subject-verb-object formatting result determination module is used to perform subject-verb-object formatting processing based on the target partition block using the first large language model to obtain the subject-verb-object formatting result. The implicit relation triple determination module is used to extract entities and relations based on the subject-verb-object formatting results using the second largest language model to obtain explicit triples, and to perform implicit relation reasoning to obtain implicit relation triples. The knowledge graph construction module is used to normalize the entity and relation types based on the explicit triples and the implicit relation triples to obtain normalized triples, and to construct a knowledge graph based on the normalized triples.

9. A knowledge graph construction device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the knowledge graph construction method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the knowledge graph construction method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Knowledge graph completion method and device and medium

    CN120123435A

  • Knowledge graph construction method and device, electronic equipment and medium

    CN120317350A

  • Building safety risk identification method of large language model-assisted knowledge graph

    CN120542919A

Cited By

  • Knowledge graph construction method and system

    CN122154885A

  • Knowledge graph construction method and system

    CN122154885B