Full text and fragment combined retrieval generation method and device

By identifying query types and employing a document segmentation strategy, combined with a mapping-reduction module to read the full text in chunks, and generating structured answers, the problem of high computational load and resource requirements in existing technologies is solved. This achieves fast and accurate answers to fragmented and global questions, while reducing hardware resource requirements.

CN120994806APending Publication Date: 2025-11-21ZHONGKE ZIDONG TAICHU (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511012719.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-22
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

Existing retrieval generation methods are computationally intensive and resource-intensive, making it difficult to quickly and accurately answer fragment or global questions in low-resource scenarios.

Method used

By identifying the query type, relevant documents in the knowledge base are retrieved first. A document fragmentation strategy is adopted to solve the input length limitation of the large model. The full text content is read in blocks by combining the mapping-reduction module to generate structured answers and perform comprehensive reasoning.

Benefits of technology

While ensuring the feasibility of large-scale text processing, it balances the comprehensiveness of retrieval with the accuracy of generation, achieving fast and accurate fragment and global question answers, and reducing hardware resource requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994806A_ABST
    Figure CN120994806A_ABST
Patent Text Reader

Abstract

The invention provides a full text and fragment combined retrieval generation method and device, which are applied to the technical field of information retrieval and comprise the following steps: determining a query type of a query text input by a user; when the query type of the query text is full-text search, obtaining all candidate documents associated with the query text in a preset knowledge base; segmenting all the candidate documents according to a preset fragment length to obtain a plurality of fragment documents; splicing of each fragment document in the multiple fragment documents and the query text is input into a large language model, multiple structured answers are obtained, and each structured answer in the multiple structured answers corresponds to each fragment document; and splicing and inputting the plurality of structured answers and the query text into a large language model to obtain a target answer corresponding to the query text. According to the invention, fragment questions can be quickly and accurately answered, and global questions can be quickly answered in a low-resource scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information retrieval technology, and in particular to a retrieval generation method and apparatus that combines full text and fragments. Background Technology

[0002] Retrieval-Augmented Generation (RAG) is a technology that combines information retrieval and text generation. It first retrieves relevant data from external knowledge bases or documents, and then generates more accurate and reliable answers based on the retrieval results, thereby improving the factuality and relevance of the generated content. It is widely used in scenarios such as intelligent question answering and dialogue systems that require the integration of real-time or domain-specific knowledge.

[0003] In related technologies, even for questions that only require reading a small fragment of a document, the entire document content and the question must be fed into a large language model. Since the length of all documents is generally quite long, the large language model requires a large amount of computation, which places a heavy burden on hardware resources.

[0004] It is evident that the retrieval and generation methods in related technologies suffer from technical problems such as high computational load and high resource requirements. Summary of the Invention

[0005] This invention provides a retrieval generation method and apparatus that combines full-text and fragment data to address the shortcomings of existing retrieval generation methods, which involve large computational loads and high resource requirements. This allows for both fast and accurate answers to fragment-related questions and rapid answers to global questions in low-resource scenarios.

[0006] This invention provides a retrieval generation method combining full-text and fragment data, comprising the following steps: Determining the query type of the user-input query text, wherein the query type includes: full-text search; when the query type of the query text is full-text search, obtaining all candidate documents associated with the query text in a preset knowledge base; when the concatenation length of the query text and all candidate documents exceeds the length range threshold of a large language model, segmenting all candidate documents according to a preset fragment length to obtain multiple fragment documents; inputting the concatenation of each fragment document and the query text into the large language model to obtain multiple structured answers, wherein each structured answer corresponds to each fragment document; inputting the concatenation of the multiple structured answers and the query text into the large language model to obtain the target answer corresponding to the query text.

[0007] According to the present invention, a retrieval generation method combining full text and fragments is provided. The query type includes fragment search. After determining the query type of the query text input by the user, the method further includes: when the query type of the query text is fragment search, obtaining all candidate fragments associated with the query text in a preset knowledge base; and inputting the concatenation of the query text and all candidate fragments into a large language model to obtain the target answer corresponding to the query text.

[0008] According to the retrieval and generation method combining full text and fragments provided by the present invention, after obtaining all candidate documents associated with the query text in the preset knowledge base, the method further includes: when the concatenation length of the query text and all candidate documents does not exceed the length range threshold of the large language model, inputting the concatenation of the query text and all candidate documents into the large language model to obtain the target answer corresponding to the query text.

[0009] According to a retrieval generation method combining full text and fragments provided by the present invention, the method further includes: when the combined length of multiple structured answers and the query text exceeds the length range threshold, repeating the following steps until the combined length of multiple structured answers and the query text is less than the length range threshold: segmenting the multiple structured answers according to the preset fragment length to obtain multiple segmented answer fragments; inputting the combined length of each segmented answer fragment and the query text into a large language model to obtain updated multiple structured answers.

[0010] According to the retrieval generation method combining full text and fragments provided by the present invention, after inputting the concatenation of each segmented answer fragment and the query text into a large language model to obtain updated multiple structured answers, the method further includes: inputting the concatenation of the updated multiple structured answers and the query text into a large language model to obtain the target answer corresponding to the query text.

[0011] This invention also provides a retrieval and generation device combining full-text and fragment data, comprising the following modules: a determination module, used to determine the query type of the query text input by the user, wherein the query type includes: full-text search; an acquisition module, used to acquire all candidate documents associated with the query text in a preset knowledge base when the query type of the query text is full-text search; a segmentation module, used to segment all candidate documents according to a preset fragment length when the concatenation length of the query text and all candidate documents exceeds the length range threshold of a large language model, to obtain multiple fragment documents; a search module, used to input the concatenation of each fragment document and the query text into the large language model to obtain multiple structured answers, wherein each structured answer corresponds to each fragment document; and a question-answering module, used to input the concatenation of the multiple structured answers and the query text into the large language model to obtain the target answer corresponding to the query text.

[0012] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the retrieval and generation method combining full text and fragments as described above.

[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the retrieval and generation method combining full text and fragments as described above.

[0014] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the retrieval and generation method combining full text and fragments as described above.

[0015] The retrieval and generation method and apparatus combining full-text and fragments provided by this invention identifies the query type of full-text search, prioritizes the retrieval of all relevant documents in the knowledge base to ensure information coverage, then adopts a document fragmentation strategy to solve the problem of input length limitation of large models, combines the fragmented parts with the query to generate preliminary structured answers, and finally aggregates all intermediate results for comprehensive reasoning. While ensuring the feasibility of large-scale text processing, it achieves global information integration through a two-stage answer generation mechanism, effectively balancing the contradiction between retrieval comprehensiveness and generation accuracy. Attached Figure Description

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

[0017] Figure 1 This is a flowchart illustrating the retrieval and generation method combining full text and fragments provided by the present invention.

[0018] Figure 2 This is a schematic diagram of document cutting provided by the present invention.

[0019] Figure 3 This is a schematic diagram of the question-and-answer process provided by the present invention.

[0020] Figure 4 This is a flowchart illustrating the question-and-answer module provided by the present invention.

[0021] Figure 5 This is a schematic diagram of the structure of the retrieval and generation device that combines full text and fragments provided by the present invention.

[0022] Figure 6 This is a schematic diagram of the physical structure of the electronic device provided by the present invention. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0024] The current document's Q&A section is mainly divided into two methods: End2end (End-to-End Approach): Directly feeds all document content and user questions into the large language model.

[0025] Pipeline Approach: First, the document content is sliced ​​according to a certain method and then stored in a knowledge base. When a question comes, multiple most relevant document fragments are searched from the knowledge base, and then these document fragments and the question are concatenated together and fed into the large language model.

[0026] The drawback of the End2end method is that even for questions that only require reading a small segment of a document, the entire document content and the question must be fed into a large language model. Since the length of all documents is generally quite long, the large language model requires a large amount of computation, which places a heavy burden on hardware resources.

[0027] The drawback of the Pipeline method is that, because it relies on retrieving and matching document fragments, it performs poorly for questions that require reading the full text. Specifically: it cannot directly retrieve relevant document fragments for full-text questions; and the retrieved document fragments are incomplete and cannot fully answer the full-text question.

[0028] To address the two issues mentioned above, this invention proposes a retrieval generation method that combines full-text and fragment retrieval. Specifically, we introduce an agent module to determine whether the query requires fragment retrieval or full-text retrieval.

[0029] For fragment issues, there is no difference from the traditional pipeline approach.

[0030] For full-text questions, a Large Language Model (LLM) and MapReduce module are further introduced to read the full text in chunks and then summarize the answers, which greatly reduces the time complexity and hardware requirements.

[0031] Optionally, the retrieval and generation method combining full text and fragments in this embodiment can be executed by a server, by a terminal device, or by both a server and a terminal device. For example, the retrieval and generation method combining full text and fragments in this embodiment can be executed by a server.

[0032] Figure 1 This is a flowchart illustrating the retrieval and generation method combining full text and fragments provided by the present invention, as shown below. Figure 1 As shown, the method includes the following steps.

[0033] Step 101: Determine the query type of the query text entered by the user, where the query type includes: full-text search.

[0034] In this embodiment of the invention, the agent module receives the query text input by the user and clarifies the query type (Search_type) of the query text.

[0035] Step 102: When the query type of the query text is full-text search, obtain all candidate documents associated with the query text in the preset knowledge base.

[0036] In some embodiments, a pre-trained semantic matching model is used to encode the query text and the content of each document in the preset knowledge base into high-dimensional vectors, respectively, to obtain query text vectors and document content vectors; the cosine similarity between each query text vector and document content vector is determined, and documents with a cosine similarity greater than a preset similarity threshold are set as association candidates.

[0037] Step 103: When the combined length of the query text and all candidate documents exceeds the length range threshold of the large language model, all candidate documents are segmented according to the preset segment length to obtain multiple segment documents.

[0038] If the combined length of all candidate documents and the query text exceeds the allowable range of the current large language model, the LLM×MapReduce module is used to segment all candidate documents into n fragments according to a certain length.

[0039] In some embodiments, the sliding window size is set to N tokens (e.g., 2048 tokens), and the step size is M tokens (e.g., 1024 tokens) to ensure that adjacent segments overlap and avoid information breaks. Semantic blocks are identified using an NLP model, prioritizing segmentation by paragraph, chapter, or punctuation (e.g., period, section break).

[0040] Each segment begins with the last K tokens (e.g., 256 tokens) of the previous segment to maintain contextual coherence; the end of each segment begins with the first L tokens (e.g., 128 tokens) of the next segment to indicate the direction of subsequent content.

[0041] Use regular expressions to detect and avoid cutting off specific patterns (such as tables, formulas, and code blocks); if entities (such as names or dates) are detected, ensure that they are completely contained within a single fragment.

[0042] refer to Figure 2 , Figure 2 This is a document segmentation diagram provided by the present invention, which includes: mapping, folding, and reducing.

[0043] Map Stage: Input: The original long text is divided into multiple text chunks (Chunk 1~N) according to preset rules. Processing logic includes: Each text chunk is input into the LLM separately, generating a structured intermediate result (MappedResult), which includes: Extracted Information: Key facts extracted from the text chunk; Rationale: The LLM's reasoning and analysis process; Answer: Preliminary conclusions based on the extracted information; Confidence Score: The reliability score of the answer (e.g., 1-5 points); If the LLM determines that a text chunk has no relevant information, it is marked as "NO INFORMATION" and discarded (DROP).

[0044] Collapse Stage: Input: All valid intermediate results (Result 1~K) output from the mapping stage. Processing logic includes: Grouping and merging: Aggregating semantically related intermediate results into groups (Group 1~K), for example: clustering by entity (such as name, term) or topic; retaining different answers within the group and their confidence scores. Conflict resolution: For contradictory answers within the same group (such as "Answer A" and "Answer B" with similar confidence scores), mark them as "OR" for processing in subsequent stages.

[0045] Reduce Stage: Input: The structured results set (CollapsedResults) output from the Collapsing Stage. Processing logic includes: inputting the grouped results back into the LLM, performing global analysis: integrating all extracted information, reasons, and confidence scores; resolving inter-group conflicts (such as contradictory answers across groups); generating the final answer and the complete reasoning chain (Rationale). If the final answer is still uncertain, it is marked as "NO INFORMATION".

[0046] Step 104: Input the concatenation of each fragment document and the query text from the multiple fragment documents into the large language model to obtain multiple structured answers.

[0047] Each structured answer in the multiple structured answers corresponds to a fragment document.

[0048] In this embodiment of the invention, each of the n document fragments is concatenated with the Query and fed into a large language model to obtain n structured answers (including extracted information, given reasons, answers, and confidence scores). Specifically, the steps include: Extract information: Extract key facts or data related to the query from the current block to provide the necessary background for resolving inter-block dependencies in subsequent stages.

[0049] The rationale is that explaining the analytical or reasoning process by which the model derives intermediate answers from the extracted information helps reduce the risk of hallucinations in later stages.

[0050] Answer: Based on the information extracted above and the given reasons, an intermediate answer to the query is derived. If, after providing the reasons, the model determines that the article does not contain relevant information to solve the problem, it will output "No information" and will be ignored in subsequent stages.

[0051] Confidence score: A score (out of 5) reflecting the model's confidence in the answer, indicating the completeness and reliability of the information. The confidence score is important for resolving inter-block conflicts.

[0052] Step 105: The concatenation of multiple structured answers and the query text is input into the large language model to obtain the target answer corresponding to the query text.

[0053] In this embodiment of the invention, if the combined length of multiple structured answers and query text is within the allowable range of the large language model, they are directly fed into the large language model to obtain the final answer (target answer).

[0054] In some embodiments, a consistent format should be maintained during concatenation. For example, specific delimiters (such as [SEP], ###) should be used to clearly distinguish the query text from each structured answer, preventing the model from confusing information sources. A clear prompt should be added at the beginning or end of the concatenated text to indicate that the model should generate a comprehensive answer based on all input content. If the concatenated text is still close to the model's length limit, partial structured answers can be input in batches to gradually generate intermediate results, which can then be merged into the final answer.

[0055] The model's output target answer is deduplicated, merging repeated or redundant information. For example, text similarity algorithms (such as TF-IDF and Sentence-BERT) are used to identify similar segments and retain the optimal expression.

[0056] refer to Figure 3 , Figure 3 This is a schematic diagram of the question-and-answer process provided by the present invention.

[0057] like Figure 3 As shown, the system obtains the user's query text (Query), inputs it into the agent, and obtains an optimized new query (rewritten_query) and query type (search_type) to improve search accuracy and determine subsequent search strategies. The optimized new query (rewritten_query) and query type (search_type) are then input into the search module to obtain search results; finally, the search results are input into the question-answering module to obtain the target answer.

[0058] Through the steps described above in this embodiment of the invention, by identifying the query type of full-text search, all relevant documents in the knowledge base are retrieved first to ensure information coverage. Then, a document fragmentation strategy is adopted to solve the problem of input length limitation of large models. The fragmented parts are combined with the query to generate preliminary structured answers. Finally, all intermediate results are aggregated for comprehensive reasoning. While ensuring the feasibility of large-scale text processing, the two-stage answer generation mechanism realizes global information integration, effectively balancing the contradiction between retrieval comprehensiveness and generation accuracy.

[0059] According to the retrieval generation method combining full text and fragments provided by the present invention, the query type includes: fragment search. After determining the query type of the query text input by the user, the method further includes: When the query type of the query text is fragment search, retrieve all candidate fragments associated with the query text from the preset knowledge base; The query text and all candidate segments are concatenated and input into a large language model to obtain the target answer corresponding to the query text.

[0060] In this embodiment of the invention, if the query type (Search_type) of the query text (Query) is a fragment search, a preset pipeline process is executed.

[0061] In some embodiments, the query text entered by the user is first identified to determine that the query type is a fragment search. This means that the user wants to obtain precise information about a specific fragment in a document, rather than a generalized result of the entire text.

[0062] Based on the fragment search type, candidate document fragments that are most semantically relevant to the query text are retrieved from a pre-defined knowledge base. This is typically achieved using high-precision retrieval algorithms (such as BM25, DPR, etc.) to ensure a strong relevance between the fragments and the query.

[0063] The query text is concatenated with all retrieved candidate fragments to form a composite input containing the query intent and information from multiple fragments. Clear delimiters (such as [SEP]) are used during concatenation to distinguish different fragments and avoid information confusion.

[0064] The concatenated composite input is fed into a large language model (such as GPT, BERT, etc.). The model understands the relationship between the query text and each segment based on the context, and directly generates the target answer for the segment search. This process does not require processing segments step by step; the model integrates all information and outputs the result at once.

[0065] The target answer generated by the model needs to accurately reflect the relationship between the query text and the candidate segments, and may include key data, comparative analysis or comprehensive conclusions from the segments.

[0066] Through the embodiments of the present invention, by designing a dedicated pipeline for fragment search type, the present invention can efficiently handle users' precise needs for local information of documents, avoid the interference of redundant information in full-text retrieval, and at the same time utilize the contextual understanding capabilities of large language models to directly generate high-quality, highly relevant target answers, thereby improving the practicality of the retrieval generation system and the user experience.

[0067] According to the retrieval and generation method combining full text and fragments provided by the present invention, after obtaining all candidate documents associated with the query text in a preset knowledge base, the method further includes: If the combined length of the query text and all candidate documents does not exceed the length range threshold of the large language model, the combined length of the query text and all candidate documents is input into the large language model to obtain the target answer corresponding to the query text.

[0068] In this embodiment of the invention, if the combined length of all candidate documents and query text is within the allowable range of the current large language model, the combined length of all candidate documents and query text is directly sent to the large language model to obtain the target answer, just like the end-to-end (E2E) method.

[0069] For example, the input length range threshold is first dynamically determined based on the parameters of the currently invoked large language model (such as the token number limit and context window size). For instance, if the model supports 4096 tokens, the total number of tokens in the concatenated text must be ≤4096.

[0070] The concatenated complete text is fed into the large language model as a single input batch, avoiding the context fragmentation caused by batch processing. Explicit prompts are added at the beginning or end of the concatenated text to guide the model in outputting high-quality answers. Based on the query intent and contextual information in the concatenated text, the model directly outputs the target answer.

[0071] Through the embodiments of the present invention, single-input processing avoids the delay and cumulative error caused by step-by-step processing, significantly improving reasoning efficiency; the end-to-end approach preserves the complete context of the query text and all candidate documents, ensuring that the model can fully understand the question and generate a comprehensive answer.

[0072] According to the retrieval generation method combining full text and fragments provided by the present invention, multiple structured answers and query text are concatenated and input into a large language model to obtain the target answer corresponding to the query text, including: When the combined length of multiple structured answers and query text does not exceed the length range threshold, the combined length of multiple structured answers and query text is input into the large language model to obtain the target answer corresponding to the query text.

[0073] In some embodiments, multiple structured answers are concatenated with the query text. If the concatenation length is within the threshold of the length range of the large language model, the concatenation of multiple structured answers and the query text is directly input into the large language model to obtain the target answer.

[0074] Through the embodiments of the present invention, redundant block processing is avoided and computational costs are reduced by directly splicing content that does not exceed the limit.

[0075] According to the retrieval generation method combining full text and fragments provided by the present invention, the method further includes: If the combined length of multiple structured answers and query text exceeds the length range threshold, repeat the following steps until the combined length of multiple structured answers and query text is less than the length range threshold: Multiple structured answers are segmented according to a preset segment length to obtain multiple segmented answer fragments; Each segmented answer fragment and the concatenation of the query text from multiple segmented answer fragments are input into the large language model to obtain multiple updated structured answers.

[0076] In this embodiment of the invention, if the combined length of multiple structured answers and the query text exceeds a length threshold, the multiple structured answers are divided into multiple segmented answer fragments according to a certain length. Each of these segmented answer fragments is then repeatedly concatenated with the query text and fed into the large language model to obtain updated multiple structured answers (including extracted information, given reasons, answers, and confidence scores). This process continues until the overall length of the multiple structured answers and the query text is within the allowable range of the large language model, at which point they are directly fed into the large language model to obtain the target answer.

[0077] According to the retrieval generation method combining full text and fragments provided by the present invention, after inputting the concatenation of each segmented answer fragment and the query text into a large language model to obtain multiple updated structured answers, the method further includes: The updated structured answers are concatenated with the query text and input into the large language model to obtain the target answer corresponding to the query text.

[0078] refer to Figure 4 , Figure 4 This is a flowchart illustrating the question-and-answer module provided by the present invention.

[0079] like Figure 4 As shown, input the query type (Search_type), search results, and query text (query), and determine whether to perform a full-text search. If yes, input n document fragments and the query text (query) into the large language model and the MapReduce module to obtain the target answer (answer). If no, input the query text (query) and candidate fragments as prompt words (Prompt) into the large language model to obtain the target answer (answer).

[0080] The following describes an example of the retrieval and generation method combining full text and fragments provided by the present invention in a practical application, specifically including the following steps.

[0081] Step 1: The user's query text (query) first passes through the agent module to clarify the search type (search_type).

[0082] Step 2: If search_type is fragment, follow the original pipeline process.

[0083] Step 3: If search_type is full text, all documents in the current knowledge base will be retrieved.

[0084] Step 4: If the length of all documents and the query is within the allowable range of the current large language model, just like the end2end method, directly concatenate all documents and the query and send them into the large language model to get the answer.

[0085] Step 5: If the total length of all documents and queries exceeds the allowable range of the current large language model, use the LLM×MapReduce module to divide the document content into n segments according to a certain length.

[0086] Step 6, Mapping: Each of these n fragments is concatenated with the query and fed into the large language model to obtain n structured answers (including extracted information, given reasons, answers, and confidence scores). These include: Extract information: Extract key facts or data related to the query from the current block to provide the necessary background for resolving inter-block dependencies in subsequent stages.

[0087] The rationale is that explaining the analytical or reasoning process by which the model derives intermediate answers from the extracted information helps reduce the risk of hallucinations in later stages.

[0088] Answer: Based on the information extracted above and the given reasons, an intermediate answer to the query is derived. If, after providing the reasons, the model determines that the article does not contain relevant information to solve the problem, it will output "No information" and will be ignored in subsequent stages.

[0089] Confidence score: This score reflects the model's confidence in the answer, indicating the completeness and reliability of the information. The confidence score is important for resolving inter-block conflicts.

[0090] Step 7, Reduce: Combine the n structured answers with the query.

[0091] If the length is within the allowable range of the large language model, it can be directly fed into the large language model to obtain the final answer.

[0092] If the length still exceeds the allowable range of the large language model, divide these n structured answers into m blocks according to a certain length, repeat the map process, until the length of the obtained structured answers and the overall length of the query are within the allowable range of the large language model, and then directly feed them into the large language model to obtain the final answer.

[0093] The above methods enable the rag strategy to effectively handle both local and global issues, while requiring only limited deployment resources.

[0094] Compared to existing technologies, this application combines the advantages of pipeline and end2end, enabling it to answer fragment questions quickly and accurately, as well as global questions quickly in low-resource scenarios, achieving a balance between efficiency and speed.

[0095] The following describes the retrieval and generation apparatus combining full text and fragments provided by the present invention. The retrieval and generation apparatus combining full text and fragments described below can be referred to in correspondence with the retrieval and generation method combining full text and fragments described above.

[0096] refer to Figure 5 , Figure 5 This is a schematic diagram of the structure of the retrieval and generation device that combines full text and fragments provided by the present invention.

[0097] The determination module 501 is used to determine the query type of the query text input by the user, wherein the query type includes: full-text search; The acquisition module 502 is used to acquire all candidate documents associated with the query text in the preset knowledge base when the query type of the query text is full-text search; The segmentation module 503 is used to segment all candidate documents according to a preset segment length when the concatenation length of the query text and all candidate documents exceeds the length range threshold of the large language model, so as to obtain multiple segment documents. The search module 504 is used to input the concatenation of each fragment document and the query text from multiple fragment documents into the large language model to obtain multiple structured answers, wherein each structured answer corresponds to each fragment document. The question-answering module 505 is used to concatenate multiple structured answers with the query text and input them into the large language model to obtain the target answer corresponding to the query text.

[0098] Specifically, the retrieval and generation apparatus combining full text and fragments provided by the present invention can realize all the method steps implemented in the above-mentioned retrieval and generation method embodiment combining full text and fragments, and can achieve the same technical effect. Here, the parts that are the same as those in the method embodiment and the beneficial effects will not be described in detail.

[0099] Figure 6 This is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as... Figure 6As shown, the electronic device may include: a processor 610, a communications interface 620, a memory 630, and a communications bus 640, wherein the processor 610, the communications interface 620, and the memory 630 communicate with each other through the communications bus 640. The processor 610 can call logical instructions in the memory 630 to execute a retrieval generation method combining full-text and fragments. This method includes: determining the query type of the user-input query text, where the query type includes full-text search; when the query type of the query text is full-text search, obtaining all candidate documents associated with the query text in a preset knowledge base; when the concatenation length of the query text and all candidate documents exceeds the length range threshold of the large language model, segmenting all candidate documents according to a preset fragment length to obtain multiple fragment documents; inputting the concatenation of each fragment document and the query text into the large language model to obtain multiple structured answers, where each structured answer corresponds to each fragment document; and inputting the concatenation of the multiple structured answers and the query text into the large language model to obtain the target answer corresponding to the query text.

[0100] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0101] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the retrieval and generation method combining full text and fragments provided by the above methods. The method includes: determining the query type of the query text input by the user, wherein the query type includes: full text search; when the query type of the query text is full text search, obtaining all candidate documents associated with the query text in a preset knowledge base; when the concatenation length of the query text and all candidate documents exceeds the length range threshold of the large language model, segmenting all candidate documents according to a preset fragment length to obtain multiple fragment documents; inputting the concatenation of each fragment document and the query text into the large language model to obtain multiple structured answers, wherein each structured answer corresponds to each fragment document; and inputting the concatenation of the multiple structured answers and the query text into the large language model to obtain the target answer corresponding to the query text.

[0102] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a retrieval generation method combining full-text and fragments provided by the methods described above. This method includes: determining the query type of a query text input by a user, wherein the query type includes full-text search; when the query type of the query text is full-text search, obtaining all candidate documents associated with the query text in a preset knowledge base; when the concatenation length of the query text and all candidate documents exceeds the length range threshold of a large language model, segmenting all candidate documents according to a preset fragment length to obtain multiple fragment documents; inputting the concatenation of each fragment document and the query text into the large language model to obtain multiple structured answers, wherein each structured answer corresponds to each fragment document; and inputting the concatenation of the multiple structured answers and the query text into the large language model to obtain the target answer corresponding to the query text.

[0103] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0104] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0105] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A retrieval generation method combining full-text and fragment data, characterized in that, include: Determine the query type of the query text entered by the user, wherein the query type includes: full-text search; When the query type of the query text is full-text search, obtain all candidate documents associated with the query text in the preset knowledge base; When the combined length of the query text and all candidate documents exceeds the length range threshold of the large language model, all candidate documents are segmented according to the preset segment length to obtain multiple segment documents. The concatenation of each of the multiple fragment documents with the query text is input into the large language model to obtain multiple structured answers, wherein each of the multiple structured answers corresponds to each fragment document; The concatenation of the multiple structured answers with the query text is input into the large language model to obtain the target answer corresponding to the query text.

2. The retrieval and generation method combining full text and fragments according to claim 1, characterized in that, The query types include: fragment search. After determining the query type of the user-input query text, the method further includes: When the query type of the query text is a fragment search, all candidate fragments associated with the query text in the preset knowledge base are obtained; The query text and all candidate segments are concatenated and input into a large language model to obtain the target answer corresponding to the query text.

3. The retrieval and generation method combining full text and fragments according to claim 1, characterized in that, After obtaining all candidate documents associated with the query text in the preset knowledge base, the method further includes: When the combined length of the query text and all candidate documents does not exceed the length range threshold of the large language model, the combined length of the query text and all candidate documents is input into the large language model to obtain the target answer corresponding to the query text.

4. The retrieval and generation method combining full text and fragments according to claim 1, characterized in that, The step of concatenating the multiple structured answers with the query text and inputting the result into a large language model to obtain the target answer corresponding to the query text includes: When the combined length of the multiple structured answers and the query text does not exceed the length range threshold, the combined length of the multiple structured answers and the query text is input into the large language model to obtain the target answer corresponding to the query text.

5. The retrieval and generation method combining full text and fragments according to claim 1, characterized in that, The method further includes: When the combined length of the multiple structured answers and the query text exceeds the length range threshold, the following steps are repeated until the combined length of the multiple structured answers and the query text is less than the length range threshold: The multiple structured answers are segmented according to the preset segment length to obtain multiple segmented answer segments; Each segmented answer fragment and the concatenation of the query text are input into the large language model to obtain multiple updated structured answers.

6. The retrieval and generation method combining full text and fragments according to claim 5, characterized in that, After concatenating each segmented answer fragment with the query text and inputting the concatenation into the large language model to obtain updated structured answers, the method further includes: The updated multiple structured answers are concatenated with the query text and input into the large language model to obtain the target answer corresponding to the query text.

7. A retrieval and generation device combining full text and fragment data, characterized in that, include: The determination module is used to determine the query type of the query text input by the user, wherein the query type includes: full-text search; The acquisition module is used to acquire all candidate documents associated with the query text in a preset knowledge base when the query type of the query text is full-text search; The segmentation module is used to segment all candidate documents according to a preset segment length when the concatenation length of the query text and all candidate documents exceeds the length range threshold of the large language model, thereby obtaining multiple segment documents. The search module is used to input the concatenation of each fragment document and the query text into the large language model to obtain multiple structured answers, wherein each structured answer corresponds to each fragment document; The question-answering module is used to input the concatenation of the multiple structured answers and the query text into the large language model to obtain the target answer corresponding to the query text.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the retrieval and generation method combining full text and fragments as described in any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the retrieval and generation method combining full text and fragments as described in any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the retrieval and generation method combining full text and fragments as described in any one of claims 1 to 6.