Long document processing method and system based on multi-agent collaborative reasoning
By employing a multi-agent collaborative reasoning approach, documents are segmented, divided into blocks, and processed using sliding windows. Formatted local reasoning results are generated and a global summary is performed, solving the problems of low efficiency and semantic incoherence in long document processing for large language models. This achieves efficient and complete document understanding and answer generation.
Patent Information
- Application Number
- CN202511055580.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2025-11-07
AI Technical Summary
Existing large language models struggle to directly handle tasks involving multiple segments or extremely long inputs, especially in application scenarios involving long-distance dependencies, cross-segment reasoning, and global summarization. Furthermore, existing block aggregation methods lack cross-block information integration and global reasoning mechanisms, resulting in semantic incoherence and incomplete reasoning.
A multi-agent collaborative reasoning method is adopted to segment and block the document, generate formatted local reasoning results, and generate a complete answer by integrating and summarizing global reasoning. The sliding window strategy is used to preserve semantic coherence, and asynchronous concurrency is combined to improve processing efficiency.
It improves the efficiency and quality of document processing, generates semantically coherent and complete answers through multi-agent collaborative reasoning, and reduces redundant calculations and information loss.
Smart Images

Figure E13728A9-6583-45E2-87E8-16CB7FA27A20 
Figure E55D0289-150F-494F-94F7-355FD813C57A
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, in particular to a long document processing method and system based on multi-agent collaborative reasoning. BACKGROUND
[0002] With the deepening of globalization and the booming development of artificial intelligence technology, humanity is in an unprecedented era of information explosion. Under this background, how to efficiently process and understand super-long documents has become one of the key challenges in information acquisition and knowledge integration. The super-long document processing task aims to extract valuable information from single or multiple documents with large volume and complex structure, and generate coherent and accurate output such as summaries, answers or analysis reports to help users quickly grasp the core content of massive information. In recent years, with the rapid development of pre-training large language models, large language models have shown excellent language understanding and generation capabilities in single-turn question answering, text generation, and dialogue tasks. However, due to the limitation of the context window length of the model architecture, i.e. the maximum number of tokens input at a time, current large language models are difficult to directly process tasks that span multiple segments or super-long inputs, especially in application scenarios involving long-distance dependencies, cross-segment reasoning and global summarization.
[0003] There are mainly two ways to solve the context limitation problem. One method is to change the structure of the large model and optimize the architecture to improve the context ability of the large model, such as sparse attention mechanism, encoding extrapolation, etc. This method often requires retraining the model and may exacerbate the model's illusion of text details. The other method is to develop at the agent level and use block aggregation, text compression and other means to let the large model process the text multiple times to grasp the key information.
[0004] Although the existing block aggregation, text compression and other methods have alleviated the context limitation problem to some extent, these solutions mostly rely on single-model block-by-block processing and lack mechanisms for cross-block information integration and global reasoning, which can easily cause semantic discontinuity and incomplete reasoning. In addition, with the improvement of model capabilities, how to more efficiently and modularly allocate reasoning tasks, reduce redundant calculations and optimize the utilization of large models has become a problem that needs to be solved in this field. SUMMARY
[0005] In view of the deficiencies in the prior art, the present application proposes a long document processing method and system based on multi-agent collaborative reasoning to solve the technical problems of low efficiency of single-model serial processing and global processing failure caused by limited context window in the prior art.
[0006] The technical solution adopted by the present application is a long document processing method and system based on multi-agent collaborative reasoning.
[0007] In a first implementation manner, comprising: segmenting and blocking the input original document, dividing the document into multiple document blocks according to a preset length limit; performing an inference task on each of the document blocks, and generating adjacent document blocks containing formatted local inference results according to information related to the problem to be solved in the text within the document blocks; integrating multiple adjacent document blocks to uniformly output a paragraph-level inference result; performing global inference summarization on the inference result to generate a complete answer to the user's question.
[0008] Further, segmenting and blocking the input original document, dividing the document into multiple document blocks according to a preset length limit, comprising: dividing the original document into logically complete semantic units based on the natural structure of the document; splicing the logical units into document blocks according to a preset length limit.
[0009] Further, dividing the original document into logically complete semantic units based on the natural structure of the document, further comprising: when the length of the logical unit exceeds the set threshold, using a sliding window to divide it, and according to the set threshold, setting an overlap ratio for the logical unit exceeding the set threshold, and then segmenting according to the preset model processing upper limit length.
[0010] Further, performing an inference task on each of the document blocks, and generating adjacent document blocks containing formatted local inference results according to information related to the problem to be solved in the text within the document blocks, comprising: extracting text segments directly related to the problem to be solved within the document block; identifying keywords within the text segment by semantic matching capability; focusing on problem-related sentences through attention mechanism; simulating human logic to generate structured inference chains based on the extracted problem-related sentences; the structured inference chain includes: relevant basis, inference process and intermediate conclusion.
[0011] Further, integrating multiple adjacent document blocks to uniformly output a paragraph-level inference result, comprising: generating a text vector according to the adjacent document blocks; calculating the vector similarity of the text vector; determining whether the vector similarity is greater than a set threshold interval, if greater than the set threshold interval, determining the current adjacent document block as a redundant conclusion, if within the set threshold interval, triggering context consistency verification, outputting a verified conclusion list, if less than the set threshold interval, determining the current adjacent document block as an independent conclusion; rearranging the redundant conclusion, the conclusion list and the independent conclusion according to their appearance order in the original text, and integrating them into a reasoning result.
[0012] Further, triggering context consistency verification, outputting a verified conclusion list, including: identifying the contradiction relationship between the adjacent document blocks as a detection result, the contradiction relationship including time sequence reversal, condition mutual exclusion and term definition conflict; verifying the unit uniformity and numerical compatibility of numerical conclusions as a detection result; verifying the coherence of the step sequence in the verification process as a detection result; and generating a conflict marker list according to the detection result; extracting the adjacent document blocks associated with the conflict marker list, and generating a reordered conclusion list according to a preset weight distribution rule.
[0013] Further, the reasoning result is globally summarized to generate a complete answer to the user's question, including: extracting a structured list of core facts from the reasoning result; building cross-paragraph logical relationships of the structured list through thought chain prompts; reorganizing targeted answers according to user questions, including: locating problem keywords; prioritizing related facts; adjusting the degree of detail and brevity of answers according to the problem requirements; generating an answer framework according to the related facts and the degree of detail and brevity of answers; binding the key conclusions in the answer framework with the source paragraph identifier; outputting a complete answer with source markers.
[0014] In combination with the first implementation manner, in the second implementation manner, a long document processing system based on multi-agent collaborative reasoning is provided, characterized in that it comprises: a document preprocessing module for segmenting and blocking the input original document, dividing the document into multiple document blocks according to a preset length limit; an analysis agent configured to perform an inference task on each of the document blocks generated by the document preprocessing module, and generate adjacent document blocks containing formatted local inference results according to information related to the problem to be solved in the text within the document blocks; a consolidation agent configured to consolidate the adjacent document blocks generated by the analysis agent, and output an inference result at a paragraph level; a summary agent configured to perform a global inference summary on the inference result output by the consolidation agent, and generate a complete answer to the user question.
[0015] In the third implementation manner, in combination with the first implementation manner, a computer device is provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements all steps of the long document processing method based on multi-agent collaborative inference when executing the program.
[0016] In the fourth implementation manner, in combination with the first implementation manner, a computer readable storage medium is provided, which stores a program, and the program implements all steps of the long document processing method based on multi-agent collaborative inference when being executed by a computing device.
[0017] According to the above technical solution, the present application has the following beneficial technical effects: 1. The long document is divided into units that can be processed by the model by means of segmentation, blocking and sliding window overlap mechanism, the semantic coherence is preserved, and the processing efficiency of the document is improved by combining multi-agent asynchronous concurrency.
[0018] 2. The structured inference chain is generated by the analysis agent, the similarity calculation and conflict detection are performed by the consolidation agent, the global logical chain is constructed by the summary agent, the complete answer with source mark is output, and the quality of the document processing is improved. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the specific embodiments or prior art, the drawings needed in the specific embodiments or prior art description will be briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn according to the actual proportions.
[0020] Figure 1 a method flowchart of the embodiment 1 of the present application; Figure 2 a system structure diagram of the embodiment 2 of the present application. DETAILED DESCRIPTION
[0021] The embodiments of the technical solutions of the present application will be described in detail below with reference to the drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present application, and therefore only serve as examples, but cannot limit the protection scope of the present application.
[0022] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in the present application should be understood as the usual meaning understood by the skilled person in the field to which the present application belongs.
[0023] Embodiment 1 The present embodiment provides a long document processing method based on multi-agent collaborative reasoning, and the working principle of embodiment 1 is described in detail as follows: The flowchart of the method of the present embodiment is shown in Figure 1 , which includes: Segmenting and blocking the input original document, dividing the document into multiple document blocks according to the preset length limit, and cutting the paragraph when its length exceeds the set threshold, to ensure semantic coherence; Performing reasoning tasks on each of the document blocks, generating adjacent document blocks containing formatted local reasoning results according to the text in the document blocks and the information related to the problem to be solved; Integrating multiple adjacent document blocks to output the reasoning results at the paragraph level; Performing global reasoning summary on the reasoning results of all paragraphs to generate complete answers to user questions.
[0024] Further, the input original document can include various file formats, including txt, docx, pdf and other common document formats. Before segmenting and blocking the input original document, it also includes classification processing according to the file suffix, and then the next blocking processing is performed after the input original document is converted into pure text form.
[0025] In the present embodiment, the paragraph is preliminarily divided based on a flexible blocking strategy, and then spliced into blocks according to a preset block size threshold. When the length of the paragraph is greater than the set threshold, the paragraph is cut into multiple blocks using a sliding window cutting strategy, i.e. a longer paragraph is cut into multiple blocks for processing. The advantage of this strategy is that by setting a reasonable window overlap ratio, the semantic fragmentation problem caused by block cutting is effectively avoided, and the model's ability to perceive context during local reasoning is enhanced.
[0026] In the present embodiment, further segmenting and blocking the input original document, dividing the document into multiple document blocks according to the preset length limit, includes: The segmentation based on the natural structure of the document (including line breaks and paragraph marks) divides the original document into logically complete units, and preserving the original paragraph structure can avoid destroying the context coherence and ensure that the text processed by each agent has an independent semantic basis. For the setting of window size and overlap length, the model context length used in this embodiment is 32768 tokens, which is approximately equal to 32768 English single characters or 54610 Chinese characters. Since the total number of input and output tokens in a single inference of a large model cannot exceed the context length, in order to ensure that the model has enough context to output the structured information required for inference and grasp finer-grained document details, the sliding window strategy is used for segmentation in this embodiment, with a window size of 1000 tokens and an overlap length of 50 tokens.
[0027] Based on the segmentation, the logically complete units are spliced into document blocks according to the preset length limit, i.e., the context window size of the model. For logically complete units with a window size exceeding 1000 tokens, sliding window segmentation is used to avoid single-block text exceeding the processing capacity of the model, and window overlap is used to reduce semantic fragmentation.
[0028] In this embodiment, further based on the natural structure of the document, the original document is divided into logically complete units, which further include: When the length of the logically complete unit exceeds the set threshold, it is divided by a sliding window to ensure semantic coherence. For the logically complete unit exceeding the set threshold, an overlap ratio is set according to the set threshold, and the document is segmented according to the preset model processing upper limit length to reduce information loss caused by semantic boundary fragmentation. In this embodiment, the sliding window overlap design solves the problem of block boundary information loss and ensures the semantic integrity of long paragraphs.
[0029] In this embodiment, further, each document block is executed for an inference task, and based on the relevant information of the text in the document block and the problem to be solved, adjacent document blocks containing formatted local inference results are generated, including: Extracting a text segment in the document block directly related to the problem to be solved; Using the semantic matching capability of a large language model to identify keywords in the text segment; Focusing on problem-related sentences through an attention mechanism; Simulating human logic to generate a structured inference chain based on the extracted problem-related sentences; The structured inference chain includes relevant basis, inference process, and intermediate conclusion. The relevant basis includes locating supportive content within the block; the inference process includes step-by-step deduction; and the intermediate conclusion includes generating an answer for the current block. Integrate the structured inference chain into the adjacent document block.
[0030] In this embodiment, the structured inference chain can enhance the traceability of the conclusion.
[0031] Further, in this embodiment, the plurality of adjacent document blocks are integrated to output the inference result at the paragraph level, including: using a pre-trained model to generate a text vector according to the adjacent document blocks; According to the cosine similarity algorithm, the vector similarity of the text vector is calculated. Determine whether the vector similarity is greater than a set threshold interval, if greater than the set threshold interval, the current adjacent document block is determined as a redundant conclusion, if within the set threshold interval, trigger context consistency verification, output the verified conclusion list and conflict resolution record, if less than the set threshold interval, the current adjacent document block is determined as an independent conclusion. The redundant conclusion, conclusion list and independent conclusion are rearranged according to their appearance order in the original text and integrated into the inference result; the paragraph-level structured object includes paragraph identification, semantically coherent paragraph text, support block ID list and conflict resolution record. In this embodiment, the similarity calculation automatically identifies redundant conclusions and conflict conclusions, which can reduce the manual verification cost and improve the efficiency of cross-block integration.
[0032] In this embodiment, further, trigger context consistency verification, output the verified conclusion list, including: Logical conflict detection: identify the contradiction relationship between the adjacent document blocks as the detection result, the contradiction relationship includes time sequence reversal, condition mutual exclusion and term definition conflict; Numerical consistency detection: check the unit uniformity and numerical compatibility of the numerical conclusion as the detection result; Sequential contradiction detection: verify the coherence of the step sequence in the process description as the detection result; And generate a conflict marker list according to the detection result; Extract the adjacent document blocks associated with the conflict marker list, and generate a reordered conclusion list according to a pre-set weight distribution rule.
[0033] In this embodiment, through the above conflict detection, cross-block contradictions can be solved to ensure the consistency of the paragraph conclusion.
[0034] In this embodiment, further, the inference result is globally summarized to generate a complete answer to the user's question, including: extracting core facts from the inference result to generate a structured fact list; generate a global logical chain, i.e., a coherent global argument text, by analyzing cross-paragraph logical relationships in the structured fact list through thought chain prompt words; locate problem keywords according to the user question and the global logical chain, and reorganize the answer framework to adjust the content priority and the degree of detail and omission, to generate an answer framework matching the user question; mark the source paragraph identification of the key conclusion; output a complete answer or a summary covering the entire text.
[0035] locate problem keywords according to the user question and the global logical chain, and reorganize the answer framework to adjust the content priority and the degree of detail and omission, to generate an answer framework matching the user question, including: parse the core demand words in the question, mark the corresponding content position in the global logical chain, and generate a keyword mapping table; top the relevant conclusions in the keyword mapping table, and sort the conclusion list by priority; adjust the degree of detail and omission of the conclusion list according to the user's question requirements, delete the modifying description if a brief answer is needed, and enhance the difference expression if a comparison is needed, and output the simplified conclusion set; reorganize the simplified conclusion set and the conclusion list into a coherent text framework, supplement logical conjunctions, and generate an answer framework that strictly matches the question; attach the source paragraph to each conclusion in the answer framework to generate a complete answer with source markers.
[0036] In this embodiment, by locating problem keywords, prioritizing related facts, and adjusting the degree of detail and omission as needed, the answer framework is dynamically reorganized, improving the relevance of the answer.
[0037] Embodiment 2 In combination with the long document processing method based on multi-agent collaborative reasoning provided in Embodiment 1, a long document processing system based on multi-agent collaborative reasoning is provided in Embodiment 2, as shown in the system structure diagram Figure 2 The document preprocessing module is configured to segment and block the input original document, and divide the document into multiple document blocks according to a preset length limit. The analysis agent is configured to perform an inference task on each document block generated by the document preprocessing module, and generate adjacent document blocks containing formatted local inference results according to the text in the document block and the information related to the problem to be solved. In the analysis agent processing stage, since the time-consuming of calling the large model API is mainly concentrated in waiting for the response of external resources, the system uses asynchronous programming means to initiate API requests in batches, and realizes concurrent inference of multiple document blocks through non-blocking response waiting, which can improve CPU utilization and thus shorten the inference time.
[0038] An integration agent is configured to integrate the adjacent document blocks generated by the analysis agent, and output a reasoning result at a paragraph level. A summary agent is configured to perform global reasoning and summarization on the reasoning result output by the integration agent, and generate a complete answer to the user question.
[0039] The integration agent and the summary agent work together through guided prompt words and thought chain prompts. The guided prompt words explicitly require the integration agent and the summary agent to combine the input reasoning process, remove redundant information, merge conflicting content, and perform result reasoning through prompt word design. The thought chain prompt guides the model to explicitly output the step-by-step reasoning process in the prompt, rather than directly giving the answer.
[0040] Embodiment 3 This embodiment includes a computer device including a memory and a processor, the memory storing a computer program, and the processor executing the program to implement all steps of the method described in embodiment 1.
[0041] Embodiment 4 This embodiment includes a computer-readable storage medium storing a program, and the program, when executed by a computing device, is configured to implement all steps of the method described in embodiment 1.
[0042] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application, and they should be covered in the scope of the claims and the specification of the present application.
Claims
1. A long document processing method based on multi-agent collaborative reasoning, characterized in that, The method comprises the following steps: segmenting and blocking the input original document, dividing the document into multiple document blocks according to a preset length limit; performing an inference task on each document block, generating adjacent document blocks containing formatted local inference results according to the information related to the problem to be solved in the text within the document block; integrating multiple adjacent document blocks to uniformly output paragraph-level inference results; performing global inference summarization on the inference results to generate a complete answer to the user's question. 2.The long document processing method based on multi-agent collaborative reasoning according to claim 1, wherein, The method comprises the following steps: segmenting and blocking the input original document, dividing the document into multiple document blocks according to a preset length limit, which comprises: dividing the original document into logically complete semantic units based on the natural structure of the document; 3.The long document processing method based on multi-agent collaborative reasoning according to claim 2, wherein, splicing the logical units into document blocks according to a preset length limit. The method of dividing the original document into logically complete semantic units based on the natural structure of the document further comprises:
4. The long document processing method based on multi-agent collaborative reasoning according to claim 1, characterized in that, when the length of the logical unit exceeds the set threshold, it is divided by a sliding window, and the logical unit exceeding the set threshold is segmented according to the set threshold overlap ratio and the preset model processing upper limit length. The method of performing an inference task on each document block, generating adjacent document blocks containing formatted local inference results according to the information related to the problem to be solved in the text within the document block, comprises: extracting the text segment directly related to the problem to be solved within the document block; identifying keywords within the text segment; focusing on problem-related sentences through attention mechanism; generating a structured inference chain based on the extracted problem-related sentences to simulate human logic; the structured inference chain includes relevant basis, inference process and intermediate conclusion; 5. The long document processing method based on multi-agent collaborative reasoning according to claim 1, characterized in that, integrating the structured inference chain into the adjacent document block. The method of integrating multiple adjacent document blocks to uniformly output paragraph-level inference results comprises: generating a text vector according to the adjacent document block; calculating the vector similarity of the text vector; determining whether the vector similarity is greater than a set threshold interval, if it is greater than the set threshold interval, the current adjacent document block is determined as a redundant conclusion, if it is within the set threshold interval, the context consistency verification is triggered, and the conclusion list after verification is output, if it is less than the set threshold interval, the current adjacent document block is determined as an independent conclusion; 6. The long document processing method based on multi-agent collaborative reasoning according to claim 5, characterized in that, rearranging the redundant conclusion, conclusion list and independent conclusion according to their appearance order in the original text, and integrating them into the inference result. The method of triggering context consistency verification and outputting the verified conclusion list comprises: identifying the contradiction relationship between the adjacent document blocks as the detection result, which includes time sequence reversal, condition mutual exclusion and term definition conflict; checking the unit uniformity and numerical compatibility of numerical conclusions as the detection result; verifying the coherence of the step sequence in the process description as the detection result; and generating a conflict marker list according to the detection result; 7. The long document processing method based on multi-agent collaborative reasoning according to claim 1, characterized in that, extracting the adjacent document blocks associated with the conflict marker list and generating a reordered conclusion list according to the preset weight distribution rule. The method of performing global inference summarization on the inference results to generate a complete answer to the user's question comprises: extracting core facts from the inference results to generate a structured fact list; generating global logical chains by analyzing cross-paragraph logical relations in the structured fact list through thought chain prompt words; locating problem keywords and reorganizing answer frameworks according to user questions and the global logical chains to generate answer frameworks matching user questions; marking source paragraph identification of key conclusions; outputting complete answers or summaries covering the entire text.
8. A multi-agent collaborative reasoning based long document processing system for implementing the method of any one of claims 1 to 7. The method comprises the following steps: a document preprocessing module is used to segment and block the input original document, and the document is divided into multiple document blocks according to a preset length limit; an analysis agent is used to perform an inference task on each document block generated by the document preprocessing module, and generate adjacent document blocks containing formatted local inference results according to the information related to the problem to be solved in the text in the document block; an integration agent is used to integrate the adjacent document blocks generated by the analysis agent, and uniformly output inference results at the paragraph level; a summary agent is used to perform global inference summarization on the inference results output by the integration agent, and generate complete answers to user questions.
9. A computer device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor executes the program to implement all the steps of the method of any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a program, and the program is executed by the computing device to implement all the steps of the method of any one of claims 1 to 7.
Citation Information
Cited By
Multi-agent collaborative knowledge reasoning system based on large language model
CN121615675A
A Multi-Agent Collaborative Knowledge Reasoning System Based on a Large Language Model
CN121615675B
Evaluation data generation method of retrieval enhancement generation system and electronic equipment
CN121724163A
Method for generating evaluation data for a search enhancement generation system and electronic device
CN121724163B
A method and system for processing long documents
CN122364436A
