Long context retrieval enhancement generation method, apparatus, device, medium and product

CN123012154APending Publication Date: 2026-10-30CHINA CONSTRUCTION INSTALLATION GROUP (LIAONING) CONSTRUCTION CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611517267.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0004]本申请的目的是提供一种长上下文检索增强生成方法、装置、设备、介质及产品,可以解决现有技术中的检索增强生成方法存在长上下文检索增强生成推理计算成本高、效率低的技术问题

Benefits of technology

本申请提供了一种长上下文检索增强生成方法、装置、设备、介质及产品,方法先基于问题词元检索待处理文本,避免全量文本冗余计算;再通过预设编码器将待处理文本生成初始块嵌入向量,以紧凑向量替代长文本序列,压缩数据体量并降低编码计算量;接着将初始块嵌入向量转换为预设解码器兼容的输入格式,保证向量与解码器输入空间对齐,避免格式不匹配导致的无效计算;最后将目标块嵌入向量与问题词元输入预设解码器生成目标问题解答,以块级向量参与解码计算,减少长文本词元的注意力运算量,从检索、编码、格式对齐到解码全流程降低推理开销。综上,本发明提供的方法在精简数据规模、降低计算复杂度的同时,完整保留了核心语义信息,进而解决了现有技术中的检索增强生成方法存在长上下文检索增强生成推理计算成本高、效率低的技术问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123012154A_ABST
    Figure CN123012154A_ABST
Patent Text Reader

Abstract

The application discloses a long-context retrieval enhancement generation method and device, equipment, medium and product, and relates to the technical field of natural language processing. The method comprises the following steps: obtaining to-be-processed text retrieved based on a question word; generating a plurality of initial block embedding vectors according to the to-be-processed text and a preset encoder; converting the plurality of initial block embedding vectors into an input format of a preset decoder to obtain a plurality of target block embedding vectors; and inputting the plurality of target block embedding vectors and the question word into the preset decoder to generate a target question answer. The application solves the technical problems of high inference calculation cost and low efficiency of long-context retrieval enhancement generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing, and in particular to a method, apparatus, device, medium, and product for enhancing long context retrieval. Background Technology

[0002] With the rapid development of large-scale language models, artificial intelligence has demonstrated unprecedented capabilities in processing cross-domain knowledge, understanding complex semantic relationships, and performing reasoning tasks. Especially in scenarios such as long-text question answering, enterprise knowledge management, and multi-turn decision-making systems, retrieval-enhanced generation (RAG) technology has become a core approach to expanding the knowledge boundaries of language models. Users only need to submit a question, and the system can retrieve a large amount of relevant material from external knowledge bases, then integrate this content and input it into the language model to generate a fully informed and logically rigorous answer. This approach greatly enhances the language model's grasp of factual knowledge, automating many high-cost, highly specialized information processing tasks. However, as the scale of searchable knowledge continues to expand, the length of context that the model needs to process grows rapidly. The massive amount of searchable content leads to significant computational costs during the reasoning phase, resulting in low reasoning efficiency.

[0003] In summary, existing retrieval enhancement generation methods suffer from high computational costs and low efficiency in reasoning for long-context retrieval enhancement generation. Summary of the Invention

[0004] The purpose of this application is to provide a method, apparatus, device, medium, and product for generating enhanced long-context retrieval data, which can solve the technical problems of high computational cost and low efficiency in the reasoning of enhanced long-context retrieval data generation in existing retrieval enhancement methods.

[0005] To achieve the above objectives, this application provides the following solution: Firstly, this application provides a method for enhancing the generation of long-context retrieval, including: Obtain the text to be processed based on the question terminology; Based on the text to be processed and the preset encoder, generate multiple initial block embedding vectors; Multiple initial block embedding vectors are converted to the input format of a preset decoder to obtain multiple target block embedding vectors; Multiple target block embedding vectors and question terms are input into a preset decoder to generate answers to the target questions.

[0006] Optionally, based on the text to be processed and the preset encoder, multiple initial block embedding vectors are generated, specifically including: dividing the text to be processed according to a preset length or semantic boundary to obtain multiple context blocks; and using the preset encoder to encode and compress the multiple context blocks to obtain multiple initial block embedding vectors.

[0007] Optionally, multiple target block embedding vectors and question words are input into a preset decoder to generate a target question answer. Specifically, this includes: concatenating multiple target block embedding vectors and question words to obtain a concatenated sequence; and using the decoder to decode the concatenated sequence to generate a target question answer.

[0008] Optionally, a decoder is used to decode the concatenated sequence to generate a solution to the target question. Specifically, this includes: using the decoder to calculate the correlation between multiple target block embedding vectors and the question vector to obtain multiple similarities, wherein the question vector is determined based on question terms; comparing the multiple similarities with a preset similarity threshold to determine high similarities, wherein a high similarity is the similarity among the multiple similarities that is greater than the preset similarity threshold; converting the target block embedding vectors corresponding to high similarities into original context blocks; and generating a solution to the target question based on the original context blocks and the multiple target block embedding vectors corresponding to non-high similarities.

[0009] Optionally, multiple target block embedding vectors and question words are input into a preset decoder to generate a target question answer. Specifically, this includes: constructing a reward function, where the reward function includes generation quality and computational cost penalties. Generation quality is determined based on the similarity between the generated text and the original text, and computational cost penalties are determined based on decoding overhead; classifying the multiple target block embedding vectors using the preset decoder based on the reward function and question words to obtain classification results; and generating a target question answer based on the classification results. The classification results include decompression and compression classes. The target block embedding vectors corresponding to the decompression class need to be converted to the original context block when used to generate the target question answer, while the target block embedding vectors corresponding to the compression class maintain their compressed form when used to generate the target question answer.

[0010] Optionally, multiple initial block embedding vectors are transformed to the input format of a preset decoder to obtain multiple target block embedding vectors. Specifically, this includes: using a preset projection layer to transform multiple initial block embedding vectors to the input format of a preset decoder to obtain multiple target block embedding vectors, wherein the preset projection layer and the preset encoder are obtained through joint pre-training based on a block reconstruction task.

[0011] Secondly, this application provides a long context retrieval enhancement generation apparatus, comprising: The module is used to acquire the text to be processed retrieved based on the question tokens; the first generation module is used to generate multiple initial block embedding vectors by encoding and compression based on the text to be processed and a preset encoder; the conversion module is used to convert the multiple initial block embedding vectors to the input format of a preset decoder to obtain multiple target block embedding vectors; the second generation module is used to input the multiple target block embedding vectors and the question tokens into the preset decoder to generate the answer to the target question.

[0012] Optionally, the first generation module is further configured to: divide the text to be processed according to a preset length or semantic boundary to obtain multiple context blocks; and use the preset encoder to perform dimensionality reduction and compression processing on the multiple context blocks to obtain the multiple initial block embedding vectors.

[0013] Optionally, the second generation module is further configured to: concatenate multiple target block embedding vectors and question words to obtain a concatenated sequence; and use a decoder to decode the concatenated sequence to generate a solution to the target question.

[0014] Optionally, the second generation module is further configured to: use a decoder to calculate the correlation between multiple target block embedding vectors and the question vector to obtain multiple similarities, wherein the question vector is determined based on question lexical units; compare the multiple similarities with a preset similarity threshold to determine high similarity, wherein high similarity is the similarity among the multiple similarities that is greater than the preset similarity threshold; convert the target block embedding vector corresponding to high similarity into an original context block; and generate a target question answer based on the original context block and the multiple target block embedding vectors corresponding to non-high similarity.

[0015] Optionally, the second generation module is further configured to: construct a reward function, wherein the reward function includes generation quality and computational cost penalty, the generation quality being determined based on the similarity between the generated text and the original text, and the computational cost penalty being determined based on the decoding overhead; classify multiple target block embedding vectors using a preset decoder based on the reward function and question lexical units to obtain classification results; and generate a target question answer based on the classification results, wherein the classification results include decompression and compression classes, the target block embedding vectors corresponding to the decompression class need to be converted into original context blocks when used to generate the target question answer, and the target block embedding vectors corresponding to the compression class maintain compressed form when used to generate the target question answer.

[0016] Optionally, the conversion module is also used to: convert multiple initial block embedding vectors to the input format of a preset decoder using a preset projection layer to obtain multiple target block embedding vectors, wherein the preset projection layer and the preset encoder are obtained through joint pre-training based on the block reconstruction task.

[0017] Thirdly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the long context retrieval enhancement generation method described in any one of the above.

[0018] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the long context retrieval enhancement generation method described above.

[0019] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the long context retrieval enhancement generation method described above.

[0020] According to the specific embodiments provided in this application, the following technical effects are disclosed: This application provides a method, apparatus, device, medium, and product for enhancing long-context retrieval. The method first retrieves the text to be processed based on question terms, avoiding redundant computation of the entire text. Then, a preset encoder generates initial block embedding vectors from the text to be processed, replacing long text sequences with compact vectors, compressing data volume and reducing encoding computation. Next, the initial block embedding vectors are converted into an input format compatible with a preset decoder, ensuring alignment between the vectors and the decoder input space, avoiding invalid computations caused by format mismatch. Finally, the target block embedding vector and question terms are input into the preset decoder to generate the target question answer. Block-level vectors participate in decoding computation, reducing the attention computation of long text terms, thus reducing inference overhead throughout the entire process from retrieval, encoding, format alignment to decoding. In summary, the method provided by this invention, while simplifying data scale and reducing computational complexity, fully preserves core semantic information, thereby solving the technical problems of high computational cost and low efficiency in existing retrieval enhancement generation methods for long-context retrieval enhancement. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is an application environment diagram of a long context retrieval enhancement generation method in one embodiment of this application; Figure 2 A flowchart illustrating a long context search enhancement generation method provided in an embodiment of this application; Figure 3 A flowchart illustrating a method for enhancing long context retrieval generation, provided as an embodiment of this application; Figure 4 An example diagram illustrating the effect of a long context search enhancement generation method provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a long context search enhancement generation device provided in an embodiment of this application; Figure 6This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0023] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0024] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0025] The long context search enhancement generation method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be set up independently, integrated into server 104, or placed in the cloud or on another server. Terminal 102 can send the text to be processed retrieved based on question tokens to server 104. After receiving the text, server 104 generates multiple initial block embedding vectors based on the text and a preset encoder; it converts these initial block embedding vectors to the input format of a preset decoder to obtain multiple target block embedding vectors; and it inputs these target block embedding vectors and question tokens into the preset decoder to generate a target question answer. Server 104 can then provide feedback to terminal 102 regarding the obtained target question answer. Furthermore, in some embodiments, the long context retrieval enhancement generation method can also be implemented independently by server 104 or terminal 102. For example, terminal 102 can directly process the text to be processed based on question tokens, or server 104 can retrieve the text to be processed based on question tokens from the data storage system and process it.

[0026] The terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, and IoT devices. The server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers, or it can be a cloud server.

[0027] In one exemplary embodiment, such as Figure 2 As shown, a method for enhancing long context retrieval is provided. This method is executed by a computer device, specifically by a terminal or server alone, or by both a terminal and a server. In this embodiment, the method is applied to... Figure 1 Taking server 104 as an example, the explanation includes the following steps 201 to 204. Wherein: Step S201: Obtain the text to be processed based on the problem terminology.

[0028] In this embodiment of the invention, step S201 aims to accurately filter effective context, providing a foundation for subsequent lightweight processing and reducing redundant computation from the source. First, the system receives the user's input question and processes it into several question tokens using a word segmenter. These question tokens carry the user's query intent and core needs, serving as the basis for retrieval. Subsequently, based on these question tokens, the system performs semantic retrieval operations in a pre-set massive document database. During the retrieval process, the semantic relevance between the question tokens and the text in the database is calculated, filtering out text fragments highly relevant to the current query content. These filtered texts are then integrated as the text to be processed. This process avoids indiscriminate processing of all documents, effectively eliminating redundant text irrelevant to the user's question, reducing the data processing volume of subsequent steps, and ensuring that the text to be processed contains the key information needed to answer the user's question. This provides a high-quality input foundation for the efficient execution of subsequent encoding and decoding stages, reducing the computational overhead of the overall reasoning process from the source.

[0029] Step S202: Generate multiple initial block embedding vectors based on the text to be processed and the preset encoder.

[0030] In this embodiment of the invention, step S202 mainly converts long text into compact semantic vectors, significantly reducing computational complexity. After obtaining the text to be processed, since the text still has a long length and scattered semantics, direct processing would lead to excessive computation and low efficiency. Therefore, it is necessary to process it in blocks first.

[0031] The segmentation method can be uniform segmentation or adaptive segmentation. Uniform segmentation divides the text to be processed into several independent text units according to a fixed length, while adaptive segmentation divides the text into semantically complete text units according to the natural segmentation of the text's semantic logic, ensuring that each text unit has independent and complete semantics.

[0032] After segmentation, a pre-configured lightweight encoder (i.e., the preset encoder) is invoked. This encoder features few parameters, fast computation speed, and low energy consumption, enabling semantic encoding and extraction of each text unit without losing core semantics. The encoder analyzes the lexical, syntactic, and semantic relationships within each text unit, condensing the complete semantic information of each unit into a fixed-dimensional vector to obtain initial block embedding vectors. Each text unit generates one initial block embedding vector, resulting in multiple initial block embedding vectors. Through this vector compression, the originally lengthy text sequence is transformed into a compact vector representation, significantly reducing the data size of the original text and simplifying the complexity of subsequent operations, while preserving the core semantic information of the text, laying the foundation for subsequent format conversion and decoding operations.

[0033] For example, a lightweight encoder is a lightweight Transformer, a sparse attention network, a low-rank matrix transformation structure, a depthwise separable convolutional network, or other low computational complexity structures adapted to the REFRAG attention pattern.

[0034] Optionally, in some embodiments of the present invention, the text to be processed is cleaned and standardized, such as removing redundant spaces, abnormal format characters, HTML tags, and other noise information. Then, the text is divided into multiple context blocks based on semantic boundaries or a fixed length. Semantic boundaries can be determined by a sentence segmentation model, dependency syntax structure, or a pre-trained language model to avoid splitting sentences with close contextual relationships. Each context block retains complete semantics, and the block length can be determined by empirical values ​​or task requirements. For example, selecting a reasonable block size within the commonly used 512 / 1024 token window for large models can reduce the computational burden on subsequent encoders while maintaining semantic integrity.

[0035] Step S203: Convert the multiple initial block embedding vectors to the input format of the preset decoder to obtain multiple target block embedding vectors.

[0036] In this embodiment of the invention, step S203 is an adaptation step to enable the encoder and decoder to work together. Its function is to resolve the incompatibility between the encoder output and the decoder input, avoiding invalid computation. The initial block embedding vector generated in step S202 is generated by the lightweight encoder based on its own encoding logic and parameters. Its vector dimension, feature distribution, and semantic representation method do not match the native input format of the preset decoder. If the initial block embedding vector is directly input into the decoder, the decoder will be unable to recognize and process the vector, leading to computational errors, inaccurate generation results, and even failure to complete the decoding process.

[0037] Therefore, the initial block embedding vectors need to be format-converted using a preset mapping function. This mapping function can be a linear mapping, a two-layer MLP, or other forms of feedforward networks. Its function is to uniformly adjust the representation space and dimensionality of all initial block embedding vectors, converting the feature distribution of the initial block embedding vectors into a form that the decoder can recognize and process, ensuring that the converted vectors are fully compatible with the input specifications and operational logic of the decoder. Optionally, the mapping function (i.e., the preset projection layer) and the lightweight encoder are obtained through continuous joint pre-training (CPT) based on the block reconstruction task. By optimizing the block reconstruction task, it is ensured that the compressed semantic information can still recover the original token-level information features as much as possible after projection mapping. After format conversion, the originally incompatible initial block embedding vectors become standardized target block embedding vectors. Each initial block embedding vector is converted into a corresponding target block embedding vector, resulting in multiple target block embedding vectors. Step S203 realizes cross-module feature adaptation between the encoder and decoder, ensuring the normal operation of subsequent decoding operations, and further optimizing the representation effect of the vectors, thus providing a guarantee for improving the accuracy of the final generated results.

[0038] Step S204: Input multiple target block embedding vectors and question terms into a preset decoder to generate a solution to the target question.

[0039] In this embodiment of the invention, step S204 is the generation stage, the purpose of which is to generate accurate and complete answers to questions by combining contextual information and user needs. After completing the format conversion of the target block embedding vectors, the system fuses and concatenates these target block embedding vectors with question words carrying the user's query intent. During the fusion process, the global semantic features of the target block embedding vectors and the query requirements of the question words are preserved, ensuring that the decoder can simultaneously obtain the contextual information of the long text and the user's core questions.

[0040] The fused information is fed into a pre-defined decoder. This decoder, acting as the generation core, possesses semantic understanding and language organization capabilities. Based on its built-in language generation logic, it performs deep reasoning operations on the input target block embedding vectors and question terms. The decoder generates answers one by one, dynamically incorporating the semantic information carried by each target block embedding vector to ensure the generated content accurately reflects the key information in the text being processed, while closely adhering to the user's question requirements and avoiding irrelevant answers. During the reasoning generation process, the decoder also autonomously optimizes the language logic to ensure the output answer to the target question is fluent, accurate, and complete, directly meeting the user's query needs. Step S204 deeply integrates the lightweighted contextual information with the user's question, reducing computational costs and improving efficiency while ensuring the accuracy and completeness of the generated results, ultimately achieving efficient and accurate output of long-context RAG reasoning.

[0041] Based on the description of the above embodiments, the method provided by the present invention first retrieves the text to be processed based on question terms, avoiding redundant computation of the entire text; then, it performs dimensionality reduction and compression on the text to be processed through a preset encoder to generate an initial block embedding vector, replacing the long text sequence with a compact vector, compressing the data volume and reducing the amount of encoding computation; next, it converts the initial block embedding vector into an input format compatible with a preset decoder, ensuring that the vector is aligned with the decoder input space, avoiding invalid computation caused by format mismatch; finally, it inputs the target block embedding vector and question terms into a preset decoder to generate the target question answer, using block-level vectors to participate in decoding computation, reducing the attention computation of long text terms, and reducing inference overhead throughout the entire process from retrieval, encoding, format alignment to decoding. In summary, the method provided by the present invention, while simplifying the data scale and reducing computational complexity, fully preserves the core semantic information, thereby solving the technical problems of high computational cost and low efficiency of long context retrieval enhancement generation in existing technologies.

[0042] Optionally, in step S202, multiple initial block embedding vectors are generated based on the text to be processed and the preset encoder, specifically including the following steps: Step S2021: Divide the text to be processed into multiple context blocks according to a preset length or semantic boundary.

[0043] In this embodiment of the invention, step S2021 aims to decompose the long text to be processed into semantically complete and appropriately sized units, facilitating subsequent encoding and compression. After obtaining the text to be processed, it still suffers from length and semantic dispersion. Direct encoding would result in excessive computational load and low efficiency for the encoder, and would make it difficult to accurately capture local semantic information. Therefore, it needs to be rationally divided. The division process can be carried out in two ways: one is to divide according to a preset length, which can be pre-set according to the encoder's processing capacity and computational efficiency requirements to ensure that the length of each divided unit is uniform and adapts to the encoder's input specifications; the other is to divide according to semantic boundaries, combining the semantic logic of the text itself to identify the natural boundaries between sentences and paragraphs, dividing semantically closely related content into a unit, avoiding the splitting of complete semantic fragments. For example, the semantic boundaries can be judged and identified through sentence segmentation models, dependency parsing analysis, or pre-trained language models. By using either of the two partitioning methods mentioned above, the text to be processed is decomposed into multiple independent units, which are called context blocks. Each context block has relatively complete semantics, which avoids the computational burden caused by the excessive size of a single block and also prevents semantic loss caused by excessive semantic splitting, thus laying a solid foundation for the subsequent encoding and compression process.

[0044] Step S2022: Encode and compress multiple context blocks using a preset encoder to obtain multiple initial block embedding vectors.

[0045] In this embodiment of the invention, step S2022 involves semantically condensing the segmented context blocks into compact vector representations, thereby achieving lightweight processing of long texts. After obtaining multiple context blocks, a preset encoder is invoked. This encoder possesses the core characteristics of few parameters, fast computation speed, and low energy consumption, enabling efficient encoding and compression operations without losing the core semantic information of the context blocks. During the encoding process, the encoder performs deep semantic analysis on each context block, extracting the semantic features of the words within the block, the relationships between words, and the core semantic connotation of the entire block. Through built-in encoding logic, the originally lengthy text-based context blocks are condensed into a fixed-dimensional vector, and the embedding dimension of this vector is substantially much smaller than the token sequence length of the original context block.

[0046] The vector obtained after encoding and compression is the initial block embedding vector. Each context block corresponds to an initial block embedding vector, resulting in multiple initial block embedding vectors. This encoding and compression process transforms the originally massive text data into compact vector data, simplifying the data size and reducing the computational complexity of subsequent steps. At the same time, it fully preserves the core semantic information of each context block, ensuring that subsequent format conversion, decoding, and generation stages can be carried out based on accurate semantic foundations. This improves overall computational efficiency and guarantees the accuracy of the final generated result.

[0047] For example, each context block Input lightweight encoder The compressed representation is obtained as follows: in, For the first A context block, This is the compressed low-dimensional semantic embedding vector, used to represent the core information of the block. Since the original block usually contains many tokens, and the embedding dimension is often much smaller than the length of the original token sequence, the encoding process is essentially an information compression.

[0048] Optionally, the lightweight encoder can employ a multi-layer attention structure, a convolutional structure, or a hybrid architecture combining both. To enhance the model's selective attention capability in long texts, sparse block-diagonal attention and REFRAG-guided attention mechanisms can be introduced into the encoder, explicitly restricting the dependencies between different blocks by modifying the attention score matrix. in, A mask matrix that limits the attention span across blocks can reduce interference between irrelevant blocks and improve the effectiveness of compressed representation.

[0049] Optionally, when the length of the context block exceeds the encoder's processing capacity, a sliding window strategy can be used for fragmented encoding, and a weighted fusion method can be used to integrate the results of overlapping areas to avoid information loss caused by semantic boundary ambiguity.

[0050] Optionally, in step S204, multiple target block embedding vectors and question terms are input into a preset decoder to generate a target question answer, specifically including the following steps: Step S2041: Concatenate multiple target block embedding vectors and question words to obtain a concatenated sequence.

[0051] In this embodiment of the invention, the purpose of step S2041 is to integrate the contextual semantic information with the user's query requirements, providing the decoder with complete and unified input data. After processing in step S203, multiple target block embedding vectors have completed format adaptation and can be recognized and processed by the decoder. Each target block embedding vector carries the core semantic information of the corresponding context block in the text to be processed, which is the key basis for answering the user's question.

[0052] Question words directly carry the user's query intent and core question, serving as the core guide for the decoder to generate targeted answers. To enable the decoder to simultaneously acquire contextual semantic information and user query needs, achieving deep integration, multiple target block embedding vectors need to be concatenated with question words. During concatenation, all target block embedding vectors and question words are integrated in a preset order, ensuring the coherence of contextual semantics and the clarity of query intent, preventing semantic confusion or loss of intent. After concatenation, a unified sequence of data, the concatenated sequence, is formed. This sequence contains both the global contextual semantic features of the long text and the user's specific query needs, providing a complete and accurate input foundation for subsequent decoder processing, ensuring the decoder can perform reasoning and generation based on comprehensive information.

[0053] Step S2042: Use a decoder to decode the spliced ​​sequence and generate a solution to the target problem.

[0054] In this embodiment of the invention, step S2042 performs deep semantic parsing and reasoning on the concatenated sequence to output a complete answer that meets the user's needs. After obtaining the concatenated sequence, it is input into a preset decoder. This decoder, as the core of the entire technical process, has powerful semantic understanding, logical reasoning, and language organization capabilities, and can accurately parse the contextual semantic information and user query intent in the concatenated sequence.

[0055] During the decoding process, the decoder performs in-depth analysis on the target block embedding vectors and question terms in the concatenated sequence, uncovering the correlation between contextual information and the user's question. Combining this with its built-in language generation logic, it constructs the linguistic logic and content framework for the answer. The decoder dynamically invokes key semantic information from the concatenated sequence to ensure that the generated content accurately corresponds to the core content of the text being processed, while closely adhering to the user's question requirements, avoiding irrelevant answers or semantic deviations. During generation, the decoder can also autonomously optimize the language expression, ensuring that the output answer to the target question is fluent, rigorous, and complete, directly meeting the user's query needs without additional supplementation or correction. This step, through efficient decoding of the concatenated sequence, achieves a deep integration of contextual information and user needs. While ensuring the accuracy and completeness of the generated results, it maintains the lightweight advantage of the entire process, further improving the efficiency and practicality of long-context RAG inference.

[0056] Optionally, in some embodiments of the invention, before inputting the decoder, normalization, layer normalization, or positional encoding adjustment can be performed on the embedding vectors of the question tokens and the target blocks to ensure consistent vector distribution from different sources and improve generation stability.

[0057] Optionally, the decoder employs a sparse block-diagonal + REFRAG attention mechanism to guide attention to the context region most relevant to the current generated state, thereby improving the model's processing efficiency on long sequences and reducing interference from irrelevant information.

[0058] Optionally, in step S2042, the concatenated sequence is decoded using a decoder to generate a solution to the target question, specifically including the following steps: In step S2042a, the decoder is used to calculate the correlation between multiple target block embedding vectors and question vectors to obtain multiple similarities, wherein the question vector is determined based on question lexical terms.

[0059] In this embodiment of the invention, step S2042a aims to identify contextual information in the concatenated sequence that is highly relevant to the user's question, providing a basis for subsequent answer generation. First, based on the question terms in the concatenated sequence and the current state of the decoder, a question vector (i.e., the decoder's current state vector) is generated. This vector dynamically condenses the core intent of the user's query and the current generation requirements, maintaining consistency with the representation space of the target block embedding vector to ensure the accuracy of relevance calculation. Subsequently, using the decoder's built-in relevance calculation logic, relevance analysis is performed on multiple target block embedding vectors and the question vector one by one. By calculating the semantic similarity between the two, a similarity value is obtained for each target block embedding vector. Each similarity value intuitively reflects the close relationship between the contextual information carried by the corresponding target block embedding vector and the user's question. The higher the similarity, the greater the role of the contextual information corresponding to the target block embedding vector in answering the user's question, providing a quantitative basis for subsequent key information filtering.

[0060] Step S2042b: Compare multiple similarities with a preset similarity threshold to determine high similarity, where high similarity is the similarity among multiple similarities that is greater than the preset similarity threshold.

[0061] In this embodiment of the invention, step S2042b serves to filter out high-similarity targets closely related to the user's question from multiple similarity values, thereby separating key information from redundant information. The preset similarity threshold is a benchmark value set in advance based on the actual application scenario, computational efficiency requirements, and generation quality requirements, used to distinguish between target block embedding vectors with high and low relevance.

[0062] The multiple similarities obtained in step S2042a are compared one by one with a preset similarity threshold. All similarities greater than the threshold are selected as high similarities. This comparison and selection process can accurately locate the target block embedding vector that is highly relevant to the user's question, avoid interference from invalid information in subsequent processing, reduce unnecessary calculation operations, and further improve the efficiency of decoding and generation.

[0063] Step S2042c: Convert the target block embedding vector corresponding to high similarity into the original context block.

[0064] In this embodiment of the invention, step S2042c retrieves the corresponding original context block from a preset cache based on the index information of the target block embedding vector corresponding to high similarity. The purpose is to provide fine-grained semantic information for generating accurate solutions. Although the target block embedding vector corresponding to high similarity carries core semantics, it is a compact vector representation lacking specific textual details. Therefore, the system does not directly perform reverse decoding of the vector. Instead, based on the mapping index between the target block embedding vector and the original text, it directly and accurately extracts and restores the corresponding complete original text sequence (Token) from the system's preset cache or storage module. This index retrieval mechanism not only fully preserves the semantic details and textual logic of the original context block, ensuring sufficient textual support for generating complete and accurate solutions to the target question, but also avoids complex reverse computation overhead, strictly adhering to the principle of lightweight processing.

[0065] Step S2042d: Generate the target question answer based on the original context block and the embedding vectors of multiple target blocks corresponding to non-high similarity.

[0066] In this embodiment of the invention, step S2042d serves to fuse key textual information with non-key global semantic information, ensuring both generation quality and computational efficiency to generate a complete answer that meets user needs. In this step, the decoder simultaneously combines two different types of information for reasoning generation. One type is the original context block restored in step S2042c. This type of information corresponds to highly similar target block embedding vectors, containing fine-grained semantic details highly relevant to the user's question, directly providing core evidence for answering the user's question and ensuring the accuracy and relevance of the answer. The other type is multiple target block embedding vectors corresponding to non-highly similar targets. These vectors correspond to contextual information with lower relevance to the user's question and do not need to be restored to the original text. They still participate in the calculation in a compact vector form, preserving the global semantic features of the text to be processed, ensuring the completeness and coherence of the answer, while avoiding the additional computational overhead of restoring non-key text, thus continuing the lightweight advantage of the entire process.

[0067] The decoder, relying on its built-in language generation logic, deeply integrates these two types of information, uncovering the correlation between key details in the original context block and the global semantics carried by non-highly similar vectors. Combined with the user's query intent, it gradually constructs the linguistic logic and content framework of the answer. During the generation process, the decoder autonomously optimizes the language expression, prioritizing the use of key information from the original context block while appropriately incorporating the global semantics corresponding to non-highly similar vectors. This ensures that the output answer to the target question is fluent, rigorous, and complete, accurately addressing the user's core question while fully presenting relevant contextual information without requiring additional supplementation or correction. Ultimately, this achieves efficient and accurate output of long-context RAG reasoning.

[0068] For example, based on the decoder's current state vector With block embedding The similarity is used to determine whether to recover the complete context token sequence corresponding to the block. Here, the current state vector corresponds to the question vector, or is a fusion vector of the question vector and the content vector currently generated by the decoder. Similarity can be measured using cosine similarity, dot product, or other metrics. The formula is as follows: when At that time, the model determines that the current generation process requires more fine-grained information for this block, and therefore removes the original context block. Replace the compressed representation input decoder; when Continue to use compressed representation. This reduces the amount of computation. A grid search can be performed using the validation set; for example, try... Choose a value that achieves the best balance between generation quality and inference cost.

[0069] Optionally, in step S204, multiple target block embedding vectors and question terms are input into a preset decoder to generate a target question answer, specifically including the following steps: Step S2043: Construct a reward function, wherein the reward function includes generation quality and computational cost penalty, the generation quality is determined based on the similarity between the generated text and the original text, and the computational cost penalty is determined based on the decoding overhead.

[0070] In this embodiment of the invention, the purpose of step S2043 is to construct an optimization objective that balances generation quality and computational cost, providing a basis for judgment in the subsequent classification operation of the decoder. The reward function is used to quantitatively evaluate the processing process and generation results of the decoder, guiding the decoder to prioritize processing methods with high quality and low cost.

[0071] The reward function mainly consists of two parts: generation quality and computational cost penalty. Generation quality is a key indicator for measuring the accuracy of the decoder's output. Its value is determined by the similarity between the generated text and the original text. Higher similarity indicates that the generated text closely matches the original context, resulting in better generation quality and a larger positive contribution to the reward function. The computational cost penalty constrains resource consumption during the decoding process. Its value is determined by the decoding overhead. Higher decoding overhead indicates more resources consumed and lower efficiency during computation, resulting in a larger negative penalty in the reward function. By combining generation quality and computational cost penalty to construct the reward function, a dynamic balance between generation quality and computational efficiency can be achieved. This avoids excessive computational costs in pursuit of high quality while preventing the sacrifice of generation accuracy for cost reduction, providing a clear optimization guide for subsequent classification operations.

[0072] For example, through a reward function: The block selection behavior is optimized, where the generation quality Q is calculated using a text similarity metric (such as ROUGE-L), and the formula can be expressed as: in Generate text for the decoder. This is the true lower-level token, where the true lower-level token is the labeled standard answer. A larger Q indicates higher generation quality.

[0073] C represents the computational cost penalty term. Based on the block selection behavior g(k) mentioned above, the computational overhead of retaining uncompressed blocks can be approximated by the number of tokens. in This represents the number of tokens in the block.

[0074] This is a trade-off factor used to balance the generation quality Q and the computational cost C, thereby achieving a selective compression strategy.

[0075] Step S2044: Based on the reward function and question words, classify the embedding vectors of multiple target blocks using a preset decoder to obtain the classification result.

[0076] In this embodiment of the invention, the purpose of step S2044 is to differentiate and classify multiple target block embedding vectors based on the optimization objective of the reward function and the user's query requirements, providing a basis for subsequent generation processing. In step S2044, the decoder simultaneously performs classification operations by combining the reward function and question terms. Question terms carry the user's core query intent and are used to clarify the classification direction, ensuring that the classification results meet the user's needs. The decoder analyzes each target block embedding vector one by one, and, in conjunction with the evaluation criteria of the reward function, determines which processing method (decompression or compression-preservation) can maximize the value of the reward function for that target block embedding vector.

[0077] Specifically, target block embedding vectors that are closely related to the user's problem, contribute significantly to the generated quality, and whose computational cost increases only slightly after decompression are grouped into one category; target block embedding vectors that are less related to the user's problem, contribute little to the generated quality, and whose computational cost increases significantly after decompression are grouped into another category. This classification process yields clear results, providing a clear basis for subsequent differentiated generation processing.

[0078] Step S2045: Generate a solution to the target question based on the classification results. The classification results include decompressed and compressed classes. The target block embedding vector corresponding to the decompressed class needs to be converted into the original context block when used to generate a solution to the target question. The target block embedding vector corresponding to the compressed class maintains its compressed form when used to generate a solution to the target question.

[0079] In this embodiment of the invention, the purpose of step S2045 is to differentiate the embedding vectors of different types of target blocks according to the classification results, so as to minimize the computational cost while ensuring the generation quality and generate a complete solution that meets the user's needs.

[0080] The classification results are clearly divided into two categories: decompression and compression. The target block embedding vectors of these two categories participate in the generation process using different processing methods. For the target block embedding vectors corresponding to the decompression category, since they are closely related to the user question and contribute significantly to the generation quality, they need to be converted into original context blocks through a pre-defined restoration mechanism. The restored original context blocks contain fine-grained semantic details, providing core support for generating accurate and targeted solutions and ensuring the accuracy of the solutions. For the target block embedding vectors corresponding to the compression category, since they are less related to the user question and contribute less to the generation quality, and decompression would increase additional computational overhead, they retain their original compressed vector form during the generation process and do not require restoration.

[0081] The aforementioned differentiated processing method ensures generation quality by decompressing the original context blocks and reduces computational cost by compressing the vector form of the target blocks, achieving an optimal balance between generation quality and computational efficiency. The decoder, relying on its built-in language generation logic, deeply integrates the converted original context blocks with the target block embedding vector while maintaining its compressed form. Combined with the query intent of the question terms, it gradually constructs the language logic and content framework of the answer, ultimately generating a fluent, rigorous, and complete answer to the target question, meeting the user's query needs.

[0082] Optionally, multiple initial block embedding vectors are transformed to the input format of a preset decoder to obtain multiple target block embedding vectors. Specifically, this includes: using a preset projection layer to transform multiple initial block embedding vectors to the input format of a preset decoder to obtain multiple target block embedding vectors, wherein the preset projection layer and the preset encoder are obtained through joint pre-training based on a block reconstruction task.

[0083] In this embodiment of the invention, the logic of joint pre-training is to enable the preset projection layer and the preset encoder to learn collaboratively, with the block reconstruction task as the training objective, ensuring that the representation spaces of the two remain consistent, thereby improving the accuracy and efficiency of vector conversion. The core of the block reconstruction task is to enable the initial block embedding vector generated by the encoder to accurately restore the original context block semantic information after being converted by the projection layer. Through this training process, the encoder can generate an initial block embedding vector that better fits the conversion requirements of the projection layer, while the projection layer can accurately grasp the feature distribution of the encoder's output vector, optimize the conversion logic, and ensure that the converted target block embedding vector can both adapt to the decoder's input format and completely retain the core semantic information of the original context block.

[0084] For example, the compressed target block embedding vector is passed through a projection layer. Mapped to a vector space with the same dimension as the decoder token: Where the mapping function This can be a linear mapping, a two-layer MLP, or other forms of feedforward network, used to ensure that the compressed representation of the block can fit into the decoder's original token embedding space. This mapping process is equivalent to realigning the semantically compressed information into a vector domain that the generative model can recognize.

[0085] Continuous pre-training (CPT) is performed on the lightweight encoder and projection layer to enhance the consistency between block compression and projection by optimizing the block reconstruction task: in This represents the original token-level target. For the projection matrix, This is for block embedding. The goal of pre-training is to ensure that the compressed semantic information can still recover the original information as much as possible after projection.

[0086] During pre-training, a course learning strategy is adopted, starting with single-block reconstruction tasks to enable the model to learn basic compression mapping capabilities; then gradually increasing to multi-block combined reconstruction tasks to increase the difficulty and enable the model to maintain stable performance in more complex context structures.

[0087] Optionally, refer to Figure 3 In this embodiment of the invention, the long context retrieval enhancement generation method is implemented as follows: Long text input: Receives long documents or multi-paragraph text to be processed as the original source of contextual information.

[0088] Text segmentation: The input long text is split into multiple independent context blocks according to preset length or semantic boundaries, ensuring that each unit is of moderate size and semantically complete, which facilitates subsequent processing.

[0089] Lightweight encoder: Encodes and compresses each context block to generate the corresponding initial block embedding vector, transforming lengthy text into compact semantic vector representations, thus achieving lightweight processing of long texts.

[0090] Projection module: Receives the initial block embedding vector output by the lightweight encoder, and adjusts it into a target block embedding vector that is compatible with the decoder input format through preset conversion logic. This solves the feature space incompatibility problem between the encoder and decoder, and ensures that the subsequent decoding stage can correctly identify and process vector information.

[0091] Question Input: Receives user queries, carries the user's core intent, and serves as a guiding signal for the subsequent generation process.

[0092] Block expansion decision module: Receives the target block embedding vector and problem information output by the projection module, performs classification decisions for each block, determines which blocks need to be restored to the original text and which should be kept in compressed vector form, and achieves selective processing.

[0093] Decoder: Receives block information and question information processed by the decision module, relies on built-in language generation logic, and combines efficient computing methods to perform decoding reasoning to generate answer text that meets user needs.

[0094] Output the response: The output decoder generates a natural language response, which is then fed back to the user as the system's final result.

[0095] Sparse Block-Diagonal Attention: This optimizes the attention calculation method of the decoder by performing sparse calculations only on the correlation between key blocks and questions and generated text, which significantly reduces the computational overhead of the decoding process and improves inference efficiency.

[0096] REFRAG guidance strategy: With the goal of balancing generation quality and computational cost, it provides optimization guidance to the block expansion decision module, guiding it to classify blocks and achieve a dynamic balance between quality and efficiency.

[0097] Selective compression: Based on the classification results of the decision module, the blocks are differentiated. Key blocks are restored to the original text to ensure the quality of generation, while non-key blocks are kept in compressed form to reduce computational costs and achieve efficient generation.

[0098] Optionally, refer to Figure 4 In this embodiment of the invention, the input question is the starting point of the decision-making process. The system receives the user's query question and converts it into a question vector, which serves as the basis for subsequently determining the importance of each context block. Block importance determination is a key decision-making step in this invention. The system combines the question vector to calculate the relevance of each context block to the question and its contribution to generating the answer, thereby determining the importance level of the block and classifying it into high-importance blocks and low-importance blocks.

[0099] For highly important blocks that are closely related to the question and crucial for generating accurate answers, the system avoids complex reverse decompression calculations. Instead, it directly retrieves the corresponding original text form from a pre-set cache based on the block's vector mapping index and inputs it completely into the decoder. This ensures that the decoder can capture fine-grained semantic details, thereby guaranteeing the accuracy and quality of the final generated answer.

[0100] For low-importance blocks that are less relevant to the question and have little impact on the generated answer, the system does not need to retrieve the text from the cache; instead, it inputs the compressed vector form into the decoder. This approach avoids the additional computational overhead of involving long text in the attention mechanism, significantly reducing the computational cost during decoding and improving overall reasoning efficiency. The complete input of high-importance blocks ultimately leads to a quality-preserving result, ensuring the accuracy and relevance of the answer.

[0101] Compressing the input of low-importance blocks ultimately leads to a reduction in computational cost, enabling lightweight inference.

[0102] Based on the same inventive concept, this application also provides a long context search enhancement generation apparatus for implementing the long context search enhancement generation method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more embodiments of the long context search enhancement generation apparatus provided below can be found in the limitations of the long context search enhancement generation method described above, and will not be repeated here.

[0103] In one exemplary embodiment, such as Figure 5As shown, a long context retrieval enhancement generation device 50 includes: an acquisition module 501, used to acquire the text to be processed retrieved based on question terms; a first generation module 502, used to generate multiple initial block embedding vectors by performing dimensionality reduction compression based on the text to be processed and a preset encoder; a conversion module 503, used to convert the multiple initial block embedding vectors to the input format of a preset decoder to obtain multiple target block embedding vectors; and a second generation module 504, used to input the multiple target block embedding vectors and question terms into the preset decoder to generate a target question answer.

[0104] Optionally, the first generation module 502 is further configured to: divide the text to be processed according to a preset length or semantic boundary to obtain multiple context blocks; and use a preset encoder to encode and compress the multiple context blocks to obtain multiple initial block embedding vectors.

[0105] Optionally, the second generation module 504 is further configured to: use a decoder to calculate the correlation between multiple target block embedding vectors and the question vector to obtain multiple similarities, wherein the question vector is determined based on question lexical units; compare the multiple similarities with a preset similarity threshold to determine high similarity, wherein high similarity is the similarity among the multiple similarities that is greater than the preset similarity threshold; convert the target block embedding vector corresponding to high similarity into an original context block; and generate a target question answer based on the original context block and the multiple target block embedding vectors.

[0106] Optionally, the second generation module 504 is further configured to: construct a reward function, wherein the reward function includes generation quality and computational cost penalty, the generation quality is determined based on the similarity between the generated text and the original text, and the computational cost penalty is determined based on the decoding overhead; classify multiple target block embedding vectors using a preset decoder based on the reward function and question lexical units to obtain classification results; and generate a target question answer based on the classification results, wherein the classification results include original text retrieval class and compressed class, the target block embedding vector corresponding to the original text retrieval class needs to be replaced with the corresponding original context block when used to generate the target question answer, and the target block embedding vector corresponding to the compressed class maintains the compressed form when used to generate the target question answer.

[0107] Optionally, the conversion module 503 is further configured to: convert multiple initial block embedding vectors to the input format of a preset decoder using a preset projection layer to obtain multiple target block embedding vectors, wherein the preset projection layer and the preset encoder are obtained through joint pre-training based on the block reconstruction task.

[0108] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 6As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores text to be processed. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a long-context retrieval enhanced generation method.

[0109] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0110] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0111] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0112] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0113] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0114] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

[0115] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0116] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0117] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for enhancing the generation of long contextual retrieval, characterized in that, The long context retrieval enhancement generation method includes: Obtain the text to be processed based on the question terminology; Based on the text to be processed and the preset encoder, generate multiple initial block embedding vectors; The multiple initial block embedding vectors are converted to the input format of a preset decoder to obtain multiple target block embedding vectors; The multiple target block embedding vectors and the question lexical units are input into a preset decoder to generate the answer to the target question.

2. The long context retrieval enhancement generation method according to claim 1, characterized in that, The step of generating multiple initial block embedding vectors based on the text to be processed and the preset encoder specifically includes: The text to be processed is divided according to a preset length or semantic boundary to obtain multiple context blocks; The preset encoder is used to encode and compress the multiple context blocks to obtain the multiple initial block embedding vectors.

3. The long context retrieval enhancement generation method according to claim 1, characterized in that, The step of inputting the multiple target block embedding vectors and the question lexical units into a preset decoder to generate a target question answer specifically includes: The embedding vectors of the multiple target blocks and the question words are concatenated to obtain a concatenated sequence; The decoder is used to decode the spliced ​​sequence to generate the answer to the target question.

4. The long context retrieval enhancement generation method according to claim 3, characterized in that, The step of using the decoder to decode the concatenated sequence and generate a solution to the target question specifically includes: Using the decoder, the correlation between the multiple target block embedding vectors and the question vector is calculated to obtain multiple similarities, wherein the question vector is determined based on the question lexical. The plurality of similarities are compared with a preset similarity threshold to determine high similarity, wherein the high similarity is the similarity among the plurality of similarities that is greater than the preset similarity threshold; The target block embedding vector corresponding to the high similarity is converted into the original context block; The solution to the target question is generated based on the original context block and the embedding vectors of multiple target blocks corresponding to non-high similarity.

5. The long context retrieval enhancement generation method according to claim 1, characterized in that, The step of inputting the multiple target block embedding vectors and the question lexical units into a preset decoder to generate a target question answer specifically includes: Construct a reward function, wherein the reward function includes a generation quality penalty and a computational cost penalty, wherein the generation quality is determined based on the similarity between the generated text and the original text, and the computational cost penalty is determined based on the decoding overhead; Based on the reward function and the question words, the preset decoder is used to classify the embedding vectors of the multiple target blocks to obtain the classification result; Based on the classification results, the answer to the target question is generated. The classification results include decompression class and compression class. The target block embedding vector corresponding to the decompression class needs to be converted into the original context block when used to generate the answer to the target question. The target block embedding vector corresponding to the compression class maintains the compressed form when used to generate the answer to the target question.

6. The long context retrieval enhancement generation method according to claim 1, characterized in that, The step of converting the plurality of initial block embedding vectors to the input format of a preset decoder to obtain a plurality of target block embedding vectors specifically includes: The multiple initial block embedding vectors are transformed into the input format of a preset decoder using a preset projection layer to obtain multiple target block embedding vectors. The preset projection layer and the preset encoder are obtained through joint pre-training based on a block reconstruction task.

7. A long context search enhancement generation device, characterized in that, The long context retrieval enhancement generation device includes: The acquisition module is used to acquire the text to be processed based on the question terminology. The first generation module is used to generate multiple initial block embedding vectors based on the text to be processed and the preset encoder; The conversion module is used to convert the multiple initial block embedding vectors to the input format of a preset decoder to obtain multiple target block embedding vectors; The second generation module is used to input the multiple target block embedding vectors and the question lexical into a preset decoder to generate a solution to the target question.

8. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the long context retrieval enhanced generation method according to any one of claims 1-6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the long context retrieval enhancement generation method as described in any one of claims 1-6.

10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the long context retrieval enhancement generation method as described in any one of claims 1-6.