A query-adaptive two-pass retrieval augmentation generation method
Patent Information
- Application Number
- CN202611187206.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-06
- Publication Date
- 2026-11-03
AI Technical Summary
Existing retrieval enhancement generation systems suffer from problems such as fragmented text structure information, high cost of knowledge graph construction, serious repetitive calculations in incremental updates, and lack of query adaptability in long document processing.
By employing hierarchical summary trees, lightweight knowledge graphs, and bidirectional indexes, and constructing a multi-granular semantic index structure, global semantic organization and entity structure association are achieved. Combined with an incremental update mechanism, local entity retrieval or global summary retrieval is dynamically selected, reducing redundant calculations and improving query adaptability.
It improves the construction efficiency, update efficiency, and generation quality of the long document retrieval enhancement generation system, reduces the cost of knowledge base construction, and enhances the accuracy and interpretability of evidence recall.
Smart Images

Figure CN123030730A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence, natural language processing, knowledge graphs, and retrieval enhancement generation technology, and in particular to an incremental knowledge graph dual-path retrieval enhancement generation method for scenarios of continuous updating of long document knowledge bases.
[0002] More specifically, this invention is applicable to application scenarios such as enterprise knowledge bases, scientific research literature databases, technical specification databases, course material databases, and legal databases, which contain a large amount of long text and require continuous addition of content. It can reduce the cost of repetitive calculations in the knowledge base construction, incremental maintenance, and question-and-answer retrieval stages, and improve the accuracy and interpretability of retrieval evidence. Background Technology
[0003] Retrieval-enhanced generation technology combines external knowledge base retrieval with the generative capabilities of large language models. Before answering a user's question, this technology retrieves relevant evidence from external documents, databases, or knowledge bases, then uses this retrieved evidence as contextual input to the generative model. This alleviates problems such as knowledge lag, insufficient domain knowledge, and generation illusions inherent in large language models. With the development of applications such as enterprise knowledge management, intelligent question answering, scientific literature analysis, and technical document retrieval, retrieval-enhanced generation systems have become an important technological approach for the practical application of large language models.
[0004] Existing retrieval enhancement systems typically employ vector retrieval as their primary method. This approach generally involves first dividing a long document into multiple text blocks, then encoding each block into vectors and storing them in a vector index. During a query, several text blocks are retrieved based on semantic similarity. While this method is simple to implement and can handle open-ended semantic matching problems, its drawbacks are also significant: firstly, after a long document is split into independent text blocks, the document's chapter structure, thematic hierarchy, and cross-paragraph connections are easily weakened; secondly, relying solely on vector similarity makes it difficult to explicitly determine whether interpretable relationships exist between entities, easily leading to the retrieval of semantically similar but factually insufficiently supported text.
[0005] To enhance the structured representation capabilities of retrieval systems, some methods introduce knowledge graphs, organizing entities, concepts, and relationships in text into a graph structure and utilizing entity connections to aid retrieval. Knowledge graphs can improve the interpretability of retrieval results, enabling the system to not only know "which texts are similar" but also "which entities are related." However, building a complete knowledge graph in a long document knowledge base typically requires frequent calls to large language models to perform entity extraction, relation extraction, entity alignment, and relation fusion, resulting in long indexing times and high construction costs, making it difficult to apply efficiently, especially in resource-constrained or locally deployed scenarios.
[0006] Meanwhile, many real-world knowledge bases are not statically constructed all at once, but are continuously updated with new text as business data, research literature, course content, or technical specifications are added. Traditional solutions often require re-segmentation, re-summarization, re-extraction of entity relationships, and re-indexing after document additions. For already stable historical texts, this full reconstruction results in a large amount of redundant computation, increases update time, and is also detrimental to maintaining the continuity of node numbering, evidence sources, and index structure.
[0007] Furthermore, the types of user queries are not fixed. Some questions involve explicit entity or object relationships, such as inquiring about the association between two concepts, the specific steps of a method, or the local meaning of an indicator, which are suitable for precise local retrieval using entity graphs and inverted indexes. Other questions tend to be summaries, comparisons, or overall descriptions, requiring the retrieval of macro-level background information from multi-level document summaries. Existing hybrid retrieval methods often simply overlay the results of vector retrieval, keyword retrieval, and graph retrieval, lacking adaptive judgment of query categories, and are prone to problems such as overly narrow search scope or over-expansion of context.
[0008] Therefore, it is necessary to propose a new technical solution that takes into account both the global semantic organization and the structured association of entities in long documents during the indexing stage, avoids full reconstruction during the update stage, and dynamically selects local or global retrieval based on the entity structure relationship during the query stage, thereby improving the construction efficiency, update efficiency, and generation quality of the long document retrieval enhancement generation system. Summary of the Invention
[0009] The purpose of this invention is to provide a query-adaptive dual-path retrieval enhancement generation method for long document continuous update scenarios. This method aims to address the problems of fragmented text structure information, high knowledge graph construction costs, severe repetitive computation during incremental updates, and lack of query adaptability in existing retrieval enhancement generation systems during long document processing. This invention achieves a unified representation of global semantic organization and entity structure association during the knowledge base construction phase, implements local updates targeting only newly added content and affected paths during the knowledge base update phase, and dynamically selects between local entity retrieval and global summary retrieval during the query phase. This improves the construction efficiency, update efficiency, evidence recall quality, and accuracy of the generated results of the retrieval enhancement generation system.
[0010] This method uses a hierarchical summary tree to store multi-granular semantic information of long documents, a lightweight knowledge graph to store entity co-occurrence relationships and structural connections, and a bidirectional index to establish a traceable mapping between entities and text blocks. When appending documents, only the newly added text and affected paths are locally updated. During querying, local entity retrieval or global summary retrieval is adaptively selected through entity extraction and graph distance judgment.
[0011] The incremental knowledge graph dual-path retrieval enhancement generation method of the present invention is attached. Figure 1 As shown, it mainly includes steps 1 to 10.
[0012] Step 1: Construct a knowledge index, as shown in the attached document. Figure 2 As shown. Obtain the long document to be processed and perform sliding window segmentation on the long document. Let the input long document be D, the maximum length of the text block be L, and the overlap length of adjacent text blocks be... Then you can get a set of text blocks arranged in the original text order.
[0013] (1)
[0014] The definitions of each parameter are as follows:
[0015] Represents the i-th text block
[0016] n represents the number of text blocks obtained after segmentation.
[0017] Overlapping areas are preserved between adjacent text blocks to reduce sentence truncation and semantic breaks across blocks.
[0018] Step 2: Construct a hierarchical summarization tree based on the text block set. The system uses the bottom-level text blocks as leaf nodes, groups adjacent nodes according to the original document order, and calls the summarization model to generate the next-level summary nodes. Assuming each group contains m consecutive nodes, the first-level summary node can be represented as:
[0019] (2)
[0020] The next-level summary node can then be defined as:
[0021] (3)
[0022] Through this recursive construction method, the original document is progressively compressed into a tree structure composed of multi-level summary nodes. Leaf nodes correspond to original text blocks, intermediate nodes correspond to comprehensive summaries of local regions, and the root node represents the global semantic summary of the entire document. This is a multi-granularity semantic indexing structure: bottom-level nodes are geared towards precise detail retrieval, high-level nodes towards global topic understanding, and intermediate-level nodes act as bridges connecting local evidence and overall semantics. The final summary tree can be formally represented as:
[0023] (4)
[0024] The definitions of each parameter are as follows:
[0025] Indicates the first-level summary node;
[0026] Indicates the lower-level summary node;
[0027] Step 3: Construct a lightweight knowledge graph based on the co-occurrence relationships of entities in text blocks. For each text block... The system extracts domain terms, key concepts, important objects, and named entities to obtain an entity set. .
[0028] (5)
[0029] Co-occurrence relationships are used to represent connections between entities. If two entities co-occur within the same text block, sentence, or preset local window, an edge is established between them. If the same entity co-occurs multiple times, the connection between them is likely stronger, and the corresponding edge weight is higher. Therefore, the edge weights are accumulated, and the edge weights can be represented as:
[0030] (6)
[0031] The block entity subgraph constructed independently for each text block can be represented as:
[0032] (7)
[0033] The definitions of each parameter are as follows:
[0034] It is the set of entity nodes extracted from the text block;
[0035] It is a set of edges generated based on entity co-occurrence relationships;
[0036] A global knowledge graph G is then generated through entity alignment, edge weight accumulation, and node merging. This graph does not force the extraction of complex semantic relationships, but rather preserves the structural connections between entities within a document at a lower cost.
[0037] (8)
[0038] Step 4: Build an inverted index from entity to text block and a forward index from text block to entity. The entity-to-text block index is used to quickly locate text evidence containing the entity, and the text block-to-entity index is used to determine which query entities a text block covers.
[0039] (9)
[0040] Step 5: When new content is appended to the end of the document, the system performs an incremental update instead of a full rebuild, as shown in the attached document. Figure 3 As shown, the system first registers the newly added text block as a new leaf node, and then performs local attachment starting from the rightmost path of the summary tree.
[0041] If the rightmost summary node has not yet reached the preset merging limit m, newly added leaf nodes are preferentially added to that node; if the number of newly added leaf nodes exceeds the remaining capacity, new sibling summary nodes are created. Nodes whose child node sets have changed are marked as dirty nodes, and this change propagates upwards along the parent node. Historical nodes that are not marked as dirty nodes retain their original summary content, node number, and parent-child relationship.
[0042] (10)
[0043] The definitions of each parameter are as follows:
[0044] It is the newly formed tree structure after incremental updates;
[0045] It's the tree structure before the update;
[0046] To add a new leaf set;
[0047] The set of nodes affected;
[0048] Step 6 introduces an entity structure awareness mechanism into the retrieval routing design. This enables the system to adaptively select local or global retrieval based on the entity distribution of the query itself and its connections within the knowledge structure, rather than relying on manually preset retrieval modes. (See attached...) Figure 4 As shown, the specific implementation principle is as follows: The system receives user queries and extracts entities to obtain a set of query entities. If there are no valid entities in the query, or if no structural relationship can be formed between the entities, the system proceeds to global summary retrieval; if valid entity pairs exist, it proceeds to local entity retrieval.
[0049] (11)
[0050] The definitions of each parameter are as follows:
[0051] It is a query for a collection of entities;
[0052] These are the extracted query entities;
[0053] For any pair of entities in the query entity set The system calculates the shortest path distance between the two entities in the global knowledge graph G. If both entities exist in the graph and the shortest path distance does not exceed the hop count threshold, then the entity pair is added to the set of valid entity pairs.
[0054] (12)
[0055] The definitions of each parameter are as follows:
[0056] A set of valid entity pairs;
[0057] In the entity diagram The shortest path distance in;
[0058] This is the threshold for the number of hops;
[0059] Step 7, when When the query is not empty, there are explicit connections between the queried entities in the knowledge structure, and the problem is more likely to be a local factual or relational problem, in which case a local entity retrieval is performed. For each valid entity pair... The system retrieves the contents from the inverted index from the entity to the text block. and The set of text blocks is used, and the intersection of these blocks is taken as the set of candidate evidence.
[0060] (13)
[0061] The definitions of each parameter are as follows:
[0062] A set of candidate evidence;
[0063] Index from entity to segment;
[0064] The union of candidate evidence for multiple valid entities is used to obtain a local candidate set. If the number of candidates exceeds the preset evidence upper limit k, the hop count threshold h can be gradually reduced to prioritize retaining entity pairs with closer structural distances. After tightening the threshold, the number of candidate text blocks usually decreases, and the search results become more concentrated.
[0065] If the threshold is too low, resulting in an empty candidate set, the system reverts to the previous non-empty candidate set and enters the entity-aware re-ranking stage. After the local candidate set is determined, the system sorts them according to entity coverage and entity frequency. The ranking primarily considers two metrics: entity coverage and entity frequency. Entity coverage measures how many query-related entities a text block contains; higher coverage indicates that the text block contains more core query entities. Entity frequency measures the cumulative intensity of query-related entities within a text block; higher frequency indicates a stronger focus on the query entity within the text block.
[0066] (14) (15)
[0067] The definitions of each parameter are as follows:
[0068] Indicates entity coverage;
[0069] Indicates the frequency of an entity's occurrence;
[0070] Represents a text block The collection of entities contained
[0071] Representing entities In text block The number of times it appears in;
[0072] The final system adopts a hierarchical sorting strategy, first sorting by entity coverage, and then sorting by entity frequency of occurrence:
[0073] (16)
[0074] The definitions of each parameter are as follows:
[0075] Indicates entity coverage score;
[0076] This represents the frequency score of an entity.
[0077] After sorting, select the top scorers. These text blocks serve as the final evidence for local retrieval:
[0078] (17)
[0079] Step 8, when When empty, there is no explicit connection between the queried entities in the knowledge structure, and the question is more of a summary or comprehension question, in which case a global summary retrieval is performed. The system encodes the user query q into a query vector and treats all leaf nodes, intermediate summary nodes, and high-level summary nodes in the summary tree as searchable nodes for vector similarity calculation.
[0080] Basic global retrieval directly returns the top k nodes based on similarity. For issues containing entities but not forming valid entity pairs, the system first recalls the top 2k candidate nodes, then calculates the entity occurrence weight for each node in the candidate set. For the original text block... Its weight can be defined as the set of query entities. Number of times it appears in this text block:
[0081] (18)
[0082] For a summary node, its entity weight can be obtained by recursively summing the weights of its child nodes.
[0083] (19)
[0084] The definitions of each parameter are as follows:
[0085] Represents a summary node The set of child nodes;
[0086] Indicates the weight of the child node;
[0087] After calculating the weights, the system reorders the candidate nodes based on entity appearance, and finally selects the top-weighted nodes from the candidate set. Each node serves as supplementary global evidence:
[0088] (20)
[0089] Step 9, Evidence Organization. Local search results are organized in the form of "entity pair-text block," which facilitates the generative model in identifying the entity relationships supported by each set of evidence. Global search results are organized according to the abstract tree hierarchy and the original text order, allowing the generative model to first obtain the overall background and then obtain the necessary details. When the same text block is recalled by multiple entity pairs, the system merges the entity keys and removes duplicate fragments.
[0090] Step 10: Response generation based on evidence. The system inputs the user query, retrieved evidence, evidence source identifiers, and response format requirements into the large language model, which then generates the final response under the constraints of the retrieved evidence. Because the input evidence undergoes structural filtering and hierarchical organization, the generation model can obtain higher-density information in a shorter context, thereby reducing the risk of irrelevant text interference and factual illusions.
[0091] In a preferred implementation, the number of summary nodes required to construct the summary tree is approximately linearly related to the number of underlying text blocks. If the original document is divided into n text blocks, and each summary node merges with m child nodes, then the number of non-leaf summary nodes can be approximated as:
[0092] (21)
[0093] In append-only scenarios, this invention only processes newly added text blocks and affected nodes that spread upwards from the rightmost path, avoiding repeated summarization and entity relation extraction for historically stable nodes. Therefore, this method is more suitable for applications with continuously updated long document knowledge bases and limited local resources. Attached Figure Description
[0094] Appendix Figure 1 This is a schematic diagram of the overall system architecture of the present invention;
[0095] Appendix Figure 2 This is a schematic diagram of the knowledge indexing method of the present invention;
[0096] Appendix Figure 3 This is a schematic diagram of the right-side path reconstruction for incremental update of the summary tree according to the present invention;
[0097] Appendix Figure 4 This is a schematic diagram of the dynamic retrieval path decision-making of the present invention;
[0098] Appendix Figure 5 These are comparison charts showing the effects of various implementation examples of the present invention;
[0099] Appendix Figure 6 This is a comparison chart of the long text expansion capabilities of this invention and the baseline;
[0100] It should be noted that the above figures are only used to explain the technical steps and system structure of the present invention. Those skilled in the art can draw equivalent figures based on the same technical concept in different document types, different knowledge base sizes and different model deployment environments. Detailed Implementation
[0101] The steps and processes of this invention are described in full and clear below. Obviously, the described embodiments are merely one preferred embodiment of this invention, and not all embodiments. Other embodiments obtained by those skilled in the art based on the content of this invention without inventive effort should all fall within the protection scope of this invention.
[0102] In this embodiment, Qwen 7B is used as the base model. On long document question-answering datasets such as InfiniteChoice and InfiniteQA, it is compared with three methods: GraphRAG, LightRAG, and RAPTOR. The comparison metrics include the question-answering performance metric MET and the indexing time IT.
[0103] The document chunking module receives a long document D to be processed. The system sets the maximum text chunk length L based on the large language model context window, target retrieval granularity, and deployment resources, for example, to approximately 1200 tokens; it also sets the overlap length between adjacent text chunks, for example, to approximately 100 tokens. The original text order is preserved during chunking, and each text chunk is assigned a unique number. .
[0104] Hierarchical summary tree building module reading The nodes are grouped sequentially, with every m nodes forming a group. For each group, the system calls the summary model to generate a summary node, which includes the core theme, key entities, main facts, and contextual boundaries of the text in that group. Subsequently, the system continues to use the summary as input to recursively generate higher-level nodes in the same manner.
[0105] Compared to clustering-based tree construction methods, this embodiment employs sequential recursive summarization. This method does not disrupt the original narrative structure of the document and is more suitable for long texts with chapter order, such as papers, reports, regulations, and technical specifications. Leaf nodes retain original details, intermediate nodes represent local topics, and high-level nodes represent the overall semantics of the document.
[0106] The system performs unified vector encoding on leaf nodes and summary nodes in the summary tree, and writes information such as node number, node level, node text, parent-child relationship, and original text source into the index database. Through this processing, subsequent global searches are no longer limited to the original text blocks, but can perform cross-level matching between original text fragments, local summaries, and global summaries.
[0107] The knowledge graph construction module performs entity extraction on each text block. Entities can include algorithm names, technical terms, metric names, method steps, dataset names, model names, organization names, and noun phrases that appear repeatedly in the document. After extraction, the system performs entity cleaning and normalization, merging differences in capitalization, abbreviations, and synonyms into the same entity node.
[0108] The system constructs segmented subgraphs based on entity co-occurrence. If two entities co-occur within the same text block, sentence, or preset window, a co-occurrence edge is established between them; when the same entity appears repeatedly in multiple text blocks, the edge weights are accumulated. Multiple segmented subgraphs are then combined through entity alignment, relationship fusion, and node merging to obtain a global knowledge graph.
[0109] The bidirectional index building module creates an entity-to-text block index. and text block to entity index . Used to quickly recall original evidence based on the entity. This is used to calculate entity coverage and entity frequency when ranking candidate evidence. Through this structure, a traceable relationship is maintained between graph nodes and original textual evidence.
[0110] When new text is appended to the end of the knowledge base, the incremental update module first reads the cached summary tree and graph files, counts the number of existing leaf nodes, and compares it with the current number of chunks. If the current number of chunks is not greater than the number of existing leaf nodes, it means that no new text chunks have been added, and the system directly reuses the cache without loading the summary model for re-summarization.
[0111] If a new text block is added, the system registers it as a new leaf node and searches for the rightmost summary node starting from level 0. If the node is not full, some of the newly added leaf nodes are added to it; if there are still remaining leaf nodes, new summary nodes are created in groups of m. Any node whose child node set changes is marked as a dirty node, and the summary model is called again to generate a summary. After the bottom-level update is completed, the system propagates the dirty markings along the parent node direction. If a node is re-summarized, the input content of its parent node changes accordingly, and the parent node also needs to be re-summarized. This process is executed level by level upwards along the affected path on the right, until the root node or no new affected parent nodes.
[0112] After receiving the user query q, the retrieval path decision module first extracts the query entity set. .like If the query is empty, the system considers it to lack explicit object constraints and directly proceeds to global summary retrieval. If not empty, the system calculates the shortest path distance between entity pairs in the global knowledge graph G and selects entity pairs whose distance does not exceed the threshold h as valid entity pairs.
[0113] If the set of valid entities If the query is not empty, it indicates that the query is more likely to be a local factual or relational question, and the system enters the local entity retrieval stage. The local retrieval module queries the inverted index for each valid entity pair and takes the intersection of the text block sets corresponding to the two entities, prioritizing the recall of text blocks that cover both entities.
[0114] if An empty result indicates that while the query may contain several entities, these entities lack stable structural connections in the graph, or the question itself is more inclined towards macro-level summaries, thematic descriptions, and cross-paragraph comparisons. In this case, the system enters global summary retrieval and can use the query entities as auxiliary signals to participate in the candidate node reordering.
[0115] The local entity retrieval module merges, deduplicates, and sorts candidate evidence. When the number of candidate evidence exceeds the upper limit k, the system gradually tightens the graph distance threshold, prioritizing the retention of entity pairs with closer structural relationships. During sorting, entity coverage is compared first, followed by entity frequency, thus prioritizing text blocks that simultaneously contain multiple core query entities and whose narratives revolve around these entities.
[0116] The global summary retrieval module vectorizes user queries and calculates similarity in a unified vector space composed of nodes at all levels of the summary tree. For summary questions, higher-level summary nodes are more likely to be recalled; for questions that require both overall background and specific factual details, mid-level summary nodes and lower-level text blocks can also be included in the candidate set.
[0117] In a preferred implementation, the system first recalls the top 2k candidate nodes based on similarity, and then calculates the entity weight based on the occurrence of the query entity in the candidate nodes and their child nodes. The weight of a high-level summary node is recursively accumulated from the weights of its child nodes, thus naturally reflecting the breadth of relevant entities covered by the summary node.
[0118] The evidence organization module formats local and global evidence separately. Local evidence is organized in the format of "Entity A - Entity B: Text Block Number and Text Content"; global evidence is organized in a hierarchical order of "High-level Summary - Mid-level Summary - Original Text Block". If the same text block is recalled by multiple entity pairs, the entity keys are merged to avoid redundant input and wasted context.
[0119] The generation module takes user queries, structured evidence, evidence source numbers, and answer format requirements as input into the large language model. Since entity constraints, hierarchical semantic recall, and evidence deduplication have already been completed in the retrieval phase, the generation model can generate answers based on more compact and explicit evidence.
[0120] The summarization model, embedding model, and generative model in this invention can be a locally deployed model or a large cloud-based model; the vector index library can use Faiss, Milvus, or other approximate nearest neighbor indexes; the graph storage can use NetworkX, Neo4j, graph databases, or ordinary key-value stores. These substitutions do not affect the core technical concept of this invention.
[0121] The incremental knowledge graph dual-path retrieval enhancement generation method of the present invention has at least the following beneficial effects:
[0122] First, it reduces the cost of building a knowledge base. This invention organizes the global semantics of long documents using a hierarchical summary tree and stores structural relationships using an entity co-occurrence knowledge graph. Compared to extracting complex relationships segment by segment, this reduces the number of model calls and the pressure of formatted output.
[0123] Second, improve the efficiency of incremental updates. When new content is appended to the end of a document, the system only recalculates the newly added leaf nodes, the rightmost summary node that is added, and the dirty nodes that propagate along the parent node, without performing a full reconstruction of the entire summary tree and historical graph.
[0124] Third, it improves the adaptability of retrieval strategies. This invention automatically selects local entity retrieval or global summary retrieval based on the query entity and its structural distance in the knowledge graph, which can simultaneously adapt to both fine-grained factual questions and macro-level summary questions.
[0125] Fourth, improve evidence density and interpretability. Local retrieval prioritizes recalling text blocks that simultaneously contain valid entity pairs, while global retrieval recalls semantic matching evidence across multiple levels of summary nodes and uses entity occurrence weights to assist in ranking, making the context input to the generation model more focused.
[0126] Fifth, maintain the traceability of evidence. Entity-to-text block indexes and text block-to-entity indexes enable structured graph relationships to be traced back to the original text evidence, facilitating response generation, source display, manual verification, and subsequent maintenance.
[0127] Sixth, it has strong scalability. This invention does not limit the specific summary model, embedding model, vector index library, and graph database type, and can be replaced with local models, cloud models, Faiss, Milvus, Neo4j, or other equivalent implementations depending on the deployment environment.
[0128] To validate this method, the experiment used Qwen 7B as the base model. On the InfiniteChoice and InfiniteQA long document question-answering datasets, its performance was compared with baseline methods GraphRAG, LightRAG, and RAPTOR in terms of question-answering effectiveness metrics (MET) and indexing time (IT). Their long text expansion capabilities were also tested. Data was collected and plotted into performance comparison bar charts and long text expansion fitting graphs, as shown in the attached figure. Figure 5 Appendix Figure 6 As shown in the figures, the experimental data all demonstrate the significant effect and gain of this method.
[0129] In summary, this invention combines hierarchical summary trees, lightweight knowledge graphs, incremental update mechanisms, and query category-adaptive dual-path retrieval to form a retrieval enhancement generation method for long document continuous update scenarios. This method can utilize summary trees to handle global semantic problems, as well as knowledge graphs and bidirectional indexes to handle local entity relationship problems, and reduces redundant computation costs through incremental updates.
Claims
1. A query-adaptive dual-path retrieval enhancement generation method, characterized by: Obtain the document to be processed, divide the document into blocks, and obtain a set of text blocks; Summarize nodes recursively according to the order of text blocks in the original text, construct a multi-level semantic index structure tree including leaf text block nodes and multi-level summary nodes, and establish vector indexes for nodes in the hierarchical summary tree; extract entities from each text block and construct block entity subgraphs, merge multiple block entity subgraphs into a global knowledge graph, and establish entity-to-text block indexes and text block-to-entity indexes; when new text is appended to the end of the document to be processed, the new text block is attached to the affected path of the existing hierarchical summary tree, and only the affected nodes are re-summarized, while the new entities and new relations are disambiguated and merged into the global knowledge graph; extract the query entity set for the user query, and filter valid entity pairs based on the structural distance of the query entity set in the global knowledge graph; when a valid entity pair exists, perform a local retrieval based on entity relations to obtain a local evidence set; when no valid entity pair exists, perform a global retrieval based on the hierarchical summary tree to obtain a global evidence set; input the local evidence set or the global evidence set into the generation model to generate an answer corresponding to the user query.
2. The method according to claim 1, characterized in that, A knowledge graph is constructed using a lightweight entity-co-occurrence relation extraction tool, avoiding frequent calls to the APIs of large models: for the i-th text block Extract the entity set If two entities co-occur within the same text block, sentence, or preset local window, a co-occurrence edge is established between the two entities. For repeated co-occurrence relationships, the weights of the corresponding co-occurrence edges are accumulated to obtain the text block. Corresponding block entity subgraph ,in It is the set of entity nodes extracted from the text block. It is a set of edges generated based on entity co-occurrence relationships.
3. The method according to claim 1, characterized in that, Construct a bidirectional index between entities and blocks: the entity-to-text-block index is used to record the set of text blocks I(e) in which entity e appears, and the text-to-entity index is used to record the set of entities E(c) contained in text block c; in local retrieval, candidate text blocks containing the query entity are located based on I(e); in reordering, the coverage of the query entity by the candidate text blocks is calculated based on E(c).
4. The method according to claim 1, characterized in that, The incremental update method for the digest tree, which re-summarizes only the affected nodes on the right, involves: reading the existing hierarchical digest tree cache and counting the number of existing leaf nodes. When the current number of text blocks n is not greater than When n is greater than n, reuse the existing hierarchical summary tree; At that time, the first The nth to nth text blocks are registered as new leaf nodes, and are preferentially attached to the rightmost unfilled summary node. New leaf nodes that cannot be attached are generated into new sibling summary nodes according to the preset number of merging. Summary nodes whose child node sets have changed are marked as dirty nodes, and the dirty markings are propagated to their parent nodes from bottom to top. The summary model is only called to regenerate the summary for dirty nodes.
5. The method according to claim 1, characterized in that, Dynamic retrieval routing based on effective entity pair structural distance filtering: Extracting the query entity set from user query q. ;like If empty, proceed with a global search; if If not empty, then calculate Any two entities , Shortest path distance in global knowledge graph G , will satisfy Add the entity pairs to the set of valid entity pairs Where h is the hop count threshold; when When not empty, enter local search, when If the value is empty, proceed with a global search.
6. The method according to claim 1, characterized in that, Local retrieval includes entity-aware ranking: calculating the entity coverage of candidate text block c. Calculate the frequency of the query entity in candidate text block c. ,in , This represents the number of times entity e appears in text block c; the local candidate set is sorted according to the order of entity coverage first and entity frequency second, and the top k text blocks are selected as the local evidence set.
7. The method according to claim 1, characterized in that, The global retrieval includes: recalling the top 2k candidate nodes with the highest similarity in the vector index of the hierarchical summary tree based on the query vector; if the user query contains a query entity, calculating the entity occurrence weight for the candidate nodes, where the entity occurrence weight of a leaf node is the cumulative number of times the query entity appears in that leaf node, and the entity occurrence weight of a summary node is the recursive sum of the entity occurrence weights of its child nodes; reordering the candidate nodes based on semantic similarity and entity occurrence weight, and selecting the top k candidate nodes as the global evidence set.
