RAG multi-hop question and answer method, device and system and storage medium

Through task decomposition and logic orchestration technology and dual-path index optimization, the logical discontinuity and noise accumulation problems of the RAG system in multi-hop question answering are solved, achieving higher-quality information extraction and answering.

CN120723869APending Publication Date: 2025-09-30ZHEJIANG GONGSHANG UNIVERSITY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510833460.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

Existing RAG systems suffer from logical gaps, retrieval noise accumulation, and semantic bias in multi-hop question answering tasks, which affect the quality of answers.

Method used

Task decomposition and logic arrangement techniques are used to decompose complex problems into orderly retrieval and reasoning subtasks. Cosine similarity and relative margin algorithms are combined for dual-path document retrieval, and the final answer is generated through topic-level text integration and sentence-level noise filtering.

Benefits of technology

It significantly improves the logical coherence and retrieval accuracy of multi-hop question answering, reduces noise interference, improves the accuracy and robustness of question answering, and adapts to different task requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723869A_ABST
    Figure CN120723869A_ABST
Patent Text Reader

Abstract

The invention discloses an RAG multi-hop question and answer method, device and system and a storage medium. The method comprises the steps of training a planning model and an information extraction model; analyzing the complex problem into a retrieval sub-task and a reasoning sub-task through the trained planning model; performing dual-path document retrieval by combining a cosine similarity algorithm and a relative boundary distance algorithm to obtain a main index result and an auxiliary retrieval result; performing parallel processing on the main index result and the auxiliary index result, and sequentially connecting the processing results to obtain a final retrieval result; wherein the parallel processing is that corresponding text segments are integrated based on themes and sentence-level text filtering is carried out; and processing the retrieval sub-task and the reasoning sub-task by using the trained information extraction model, and integrating all intermediate results to generate a final answer. Through the task decomposition planning and double-path index optimization technology, the interpretability of the reasoning process is improved, the question and answer accuracy and reliability are improved, and the method can be widely applied to complex multi-hop question and answer scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of natural language processing technology, and in particular relates to a RAG multi-hop question answering method and device, system, and storage medium. Background Art

[0002] With the rapid development of large language model technology, existing technologies primarily store knowledge implicitly through parameterization. This lacks transparency in knowledge representation, and storage capacity is limited by the model size. This results in costly, large-scale, repetitive training required for model updates. Existing large language models have significant limitations when handling long-context scenarios. They struggle to effectively manage information associations across multiple conversations or long documents, leading to attention dilution. This increases the risk of hallucinations and factual errors in generated content, ultimately reducing the factual accuracy and attribution reliability of answers.

[0003] To alleviate these issues, the Retrieval-Augmented Generation (RAG) framework improves answer accuracy by combining external knowledge base retrieval with language model generation capabilities. However, traditional RAG, which employs a "retrieve-then-reason" paradigm, suffers from the following drawbacks in complex tasks such as multi-hop question answering: First, the retrieval phase is prone to introducing redundant or irrelevant documents, forcing the generative model to extract valid information from the noise, significantly increasing the inference burden; second, the multi-dimensional information retrieval required for multi-hop tasks can easily exceed the model's context window, further leading to information truncation or logical discontinuities.

[0004] In the existing Retrieval Augmented Generation (RAG) technology framework, solutions for multi-hop question answering tasks primarily employ three technical approaches: First, a query reconstruction-based solution decomposes complex questions into multiple atomic subquery sequences, achieving fine-grained retrieval targets; second, an iterative retrieval generation framework, which gradually approaches the optimal answer by establishing a multi-round interactive retrieval-generation mechanism; and third, a hybrid retrieval architecture that integrates sparse and dense retrieval, leveraging the complementary strengths of the two retrieval methods to improve initial recall. These technical solutions have achieved considerable success in improving basic retrieval capabilities.

[0005] However, existing technical solutions suffer from key bottlenecks: First, while query reconstruction and question decomposition techniques reduce the complexity of a single search, the lack of semantic association modeling between subqueries leads to logical discontinuities in the generated sub-question sequence. Second, the iterative retrieval mechanism produces a significant noise accumulation effect during multiple searches, which not only causes an exponential increase in computing resources but also leads to information overload in the context window. Finally, while the hybrid retrieval architecture improves recall, the lack of an intelligent semantic focusing mechanism results in a large number of low-relevance documents in the search results. This noisy data can severely interfere with the reasoning process of the subsequent generation model, ultimately affecting the quality of the answer. These technical shortcomings have severely restricted the practical application of RAG systems in multi-hop question-answering scenarios. Summary of the Invention

[0006] The technical problem to be solved by the present invention is to provide a RAG multi-hop question answering method and device, system, and storage medium to solve the problems of logical discontinuity, retrieval noise accumulation, and semantic deviation in multi-hop question answering.

[0007] To achieve the above object, the present invention adopts the following technical solutions:

[0008] A RAG multi-hop question answering method, comprising:

[0009] Step S1, training planning model and information extraction model;

[0010] Step S2: Use the trained planning model to parse the complex question into a retrieval subtask and a reasoning subtask. Contextual logical dependencies are established between the retrieval subtask and the reasoning subtask via question-answer placeholders. The retrieval subtask triggers a dual-path retrieval, text optimization, and information extraction process, while the reasoning subtask generates an intermediate answer directly based on the context.

[0011] Step S3: Combine the cosine similarity algorithm and the relative boundary distance algorithm to perform dual-path document retrieval to obtain the main index results and auxiliary retrieval results;

[0012] Step S4: Process the primary index results and the auxiliary index results in parallel, and sequentially connect the processed results to obtain the final search results; wherein the parallel processing is to integrate the corresponding text fragments based on themes and perform sentence-level text filtering;

[0013] Step S5: Use the trained information extraction model to process the retrieval subtask and the reasoning subtask, and integrate all intermediate results to generate the final answer.

[0014] Preferably, step S3 includes:

[0015] Step S31: Use the cosine similarity algorithm to obtain the top-k document indexes with the highest semantic similarity to the subquery;

[0016] Step S32: dynamically calibrate the query vector using an algorithm based on relative margin similarity to obtain the top-k document indexes;

[0017] Among them, the cosine similarity algorithm result is used as the main index, and the relative margin algorithm result is deduplicated as the auxiliary index.

[0018] Preferably, step S4 includes: step S41, converting the index into text segments and integrating them into text blocks according to themes;

[0019] Step S42: Divide the text block into a sentence list, calculate the similarity between the sentence and the subquery, and sort and trim the sentence;

[0020] Step S43: reorganize the clipped sentences into text blocks and sort them by average similarity;

[0021] Step S44: Execute steps S41-S43 on the primary index and the auxiliary index in parallel, and connect the results sequentially to obtain the final search result.

[0022] Preferably, step S5 includes:

[0023] Step S51: For the retrieval subtask, use the information extraction model to perform retrieval enhancement generation;

[0024] Step S52: For the reasoning subtask, replace the placeholder with the answer in the mapping table to perform reasoning question and answer;

[0025] Step S53: Integrate the intermediate answers into the prompt word template in the order of the subtasks to obtain the final answer.

[0026] The present invention also provides a RAG multi-hop question-answering device, comprising:

[0027] The knowledge base construction module is used to divide the input document into blocks of equal length. Each text block retains its own topic and is converted into a high-dimensional semantic vector using the e5-base-v2 encoder. The vector vector is then stored in the vector database and indexed.

[0028] Thought chain fine-tuning module, used to train planning models and information extraction models;

[0029] The task decomposition module is used to decompose the retrieval subtask and the reasoning subtask, and establish logical dependencies through placeholders;

[0030] The dual-path retrieval module is used to combine the cosine similarity algorithm and the relative boundary distance algorithm to perform dual-path document retrieval and obtain the main index results and auxiliary retrieval results;

[0031] The text optimization module is used to process the primary index results and the auxiliary index results in parallel, and sequentially connect the processed results to obtain the final search results. The parallel processing is to integrate the corresponding text fragments based on themes and perform sentence-level text filtering.

[0032] The collaborative reasoning module is used to generate a task sequence with logical placeholders through the planning model and parse the subtask dependencies through the information extraction model, combine with the dynamic answer mapping table to achieve data integration, and cooperate with the information extraction model to generate the final answer.

[0033] The present invention also provides a RAG multi-hop question-answering system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes the RAG multi-hop question-answering method when executed by the processor.

[0034] The present invention also provides a storage medium, on which a computer program is stored, and the computer program executes the RAG multi-hop question-answering method when running.

[0035] The present invention handles multi-hop question-answering tasks through the following two approaches: On the one hand, the present invention utilizes task decomposition and logic arrangement technology, decomposes complex problems into ordered [retrieval] and [reasoning] subtasks through a planning model, and establishes explicit dependencies to ensure the logical coherence of multi-hop reasoning; on the other hand, the present invention utilizes dual-path index optimization technology, combined with cosine similarity and relative margin algorithms to achieve hybrid retrieval, and through dynamic semantic calibration and sentence-level filtering mechanisms, significantly improves retrieval accuracy and effectively reduces noise interference. The beneficial effects of the present invention are as follows:

[0036] 1. Through task decomposition and logical arrangement, complex multi-hop questions are broken down in an orderly manner and logical dependencies are established between subtasks, significantly improving the logical coherence of multi-hop question answering and avoiding logical breaks in the reasoning process.

[0037] 2. Using a similarity algorithm based on relative margins, the retrieval semantic boundaries are dynamically calibrated, effectively expanding the semantic coverage of the retrieval, improving the semantic relevance of the retrieval results, and helping to obtain relevant information more accurately.

[0038] 3. Implementing topic-level text integration and sentence-level noise filtering mechanisms can effectively remove redundant and irrelevant information, significantly reducing retrieval noise, thereby improving the accuracy of retrieval results and providing higher-quality information input for subsequent question and answer generation.

[0039] 4. Model fine-tuning based on thought chain enables small-scale models to demonstrate capabilities comparable to large-scale models on specific tasks, achieving efficient and accurate reasoning and information extraction with less resource consumption, reducing dependence on large models.

[0040] 5. With the help of dynamic task allocation, retrieval algorithms that do not require additional training, and customizable parameters, the accuracy, robustness, and generalization ability of the question-answering system are improved, enabling it to operate stably and efficiently in various multi-hop question-answering scenarios and adapt to different task requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0042] Figure 1 This is a flow chart of the RAG multi-hop question-answering method according to an embodiment of the present invention;

[0043] Figure 2 This is a block diagram of an implementation of a thinking chain fine-tuning planning model provided by an embodiment of the present invention;

[0044] Figure 3 This is a block diagram of an implementation of a thought chain-based fine-tuning information extraction model provided by an embodiment of the present invention;

[0045] Figure 4 A schematic diagram of the problem decomposition and planning process provided by an embodiment of the present invention;

[0046] Figure 5 A schematic diagram of the noise filtering and information extraction process provided by an embodiment of the present invention;

[0047] Figure 6 This is a structural block diagram of the RAG multi-hop question-answering system provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0048] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0049] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0050] Example 1:

[0051] like Figure 1 As shown, an embodiment of the present invention provides a RAG multi-hop question-answering method, including:

[0052] Step S1, training planning model and information extraction model;

[0053] Step S2: Use the trained planning model to parse the complex question into a retrieval subtask and a reasoning subtask. Contextual logical dependencies are established between the retrieval subtask and the reasoning subtask via question-answer placeholders. The retrieval subtask triggers a dual-path retrieval, text optimization, and information extraction process, while the reasoning subtask generates an intermediate answer directly based on the context.

[0054] Step S3: Combine the cosine similarity algorithm and the relative boundary distance algorithm to perform dual-path document retrieval to obtain the main index results and auxiliary retrieval results;

[0055] Step S4: Process the primary index results and the auxiliary index results in parallel, and sequentially connect the processed results to obtain the final search results; wherein the parallel processing is to integrate the corresponding text fragments based on themes and perform sentence-level text filtering;

[0056] Step S5: Use the trained information extraction model to process the retrieval subtask and the reasoning subtask, and integrate all intermediate results to generate the final answer.

[0057] As an implementation of the embodiment of the present invention, step S3 includes:

[0058] Step S31: Use the cosine similarity algorithm to obtain the top-k document indexes with the highest semantic similarity to the subquery;

[0059] Step S32: dynamically calibrate the query vector using an algorithm based on relative margin similarity to obtain the top-k document indexes;

[0060] Among them, the cosine similarity algorithm result is used as the main index, and the relative margin algorithm result is deduplicated as the auxiliary index.

[0061] As an implementation of an embodiment of the present invention, step S4 includes: step S41, converting the index into text segments and integrating them into text blocks according to themes;

[0062] Step S42: Divide the text block into a sentence list, calculate the similarity between the sentence and the subquery, and sort and trim the sentence;

[0063] Step S43: reorganize the clipped sentences into text blocks and sort them by average similarity;

[0064] Step S44: Execute steps S41-S43 on the primary index and the auxiliary index in parallel, and connect the results sequentially to obtain the final search result.

[0065] As an implementation of the embodiment of the present invention, step S5 includes:

[0066] Step S51: For the retrieval subtask, use the information extraction model to perform retrieval enhancement generation;

[0067] Step S52: For the reasoning subtask, replace the placeholder with the answer in the mapping table to perform reasoning question and answer;

[0068] Step S53: Integrate the intermediate answers into the prompt word template in the order of the subtasks to obtain the final answer. Example 2:

[0069] An embodiment of the present invention further provides a RAG multi-hop question-answering method, including:

[0070] Step 1: Train the problem decomposition planning model and information extraction model

[0071] First, through prompts with specific decomposition-planning instructions and a few-shot examples, complex multi-hop problems are fed into the larger model, generating a structured JSON output containing a list of orchestrated tasks for downstream parsing. Although the base model can also generate plans, its decomposition and planning capabilities are still limited, necessitating fine-tuning based on thought chaining to improve model performance.

[0072] Next, we need to obtain training data for training two different models. For the question decomposition planning model, 2500 questions are randomly selected from each of the four multi-hop question answering datasets HotPotQA, 2WikiMultiHopQA, Musique, and ComplexWebQuestions. The task planning list is generated using task-specific instructions, a small number of sample prompts, and the contextual learning ability of GPT-4o. Based on these outputs, the embodiment of the present invention constructs a dataset D0 containing 10,000 <question, planning output> pairs. Figure 2 As shown, on this basis, we continue to combine the prompt word guidance model (GPT-4o) to generate a complete thinking chain reasoning trajectory for problem decomposition. This produces a training dataset D1 containing 10,000 entries * ={Q, CoT, Plan}.

[0073] Similarly, for information extraction models, it is necessary to ensure that the processing model makes the most of the retrieved information to generate accurate responses, thereby maintaining the integrity of the entire logical chain. Figure 3 As shown in the figure, 8,000 examples are randomly selected from the natural question (NQ) training set, and their questions, true answers, and the content obtained by the two-way retrieval are organized into a predefined instruction template to guide GPT-4o to generate a thinking path that gradually infers the answer based on the question and the retrieval content, that is, the reasoning thinking chain. The generated training dataset D2 *= {q, rs, CoT, answer} contains these question-answer pairs, their reasoning trajectories, and retrieval content.

[0074] Synthetic training dataset D1 with chain-of-thought annotations * The training language model first generates a chain-of-thought reasoning for question decomposition, and then generates an interpretable planning task sequence; synthetic training dataset D2 with chain-of-thought annotations * The training language model first generates a chain-of-thought reasoning for analyzing questions and documents, and then outputs the final reasoning answer.

[0075] Specifically, during the training process, the pre-trained language model parameter matrix is decomposed into W = W0 + ΔW, where ΔW = BA is a low-rank adaptation matrix, and are trainable parameter matrices, r is the rank parameter and r << min(d, k). During training, W0 is frozen, and only the low-rank adaptation matrix is trained. Through supervised fine-tuning (SFT) with a standard language modeling objective, the model learns the reasoning patterns of the dataset by maximizing the generation accuracy given the question q and the instruction prompt P, and is optimized using cross-entropy loss.

[0076] In theory, any pre-trained language model can be used as the initial model; in this invention, the base model is initialized using Llama38B-Instruct. During training and inference, both fine-tuned models use the same prompt template.

[0077] Step 2: Input the user question (multi-hop question) into the planning model, and parse and output to obtain the planning sequence

[0078] As Figure 4 shown, first, under the guidance of the instruction prompt, the planning model generates a chain-of-thought reasoning to decompose the question and analyze the relationship between subtasks, and then generates an ordered list of subtasks P = [P1, P2, …, P n . Each subtask P i = (Type i , Query i , Tag i ) is a triple, containing the operation task type, the task query statement, and the task tag. During the sequential processing of subtasks, the system constructs and maintains a mapping dictionary A = [A1, A2, …, A n , storing the <placeholder - answer> pairs of P, where is a one-to-one mapping, and the replacement mechanism maintains the logical flow by reducing LM calls.

[0079] Specifically, during the execution of subtask j, the embodiment of this invention uses Replace all placeholders in the current query statement to generate the final executable version of the subquery. Since each subtask is executed sequentially, it is guaranteed that the answer corresponding to each placeholder in the mapping dictionary is not empty. Subtasks are processed by type: the [Reasoning] task directly generates the answer after extracting the query statement and the input information from the reasoning prompt template, while the [Retrieval] task uses a dual-path index, followed by content filtering and optimized retrieval enhancement generation. All subtask answers A are stored in A and aggregated for final reasoning and synthesis, optimizing resource allocation while minimizing redundant retrieval and noise accumulation.

[0080] Step 3: The subquery of the retrieval task uses a two-way retrieval algorithm based on relative margin similarity enhancement to obtain index results

[0081] Although cosine similarity is widely used as a basic method for text vector matching, its inherent limitations, such as scale inconsistency and centrality bias, have become increasingly negatively impacted in large-scale vector databases (more than tens of millions of records). The relative margin similarity measurement scheme calculates the difference between the candidate query similarity and the average similarity between the candidate and its nearest neighbors to establish a dynamic comparison benchmark to address the scale inconsistency problem of traditional methods. The present invention simplifies the relative margin-based measurement method and uses the results to supplement the traditional cosine retrieval results.

[0082] Specifically, the calculation formula of the relative margin measurement method is as follows:

[0083]

[0084] Similarity score is the ratio of cosine similarity to relative margin similarity. The k1 vectors closest to the query vector q in the vector database is the cosine similarity between the query vector and the database vector.

[0085] is the dynamically constructed neighborhood similarity benchmark value, and the calculation formula is:

[0086]

[0087] Among them, z belongs to the k2 vectors closest to the query vector q in the vector database And k2 is much smaller than k1. NN The metric differs fundamentally from the standard cosine similarity in its semantic evaluation, by computing The average of the cosine similarities with q’s k2 nearest neighbors {z}, which dynamically recalibrates the similarity benchmark and effectively addresses the inherent limitations of cosine similarity in terms of scale consistency and central tendency.

[0088] Specifically, the original boundary-based retrieval method evaluates all database vectors The score is calculated relative to the k2 nearest neighbors {z} of the query q. However, as the database expands, this approach will bring huge computational overhead. In fact, the difference between relative margin similarity and cosine similarity mainly occurs in the semantic neighborhood of q. Therefore, in the present invention, the boundary calculation is limited to the k1 nearest neighbors of q. Excluding remote vectors: k1 = 1000 >> k2 = 20. Compared to the original method that needs to process millions of vectors, the latency is reduced without sacrificing accuracy.

[0089] Step 4: Filter and integrate the content of the dual-path index obtained from the retrieval task, and perform retrieval enhancement generation with reasoning thinking chain

[0090] Directly merging the two index results obtained in step (3) will introduce too long context and a lot of text noise, which will damage the performance of LLM. By deduplicating the boundary-based search results according to the cosine search results, and then applying topic-level merging and sentence-level filtering to the two index sets, the search quality is improved. Figure 5 As shown, both indexes follow the same processing flow.

[0091] Specifically, the primary index and the auxiliary index are converted into the original text block set T main ={T i} and T aux ={T j Each text block in the collection retains its theme during the cosine segmentation process. Then, text aggregation is performed based on the pre-stored theme identifiers, and text blocks with the same title are spliced ​​across documents to generate a collection of text blocks with coherent themes. and That is, a union operation is performed on all 1-M or 1-N topics of the two indexes. The single block construction satisfies:

[0092]

[0093] where s m Indicates the mth unique title, where s n Indicates the nth unique title. main and B aux Divide into a set of sentences with titles and Calculate the relationship between each sentence and the query vector s n degrees, and obtain the similarity score list cos={c1,c2,…,c L1} and cos={c1,c2,…,c L2}, where the similarity is calculated as c i =cos(q,s i ); after sorting the list in reverse order, cut it according to the preset ratio (the cosine similarity list is set to 70% before the cutoff, and the relative margin similarity list is set to 50% before the cutoff), delete the sentences with low semantic relevance, and get and According to the sentence list S obtained by filtering main and S aux , whose index maps and organizes the original sentence set into a noise-filtered text block set B main_filtered and B aux_filtered .

[0094] Furthermore, the obtained text block set B main_filtered and B aux_filtered Sequentially connect and fill in the question-answer template together with the current query question, then input the information extraction model obtained by fine-tuning in step (1). After outputting a long answer with a chain of reasoning thoughts, the information extraction model extracts the concise answer from it again and fills it into the global answer mapping dictionary A so that it can be filled in the placeholder in the subsequent task query to complete this [retrieval] task.

[0095] In particular, the process intentionally maintains independent filtering pipelines for the two indexing methods, as boundary-based retrieval captures semantic patterns that are fundamentally different from cosine similarity. Early merging would result in prioritizing cosine-based content during sentence-level filtering, failing to capture more semantic information.

[0096] Step 5: Combine all question-answer pairs in the “question-answer” mapping dictionary A and the original question input, combine with the specific prompt word template, and output the final answer corresponding to the original complex multi-hop question

[0097] Example 3:

[0098] like Figure 6 As shown, the present invention also provides a RAG multi-hop question-answering device, comprising:

[0099] Knowledge Base Construction Module: Upon startup, the input document is segmented into chunks of 100 tokens. If the text is too long, it is truncated at periods or commas, preserving the topic information of each chunk. After processing with the e5-base-v2 encoder, these chunks are converted into high-dimensional semantic vectors, which are then stored in the vector database and indexed.

[0100] The Thought Chain fine-tuning module: Before processing user questions, it leverages pre-trained language models (such as GPT-4o) and thought chain technology to generate a training dataset containing reasoning processes on a multi-hop question-answering dataset. By applying low-rank adaptive fine-tuning, the model improves its planning and information extraction capabilities.

[0101] Task Decomposition Module: When a user enters a question into the system, the Task Decomposition Module breaks it down into two subtasks: retrieval and reasoning. Using a placeholder mechanism, the module establishes logical connections between subtasks, forming an ordered list of subtasks. Each subtask in the list includes key information such as the task type, query statement, and tags.

[0102] Collaborative Reasoning Module: The decomposed subtask sequence enters this module, where it is judged and processed according to the subtask type. For [retrieval] tasks, a dual-path retrieval process is triggered; for [reasoning] tasks, the reasoning operation proceeds directly. During processing, this module updates the dynamic answer mapping dictionary in real time and stores the intermediate results of each subtask, ensuring the integrity and coherence of the reasoning chain and enabling data coherence across steps.

[0103] Dual-Path Retrieval Module: This module is activated when a retrieval task is encountered. It cleverly combines the cosine similarity algorithm and the relative margin algorithm to efficiently retrieve relevant documents from different semantic levels and obtain the top-k document indexes. The processed retrieval results are then sent to the text optimization module.

[0104] Text Optimization Module: The retrieved index is converted into text snippets and clustered by topic to generate semantically coherent text blocks. These snippets are then segmented into sentence lists, ranked and pruned by calculating their similarity to the subquery, removing redundant and low-relevance sentences. Finally, the optimized text results are integrated and output, providing accurate and concise input for the information extraction model.

[0105] Through the collaborative work of the above modules, the system realizes the complete process from user questions to answers, effectively solves the multi-hop question-answering problem, and improves the accuracy and reliability of answers.

[0106] Example 3:

[0107] An embodiment of the present invention further provides a RAG multi-hop question-answering system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes the RAG multi-hop question-answering method when executed by the processor.

[0108] Example 4:

[0109] An embodiment of the present invention further provides a storage medium having a computer program stored thereon, and the computer program executes the RAG multi-hop question-answering method when running.

[0110] The embodiments described above are merely descriptions of preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by persons skilled in the art should fall within the scope of protection defined by the claims of the present invention.

Claims

1. A RAG multi-hop question-answering method, characterized in that: include: Step S1, training planning model and information extraction model; Step S2: Parse the complex problem into retrieval subtasks and reasoning subtasks using the trained planning model; The retrieval subtask and the reasoning subtask establish contextual logical dependencies through question-answer placeholders. The retrieval subtask triggers a dual-path retrieval, text optimization, and information extraction process, while the reasoning subtask directly generates an intermediate answer based on the context. Step S3: Combine the cosine similarity algorithm and the relative boundary distance algorithm to perform dual-path document retrieval to obtain the main index results and auxiliary retrieval results; Step S4: Process the primary index results and the auxiliary index results in parallel, and sequentially connect the processed results to obtain the final search results; wherein the parallel processing is to integrate the corresponding text fragments based on themes and perform sentence-level text filtering; Step S5: Use the trained information extraction model to process the retrieval subtask and the reasoning subtask, and integrate all intermediate results to generate the final answer.

2. The RAG multi-hop question-answering method according to claim 1, wherein: Step S3 includes: Step S31: Use the cosine similarity algorithm to obtain the top-k document indexes with the highest semantic similarity to the subquery; Step S32: dynamically calibrate the query vector using an algorithm based on relative margin similarity to obtain the top-k document indexes; Among them, the cosine similarity algorithm result is used as the main index, and the relative margin algorithm result is deduplicated as the auxiliary index.

3. The RAG multi-hop question-answering method according to claim 2, wherein: Step S4 includes: Step S41: convert the index into text fragments and integrate them into text blocks according to themes; Step S42: Divide the text block into a sentence list, calculate the similarity between the sentence and the subquery, and sort and trim the sentence; Step S43: reorganize the clipped sentences into text blocks and sort them by average similarity; Step S44: Execute steps S41-S43 on the primary index and the auxiliary index in parallel, and connect the results sequentially to obtain the final search result.

4. The RAG multi-hop question-answering method according to claim 3, wherein: Step S5 includes: Step S51: For the retrieval subtask, use the information extraction model to perform retrieval enhancement generation; Step S52: For the reasoning subtask, replace the placeholder with the answer in the mapping table to perform reasoning question and answer; Step S53: Integrate the intermediate answers into the prompt word template in the order of the subtasks to obtain the final answer.

5. A RAG multi-hop question-answering device, characterized in that: include: The knowledge base construction module is used to divide the input document into blocks of equal length. Each text block retains its own topic and is converted into a high-dimensional semantic vector using the e5-base-v2 encoder. The vector vector is then stored in the vector database and indexed. Thought chain fine-tuning module, used to train planning models and information extraction models; The task decomposition module is used to decompose the retrieval subtask and the reasoning subtask, and establish logical dependencies through placeholders; The dual-path retrieval module is used to combine the cosine similarity algorithm and the relative boundary distance algorithm to perform dual-path document retrieval and obtain the main index results and auxiliary retrieval results; The text optimization module is used to process the primary index results and the auxiliary index results in parallel, and sequentially connect the processed results to obtain the final search results. The parallel processing is to integrate the corresponding text fragments based on themes and perform sentence-level text filtering. The collaborative reasoning module is used to generate a task sequence with logical placeholders through the planning model and parse the subtask dependencies through the information extraction model, combine with the dynamic answer mapping table to achieve data integration, and cooperate with the information extraction model to generate the final answer.

6. A RAG multi-hop question answering system, characterized in that: include: A memory and a processor, wherein the memory stores a computer program executed by the processor, and when the computer program is executed by the processor, the RAG multi-hop question-answering method according to any one of claims 1 to 4 is executed.

7. A storage medium, characterized in that: The storage medium stores a computer program, which executes the RAG multi-hop question-answering method according to any one of claims 1 to 4 when running.

Citation Information

Cited By

  • Subject knowledge multi-hop question and answer method based on structured planning and reflection reasoning

    CN121480651A