Long text intelligent answering method and apparatus based on intelligent agent and retrieval-augmented generation

By employing ColBERTv2 vector retrieval and hierarchical segmentation strategies, key segments of long documents are selected to ensure the credibility of answers generated by large models. This addresses the issues of answer quality and interpretability in long documents, achieving efficient and accurate extraction of key information and answer generation.

WO2025251379A1PCT designated stage Publication Date: 2025-12-11SHANDONG INSPUR SCI RES INST CO LTD

Patent Information

Application Number
PCT/CN2024/104733
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-06-05
Filing Date
2024-07-10
Publication Date
2025-12-11

AI Technical Summary

Technical Problem

Existing intelligent question answering systems struggle to provide high-quality, detailed answers when dealing with long documents, and large language models may generate answers without referencing the retrieved document, reducing the system's interpretability and credibility.

Method used

The ColBERTv2 vector retrieval method is used to quickly retrieve the entire document set from the document library. Long documents are divided into segments of reasonable length through a hierarchical segmentation strategy. The cross-entropy score is calculated to select the top-k relevant segments. A large model is used to generate conditional answers to ensure that the answers are generated based on the retrieved segments.

Benefits of technology

It improves the detailed answering capabilities and interpretability of open-domain question answering systems, ensuring that answers originate from key information in the retrieved documents, thereby enhancing retrieval efficiency and the credibility of answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024104733_11122025_PF_FP_ABST
    Figure CN2024104733_11122025_PF_FP_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of artificial intelligence. Disclosed are a long text intelligent answering method and apparatus based on an intelligent agent and retrieval-augmented generation. In the method of the present invention, the differences in model predicted logits in the presence and absence of a document context are compared, so as to ensure that a model answer is generated on the basis of a reference retrieval fragment. The method of the present invention can efficiently and accurately extract key semantic information from a long document, and guide a language model to generate a high-quality answer by referring to the information, thereby improving the detailed answering capability and interpretability of an open-domain question answering system.
Need to check novelty before this filing date? Find Prior Art

Description

Method and device for generating intelligent answers to long texts based on agents and retrieval enhancement TECHNICAL FIELD

[0001] The application discloses a method and device for generating intelligent answers to long texts based on agents and retrieval enhancement, and relates to the technical field of artificial intelligence. BACKGROUND

[0002] In today's big data era, vast amounts of unstructured text data contain valuable knowledge and insights. How to intelligently retrieve relevant content from a large document knowledge base and generate high-quality answers is an important issue in the fields of natural language processing and intelligent question answering.

[0003] Traditional intelligent question answering systems usually adopt a retrieval-augmented generation (RAG) process, which first retrieves a set of documents related to the question from a large text corpus, and then generates the final answer based on these documents. In this process, document retrieval and semantic understanding are two key links.

[0004] As for document retrieval, early keyword matching methods often perform poorly because they cannot capture semantic information. In recent years, dense vector retrieval models based on deep learning (such as BERT, ColBERT, etc.) can well capture the semantic relevance between queries and documents, but their retrieval efficiency is often low, which cannot meet the needs of real-time question answering.

[0005] As for semantic understanding, generating answers based on large language models (such as GPT-4, GLM-4, etc.) is currently the mainstream approach. However, when dealing with long documents, existing RAG systems have the following two main problems:

[0006] First, it is difficult to provide high-quality answers to document details. Long documents often contain a lot of redundant information, and directly inputting the full text into the language model will cause key details to be overwhelmed, making it difficult for the model to give accurate answers to specific questions in the document.

[0007] Second, it cannot be determined whether the model's answer is truly based on the retrieved materials. Large language models may generate seemingly reasonable answers without referencing the retrieved documents due to their prior knowledge, which will reduce the system's explainability and credibility.

[0008] Therefore, how to efficiently retrieve key semantic information related to the question from vast amounts of text and ensure that the language model's answer is generated based on these information is a key problem that needs to be solved for open-domain question answering systems.

[0009] SUMMARY

[0010] The present application aims at the problems of the prior art, and provides a method and device for generating an intelligent answer to a long text by an agent and retrieval enhancement.

[0011] In a first aspect, a method for generating an intelligent answer to a long text based on an agent and retrieval enhancement is provided, comprising:

[0012] S1. According to a given question q, a ColBERTv2 vector retrieval method is used to quickly retrieve a full document set D={d1, d2,..., dm} from a document knowledge base that is semantically related to the question q;

[0013] S2. According to a hierarchical segmentation strategy, each long document di in the full document set D is divided into a document segment set Fi={fi1, fi2,..., fini};

[0014] S3. According to the question q and the segment list Fi, a large model is inputted, and a semantic relevance score score(q, fj) is calculated by cross-entropy as a cross-entropy score;

[0015] S4. According to the cross-entropy score, the segment list Fi is filtered, a threshold k is set, and the top-k segments {f1, f2,..., fk} with the highest cross-entropy are retained;

[0016] S5. According to the score(q, fj) score difference, redundant segments are removed from the top-k segments to obtain a final segment set F';

[0017] S6. A large model is used to generate conditional answers from each segment in F', and these answers are combined as a final output.

[0018] In some implementations, S1 specifically comprises:

[0019] S11. All documents are offline vector encoded to obtain a document vector library V={v1, v2,..., vn};

[0020] S12. The question q is encoded into a vector vq;

[0021] S13. The cosine similarity sim(vq, vi)=vq·vi / ||vq||·||vi|| between vq and each vi in V is calculated;

[0022] S14. The cosine similarity score is sorted, and the top-N is taken as the final retrieved full document set D;

[0023] wherein vi and vq represent the vector representation of the document and the question, and ||v|| represents the L2 norm of the vector v.

[0024] In some implementations, S2 specifically includes:

[0025] S21, setting a target segment maximum length max len;

[0026] S22, using a sentence terminator to split the long document di into two sub-segments at a middle position of di;

[0027] S23, for a sub-segment with a length exceeding the maximum length max len, recursively performing the splitting operation of S22;

[0028] S24, merging all the split sub-segments into Fi.

[0029] In some implementations, S5 specifically includes:

[0030] S51, calculating the cross-entropy difference value | score(q, fi) - score(q, fj) | between each two segment pair (fi, fj);

[0031] S52, if the difference value exceeds a preset percentage threshold T, retaining the one with the highest relevance; otherwise, retaining the one with the shortest relevance; obtaining a final segment set F'.

[0032] In a second aspect, the embodiments of the present application provide a long text intelligent answering device based on agent and retrieval enhancement generation, comprising:

[0033] A retrieval module is configured to retrieve a full document set D = {d1, d2,..., dm} semantically related to a given question q from a document knowledge base through a ColBERTv2 vector retrieval method.

[0034] A splitting module is configured to split each long document di in the full document set D into a document segment set Fi = {fi1, fi2,..., fini} according to a hierarchical splitting strategy.

[0035] An analysis module is configured to input a large model according to the question q and the segment list Fi, and calculate the semantic relevance score score(q, fj) of the question q and the segment list Fi through cross-entropy as a cross-entropy score.

[0036] A retaining module is configured to set a threshold value k according to the cross-entropy score, and retain the top-k segments {f1, f2,..., fk} with the highest cross-entropy by screening the segment list Fi.

[0037] A deduplication module is configured to remove redundant segments in the top-k segments according to the score(q, fj) score difference, and obtain a final segment set F'.

[0038] A generating module is configured to generate conditional answers for each segment in F' by using the large model, and then combine the answers to obtain a final output.

[0039] In some implementations, the retrieving module specifically includes:

[0040] A first encoding unit is configured to perform vector encoding on all documents offline to obtain a document vector library V={v1, v2, …, vn};

[0041] A second encoding unit is configured to encode the question q into a vector vq;

[0042] A cosine processing unit is configured to calculate the cosine similarity sim(vq, vi) = vq·vi / ||vq||·||vi|| between vq and each vi in V;

[0043] A full-text processing unit is configured to sort according to the cosine similarity scores and take Top-N as the final retrieved full-text document set D;

[0044] wherein vi and vq represent vector representations of the documents and the question, and ||v|| represents the L2 norm of the vector v.

[0045] In some implementations, the segmenting module specifically includes:

[0046] A target setting unit is configured to set a target segment maximum length max_len;

[0047] A middle segmenting unit is configured to segment the long document di into two sub-segments at a middle position of the long document di using a sentence terminator;

[0048] A segmenting execution unit is configured to perform the segmenting operation of step S22 recursively for the sub-segment whose length exceeds the maximum length max_len;

[0049] A segment merging unit is configured to merge all the segmented sub-segments into Fi.

[0050] In some implementations, the deduplication module specifically includes:

[0051] A difference analyzing unit is configured to calculate the cross-entropy difference |score(q, fi)-score(q, fj)| between each two segment pairs (fi, fj);

[0052] A segment screening unit is configured to, if the difference exceeds a preset percentage threshold T, retain the one with the highest relevance; otherwise, retain the one with the shortest relevance; and obtain the final segment set F'.

[0053] Thirdly, embodiments of the present invention provide an electronic device, including a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein when the one or more computer instructions are executed by the processor, they implement the method described in the first aspect above.

[0054] Fourthly, embodiments of the present invention provide a computer storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, it implements the method described in the first aspect.

[0055] One or more embodiments of the present invention can bring at least the following beneficial effects: The method of the present invention first uses a vector retrieval model to quickly retrieve a preliminary set of full-text documents related to the question from a document library. Then, for each long document, a multi-granularity hierarchical segmentation strategy is used to segment it into a set of semantic fragments of reasonable length, from which the key information required to cover the question is accurately extracted. Next, by calculating the cross-entropy score between the question and each document fragment, their semantic relevance is measured, and the top-K fragments with the highest scores are retained and deduplicated to obtain the final fragment set F′. Finally, a large language model is instructed to generate local answers based on the fragments in F′, and all local answers are combined to generate the final answer. In this process, by comparing the difference in the model's predicted logits with and without document context, it is ensured that the model's answer is generated based on the referenced retrieved fragments. The method of the present invention can efficiently and accurately extract key semantic information from long documents, guide the language model to generate high-quality answers with reference to this information, thereby improving the detailed answering ability and interpretability of open-domain question answering systems. Attached Figure Description

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

[0057] Figure 1 is a flowchart of a long text intelligent response method based on intelligent agent and retrieval enhancement provided by an embodiment of the present invention;

[0058] Figure 2 is a block diagram of a long text intelligent response device based on intelligent agent and retrieval enhancement provided in an embodiment of the present invention. Detailed Implementation

[0059] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. The components of the embodiments of the present application described and shown in the drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.

[0060] Embodiment one:

[0061] Figure 1 shows a long text intelligent answering method flow chart based on agent and retrieval enhancement generation. As shown in Figure 1, the long text intelligent answering method based on agent and retrieval enhancement generation provided in the embodiment comprises:

[0062] S1, according to the given question q, the full document set D={d1, d2,..., dm} semantically related to the question q is quickly retrieved from the document knowledge base by ColBERTv2 vector retrieval method;

[0063] S2, according to the hierarchical segmentation strategy, each long document di in the full document set D is divided into a document segment set Fi={fi1, fi2,..., fini};

[0064] S3, according to the question q and the segment list Fi, input the big model, and calculate the semantic relevance score score(q, fj) as the cross entropy score by cross entropy;

[0065] S4, according to the cross entropy score, the segment list Fi is filtered by setting a threshold k, and the top-k segments {f1, f2,..., fk} with the highest cross entropy are retained;

[0066] S5, according to the score(q, fj) score difference, remove the redundant segments in the top-k segments to obtain the final segment set F';

[0067] S6, generate conditional answers for each segment in F' by the big model, and combine these answers into the final output.

[0068] When using the method of the present application, first, according to S1, the preliminary relevant full document set is retrieved; for a given question q, the full document set D={d1, d2,..., dm} semantically related to q is quickly retrieved from the document knowledge base by using ColBERTv2 vector retrieval method. Specifically, it includes:

[0069] S11, vector encoding all documents offline to obtain a document vector library V = {v1, v2,..., vn};

[0070] S12, encode the question q into a vector vq;

[0071] S13, calculate the cosine similarity sim(vq, vi) = vq·vi / ||vq||·||vi|| between vq and each vi in V;

[0072] S14, sort according to the cosine similarity score, and take Top-N as the final retrieved full document set D;

[0073] where vi and vq represent the vector representation of documents and questions, and ||v|| represents the L2 norm of vector v. The cosine similarity value ranges between [-1, 1], and the closer the value is to 1, the closer the direction of the two vectors, i.e., the higher the semantic relevance.

[0074] By calculating the cosine similarity between the question vector vq and all document vectors vi, and sorting according to the similarity score, the most relevant full document set D to the question q can be quickly retrieved from the massive document library. This lays the foundation for subsequent segmentation, sorting, and answer generation.

[0075] Next, search for the hierarchical segmentation of documents into standard segments according to S2; specifically including:

[0076] S21, set the maximum length of the target segment max_len;

[0077] S22, use the sentence terminator symbol to divide the long document di at the middle position into two sub-segments;

[0078] S23, for sub-segments whose length exceeds the maximum length max_len, recursively perform the segmentation operation of step S22;

[0079] S24, combine all segmented sub-segments into Fi.

[0080] For each di in D, the following hierarchical segmentation strategy is adopted to cut it into a set of reasonable length document segments Fi:

[0081] Input: long document di, target segment maximum length max_len

[0082] Output: document segment set Fi

[0083] The idea of this segmentation algorithm is as follows: first, use the sentence terminator punctuation marks (such as ".!?") to cut the long document di into two sub-segments near the middle position, obtaining a sub-segment list chunks.

[0084] For each chunk:

[0085] If the chunk length does not exceed max_len, directly add it to the final segment set Fi;

[0086] If the chunk length exceeds max_len, recursively call the divide() function to continue to divide the chunk, and the obtained sub-chunks are added to Fi.

[0087] Next, according to S3, input the question q and the segment list Fi into the large model to calculate the cross-entropy score of the document segment. The application needs to use a locally deployed large model, such as Qwen series, ChatGLM3-6B, etc. Online large models such as GPT-4 cannot obtain logits distribution and cannot be used in the method described in the application.

[0088] For each question q and segment fj, calculate its cross-entropy score score(q, fj).

[0089] The cross-entropy score is defined as follows:

[0090] Let the question be q and the document segment be d. Let G(q) represent the baseline logits distribution of the large model based on q, and G(q, d) represent the new logits distribution when d is used as the context. We define the relevance score of q and d as the cross-entropy:

[0091] score(q, d) = -∑p(y|q)log(p(y|q, d))

[0092] Where p(y|q) is the probability of y under the baseline logits distribution, and P(y|q, d) is the probability of y under the conditional logits distribution.

[0093] This score can be interpreted as the KL divergence that occurs when considering d compared to G(q). The larger the score, the greater the change in semantic understanding of d to q, i.e., the more relevant d is to q.

[0094] The steps for calculating the above cross-entropy score include:

[0095] S31, let the large model perform greedy generation without context for the question q to obtain the baseline logits sequence G(q) = [g1, g2,..., gn]; connect d to q and let the LLM perform greedy generation with context to obtain the conditional logits sequence G(q, d) = [g'1, g'2,..., g'n];

[0096] S32, calculate the cross-entropy score score(q, d) = -∑softmax(gi)log(softmax(g'i)).

[0097] By comparing the difference between G(q) and G(q, d), we can directly evaluate the degree of influence of d on the semantic understanding of the LLM, and then measure the correlation between q and d.

[0098] Next, according to S4, the Top-K high-scored segments are retained; according to the cross-entropy score calculated in S3, the segment list Fi is filtered. Set the threshold k, and retain the top-k segments with the highest cross-entropy {f1, f2,..., fk}.

[0099] Next, according to S5, further deduplication is performed in the Top-K segments, which specifically includes:

[0100] S51, calculate the cross-entropy difference between each two segment pair (fi, fj) |score(q, fi)-score(q, fj)|;

[0101] S52, if the difference exceeds the preset percentage threshold T, the one with the highest correlation is retained; otherwise, the one with the shortest correlation is retained; the final segment set F' is obtained.

[0102] Finally, according to S6, the final answer is generated: let the LLM generate conditional answers aj' according to each segment fj' in F', and then generate the final answer a by synthesizing all aj'.

[0103] Embodiment two:

[0104] Figure 2 shows a block diagram of an intelligent agent and retrieval-enhanced generation-based long text intelligent answering device, as shown in Figure 2, the intelligent agent and retrieval-enhanced generation-based long text intelligent answering device provided by the embodiment comprises:

[0105] The retrieval module is configured to retrieve a full document set D = {d1, d2,..., dm} semantically related to the given question q from the document knowledge base through the ColBERTv2 vector retrieval method;

[0106] The segmentation module is configured to divide each long document di in the full document set D into a document segment set Fi = {fi1, fi2,..., fini} according to a hierarchical segmentation strategy;

[0107] The analysis module is configured to input the question q and the segment list Fi into a large model to calculate the semantic correlation score score(q, fj) of the question q and the segment list Fi as the cross-entropy score.

[0108] a reservation module configured to reserve top-k segments {f1, f2,..., fk} with the highest cross-entropy scores by filtering the segment list Fi and setting a threshold k according to the cross-entropy scores;

[0109] a deduplication module configured to remove redundant segments from the top-k segments to obtain a final segment set F' according to the score(q, fj) score difference;

[0110] a generation module configured to generate conditional answers for each segment in F' by the large model and combine the answers into a final output.

[0111] Further, the retrieval module specifically includes:

[0112] a first encoding unit configured to perform vector encoding on all documents offline to obtain a document vector library V={v1, v2,..., vn};

[0113] a second encoding unit configured to encode the question q into a vector vq;

[0114] a cosine processing unit configured to calculate the cosine similarity sim(vq, vi)=vq·vi / ||vq||·||vi|| between vq and each vi in V;

[0115] a full-text processing unit configured to sort according to the cosine similarity score and take top-N as the final retrieved full-text document set D;

[0116] wherein vi and vq represent vector representations of documents and questions, and ||v|| represents the L2 norm of vector v.

[0117] Further, the segmentation module specifically includes:

[0118] a target setting unit configured to set a target segment maximum length max_len;

[0119] a middle segmentation unit configured to segment the long document di into two sub-segments at a middle position of the long document di using a sentence terminator;

[0120] a segmentation execution unit configured to recursively perform the segmentation operation of step S22 for the sub-segment whose length exceeds the maximum length max_len;

[0121] a segment merging unit configured to merge all segmented sub-segments into Fi.

[0122] Further, the deduplication module specifically includes:

[0123] a difference analysis unit configured to calculate a difference of cross-entropy between each two segments pair (fi, fj) as |score(q, fi)-score(q, fj)|

[0124] a segment screening unit configured to keep the one with the highest relevance if the difference exceeds a preset percentage threshold T, or keep the one with the shortest relevance otherwise, to obtain a final segment set F′.

[0125] Embodiment Three

[0126] The embodiment also provides an electronic device, including a memory and a processor, the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method in Embodiment One.

[0127] In actual application, the processor can be an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a controller, a microcontroller (MCU), a microprocessor or other electronic elements, which are used to execute the method in the above embodiments.

[0128] The method implemented by the embodiment is as described in Embodiment One.

[0129] Embodiment Four

[0130] The embodiment also provides a computer storage medium, the computer readable storage medium stores a computer program, and the computer program is executed by one or more processors to implement the method in Embodiment One.

[0131] The computer readable storage medium can be realized by any type of volatile or nonvolatile storage devices or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0132] The method implemented by the embodiment includes:

[0133] The method implemented by the embodiment is as described in Embodiment One.

[0134] In several embodiments provided by the embodiment of the application, it should be understood that the disclosed system and method can also be implemented by other ways. The system and method embodiments described above are only illustrative.

[0135] It should be noted that in this paper, the terms "first", "second" and the like in the description and claims of the application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. The terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0136] Although the embodiments of the present application are disclosed as above, the content described is only for the purpose of facilitating understanding of the embodiments adopted by the present application, and is not intended to limit the present application. Any person skilled in the art of the present application can make any modification and change in the form and details without departing from the spirit and scope of the present application, but the patent protection scope of the present application shall be subject to the scope defined by the appended claims.

Claims

1. A long text intelligent answering method based on agent and retrieval enhancement generation, characterized in that, Comprising: S1, according to the given question q, through ColBERTv2 vector retrieval method, retrieve the full document set D={d1, d2,..., dm} from the document knowledge base which is semantically related to the question q quickly; S2, according to the hierarchical segmentation strategy, by dividing each long document di in the full document set D into a document segment set Fi={fi1, fi2,..., fini}; S3, according to the question q and the segment list Fi input the large model, calculate its semantic relevance score score(q, fj) as the cross entropy score by cross entropy; S4, according to the cross entropy score, by screening the segment list Fi, set threshold k, keep the top-k segments with the highest cross entropy {f1, f2,..., fk}; S5, according to the score(q, fj) score difference, remove redundant segments in the top-k segments to get the final segment set F'; S6, generate conditional answers for each segment in F' through the large model, and then combine these answers into the final output.

2. The method of claim 1, wherein, S1, specifically comprising: S11, encode all documents offline to get document vector library V={v1, v2,..., vn}; S12, encode the question q into vector vq; S13, calculate the cosine similarity sim(vq, vi)=vq·vi / ||vq||·||vi|| between vq and each vi in V; S14, sort according to the cosine similarity score, and take Top-N as the final retrieved full document set D; Wherein, vi, vq represents the vector representation of the document and the question, ||v|| represents the L2 norm of the vector v.

3. The method of claim 2, wherein, S2, specifically comprising: S21, set the maximum length of the target segment max_len; S22, use the sentence terminator symbol to divide the long document di into two sub segments at the middle position; S23, for the sub segment whose length exceeds the maximum length max_len, recursively perform the segmentation operation of step S22; S24, combine all the segmented sub segments into Fi.

4. The method of claim 3, wherein, S5, specifically comprising: S51, calculate the cross entropy difference |score(q, fi)-score(q, fj)| between each two segment pair (fi, fj); S52, if the difference exceeds the preset percentage threshold T, keep the one with the highest relevance; Otherwise, keep the one with the shortest relevance; Get the final segment set F'.

5. An intelligent long text answering device based on agent and retrieval enhancement generation, characterized in that, Comprising: The retrieval module is used for retrieving the full document set D={d1, d2,..., dm} from the document knowledge base which is semantically related to the question q according to the given question q through ColBERTv2 vector retrieval method; The segmentation module is used for dividing each long document di in the full document set D into a document segment set Fi={fi1, fi2,..., fini} according to the hierarchical segmentation strategy; The analysis module is used for calculating the semantic relevance score score(q, fj) as the cross entropy score by cross entropy according to the question q and the segment list Fi input the large model; A reservation module is configured to reserve the top-k segments with the highest cross-entropy scores by screening the segment list Fi and setting a threshold k. A deduplication module is configured to remove redundant segments from the top-k segments according to the score(q, fj) score difference to obtain a final segment set F'. A generation module is configured to generate conditional answers for each segment in F' by using a large model and then combine the answers into a final output.

6. The apparatus of claim 5, wherein, The retrieval module specifically includes: A first encoding unit is configured to encode all documents offline to obtain a document vector library V = {v1, v2,..., vn}. A second encoding unit is configured to encode a question q into a vector vq. A cosine processing unit is configured to calculate the cosine similarity sim(vq, vi) = vq·vi / ||vq||·||vi|| between vq and each vi in V. A full-text processing unit is configured to sort the cosine similarity scores and take the top-N as a final retrieved full-text document set D. Wherein, vi and vq represent the vector representation of the document and the question, and ||v|| represents the L2 norm of the vector v.

7. The apparatus of claim 6, wherein, The segmentation module specifically includes: A target setting unit is configured to set a target segment maximum length max_len. A middle segmentation unit is configured to segment the long document di into two sub-segments at a middle position of the long document di using a sentence terminator. A segmentation execution unit is configured to recursively perform the segmentation operation of step S22 for sub-segments with a length exceeding the maximum length max_len. A segment merging unit is configured to merge all segmented sub-segments into Fi.

8. The apparatus of claim 7, wherein, The deduplication module specifically includes: A difference analysis unit is configured to calculate the cross-entropy difference between each two segment pairs (fi, fj) |score(q, fi)-score(q, fj)|. A segment screening unit is configured to retain the one with the highest relevance if the difference exceeds a preset percentage threshold T, or retain the one with the shortest relevance otherwise, to obtain a final segment set F'.

9. An electronic device, comprising: The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the long text intelligent answering method based on agent and retrieval enhanced generation according to any one of claims 1-4.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the long text intelligent answering method based on agent and retrieval enhanced generation according to any one of claims 1-4.

Citation Information

Patent Citations

  • Knowledge retrieval method, equipment, storage medium and device

    CN117763126A

  • Traditional Chinese medicine question and answer method and device based on long document retrieval enhancement generation and medium

    CN117828050A

  • Government affair intelligent response device and method based on intention recognition and large language model

    CN118035419A

  • Intelligent long text answering method and device based on agent and retrieval enhancement generation

    CN118296133A

  • Questions and answers generation

    US20110125734A1

Cited By

  • High-quality metal material process data set construction method based on large language model

    CN121789818A