Method and system for ultra-long document understanding based on neighborhood-aware context reconstruction
Patent Information
- Application Number
- CN202611227994.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-13
- Publication Date
- 2026-10-30
AI Technical Summary
在多跳问答、跨段落推理等复杂任务场景中,检索机制仅能依据用户问题与单个文本块的局部相关性筛选内容,无法识别、整合分散在文档不同位置的关联线索,导致关键推理链条断裂
[0021]与现有技术相比,本发明至少具有以下有益效果。
Smart Images

Figure CN123013908A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing technology, specifically relating to a method and system for understanding ultra-long documents based on neighborhood-aware context reconstruction. Background Technology
[0002] In recent years, large language models have made significant progress in the field of natural language processing, but they still face enormous challenges when dealing with single, extremely long documents (such as books, legal files, collections of research papers, financial reports, etc., whose text length exceeds the model's context window limit). Unlike retrieval scenarios involving multiple independent documents, processing single, extremely long documents requires fully capturing the local connections and logical dependencies within the text, thereby providing large language models with more coherent and logically complete input information to improve the accuracy of their responses.
[0003] Currently, existing technologies for processing ultra-long documents for large language models are mainly divided into two mainstream technical routes: context window expansion technology and block retrieval paradigm. At the same time, improvement schemes such as dynamic block optimization and graph structure modeling have emerged. Each technical solution has its own technical limitations and cannot simultaneously ensure the semantic integrity, long-distance dependency capture capability and computational efficiency of ultra-long document processing.
[0004] Among them, the context window expansion technique mainly optimizes the native Transformer architecture of large language models. By improving the attention calculation mechanism and optimizing the positional encoding method, it breaks through the fixed context length limit in the model pre-training stage and enables direct processing of ultra-long documents. The core principle of this technical approach is to reduce the computational complexity and memory overhead in long sequence input scenarios and adapt to the needs of ultra-long text input. Typical implementation methods include the YaRN scheme based on interpolation-extended rotational positional encoding, the LM-Infinite scheme that introduces a smooth scaling mechanism for attention weights, and the InfLLM scheme that uses sparse attention masks and hierarchical attention design. This type of technology does not require segmentation preprocessing of the original document and can completely preserve the global contextual information of the document. However, due to the inherent characteristics of the Transformer architecture, the computational complexity of self-attention increases quadratically with the text length. The longer the document, the greater the computational resources and memory overhead. It is prone to problems such as attention dilution and positional encoding deviation, making it difficult to accurately capture long-distance semantic dependencies in ultra-long documents. The deployment cost is high and the practicality is poor.
[0005] Chunk-based retrieval is currently the mainstream lightweight solution for processing ultra-long documents in the industry. Its core process is "chunk-retrieval-concatenation," requiring no modification to the native architecture of large language models and enabling the processing of ultra-long texts within a limited contextual resource budget. The typical process involves: first, dividing the ultra-long document into several independent text blocks; then, calculating the relevance score between the user's question and each text block using a retrieval algorithm, filtering highly relevant text blocks; and finally, concatenating the candidate text blocks and inputting them into a large language model to complete downstream tasks. Based on different retrieval principles, it is mainly divided into sparse retrieval, represented by the BM25 algorithm, and dense retrieval, based on semantic coding models such as MiniLM, BGE, and E5. The former is computationally fast and requires no training, while the latter can capture fine-grained semantic relationships. To address the semantic boundary fragmentation problem caused by traditional fixed-length chunking, existing technologies further propose dynamic chunking and selection (DCS) schemes. These schemes abandon fixed token segmentation rules, implement dynamic chunking based on text semantic units, and optimize the semantic coherence of candidate contexts through a "question-text block" selector. However, this only slightly alleviates the problem of local semantic fragmentation.
[0006] In addition, existing technologies have proposed a long document processing scheme based on graph structure modeling called GraphReader. This scheme extracts entities such as people, places, events, and concepts from documents through a large language model, as well as the relationships between entities such as ownership, causality, and temporal sequence. It constructs a document-level entity graph with entities as nodes and relationships as edges, transforming unstructured ultra-long text into a structured graph. Then, it retrieves relevant content of user questions by guiding graph traversal through a large language model, realizing the mining of cross-text block association information.
[0007] In summary, while existing technologies for processing extremely long documents can address the issue of large language models being unable to handle such texts to some extent, they still suffer from numerous core technical shortcomings in practical applications. These shortcomings fail to meet the demands for high-precision and high-efficiency processing of complex, extremely long documents. The specific shortcomings are as follows: First, there are serious problems with context fragmentation and broken reasoning chains. Whether it's the traditional fixed-block or dynamic-block retrieval paradigm, or conventional text processing solutions, they all essentially cut complete, long documents into multiple independent text segments, failing to model the semantic connections, logical dependencies, and textual references between these segments. In complex task scenarios such as multi-hop question answering and cross-paragraph reasoning, the retrieval mechanism can only filter content based on the local relevance between the user's question and a single text segment, unable to identify and integrate the scattered clues across different parts of the document, leading to broken key reasoning chains. Dynamic-block solutions only optimize text segmentation boundaries and alleviate local semantic fragmentation, failing to fundamentally address the core defect of missing inter-block connections. Ultimately, this results in incomplete input information for large language models, frequently leading to reasoning errors and missing key information in the answers. Second, the ability to capture long-distance dependencies is insufficient, failing to simultaneously capture both global and local semantic features. Ultra-long documents exhibit both long-distance topic associations and local positional continuity, but current technologies cannot simultaneously and accurately capture both types of features. Chunk-based retrieval solutions focus only on the independent relevance of a single text block to the user's question, completely ignoring cross-block and long-distance topic associations within the document; while context window expansion technology can cover the entire document, it suffers from attention dilution and positional bias, making it difficult to accurately locate long-distance semantic dependencies; GraphReader graph structure solutions focus only on modeling relationships between entities, neglecting the original neighborhood structure and narrative continuity of the text, and cannot fully restore the original semantic structure of the document. All existing solutions are unable to efficiently adapt to the complex semantic distribution features of ultra-long documents. Third, the inherent contradiction between computational efficiency and processing performance is irreconcilable, making it difficult to adapt to industrial application needs. Existing technologies generally suffer from the flaw of "high performance inevitably leads to high overhead, and high efficiency inevitably leads to low performance," failing to achieve a balance between performance and efficiency. While context window expansion technology and graph structured modeling technology can improve semantic integrity and long-distance capture capabilities, their computational complexity is extremely high. The time consumed in preprocessing and inference increases sharply with the document length, resulting in large hardware resource consumption and poor real-time performance, failing to meet the high-concurrency and low-latency usage requirements of the industrial sector. On the other hand, while lightweight solutions such as traditional block retrieval and dynamic block retrieval have low computational costs and are easy to deploy, they are limited by context fragmentation and the lack of long-distance dependencies, resulting in poor performance and insufficient inference accuracy in complex and ultra-long document understanding tasks.
[0008] Currently, there is no perfect and efficient solution to the technical pain points of existing ultra-long document processing technologies, such as information dispersion, broken reasoning chains, weak ability to capture long-distance dependencies, and the inability to balance efficiency and performance. Therefore, there is an urgent need to design a novel language model context processing scheme for single ultra-long documents that can reconstruct the document context relationships while maintaining the advantages of lightweight computing, accurately capture long and short-distance semantic features, and balance processing efficiency and reasoning performance. Summary of the Invention
[0009] To address the inherent problems of information dispersion, context fragmentation, and missing long-distance dependencies in the chunked retrieval paradigm, this invention proposes a method and system for understanding ultra-long documents based on neighborhood-aware context reconstruction. Through three core methods—two-layer neighborhood graph modeling, iterative dual-pool exploration, and budget-aware context reconstruction—this method organizes question-related information from ultra-long documents based on user question requirements and reconstructs it into a coherent input context suitable for understanding large language models, thereby improving the accuracy, robustness, and practicality of reading comprehension of ultra-long documents.
[0010] To achieve the above objectives, the technical solution of the present invention includes the following:
[0011] A method for understanding ultra-long documents based on neighborhood-aware context reconstruction, the method comprising: Divide the extremely long document into discrete text blocks and obtain the topic neighbors and physical neighbors of each text block; Based on the keyword relevance score between the user question and the text block, several text blocks are selected and sent to the initial global pool, and an empty frontier propagation pool is constructed; wherein, the score of the text block in the initial global pool is the keyword relevance score; Alternately select the highest-scoring text block from the initial global pool and the frontier propagation pool to add to the candidate text block set, and add the topic neighbors of the text block to the frontier propagation pool; wherein, the score of the topic neighbor in the frontier propagation pool is the semantic similarity score between the text block and the user question; Based on the semantic similarity score between the text block and the user question, a specified number of core text blocks are selected from the candidate text block set, and the core text blocks are expanded according to the physical neighbors of each core text block; An input context is generated based on the expanded core text block and other candidate text blocks in the candidate text block set. After embedding the user question and the input context into a pre-defined prompt word template, the answer corresponding to the user question is generated based on the large language model.
[0012] Furthermore, the topic neighbors and physical neighbors of each text block are obtained, including: Based on the keyword relevance scores between text blocks, obtain the topic neighbors of each text block; Based on the physical location of the text block in the long document, obtain the physical neighbors of each text block.
[0013] Furthermore, the highest-scoring text block is alternately selected from the initial global pool and the frontier propagation pool and added to the candidate text block set, and the topic neighbors of this text block are added to the frontier propagation pool, including: Select the text block with the highest keyword relevance score from the initial global pool. , This indicates the index of the text block in the initial global pool; Calculate the text block Semantic similarity score between user questions And will carry the semantic similarity score text blocks Add to the candidate text block set; The semantic similarity score Assign to this text block After the topic neighbor, the text block Thematic neighbors are sent into the cutting-edge dissemination pool; Select the text block with the highest semantic similarity score from the frontier propagation pool. Add to the candidate text block set. This indicates the index of the text block in the front propagation pool; Calculate the text block Semantic similarity score between user questions And will carry the semantic similarity score text blocks Add to the candidate text block set; The semantic similarity score Assign to this text block After the topic neighbor, the text block Thematic neighbors are sent into the cutting-edge dissemination pool; Re-execute the step of selecting the text block with the highest keyword relevance score from the initial global pool. The process continues until the number of text blocks in the candidate text block set reaches the set number.
[0014] Furthermore, after sending the topic neighbors into the frontier propagation pool, the method also includes: Determine whether the topic's neighbors already exist in the frontier propagation pool; For topic neighbors not present in the frontier propagation pool, their semantic similarity scores are calculated. The semantic similarity score is used as the neighbor score for that topic; where, ; For topic neighbors already existing in the frontier propagation pool, their original semantic similarity scores are compared with their semantic similarity scores. The results are compared, and the semantic similarity score with the higher score is selected as the new semantic similarity score for the topic's neighbors.
[0015] Furthermore, the core text blocks are expanded based on their physical neighbors, including: Obtain the boundary expansion ratio; Get core text block Physical neighbors, the physical neighbors including text blocks and text blocks , This indicates the index of a text block within a very long document; From text block Extract the last part of the boundary expansion ratio. From text block Extract the initial part of the boundary expansion ratio from it; The end part, the core text block Combined with this starting part, the expanded core text block is obtained.
[0016] Furthermore, an input context is generated based on the expanded core text block and other candidate text blocks in the candidate text block set, including: After removing duplicate segments from the expanded core text block and other candidate text blocks in the candidate text block set, the text blocks are sorted in ascending order according to their absolute position in the long document to obtain the reconstructed input context.
[0017] Furthermore, algorithms for calculating keyword relevance scores include the BM25 algorithm.
[0018] Furthermore, the process of generating the semantic similarity score includes: The user question and the text block are fed into a lightweight semantic matching model to obtain a semantic similarity score; wherein, the lightweight semantic matching model includes the MiniLM-L12-v2 model.
[0019] A system for understanding ultra-long documents based on neighborhood-aware context reconstruction, the system comprising: The two-layer neighborhood graph document representation module is used to divide ultra-long documents into discrete text blocks and obtain the topic neighbors and physical neighbors of each text block. The iterative dual-pool exploration and verification module is used to select several text blocks and send them into the initial global pool based on the keyword relevance score between the user question and the text blocks, and to construct an empty frontier propagation pool; wherein, the score of the text block in the initial global pool is the keyword relevance score; alternately, the text block with the highest score is selected from the initial global pool and the frontier propagation pool and added to the candidate text block set, and the topic neighbors of the text block are added to the frontier propagation pool; wherein, the score of the topic neighbors in the frontier propagation pool is the semantic similarity score between the text block and the user question; The budget-aware context reconstruction module is used to select a specified number of core text blocks from the candidate text block set based on the semantic similarity score between the text blocks and the user question, and expand the core text blocks according to the physical neighbors of each core text block; generate an input context based on the expanded core text blocks and other candidate text blocks in the candidate text block set, and after embedding the user question and the input context into a pre-set prompt word template, generate the answer corresponding to the user question based on the large language model.
[0020] A computer device, characterized in that the computer device comprises: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the ultra-long document understanding method based on neighborhood-aware context reconstruction as described above.
[0021] Compared with the prior art, the present invention has at least the following beneficial effects.
[0022] (1) The dual-layer neighborhood graph document representation module of the present invention alleviates the problem that traditional block retrieval cuts documents into isolated units and cannot simultaneously build long-range semantic associations and local positional continuity between modules, providing a structured basis for subsequent association clue mining. It represents documents as a dual-layer neighborhood graph that combines the topic layer and the physical layer. The topic layer connects distant blocks with similar topics to capture long-range dependencies, and the physical layer connects adjacent blocks to preserve local continuity.
[0023] (2) The iterative dual-pool exploration and verification module of the present invention proposes a dual-pool exploration strategy that alternately selects candidate blocks from the initial global pool and the frontier propagation pool. Combined with the relevance secondary verification mechanism, it can ensure global retrieval coverage, deeply explore local related content, and alleviate error propagation.
[0024] (3) Existing technologies are either high-cost and low-efficiency or high-efficiency and low-performance, and cannot solve the problem of information dispersion and improve understanding under the premise of lightweight design. To address this problem, the present invention adopts a lightweight design throughout the entire process, realizing a solution that does not require model training and whose inference latency is close to that of a pure retrieval solution. It significantly improves the accuracy and robustness of large language models in understanding ultra-long documents with low computational overhead. Attached Figure Description
[0025] Figure 1 A flowchart of a method for understanding ultra-long documents based on neighborhood-aware context reconstruction. Detailed Implementation
[0026] To enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, and to make the objectives, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0027] This invention provides a neighborhood-aware context reconstruction framework for reading comprehension of ultra-long documents using large language models. The framework first constructs a two-layer neighborhood graph of the ultra-long document, considering both long-range topic associations and local positional continuity. Then, it iteratively explores two pools to filter and verify the trust of relevant text blocks. Finally, through budget-aware selective expansion and original position rearrangement, fragmented retrieval blocks are reconstructed into a logically coherent input context, providing a complete and readable reading input for large language models (LLMs). The overall process is as follows: Figure 1 As shown.
[0028] The following will provide a detailed explanation of the specific implementation steps and corresponding structure of the framework.
[0029] 1. Two-layer neighborhood graph document representation module.
[0030] The core of this module lies in transforming a given extremely long document into a structured two-layer domain graph with semantic associations and positional dependencies. In this example, "extremely long text" refers to text exceeding a set threshold in length. Specifically, the extremely long document is first divided into discrete text blocks using a specific segmentation method, such as segmentation by a fixed number of tokens or recursive segmentation. Then, for each text block, its topic neighbors and physical neighbors are constructed, modeling the long-range topic relationships and local narrative continuity of the extremely long document. This module provides a structured foundation for subsequent context exploration and reconstruction. The constructed graph is saved to the local disk for reuse.
[0031] 1.1. Topic Neighbor Construction: Based on the topic relevance between text blocks, associations are established, connecting text blocks that are geographically distant but have similar topics in the document. This is used to capture cross-block, long-distance topic dependencies. Specifically, for each text block, this invention uses the BM25 algorithm to calculate the keyword relevance score between blocks. To ensure efficiency, this invention selects the K blocks with the highest scores to form the topic neighborhood.
[0032] 1.2. Physical Neighbor Construction: This involves establishing associations based on the physical location of text blocks within the original document, preserving their sequential adjacency to maintain the coherence of local context and the integrity of document reference. Specifically, for text blocks... Its physical neighbors are the text blocks that are adjacent to each other. With text blocks Only the usable side of the boundary blocks located at the beginning and end of the document is retained.
[0033] 2. Iterative dual-pool exploration and verification module.
[0034] This module accurately mines relevant text blocks based on a given user question and a pre-constructed two-layer neighborhood graph. Specifically, it employs an iterative dual-pooling exploration strategy to discover relevant text blocks, balancing global search coverage with local association depth. Simultaneously, during the exploration process, relevance verification is used to filter out noisy segments and mitigate error propagation. The exploration ends when the number of selected text blocks reaches a preset upper limit, ultimately yielding a set of candidate text blocks for subsequent context reconstruction.
[0035] 2.1 Construction of dual candidate pools.
[0036] After the user submits a question, based on the document segmentation results and the two-layer neighborhood graph, two independent candidate pools are constructed: The first is the initial global pool: based on the BM25 algorithm, the keyword relevance scores of all text blocks to the user's question are calculated as the initial relevance scores, and the text blocks are sorted in descending order of scores. Only a predetermined number of text blocks are retained to form the initial global pool, providing an initial source for global retrieval. The second is the frontier propagation pool: initialized to empty, it is used to store the topic neighbor text blocks updated through relevance propagation during the exploration process, providing a frontier source for local association mining.
[0037] 2.2 Iterative alternation block selection.
[0038] The text block selection operation is performed iteratively, with the candidate pool switching alternately during the iteration: in even-numbered iterations, the text block with the highest score is selected from the initial global pool; in odd-numbered iterations, the text block with the highest score is selected from the frontier propagation pool; the iteration count starts from 0, and the selected text block is added to the candidate set and does not participate in subsequent selections again. When the number of candidate text blocks reaches the upper limit set by this invention, the iterative block selection process terminates, and these selected text blocks are used as the context set for further reconstruction.
[0039] 2.3 Correlation verification and score propagation.
[0040] After iteratively selecting a text block, a lightweight semantic matching model, MiniLM-L12-v2, is used to perform a secondary relevance check, recalculating the semantic similarity score between the text block and the user's question as the verification score. For a verified text block, all its topic neighbors are traversed. If a neighbor has not yet been added to the frontier propagation pool, the current block's verification score is directly propagated to it, and it is added to the frontier propagation pool. If the neighbor already exists in the frontier propagation pool (e.g., explored from a previously verified text block), its existing score is compared with the newly transmitted verification score, and the larger of the two is retained as the neighbor's updated score. This score update method ensures that the frontier propagation pool always prioritizes recommending text blocks closely related to highly relevant blocks, allowing the exploration frontier to gradually expand from confirmed high-value regions to semantically adjacent regions, thereby filtering out low-relevance, misleading, and noisy text blocks and reducing the propagation of errors during the exploration process.
[0041] 3. Budget-aware context refactoring module.
[0042] Within a fixed context budget, this module reconstructs candidate text blocks obtained through iterative exploration to generate a logically coherent and grammatically ordered input context, mitigating information fragmentation caused by segmentation and retrieval. Specifically, firstly, candidate text blocks are sorted by validation score, and a predetermined number of text blocks with the highest scores are selected as core text blocks, prioritizing the integrity of high-value information; subsequently, selective boundary expansion and deduplication are performed on the core text blocks; finally, all candidate text blocks are concatenated according to the original document order to form the final input context.
[0043] 3.1 Selective boundary extension.
[0044] The core text block is locally expanded by supplementing only the boundary text fragments of its physical neighbors, thus restoring the local contextual continuity of the core text block. The boundary expansion ratio can be adaptively adjusted. This process can be formally expressed as the following formula: in To expand the proportion of the boundary, The concatenation operator represents the suffix and the prefix, respectively, and they are used to precisely extract the suffix and prefix from the corresponding text blocks. The text content at the end and beginning of the proportion.
[0045] 3.2 Position rearrangement and splicing.
[0046] The expanded core text block and other non-core candidate text blocks are stripped of duplicate fragments, sorted in ascending order according to their absolute position in the original document, and concatenated in sequence to form the final coherent context. Finally, the reconstructed context and user questions are combined with the user questions using a pre-defined prompt word template to form a standard input format, which is then input into the LLM to complete the understanding of the extremely long document and generate the corresponding answers to the user questions.
[0047] Below, this invention undergoes comprehensive performance verification using standardized experimental settings. Experiments are conducted on six mainstream ultra-long document question-answering benchmark datasets, covering both single-hop and multi-hop question-answering scenarios. Specifically, these datasets are Factrecall, MultifieldQA, Loogle_SD, Loogle_CR, Loogle_MIR, and HotpotWikiQA, with input lengths ranging from 16k to 256k tokens. The Llama-3-8B-Instruct large language model is selected as the experimental model, and the average F1 score across the six datasets is used to quantify the performance. Based on this invention, the time overhead of different methods in outputting answers with a text length of 16k is compared. Table 1 Performance and Time Cost The performance and time cost of different methods are shown in Table 1.
[0048] Ablation Experiment Setup: To verify the necessity and effectiveness of the three core inventive points of this invention, and to compare the contribution of each component to the overall system performance, this invention sets up three sets of control ablation experiments, conducting tests in the text length range of 16k to 256k tokens. The three ablation schemes are as follows: (a) w / o correlation verification: No secondary correlation verification is performed on the selected text block in the iteration, and the basic iterative exploration process is retained; (b). w / o dual-source exploration, replacing the iterative dual-pool alternating exploration with single-source exploration (relying only on the frontier pool), canceling the alternating selection logic of the initial global pool and the frontier propagation pool, relying only on the frontier propagation pool for text block filtering, abandoning global retrieval prior, and completing candidate block exploration only through local relevance propagation; (c). with / o two-layer neighborhood graph structure, respectively retaining only the physical neighbor layer and modeling only the physical adjacency relationship of text blocks; retaining only the topic neighbor layer and completely removing the physical neighbor association, modeling only the topic similarity relationship. Table 2 Ablation Experiment Results The results of the ablation experiment are shown in Table 2.
[0049] In summary, through comparison and analysis of the above experimental results, the innovative technical solution of the present invention demonstrates significant technical effects in the following aspects.
[0050] 1. Two-layer neighborhood graph document representation module.
[0051] Beneficial technical effects: It can alleviate the problems of information dispersion and broken inter-block association caused by block retrieval, and re-associate isolated text blocks into a complete semantic topology structure. At the same time, it takes into account long-range topic dependence and local narrative continuity. It is built with a pure lightweight algorithm, without LLM call overhead, and can be pre-computed offline and reused online, adapting to ultra-large-scale and ultra-long documents.
[0052] Experimental data supports the following: Single-layer structures using only the physical layer or only the topic layer significantly outperform two-layer structures across the entire 16k-256k token length range; the complete structure shows a score fluctuation of less than 2 percentage points across the 16k-256k token text input length range.
[0053] 2. Iterative dual-pool exploration and verification module.
[0054] Beneficial technical effects: It avoids the one-sidedness of traditional retrieval relying solely on global similarity for coarse screening, and also avoids getting stuck in local semantic narrow areas, accurately locating related clues scattered in different locations; relevance verification effectively filters low-relevance noise blocks, preventing error propagation, and significantly improving retrieval accuracy, especially in very long documents; iterative exploration automatically aggregates cross-block related information, supplementing the reasoning chain missing in traditional retrieval.
[0055] Experimental data supports the following: After removing the correlation verification, the performance drops by nearly 5 absolute percentage points at a length of 256k tokens; After replacing the dual-pool alternation strategy with single-source exploration, the performance drops by 2.71% relative at a length of 256k tokens; The complete mechanism enables the present invention to improve performance by 23.40% compared to DCS and 15.10% compared to GraphReader at a length of 16k tokens.
[0056] 3. Budget-aware context refactoring module.
[0057] Beneficial technical effects: It reconstructs discrete retrieval blocks into logically coherent and grammatically correct input contexts, alleviating semantic confusion caused by direct splicing, achieving the optimal balance between information density and coherence within a fixed context window, intuitively solving the problem of "fragments retrieved but the model cannot understand them", and directly improving question answering accuracy.
[0058] Experimental data support this finding: On six mainstream ultra-long document question-answering datasets of varying lengths, the average F1 score of this invention significantly outperforms other existing methods across all input lengths.
[0059] Although the present invention has been described through the above preferred embodiments, those skilled in the art will understand that various modifications in form and detail can be made therein without departing from the spirit and scope of the invention. Therefore, the scope of protection of the present invention should be defined by the appended claims.
Claims
1. A method for understanding ultra-long documents based on neighborhood-aware context reconstruction, characterized in that, The method includes: Divide the extremely long document into discrete text blocks and obtain the topic neighbors and physical neighbors of each text block; Based on the keyword relevance score between the user question and the text block, several text blocks are selected and sent to the initial global pool, and an empty frontier propagation pool is constructed; wherein, the score of the text block in the initial global pool is the keyword relevance score; Alternately select the highest-scoring text block from the initial global pool and the frontier propagation pool to add to the candidate text block set, and add the topic neighbors of the text block to the frontier propagation pool; wherein, the score of the topic neighbor in the frontier propagation pool is the semantic similarity score between the text block and the user question; Based on the semantic similarity score between the text block and the user question, a specified number of core text blocks are selected from the candidate text block set, and the core text blocks are expanded according to the physical neighbors of each core text block; An input context is generated based on the expanded core text block and other candidate text blocks in the candidate text block set. After embedding the user question and the input context into a pre-defined prompt word template, the answer corresponding to the user question is generated based on the large language model.
2. The method according to claim 1, characterized in that, Retrieve the topic neighbors and physical neighbors of each text block, including: Based on the keyword relevance scores between text blocks, obtain the topic neighbors of each text block; Based on the physical location of the text block in the long document, obtain the physical neighbors of each text block.
3. The method according to claim 1, characterized in that, Alternately select the highest-scoring text block from the initial global pool and the frontier propagation pool to add it to the candidate text block set, and add the topic neighbors of this text block to the frontier propagation pool, including: Select the text block with the highest keyword relevance score from the initial global pool. , This indicates the index of the text block in the initial global pool; Calculate the text block Semantic similarity score between user questions And will carry the semantic similarity score text blocks Add to the candidate text block set; The semantic similarity score Assign to this text block After the topic neighbor, the text block Thematic neighbors are sent into the cutting-edge dissemination pool; Select the text block with the highest semantic similarity score from the frontier propagation pool. Add to the candidate text block set. This indicates the index of the text block in the front propagation pool; Calculate the text block Semantic similarity score between user questions And will carry the semantic similarity score text blocks Add to the candidate text block set; The semantic similarity score Assign to this text block After the topic neighbor, the text block Thematic neighbors are sent into the cutting-edge dissemination pool; Re-execute the step of selecting the text block with the highest keyword relevance score from the initial global pool. The process continues until the number of text blocks in the candidate text block set reaches the set number.
4. The method according to claim 3, characterized in that, After sending the topic's neighbors into the frontier propagation pool, the method further includes: Determine whether the topic's neighbors already exist in the frontier propagation pool; For topic neighbors not present in the frontier propagation pool, their semantic similarity scores are calculated. The semantic similarity score is used as the neighbor score for that topic; where, ; For topic neighbors already existing in the frontier propagation pool, their original semantic similarity scores are compared with their semantic similarity scores. The results are compared, and the semantic similarity score with the higher score is selected as the new semantic similarity score for the topic's neighbors.
5. The method according to claim 1, characterized in that, The core text blocks are expanded based on their physical neighbors, including: Obtain the boundary expansion ratio; Get core text block Physical neighbors, the physical neighbors including text blocks and text blocks , This indicates the index of a text block within a very long document; From text block Extract the last part of the boundary expansion ratio. From text block Extract the initial part of the boundary expansion ratio from it; The end part, the core text block Combined with this starting part, the expanded core text block is obtained.
6. The method according to claim 1, characterized in that, The input context is generated based on the expanded core text block and other candidate text blocks in the candidate text block set, including: After removing duplicate segments from the expanded core text block and other candidate text blocks in the candidate text block set, the text blocks are sorted in ascending order according to their absolute position in the long document to obtain the reconstructed input context.
7. The method according to claim 1, characterized in that, Algorithms for calculating keyword relevance scores include the BM25 algorithm.
8. The method according to claim 1, characterized in that, The process of generating the semantic similarity score includes: The user question and the text block are fed into a lightweight semantic matching model to obtain a semantic similarity score; wherein, the lightweight semantic matching model includes the MiniLM-L12-v2 model.
9. A system for understanding ultra-long documents based on neighborhood-aware context reconstruction, characterized in that, The system includes: The two-layer neighborhood graph document representation module is used to divide ultra-long documents into discrete text blocks and obtain the topic neighbors and physical neighbors of each text block. The iterative dual-pool exploration and verification module is used to select several text blocks and send them into the initial global pool based on the keyword relevance score between the user question and the text blocks, and to construct an empty frontier propagation pool; wherein, the score of the text block in the initial global pool is the keyword relevance score; alternately, the text block with the highest score is selected from the initial global pool and the frontier propagation pool and added to the candidate text block set, and the topic neighbors of the text block are added to the frontier propagation pool; wherein, the score of the topic neighbors in the frontier propagation pool is the semantic similarity score between the text block and the user question; The budget-aware context reconstruction module is used to select a specified number of core text blocks from the candidate text block set based on the semantic similarity score between the text blocks and the user question, and expand the core text blocks according to the physical neighbors of each core text block; generate an input context based on the expanded core text blocks and other candidate text blocks in the candidate text block set, and after embedding the user question and the input context into a pre-set prompt word template, generate the answer corresponding to the user question based on the large language model.
10. A computer device, characterized in that, The computer device includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the method for understanding ultra-long documents based on neighborhood-aware context reconstruction as described in any one of claims 1-8.
