Complex knowledge question answering method based on knowledge graph and retrieval enhancement generation

CN122529094APending Publication Date: 2026-08-07ZHEJIANG UNIV CITY COLLEGE
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG UNIV CITY COLLEGE
Filing Date
2026-05-22
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

S2、基于模式引导的查询解析与多阶段检索增强生成:针对用户输入的复杂自然语言查询,利用所述异构知识图谱,通过问题分解和多阶段检索策略,逐步定位证据并生成最终答案

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122529094A_ABST
    Figure CN122529094A_ABST
Patent Text Reader

Abstract

The application relates to a complex knowledge question answering method based on knowledge graph and retrieval enhancement generation, and comprises the following steps: automatically constructing a heterogeneous knowledge graph containing structured knowledge and unstructured semantics according to a set of unstructured text documents provided by a user; and utilizing the heterogeneous knowledge graph to gradually locate evidence and generate a final answer through problem decomposition and a multi-stage retrieval strategy for a complex natural language query input by the user.The application has the beneficial effect that: through an automatic construction process, the application constructs a heterogeneous knowledge graph with structured reasoning ability and rich semantic context from unstructured documents without a large amount of manual annotation, thereby solving the problems of a high-quality and high-adaptability knowledge graph being scarce, and a high construction cost and poor adaptability of the knowledge graph.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of knowledge question answering based on large language models, and more specifically, to a complex knowledge question answering method based on knowledge graphs and retrieval enhancement. Background Technology

[0002] In recent years, Large Language Models (LLMs) have demonstrated powerful capabilities in the knowledge question answering field. However, their inherent "illusion" problem—generating content that does not conform to reality—severely limits their reliability in downstream tasks. Retrieval-enhanced generation (RAG) techniques effectively alleviate the illusion problem by retrieving relevant information from external knowledge bases to assist in generation. However, traditional RAG methods are mainly based on semantic similarity retrieval, making it difficult to handle complex problems requiring multi-step reasoning. They also neglect important structured relationships between texts, often leading to fragmented retrieval results and the introduction of redundant information.

[0003] One improvement is Graph Retrieval Augmentation (GraphRAG), which enhances answer accuracy by combining the structured information of knowledge graphs (KG) with the reasoning capabilities of LLMs. However, existing technologies still face significant challenges in practical applications: 1. High-quality knowledge graph construction is costly and lacks adaptability. Traditional knowledge graph construction relies on expensive and time-consuming manual annotation (such as defining ontology schemas, annotating entities and relations), making it difficult to adapt to dynamically evolving private documents and emerging domain knowledge. While LLM-based information extraction improves automation and reduces costs, it faces a trade-off between schema constraints and open adaptability: schema-constrained extraction can standardize triple quality, but predefined static schemas are difficult to cover emerging entities and relations in dynamic documents; open extraction without schema constraints, while flexible, easily generates a large number of redundant entities and noisy relations, seriously affecting the quality of the knowledge graph. In addition, the context window limitation of LLM further exacerbates the above problems when processing long documents in chunks: LLM lacks a global perspective in local text, easily identifying the same objective entity as multiple nodes with different literal forms, causing entity splitting, destroying graph connectivity, resulting in a sparse graph structure, and thus hindering multi-hop reasoning in downstream tasks. A single structured or unstructured graph also cannot simultaneously meet the dual requirements of accurate reasoning and rich contextual references.

[0004] 2. Inefficient reasoning and insufficient accuracy in answering complex questions. When retrieving information from knowledge graphs to answer complex multi-hop questions, the number of candidate subgraphs explodes exponentially as the graph size increases, leading to a sharp decline in retrieval efficiency and easy introduction of noise. Furthermore, accurately measuring the semantic similarity between natural language queries and structured graph elements (such as nodes and triples) remains a pressing problem.

[0005] Therefore, there is an urgent need for a knowledge question answering method that can automatically construct high-quality knowledge graphs and perform efficient and accurate reasoning on complex questions. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide a complex knowledge question answering method based on knowledge graphs and retrieval enhancement.

[0007] Firstly, it provides a complex knowledge question answering method based on knowledge graphs and retrieval enhancement, including: S1. Automated construction of heterogeneous knowledge graphs: Based on the user-provided collection of unstructured text documents, automatically construct heterogeneous knowledge graphs containing both structured knowledge and unstructured semantics. S2. Pattern-guided query parsing and multi-stage retrieval enhancement generation: For complex natural language queries input by users, the heterogeneous knowledge graph is used to gradually locate evidence and generate the final answer through question decomposition and multi-stage retrieval strategies.

[0008] Preferably, S1 includes: S101. Perform data preprocessing on the original document and extract plain text content; S102. Semantic-aware intelligent segmentation: Using a large language model to identify the semantic boundaries of a document, the document is segmented into semantically coherent text blocks, and a vector representation is generated for each text block. S103. Knowledge extraction based on dynamic pattern expansion: A strategy combining seed ontology and automatic evolution is adopted. An initial ontology pattern is predefined, and entities, relations and attributes are extracted from each text block using a large language model. At the same time, new pattern elements that meet the confidence requirements are identified and dynamically incorporated. S104, Layered Knowledge Fusion: Maintain a global entity set, and for each text block, extract local entities and perform entity alignment through a multi-layered process of string matching, type consistency and semantic disambiguation. Also, perform attribute and relationship migration fusion for duplicate entities. S105. Hybrid Index Construction: Based on the fused knowledge, a heterogeneous knowledge graph is constructed. The graph includes entity nodes, attribute nodes, and text block nodes, and a graph structure index and a multi-granularity vector index are established.

[0009] As a preferred method, the text block vector in S102 is generated by splitting the text block into sentences and then performing a weighted average of the vectors of each sentence, with the weights being positively correlated with the sentence length.

[0010] Preferably, the process of dynamically incorporating new pattern elements in S103 includes: defining the iterative expansion of the ontology pattern as a merging of the current pattern and the pattern to be expanded; the pattern to be expanded is output by the large language model after confidence evaluation based on the current text block, the current pattern and the confidence threshold.

[0011] Preferably, the multi-layer process in S104 includes: First layer, exact matching: Determines whether there is an entity in the global entity set whose name is exactly the same as that of the local entity; The second layer, homonym detection: For entity pairs with the same name but different types, they are marked as potential homonyms and then entered into semantic disambiguation; The third layer, fuzzy semantic disambiguation: candidate entities are selected based on vector similarity, and a large language model is called to make a final matching judgment between local entities and candidate entities.

[0012] Preferably, S2 includes: S201, Query parsing with pattern constraints: Using ontology patterns from knowledge graphs to guide the large language model to decompose complex queries into an ordered sequence of atomic sub-problems and identify the dependencies between sub-problems; S202. Subproblem rewriting: According to the order of the subproblem sequence, for subproblems with dependencies, semantic supplementation is performed by combining the answers of the preceding subproblems to form independent and searchable query statements; S203, Graph Data Retrieval and Answer Generation: For the rewritten sub-question, relevant triples are recalled based on vector similarity. The nodes in the triples are used as seeds to expand and form candidate subgraphs. After filtering by a large language model, evidence subgraphs are obtained, and the answer to the current sub-question is generated based on the evidence subgraph. S204. Text fallback retrieval and answer generation: If the evidence subgraph is insufficient to answer the question, the text block is recalled as supplementary context to generate the answer based on a comprehensive index combining semantic similarity and evidence coverage; after all sub-questions are completed, the answer to the last sub-question is taken as the final answer.

[0013] As a preferred option, the graph data retrieval in S203 specifically includes: calculating the similarity between the subquestion vector and all entity-relation-entity triple vectors in the knowledge graph, recalling the triples with the highest similarity; using the nodes in these triples as seeds to expand one hop to obtain candidate subgraphs; using a large language model to filter the triples in the candidate subgraphs based on relevance; if all triples are filtered, then directly using the text block most similar to the subquestion to generate the answer.

[0014] Secondly, a complex knowledge question-answering system based on knowledge graphs and retrieval enhancement is provided for performing any of the methods described in the first aspect, including: The building module is used to automatically construct a heterogeneous knowledge graph containing both structured knowledge and unstructured semantics based on a set of unstructured text documents provided by the user. The generation module is used to address complex natural language queries input by users, and utilizes the heterogeneous knowledge graph to gradually locate evidence and generate the final answer through question decomposition and multi-stage retrieval strategies.

[0015] Thirdly, a computer storage medium is provided, wherein a computer program is stored therein; when the computer program is run on a computer, the computer causes the computer to perform any of the methods described in the first aspect.

[0016] Fourthly, an electronic device is provided, comprising: Memory, used to store computer programs; A processor for executing the computer program to implement the method as described in any of the first aspects.

[0017] The beneficial effects of this invention are as follows: Through an automated construction process, this invention constructs a heterogeneous knowledge graph from unstructured documents, possessing both structured reasoning capabilities and rich semantic context, without requiring extensive manual annotation. This addresses the scarcity of high-quality, highly adaptable knowledge graphs, as well as the high cost and poor adaptability of knowledge graph construction. Furthermore, based on pattern-constrained question decomposition and a multi-stage retrieval strategy, it effectively solves the problems of candidate subgraph explosion and inaccurate semantic matching in complex multi-hop reasoning. These two steps work synergistically to achieve bidirectional enhancement of LLM and KG, improving the accuracy and robustness of large language models in complex question answering on private knowledge bases. Attached Figure Description

[0018] Figure 1 This is a flowchart illustrating the overall process of the complex knowledge question-answering method based on knowledge graphs and retrieval enhancement in this invention. Figure 2 This is a detailed flowchart of the automated construction of heterogeneous knowledge graphs in this invention; Figure 3 This is a detailed flowchart of the pattern-guided query parsing and multi-stage retrieval enhancement generated in this invention. Detailed Implementation

[0019] The present invention will be further described below with reference to embodiments. The description of the embodiments below is only for the purpose of helping to understand the present invention. It should be noted that those skilled in the art can make several modifications to the present invention without departing from the principle of the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.

[0020] Example 1: To address the problems of existing technologies, Embodiment 1 of this application provides a complex knowledge question answering method based on knowledge graphs and retrieval enhancement. This method automatically constructs a high-quality heterogeneous knowledge graph from the user's document knowledge base and uses this graph to analyze complex questions and perform multi-stage retrieval enhancement generation, thereby improving the accuracy of question answering for complex multi-hop questions.

[0021] Specifically, such as Figure 1 As shown, the method provided in this application includes: S1. Automated construction of heterogeneous knowledge graphs: Based on a set of unstructured text documents provided by the user, automatically construct a heterogeneous knowledge graph containing both structured knowledge and unstructured semantics.

[0022] like Figure 2 As shown, S1 includes: S101. Perform data preprocessing on the original document and extract plain text content.

[0023] In S101, preprocessing includes removing non-textual noise such as formatting marks, headers and footers, and special symbols to provide clean text input for subsequent semantic segmentation.

[0024] S102. Semantic-aware intelligent segmentation: Using a large language model to identify the semantic boundaries of a document, the document is segmented into semantically coherent text blocks, and a vector representation is generated for each text block.

[0025] Specifically, S102 includes: S1021. The text content extracted in S101 is concatenated into the prompt words and input into the large model, which then outputs the segmentation results. For each document, the number of characters in the text content is counted. Documents with fewer than 800 characters are not segmented. For long documents, a preliminary segmentation is performed using a sliding window size of 5000 characters to avoid poor segmentation results due to excessively long context. Except for the first sliding window, the starting point of subsequent sliding windows is the starting point of the last text block of the previous sliding window. This is done to avoid the fixed window size compromising the integrity of the last text block. The semantic segmentation prompt words for the large model are designed as follows: You are a seasoned text structure analysis expert, skilled at identifying logical breakpoints in long documents.

[0026] instruction: 1. Please understand the text content in the "Input" field, identify the structure and components of the text, and determine the segmentation points according to the semantic theme to divide it into several non-overlapping sections.

[0027] 2. If the article has identifiable structural information such as chapters, please segment it directly according to the top-level structure.

[0028] 3. Please return the fields defined in the "pattern", including the section summary and the section start point.

[0029] 4. Answers must be in JSON string format. Please refer to the examples provided in the "Examples" field for specific formats.

[0030] 5. Each text block should be kept to around 800 words. Prioritize the consistency of the theme and semantics within each text block before controlling the word count.

[0031] model: {"Section Title":"A brief summary of the text in this section","Section Start Point":"The starting point of the original text contained in this section, approximately 20 characters. This dividing point will be used to separate the original text, so it must be found in the original text!"} S1022. After obtaining the segmentation results, each text block is first split into sentences, and then the sentences are embedded into vectors using an embedding model. The weighted average of all sentence vectors is the vector of that text block. The weight is the proportion of the sentence length to the total length of the text block. The formula for calculating the text block vector is: in, This is a vector representation of a text block. Let be the embedding vector of the i-th sentence. For the first The length of each sentence The total number of sentences is given; text blocks and their vectors are stored in a vector database, and metadata such as document ID, block ID, and title are appended to complete the construction of the vector index of the text blocks.

[0032] S103. Knowledge extraction based on dynamic pattern expansion: A strategy combining seed ontology and automatic evolution is adopted. An initial ontology pattern is predefined, and entities, relations and attributes are extracted from each text block using a large language model. At the same time, new pattern elements that meet the confidence requirements are identified and dynamically incorporated to realize the dynamic expansion of the ontology pattern.

[0033] S103 includes: S1031. Knowledge graph extraction is viewed as a task of constraint generation based on high-quality ontology schemas using LLM, and the ontology schema is defined as follows: in, Indicates the type of the target entity. This indicates a simplified relation type. This represents the type of attribute that can be attached and used to describe any corresponding entity; by introducing ontology schema constraints, the search space for open information extraction is limited to... Within the Cartesian product, the generation of irrelevant triples is effectively reduced; S1032, The extended formula of the ontology pattern in the (t+1)th iteration is defined as follows: in, Indicates the first Ontology pattern during round iteration This is an ontology pattern to be expanded, containing new entity types. New Relationship Types and new attribute types ; S1033, Ontology Mode to be Expanded The mining and knowledge graph information extraction processes based on ontology patterns are carried out simultaneously. This invention introduces a dynamic filtering mechanism based on LLM confidence scoring. Only when the confidence score of a new pattern exceeds a preset threshold will the new pattern be integrated into the ontology pattern to be expanded. In this process, the confidence level comprehensively considers frequency of occurrence, contextual consistency, and differences from existing ontology patterns. The mining formula for the ontology pattern to be expanded is defined as follows: in, This is a new pattern confidence evaluation function, whose input is the currently processed text block. and the original mode and confidence threshold Output the ontology patterns to be expanded that have a confidence level higher than a set threshold after evaluation by a large model. This dynamic adaptation mechanism enables the schema to evolve continuously beyond the limitations of its initial definition, achieving an effective balance between strictly adhering to schema guidelines and flexibly acquiring knowledge. Schema-constrained extraction standardizes the quality of triples, while the dynamic evolution mechanism overcomes the limitations of static schemas in covering emerging entities and relationships in dynamic documents, avoiding redundant entities and noisy relationships generated by open extraction without schema constraints.

[0034] S1034. The initial seed ontology pattern design is shown in Table 1: Table 1 Entity type People, places, organizations, events, objects, concepts, time periods, creative works, biological entities, natural phenomena Relationship type It is part of, located within, created by, used by, involved in, related to, belongs to, influences, precedes, arrives at, and is equivalent to. Attribute type Name, Date, Size, Type, Description, Status, Quantity, Value, Location, Duration, Time S104, Layered Knowledge Fusion: Maintain a global entity set, and for each text block, extract local entities and perform entity alignment through a multi-layered process of string matching, type consistency and semantic disambiguation. Also, perform attribute and relation migration fusion for duplicate entities.

[0035] In S104, a global entity set is maintained. For each new text block, a local entity set is extracted. The system performs entity alignment through a three-layer process: exact string matching, homonym detection, and fuzzy semantic disambiguation. For entities that are determined to be duplicates, the system calls LLM to select the standard name as the main entity and performs attribute and relation migration and fusion.

[0036] Specifically, S104 includes: S1041. The first layer performs exact string matching, filters out entities with exactly the same name, and searches for entities with exactly the same name in GES. If no entity exists, the local entity is marked as a potential new entity and enters the third layer for processing. If an entity exists, the second layer is entered to detect homonyms to prevent the incorrect merging of entities with the same name but different meanings. S1042. In the second-layer synonym detection, for pairs of entities with the same name... The system determines whether their types are consistent: like This indicates that the two are highly likely to refer to the same entity, and LLM judgment is not required when entering the knowledge fusion stage; if This indicates a risk of having the same name but different meanings; in this case, the entity should be... Passed to the third-layer fuzzy semantic disambiguation layer; S1043, In the third-layer fuzzy semantic disambiguation, local entities that have undergone processing in the first two layers... First, the entity names are mapped to vectors using an embedding model, and then the local entity is calculated. Cosine similarity with all entities in GES: Select the sample with the highest similarity score, which is not 1 and is greater than the set threshold. The top-k candidate entities; then, the local entities The top-k candidate entities, along with the entities with the same name passed from the second-layer synonym detection, are input into the LLM for final decision-making to determine the local entity. Does it refer to the same objective object as one in the global entity? If LLM determines it's a duplicate, proceed to the entity fusion stage; if LLM determines it's not a duplicate, then... Officially joined GES as a new node; S1044. For entities determined to be duplicates, perform an entity fusion operation. This invention designs an entity duplication judgment and retention information selector based on LLM. Given an entity pair... The system does not pre-define a reserved party, but instead prompts the LLM to determine, based on the context semantics, which name and type are more suitable as the standard identifier for the objective object, and selects the function formally defined as: in, Select a function for entity duplication detection and information retention; if an entity is duplicated, return the corresponding entity. This will include retained information (entity name, type); if no duplicates exist, it will return empty content. Next, the retained entity name will be used as the global entity. Using the names as an example, describe the fusion process of two types of triplet information.

[0037] Unlike key-value pairs that treat attributes as appendages of entities, this invention models attributes as independent nodes in a graph. Therefore, the merging operation involves not only merging the entity nodes themselves but also properly handling the two types of association information within the graph structure. For entity-attribute triples, all attribute node connections of the local entity are migrated and pointed to the global entity, and duplicate attribute nodes are deleted only when the attribute key and attribute value are exactly the same. For entity-entity relation triples, all edges associated with the local entity are traversed, and for each triple... or Modify it to or Delete isolated local entities Finally, Information updated to global entity middle.

[0038] S105. Hybrid Index Construction: Based on the fused knowledge, a heterogeneous knowledge graph is constructed. The graph includes entity nodes, attribute nodes, and text block nodes, and a graph structure index and a multi-granularity vector index are established.

[0039] S105 includes: S1051. The logical structure of the constructed heterogeneous knowledge graph is defined as a set of triples: Among them, the node set It includes three heterogeneous node types: entity nodes, which represent core concepts, objects or events extracted from the text; attribute nodes, which independently model attributes as nodes to preserve their complete semantic information; and text block nodes, which represent fragments of the original document after semantic segmentation, serving as a bridge connecting structured knowledge and unstructured original text. This represents a relationship edge connecting entity nodes. Represents the relationship edge connecting entity nodes and attribute nodes; S1052. At the graph structure level, construct two types of edges: entity-entity relationship edges represent the specific semantic relationship between two entity nodes, forming the core reasoning path of the graph; entity-attribute "relationship" edges represent the subordinate relationship between an entity and an attribute, forming a structured expression of (entity, attribute, attribute key: attribute value). S1053. Each entity node, attribute node, and entity-entity relationship edge carries a text block ID as a metadata attribute during storage. Through this design, the system can trace back from any graph element to its original text block, achieving a tight anchoring of structured knowledge with the original semantic context. The schema design of nodes and edges is as follows: Node schema: { "label": The label attribute value of "entity" or "attribute" indicates whether this node is an entity node or an attribute node. "properties": { "name": Node name. For entity nodes, this attribute stores the entity name; for attribute nodes, it stores the attribute key: attribute value. "chunk id": The ID of the text block to which this node belongs. "schema_type": Entity type. Attribute nodes do not have this attribute; the attribute type of an attribute node is the attribute key, which is stored in the node name. } } edge schema: { "relation": Relation type "chunk id": The ID of the text block to which this edge belongs. } S1054. The vector index objects include four types: text block vector index, used to recall document fragments containing dense contextual information; entity vector index, used for entity linking and concept matching; entity-attribute triple vector index, used to accurately retrieve specific object features; and entity-entity triple vector index, used for relation retrieval and inference clue discovery based on semantic similarity. Among them, the text block vector is constructed in step S1022 after obtaining the block results; the entity vector is obtained by embedding entity names through an embedding model, and a global entity set is created and maintained in step S104. Each global entity corresponds to an entity vector, and the corresponding entity vector is updated when a new global entity is added or the global entity name is modified; the entity-attribute triple (entity name, attribute, attribute key: attribute value) and entity-entity triple (head entity name, relation type, tail entity name) vectors are obtained by directly embedding the triple text. After knowledge fusion is completed, the entity names involved in the triple are now consistent with the global entity set, and all triples are then uniformly embedded and saved. Due to the existence of the global entity set, subsequent incremental updates of the knowledge graph only require repeating steps S101-S104 for newly added text documents. During the knowledge fusion process, for entities with duplicates, the global entity information text and vector are updated as needed, and the related triplet text and vector are also updated. If there are no duplicates, the entity information text, vector, and triplet text and vector are directly added to the database.

[0040] S2. Pattern-guided query parsing and multi-stage retrieval enhancement generation: For complex natural language queries input by users, the heterogeneous knowledge graph is used to gradually locate evidence and generate the final answer through question decomposition and multi-stage retrieval strategies.

[0041] Example 2: Building upon Example 1, Example 2 of this application provides a more specific method for complex knowledge question answering based on knowledge graphs and retrieval enhancement, including: S1. Automated construction of heterogeneous knowledge graphs: Based on a set of unstructured text documents provided by the user, automatically construct a heterogeneous knowledge graph containing both structured knowledge and unstructured semantics.

[0042] S2. Pattern-guided query parsing and multi-stage retrieval enhancement generation: For complex natural language queries input by users, the heterogeneous knowledge graph is used to gradually locate evidence and generate the final answer through question decomposition and multi-stage retrieval strategies.

[0043] like Figure 3 As shown, S2 includes: S201, Query parsing with pattern constraints: For complex natural language queries input by users, the ontology pattern of the knowledge graph is used as an external constraint. The LLM is guided by prompt words to decompose the query into an ordered, semantically clear sequence of atomic sub-problems. For the decomposed sub-problems, their logical dependencies are identified and the preceding sub-problems are marked.

[0044] Specifically, S201 includes: S2011. The query decomposition process is formally defined as a schema-constrained generative task. Let the complex problem input by the user be... The ontology pattern set of knowledge graphs is The goal of query decomposition is to generate a sequence of subproblems. By using ontology mode As part of the prompt words, the entity types and relationships defined in the ontology pattern provide clear thinking boundaries for the large model, effectively curbing the illusion tendency of the large model in the decomposition process and ensuring that the generated sub-problems can be semantically covered by the knowledge graph. S2012. When decomposing a problem, for subproblems with strong logical dependencies, the dependencies are explicitly indicated by adding conditions. The dependencies refer to the existence of a prerequisite dependency between some subproblems, that is, the solution of the subproblem depends on the answer of another subproblem. For subproblems with marked dependencies, the context is supplemented in the subsequent rewriting stage by combining the answers of the prerequisite subproblems.

[0045] S202. Subproblem Rewriting: Process each subproblem sequentially according to the order of the subproblem sequence. For subproblems with dependencies, rewrite them by combining the answers to previous subproblems, supplementing the current subproblem with entity information involved in the previous answers to form a semantically complete and independently searchable query statement. It should be noted that for subproblems with dependencies, they can only be used for retrieval after the question information is improved. For subproblems without dependencies, keep the original question form unchanged and proceed directly to the next stage.

[0046] S203, Graph Data Retrieval and Answer Generation: For the current sub-problem after rewriting, execute the "triple found" retrieval strategy, calculate the vector similarity between the sub-problem and the triple to recall candidate triples, use the nodes contained in the triple as seeds to expand one hop on the knowledge graph to form a candidate subgraph, call LLM to filter irrelevant triples to obtain the evidence subgraph; input the evidence subgraph into LLM to generate the answer to the current sub-problem, and at the same time require LLM to determine whether the evidence subgraph is sufficient to answer the question. If it is insufficient to answer the question, mark it as "unable to answer" and trigger the text data fallback retrieval.

[0047] S203 includes: S2031. For sub-questions with dependency issues, after the preceding question is answered, the sub-question is rewritten based on the preceding sub-question and the answer, and the entity information involved in the preceding answer is added to the current sub-question to form a semantically complete and independently searchable query statement; only after the question information is improved can the sub-question be used for retrieval. S2032. For the current sub-problem that has been processed, a retrieval strategy based on the found triples is adopted: calculate the similarity between the text vector of the sub-problem and all "entity-relationship-entity" triple vectors in the knowledge graph, and recall the top-k triples with the highest similarity; the core advantage of triples lies in their context encapsulation capability. A triple not only contains the concept of the target object, but also encapsulates the basic semantic relationship between the concept and other objects. Compared with isolated entity nodes, triples can provide the model with richer contextual information; S2033. Using the nodes contained in the top-k recalled triples as seed nodes, extend the knowledge graph by one hop to obtain candidate subgraphs. Then, call LLM to filter the triples in the candidate subgraphs and remove triples that do not help answer the subquestion. The filtered triples are the final evidence subgraph. If all triples are filtered, use the text block with the closest semantics to the subquestion query as the context to answer the question.

[0048] For example, the prompt words required for S203 are designed as follows: You are an expert knowledge assistant. Your task is to answer questions based on the provided knowledge context.

[0049] Require: 1. Use the information in the provided knowledge context and make your best effort to answer the questions.

[0050] 2. If the knowledge extracted is insufficient to answer the question, please answer based on your own knowledge.

[0051] 3. If neither the extracted knowledge nor your own knowledge is sufficient to answer the question, please refuse to answer the question and output "Unable to answer".

[0052] 4. Answers should be accurate and concise.

[0053] 5. For factual questions, specific facts or entity names must be provided.

[0054] 6. For time-related questions, please provide the specific date, year, or time period.

[0055] Question: <Question> Knowledge Context: <Knowledge Context> S204. Text fallback retrieval and answer generation: Input the evidence subgraph into the LLM to generate the answer to the current subquestion. If the LLM determines that the evidence subgraph is insufficient to answer the question, it initiates text data retrieval, recalls relevant text blocks as supplementary context based on a comprehensive metric that integrates semantic similarity and evidence coverage, and generates the answer. After all subquestions are answered in sequence, the answer to the last subquestion is the final answer to the original complex query.

[0056] S204 includes: The comprehensive evaluation metric not only considers the semantic similarity between the text block and the original query, but also quantifies the text block's capacity to carry evidence subgraphs. Specifically, it counts the number of evidence subgraph nodes and triples contained in the text block, using the normalized weighted score of these two items as the evaluation metric. The calculation formula is as follows: in, For the first A text block, For the current subproblem, For text blocks The total number of nodes in the evidence subgraph included. Let be the total number of nodes contained in the evidence subgraph. For text blocks The total number of triples in the evidence subgraph contained therein. The total number of triples contained in the evidence subgraph. For text blocks With query similarity of embedding vectors between them For all text blocks and queries The maximum embedding vector similarity between them To balance the hyperparameters, the range of values ​​is... This is used to adjust the relative importance of evidence subgraph size and vector similarity.

[0057] It should be noted that the parts in this embodiment that are the same as or similar to those in Embodiment 1 can be referred to each other, and will not be repeated in this application.

[0058] Example 3: Building upon Example 2, Example 3 of this application provides a complex knowledge question-answering system based on knowledge graphs and retrieval enhancement, including: The building module is used to automatically construct a heterogeneous knowledge graph containing both structured knowledge and unstructured semantics based on a set of unstructured text documents provided by the user. The generation module is used to address complex natural language queries input by users, and utilizes the heterogeneous knowledge graph to gradually locate evidence and generate the final answer through question decomposition and multi-stage retrieval strategies.

[0059] It should be noted that the system provided in this embodiment corresponds to the system of the method provided in Embodiment 2. Therefore, in this embodiment... The parts of the embodiments that are the same as or similar to those of Embodiment 2 can be referred to each other, and will not be repeated in this application.

[0060] In summary, this invention, through the automated construction process in step S1, constructs a heterogeneous knowledge graph from unstructured documents that possesses both structured reasoning capabilities and rich semantic context, without requiring extensive manual annotation. This addresses the scarcity of high-quality, highly adaptable knowledge graphs, as well as the high cost and poor adaptability of knowledge graph construction. Step S2, based on pattern-constrained question decomposition and a multi-stage retrieval strategy, effectively solves the problems of candidate subgraph explosion and inaccurate semantic matching in complex multi-hop reasoning. The synergistic effect of these two steps achieves bidirectional enhancement of LLM and KG, improving the accuracy and robustness of large language models in complex question answering on private knowledge bases.

Claims

1. A complex knowledge question-answering method based on knowledge graphs and retrieval enhancement, characterized in that, include: S1. Automated construction of heterogeneous knowledge graphs: Based on the user-provided collection of unstructured text documents, automatically construct heterogeneous knowledge graphs containing both structured knowledge and unstructured semantics. S2. Pattern-guided query parsing and multi-stage retrieval enhancement generation: For complex natural language queries input by users, the heterogeneous knowledge graph is used to gradually locate evidence and generate the final answer through question decomposition and multi-stage retrieval strategies.

2. The complex knowledge question answering method based on knowledge graph and retrieval enhancement as described in claim 1, characterized in that, S1 includes: S101. Perform data preprocessing on the original document and extract plain text content; S102. Semantic-aware intelligent segmentation: Using a large language model to identify the semantic boundaries of a document, the document is segmented into semantically coherent text blocks, and a vector representation is generated for each text block. S103. Knowledge extraction based on dynamic pattern expansion: A strategy combining seed ontology and automatic evolution is adopted. An initial ontology pattern is predefined, and entities, relations and attributes are extracted from each text block using a large language model. At the same time, new pattern elements that meet the confidence requirements are identified and dynamically incorporated. S104, Layered Knowledge Fusion: Maintain a global entity set, and for each text block, extract local entities and perform entity alignment through a multi-layered process of string matching, type consistency and semantic disambiguation. Also, perform attribute and relationship migration fusion for duplicate entities. S105. Hybrid Index Construction: Based on the fused knowledge, a heterogeneous knowledge graph is constructed. The graph includes entity nodes, attribute nodes, and text block nodes, and a graph structure index and a multi-granularity vector index are established.

3. The complex knowledge question answering method based on knowledge graph and retrieval enhancement as described in claim 2, characterized in that, The method for generating text block vectors in S102 is as follows: the text block is split into sentences, and the vectors of each sentence are weighted and averaged. The weights are positively correlated with the sentence length.

4. The complex knowledge question answering method based on knowledge graph and retrieval enhancement as described in claim 3, characterized in that, The process of dynamically incorporating new pattern elements in S103 includes: defining the iterative expansion of the ontology pattern as the merging of the current pattern and the pattern to be expanded; the pattern to be expanded is output by the large language model after confidence evaluation based on the current text block, the current pattern and the confidence threshold.

5. The complex knowledge question answering method based on knowledge graph and retrieval enhancement as described in claim 4, characterized in that, The multi-layer process in S104 includes: First layer, exact matching: Determines whether there is an entity in the global entity set whose name is exactly the same as that of the local entity; The second layer, homonym detection: For entity pairs with the same name but different types, they are marked as potential homonyms and then entered into semantic disambiguation; The third layer, fuzzy semantic disambiguation: candidate entities are selected based on vector similarity, and a large language model is called to make a final matching judgment between local entities and candidate entities.

6. The complex knowledge question answering method based on knowledge graph and retrieval enhancement according to claim 5, characterized in that, S2 include: S201, Query parsing with pattern constraints: Using ontology patterns from knowledge graphs to guide the large language model to decompose complex queries into an ordered sequence of atomic sub-problems and identify the dependencies between sub-problems; S202. Subproblem rewriting: According to the order of the subproblem sequence, for subproblems with dependencies, semantic supplementation is performed by combining the answers of the preceding subproblems to form independent and searchable query statements; S203, Graph Data Retrieval and Answer Generation: For the rewritten sub-question, relevant triples are recalled based on vector similarity. The nodes in the triples are used as seeds to expand and form candidate subgraphs. After filtering by a large language model, evidence subgraphs are obtained, and the answer to the current sub-question is generated based on the evidence subgraph. S204. Text fallback retrieval and answer generation: If the evidence subgraph is insufficient to answer the question, the text block is recalled as supplementary context to generate the answer based on a comprehensive index combining semantic similarity and evidence coverage; after all sub-questions are completed, the answer to the last sub-question is taken as the final answer.

7. The complex knowledge question answering method based on knowledge graph and retrieval enhancement as described in claim 6, characterized in that, The graph data retrieval in S203 specifically includes: calculating the similarity between the subquestion vector and all entity-relation-entity triple vectors in the knowledge graph, recalling the triples with the highest similarity; using the nodes in these triples as seeds to expand one hop to obtain candidate subgraphs; using a large language model to filter the triples in the candidate subgraphs based on relevance; if all triples are filtered, then directly using the text block most similar to the subquestion to generate the answer.

8. A complex knowledge question-answering system based on knowledge graphs and retrieval enhancement, characterized in that, For performing the method according to any one of claims 1 to 7, comprising: The building module is used to automatically construct a heterogeneous knowledge graph containing both structured knowledge and unstructured semantics based on a set of unstructured text documents provided by the user. The generation module is used to address complex natural language queries input by users, and utilizes the heterogeneous knowledge graph to gradually locate evidence and generate the final answer through question decomposition and multi-stage retrieval strategies.

9. A computer storage medium, characterized in that, The computer storage medium stores a computer program; when the computer program is run on the computer, it causes the computer to perform the method described in any one of claims 1 to 7.

10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the method as described in any one of claims 1 to 7.