Intelligent question and answer processing method based on RAG retrieval enhancement
By employing a multi-round progressive retrieval and verification mechanism, combining sparse and dense vector retrieval, and utilizing a deep semantic matching model to evaluate answer reliability, this approach addresses the issues of insufficient information capture and credibility assessment in existing question-answering systems, thereby achieving the generation of high-quality answers and improved transparency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-06
- Publication Date
- 2026-04-10
AI Technical Summary
Existing question-answering methods based on retrieval enhancement struggle to fully capture the multidimensional information needs of complex questions, lack a mechanism for evaluating the reliability of generated answers, and lack a dynamic feedback mechanism to optimize the retrieval process, resulting in insufficient answer quality and credibility.
It adopts a multi-round progressive retrieval and verification mechanism, combines sparse vector and dense vector retrieval, integrates pre-trained language model generation and evaluation, and uses a deep semantic matching model for re-ranking and credibility calculation to dynamically adjust the retrieval query to obtain high-quality answers.
It significantly improves the accuracy and reliability of answers, provides quantitative confidence indicators and answer traceability, enhances the transparency and user credibility of the system, and improves the completeness of knowledge retrieval for complex problems.
Smart Images

Figure CN121833902A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence and natural language processing, and particularly relates to an intelligent question and answer processing method based on RAG retrieval enhancement. BACKGROUND
[0002] With the rapid development of information technology and the explosive growth of Internet data, how to quickly and accurately obtain the required information from a large amount of unstructured text has become a core challenge in the field of current human-computer interaction and knowledge service. Intelligent question and answer system as a key technology connecting user natural language question and vast knowledge base, its goal is to directly understand user intent and generate accurate and reliable answers, thereby greatly improving the efficiency of information retrieval and knowledge acquisition, and having wide application prospects in intelligent customer service, online education, medical auxiliary decision-making and enterprise knowledge management, etc.
[0003] Traditional intelligent question and answer systems mainly follow two technical paths based on retrieval or generation. The retrieval-based method relies on accurate matching of existing knowledge base, directly extracting answers from predefined question and answer pairs or document fragments, which has the advantages of fixed and controllable answer sources, but is limited by the coverage and generalization ability of the knowledge base, and is difficult to deal with complex and open-domain questions. The generative method based on deep learning and large-scale pre-training language model can directly synthesize fluent and coherent natural language answers, significantly improving the expression flexibility and context adaptability of the system, but such models are prone to factual errors or "hallucinations" in the generation process, i.e. generating seemingly reasonable but lacking reliable knowledge support, resulting in difficulty in ensuring the credibility of the answer. In recent years, retrieval-enhanced generation technology combines the advantages of the two methods, by retrieving relevant information from external knowledge base in real time as context basis for generating answers, to a certain extent, enhancing the factual accuracy of the generated answers, and becoming the mainstream direction of current research and application.
[0004] However, the existing retrieval-enhanced generation-based question and answer method still faces several key technical problems: first, a single round of retrieval often fails to fully capture the multi-dimensional information needs of complex problems, especially when the initial query expression is not accurate enough or the knowledge base information is sparse, which easily leads to incomplete or insufficient relevance of the retrieved context, and further affects the quality of the generated answer; second, most systems lack effective evaluation mechanisms for the reliability of the generated answers, and cannot quantify the credibility of the answers before output, making it difficult for users to judge whether the answers have sufficient evidence support; finally, when the system identifies that the current retrieval results are insufficient to support high-credibility answers, it usually lacks a dynamic and adaptive feedback mechanism to guide the new round of more targeted retrieval, thereby limiting the system's ability to optimize the final output results through iteration.
[0005] Therefore, it is necessary to invent an intelligent question and answer processing method based on RAG retrieval enhancement to solve the above problems. SUMMARY
[0006] The present application aims to provide an intelligent question and answer processing method based on RAG retrieval enhancement to solve the problems raised in the background art.
[0007] To achieve the above-mentioned purpose, the present application provides the following technical scheme: an intelligent question and answer processing method based on RAG retrieval enhancement, specifically comprising the following steps: S1, receiving a natural language question input by a user; S2, generating an initial retrieval query based on the natural language question; S3, taking the initial retrieval query as the retrieval query of the current round, performing multi-round progressive retrieval and verification until obtaining a final answer text meeting the reliability requirement, wherein each round includes: S31, based on the retrieval query of the current round, retrieving a plurality of candidate text segments from a target knowledge base and reordering them to obtain Top-K candidate text segments ranked in descending order of relevance, K being an integer greater than 1; S32, inputting the natural language question and the Top-K candidate text segments obtained in the current round into a pre-trained language model; the pre-trained language model is configured to perform two tasks simultaneously: Task 1, generating an initial answer text of the current round; Task 2, outputting an overall credibility score representing the reliability of the initial answer text; S33, if the overall credibility score is not lower than a preset credibility threshold, taking the initial answer text of the current round as the final answer text and outputting, and the process ends; S34, in response to the overall credibility score being lower than the credibility threshold, reconstructing the retrieval query of the current round based on the initial answer text and the Top-K candidate text segments, generating a retrieval query of a new round, and returning to step S31.
[0008] The technical effects and advantages of the present application are as follows: 1. The present application effectively combines the advantages of keyword exact match and deep semantic similarity by performing sparse vector retrieval and dense vector retrieval in parallel and fusion, and combining a deep semantic matching model based on the Transformer architecture for reordering, significantly improving the overall relevance between the Top-K candidate text segments selected from the target knowledge base and the retrieval query, and providing a high-quality context basis for subsequent generation of reliable answers; 2、The application realizes the integration of generation and evaluation by configuring a pre-trained language model to synchronously perform the two tasks of initial answer text generation and overall credibility score output; and realizes quantitative evaluation of the reliability of the answer by comprehensively calculating the semantic similarity of each candidate text segment and the answer, and weighting and fusing the relevance score thereof with the retrieval query to calculate the overall credibility score, thereby providing accurate basis for decision-making; 3、The application realizes iterative optimization of the retrieval process by introducing a multi-round progressive retrieval and verification mechanism based on comparison of the overall credibility score with a preset threshold, which can automatically trigger query reconstruction when the answer credibility is insufficient, and expand or correct the retrieval query by supplementing information extraction of low semantic correlation segments, thereby continuously improving the accuracy and reliability of the final answer text; 4、The application provides a quantitative confidence index and answer traceability basis for the user by synchronously outputting the overall credibility score and at least one supporting candidate text segment as a reference source when outputting the final answer text, thereby greatly enhancing the transparency and user credibility of the intelligent question answering system; 5、The application identifies information gaps by calculating the semantic correlation between the candidate text segments and the initial answer text in the query reconstruction phase, and extracts supplementary information different from the current query from the gaps, thereby generating a new round of retrieval query, which can accurately locate the knowledge gaps and guide the retrieval to focus on the information dimensions that are not fully covered, thereby effectively improving the knowledge retrieval completeness under complex problems. BRIEF DESCRIPTION OF DRAWINGS
[0009] Figure 1 The method flowchart of the application.
[0010] Figure 2 The candidate text segment retrieval and reordering flowchart of the application.
[0011] Figure 3 The overall credibility score calculation flowchart of the application.
[0012] Figure 4 The query reconstruction flowchart of the application. DETAILED DESCRIPTION
[0013] The technical solutions in the embodiments of the application will be described clearly and completely below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only part of the embodiments of the application, rather than all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the application.
[0014] The application provides a method for generating an answer to a query as follows Figure 1The illustrated intelligent question answering processing method based on RAG retrieval enhancement specifically includes the following steps: S1, receiving a natural language question input by a user; Specifically, the execution subject of the present application can be an intelligent question answering processing system deployed on a server side. The system provides a user interaction interface, such as a Web API, a graphical user interface or a message robot interface, through which the original question text input by the user is received.
[0015] In a preferred embodiment, the received natural language question can also be preprocessed before generating the initial retrieval query (S2). The preprocessing includes but is not limited to correcting obvious spelling errors, performing text normalization such as full-width to half-width conversion, capitalization uniformity, and identifying the intent category of the question. The purpose of preprocessing is to clean the input data and improve the stability of subsequent retrieval and generation.
[0016] S2, generating an initial retrieval query based on the natural language question; Further, in the above technical solution, S2 includes: inputting the natural language question into a query generation model to generate the initial retrieval query; wherein the query generation model is a sequence-to-sequence model based on the Transformer architecture.
[0017] It should be noted that the query generation model is the core component for converting from a natural language question to a structured retrieval query. In a specific embodiment, the query generation model is a supervised fine-tuned Transformer sequence-to-sequence model, such as T5, BART or its variants.
[0018] The training process of the model is as follows: first, a training data set is constructed, which contains a large number of triple samples, each sample includes: an original natural language question, one or more standard retrieval queries extracted or artificially constructed from the document related to the question, and the corresponding relevant text fragment. The learning goal of the model is to generate the corresponding standard retrieval query according to the input original question.
[0019] In the model inference phase, that is, when performing step S2, the natural language question input by the user is input into the query generation model as the source sequence. The model performs semantic understanding and intent analysis on the question and generates an optimized query text that is more suitable for retrieval in the target knowledge base. The initial retrieval query generated usually contains more explicit keywords, entities or limiting conditions than the original question, and its purpose is to improve the accuracy and recall rate of the first retrieval.
[0020] Further, the query generation model in step S2 can share or partially share the mechanism relied on in the subsequent step S34 for performing query reformulation. In a preferred implementation, the query reformulation in step S34 can also be achieved by invoking or reusing this query generation model, whose input is no longer only the original question, but is combined with the initial answer text of the current round, and the supplementary information extracted from the candidate text segments with lower relevance in the retrieval results, so as to generate a revised or expanded new retrieval query to guide the next round of more accurate retrieval.
[0021] S3, performing multi-round progressive retrieval and verification with the initial retrieval query as the retrieval query of the current round until the final answer text meeting the reliability requirement is obtained, wherein each round comprises: S31, retrieving a plurality of candidate text segments from the target knowledge base based on the retrieval query of the current round, and reordering the candidate text segments to obtain Top-K candidate text segments arranged in descending order of relevance, K being an integer greater than 1; Further, in the above technical solution, reference Figure 2 is made to the following sub-steps: S311, performing sparse vector retrieval and dense vector retrieval in parallel based on the retrieval query to obtain a first candidate result set and a second candidate result set; S312, fusing and deduplicating the first candidate result set and the second candidate result set to form a hybrid result set; S313, concatenating each candidate text segment in the hybrid result set with the retrieval query, inputting a deep semantic matching model, and obtaining a relevance score of each candidate text segment; S314, sorting the candidate text segments in the hybrid result set in descending order according to the relevance scores, and selecting the top K as the Top-K candidate text segments, wherein K is a preset positive integer parameter, and the core meaning is that the number of candidate text segments selected from the target knowledge base to support subsequent answer generation and evaluation in each round of progressive retrieval is limited.
[0022] The target knowledge base is constructed from unstructured original documents (such as text files, web pages, PDF documents, etc.). The construction process includes: parsing and cleaning the original documents, then blocking them by semantics or fixed length to obtain a series of text segments; then, a semantic encoding model (such as the Sentence-BERT model based on Transformer) is used to generate a dense vector representation for each text segment, and the dense vector representation is stored in a vector database (such as Faiss, Milvus) to construct an index for dense vector retrieval; at the same time, a traditional inverted index is established for these text segments to support sparse vector retrieval.
[0023] Further, in the above technical solution, the deep semantic matching model in S313 is a model based on a Transformer architecture.
[0024] It should be noted that step S31 aims to efficiently and accurately filter out the most relevant knowledge fragments from a large-scale target knowledge base by fusing the advantages of different retrieval techniques and using deep semantic understanding for fine sorting.
[0025] Specifically, the sparse vector retrieval (S311) may, for example, employ a BM25 algorithm based on an inverted index, which represents the retrieval query Q and the text fragments d in the knowledge base as sparse vectors under a Bag-of-Words model, and calculates the matching score S (Q, d) by the following formula: BM25 where t is a term in the query Q, f(t, d) is the frequency of term t in the text fragment d, |d| is the length of the text fragment d (in terms), avgdl is the average length of all documents or fragments in the knowledge base, k1 and b are adjustable parameters, and IDF(t) is the inverse document frequency of term t, which is usually calculated as where N is the total number of documents or fragments in the knowledge base, and n(t) is the number of documents or fragments containing term t. The advantage of this algorithm is that it can effectively capture the exact match of keywords and the importance of terms.
[0026] The dense vector retrieval (S311) is based on dense vector representation (i.e. Embedding). In specific implementation, a pre-trained semantic encoding model E(·) (such as a dual encoder based on Transformer) is used to encode the retrieval query Q and the text fragments d in the knowledge base into fixed-dimensional dense vectors q = E(Q) and p = E(d), respectively. During retrieval, the similarity between the query vector and all fragment vectors in the knowledge base is calculated, such as cosine similarity, and the top several fragments with the highest similarity are returned. The cosine similarity S dense (Q, d) is calculated by the formula: The advantage of this retrieval is that it can understand the semantic similarity between the query and the text, and alleviate the problem of lexical mismatch.
[0027] Parallel execution of sparse vector retrieval and dense vector retrieval can obtain first candidate result set C1 and second candidate result set C2 based on different matching principles. In step S312, the fusion strategy can be a simple union operation C h =C1∪C2, or a weighted combination according to the preliminary score. For example, one kind of weighted combination strategy can calculate a fusion score S fused (d) for each text fragment d: where Norm(·) denotes a standardization process such as min-max normalization on the original scores, and a is a fusion weight coefficient between 0 and 1. The deduplication operation is based on the content identification (such as document ID and fragment position) or semantic vector (by calculating vector similarity and setting a threshold to determine whether it is duplicated) of the text fragment to ensure the uniqueness of the entries in the mixed result set. For example, based on the semantic vector deduplication, the threshold can be set as , if the semantic vector cosine similarity sim(d i , d j ) of two candidate text fragments d i and d j > , they are considered to be duplicated, and only the one with a higher score is retained.
[0028] The deep semantic matching model in step S313 is used for more refined "reordering". The model is usually a cross-encoder based on the Transformer architecture. In the training phase, supervised training is performed using (query, positive text fragment, negative text fragment) triplets to learn to judge the deep semantic relevance between the query and the text fragment. In the inference phase, for each candidate text fragment d in the mixed result set, the current round of retrieval query Q is spliced with the fragment to form an input format of "[CLS] Q [SEP] d [SEP]", which is input into the cross-encoder model. The model jointly encodes the entire sequence of inputs, finally extracts the feature vector corresponding to the [CLS] position, and maps it to a real value score r through a classification layer, which is the refined relevance score of the candidate text fragment with respect to the retrieval query: r = M cross ([CLS] Q [SEP] d [SEP]), which is a more complex semantic association than the initial vector similarity score.
[0029] Finally, in step S314, according to the relevance score calculated by the deep semantic matching model, all candidate text fragments are sorted in descending order, and the top K fragments are selected as the Top-K candidate text fragments used in the subsequent processing of this round. This process significantly improves the quality of the context provided to the answer generation link, and is the key basis for the reliability of the entire retrieval enhancement process.
[0030] S32, input the natural language question and the Top-K candidate text fragments obtained in the current round into a pre-trained language model; the pre-trained language model is configured to perform two tasks simultaneously: Task 1: generate an initial answer text for the current round; Task 2: output an overall credibility score representing the reliability of the initial answer text; Further, in the above technical solution, the reference Figure 3 In the S32, the overall confidence score is calculated by the following sub-steps: S321, obtaining the semantic vector representation of the initial answer text, and obtaining the semantic vector representation of each candidate text segment; S322, for each candidate text segment, calculating the similarity between its semantic vector representation and the semantic vector representation of the initial answer text as the segment support score of the segment; S323, based on the relevance scores obtained in step S31, weighting and fusing the segment support scores of the Top-K candidate text segments to obtain the overall confidence score.
[0031] Further, in the above technical solution, the weighting and fusing in the S323 is performed by: normalizing the relevance scores obtained in step S31 to obtain the weight of each candidate text segment; and using the weight to weight and sum the corresponding segment support scores.
[0032] It should be noted that the pre-trained language model in step S32 is the key to realizing synchronous generation and evaluation. In a preferred embodiment, the model is an autoregressive or encoder-decoder model based on the Transformer architecture, such as the GPT series, T5 or similar large-scale pre-trained models. The model is trained by a specific multi-task fine-tuning method, so that it has the ability to output a numerical confidence score simultaneously after given a question and a set of relevant text segments. Specifically, the training data of the model is in the form of a triple: 〈natural language question, set of relevant text segments, standard answer and artificially annotated reliability score〉. The annotation standard of the artificially annotated reliability score is as follows: the annotator judges whether each key fact claim in the standard answer can find explicit or reasonable support in at least one segment according to the provided Top-K candidate text segments. The reliability score is calculated based on the proportion of supported key claims to total claims, for example, if the answer contains 5 claims, 4 of which are supported by a segment, then the reliability score is 0.8. When multi-task fine-tuning, the total loss function L of the model is composed of the text generation loss L gen and the confidence evaluation loss L conf weighted: L = λ*L gen + (1-λ)*L conf , where λ is a balance hyperparameter. The text generation loss L gen usually adopts the standard next word prediction cross-entropy loss; the confidence evaluation loss L conf adopts the mean square error loss, which is used to minimize the difference between the confidence score output by the model and the artificially annotated reliability score.
[0033] In the model structure, a specific embodiment is to add a credibility evaluation head in addition to the standard language model head (for text generation). The head is usually a multi-layer perceptron (MLP) that takes the final hidden state (or the representation of the [EOS] token) of the language model after generating the answer text as input, and outputs a scalar score, which is the initial estimate of the overall credibility score, after nonlinear transformation. The model is fine-tuned end-to-end on the joint training data (containing questions, support documents, standard answers, and artificially labeled answer reliability labels) to optimize both the accuracy of text generation (such as cross-entropy loss) and the calibration of credibility evaluation (such as mean square error loss).
[0034] Regarding the acquisition of semantic vector representation (S321), in the implementation, the semantic vector representation of the initial answer text can be obtained by inputting it into a fixed sentence encoding model (such as BERT-based Sentence Transformer) to obtain a fixed-dimensional dense vector. Similarly, the semantic vector representation of each candidate text segment can be calculated in advance using the same sentence encoding model and stored in the knowledge base index, or calculated in real time when needed. These vectors capture the deep semantic information of the text.
[0035] In the calculation of the segment support score (S322), the similarity is usually calculated using cosine similarity. Specifically, for a candidate text segment d i , the calculation formula of the segment support score is as follows: where v ans is the semantic vector representation of the initial answer text, is the semantic vector representation of the candidate text segment d i , “·” represents vector dot product, and ||·|| represents vector L2 norm; the numerical range of the calculation result is between [-1, 1], and the higher the value represents the higher the consistency of the candidate text segment with the generated initial answer text in terms of semantics, i.e., the higher the support degree.
[0036] In the weighted fusion to obtain the overall credibility score (S323), the specific calculation process is as follows: first, normalize the relevance scores {r1, r2,..., r K} generated by the deep semantic matching model in step S31 for the Top-K segments, and convert the relevance score of each segment into a weight w i . A commonly used normalization method is to use the softmax function: where τ is an adjustable temperature parameter used to control the smoothness of the weight distribution. Then, the segment support score of each candidate text segment Its corresponding weight w i Multiply the results and sum the weighted sums of all K segments. The final weighted sum is the overall credibility score S. final : This design ensures that the overall credibility not only assesses the semantic consistency between the answer and each fragment, but also considers the relevance weight of these fragments to the question, thus reflecting the credibility of the initial answer text based on the current search results more comprehensively and reliably. This score is the core basis for subsequent decisions (S33) and query reconstruction (S34).
[0037] As a preferred implementation, to enhance the robustness of the credibility assessment and prevent intent drift during multiple rounds of retrieval, the weight calculation in step S323 can introduce anchoring to the user's original intent. Specifically, the system additionally calculates a deep semantic relevance score r between each candidate text fragment and the natural language question initially input by the user. i,question The score is obtained by inputting the original question and candidate text fragments into the same deep semantic matching model (cross-encoder) described in step S313. The final weights w used for weighted fusion are... i The relevance score r between the fragment and the current round of retrieval query i and the relevance score r to the original problem i,question Jointly decided. For example, fusion via linear weighting: w i =β*softmax(r) i )+(1-β)*softmax(r i,question ), where β is the fusion coefficient (e.g., 0.7), used to balance the current search focus with the original intent, and then w is used. i The segment support scores are weighted and summed to obtain the final overall credibility score. This scheme can be used as a configurable option for the system.
[0038] S33. If the overall credibility score is not lower than the preset credibility threshold, the initial answer text of this round will be output as the final answer text, and the process will end. Furthermore, in the above technical solution, in step S33, while outputting the final answer text, the overall credibility score and at least one candidate text fragment supporting the final answer text are also output as reference sources.
[0039] It is to be understood that the decision in step S33 is the key node for controlling the termination and output of the multi-round progressive retrieval process. The typical value range of the confidence threshold is between 0.6 and 0.9. When determining, the system can be run on the development set with real answers to draw the accuracy and recall rate curve of the final output answer under different thresholds. According to the emphasis on accuracy or coverage in the application scenario, the threshold corresponding to the performance inflection point is selected.
[0040] When it is determined that the overall confidence score is not lower than the threshold and it is decided to output the final answer text, the support information (overall confidence score and at least one candidate text segment) output by the system at the same time has important application value.
[0041] Specifically, the determination method of the at least one candidate text segment supporting the final answer text is as follows: the system reviews the Top-K candidate text segments and their corresponding segment support scores (S322) and weights (S323) used when calculating the overall confidence score in step S32. By setting a segment support threshold, support evidence is selected from these segments, for example, the top N segments with the highest segment support scores can be selected, or all segments with a score higher than a certain preset threshold can be selected as reference sources supporting the final answer text. These selected segments have high semantic consistency with the generated answer, thereby providing the user with traceability basis for the answer and enhancing the transparency and credibility of the system. The highest N segments, or all segments with a score higher than a certain preset threshold, are selected as reference sources supporting the final answer text. These selected segments have high semantic consistency with the generated answer, thereby providing the user with traceability basis for the answer and enhancing the transparency and credibility of the system.
[0042] The output of the overall confidence score provides the user with a quantitative confidence index, which is convenient for the user to judge whether to accept the answer. The output of the reference source enables the user to trace back to the specific basis in the knowledge base for verification or further exploration.
[0043] S34, query reconstruction: in response to the overall confidence score being lower than the confidence threshold, the initial answer text and the Top-K candidate text segments are used to reconstruct the retrieval query of the current round to generate a new retrieval query, and the step S31 is returned.
[0044] Further, in the above technical solution, the reference Figure 4 The S34 specifically includes the following sub-steps: S341, for each of the Top-K candidate text segments, calculating the semantic correlation degree thereof with the initial answer text; S342, identifying at least one target text segment with a semantic correlation degree lower than a preset correlation threshold; S343, extracting supplementary information different from the information already in the current retrieval query from the at least one target text segment; S344, expand or correct the search query of the current round using the supplementary information to generate a new round of search query.
[0045] Further, in the above technical solution, in S341, the semantic correlation degree is obtained by calculating the cosine similarity between the semantic vector representation of the candidate text segment and the semantic vector representation of the initial answer text.
[0046] It should be noted that the query reconstruction in step S34 is a key feedback mechanism for implementing multi-round progressive retrieval to improve the quality of the final answer. The core idea is that when the current round of retrieval results fails to support a high-credibility answer, the system analyzes the semantic correlation gap between the generated initial answer and the retrieved segments, and adjusts the search query to guide the next round of retrieval to focus on the direction of weak or missing information.
[0047] The specific implementation details are as follows: The calculation of the semantic correlation degree aims to quantify the semantic support degree of each candidate text segment for the generated initial answer text. As mentioned earlier, the cosine similarity can be calculated. Specifically, first, use a semantic encoding model (e.g., the same sentence encoding model as in step S321) to obtain the semantic vector v ans of the initial answer text and the semantic vector i of each candidate text segment d Then calculate the cosine similarity between them as the semantic correlation degree a i : The value ranges between [-1, 1], and the higher the value, the more consistent the segment is with the initial answer in terms of semantics, i.e., the higher the support.
[0048] Based on the calculated semantic correlation degree, the system identifies the candidate text segment with a semantic correlation degree a i below a preset correlation threshold (e.g., a value between 0.4 and 0.6, which can be determined by debugging on the development set to maximize the quality of the final answer) as the "target text segment". The threshold is a configurable parameter, and the typical value range is between 0.3 and 0.5. These low-correlation-degree target segments suggest that the current search query may not effectively cover the information dimensions contained in these segments, or the information in these segments deviates from the current query intent, thus constituting an "information gap" that needs to be filled.
[0049] Extract key supplementary information from the identified target text segments. In implementation, the following algorithm is used: Step 1: For each target text segment, use a keyword extraction algorithm (such as based on TF-IDF or TextRank) to extract its core keyword or key phrase set Ki .
[0050] Second step: Similarly, parse the current round of search query and extract its core term set Q terms .
[0051] Third step: For each key term k in K i , calculate its semantic similarity with all terms in Q terms (Using word vectors such as Word2Vec or BERT word vectors). If the maximum semantic similarity of key term k with any term in Q terms is below a pre-set similarity threshold (e.g. 0.7), consider k as a “supplemental information item” that is distinct from the current search query’s existing information.
[0052] Fourth step: Collect all the “supplemental information items” identified in the target text segments, and sort them by their importance (e.g. TF-IDF value) in their source segments, and select the top-M (e.g. M=2 or 3) as the “supplemental information” used in this round of reconstruction.
[0053] Use the extracted supplemental information to generate a new round of search query. In specific implementation, the supplemental information is added to the current search query in a logical “and” (AND) relationship to form an extended query. For example, the current search query is “deep learning framework comparison”, and the extracted supplemental information is “distributed training”, then the new round of search query can be constructed as “deep learning framework comparison distributed training”. This expansion process can be achieved through string concatenation.
[0054] In addition, in a more preferred embodiment, step S344 can use the query generation model described in step S2 to achieve more intelligent query reconstruction. To achieve this function, the query generation model needs to be fine-tuned for the second stage of task-specific: Build training data: Collect triplets <original question, low-confidence answer and related search segment, optimized new query>. Among them, “optimized new query” can be a query written by a person according to the defects of the answer and the segment information, aiming to retrieve more supporting evidence.
[0055] Fine-tune the model: concatenate the original question, the initial answer (or the summary of its main claims), and the supplemental information extracted from the related search segment (using the aforementioned S343 method) to form an input sequence, for example, “question: [original question] answer: [initial answer] supplement: [supplemental information]”. Take this as the source sequence, and take the “optimized new query” as the target sequence, to perform additional sequence-to-sequence fine-tuning on the query generation model.
[0056] Inference application: in step S344, the original natural language question of the current round, the summary of the initial answer text, and the supplementary information extracted in step S343 are spliced according to the format during fine-tuning, and input into the query generation model trained in two stages, and a new round of search query with optimized structure and clear intent is directly generated by the model.
[0057] To verify the effect of the query reconstruction mechanism proposed in the application on improving the effect of multi-round retrieval, the following table shows the change trend of key evaluation indicators from the first round to the tenth round of retrieval: Multi-round progressive retrieval index change table
[0058]
[0059] The table shows the complete change trend of the core indicators when the application performs multi-round progressive retrieval on a batch of complex problems. The data shows that with the iterative operation of the query reconstruction mechanism, the average relevance of the retrieved fragments to the query intent continues to increase, and the overall credibility score and cumulative accuracy rate of the generated answers also rise steadily. After about 5-6 rounds of retrieval, the main performance indicators gradually enter a stable platform period. This fully verifies that the multi-round progressive retrieval and dynamic query reconstruction mechanism proposed in the application can guide the retrieval process to systematically approach and eventually obtain sufficient information to support high-credibility answers, thereby significantly improving the final output quality in complex question-answering scenarios. At the same time, the mechanism has good convergence.
[0060] Finally, it should be noted that the above description is only a preferred embodiment of the application and does not limit the application. Although the application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent replacements to some technical features, as long as they are within the spirit and principles of the application. Any modification, equivalent replacement, improvement, etc. made shall be included in the protection scope of the application.
Claims
1. An intelligent question-answering processing method based on RAG retrieval enhancement, characterized in that, Specifically, the following steps are included: S1, Receiving natural language input from the user; S2. Based on the natural language question, generate an initial search query; S3. Using the initial search query as the search query for the current round, perform multiple rounds of progressive retrieval and verification until a final answer text that meets the reliability requirements is obtained, wherein each round includes: S31. Based on the current round of retrieval query, retrieve multiple candidate text fragments from the target knowledge base and reorder them to obtain the Top-K candidate text fragments in descending order of relevance, where K is an integer greater than 1. S32. Input the natural language problem and the Top-K candidate text fragments obtained in the current round into a pre-trained language model; the pre-trained language model is configured to perform two tasks simultaneously: Task 1: Generate the initial response text for this round; Task 2: Output an overall credibility score that characterizes the reliability of the initial response text; S33. If the overall credibility score is not lower than the preset credibility threshold, the initial answer text of this round will be output as the final answer text, and the process will end. S34. In response to the overall credibility score being lower than the credibility threshold, the current round of retrieval query is reconstructed based on the initial answer text and the Top-K candidate text fragments to generate a new round of retrieval query, and the process returns to step S31.
2. The intelligent question-answering processing method based on RAG retrieval enhancement according to claim 1, characterized in that, S2 includes: inputting the natural language question into a query generation model to generate the initial retrieval query; wherein the query generation model is a sequence-to-sequence model based on the Transformer architecture.
3. The intelligent question-answering processing method based on RAG retrieval enhancement according to claim 1, characterized in that, S31 specifically includes the following sub-steps: S311. Based on the retrieval query, sparse vector retrieval and dense vector retrieval are performed in parallel to obtain a first candidate result set and a second candidate result set; S312. Merge the first candidate result set and the second candidate result set and remove duplicates to form a hybrid result set; S313. Concatenate each candidate text segment in the mixed result set with the retrieval query, input the result into a deep semantic matching model, and obtain the relevance score of each candidate text segment. S314. Sort the candidate text segments in the mixed result set in descending order according to the relevance score, and select the top K as the Top-K candidate text segments.
4. The intelligent question-answering processing method based on RAG retrieval enhancement according to claim 3, characterized in that, The deep semantic matching model in S313 is a model based on the Transformer architecture.
5. The intelligent question-answering processing method based on RAG retrieval enhancement according to claim 1, characterized in that, In step S32, the overall credibility score is calculated through the following sub-steps: S321. Obtain the semantic vector representation of the initial response text, and obtain the semantic vector representation of each candidate text segment; S322. For each candidate text segment, calculate the similarity between its semantic vector representation and the semantic vector representation of the initial response text, and use it as the segment support score for that segment. S323. Based on the relevance scores obtained in step S31 for the Top-K candidate text segments, the support scores of each segment are weighted and fused to obtain the overall credibility score.
6. The intelligent question-answering processing method based on RAG retrieval enhancement according to claim 5, characterized in that, The weighted fusion in S323 is performed as follows: the relevance scores obtained in step S31 are normalized to obtain the weights of each candidate text segment; the weights are then used to perform a weighted summation of the corresponding segment support scores.
7. The intelligent question-answering processing method based on RAG retrieval enhancement according to claim 1, characterized in that, In step S33, while outputting the final answer text, the overall credibility score and at least one candidate text fragment supporting the final answer text are also output as reference sources.
8. The intelligent question-answering processing method based on RAG retrieval enhancement according to claim 1, characterized in that, S34 specifically includes the following sub-steps: S341. For each of the Top-K candidate text segments, calculate its semantic relevance to the initial response text; S342. Identify at least one target text segment whose semantic relevance is lower than a preset relevance threshold; S343. Extract supplementary information from the at least one target text segment that is different from the information already present in the current search query; S344. Expand or modify the current round of search query using the supplementary information to generate a new round of search query.
9. The intelligent question-answering processing method based on RAG retrieval enhancement according to claim 8, characterized in that, In step S341, the semantic relevance is obtained by calculating the cosine similarity between the semantic vector representation of the candidate text fragment and the semantic vector representation of the initial response text.
Citation Information
Cited By
Verifiable text generation method and device
CN122019736A