A rag enhancement method and system based on adaptive decision and human-computer interaction optimization

The RAG enhancement method, which optimizes adaptive decision-making and human-computer interaction, solves the problems of lack of adaptability in retrieval operations and unclear generated results in existing technologies. It achieves efficient and interpretable knowledge acquisition, and improves system response efficiency and user experience.

CN122152978APending Publication Date: 2026-06-05ZHEJIANG UNIV CITY COLLEGE

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG UNIV CITY COLLEGE
Filing Date
2026-01-26
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing search enhancement generation technologies lack adaptive decision-making mechanisms when users query, resulting in unnecessary computational overhead and response delays. At the same time, the reasoning process of the generated results is not clear enough, the interaction methods are not flexible enough, and it is difficult to meet users' needs for interpretability of results.

Method used

The RAG enhancement method, based on adaptive decision-making and human-computer interaction optimization, generates a retrieval decision-making thought chain through a pre-trained large language model, dynamically determines whether to perform a retrieval operation, and performs document segmentation, rearrangement, and context refinement when necessary. It also combines the direct preference optimization algorithm to optimize the model and provides multi-level knowledge presentation modes and interactive control.

Benefits of technology

It enables on-demand retrieval, reduces the computational overhead of unnecessary retrieval, improves the accuracy and interpretability of generated results, and enhances the system's response efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122152978A_ABST
    Figure CN122152978A_ABST
Patent Text Reader

Abstract

The application provides a retrieval enhancement generation method and system based on adaptive decision and human-computer interaction optimization. After receiving a user query, the method uses a pre-trained large language model to generate inference intermediate results containing retrieval necessity analysis, and accordingly adaptively judges whether to perform retrieval enhancement generation. When it is judged that retrieval is not needed, the answer is directly generated by the language model, and when the verification fails, the fallback retrieval mechanism is triggered; when it is judged that retrieval is needed, relevant documents are retrieved from an external knowledge base, the retrieved documents are semantically filtered and refined, refined context is generated, and a reasoning response containing a reasoning thought chain is generated based on the refined context. Further, based on the reasoning thought chain, a preference sample pair is constructed, a direct preference optimization algorithm is used to update the model in a closed loop, and the output mode of the generated result is adjusted through a human-computer interaction control module, so as to ensure the accuracy of the generation while reducing unnecessary retrieval overhead.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer natural language processing technology, and in particular to a method and system for RAG (Retrieval Enhanced Generation) based on adaptive decision-making and human-computer interaction optimization. Background Technology

[0002] Retrieval-enhanced generative techniques represent a significant advancement in the fields of natural language processing and artificial intelligence. This technology combines the generative capabilities of large-scale pre-trained language models with the retrieval capabilities of external structured or unstructured knowledge bases, aiming to improve the factual accuracy and timeliness of information in tasks such as question answering, summarizing, and reasoning.

[0003] A typical RAG system workflow usually includes: receiving user queries, retrieving relevant documents or text fragments from external knowledge bases, and inputting the retrieved contextual information along with the original query into a language model to ultimately generate a response that incorporates external knowledge. This paradigm effectively mitigates the "illusion" problem that pure generative models may produce and extends the model's ability to handle knowledge beyond the training data deadline or specific domain knowledge.

[0004] In practical applications, the operational efficiency and response quality of such systems are core considerations. On the one hand, performing retrieval operations indiscriminately on all user queries introduces additional computational and I / O overhead, potentially affecting system response speed, especially when the query itself can be answered directly by the model's internal knowledge. On the other hand, ensuring that the model-generated answers are not only correct but also that their reasoning process is clear, traceable, and easily verifiable by users is crucial for improving the system's usability and credibility. Therefore, within the RAG framework, researching how to adaptively decide the necessity of retrieval and optimize the generation and presentation of answers is of practical significance for building efficient, reliable, and user-friendly intelligent systems.

[0005] However, existing search enhancement generation (RAG) technologies still have some shortcomings in practical applications. Specifically, on the one hand, existing RAG systems typically perform a uniform search operation for each user query, lacking an effective mechanism for judging the necessity of the search. This leads to additional computational and storage access overhead in some query scenarios that do not require external knowledge support, thus affecting the system's response efficiency. On the other hand, existing technologies often focus on outputting the final answer when generating results, while lacking effective organization and expression of the reasoning and intermediate processes involved in the generation process, making it difficult to meet users' needs for interpretability and verifiability of the results. Furthermore, existing RAG systems have limited flexibility in the presentation of generated results and user interaction control, making it difficult to dynamically adjust the generated content according to different usage scenarios and user preferences.

[0006] Therefore, there is an urgent need for a technical solution that can adaptively decide whether to perform a retrieval operation within a retrieval-enhanced generation framework, while ensuring the accuracy of the generated results and improving the clarity of the reasoning process and the flexibility of system interaction. Summary of the Invention

[0007] Based on the above background, this disclosure proposes a RAG enhancement method and system optimized in terms of adaptive decision-making and human-computer interaction, aiming to solve the problems of lack of adaptive decision-making in retrieval operations, unclear reasoning processes, and insufficient flexibility in the interaction of generated results in existing retrieval enhancement generation technologies. The specific technical solution adopted is as follows: A method for enhancing RAG based on adaptive decision-making and human-computer interaction optimization includes the following steps: S1. Construct the training dataset; S2. Receive input query, use pre-trained large language model to generate thought chain for retrieval decision, and determine whether retrieval enhancement generation needs to be performed based on the thought chain, and generate decision instruction; S3. According to the decision instruction, execute the answer generation, result verification and rollback mechanism under the non-search path, or execute the document segmentation, rearrangement, filtering and context refinement under the search path. S4. Generate a reasoning response containing a thought chain based on the refined context, and refine the thought chain. S5. Using the labeled sample pairing and direct preference optimization (DPO) algorithm, perform closed-loop optimization of the adaptive decision model; S6. Receive user interaction instructions, process the generated results according to the user interaction instructions, and output them.

[0008] Further, in step S1, the construction of the dataset specifically includes: integrating and preprocessing the training sets of different datasets, and using the model to retrieve documents related to the question in the Ms Marco v2.1 document, specifically including unifying the format to id, question, answer and passage.

[0009] Furthermore, step S2 specifically includes the following steps: S21. Input user query Combined with preset prompt templates, it forms a complete decision prompt; S22. Input the decision prompt into the pre-trained large language model, and the model directly generates a thought chain containing retrieval necessity analysis based on the prompt. and output the retrieval decision identifier. ; S23. Based on the retrieval decision identifier Select the subsequent execution path: If it is marked as requiring retrieval, proceed to the retrieval enhancement path; if it is marked as not requiring retrieval, proceed to the non-retrieval generation path and directly call the model's internal parameters to generate the answer.

[0010] Further, in step S3, when the retrieval decision identifier... When the user is directed to enter the search enhancement generation path, a search and knowledge refinement process is executed, which includes the following steps: S31. Retrieving and inputting queries from external knowledge bases Related documents ; S32, the document collection Each document in Decomposed into multiple semantic fragments according to semantic units ; S33. Calculate each semantic fragment using the pre-trained large language model. With input query The correlation score is used to select highly correlated fragments based on the dynamically adjusted correlation threshold. S34. Arrange the filtered highly relevant fragments in descending order of relevance score and combine them to generate a refined context. And output it to the subsequent inference response module; Further, in step S3, when the retrieval decision identifier... When the instruction is to enter a non-retrieval generation path, a direct generation process is executed, which includes the following steps: S35. Generate an initial answer directly using the internal parameters of the pre-trained large language model; S36. Regarding the initial answer Perform a correctness check; if the check result is incorrect, trigger a rollback mechanism to redirect the processing path to step S31 to execute the retrieval process; if the check result is correct, then the initial answer is... Mark for later use.

[0011] Furthermore, step S4 specifically includes the following steps: S41, in the context of the refinement and the original query As input, the pre-trained large language model is driven to generate an initial reasoning thought chain. ; S42. For each of the initial reasoning chains... Perform the simplest and most refined operation, remove redundant reasoning steps, retain the core logic, and obtain the corresponding simplified thought chain. .

[0012] Furthermore, step S5 specifically includes the following steps: S51. A thought chain for retrieval decision-making based on the method described in S22. and the corresponding simplified thought chain in the method described in S42 The samples are labeled positively or negatively by comparing them with the standard answer; the correct samples are labeled as positive samples. Incorrectly labeled as negative samples Thus constructing multiple Preference dataset for the correct pair; S52. Using the aforementioned preference dataset, train the pre-trained large language model using the direct preference optimization algorithm, so that the model learns to generate inferences and answers that conform to the positive sample preference characteristics.

[0013] Furthermore, step S6 specifically includes the following steps: S61. Receive user instructions through the slider interaction component of the visual front end, and switch between three modes: "forced retrieval", "forced non-retrieval" and "model autonomous decision-making" according to the user's selection. S62. Based on a preset level of detail threshold, provide users with three levels of knowledge display modes to meet reading needs in different scenarios. The three modes are as follows: Level 1 mode: drive the language model to generate and output only the most simplified final answer; Level 2 mode: output the reasoning response with the core thinking chain after simplification in step S4; Level 3 mode: synchronously display the document fragments used in the retrieval process, the complete initial thinking chain, and the simplification process.

[0014] S63. Based on the knowledge display mode described in S62, in response to the user's selection of a proper noun, the definition instruction is automatically triggered and the definition or background information of the noun is displayed by the visual front end.

[0015] Furthermore, according to another aspect of this disclosure, a RAG system based on adaptive decision-making and human-computer interaction optimization is proposed, comprising: The decision module is used to receive user input queries, generate a thought chain containing retrieval necessity analysis based on a pre-trained large language model, and output a retrieval decision identifier for whether to execute retrieval enhancement based on the thought chain. The path control module is used to select whether to execute a search-enhanced generation path or a non-search-generated path based on the search decision identifier. The retrieval and knowledge refinement module is used to retrieve documents related to the user's input query from an external knowledge base when the retrieval decision identifier indicates that the retrieval enhancement generation path has been entered, and to perform semantic unit decomposition, relevance evaluation, filtering and rearrangement of the documents to generate a refined context. The generation and rollback module is used to generate an initial answer based on the pre-trained large language model when the retrieval decision identifier indicates that the non-retrieval generation path is entered, and to determine the correctness of the initial answer; when the determination result does not meet the preset conditions, the rollback process is triggered and the processing path is switched to the retrieval enhancement generation path; The reasoning generation and refinement module is used to generate a reasoning thought chain based on the refinement context or based on the user input query in a non-retrieval generation path, and to perform refinement processing on the reasoning thought chain. The model optimization module is used to construct preference sample pairs based on the reasoning chain and its refined results, and to train and update the pre-trained large language model using the direct preference optimization algorithm. The human-computer interaction control module is used to receive user interaction commands and control the output method and display level of the generated results according to the user interaction commands.

[0016] The beneficial effects of this disclosure lie in its original RAG enhancement method and corresponding system based on adaptive decision-making and human-computer interaction optimization. It combines the self-evaluation capability of large language models with the DPO algorithm, alleviating the technical bottlenecks of rigid retrieval decisions and redundant inference paths in traditional RAG systems. The system can generate a pre-inference thought chain containing retrieval necessity analysis and output decision flags, achieving on-demand retrieval while reducing the computational overhead and response latency caused by unnecessary retrievals, ensuring accuracy. Simultaneously, this disclosure proposes a fine-grained knowledge refinement strategy based on confidence scoring, which can effectively identify and filter negative signal fragments in retrieved documents and optimize contextual semantics through confidence reordering, mitigating the problem of long context interference. Furthermore, this disclosure constructs a closed-loop optimization system based on the DPO algorithm, enabling the model to learn to generate responses that are both logically accurate and procedurally concise by performing the simplest refinement operation on the inference thought chain. The accompanying visualization front-end provides three levels of knowledge display modes, supporting slider adjustment, automatic definition of proper nouns, and style template matching, improving the efficiency of users' understanding of complex knowledge. Attached Figure Description

[0017] Figure 1 This is a basic flowchart illustrating an embodiment of the method disclosed herein.

[0018] Figure 2 This is a schematic diagram of the specific process disclosed in this publication. Detailed Implementation

[0019] To further understand this disclosure, preferred embodiments of the present disclosure are described below in conjunction with examples. It should be understood that these descriptions are only for further illustrating the features and advantages of the present disclosure, and not for limiting the scope of protection of the present disclosure.

[0020] This disclosure focuses on the optimization of Retrieval Augmentation (RAG) in the field of large-scale language model applications. Conventional RAG frameworks in natural language processing typically employ a static retrieval model, forcibly triggering external knowledge retrieval regardless of the difficulty of the user query. However, in practical applications, this rigid mechanism often leads to unnecessary computational overhead when the model has sufficient internal knowledge to answer, or interference when retrieving a large number of noisy documents, resulting in decreased accuracy and logical redundancy. Furthermore, users have varying needs for the level of detail in their answers, and traditional single-output models struggle to balance conciseness and comprehensiveness. Therefore, this invention, assuming the aforementioned performance bottlenecks and interaction limitations, aims to achieve adaptive retrieval decisions and refined inference responses, while being applicable to various natural language processing scenarios requiring knowledge augmentation.

[0021] Pre-trained large language models (LLMs) have demonstrated outstanding performance in fields such as intelligent question answering and text generation. This invention uses cutting-edge pre-trained large language models, such as Llama3, as a foundation and proposes for the first time a RAG enhancement method based on adaptive decision gating. By performing closed-loop training of the adaptive decision model using the Direct Preference Optimization (DPO) algorithm, and combining it with the self-refinement technique of the CoT (Cooperation of Reasoning) framework, this invention significantly saves computational costs and optimizes reasoning logic while ensuring knowledge accuracy.

[0022] It should be noted that when implementing the solution of this invention, the selection of the pre-trained large language model is not necessarily limited to the specific models listed in this invention. Professionals can choose a base model suitable for their own business logic based on specific business scenarios, such as government affairs, medical or industrial fields, and pay attention to the latest LLMs released in the field of deep learning. The various hyperparameters involved in this specification, such as the confidence score threshold in the range of [-1, 1] and the level classification of detail, can also be adjusted and modified based on the professional's own understanding of the problem.

[0023] The following is in conjunction with the appendix Figure 1-2 The method and corresponding system of the present invention will be further described in detail with reference to specific embodiments.

[0024] See appendix Figure 1-2 In one embodiment, a RAG enhancement method based on adaptive decision-making and human-computer interaction optimization includes the following steps: S1. Construct the training dataset, which comes from datasets such as ASQA and HotpotQA, covering various types of problems including single-hop and multi-hop problems. The data format is then reorganized as follows: The BGE-large model is used to retrieve ten passages related to the question from the Ms Marco v2.1 documents. Each passage includes the document's docid in the corpus; the original webpage URL; the webpage title; repeated headings (titles or questions) on the page; relevant text segments extracted from the webpage; and the start and end character positions (start_char / end_char) of each segment in the original document. The selected question categories are then standardized to id, question, answer, and passage to form a final training dataset. It should be noted that the above steps are only an example of generating an entity-annotated literature dataset and are not essential steps of this invention. The method disclosed herein is applicable to all formatted datasets generated using similar or other methods.

[0025] S2. Receive input query, generate a thought chain for retrieval decision using a pre-trained large language model, and determine whether retrieval enhancement generation needs to be performed based on the thought chain, and generate decision instructions.

[0026] In this embodiment, llama3-8b is selected as the chosen pre-trained large language model.

[0027] This paper designs and applies structured prompts to guide a pre-trained large language model in making adaptive decisions regarding user queries. Specifically, a structured prompt template is first constructed to guide the model to autonomously analyze the timeliness requirements and knowledge boundaries of the input query and output a thought process chain containing a complete "decision rationale." This template typically includes system roles, decision-making dimension guidelines, and output format requirements. The following is the prompt template used in this embodiment: System Role: You are the adaptive question-answering scheduler. Your task is to determine whether to call an external search function based on the user's question, and to provide a reason.

[0028] Decision-making dimensions: 1. Real-time: Does the question rely on knowledge that only exists "at this moment / in the near future" (news, stock prices, weather, sports events, epidemics, etc.)? 2. Fact scarcity: Does the question involve obscure, long-tail, or dynamically updated entities / events? 3. Multi-hop complexity: Is it necessary to traverse multiple sets of data to infer the answer? 4. Confidence of Model's Own Knowledge: Can it provide a high-confidence answer based on parameter memory? Output format: Please strictly follow the JSON format below; do not provide any additional explanation: { "decision": "retrieve" | "no_retrieve", "cot": "<a one-sentence reason, no more than 50 words>" "keywords": ["keyword1", "keyword2", ...] / / Required if decision=retrieve; otherwise leave the list empty. } In practice, the user query is combined with this template to form a complete decision prompt, which is then input into the selected pre-trained large language model, llama 3-8b. The model uses the prompt to reason progressively, generating a thought chain that includes retrieval necessity analysis (denoted as...). ), and finally output a binary retrieval decision flag. This thought process not only records the model's judgment on whether to retrieve data, but more importantly, it fully preserves the reasoning basis. Taking the query "Who plays the voice of Woody in Toy Story?" as an example, the model receives the query and uses the template above for reasoning. The analysis considers that while the information is not highly real-time regarding the voice actor for a specific movie character, there is a distinction between the main film and derivative works such as games and short films. This constitutes a specific fact requiring precise identification, and the model's confidence level regarding details in derivative works may be insufficient. Therefore, the model outputs a structured decision: { "decision": "retrieve", "cot": "The question involves specific voice actor information for movie characters, and there are differences between major works and derivative works. Authoritative sources need to be consulted to ensure the accuracy and completeness of the information." “keywords”: [“Toy Story”, “Woody”, “voice actor”, “Tom Hanks”, “JimHanks”] } Taking the query "Who plays the voice of Woody in Toy Story?" as an example, the model receives the query and performs inference based on the template mentioned above. The analysis process considers that while the information involves the voice actor for a specific movie character and is not highly real-time, there is a distinction between the main movie and derivative works such as games and short films. This constitutes a specific fact requiring precise identification, and the model's confidence level regarding details in derivative works may be insufficient. Therefore, the model outputs a structured decision: where the decision field serves as a retrieval decision indicator. The `cot` field represents the reason for the decision, and the `keywords` field provides optimized query keywords for subsequent retrieval processes. If the query is "Briefly describe Newton's three laws of motion," the model might output: {"decision": "no_retrieve", "cot": "This question pertains to classical physics common sense; the model's internal knowledge has high confidence and does not require real-time information.", "keywords": []}.

[0029] This process enables intelligent routing of queries: if If the flag is "retrieve", the process proceeds to the subsequent retrieval enhancement processing path; if the flag is "no_retrieve", the process proceeds to the subsequent non-retrieval enhancement processing path, directly calling the model's internal parameters to generate the initial answer. Furthermore, the thought chain generated in this step includes decision-making rationale. It will be fully preserved as one of the key data sources for subsequent training of the Direct Preference Optimization (DPO) algorithm, used to train the model to form more accurate and interpretable adaptive decision-making capabilities.

[0030] S3. Based on the decision instruction, execute the answer generation, result verification and rollback mechanism under the non-search path, or execute the document segmentation, rearrangement, filtering and context refinement under the search path.

[0031] When the adaptive decision module determines that a retrieval is needed (i.e.) The system then enters the document deep processing flow of this step, which aims to extract high-purity and highly relevant contextual information from the original search results.

[0032] First, the system obtains an initial set of relevant documents from the training set. Then, the document refinement pipeline was launched: The document preprocessing module processes each retrieved document. Fine-grained segmentation is performed. This module decomposes the document into multiple relatively independent semantic segments based on the document's semantic structure (such as paragraphs) and natural sentence boundaries. For example, from a document about the voice acting in Toy Story... It may be possible to segment it into the following fragments: : "Tom Hanks is the primary voice actor for Woody in all four ToyStory feature films." : "In various Toy Story video games and promotional shorts, the role of Woody is often voiced by Jim Hanks, Tom Hanks' brother." : “The character Woody was designed by John Lasseter and his team at Pixar.” Relevance Assessment and Dynamic Filtering: Using the Llama 3-8B model to evaluate the relevance of each semantic segment s i,j Perform relevance scoring. Specifically, this involves analyzing the original user queries. Each segment is combined with an evaluation prompt, which is then input into the model to obtain a relevance confidence score between -1 and 1. Irrelevant and redundant segments with a negative threshold are deleted, while segments with a positive threshold are retained. In this embodiment, the model's score for the above segments might be: Regarding Tom Hanks' voice acting, it received a score of 0.95; Regarding Jim Hanks' voice acting, it received a score of 0.90; while Regarding character design, it is unrelated to the search for "voice actors" and scores -0.80. Therefore, the segment... It was automatically filtered out because of its negative score.

[0033] The retained highly relevant segments are sorted in descending order of their confidence scores. These segments are then combined and pieced together in this order to generate a logically coherent, information-rich, and concise contextual document. .For example: "1. (Correlation: 0.95) Tom Hanks is the primary voice actor for Woody in all four Toy Story feature films. 2. (Correlation: 0.90) In various Toy Story videogames and promotional shorts, the role of Woody is often voiced by Jim Hanks,Tom Hanks' brother." This reconstructed, refined context This process significantly eliminates redundant and irrelevant information in the original search results, resulting in a high-quality, highly focused knowledge summary. This summary serves as the input for generating answers in subsequent steps, directly providing it to the reasoning response module. This fundamentally improves the accuracy and completeness of the final generated answer and effectively mitigates the problems of long contextual interference and information noise.

[0034] S4. Obtaining the refining context Next, the system enters the reasoning response generation stage. The goal of this step is to drive the pre-trained large language model to generate a thought chain containing a complete reasoning process, and based on this, generate the final refined answer.

[0035] The system first constructs instructions based on a preset Chinese prompt template to guide the model in generating an initial thought chain. The template format used is as follows: Paragraph: {passage} Based on the above paragraphs, answer the following questions.

[0036] Question: {question} Please think about it step by step.

[0037] The refined context obtained in the previous step User query Enter the template. For example, to search "Who plays the voice of Woody in a toy story?", the complete prompt would be: Passage: (Correlation: 0.95) Tom Hanks is the primary voice actor for Woody in all four Toy Story feature films. (Correlation: 0.90) In various Toy Story videogames and promotional shorts, the role of Woody is often voiced by Jim Hanks,Tom Hanks' brother. Based on the above paragraphs, answer the following questions.

[0038] Question: Who plays the voice of woody in toy story? Please think about it step by step.

[0039] Input this prompt into the Llama 3-8B model. Based on this prompt, the model generates an initial thought process containing step-by-step reasoning. The output content is shown in the following example: The question asks you to identify the voice actor for Woody in Toy Story.

[0040] The provided paragraph contains two key pieces of information: 1. Tom Hanks is the primary voice actor for Woody in all four Toy Story films.

[0041] 2. In various Toy Story video games and promotional videos, Woody's character is usually voiced by Jim Hanks, Tom Hanks' younger brother.

[0042] Therefore, the answer depends on the scope of the media being referred to. If the question refers to the core film series, then the answer is Tom Hanks. If the question covers all media, including spin-offs, then Jim Hanks also voices the character.

[0043] Therefore, a comprehensive answer needs to mention both actors and explain the range of works they have participated in.

[0044] The system then initiates a self-refinement process, transforming the initial thought process into a final, concise answer. This process follows a pre-set Chinese prompt template: Task Description: 1. Read the given question and related thought processes to gather relevant information.

[0045] 2. The content of a thought chain is the thought process that can be used to answer questions.

[0046] 3. If the thought process doesn't apply, please answer the question based on your own knowledge.

[0047] 4. Give a short answer to the given question.

[0048] Question: {question} Mind Chain: {CoT} Fill this template with the original question and the initial thought chain generated in the previous step to form a self-refined prompt: Task Description: 1. Read the given question and related thought processes to gather relevant information.

[0049] 2. The content of a thought chain is the thought process that can be used to answer questions.

[0050] 3. If the thought process doesn't apply, please answer the question based on your own knowledge.

[0051] 4. Give a short answer to the given question.

[0052] Question: Who plays the voice of woody in toy story? Thinking Chain: The question asks you to identify the voice actor for Woody in *Toy Story*. Based on the provided passage, there are two key pieces of information: 1. Tom Hanks is the primary voice actor for Woody in all four main *Toy Story* films. 2. In various *Toy Story* video games and promotional shorts, Woody is typically voiced by Jim Hanks, Tom Hanks' brother. Therefore, the answer depends on the scope of media referred to. If the question refers to the core film series, then the answer is Tom Hanks. If the question covers all media, including spin-offs, then Jim Hanks also voices the character. Therefore, a comprehensive answer would need to mention both actors and specify the range of works they have worked on.

[0053] Input this prompt again into the Llama 3-8B model, and the model will extract the core information from the thought process and generate a direct and concise final answer. The output example is as follows: In the main Toy Story films, Woody is voiced by Tom Hanks; while in many video games and short films, he is voiced by his brother Jim Hanks.

[0054] At this point, the system has completed the entire process from generating a detailed reasoning process to outputting a refined answer. The initial thought chain and the final answer generated in this step will be saved together. The former will serve as a traceable basis for reasoning and will be used for interactive display, while the latter will be output to the user as a direct response. Both will also serve as key data in subsequent model optimization stages.

[0055] S5. After the system completes a single question-and-answer process, this step aims to use the generated interaction data to continuously fine-tune the adaptive decision model (i.e., the Llama 3-8B model that performs retrieval judgment in the second step) through the Direct Preference Optimization (DPO) algorithm, forming a self-improving closed-loop optimization system.

[0056] The specific implementation process is as follows: First, a preference dataset is constructed. The system pairs and labels the key intermediate data generated during this complete interaction with the final results, forming sample pairs for DPO training. .in: Positive samples The decision-making thought chain generated by the model in step two that guided this successful question-and-answer session. and the corresponding final accurate answer generated in the fourth step. Together they constitute the whole. Taking the query "Woody's voice in Toy Story" as an example, the positive sample is the complete structured output of the model, with the decision being "retrieval," and the correct answer that ultimately distinguishes the movie from its derivative works.

[0057] negative samples The negative sample is constructed by using a flawed decision-making path or answering the wrong question in step four, such as only answering "Tom Hanks" and omitting Jim Hanks' contributions to derivative works. This data pair containing flawed decisions and incomplete answers constitutes the negative sample.

[0058] The system will continuously collect such positive and negative sample pairs, accumulating them to build a continuously expanding preference dataset. Each sample pair is clearly labeled with which decision-making and reasoning patterns lead to a better answer when faced with a specific type of query.

[0059] Then, perform DPO training using the preference dataset constructed above. We fine-tune a pre-trained large language model (Llama 3-8B) using the DPO algorithm. The core of DPO training lies in its ability to optimize the policy model—our adaptive decision-making model—directly using preference data, rather than training a complex reward model. This ensures that the distribution of its generated answers aligns with human or system-defined preferences. In this embodiment, the training goal is to enable the model, when receiving similar queries such as "Who voices a certain character in a movie?" or "What are the recent financial reports of a certain company?", to generate a decision-making chain containing the probability distributions of decision, cot, and keywords. This chain tends to match patterns observed in historical positive samples—that is, accurately identifying the need for timeliness, factual accuracy, or cross-source verification in queries, thereby making informed "retrieval" decisions and extracting effective keywords; while avoiding erroneous patterns such as "blind confidence" or "missed detections" observed in negative samples.

[0060] Through this closed-loop training based on real-world interactive feedback, the adaptive decision-making model can continuously learn more refined and reliable judgment capabilities regarding the necessity of retrieval. This not only improves the overall efficiency of the system, but more importantly, by improving the accuracy of retrieval triggering, it fundamentally ensures that subsequent answer generation stages receive high-quality external knowledge support, thereby continuously improving the system's answer quality and reliability.

[0061] S6. After the system generates the final answer, this step focuses on presenting the results to the user in a flexible, intuitive, and interpretable way through a human-computer interaction interface, and providing additional knowledge enhancement functions to improve user experience and information acquisition efficiency. These interactive functions are all implemented through an integrated visual front-end.

[0062] The following section uses the results of the query "Who voices Woody in Toy Story?" to illustrate the interaction process in detail: First, there's the mode switching and multi-level answer display: the front-end interface provides a slider or drop-down menu, allowing users to switch between three modes: "Force Search," "Force No Search," and the default "Model Autonomous Decision." After this query runs in "Model Autonomous Decision" mode and generates the final answer, the front-end provides the user with three selectable answer display levels: Level 1, Concise Mode: The interface only displays the most refined final answer, such as: Woody's voice actor is Tom Hanks, the main movie, and Jim Hanks, some spin-offs.

[0063] Level 2, Standard Mode, Default: Displays a simplified version of the answer generated in step 4. ; For example, Woody is voiced by Tom Hanks in the main Toy Story films, while his brother Jim Hanks voices him in many video games and short films.

[0064] Level 3, Detailed / Traceable Mode: For users requiring in-depth verification or learning, the front end synchronously displays three main sections, namely the context used, i.e., the refined context generated in step 3. The complete thought process chain, that is, demonstrating the initial reasoning thought chain generated in step four. The entire content, including the final answer. This presentation method ensures complete traceability of the answer, allowing users to verify the source of information and the complete reasoning path themselves.

[0065] Within the answer text displayed at any level, when a user hovers their mouse over or clicks on a proper noun, such as "Jim Hanks," the front end automatically triggers a definition prompt. The system invokes internal knowledge or performs a quick search, instantly displaying the definition or background information of the noun in the form of a floating tooltip or sidebar, such as: Jim Hanks is an American voice actor and the younger brother of famous actor Tom Hanks. Background: He has long provided voice-over for his brother Tom Hanks, notably voicing Woody in video games, theme park shorts, and some animated series.

[0066] Through the above interactive functions, this invention not only provides accurate answers, but more importantly, it empowers users to control the granularity of information, understand the reasoning process, and explore relevant knowledge, thereby constructing an efficient, transparent, and user-friendly knowledge acquisition system.

[0067] In another embodiment of this disclosure, a RAG system based on adaptive decision-making and human-computer interaction optimization is provided to implement the retrieval enhancement generation method described in any of the foregoing method embodiments. This system can be deployed on a server, cloud computing platform, or other computing device with computing and storage capabilities. The system includes the following functional modules: The decision module is used to receive query requests input by users, input the query requests into a pre-trained large language model, generate a thought chain containing retrieval necessity analysis, and output a retrieval decision identifier based on the thought chain to determine whether to perform retrieval enhancement generation.

[0068] The path control module is used to control the system to enter either the search-enhanced generation path or the non-search-generated path based on the search decision identifier.

[0069] The retrieval and knowledge refinement module is used to retrieve document content related to the user's input query from an external knowledge base when the retrieval decision identifier indicates that the retrieval enhancement generation path has been entered. The retrieved documents are then subjected to semantic unit-level decomposition, relevance evaluation, filtering, and rearrangement to generate refined contextual information.

[0070] The generation and rollback module is used to generate an initial answer based on the pre-trained large language model when the retrieval decision identifier indicates that the non-retrieval generation path is entered, and to perform a correctness judgment on the initial answer; when the judgment result does not meet the preset conditions, a rollback mechanism is triggered to switch the processing path to the retrieval enhancement generation path.

[0071] The reasoning generation and refinement module is used to drive the pre-trained large language model to generate reasoning thought chains based on the refined context information or based on the user input query in a non-retrieval generation path, and to perform refinement processing on the reasoning thought chains to obtain simplified reasoning thought chains.

[0072] The model optimization module is used to construct preference sample pairs based on the reasoning thought chain and its refinement results, and to train and update the pre-trained large language model using the direct preference optimization algorithm to achieve continuous optimization of model performance.

[0073] The human-computer interaction control module is used to receive user interaction instructions and control the output method and display level of the generated results according to the user interaction instructions, including controlling whether to perform search enhancement generation and the presentation method of the generated results.

[0074] In this embodiment, each functional module can be implemented through software, hardware, or a combination of both. The functional division between modules is only for illustrating the technical solution of the present invention and does not constitute a limitation on the system structure. Those skilled in the art can merge, split, or adjust the modules according to actual application scenarios without departing from the spirit and scope of protection of the present invention.

[0075] The above description of the embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. It should be noted that those skilled in the art can make several improvements and modifications to the present invention without departing from the principles of the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.

Claims

1. A RAG enhancement method based on adaptive decision-making and human-computer interaction optimization, characterized in that, Includes the following steps: S1. Construct the training dataset; S2. Receive input query, use pre-trained large language model to generate thought chain for retrieval decision, and determine whether retrieval enhancement generation needs to be performed based on the thought chain, and generate decision instruction; S3. According to the decision instruction, execute the answer generation, result verification and rollback mechanism under the non-search path, or execute the document segmentation, rearrangement, filtering and context refinement under the search path. S4. Generate a reasoning response containing a thought chain based on the refined context, and refine the thought chain. S5. Using the labeled sample pairing and direct preference optimization (DPO) algorithm, perform closed-loop optimization of the adaptive decision model; S6. Receive user interaction instructions, process the generated results according to the user interaction instructions, and output them.

2. The RAG enhancement method based on adaptive decision-making and human-computer interaction optimization as described in claim 1, characterized in that, In step S1, the dataset construction includes integrating and preprocessing different training datasets, wherein document content matching the question samples in the training dataset is retrieved from a preset document set, and the training data is uniformly organized into a data format containing questions, reference answers and corresponding document content.

3. The RAG enhancement method based on adaptive decision-making and human-computer interaction optimization as described in claim 1, characterized in that, Step S2 specifically includes the following steps: S21. Combine the user's input query with the preset prompt word template to construct a decision prompt for retrieval decision-making; S22. Input the decision prompt into the pre-trained large language model. The pre-trained large language model generates a thought chain containing retrieval necessity analysis based on the decision prompt and outputs the corresponding retrieval decision identifier. S23. Determine the subsequent execution path based on the search decision identifier, wherein when the search decision identifier indicates that a search is required, determine to enter the search enhancement path; when the search decision identifier indicates that a search is not required, determine to enter the non-search generation path.

4. The RAG enhancement method based on adaptive decision-making and human-computer interaction optimization as described in claim 1, characterized in that, In step S3, when the retrieval decision identifier indicates entry into the retrieval enhancement generation path, the retrieval and knowledge refinement process is executed, which includes the following steps: S31. Retrieve documents related to the input query from an external knowledge base; S32. Decompose the retrieved documents according to semantic units to obtain multiple semantic fragments; S33. Calculate the relevance score between each semantic fragment and the input query, and filter out highly relevant semantic fragments based on a dynamically adjusted relevance threshold. S34. Sort and combine the selected highly relevant semantic fragments according to their relevance scores to generate a refined context for subsequent reasoning response generation.

5. The RAG enhancement method based on adaptive decision-making and human-computer interaction optimization as described in claim 4, characterized in that, In step S3, when the retrieval decision identifier indicates that a non-retrieval generation path is entered, a direct generation process is executed, which includes the following steps: S35. Generate an initial answer based on the pre-trained large language model; S36. Determine the correctness of the initial answer; if the determination result is incorrect, trigger the rollback process and switch the processing path to step S31 to execute the retrieval and knowledge refinement process; if the determination result is correct, use the initial answer as the result of subsequent processing or output.

6. The RAG enhancement method based on adaptive decision-making and human-computer interaction optimization as described in claim 1, characterized in that, Step S4 specifically includes the following steps: S41. Using the context information obtained in step S3 and the original query as input, drive the pre-trained large language model to generate an initial reasoning thought chain. Wherein, when step S3 is a retrieval enhancement generation path, the context information is refined context; when step S3 is a non-retrieval generation path, the context information is the context information on which the answer is based by the pre-trained large language model or is empty. S42. Perform a refinement process on each of the initial reasoning thought chains, including filtering, merging, or compressing the reasoning steps to generate a simplified reasoning thought chain.

7. The RAG enhancement method based on adaptive decision-making and human-computer interaction optimization as described in claim 1, characterized in that, Step S5 specifically includes the following steps: S51. Based on the reasoning thought chain for retrieval decision generated in step S2 and the corresponding simplified reasoning thought chain generated in step S4, and combined with the reference answer, the reasoning thought chain is labeled with preferences to construct a preference dataset containing multiple preference sample pairs. S52. Using the preference dataset, the pre-trained large language model is trained and updated using the DPO algorithm to optimize the preference characteristics of the model's inference process and output results.

8. The RAG enhancement method based on adaptive decision-making and human-computer interaction optimization as described in claim 1, characterized in that, Step S6 specifically includes the following steps: S61. Receive user input interaction instructions, and switch between preset search control modes according to the interaction instructions to control whether to perform search enhancement generation; S62. Adjust the display hierarchy of the generated results according to the output control parameters selected by the user; S63. In response to the user's selection of proper nouns in the generated results, trigger the definition instruction and output the corresponding definition information.

9. The RAG enhancement method based on adaptive decision-making and human-computer interaction optimization as described in claim 8, characterized in that, Based on a preset level of detail threshold, the system provides users with multiple knowledge display modes, with different levels of knowledge display modes corresponding to different levels of output results.

10. A RAG system based on adaptive decision-making and human-computer interaction optimization, characterized in that, include: The decision module is used to receive user input queries, generate a thought chain containing retrieval necessity analysis based on a pre-trained large language model, and output a retrieval decision identifier for whether to execute retrieval enhancement based on the thought chain. The path control module is used to select whether to execute a search-enhanced generation path or a non-search-generated path based on the search decision identifier. The retrieval and knowledge refinement module is used to retrieve documents related to the user's input query from an external knowledge base when the retrieval decision identifier indicates that the retrieval enhancement generation path has been entered, and to perform semantic unit decomposition, relevance evaluation, filtering and rearrangement of the documents to generate a refined context. The generation and rollback module is used to generate an initial answer based on the pre-trained large language model when the retrieval decision identifier indicates that the non-retrieval generation path is entered, and to determine the correctness of the initial answer; when the determination result does not meet the preset conditions, the rollback process is triggered and the processing path is switched to the retrieval enhancement generation path; The reasoning generation and refinement module is used to generate a reasoning thought chain based on the refinement context or based on the user input query in a non-retrieval generation path, and to perform refinement processing on the reasoning thought chain. The model optimization module is used to construct preference sample pairs based on the reasoning chain and its refined results, and to train and update the pre-trained large language model using the direct preference optimization algorithm. The human-computer interaction control module is used to receive user interaction commands and control the output method and display level of the generated results according to the user interaction commands.