A Search Enhancement Generation Method and System Based on Structured Documents

By integrating structural information and relationships into structured documents, an enhanced knowledge graph is constructed, which solves the problems of sparse relationships and loss of structural information in existing technologies, and achieves more accurate and information-rich answer generation.

CN120067340BActive Publication Date: 2026-03-13HANGZHOU DIANZI UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-27
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing search enhancement generation techniques suffer from sparse relationships and loss of structural information when processing structured documents, resulting in poor response quality.

Method used

By integrating the structural information of structured documents into the knowledge graph, increasing the number of relationships and adding structured information, an enhanced knowledge graph is constructed. This graph is then used to perform community segmentation and summary construction using a large language model, generating more accurate answers.

Benefits of technology

It improves the accuracy and richness of the answers, making the community structure more reasonable and the information more comprehensive, and enabling better answers to summary-type questions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120067340B_ABST
    Figure CN120067340B_ABST
Patent Text Reader

Abstract

This invention proposes a retrieval enhancement generation method and system based on structured documents. First, it extracts the document structure information from structured documents. Second, it extracts entity relationships and their descriptions to construct a knowledge graph. Then, it uses the document structure relationships to enhance the knowledge graph. Next, it divides the enhanced knowledge graph into communities and constructs community summaries. Finally, it performs retrieval enhancement generation. Compared to existing technologies, this retrieval enhancement generation method based on structured documents achieves higher accuracy. Compared to existing methods, by integrating the structured information of structured documents into the knowledge graph, it increases the number of relationships, solving the problem of sparse relationships in the knowledge graph, and adds structured information, solving the problem of missing structured information in the knowledge graph. This results in a more reasonable community structure and richer information, thus leading to higher accuracy in the final answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of search enhancement, and more specifically to a search enhancement generation method and system based on structured documents. Background Technology

[0002] Currently, there are many structured documents on the internet with obvious chapters, numbering, or other similar structures. These documents are characterized by their content being organized into ordered parts, such as chapters, sections, subsections, lists, etc. Examples include books and long documents with chapter relationships, legal documents with paragraph and sub-paragraph relationships, and standards and technical documents with hierarchical relationships such as clauses and sub-clauses.

[0003] As large language models become increasingly powerful, retrieval augmented generation (RAG) techniques can be used for question answering on such documents. First, relevant text fragments are retrieved from the document based on a question. These text fragments, along with the question, are then fed into the large language model to obtain the answer. However, traditional retrieval augmented generation (RAG) has a limitation: it is designed for answers contained within text blocks and is not adept at answering summary-type questions. GraphRAG addresses this problem by constructing a knowledge graph from text data, dividing it into communities, and summarizing community summaries to answer summary-type questions.

[0004] However, GraphRAG suffers from sparse relationships when building knowledge graphs, causing the constructed communities to lose some entity relationship information. Secondly, when dealing with structured documents, GraphRAG loses structural information, such as which subheadings are included in the title or which entities belong to the same title, resulting in communities that also lack document structure information. All of these factors contribute to poor final response quality. Summary of the Invention

[0005] To address the aforementioned issues, this paper proposes a retrieval enhancement generation method and system based on structured documents. By integrating the structured information of structured documents into the knowledge graph, it not only increases the number of relationships to solve the problem of sparse relationships in the knowledge graph, but also adds structured information to solve the problem of missing structured information in the knowledge graph. This results in a more reasonable community structure and richer information, leading to higher accuracy in the final answer.

[0006] This invention provides a retrieval enhancement generation method based on structured documents, comprising the following steps:

[0007] Step 1: Obtain a collection of structured documents and extract their structured information;

[0008] The structured document is identified, and the text of element nodes and text nodes, as well as the positions of text nodes and element nodes in the document, are extracted. The element nodes refer to the basic units in the document used to organize and hierarchically classify specific content, and the text nodes refer to the specific text content at the lowest content level in the document, without involving the document structure.

[0009] For the extracted element nodes, a hierarchical structure of the element nodes is constructed using a large language model, which serves as the document's structural information HS = (V1, R), where V1 is the set of element nodes and R is the set of adjacency relationships R = {(v j ,v j )|v i ∈V1,v j ∈V1};

[0010] Step 2: Divide the text into blocks according to the document structure;

[0011] Based on the positions of element nodes and text nodes in the document, the lowest-level element node to which the text node belongs is obtained; the text of the text node is divided according to the maximum number of tokens in the large language model to obtain text blocks and the lowest-level element node to which the text block belongs, as text block information;

[0012] Step 3: Extract entities, relations, and their descriptions from the text blocks;

[0013] Based on the text block and the lowest-level element node to which the text block belongs, an entity relationship extraction prompt is constructed. Using the large language model, entities and their descriptions, as well as the relationships and descriptions between entities, are identified, ultimately yielding entity information and relationship information.

[0014] Step 4: Construct an augmented knowledge graph

[0015] Based on entity and relation information, entities and relations are aligned, and then a knowledge graph G is constructed, G = {(E,V)}, where E is the aligned entity set E = {(e,a1)}, where e is the entity name, a1 is the entity attribute, including the entity description and associated text block, and V is the relation set V = {(e1,a,e2)|e1∈E,e2∈E}, where a is the attribute of the relation edge between entities e1 and e2, including the relation description.

[0016] Using the document structure information obtained in step 1 and the text block information obtained in step 2, the knowledge graph is enhanced to obtain the enhanced knowledge graph G′={(E′,V′)}, E′=E∪EH, where EH represents an element node, and V′=V∪VH, where VH represents the relationship between the lowest level element node and the entity, and the hierarchical relationship between element nodes.

[0017] Step 5: Community segmentation and community summary construction;

[0018] The enhanced knowledge graph is used to perform community segmentation using a community detection algorithm. For each segmented community, a summary community prompt is constructed. The summary community prompt, along with the entity name e, entity description, and relationship description contained in the community, are concatenated and input into the large language model to obtain the community summary.

[0019] The community summary is vectorized using the embedding model to obtain community summary information, which includes the mapping relationship between the community summary and the community summary embedding.

[0020] Step 6: Search and answer generation;

[0021] Obtain summary-type user questions to be answered. These summary-type user questions are those designed to obtain core information or a brief overview related to a specific topic or need, without requiring detailed background information or complex analysis.

[0022] The abstract-type user question is vectorized using the embedding model, and its similarity is calculated with the community abstract embedding. Community abstracts with similarity below a certain threshold are filtered out to obtain a number of highly similar community abstracts.

[0023] Based on the summary-type user question to be answered, a prompt is constructed to generate intermediate answers and score them. A large language model is used to generate an intermediate answer and its score for each highly similar community summary. These intermediate answers are sorted in descending order of score and added to the large language model context until the maximum context window limit is met. Then, a prompt summarizing the intermediate answers is constructed, and the answer is returned to the user using the large language model.

[0024] Preferably, in step 2, the lowest-level element node to which the text block belongs is obtained as follows: based on the relationship between the text block and the text node, and the relationship between the text node and the lowest-level element node, the lowest-level element node to which the text block belongs is obtained;

[0025] Preferably, in step 3, the entity information includes: entity name, entity description, and the text block in which the entity is located; the relationship information includes: head entity name, tail entity name, and relationship description.

[0026] Preferably, in step 1, the element node is specifically a title, and the text node is specifically a text fragment under the lowest-level title.

[0027] Preferably, step 1 specifically includes the following steps:

[0028] Step 1.1 Use the layout analysis model to identify the positions of element nodes and text nodes in the structured document, and use the character recognition model to extract the text in the element nodes and text nodes;

[0029] Step 1.2 Construct a prompt to identify the hierarchical structure of element nodes. Arrange the element nodes from top to bottom according to their position in the document and input them together into the large language model to obtain the hierarchical structure of the element nodes, which is used as the document structure information, denoted as HS = (V1, R), where V1 is the set of element nodes and R is the set of adjacency relations R = {(v i ,v j )|v i ∈V1,v j ∈V1}; The document structure information stores the mapping relationship between element nodes and their child element nodes.

[0030] As a preferred method, the entity relationship alignment method mentioned in step 4 is as follows: Based on the entity information and relationship information, entities are aligned according to their names, and relationships are aligned according to the names of the first and last entities. The text blocks in which the entities appear are merged into a list, and the large language model is used to summarize the multiple descriptions of the aligned entities and relationships into a single description.

[0031] Preferably, the enhanced knowledge graph described in step 4 specifically includes the following steps:

[0032] Step 4.1 Based on the document structure information, add the element nodes as nodes to the knowledge graph G;

[0033] Step 4.2 Establish a relationship between each element node and its parent element node, and add it to the knowledge graph G;

[0034] Step 4.3 Based on the text block information, find the text block contained under the lowest-level element node, find all entities corresponding to the text block from the knowledge graph G, obtain the entities contained in the lowest-level element node, establish the relationship between the lowest-level element node and all entities contained therein, and add them to the knowledge graph G.

[0035] This invention also provides a retrieval enhancement generation system based on structured documents, comprising:

[0036] The document structure information extraction module is used to identify the structured document and extract the text of element nodes and text nodes, as well as the position of the text nodes in the document. Element nodes refer to the basic units in the document used to organize and hierarchically categorize specific content, while text nodes refer to the specific text content at the lowest content level in the document. For the extracted element nodes, a hierarchical structure of the element nodes is constructed using a large language model, which serves as the document structure information HS = (V1, R), where V1 is the set of element nodes, and R is the set of adjacency relationships R = {(v1, R1, R2, ..., R3, ..., R4, ..., R5, ..., R6, ..., R7, ..., R8, ..., R9, ..., R1 ... i ,v j )|v i ∈V1,v j ∈V1};

[0037] The text block segmentation module is used to: obtain the lowest-level element node to which the text node belongs based on the position of the element node and the text node in the document; and segment the text of the text node according to the maximum number of tokens in the large language model to obtain text blocks and the lowest-level element node to which the text block belongs, as text block information.

[0038] The entity relationship extraction module is used to construct an entity relationship extraction prompt based on the text block and the lowest-level element node to which the text block belongs. Using the large language model, it identifies entities and their descriptions, as well as the relationships between entities and their descriptions, and finally obtains entity information and relationship information.

[0039] The enhanced knowledge graph construction module is used to: align entities and relations based on entity and relation information, and then construct a knowledge graph G, G = {(E,V)}, where E is the aligned entity set E = {(e,a1)}, where e is the entity name, a1 is the entity attribute including the entity description and associated text blocks, and V is the relation set V = {(e1,a,e2)|e1∈E,e2∈E}, where a is the attribute of the relation edge between entities e1 and e2, including the relation description; using the document structure information obtained in step 1 and the text block information obtained in step 2, the knowledge graph is enhanced to obtain the enhanced knowledge graph G′ = {(E′,V′)}, E′ = E∪EH, where EH represents an element node, and V′ = V∪VH, where VH represents the relationship between the lowest-level element node and the entity, and the hierarchical relationship between element nodes;

[0040] The community segmentation and community summary construction module is used to: call the community discovery algorithm to segment the augmented knowledge graph into communities; construct a summary community summary prompt for each segmented community; concatenate the summary community summary prompt with the entity name e, entity description, and relationship description contained in the community and input them into the large language model to obtain the community summary; and use the embedding model to vectorize the community summary to obtain community summary information, wherein the community summary information includes the mapping relationship between the community summary and the community summary embedding.

[0041] The retrieval and answer generation module is used to: obtain summary-type user questions to be answered, wherein the summary-type user questions refer to questions that aim to obtain core information or a brief overview related to a specific topic or need, without requiring detailed background information or complex analysis; vectorize the summary-type user questions using the embedding model, calculate the similarity with community summary embeddings, filter out community summaries with similarity below a certain threshold, and obtain several highly similar community summaries; based on the summary-type user questions to be answered, construct a prompt for generating intermediate answers and scoring the intermediate answers, and use a large language model to generate an intermediate answer and a score for each highly similar community summary; sort these intermediate answers in descending order of score, add them to the context of the large language model, then construct a prompt summarizing the intermediate answers, and return the answer to the user using the large language model.

[0042] Compared to existing technologies, the above-mentioned retrieval enhancement generation method based on structured documents has higher accuracy.

[0043] Compared to existing methods, integrating the structural information of structured documents into the knowledge graph not only increases the number of relationships, solving the problem of sparse relationships in the knowledge graph, but also adds structured information, solving the problem of missing structured information in the knowledge graph. This results in a more reasonable community structure and richer information, thus leading to higher accuracy in the final answer. Attached Figure Description

[0044] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Some specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings in an exemplary and non-limiting manner. The same reference numerals in the drawings indicate the same or similar parts or components. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:

[0045] Figure 1 This is a flowchart of a retrieval enhancement generation method based on structured documents according to the present invention.

[0046] Figure 2 This is a sample diagram of the aviation industry engineering design specification document of this invention.

[0047] Figure 3 This is an example diagram of the enhanced knowledge graph constructed by the present invention based on the aviation industry engineering design specification document. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0049] In this invention, embedding represents vectorized embedding; prompt represents a prompt word; Specific Implementation

[0051] To make the technical solutions and advantages of the present invention clearer, the present invention will be further described below with reference to the accompanying drawings.

[0052] A retrieval enhancement generation method based on structured documents mainly includes the following steps:

[0053] First, perform step S1 to import the aviation industry engineering design specification document set and extract the document structure information.

[0054] The Aviation Industry Engineering Design Specification Document Collection contains multiple aviation industry engineering design specification documents. These documents are in PDF format.

[0055] Each page of the aviation industry engineering design specification document is generated as an image. Then, the 360 ​​Layout Analysis model is used to identify the position of each element node and text node in the document based on the image. Finally, the PP-OCRv3 text recognition model is used to extract the text from the element nodes and text nodes.

[0056] A prompt is constructed to identify the hierarchical structure of element nodes. The element nodes are arranged from top to bottom according to their position in the document and input together into the GPT-4o model to obtain the hierarchical structure of element nodes, that is, the document structure information. The document structure information stores the mapping relationship between element nodes and their child element nodes.

[0057] In this embodiment, element nodes refer to headings, and text nodes refer to text fragments under the lowest-level headings. The document structure information is a JSON file, where the key is the heading (data type: string), and the value is the subheading of that heading (data type: object).

[0058] The prompt for identifying the element node hierarchy is:

[0059] Please organize the element node information below into a hierarchical JSON structure. The JSON key is a string representing an element node, and the value is an object representing a child element node.

[0060] #Example

[0061] {Examples}

[0062] #enter

[0063] {input_text}

[0064] Then, proceed to step 2: based on the position of the element node and the text node in the document, obtain the lowest-level element node to which the text node belongs; divide the text of the text node according to the maximum number of tokens to obtain text blocks; based on the relationship between the text block and the text node, and the relationship between the text node and the lowest-level element node, obtain the lowest-level element node to which the text block belongs; finally, obtain the text block information, which includes the text block content and the lowest-level element node to which it belongs.

[0065] In this embodiment, the text block information is a CSV file, the fixed length of the segment is set to 512, and the length of the overlapping part is set to 256.

[0066] Then, step 3 is executed. Based on the text block information, an entity relationship extraction prompt is constructed. Using the GPT-4o model, entities and their descriptions, as well as the relationships and descriptions between entities, are identified. Finally, entity information and relationship information are obtained. Entity information includes: entity name, entity description, and the text block in which the entity is located. Relationship information includes: head entity name, tail entity name, and relationship description.

[0067] In this embodiment, the entity relation extraction prompt is:

[0068] -Target--

[0069] Given a text and a list of entity types, identify all entities of each type and all relationships between them.

[0070] -step-

[0071] 1. Identify all entities. For each identified entity, extract the following information:

[0072] -Entity Name: The name of the entity

[0073] - Entity type: One of the following types [{entity_types}]

[0074] - Entity description: Description related to the entity

[0075] Each entity is formatted as ("entity"{tuple_delimiter}<entity name>{tuple_delimiter}<entity type>{tuple_delimiter}<entity description>).

[0076] 2. From the entities identified in step 1, identify all pairs of entities that are clearly related (head entity, tail entity).

[0077] For each pair of entities, extract the following information:

[0078] - Header entity: The name of the header entity

[0079] - Tail entity: The name of the tail entity

[0080] - Relationship description: Reasons for assuming a relationship between the head entity and the tail entity.

[0081] The format of each relation is set as ("relation"{tuple_delimiter}<head entity>{tuple_delimiter}<tail entity>{tuple_delimiter}<relation description>).

[0082] 3. All entities and relationships identified in steps 1 and 2. Use {record_delimiter} as the list separator.

[0083] 4. After completion, output {completion_delimiter}.

[0084] ######################

[0085] -Example-

[0086] ######################

[0087] {Examples}

[0088] #############################

[0089] -Real data-

[0090] ######################

[0091] Entity type: {entity_types}

[0092] Text: {input_text}

[0093] ######################

[0094] answer:

[0095] Then proceed to step 4 to construct the enhanced knowledge graph.

[0096] First, a knowledge graph is constructed. Based on the entity and relationship information, entities are aligned by name, and relationships are aligned by the first and last entity names. The text blocks containing entities are merged into a list. The GPT-4o model is used to summarize multiple descriptions of aligned entities and relationships into a single description.

[0097] The aligned entities are used as nodes, and the aligned relationships are used as edges to construct a knowledge graph. The entity description and the list of text blocks containing the entity are added as attributes to the knowledge graph, and the relationship description is added as an attribute to the relationship.

[0098] Then, the knowledge graph is enhanced by adding element nodes as nodes to the knowledge graph based on the document structure information, establishing a relationship between each element node and its parent element node, and adding it to the knowledge graph; based on the text block information, the text block contained under the lowest-level element node is found, all entities corresponding to the text block are found in the knowledge graph, the entities contained in the lowest-level element node are obtained, the relationship between the lowest-level element node and all entities contained therein is established, and added to the knowledge graph.

[0099] The resulting augmented knowledge graph is then stored in a graph database.

[0100] In this embodiment, when merging text blocks containing entities, deduplication is required using a set; the graph database used is Neo4j graph database.

[0101] The prompt summarizing the descriptions of entities and relationships is as follows:

[0102] You are a helpful assistant responsible for generating a comprehensive summary of the data provided below.

[0103] Given one or two entities and a list of descriptions, each description corresponds to an entity or a group of entities.

[0104] Please summarize all of this into a comprehensive description. Make sure to include all information from the description.

[0105] If there are contradictions in the provided descriptions, please resolve them and provide a coherent summary.

[0106] Make sure it is written in the third person and includes entity names for complete context.

[0107] #######

[0108] -data-

[0109] Entity: {entity_name}

[0110] Description list: {description_list}

[0111] #######

[0112] Output:

[0113] """

[0114] Then, step 5 is executed, where the community detection algorithm is called to divide the augmented knowledge graph into communities, and a summary community prompt is constructed. The summary community prompt, along with the entities and their descriptions, and the relationships and their descriptions contained in the community, are concatenated and input into the GPT-4o model to obtain the community summary.

[0115] The embedding model is used to vectorize the community summary, which together with the community summary constitutes the community summary information. It stores the mapping relationship between the community summary and the community summary embedding.

[0116] In this embodiment, the community summary information is a CSV file; the maximum community size of the Leiden community discovery algorithm is set to 10, the random seed is set to 0xDEADBEEF; and the dimension of the community summary vector is 1536.

[0117] The community summary prompt is as follows:

[0118] #Target

[0119] Based on the given list of community entities and their relationships, a community report is generated. This community report contains community-related information and its importance.

[0120] #Community Report Structure

[0121] The community report should include the following sections:

[0122] - Title: The name of the community, which needs to include its key entities. The title should be short but specific. If possible, include representative entities in the title.

[0123] -Summary: A summary that reflects the overall structure of the community, including how entities are interconnected and important information related to those entities.

[0124] - Details: A list of 5-10 key pieces of information about the community. Each key piece of information should have a brief summary, followed by an explanation of the summary, based on the following basic rules: be comprehensive.

[0125] The output will be returned as a properly formatted JSON string, as follows:

[0126]

[0127] #Regulation

[0128] Please do not provide irrelevant information without supporting evidence.

[0129] #Example

[0130] {Examples}

[0131] -----------

[0132] #RealData

[0133] Use the following text as your answer. Do not make anything up in your answer.

[0134] enter:

[0135] {input_text}

[0136] The community report should include the following sections:

[0137] - Title: The name of the community, which needs to include its key entities. The title should be short but specific. If possible, include representative entities in the title.

[0138] -Summary: A summary that reflects the overall structure of the community, including how entities are interconnected and important information related to those entities.

[0139] - Details: A list of 5-10 key pieces of information about the community. Each key piece of information should have a brief summary, followed by an explanation of the summary, based on the following basic rules: be comprehensive.

[0140] The output will be returned as a properly formatted JSON string, as follows:

[0141]

[0142] #Regulation

[0143] Please do not provide irrelevant information without supporting evidence.

[0144] Output:

[0145] Then, proceed to step 6 to obtain the summary-type user questions to be answered, vectorize the summary-type user questions using the embedding model, calculate the similarity with the community summary embedding, and filter out community summaries with similarity below a certain threshold.

[0146] A prompt for answering intermediate questions is constructed. The GPT-4o model generates an intermediate answer for each community summary with a similarity higher than a threshold, and scores these intermediate answers. These intermediate answers are sorted in descending order of score and added to the GPT-4o model context until the maximum context window limit is met. Then, a summary intermediate answer prompt is constructed, input into the GPT-4o model, and finally, the answer is returned to the user.

[0147] In this embodiment, cosine similarity is used to represent the similarity between two vectors, and the similarity threshold is set to 0.77.

[0148] The prompt for answering the intermediate questions is as follows:

[0149] ---Role---

[0150] You can be an assistant to answer related questions based on the data in the table.

[0151] ---Target---

[0152] Summarize all relevant information from the input table to generate an answer, which is a list of key points.

[0153] You should use the data provided in the table below as the primary context for generating your answer.

[0154] If you don't know the answer, or if the data in the table you entered doesn't contain enough information to provide an answer, please say so. Don't make anything up.

[0155] Each key point in the answer should include the following:

[0156] - Description: A comprehensive description of the key points.

[0157] - Importance Score: An integer score between 0 and 100, representing the importance of the key point in answering the user's question. A "I don't know" response receives a score of 0.

[0158] The response is in JSON format, as shown below:

[0159] {{

[0160] "Key Points List":[

[0161] {{"Description":"Description of Key Point 1","Score":Score of Key Point 1}},

[0162] {{"Description":"Description of Key Point 2","Score":Score of Key Point 2}}, ]

[0164] }}

[0165] The answer should retain the original meaning and modal verbs (such as "maybe").

[0166] Please do not provide information without supporting evidence.

[0167] Example:

[0168] {Examples}

[0169] ---Data Table---

[0170] {input_data}

[0171] ---Target---

[0172] Summarize all relevant information from the input table to generate an answer, which is a list of key points. You should use the data provided in the table below as the primary context for generating the answer.

[0173] If you don't know the answer, or if the data in the table you entered doesn't contain enough information to provide an answer, please say so. Don't make anything up.

[0174] Each key point in the answer should include the following:

[0175] - Description: A comprehensive description of the key points.

[0176] - Importance Score: An integer score between 0 and 100, representing the importance of the key point in answering the user's question. A "I don't know" response should have a score of 0.

[0177] The answer should retain the original meaning and modal verbs (such as "maybe").

[0178] Please do not provide information without supporting evidence.

[0179] The response should be in JSON format, as shown below:

[0180] {{

[0181] "Key Points List":[

[0182] {{"Description":"Description of Key Point 1","Score":Score of Key Point 1}},

[0183] {{"Description":"Description of Key Point 2","Score":Score of Key Point 2}}, ]

[0185] }}

[0186] The summary of intermediate answer prompts is as follows:

[0187] ---Role---

[0188] You are an assistant who can answer questions about datasets by combining perspectives from multiple different angles.

[0189] ---Target---

[0190] Generate an answer that solves the user's problem, aggregating multiple answers from different perspectives, each focusing on a different part of the dataset. The answers from different perspectives provided below are sorted in descending order of importance.

[0191] If you don't know the answer, or if your answer doesn't contain enough information to answer it, please say so. Don't make anything up.

[0192] The final answer should remove all irrelevant information from the provided answers and combine the processed information into a comprehensive answer that provides explanations for all key points.

[0193] The answer should retain the original meaning and modal verbs (such as "maybe").

[0194] Please do not provide information without supporting evidence.

[0195] ---Target Length and Format of the Response---

[0196] {response_type}

[0197] ---Data Report---

[0198] {input_data}

[0199] ---Target---

[0200] Generate an answer that solves the user's problem, aggregating multiple answers from different perspectives, each focusing on a different part of the dataset. The answers from different perspectives provided below are sorted in descending order of importance.

[0201] If you don't know the answer, or if your answer doesn't contain enough information to answer it, please say so. Don't make anything up.

[0202] The final answer should remove all irrelevant information from the provided answers and combine the processed information into a comprehensive answer that provides explanations for all key points.

[0203] The answer should retain the original meaning and modal verbs (such as "maybe").

[0204] Please do not provide information without supporting evidence.

[0205] Corresponding to the aforementioned embodiment of a retrieval enhancement generation method based on structured documents, this invention also provides a retrieval enhancement generation system based on structured documents. It includes a document structured information extraction module, a text block segmentation module, an entity relation extraction module, an enhanced knowledge graph construction module, a community segmentation and community summary construction module, and a retrieval and answer generation module.

[0206] The document structure information extraction module is used to identify the structured document and extract the text of element nodes and text nodes, as well as the position of the text nodes in the document. Element nodes refer to the basic units in the document used to organize and hierarchically categorize specific content, while text nodes refer to the specific text content at the lowest content level in the document. For the extracted element nodes, a hierarchical structure of the element nodes is constructed using a large language model, which serves as the document structure information HS = (V1, R), where V1 is the set of element nodes, and R is the set of adjacency relationships R = {(v1, R1, R2, ..., R3, ..., R4, ..., R5, ..., R6, ..., R7, ..., R8, ..., R9, ..., R1 ... i ,v j )|v i ∈V1,v j ∈V1};

[0207] The text block segmentation module is used to: obtain the lowest-level element node to which the text node belongs based on the position of the element node and the text node in the document; and segment the text of the text node according to the maximum number of tokens in the large language model to obtain text blocks and the lowest-level element node to which the text block belongs, as text block information.

[0208] The entity relationship extraction module is used to construct an entity relationship extraction prompt based on the text block and the lowest-level element node to which the text block belongs. Using the large language model, it identifies entities and their descriptions, as well as the relationships between entities and their descriptions, and finally obtains entity information and relationship information.

[0209] The enhanced knowledge graph construction module is used to: align entities and relations based on entity and relation information, and then construct a knowledge graph G, G = {(E,V)}, where E is the aligned entity set E = {(e,a1)}, where e is the entity name, a1 is the entity attribute including the entity description and associated text blocks, and V is the relation set V = {(e1,a,e2)|e1∈E,e2∈E}, where a is the attribute of the relation edge between entities e1 and e2, including the relation description; using the document structure information obtained in step 1 and the text block information obtained in step 2, the knowledge graph is enhanced to obtain the enhanced knowledge graph G′ = {(E′,V′)}, E′ = E∪EH, where EH represents an element node, and V′ = V∪VH, where VH represents the relationship between the lowest-level element node and the entity, and the hierarchical relationship between element nodes;

[0210] The community segmentation and community summary construction module is used to: call the community discovery algorithm to segment the augmented knowledge graph into communities; construct a summary community summary prompt for each segmented community; concatenate the summary community summary prompt with the entity name e, entity description, and relationship description contained in the community and input them into the large language model to obtain the community summary; and use the embedding model to vectorize the community summary to obtain community summary information, wherein the community summary information includes the mapping relationship between the community summary and the community summary embedding.

[0211] The retrieval and answer generation module is used to: obtain summary-type user questions to be answered, wherein the summary-type user questions refer to questions that aim to obtain core information or a brief overview related to a specific topic or need, without requiring detailed background information or complex analysis; vectorize the summary-type user questions using the embedding model, calculate the similarity with community summary embeddings, filter out community summaries with similarity below a certain threshold, and obtain several highly similar community summaries; based on the summary-type user questions to be answered, construct a prompt for generating intermediate answers and scoring the intermediate answers, and use a large language model to generate an intermediate answer and a score for each highly similar community summary; sort these intermediate answers in descending order of score, add them to the context of the large language model, then construct a prompt summarizing the intermediate answers, and return the answer to the user using the large language model.

[0212] The above description is only a part of the specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the protection scope of the present invention.

Claims

1. A retrieval enhancement generation method based on structured documents, characterized in that, Includes the following steps: Step 1: Obtain the structured document, identify the structured document, extract the text of element nodes and text nodes, and the position of text nodes and element nodes in the document. The element node refers to the basic unit in the document used to organize and hierarchically classify specific content, and the text node refers to the specific text content at the lowest content level in the document. For the extracted element nodes, a hierarchical structure of the element nodes is constructed using a large language model, which serves as the document's structural information. Step 2: Based on the position of the element node and text node in the document, obtain the lowest-level element node to which the text node belongs; divide the text of the text node according to the maximum number of tokens in the large language model to obtain text blocks and the lowest-level element node to which the text block belongs, as text block information; Step 3: Based on the text block and the lowest-level element node to which the text block belongs, construct an entity relationship extraction prompt, use the large language model to identify entities and their descriptions, as well as the relationships and descriptions between entities, and finally obtain entity information and relationship information; Step 4: Align entities and relationships based on entity and relationship information, and then construct a knowledge graph. , ,in It is the aligned set of entities ,in It is the entity name. These are entity attributes, including the entity's description and the associated text block. It is a set of relations. , It is a physical entity and The attributes of the edges that form a relationship, including the relationship description; Using the document structure information obtained in step 1 and the text block information obtained in step 2, the knowledge graph is enhanced to obtain an enhanced knowledge graph. , , Represents an element node. ,in It represents the relationship between the lowest-level element node and the entity, and the hierarchical relationship between element nodes; Step 5: Apply the community detection algorithm to the augmented knowledge graph to divide it into communities. For each community, construct a summary community prompt and combine the summary community prompt with the entity names contained in that community. The entity description and relation description are concatenated and input into the large language model to obtain the community summary; using the embedding model, the community summary is vectorized to obtain the community summary information, which includes the mapping relationship between the community summary and the community summary embedding. Step 6: Obtain the summary-style user questions to be answered. The summary-type user question is vectorized using the embedding model, and its similarity is calculated with the community summary embedding. Community summaries with similarity below a certain threshold are filtered out, resulting in several highly similar community summaries. Based on the summary-type user question to be answered, a prompt for generating intermediate answers and rating the intermediate answers is constructed. An intermediate answer and a rating for each highly similar community summary are generated using the large language model. These intermediate answers are sorted in descending order of rating and added to the context of the large language model. Then, a prompt summarizing the intermediate answers is constructed, and the answer is returned to the user using the large language model. Step 1 specifically includes the following steps: Step 1.1 Use the layout analysis model to identify the positions of element nodes and text nodes in the structured document, and use the character recognition model to extract the text in the element nodes and text nodes; Step 1.2 Construct a prompt to identify the hierarchical structure of element nodes. Arrange the element nodes from top to bottom according to their position in the document and input them together into the large language model to obtain the hierarchical structure of the element nodes. This is used as the document's structural information and denoted as [missing information]. ,in It is a collection of element nodes. For the set of adjacency relations The document structure information stores the mapping relationship between element nodes and their child element nodes.

2. The method for enhancing retrieval and generating structured documents as described in claim 1, characterized in that, The method for constructing the augmented knowledge graph described in step 4 specifically includes the following steps: Step 4.1 Based on the document structure information, add the element nodes as nodes to the knowledge graph. middle; Step 4.2 Establish the relationship between each element node and its parent element node, and add it to the knowledge graph. middle; Step 4.3 Based on the text block information, find the text blocks contained under the lowest-level element node, and then analyze them from the knowledge graph. Find all entities corresponding to the text block, obtain the entities contained in the lowest-level element node, establish relationships between the lowest-level element node and all its contained entities, and add them to the knowledge graph. middle; The entity and relation alignment described in step 4 specifically includes the following steps: based on the entity information and relation information, align entities according to their names, align relations according to the names of the first and last entities, merge the text blocks in which the entities appear into a list, and use a large language model to summarize the multiple descriptions of the aligned entities and relations into a single description.

3. The retrieval enhancement generation method based on structured documents as described in claim 1, characterized in that, In step 2, the lowest-level element node to which the text block belongs is obtained as follows: based on the relationship between the text block and the text node, and the relationship between the text node and the lowest-level element node, the lowest-level element node to which the text block belongs is obtained.

4. The method for enhancing retrieval and generating structured documents as described in claim 1, characterized in that, In step 3, the entity information includes: entity name, entity description, and the text block in which the entity is located; the relationship information includes: head entity name, tail entity name, and relationship description.

5. The method for enhancing retrieval and generating structured documents as described in claim 1, characterized in that, In step 1, the element node is specifically a title, and the text node is specifically a text fragment under the lowest-level title.

6. A retrieval enhancement generation system based on structured documents, characterized in that, include: The document structure information extraction module is used to identify the structured document and extract the text of element nodes and text nodes, as well as the positions of text nodes and element nodes in the document. Element nodes refer to the basic units in the document used to organize and hierarchically categorize specific content, while text nodes refer to the specific text content at the lowest content level in the document. For the extracted element nodes, a hierarchical structure of the element nodes is constructed using a large language model, serving as the document's structured information. ,in It is a collection of element nodes. For the set of adjacency relations ; The text block segmentation module is used to: obtain the lowest-level element node to which the text node belongs based on the position of the element node and the text node in the document; and segment the text of the text node according to the maximum number of tokens in the large language model to obtain text blocks and the lowest-level element node to which the text block belongs, as text block information. The entity relationship extraction module is used to construct an entity relationship extraction prompt based on the text block and the lowest-level element node to which the text block belongs. Using the large language model, it identifies entities and their descriptions, as well as the relationships between entities and their descriptions, and finally obtains entity information and relationship information. The enhanced knowledge graph construction module is used to: align entities and relationships based on entity and relationship information, and then construct the knowledge graph. , ,in It is the aligned set of entities ,in It is the entity name. These are entity attributes, including the entity's description and the associated text block. It is a set of relations. , It is a physical entity and The attributes of the edges representing relationships, including relationship descriptions; using the document structure information obtained in step 1 and the text block information obtained in step 2, the knowledge graph is enhanced to obtain an enhanced knowledge graph. , , Represents an element node. ,in It represents the relationship between the lowest-level element node and the entity, and the hierarchical relationship between element nodes; The community segmentation and community summary construction module is used to: call a community discovery algorithm to segment the enhanced knowledge graph into communities; for each segmented community, construct a summary community prompt; and combine the summary community prompt with the entity names contained in that community. The entity description and relation description are concatenated and input into the large language model to obtain the community summary; using the embedding model, the community summary is vectorized to obtain the community summary information, which includes the mapping relationship between the community summary and the community summary embedding. The retrieval and answer generation module is used for: obtaining summary-type user questions to be answered; vectorizing the summary-type user questions using the embedding model; calculating the similarity between the summary-type user questions and the community summary embeddings; filtering out community summaries with similarity below a certain threshold to obtain several highly similar community summaries; based on the summary-type user questions to be answered, constructing a prompt for generating intermediate answers and rating the intermediate answers; using a large language model to generate an intermediate answer and a rating for each highly similar community summary; sorting these intermediate answers in descending order of rating, adding them to the context of the large language model, then constructing a prompt summarizing the intermediate answers, and returning the answer to the user using the large language model.

Citation Information

Patent Citations

  • RAG question and answer method and system based on knowledge graph and medium

    CN118673126A

  • Dynamic correlation enhancement retrieval generation system and method driven by intelligent knowledge graph

    CN118839021A

Cited By

  • Communication field retrieval enhancement method based on embedded model fine tuning and adaptive iteration

    CN122086968A