Error-driven self-correction-based answer generation method, apparatus, equipment, and medium
By segmenting the knowledge base in the financial and insurance field and applying a self-correcting model, the problems of insufficient retrieval accuracy and low error correction efficiency of traditional RAG systems in the financial and insurance field are solved. Self-error assessment and dynamic self-correction are realized, which improves the accuracy of answer generation and the reliability of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- PING AN TECH (SHENZHEN) CO LTD
- Filing Date
- 2026-02-10
- Publication Date
- 2026-05-26
AI Technical Summary
Traditional RAG systems in the financial and insurance sector face problems such as insufficient retrieval accuracy, lack of transparent error tracking and diagnosis mechanisms, and inability to dynamically self-optimize. This leads to factual errors and logical inconsistencies when generating answers, making it difficult to adapt to rapid changes in business needs.
By segmenting the target knowledge base to generate a benchmark dataset, using the RAG model to retrieve and generate preliminary answers, and then inputting them into an error assessment model for classification and evaluation, the system determines whether self-correction is needed based on the evaluation results, and dynamically generates the target answer through a self-correction model to achieve self-error assessment and correction.
The RAG system has achieved self-error assessment and self-correction in the financial and insurance field, which improves the accuracy of answer generation and the reliability of the system, adapts to complex business needs, and requires no manual intervention.
Smart Images

Figure CN122087031A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology and is applied to the financial or smart healthcare fields. In particular, it relates to an error-driven self-correcting answer generation method, apparatus, device, and medium. Background Technology
[0002] Currently, the financial insurance and smart healthcare industries widely adopt the Retrieval-Augmented Generation (RAG) framework to build systems for intelligent customer service, terms and conditions Q&A, and compliance review. This framework typically includes two core modules: a retrieval module that searches for relevant document fragments in a knowledge base, and a generation module that synthesizes natural language responses based on these fragments.
[0003] However, in the highly specialized and dynamic field of finance and insurance, traditional RAG systems face severe challenges. First, insufficient retrieval accuracy can easily lead to misleading generation: there are many semantically similar but logically contradictory expressions between insurance clauses and regulatory provisions. The model can easily retrieve seemingly related but actually contradictory contexts, resulting in factual errors or "semantic drift" in the generated answers. Second, the system lacks a transparent error tracing and diagnosis mechanism: when generating incorrect answers, existing solutions struggle to automatically determine whether the root cause lies in "inaccurate retrieval" or "generation bias," leading to blind and inefficient debugging and optimization efforts. Finally, the system lacks dynamic self-optimization capabilities: error correction typically relies on time-consuming and costly manual annotation and model retraining, failing to achieve closed-loop iteration and rapid response, making it difficult to adapt to the business needs of frequently updated financial policies and complex risk scenarios. Summary of the Invention
[0004] This invention provides an error-driven self-correcting answer generation method, apparatus, device, and medium, aiming to enable the RAG system to self-evaluate and self-correct errors when generating answers, without relying on manual intervention, thereby improving system reliability and long-term evolution capabilities and adapting to complex business needs.
[0005] In a first aspect, embodiments of the present invention provide an answer generation method based on error-driven self-correction, comprising: segmenting documents in a target knowledge base to obtain a benchmark dataset; acquiring data to be answered, and generating preliminary answer data based on the benchmark dataset and the data to be answered using a RAG model; inputting the benchmark dataset and the preliminary answer data into a preset error evaluation model for classification and evaluation processing to obtain a first target error type and a comprehensive score of a first evaluation index, and determining whether self-correction is required based on the comprehensive score of the first evaluation index; if self-correction is required, inputting the benchmark dataset, the preliminary answer data, the first target error type, and the comprehensive score of the first evaluation index into a preset self-correction model to generate a self-correction task; and regenerating the target answer data based on the self-correction task using a RAG model.
[0006] Secondly, embodiments of the present invention also provide an answer generation apparatus based on error-driven self-correction, which includes a unit for performing the above-described method.
[0007] Thirdly, embodiments of the present invention also provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0008] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, can implement the above-described method.
[0009] This application provides an error-driven self-correcting answer generation method, apparatus, device, and medium. Through a closed-loop mechanism of answer generation, error classification, automatic evaluation, autonomous correction, and answer regeneration, it addresses issues such as factual errors, logical inconsistencies, and compliance deviations in traditional RAG systems within professional fields. The system can not only automatically identify different types of errors in generated answers but also dynamically generate self-correction schemes based on feedback from an error evaluation model. This enables the RAG system to self-evaluate and self-correct errors during answer retrieval without relying on manual intervention, improving system reliability and long-term evolution capabilities, and adapting to complex business needs. Attached Figure Description
[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1A schematic flowchart illustrating the error-driven self-correction-based answer generation method provided in this embodiment of the invention; Figure 2 A schematic diagram of a sub-process of the error-driven self-correction-based answer generation method provided in an embodiment of the present invention; Figure 3 A schematic diagram of a sub-process of the error-driven self-correction-based answer generation method provided in an embodiment of the present invention; Figure 4 A schematic diagram of a sub-process of the error-driven self-correction-based answer generation method provided in an embodiment of the present invention; Figure 5 A schematic diagram of a sub-process of the error-driven self-correction-based answer generation method provided in an embodiment of the present invention; Figure 6 A schematic diagram of a sub-process of the error-driven self-correction-based answer generation method provided in an embodiment of the present invention; Figure 7 A schematic block diagram of an error-driven self-correcting answer generation device provided in an embodiment of the present invention; Figure 8 A schematic block diagram of a computer device provided for an embodiment of the present invention. Detailed Implementation
[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0013] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0014] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0015] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0016] Please see Figure 1 This is a schematic flowchart of an error-driven self-correcting answer generation method provided in this invention. In this application, the error-driven self-correcting answer generation method is applied to the natural language processing domain, particularly in the financial and smart healthcare fields. When users use intelligent customer service systems to consult about financial insurance, medical conditions, or other professional knowledge, the system can accurately identify the user's questions and, based on its self-correcting function, generate more accurate answers, ultimately providing customers with precise and reliable responses, significantly improving the accuracy and compliance of intelligent services.
[0017] This application provides an answer generation method, apparatus, computer device, and storage medium based on error-driven self-correction. The answer generation method based on error-driven self-correction includes: segmenting documents in a target knowledge base to obtain a benchmark dataset; acquiring data to be answered and generating preliminary answer data based on the benchmark dataset and the data to be answered using a RAG model; inputting the benchmark dataset and the preliminary answer data into a preset error evaluation model for classification and evaluation to obtain a first target error type and a comprehensive score of a first evaluation index, and determining whether self-correction is needed based on the comprehensive score of the first evaluation index; if self-correction is needed, inputting the benchmark dataset, the preliminary answer data, the first target error type, and the comprehensive score of the first evaluation index into a preset self-correction model to generate a self-correction task; and regenerating the target answer data based on the self-correction task using the RAG model.
[0018] This application addresses the issues of factual errors, logical inconsistencies, and compliance deviations inherent in traditional RAG systems within specialized fields through a closed-loop mechanism encompassing answer generation, error classification, automatic evaluation, autonomous correction, and answer regeneration. The system not only automatically identifies different types of errors in generated answers but also dynamically generates self-correction schemes based on feedback from the error evaluation model. This enables the RAG system to self-evaluate and self-correct errors during answer retrieval without relying on manual intervention, thereby improving system reliability and long-term evolution capabilities, and adapting to complex business needs.
[0019] Figure 1 This is a flowchart illustrating the error-driven self-correction-based answer generation method provided in an embodiment of the present invention. Figure 1 As shown, the method includes the following steps S10-S50.
[0020] S10. Perform fragmentation processing on the documents in the target knowledge base to obtain the benchmark dataset; Specifically, the target knowledge base is a collection of all structured and unstructured documents to be retrieved and queried in the target domain, and the document formats include PDF / Word / HTML, etc.; the target domain can be the medical field, the education field, the financial field, the art field, etc., and is not limited here; in this embodiment, the target domain refers to the financial field, so the target knowledge base includes data such as insurance contract templates, terms and conditions, regulatory documents, and historical Q&A records.
[0021] The segmentation process refers to the process of cutting a long or complex original document into independent text fragments of appropriate size and relatively complete semantics according to preset rules and algorithms. Its purpose is to adapt to the limitations of the input text length imposed by the subsequent retrieval module and improve the granularity and accuracy of the retrieval.
[0022] The benchmark dataset refers to a dataset containing several semantically independent and format-standardized document fragments after being fragmented, which is used for accurate matching and error tracing in the subsequent retrieval module.
[0023] In practice, the system reads each document from the target knowledge base and segments it according to its inherent logical structure and semantic boundaries. Each segment must ensure that it contains a relatively independent and complete unit of information, such as a complete insurance liability clause, a specific description of exclusions, or an independent regulatory requirement. After all documents are segmented, all segmented documents are stored in the benchmark dataset, ultimately forming a benchmark dataset for subsequent retrieval and comparison.
[0024] This embodiment focuses on the core step of "segmenting documents in the target knowledge base to obtain the benchmark dataset", providing standardized basic data support for subsequent error-driven self-correcting knowledge retrieval.
[0025] In one embodiment, reference is made to Figure 2 Step S10 includes steps S11-S14.
[0026] S11. Perform structural identification and preprocessing on each document to generate the first document; S12. The first document is semantically segmented to generate multiple target segments; S13. Determine whether the lengths of the multiple target segments are all within a preset length range; S14. If so, generate a fragment set from the plurality of target fragments, and generate the benchmark dataset from the fragment set of each document.
[0027] Specifically, the first document is a standardized document with a regular format and no information fragmentation after structural preprocessing; the target segment is the initial text unit formed after semantic segmentation; the preset length range refers to the preset length requirement of each target segment, including the maximum length threshold and the minimum length threshold. In this embodiment, it is set to 300-800 tokens to adapt to the subsequent RAG retrieval accuracy requirements; the segment set is a set of semantically complete segments that meet the requirements of a single document, and each segment can be used for vector retrieval, error location, and rule verification.
[0028] In the specific implementation process, the document structure is first identified and preprocessed: the system parses the format marks of the original document (such as PDF, Word) and identifies the hierarchical structure such as chapter titles, clauses, and paragraphs. Then, it performs operations such as unified encoding, removing headers and footers, standardizing terminology, and merging excessively short paragraphs to generate the first document with a neat format and clear logic.
[0029] Next, semantic continuity segmentation is performed: this step determines the segmentation boundaries based on the inherent semantic coherence of the text (rather than physical length). The system uses TextTiling, C99, or sentence vector similarity (SimCSE / BERT) for semantic boundary detection. In this embodiment, the semantic similarity between adjacent text units is calculated based on the sentence vector similarity algorithm. When the similarity is lower than a preset threshold δ, it is determined to be a semantic boundary, and segmentation is performed to generate semantically independent and complete target segments.
[0030] Next, segment length control and verification are performed: to adapt to the optimal processing window of the downstream model, a reasonable length range for the segments is preset. The system checks whether the length of each target segment is within the preset length range. If a target segment exceeds the maximum length threshold, the above semantic segmentation steps are repeated; if a target segment is below the minimum length threshold, it is merged with the semantically adjacent segment. Through this iterative adjustment, it is ensured that the size of all output segments is compliant.
[0031] Finally, the fragment set and benchmark dataset are generated: each target fragment that passes the verification is formally defined as a fragment, and each fragment represents a smallest independently searchable semantic unit (such as a complete clause). Each document includes a fragment set D={d1,d2,...,d...} consisting of multiple target fragment sets. n The collection of fragments from all documents is aggregated to form a structured benchmark dataset, providing authoritative and granular knowledge units for subsequent retrieval, generation, and evaluation.
[0032] In one embodiment, step S12 is followed by step S121.
[0033] S121. Multidimensional embedding is performed on each target fragment to generate an embedding vector, wherein the embedding vector includes context-dependent features, semantic label vectors and keyword features.
[0034] Specifically, the multidimensional embedding refers to the process of extracting multiple types of features for each target segment and converting them into vector form. This process is not a simple single semantic vectorization, but aims to extract and fuse a set of complementary, domain-specific feature representations for each target segment.
[0035] The embedding vector refers to a multi-dimensional vector formed by concatenating context dependency features, semantic tag vectors, and keyword features; the context dependency features are used to capture the deep logic and dependencies of the text fragment in the target domain context (e.g., in the context of finance and insurance); the semantic tag vector is used to explicitly label the domain semantic category of the fragment; and the keyword features aim to highlight the core domain terms in the target fragment.
[0036] In practice, the system inputs the target fragment of each generated document into a multimodal encoder (e.g., a text-image encoder) to obtain the embedding vector. ;in, Represents context-dependent features; Represents a semantic label vector; Indicates keyword features.
[0037] For the context-dependent features, the system inputs the text sequence of the target segment into an encoder based on the Transformer architecture (such as BERT or a similar domain adaptation model). This encoder, through its self-attention mechanism, models the contextual relationships between lexical units within the segment and (where necessary) across segments, thereby outputting a dense vector representing the context-dependent features. These context-dependent features encode complex semantic information such as conditional references between clauses, time-series constraints, and numerical logical relationships. For example: the logic between clause entries (payment conditions → liability exemption), time dependence ("effective after a 90-day waiting period"), and numerical / constraint relationships. The specific method for obtaining the context-dependent features is as follows: .
[0038] To generate the semantic label vector, a semantic annotation head (usually a classification layer) is added on top of a language model pre-trained on a large-scale target domain corpus. This annotation head is supervisedly trained using labeled fragment samples (the sample label system includes predefined domain categories such as "liability exclusion clauses," "surcharge rules," "product descriptions," and "high-risk warnings"), enabling the language model to output the semantic category embedding for any input fragment. The final semantic label vector is a low-dimensional representation that incorporates multi-class probability distribution information.
[0039] For keyword feature generation: The system employs keyword extraction techniques based on statistics (such as TF-IDF) or graph algorithms (such as TextRank) to automatically extract the most representative and discriminative keywords from the target text segment. Subsequently, these keywords are mapped to fixed-dimensional vectors through an embedding layer and aggregated into a comprehensive keyword feature vector through pooling operations (such as average pooling).
[0040] Ultimately, the three feature vectors are concatenated or fused through a specific network layer to form a multidimensional embedding vector for the target fragment. All fragment embedding vectors are stored in a vector database (such as Milvus or Faiss) to form an index, providing a core data foundation for subsequent accurate semantic retrieval and semantic comparison and feature analysis in the error detection stage.
[0041] Therefore, this embodiment introduces multi-layer features (context + semantics + keywords) of document embedding vectors into the error detection and correction process, thereby improving the detection and self-correction accuracy.
[0042] S20. Obtain the data to be answered, and generate preliminary answer data based on the RAG model by retrieving the benchmark dataset and the data to be answered.
[0043] Specifically, the data to be answered is the natural language question text or instruction posed by the user, such as an inquiry about insurance terms. The RAG model refers to a knowledge-enhanced generative model pre-installed within the system, integrating the retrieval and generation modules. The preliminary answer data refers to the answer data output by the RAG model for the data to be answered, specifically including two core types of content: first, relevant fragments retrieved by the retrieval module from the benchmark dataset; and second, natural language text generated by the generation module based on the retrieved fragments.
[0044] In the specific implementation process, the system first receives questions from users in the form of natural language. These questions are defined as data to be answered and the data to be answered is then input into the RAG model.
[0045] The RAG model first calls the retrieval module, which inputs the data to be answered into a pre-trained query encoder. This encoder shares the structure or parameters with the text encoding model used when constructing the embedding features of the benchmark dataset. Its function is to convert the text sequence of the data to be answered into a high-dimensional distributed semantic representation, thereby outputting the query semantic embedding vector of the data to be answered. This facilitates the retrieval module to perform retrieval in the benchmark dataset based on the embedding vector of the data to be answered.
[0046] In the retrieval process, the model locates the most relevant knowledge context from the benchmark dataset. The retrieval process includes a semantic retrieval phase and a context reordering phase: In the semantic retrieval phase (also known as the recall phase), the system calculates the cosine similarity between the embedding vector of the data to be answered and the pre-generated multidimensional embedding vectors of all segments in the benchmark dataset. Using an efficient vector indexing and approximate nearest neighbor search algorithm, the system quickly recalls the top K candidate knowledge segments most similar to the data to be answered, forming a preliminary candidate segment set. The core objective of this step is to ensure a high recall rate, ensuring that segments containing the correct answer are included as much as possible.
[0047] The context reordering stage (also known as the fine-tuning stage) introduces a more computationally complex but more accurate cross-encoder (e.g., a text pair classification model based on the Transformer architecture). This model concatenates the user-inputted text of the data to be solved with each preliminary candidate fragment text as a whole input. Through a deep bidirectional attention mechanism, it performs interactive modeling, outputting a reordering score that accurately reflects the relevance between the two. The system sorts the preliminary candidate fragment set in descending order based on this score, typically selecting the top N (N≤K) fragments to form the final fine-tuned context fragment set d. The purpose of this context reordering is to significantly improve the ranking of the most relevant fragments in the result list, optimizing the quality of the context upon which subsequent generation depends.
[0048] After the retrieval is complete, the RAG model enters the answer generation stage. The user-inputted data to be answered, along with a set of finely ranked context fragments, is input into a pre-trained large language model (i.e., the generation module). This model uses the aforementioned N retrieved fragments as the factual basis and contextual constraints for generation, comprehensively understands the question's intent, integrates and organizes relevant information, and finally synthesizes a natural language text y that directly and accurately answers the user's question. This natural language text and the set of finely ranked context fragments upon which its generation depends together constitute the initial answer data output by the system. This data is not only a direct response to the user, but all intermediate products in its generation process (such as the original similarity of each candidate fragment, the re-ranking score, and the final context used) are also completely retained by the system as key inputs for quantitative analysis and problem tracing in subsequent error detection and self-correction processes.
[0049] This embodiment generates preliminary answer data based on the RAG model, laying the foundation for subsequent error self-correction and question answering.
[0050] S30. Input the benchmark dataset and the preliminary answer data into the preset error assessment model for classification and assessment processing to obtain the first target error type and the first assessment index comprehensive score, and determine whether self-correction is needed based on the first assessment index comprehensive score.
[0051] In this embodiment, the error assessment model refers to a pre-trained model used to identify whether the preliminary answer data is incorrect, and it has error classification and quantitative assessment functions; the first target error type refers to the error category (such as semantic drift, citation error, etc.) to which the preliminary answer data belongs as determined by the error assessment model; the first evaluation index comprehensive score refers to the comprehensive score after the model quantifies the error degree, relevance and other indicators of the preliminary answer data; the self-correction refers to the optimization process of the system automatically correcting the wrong answers.
[0052] In the specific implementation process, the benchmark dataset and the preliminary answer data are input into the error assessment model. The model, based on its internal classification rules, performs error classification processing on the preliminary answer data according to the benchmark dataset to output the error type corresponding to the preliminary answer data, i.e., the first target error type. The model then performs multi-indicator quantitative evaluation on the preliminary answer data based on its internal evaluation rules to output a comprehensive score for the first evaluation indicator. The first target error type and the comprehensive score for the first evaluation indicator lay the foundation for the initiation judgment and self-correction direction of the subsequent self-correction process.
[0053] Finally, based on the preset judgment rules and the comprehensive score of the first evaluation index, it is determined whether self-correction is required. If self-correction is required, the self-correction process is initiated; if self-correction is not required, the preliminary answer data is sent to the client for user reference.
[0054] This embodiment drives the self-correction process by calculating a comprehensive score based on the error type and indicators of the preliminary answer data, realizing a closed loop of online self-assessment and self-correction of RAG: it can automatically discover, classify and correct errors without human intervention, realizing a truly "self-evolving RAG system".
[0055] In one embodiment, such as Figure 3 As shown, step S30 may include steps S31-S34.
[0056] S31. Based on preset classification rules, calculate the error probability of each error type according to the benchmark dataset and the preliminary answer data. The error types include factual deviation, semantic offset, logical contradiction, compliance risk, and omission of reference. S32. Select the first target error type according to the preset selection rules and the error probabilities; S33. Based on the preset evaluation rules, calculate each evaluation index according to the benchmark dataset and the preliminary answer data. The evaluation index includes keyword deviation rate, semantic similarity and logical consistency score. S34. Calculate the comprehensive score of the first evaluation indicator based on each evaluation indicator.
[0057] Specifically, the preset classification rules refer to the pre-set judgment criteria and calculation logic used to determine the error type; the error types include factual deviation (E1: the cited information does not match the actual terms), semantic deviation (E2: the generated content does not match the semantics of the input document), logical contradiction (E3: the conclusion is inconsistent with the premise), compliance risk (E4: violation of financial regulatory requirements or terminology standards), and omission of citation (E5: failure to cite the required key terms).
[0058] The error probability refers to the quantitative value of the likelihood of various errors appearing in the preliminary answer data. The higher the error probability corresponding to the error type, the greater the likelihood that the preliminary answer data belongs to that error type.
[0059] The preset selection rule refers to the logic used to filter and determine the final output error type from the calculated error probabilities, such as "selecting all error types with probabilities exceeding a threshold θ" or "selecting only the error type with the highest error probability." In this embodiment, the selection rule is to select the error type with the highest error probability as the first target error type. The first target error type refers to the core error category selected from all error types.
[0060] The preset evaluation rules refer to the pre-defined algorithms, formulas, and calculation processes used to calculate various quantitative evaluation indicators; the evaluation indicators include keyword deviation rate, semantic similarity, and logical consistency score. The keyword deviation rate refers to the proportion of mismatch between the generated answer text (i.e., the natural language text y generated by the generation module of the aforementioned RAG model) and the reference context text (i.e., the finely ranked context fragment set d retrieved by the retrieval module of the aforementioned RAG module) in the set of key domain terms. It is used to measure the coverage and accuracy of core terms, and the larger the value, the lower the keyword consistency between the two.
[0061] The semantic similarity is achieved by using a semantic embedding model to represent the generated answer text (i.e., the natural language text y generated by the generation module of the aforementioned RAG model) and the reference context text (i.e., the finely ranked context fragment set d retrieved by the retrieval module of the aforementioned RAG module) as high-dimensional vectors respectively, and calculating the cosine similarity value between the two vectors to measure the closeness of the two at the overall semantic level. The larger the value, the higher the semantic consistency between the two.
[0062] The logical consistency score refers to a quantitative score given for the logical coherence and reasonableness of the generated answer text relative to its reference context text, through a combination of natural language reasoning (NLI) model and rule verification.
[0063] The first evaluation indicator's comprehensive score refers to the quantitative evaluation result obtained by integrating the scores of each evaluation indicator.
[0064] In the specific implementation process, the error assessment model calls the preset classification rules, takes the standard text and embedding vector of the benchmark dataset as a reference, compares and analyzes the accuracy of the retrieved fragments (i.e. reference context text) in the preliminary answer data, the semantic fit between the generated answer text and the standard text, and calculates the error probability of five types of errors: factual deviation, semantic offset, logical contradiction, compliance risk and omission of reference.
[0065] Next, based on preset selection rules, the core error category is selected from five error types as the first target error type. Simultaneously, the model invokes preset evaluation rules to calculate the specific scores for three evaluation indicators—keyword deviation rate, semantic similarity, and logical consistency score—based on the benchmark dataset and the preliminary answer data. Then, the scores of the three indicators are weighted and summed according to preset weights to obtain the comprehensive score of the first evaluation indicator, thus completing the full classification and quantitative evaluation of the preliminary answer data.
[0066] This embodiment designs an error type classification and a first evaluation index comprehensive score that integrates multiple indicators. It realizes quantitative analysis from three dimensions: lexical deviation, semantic similarity, and logical consistency to determine whether the preliminary answer is wrong, thereby improving the accuracy of judgment and further improving the accuracy of self-correction.
[0067] Furthermore, the error assessment model is a multi-class classification model.
[0068] Furthermore, the step of calculating the error probability of each error type based on the benchmark dataset and the preliminary answer data according to the preset classification rules includes: The formula for calculating the error probability is: ; Among them, input ={Generated text y, Retrieval fragment d, Embedding vector v}, where the generated text y is the natural language text y generated by the generation module of the aforementioned RAG model, the retrieval fragment d is the set of finely ranked context fragments d retrieved by the retrieval module of the aforementioned RAG module, and the embedding vector v is the embedding vector corresponding to the retrieval fragment d in the benchmark dataset. The original score logit output by the error assessment model for "error type k"; It is the raw score logit output by the error evaluation model for each possible error type (including the k-th class and all other classes), where the denominator contains... It is an exponential logit summation of all categories to achieve probability normalization.
[0069] Furthermore, the step of calculating various evaluation indicators based on the benchmark dataset and the preliminary answer data according to preset evaluation rules, wherein the evaluation indicators include keyword deviation rate, semantic similarity, and logical consistency score, includes: Calculate the keyword deviation rate The formula is: , in, The set of key terms for the preliminary answer data. The set of key terms for the reference segment in the benchmark dataset; Calculate the semantic similarity The formula is: , in, The semantic vector of the preliminary answer data. The semantic vector of the reference segment in the benchmark dataset; Calculate the logical consistency The formula is: , in, for , The premise facts of the reference segment in the benchmark dataset, This is a conclusion drawn from the preliminary answer data; To combine the Boolean value output by the logic verification, ∈{0,1}.
[0070] Furthermore, the step of calculating the comprehensive score of the evaluation indicators based on each evaluation indicator includes: Calculate the comprehensive score of the evaluation indicators. The formula is: ; in, , , These are configurable weighting parameters used to balance the importance of different quality dimensions; the comprehensive score of the evaluation index satisfies: ∈[0,1], and The higher the value, the higher the overall quality of the generated preliminary answer data.
[0071] More specifically, the step of determining whether self-correction is needed based on the comprehensive score of the first evaluation index includes: Determine whether the comprehensive score of the first evaluation indicator is lower than the preset threshold τ; If the comprehensive score of the first evaluation index is lower than the preset threshold τ, then the self-correction process is initiated; If the overall score of the first evaluation index is higher than the preset threshold τ, then there is no need to start the self-correction process.
[0072] Specifically, the system presets a quality threshold τ to determine whether the generated answer data meets the reliability and compliance requirements of the target domain scenario. When When the value is greater than or equal to τ, the generated preliminary answer data is considered to be of acceptable quality and can be directly output or entered into subsequent business processes. when When the value is less than τ, the system determines that the generated preliminary answer data is insufficient in terms of keyword consistency, semantic similarity, or logical consistency, and automatically enters the self-correction process to correct and regenerate the generation process.
[0073] S40. If self-correction is required, the benchmark dataset, the preliminary answer data, the first target error type, and the comprehensive score of the first evaluation index are input into the preset self-correction model to generate a self-correction task.
[0074] Specifically, the self-correction model is an intelligent agent or sequence generation model with planning capabilities, specifically designed for error correction decision-making. It is pre-trained and can call upon a Large Language Model (LLM) to generate correction scheme code. The self-correction task refers to a structured set of task instructions containing error correction guidelines and corresponding correction scheme code; the correction scheme code C... k This refers to executable code used to implement error correction (such as dynamically updating search weights, replacing referenced documents, etc.).
[0075] In the specific implementation process, after the preliminary answer data is determined to need self-correction based on the aforementioned evaluation, the benchmark dataset, the preliminary answer data, the first target error type, and the comprehensive score of the first evaluation index are input into the preset self-correction model. The self-correction model outputs a structured self-correction task, providing clear and accurate task guidance and executable code support for the subsequent automatic error correction operation of the system.
[0076] In one embodiment, such as Figure 4 As shown, step S40 may include steps S41-S43.
[0077] S41. Generate a self-correction prompt based on the first target error type; S42. Reselect retrieval information based on the self-correction prompt and the benchmark dataset; S43. Based on the preset error type mapping rule table, generate the self-correction task according to the first target error type, the first evaluation index comprehensive score and the retrieval information.
[0078] Specifically, the self-correction prompt refers to the prompt information generated by the LLM to guide error correction. It is related to the first target error type, such as a clear instruction "Please reorganize your answer based on the following key clauses, with priority given to: liability exemption clause (fragment d)". 12 This transforms the abstract "error type" into a concrete, actionable text instruction.
[0079] The retrieved information refers to relevant text fragments selected from the benchmark dataset for error correction.
[0080] The preset error type mapping rule table refers to the pre-defined correspondence table between error types and self-correction strategies. For example: E1: Fact deviation type → increase search weight and reselect fragments; E2: Semantic offset type → modify the Prompt to make the LLM closer to the semantics; E3: Logical contradiction type → perform logical alignment constraints; E4: Compliance risk type → force the use of compliance templates; E5: Reference omission type → add related clause search nodes.
[0081] In the specific implementation process, the first target error type, the preliminary answer data text of the problem, and the corresponding fragments from the key benchmark dataset corresponding to set d obtained in the previous context rearrangement stage, along with relevant quantitative evaluation indicators, are input into a large language model (LLM). Based on a deep understanding of the nature of the error, the model automatically generates a structured self-correcting prompt with clear instructions.
[0082] The self-correcting suggestions generated in the previous step are used as new query guides to retrieve the benchmark dataset again. Unlike the initial retrieval, this retrieval process is strongly constrained by the self-correcting suggestions, for example, by enhancing key segments explicitly indicated in the suggestions (such as d). 12 The retrieval weights of the error types are adjusted, or semantic constraints of error types are incorporated into the vector similarity calculation, thereby re-filtering and reordering the retrieval information (a new or reordered set of document fragments) most relevant to the correction target. This step aims to provide accurate and reliable knowledge context directly for subsequent correction.
[0083] Finally, the system generates the final self-correction task based on the preset error type mapping rule table. This rule table is a predefined set of strategy mappings, which specifies a particular correction strategy code template for each first target error type. The system searches the table based on the first target error type to determine the corresponding self-correction strategy. Then, it combines and instantiates this self-correction strategy with the retrieved information, the first target error type, and the comprehensive score of the first evaluation index, automatically assembling it into a self-correction task instruction that can be scheduled and executed by the system, containing specific operations and parameters. This completes the entire process from error diagnosis to correction planning, providing precise guidance for subsequent error correction execution.
[0084] More specifically, the self-calibration task instruction is a task code. The code structure follows: ; Where g is the generating function, The first target error type; For re-retrieval of search information; The overall score is the first evaluation indicator.
[0085] S50. Based on the RAG model, regenerate the target answer data according to the self-correction task.
[0086] Specifically, the system acquires the structured self-calibration task code generated by the self-calibration module. The code is parsed and executed by the system's task scheduling engine. Its core is to dynamically adjust the internal parameters and logic of the original RAG workflow. Subsequently, the system re-invokes the complete RAG pipeline with the adjusted parameters. This means that the system uses the same unanswered data from the original user query, but in the corrected code... In the modified internal environment, the entire process of semantic retrieval, context rearrangement, and answer generation is re-executed. Because the retrieval strategy and generation instructions have been specifically optimized, the set of context fragments obtained from this retrieval will be more accurate, and the constraints of the instructions received by the generation module will be more explicit. Finally, based on this optimized context and instructions, the generation module synthesizes and outputs a new natural language answer, which is the target answer data, referring to the final response data that meets the standards after correction.
[0087] This process achieves an automated closed loop from error identification to parameter adjustment and answer regeneration. It can automatically discover, classify and correct errors without human intervention, realizing a true "self-evolving RAG system".
[0088] In one embodiment, such as Figure 5 As shown, steps S50 may be followed by steps S51-S53.
[0089] S51. Input the target answer data into the error assessment model for classification and assessment processing to obtain the second target error type and the comprehensive score of the second assessment indicator, and determine whether self-correction is needed based on the comprehensive score of the second assessment indicator; S52. If self-correction is required, the benchmark dataset, the target answer data, the second target error type, and the comprehensive score of the second evaluation index are input into the preset self-correction model to generate the second self-correction task. S53. If self-correction is not required, output the target answer data.
[0090] Specifically, the second target error type refers to the core error category to which the target answer data belongs, as determined by the error assessment model. The second evaluation index comprehensive score refers to the comprehensive score after the model quantifies the error degree, relevance, and other indicators of the target answer data. The second self-correction task refers to a new set of structured correction task instructions generated in response to errors in the target answer data.
[0091] In the specific implementation process, after the system completes the generation of the target answer data, it will initiate a self-looping verification process to ensure continuous optimization. The system first uses this target answer data as a new evaluation object and inputs it into a preset error evaluation model. This model uses the same working mechanism as the initial answer data evaluation to classify and quantify it.
[0092] Specifically, the model analyzes the target answer data based on the benchmark dataset, calculates the probability of it belonging to each error type, and determines the main error type identified in this evaluation, i.e., the second target error type, according to preset selection rules. Simultaneously, the model calculates multiple indicators, including keyword deviation rate, semantic similarity, and logical consistency score, and weights and sums them to obtain a comprehensive score for the second evaluation indicator.
[0093] Subsequently, the system determines whether a new round of self-correction needs to be initiated based on the comprehensive score of the second evaluation indicator. This judgment logic is consistent with the initial judgment, that is, it is achieved by comparing the comprehensive score of the second evaluation indicator with a preset quality threshold τ: if the comprehensive score of the second evaluation indicator is still below the acceptable range (i.e., the comprehensive score of the second evaluation indicator is below the threshold τ), then it is determined that self-correction is required; otherwise, it is determined that the quality of the target answer data has met the standard.
[0094] If self-correction is deemed necessary, the system proceeds to the next correction iteration. The baseline dataset, the target answer data, the second target error type, and the comprehensive score of the second evaluation index are used as input and submitted again to the preset self-correction model. Based on the new error diagnosis information, this model generates a more targeted second self-correction task, thereby driving the system to perform a new round of parameter adjustments and answer regeneration, forming a continuously iterative optimization loop.
[0095] If it is determined that no self-correction is needed, that is, if the comprehensive score of the second evaluation index is higher than the preset threshold τ, the system will terminate the self-evolution cycle and finally deliver the target answer data generated in the current round as a qualified output result.
[0096] This embodiment utilizes reinforcement learning and the error feedback (RAG) model to enable the system to continuously improve retrieval quality and generation reliability through multiple iterations.
[0097] Furthermore, each error detection and repair generates an auditable log, meeting financial compliance and risk control requirements and improving the system's traceability and interpretability.
[0098] In one embodiment, such as Figure 6 As shown, steps S53 may be followed by steps S531-S532.
[0099] S531. Input the target answer data into a preset verification model for dual verification of logical consistency and compliance; S532. If both logical consistency and compliance are passed, the target answer data is output to the client.
[0100] Specifically, the preset verification model refers to a verification model that integrates a symbolic logic reasoning module and a compliance rule base in the target domain, used to achieve dual verification of logical consistency and compliance; logical consistency verification refers to the verification process of detecting whether there are contradictions between text propositions through symbolic logic reasoning; compliance verification refers to the process of verifying the standardization of texts according to the industry compliance requirements of the target domain.
[0101] In the specific implementation process, after determining that no further self-correction is needed, the system performs a final quality verification on the target answer data.
[0102] The pre-defined verification model first performs a logical consistency verification: this module transforms the text of the target answer data and its underlying context fragments (i.e., retrieval information) into a set of formalized logical propositions P={p1,p2,...,p...} through semantic parsing. m}. Subsequently, the symbolic logic reasoning engine performs a consistency check on all propositions in the set, the core of which is to verify whether any pair of propositions (p) exists. i ,p j ) satisfies p i ⇒¬p j The system identifies logical contradictions. If such logical conflicts are detected, the verification fails, and the system will mark the target answer data as having a logical inconsistency.
[0103] Simultaneously, the preset verification model performs compliance verification in parallel. This module accesses a compliance rule knowledge base for the target domain, which consists of a series of text pattern matching rules based on regular expressions and structured rule templates. The system uses these rules to scan the target answer data, checking for any non-compliant expressions, such as: whether there are any absolute promises prohibited by regulations, whether the description of benefits is accompanied by necessary risk warning statements, and whether the cited calculation formulas or data disclosure formats comply with regulatory requirements. If the target answer data triggers a match for any compliance rule, the verification fails.
[0104] The system determines that the target answer data possesses verifiable consistency and compliance only when both of the above logical consistency and compliance verifications are passed (i.e., both are displayed as "passed"), and outputs it as the final valid result to the client. If either verification fails, the system will not output the answer and will trigger an alarm or initiate a new correction process according to the configured policy.
[0105] This embodiment integrates logical verification with rule-based knowledge to ensure that the generated target answer data is reliable, interpretable, and compliant with regulations, significantly reducing factual and compliance error rates and adapting to high-precision scenarios such as the financial and insurance sectors.
[0106] This application addresses the issues of factual errors, logical inconsistencies, and compliance deviations inherent in traditional RAG systems within the financial and insurance sectors through a closed-loop mechanism: answer generation → error classification and automatic evaluation → autonomous correction → answer regeneration. The system not only automatically identifies different types of errors in the generated answers but also dynamically generates self-correction schemes based on feedback from the error evaluation model. This enables the RAG system to self-evaluate and self-correct errors during answer retrieval without manual intervention, improving system reliability and long-term evolution capabilities, adapting to complex business needs, and ultimately ensuring the credibility and compliance of the results through symbolic logic reasoning and domain rule verification.
[0107] Figure 7 This is a schematic block diagram of an error-driven self-correcting answer generation device 300 provided in an embodiment of the present invention. Figure 7 As shown, corresponding to the above-described error-driven self-correcting answer generation method, the present invention also provides an error-driven self-correcting answer generation apparatus 300. This error-driven self-correcting answer generation apparatus 300 includes a unit for executing the above-described error-driven self-correcting answer generation method, and the apparatus can be configured in a computer device. Specifically, please refer to... Figure 7 The error-driven self-correcting answer generation device 300 includes a processing unit 301, a first generation unit 302, an evaluation unit 303, a correction unit 304, and a second generation unit 305.
[0108] Processing unit 301 is used to segment documents in the target knowledge base to obtain a benchmark dataset; The first generation unit 302 is used to acquire the data to be answered and generate preliminary answer data based on the benchmark dataset and the data to be answered according to the RAG model. The first evaluation unit 303 is used to input the benchmark dataset and the preliminary answer data into a preset error evaluation model for classification and evaluation processing to obtain a first target error type and a comprehensive score of the first evaluation index, and to determine whether self-correction is needed based on the comprehensive score of the first evaluation index. The first correction unit 304 is used to input the benchmark dataset, the preliminary answer data, the first target error type and the comprehensive score of the first evaluation index into a preset self-correction model to generate a self-correction task if self-correction is required. The second generation unit 305 is used to regenerate the target answer data based on the RAG model according to the self-correction task.
[0109] In one embodiment, the first evaluation unit 303 includes a calculation unit.
[0110] The calculation unit is used to calculate the error probability of each error type based on the benchmark dataset and the preliminary answer data according to preset classification rules. The error types include factual deviation, semantic offset, logical contradiction, compliance risk, and citation omission. The unit selects the first target error type according to preset selection rules and each error probability. The unit calculates each evaluation index based on the benchmark dataset and the preliminary answer data according to preset evaluation rules. The evaluation index includes keyword deviation rate, semantic similarity, and logical consistency score. The unit calculates the comprehensive score of the first evaluation index based on each evaluation index.
[0111] In one embodiment, the error-driven self-correcting answer generation device 300 further includes a second evaluation unit, a second correction unit, and an output unit.
[0112] The second evaluation unit is used to input the target answer data into the error evaluation model for classification and evaluation processing to obtain the second target error type and the comprehensive score of the second evaluation index, and to determine whether self-correction is needed based on the comprehensive score of the second evaluation index. The second correction unit is used to input the benchmark dataset, the target answer data, the second target error type, and the comprehensive score of the second evaluation index into a preset self-correction model to generate a second self-correction task if self-correction is required. An output unit is used to output the target answer data if self-correction is not required.
[0113] In one embodiment, the error-driven self-correcting answer generation device 300 further includes a verification unit.
[0114] The verification unit is used to input the target answer data into a preset verification model for dual verification of logical consistency and compliance; if both logical consistency and compliance are passed, the target answer data is output to the client.
[0115] In one embodiment, the first correction unit 304 includes a third generation unit, a selection unit, and a fourth generation unit.
[0116] The third generation unit is used to generate a self-correction prompt based on the first target error type; The selection unit is used to reselect retrieval information based on the self-correction prompts and the benchmark dataset; The fourth generation unit is used to generate the self-correction task based on the first target error type and the retrieval information according to a preset error type mapping rule table.
[0117] In one embodiment, the processing unit 301 includes a preprocessing unit, a segmentation unit, a judgment unit, and a fifth generation unit.
[0118] The preprocessing unit is used to perform structural identification and preprocessing on each document to generate the first document; The segmentation unit is used to semantically segment the first document to generate multiple target fragments; A judgment unit is used to determine whether the lengths of the plurality of target segments are all within a preset length range; The fifth generation unit is configured to generate a set of fragments from the plurality of target fragments if the condition is met, and to generate the benchmark dataset from the set of fragments from each document.
[0119] In one embodiment, the segmentation unit includes an embedding unit.
[0120] An embedding unit is used to perform multi-dimensional embedding of each target fragment to generate an embedding vector, which includes context-dependent features, semantic label vectors, and keyword features.
[0121] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned error-driven self-correcting answer generation device and its various units can be referred to the corresponding descriptions in the foregoing method embodiments. For the sake of convenience and brevity, these details will not be repeated here.
[0122] The aforementioned error-driven self-correcting answer generation device 300 can be implemented as a computer program, which can, for example... Figure 8 It runs on the computer device shown.
[0123] Please see Figure 8 , Figure 8 This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 500 can be a terminal or a server. The terminal can be an electronic device with communication functions, such as a smartphone, tablet, laptop, desktop computer, personal digital assistant, or wearable device. The server can be a standalone server or a server cluster composed of multiple servers.
[0124] See Figure 8 The computer device 500 includes a processor 502, a memory, and a network interface 505 connected via a system bus 501. The memory may include a non-volatile storage medium 503 and internal memory 504.
[0125] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions that, when executed, cause the processor 502 to perform an error-driven self-correcting answer generation method.
[0126] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.
[0127] The internal memory 504 provides an environment for the execution of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute an error-driven self-correcting answer generation method.
[0128] This network interface 505 is used for network communication with other devices. Those skilled in the art will understand that... Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 500 to which the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0129] The processor 502 is used to run the computer program 5032 stored in the memory to implement the steps of the above-described error-driven self-correction-based answer generation method.
[0130] It should be understood that in the embodiments of this application, the processor 502 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0131] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0132] Therefore, the present invention also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When executed by a processor, the program instructions cause the processor to perform the steps of the above-described error-driven self-correction-based answer generation method.
[0133] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0134] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0135] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0136] The steps in the method of this invention can be adjusted, merged, or reduced in order according to actual needs. The units in the device of this invention can be merged, divided, or reduced according to actual needs. Furthermore, the functional units in the various embodiments of this invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0137] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0138] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. An answer generation method based on error-driven self-correction, characterized in that, The method includes: The documents in the target knowledge base are segmented to obtain a benchmark dataset; Obtain the data to be answered, and generate preliminary answer data based on the benchmark dataset and the data to be answered; The benchmark dataset and the preliminary answer data are input into a preset error assessment model for classification and assessment to obtain a first target error type and a comprehensive score of the first assessment index, and it is determined whether self-correction is needed based on the comprehensive score of the first assessment index. If self-correction is required, the benchmark dataset, the preliminary answer data, the first target error type, and the comprehensive score of the first evaluation index are input into the preset self-correction model to generate a self-correction task. Target answer data is generated based on the self-correction task.
2. The method according to claim 1, characterized in that, The step of inputting the benchmark dataset and the preliminary answer data into a preset error assessment model for classification and evaluation to obtain a comprehensive score for the first target error type and the first evaluation index includes: Based on preset classification rules, the error probability of each error type is calculated according to the benchmark dataset and the preliminary answer data. The error types include factual deviation, semantic offset, logical contradiction, compliance risk, and omission of reference. The first target error type is selected according to preset selection rules and various error probabilities; Based on preset evaluation rules, various evaluation indicators are calculated according to the benchmark dataset and the preliminary answer data. The evaluation indicators include keyword deviation rate, semantic similarity, and logical consistency score. Calculate the comprehensive score of the first evaluation indicator based on each evaluation indicator.
3. The method according to claim 2, characterized in that, The step of regenerating the target answer data based on the self-correction task includes: The target answer data is input into the error assessment model for classification and assessment to obtain a second target error type and a comprehensive score of the second assessment indicator. Based on the comprehensive score of the second assessment indicator, it is determined whether self-correction is required. If self-correction is required, the benchmark dataset, the target answer data, the second target error type, and the comprehensive score of the second evaluation index are input into the preset self-correction model to generate the second self-correction task; If self-correction is not required, output the target answer data.
4. The method according to claim 3, characterized in that, The step of outputting the target answer data if self-correction is not required includes: The target answer data is input into a preset verification model for dual verification of logical consistency and compliance; If both logical consistency and compliance are passed, the target answer data will be output to the client.
5. The method according to claim 1, characterized in that, The step of inputting the benchmark dataset, the preliminary answer data, the first target error type, and the comprehensive score of the first evaluation index into a preset self-correction model to generate a self-correction task if self-correction is required includes: Generate a self-correction prompt based on the first target error type; Reselect retrieval information based on the self-correction prompts and the benchmark dataset; The self-correction task is generated based on the first target error type and the retrieval information according to the preset error type mapping rule table.
6. The method according to claim 1, characterized in that, The steps of segmenting documents in the target knowledge base to obtain the benchmark dataset include: Each document undergoes structural identification and preprocessing to generate the first document; The first document is semantically segmented to generate multiple target fragments; Determine whether the lengths of the multiple target segments are all within a preset length range; If so, the multiple target fragments are used to generate a fragment set, and the fragment set of each document is used to generate the benchmark dataset.
7. The method according to claim 6, characterized in that, The step of semantically segmenting the first document to generate multiple target fragments includes: Each target fragment is embedded in multiple dimensions to generate an embedding vector, which includes context-dependent features, semantic label vectors, and keyword features.
8. An answer generation device based on error-driven self-correction, characterized in that, Includes a unit for performing the method as described in any one of claims 1-7.
9. A computer device, characterized in that, The computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-7.
10. A storage medium, characterized in that, The storage medium stores a computer program, which includes program instructions that, when executed by a processor, can implement the method as described in any one of claims 1-7.