A language model self-correction method and device
By constructing a directed graph of error propagation and a reflection-action error correction framework, the problem of causal dependence not being considered in automatic error correction methods for language models is solved, achieving an efficient and reliable error correction process applicable to various text generation tasks.
Patent Information
- Application Number
- CN202611213734.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-11
- Publication Date
- 2026-11-27
AI Technical Summary
Existing automatic error correction methods for language models fail to effectively consider the causal dependencies and propagation relationships between errors, resulting in low reliability of error correction results and overcorrection issues.
By performing multimodal error detection on the text output by the language model, constructing a directed graph of error propagation, calculating the importance score of error nodes, determining the error correction priority by combining topological sorting, adopting a reflection-action two-stage error correction framework, conducting root cause analysis and round-by-round targeted correction, and using Markov chains to determine the convergence of the error correction process.
It improves the accuracy and reliability of language model error correction, reduces the overcorrection rate, and is suitable for automatic error correction tasks in various scenarios such as machine translation, text summarization, and code generation. It also improves the error correction F1 score and reduces the number of iterations.
Smart Images

Figure CN123180128A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to a method and apparatus for self-correction of language models. Background Technology
[0002] With the rapid development of large language model technology, the text generation capabilities based on pre-trained language models have been significantly improved. However, even the most advanced large language models can still produce errors in areas such as domain-specific terminology translation, consistency of long text summarization, and code logic correctness.
[0003] Existing automatic error correction methods for language models include rule-based post-editing methods, neural network-based automatic post-editing methods, prompt-based large language model self-correction methods, and case retrieval-based error correction methods. However, existing automatic error correction methods treat each error as an independent entity, failing to consider causal dependencies and propagation relationships between errors, resulting in low reliability of correction results. Furthermore, these methods directly correct errors based on error labels, lacking in-depth analysis of error root causes and exhibiting overcorrection problems. Therefore, overcoming the limitations of isolated error correction in existing automatic error correction methods, achieving deep error correction, and avoiding overcorrection are pressing technical problems that need to be solved by those skilled in the art. Summary of the Invention
[0004] This invention provides a language model self-correction method and apparatus to solve the technical problems of isolated error correction, difficulty in deep correction, and overcorrection in existing language model automatic error correction methods.
[0005] In view of this, the first aspect of the present invention provides a language model self-correction method, comprising: S1. Perform multimodal error detection on the recognized text output by the language model and generate a set of structured error tags; S2. Based on the structured error tag set, construct a directed error propagation graph based on the causal dependencies between errors; S3. Calculate the importance score of each error node in the error propagation directed graph, and determine the error correction priority sequence by combining topological sorting; S4. Construct a meta-reasoning hint template containing structured information of the directed graph of error propagation. Take the error node, directed edge weight and propagation probability matrix as structured input, obtain the root cause analysis results of the meta-reasoning hint template, and generate an error reflection report. The error reflection report contains correction strategies. S5. Based on the error reflection report, the correction strategy and error correction priority sequence are used to construct a round-by-round error correction prompt, and the errors are corrected in a targeted manner in order of error correction priority from high to low. S6. After each round of correction is completed, check whether the correction has introduced new errors. If so, perform a partial rollback to restore the state before the correction, adopt the alternative correction strategy, and return to step S5. If not, proceed to step S7. S7. Model the error correction process as a discrete-time Markov chain. Use the absorption state property of the Markov chain to determine the convergence of the error correction process. If the error correction process converges, stop the iteration and output the correction result. If the error correction process does not converge, return to step S5 to perform the next round of error correction.
[0006] Optionally, step S1 includes: Obtain the recognized text output by the language model for the input text; A multimodal error detection model is used to detect multimodal errors in the identified text. The various types of errors obtained from the multimodal error detection are used to generate a set of structured error tags, including terminology errors, grammatical errors, style errors, logical errors, and consistency errors.
[0007] Optionally, the vertex set of the error propagation directed graph is all detected error labels, the edge set is the causal dependencies between error labels, and the weight of the causal dependencies between error labels is a non-linear weighted fusion result of semantic dependency, positional adjacency, and type propagation probability.
[0008] Optionally, in step S3, the improved PageRank algorithm is used to calculate the importance score of each error node in the error propagation directed graph.
[0009] Optionally, the formula for calculating the importance score of each erroneous node in the error propagation directed graph is: ; in, Error node Importance score, where d is the damping coefficient. Pointing to the wrong node The set of nodes, Error node The set of nodes it points to. Error node Pointing to the wrong node edge weights, Error node Prior importance, Error node Pointing to the wrong node Edge weights.
[0010] Optionally, in step S6, a triple verification mechanism of semantic consistency, factual consistency, and grammatical correctness is used to detect whether the correction introduces new errors.
[0011] Optionally, step S7 includes: The error correction process is modeled as a discrete-time Markov chain. Calculate the error correction rate and error introduction rate after each iteration; The convergence of the error correction process is determined by the ratio of the error correction rate to the error introduction rate in two consecutive rounds. If the error correction process converges, the iteration is stopped and the correction result is output. If the error correction process does not converge, the process returns to step S5 for the next round of error correction.
[0012] Optionally, the error correction process converges when the ratio of the error correction rate to the error introduction rate in two consecutive rounds is lower than the convergence threshold or the current round reaches the maximum number of iterations.
[0013] Optionally, the error correction rate is calculated as follows: ; in, Let be the error correction rate after the t-th iteration. The error set after the (t-1)th iteration The error set after the t-th iteration; The formula for calculating the error introduction rate is: ; in, Let be the error correction rate after the t-th iteration.
[0014] A second aspect of the present invention provides a language model self-correction device, comprising: The error tagging module is used to perform multimodal error detection on the recognized text output by the language model and generate a structured error tag set. The propagation path construction module is used to construct a directed error propagation graph based on the causal dependencies between errors, based on a set of structured error tags. The priority calculation module is used to calculate the importance score of each error node in the error propagation directed graph and determine the error correction priority sequence by combining topological sorting. The reflection module is used to construct a meta-inference hint template containing structured information of the directed graph of error propagation. It takes the error node, directed edge weights and propagation probability matrix as structured input, obtains the root cause analysis results of the meta-inference hint template, and generates an error reflection report. The error reflection report contains correction strategies. The correction module is used to build a round-by-round error correction prompt based on the error reflection report's correction strategy and error correction priority sequence, and to correct errors in a targeted manner according to the error correction priority from high to low. The over-correction detection module is used to detect whether the correction has introduced new errors after each round of correction. If so, a partial rollback is performed to restore the state before the correction, and an alternative correction strategy is adopted before returning to the execution correction module. If not, it jumps to the convergence determination module. The convergence determination module is used to model the error correction process as a discrete-time Markov chain. It uses the absorption state property of the Markov chain to determine the convergence of the error correction process. If the error correction process converges, the iteration stops and the correction result is output. If the error correction process does not converge, it returns to the execution correction module to perform the next round of error correction.
[0015] As can be seen from the above technical solutions, the language model self-correction method provided by the present invention has the following advantages: The language model self-correction method provided by this invention performs multimodal error detection on the recognized text output by the language model, constructs a directed error propagation graph to model the causal dependencies between errors, calculates the importance score of each error node in the directed error propagation graph, determines the error correction priority sequence by combining topological sorting, and adopts a reflection-action two-stage error correction framework. The structured error propagation graph is used as the meta-inference input. Root cause analysis is performed first, followed by targeted correction. Overcorrection detection is performed after each round of correction. The error correction process is then formalized as a Markov random process with an absorbing state. The convergence of the error correction process is judged by the absorbing state property of the Markov chain, ensuring the quality of error correction. This method overcomes the limitations of isolated error correction and empirical convergence in existing technologies. It is applicable to automatic error correction tasks in multiple scenarios such as machine translation, text summarization, and code generation, and solves the technical problems of isolated error correction, difficulty in deep correction, and overcorrection in existing automatic language model error correction methods. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating a language model self-correction method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a language model self-correction device provided in an embodiment of the present invention. Detailed Implementation
[0018] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. 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.
[0019] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, they are provided so that this application will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted.
[0020] The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced without one or more of these specific details, or other methods, components, materials, devices, etc. In these cases, well-known structures, methods, devices, implementations, materials, or operations will not be shown or described in detail.
[0021] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.
[0022] The technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0023] The language model self-correction method provided by this invention is applicable to automatic error correction in various text generation tasks such as machine translation, text summarization, question answering systems, and code generation.
[0024] For easier understanding, please refer to Figure 1 This invention provides an embodiment of a language model self-correction method, comprising: Step S1: Perform multimodal error detection on the recognized text output by the language model to generate a set of structured error tags.
[0025] It should be noted that the input text for the language model can be machine-translated text, code-generated text, or long-text summarization text. The input text is fed into the language model, which generates output text. A multimodal error detection model is used to identify various types of errors in the output text, generating a structured error tag set. The multimodal error detection model is based on a sequence labeling architecture and supports the identification of five types of errors: terminology errors, grammatical errors, style errors, logical errors, and consistency errors. Each error tag includes fields such as error type, severity, location, original text, suggested correction, and confidence level. (Structured error tag set) Each error tag Includes error types ,Location Severity and original text fragment fields .
[0026] Step S2: Based on the structured error tag set, construct an error propagation directed graph based on the causal dependencies between errors.
[0027] It should be noted that, based on the structured error label set, an error propagation directed graph G=(V,E) based on the causal dependencies between errors is constructed. The vertex set V of the error propagation directed graph G=(V,E) is all the detected error labels, and the edge set E is the causal dependencies between error labels. The weight of the causal dependencies between error labels is the non-linear weighted fusion result of semantic dependency, positional adjacency and type propagation probability.
[0028] Semantic dependency: The cosine similarity of the semantic embeddings of the two text segments containing errors is calculated using a text encoder such as Sentence-BERT to measure the strength of the semantic association. Semantic embedding vectors of the text segments corresponding to the two errors are calculated separately using a pre-trained text encoder. and The cosine similarity formula is used. Measure the strength of semantic association.
[0029] Positional adjacency: Based on the character distance between two errors in the text, an exponential decay function is used to calculate the adjacency weight; the closer the positions, the higher the weight. (Calculate the character distance between two errors in the text.) Using an exponential decay function Calculate the adjacency weight, where L is the total text length. This is the attenuation coefficient (default value is 2.0).
[0030] Type propagation probability: Based on a predefined error type propagation probability matrix, obtained through statistical analysis of a large-scale error-correction corpus, this matrix characterizes the causal propagation tendency between different error types. Elements in the error type propagation probability matrix. The type is The error type is The probability of errors was obtained by statistically analyzing a large-scale error-correcting corpus; among them, the probability of logical errors propagating to consistency errors was the highest, followed by the probability of terminology errors propagating to semantic errors.
[0031] When the weighted combined weights of semantic dependency, positional adjacency, and type propagation probability are... When the value exceeds the propagation threshold τ (default value is 0.5), a directed edge is added to the graph. , indicating an error node Possibly a faulty node The causes.
[0032] The weighted composite weight of the three dimensions (i.e., ( , Causal dependency weights between ) The formula is: ; in, Error node and error nodes semantic similarity, Error node and error nodes Location distance, Error node and error nodes Type propagation probability, All of these are hyperparameters determined through grid search, with default values of 0.4, 0.3, 2.0, and 0.3, respectively, and L is the total text length.
[0033] Step S3: Calculate the importance score of each erroneous node in the error propagation directed graph, and determine the error correction priority sequence by combining topological sorting.
[0034] It should be noted that an improved PageRank algorithm is used to calculate the importance score of each erroneous node on the error propagation directed graph, taking into account the node's in-degree, out-degree, and edge weights. The scoring formula is: ; in, Error node The importance score, where d is the damping coefficient (default value is 0.85). Pointing to the wrong node The set of nodes, Error node The set of nodes it points to. Error node Pointing to the wrong node edge weights, Error node Prior importance, Error node Pointing to the wrong node Edge weights. Determined by the severity level of the error: Critical error =3, Medium error =2, minor error =1.
[0035] The improved PageRank algorithm introduces error severity as a priori weight for nodes, giving source errors and high-severity errors a higher priority for correction.
[0036] Based on the topology of the error propagation graph and the node importance score, an error correction priority sequence is generated: source errors (nodes with an in-degree of 0) are corrected first, and nodes with high importance are corrected first.
[0037] Step S4: Construct a meta-inference hint template containing structured information of the directed graph of error propagation. Take the error node, directed edge weights and propagation probability matrix as structured inputs, obtain the root cause analysis results of the meta-inference hint template, and generate an error reflection report. The error reflection report contains correction strategies.
[0038] It should be noted that this invention adopts a two-stage error correction paradigm of "reflection first, action later," drawing on meta-reasoning theory to allow the model to first understand the nature and correlation of errors before performing corrective operations. First, a meta-reasoning prompt template containing structured information of the directed graph of error propagation is constructed to guide the model in conducting in-depth root cause analysis of the error propagation chain. The meta-reasoning prompt template includes the following elements: a structured representation of the error propagation chain (node list, directed edges, propagation probability); a root cause analysis task: identifying the source error and key intermediate nodes in the propagation chain; impact assessment: evaluating the expected benefits and potential side effects of correcting each error; and correction strategy suggestions: proposing the optimal correction order and strategy based on error dependencies. Using error nodes, directed edge weights, and the propagation probability matrix as structured inputs, the model is guided to perform root cause analysis based on the graph topology, generating an error reflection report. The meta-reasoning prompt template also includes graph-based reasoning guidance instructions, requiring the model to trace the source error backward along the propagation path and evaluate the correction benefits of each node. The error reflection report includes correction strategies, which include root cause identification results, correction priority suggestions, and precautions, providing guidance for the action phase.
[0039] Step S5: Based on the error reflection report's correction strategy and error correction priority sequence, construct a round-by-round error correction prompt, and correct errors in a targeted manner according to their error correction priority from high to low.
[0040] It should be noted that, based on the error reflection report's correction strategy and error correction priority sequence, a round-by-round error correction prompt is constructed, and high-priority errors are corrected in turn. Each round of correction only processes the current highest-priority error node and its directly downstream related nodes, avoiding mutual interference caused by correcting multiple errors simultaneously. The error correction prompt integrates: the original text and the text to be corrected; detailed tags of the error to be corrected (type, location, suggested correction direction); similar error correction examples retrieved from the case memory (few-shot examples); and the root cause analysis and correction strategy output from the reflection phase. Each round prioritizes correcting the highest-priority error, and after correction, the text status and the directed error propagation graph are updated.
[0041] Step S6: After each round of correction is completed, check whether the correction has introduced new errors. If so, perform a partial rollback to restore the state before the correction, adopt the alternative correction strategy, and return to step S5. If not, proceed to step S7.
[0042] It should be noted that after each round of correction, a triple verification mechanism is used to check for the introduction of new errors: Semantic consistency verification: the semantic embedding similarity of the text before and after correction is compared, and if it is lower than the threshold, it is determined to be over-correction; Factual consistency verification: the factual accuracy of the corrected content is verified based on the original text evidence; Syntactic correctness verification: the syntactic legality of the corrected sentence is verified by relying on the syntactic parser. If over-correction is detected, a partial rollback is performed to restore the state before correction, alternative correction strategies are selected, and the process returns to step S5. If the correction does not introduce new errors, step S7 is executed.
[0043] Step S7: Model the error correction process as a discrete-time Markov chain. Use the absorption state property of the Markov chain to determine the convergence of the error correction process. If the error correction process converges, stop the iteration and output the correction result. If the error correction process does not converge, return to step S5 for the next round of error correction.
[0044] It should be noted that modeling the error correction process as a discrete-time Markov chain (DTMC) provides a provable guarantee of convergence.
[0045] First, the error correction process is modeled as a discrete-time Markov chain: the state space is defined as the set of all possible error configurations E(s), and each state s∈S corresponds to the set of errors present in the text. A state transition corresponds to one round of error correction, and the transition probability P(s→s') is determined by the statistical behavior of the error correction model. This Markov chain satisfies the absorbing state property: it reaches the absorbing state when there are no errors in the text, i.e., E(s) = empty, and no further transitions occur.
[0046] Calculate the error correction rate and error introduction rate after each iteration. The formula for calculating the error correction rate is: ; in, Let be the error correction rate after the t-th iteration, representing the proportion of errors successfully corrected in the t-th iteration. The error set after the (t-1)th iteration The error set after the t-th iteration; The formula for calculating the error introduction rate is: ; in, Let be the error correction rate after the t-th iteration, used to represent the proportion of newly introduced errors in the t-th iteration.
[0047] The ECR / EIR ratio criterion is used for two consecutive rounds. When the ECR / EIR ratio is lower than the convergence threshold λ for two consecutive rounds, it indicates that the error correction efficiency is insufficient to compensate for newly introduced errors, and the marginal benefit of continuing iteration is negative, thus determining convergence. The convergence determination formula is: ; Where Converged is the convergence condition. This is the convergence threshold (default value is 1.2). This represents the maximum number of iterations (default value is 8). When EIR is 0 (i.e., no new errors are introduced), if ECR is also 0, convergence is determined directly. When EIR is 0 but ECR > 0, it is considered to be in the efficient error correction stage, and iteration continues.
[0048] The language model self-correction method provided by this invention performs multimodal error detection on the recognized text output by the language model, constructs a directed error propagation graph to model the causal dependencies between errors, calculates the importance score of each error node in the directed error propagation graph, determines the error correction priority sequence by combining topological sorting, and adopts a reflection-action two-stage error correction framework. The structured error propagation graph is used as the meta-inference input. Root cause analysis is performed first, followed by targeted correction. Overcorrection detection is performed after each round of correction. The error correction process is then formalized as a Markov random process with an absorbing state. The convergence of the error correction process is judged by the absorbing state property of the Markov chain, ensuring the quality of error correction. This method overcomes the limitations of isolated error correction and empirical convergence in existing technologies. It is applicable to automatic error correction tasks in multiple scenarios such as machine translation, text summarization, and code generation, and solves the technical problems of isolated error correction, difficulty in deep correction, and overcorrection in existing language model automatic error correction methods.
[0049] This invention provides a language model self-correction method that, for the first time, treats errors as an interconnected system rather than isolated individuals. By constructing a directed error propagation graph, it models the causal dependencies between errors from three dimensions: semantics, location, and type. Priority determination based on PageRank node importance calculation and topological sorting ensures that source errors and critical nodes are processed first. Experiments show that error propagation chain modeling can improve the F1 score of error correction by more than 15% in multi-error scenarios.
[0050] The language model self-correction method provided by this invention draws upon the "dual-process theory" and meta-reasoning concepts in cognitive science, designing a two-stage correction paradigm of reflection and action. The reflection stage allows the model to "stop and think," deeply analyzing the root causes and propagation paths of errors to avoid blind corrections; the action stage executes precise corrections based on the reflection results. This understanding-before-operation model is particularly suitable for handling complex error types such as logical errors and consistency errors.
[0051] This invention provides a language model self-correction method that formalizes the error correction process as a Markov chain, theoretically proving the convergence of the error correction process (absorption state theorem). The proposed ECR / EIR dynamic convergence criterion replaces the traditional fixed confidence threshold, adapting to different tasks and difficulty levels, and avoiding undercorrection and overcorrection. Compared with fixed threshold methods, the convergence criterion of this invention reduces the average number of iterations by more than 20% while maintaining error correction quality.
[0052] The language model self-correction method provided in this invention addresses the overcorrection problem commonly found in the self-correction of large language models. This invention designs a triple verification mechanism (semantic + factual + syntactic), automatically detecting newly introduced errors and performing a rollback after each iteration. This mechanism effectively solves the problem of "the more you correct, the more errors you get," reducing the overcorrection rate by more than 40%.
[0053] To verify the language model self-correction method provided by this invention, an application example of multi-error linkage correction in the field of machine translation is provided.
[0054] Scenario Description: A user inputs an English technical document, and the system generates a German translation containing multiple related errors. One terminology error leads to a subsequent consistency error, and a grammatical error causes semantic ambiguity. This example demonstrates how the error propagation chain identifies error associations and how the reflect-action framework corrects them at their root.
[0055] The original English text reads: “This environment variable controls the maximum filesize that the system can process during batch operations.” The initial German translation (containing errors) reads: “Diese Umweltvariable steuert die maximale Dateigröße, die das System während Stapelverarbeitungen verarbeiten kann.” Errors found: ① Terminology error: “Umweltvariable” (environmental variable, ecological meaning) should be “Umgebungsvariable” (environmental variable in the field of computer science). ② Consistency error: “währendStapelverarbeitungen” is missing the definite article “den” and should be “während der Stapelverarbeitung”. ③ Grammatical error: The case of the relative clause introductory word “die” is incorrect. It should be “die” (in the accusative case, since Dateigröße is the accusative object) – this was actually correct in the initial translation, but may change with terminology correction.
[0056] Step 1: Error detection and propagation chain construction.
[0057] The multimodal error detection model identified three error markers: Terminology error: “Umweltvariable” → “Umgebungsvariable”, high severity, position 8-21. Grammatical error: "währendStapelverarbeitungen" is missing the definite article, moderate severity, position 78-100. Consistency error, the plural form of the noun is incorrect, it should be the singular "Stapelverarbeitung", moderate severity, position 86-103.
[0058] Constructing a directed graph of error propagation: computation and The associations are as follows: semantic similarity 0.62, positional distance 67 characters (weight 0.33), type propagation probability P(term → grammar) = 0.15, and overall weight. =0.42 < threshold τ=0.5, no boundary. Calculate and The associations are as follows: semantic similarity 0.89, positional distance 8 characters (weight 0.92), type propagation probability P(syntax → consistency) = 0.65, and overall weight. =0.82>τ, add a directed edge → .calculate and The association is as follows: semantic similarity 0.45, distance is relatively far, overall weight 0.28 < τ, no boundary.
[0059] The final propagation graph contains edges: → (Weight 0.82).
[0060] Node importance is calculated using PageRank: S( ) = (1-0.85) / 3 + 0.85×0 = 0.05 - S( )= (1-0.85) / 3 + 0.85×0 = 0.05 - S( ) = (1-0.85) / 3 + 0.85×(0.82×S( )) / 0.82 = 0.05 + 0.85×0.05 = 0.0925.
[0061] Priority is determined based on topological sorting and importance: 1. (Source error, in-degree 0, terminology error, high severity) 2. (Source error, in-degree 0, medium severity syntax error) 3. (Downstream error, dependency) It is necessary to Post-processing correction.
[0062] Step Two: Reflection Phase – Root Cause Analysis.
[0063] Construct meta-inference hints, including the error propagation graph structure and details of each error. Model outputs a reflection report: Root cause analysis: 1. Error The error "(Umweltvariable)" is a misuse of terminology, a domain knowledge error, and an independent source error that does not affect other errors. 2. Error (Missing a definite article) is a grammatical error. The upstream cause is that, because während, as a preposition, requires the genitive case, the definite article 'den' is missing before 'Stapelverarbeitungen', leading to a grammatical error. Error e3 (inconsistent noun number) is... The downstream error. Due to the lack of number and case constraints from the definite article, the noun uses the incorrect plural form. 4. Correction strategy: Correct first. (Determined article + case), verify again Whether to resolve automatically; if not, make targeted corrections. It can be corrected independently. Step 3: Action Phase – Round-by-Round Correction.
[0064] Round 1: Correcting the highest priority errors (Terminology error). Build hint: Includes original text, current translation, error marker, and similar terminology examples - Model correction: Replace "Umweltvariable" with "Umgebungsvariable". Overcorrection detection: Semantic similarity 0.95 (>0.8 threshold), passed. Round 2: Correcting Errors (Grammatical error, missing definite article). Based on the reflection results, the focus is on correcting the definite article and case after "während". Model correction: Change "während Stapelverarbeitungen" to "während derStapelverarbeitung". Overcorrection check: Grammatical validation passed, semantic similarity 0.92, passed. Simultaneously validated... With the E2 revision, The number of nouns was also corrected (plural to singular).
[0065] Step 4: Markov convergence determination.
[0066] After round 1: -E0={ , , } (Initial 3 errors) - E1 = { , (Corrected) ECR1 = (3-2) / 3 = 0.333. EIR1 = 0 (No new errors).
[0067] After round 2: E2 = {} (all corrected). ECR2 = (2-0) / 2 = 1.0. EIR2 = 0.
[0068] After two consecutive rounds where EIR=0 and ECR>0, all errors have been corrected, the absorption state has been reached, and convergence is determined. Number of iterations = 2.
[0069] Final output: "Diese Umgebungsvariable steuert die maximale Dateigröße,die das System während der Stapelverarbeitung verarbeiten kann." In this embodiment, the error propagation chain successfully identified the causal relationship between syntax errors and consistency errors. The reflection phase provided precise guidance for correction strategies, and the two related errors were resolved through a single coordinated correction, demonstrating the high efficiency of the method of this invention.
[0070] To verify the language model self-correction method provided by this invention, an application example of code generation logic error chain correction is provided in this invention.
[0071] Scenario Description: A user requests a Python function to calculate the sum of all even numbers in an array. The code generated by the model contains multiple interconnected logical errors. This embodiment demonstrates how the present invention handles complex logical error propagation chains.
[0072] Initial generated code: def sum_even(arr): total = 1 # Error: initial value should be 0 for i in range(len(arr)): if arr[i] % 2 == 0: total = arr[i] # Error: should be summed, not assigned a value return total Existing errors: : Logical error, the initial value total=1 should be 0. : Logical error, total = arr[i] should be total += arr[i]. Consistency error: Loop variable i is not used, affecting code readability.
[0073] Step 1: Error detection and propagation chain construction.
[0074] The code error detection model (based on static analysis and unit testing) identified three error markers and constructed a propagation graph: → The error in the result is caused by both the initial value error and the accumulation error. There is a functional correlation between them, with a weight of 0.75. → An accumulated logic error may cause developers to use different loop methods, with a weight of 0.4. → The initial value is not directly related to the loop variable, and has a weight of 0.2.
[0075] Final propagation diagram: → (Weight 0.75).
[0076] PageRank Importance: - S( = 0.05 (source node) - S( ) = 0.05 + 0.85×(0.75×0.05) / 0.75 = 0.0925 - S( = 0.05.
[0077] Priority sequence: → → (First, correct the source error) Then correct the downstream Finally, handle the independent ).
[0078] Step Two: Reflection Phase Meta-inference analysis output: "Root cause analysis: 1." The error (incorrect initial value) is at the source; setting the initial value to 1 instead of 0 will cause the final result to have 1 more than the initial value. 2. The core logical error is that it involves assignment rather than accumulation. Both errors contribute to the incorrect summation calculation. The combination of these two errors means that even if the initial values are correct, the result will only equal the last even number because of assignment instead of accumulation. 3. (Unused loop variable) is a separate coding style issue; it doesn't affect functionality but reduces readability. 4. Correction strategy: Correct it first. The accumulation logic (core functional error) needs to be corrected. The initial value, and finally optimized. The code style should be improved. Using `enumerate` or directly iterating over elements is recommended to improve readability. Step 3: Action Phase.
[0079] Round 1: Correction (Core logic error). Change total = arr[i] to total += arr[i]. Overcorrection check: Unit test verification (test case [2,4,6] → expected value 12, actual output 7 (1+6) → still has e1 problem).
[0080] Round 2: Correction (Initial value error). Change total = 1 to total = 0 - pass correction check: unit test verification ([2,4,6]→12, correct). Simultaneously, e2 follows... The function is now working correctly after the correction.
[0081] Round 3: Correction (Code style optimization). Change `for i in range(len(arr))` to `for num inarr` to improve readability. Passed the correction check: Functional test passed, semantic equivalence, passed.
[0082] Step 4: Markov Convergence Determination After Round 1: ECR1 = 1 / 3 = 0.333, EIR1 = 0. After Round 2: ECR2 = 1 / 2 = 0.5, EIR = 0. After Round 3: ECR3 = 1 / 1 = 1.0, EIR3 = 0.
[0083] After two consecutive rounds of EIR=0 and the error has been cleared, the absorption state is reached, and convergence is achieved. Number of iterations = 3.
[0084] Final code: def sum_even(arr):total = 0for num in arr:if num % 2 == 0:total +=numreturn total This embodiment demonstrates the application of the present invention in code generation and error correction scenarios. The error propagation chain clearly reveals the correlation between logical errors, and the reflection phase provides a reasonable order of correction, ultimately achieving a dual improvement in functional correctness and code quality.
[0085] To verify the language model self-correction method provided by this invention, an application example of fact consistency correction for long text summaries is provided in this invention.
[0086] Scenario Description: The system summarizes a 5000-word technology news article, generating a 300-word summary containing multiple factual inconsistencies, and these errors propagate from one another. This embodiment demonstrates how the present invention handles chaines of factual inconsistencies in long texts.
[0087] Key information from the original text: - Company A was founded in 2018 and is headquartered in Shanghai. - It completed its Series B financing in 2023, raising 200 million yuan. - It aims to have over 5 million users by 2025. - Its core product is an AI-assisted writing tool with 1.2 million monthly active users. Generate summary (including errors): "Technology company A, founded in 2015 and headquartered in Hangzhou, completed a Series A financing round of 150 million yuan in 2022. As of 2024, the company had more than 3 million users, and its core product, the AI writing assistant, had more than 800,000 monthly active users." Existing errors: The statement is factually incorrect; the establishment date should be "2018" instead of "2015". The facts are incorrect; the headquarters should be "Shanghai" instead of "Hangzhou". The facts are incorrect. The financing round "Series A" should be "Series B", the amount "150 million" should be "200 million", and the year "2022" should be "2023". The facts are incorrect; the number of users should be "5 million" instead of "3 million", and the year should be "2025" instead of "2024". The facts are incorrect; the monthly active users should be "1.2 million" instead of "800,000".
[0088] Step 1: Error Detection and Propagation Chain Construction The fact consistency detection model identified five factual errors based on entity alignment and semantic implication. A directed graph of error propagation was constructed: and Independent error (no causal relationship between establishment time and headquarters location), weight 0.3. and Financing data and user data may have a timeline correlation, with a weight of 0.55. and There is a proportional relationship between the total number of users and the number of monthly active users, with a weight of 0.65. and Financing is indirectly related to monthly active users, with a weight of 0.42.
[0089] The final propagation graph contains edges: → (Weight 0.55). → (Weight 0.65). → (Weight 0.42).
[0090] Transmission chain: → → (Financing data → total number of users → monthly active users, forming a timeline of development).
[0091] PageRank Importance: - S(e1) = 0.03 - S(e2) = 0.03 - S(e3) = 0.03 (Source Node) - S(e4) = 0.03 + 0.85×(0.55×0.03) / 0.97 = 0.0445 - S(e5) = 0.03 + 0.85×[(0.65×0.0445) / 0.65 + (0.42×0.03) / 0.97] = 0.03 + 0.85×[0.0445 + 0.0130]=0.0789 Priority: > > > ≈ (Ranked from highest to lowest importance, with source errors taking priority).
[0092] Step Two: Reflection Phase.
[0093] Meta-inference analysis output: "Root cause analysis: 1." (Incorrect financing data) is the source of the chain of transmission; the financing round, amount, and year are all incorrect. Financing data is a key milestone in the company's development, affecting the perceived accuracy of subsequent data such as user scale. 2. (Incorrect total user count) is an intermediate point, affected by the timeline of financing data. 3. (Incorrect monthly active users) refers to a downstream node, which should maintain a proportional relationship with the total number of users. 4. and This is an independent factual error and has no propagation relationship with other errors. 5. Correction Strategy: Correct according to the timeline from earliest to latest—first correct the establishment date and headquarters location (basic facts), then correct the financing data (starting point of the timeline), and then sequentially correct the total number of users and monthly active users, ensuring a reasonable ratio between the data. During correction, pay attention to maintaining logical consistency between the data. Step 3: Action Phase.
[0094] Round 1: Correction (Establishment date) and (Headquarters Location) – Independent Base Facts – 2015 → 2018, Hangzhou → Shanghai. Correction Check: Fact verification passed, semantic consistency achieved.
[0095] Round 2: Correction (Financing Data) – Source of the dissemination chain. Series A: 150 million RMB, 2022 → Series B: 200 million RMB, 2023. Correction check passed: Fact verification passed, consistent with the original evidence.
[0096] Round 3: Correction (Total Users) – Intermediate Node. 3 million in 2024 → 5 million in 2025. Passed Correction Test: Logically consistent with the funding timeline (user growth after 2023 funding). Round 4: Correction (Monthly Active Users) – Downstream Node. 800,000 → 1.2 million. Passed Correction Detection: The ratio (24%) to the total user count of 5 million is reasonable, pass.
[0097] Step 4: Markov convergence determination.
[0098] ECR / EIR calculations per round: Round 1: ECR1 = 2 / 5 = 0.4, EIR1 = 0, ratio = ∞. Round 2: ECR2 = 1 / 3 ≈ 0.333, EIR2 = 0, ratio = ∞. Round 3: ECR3 = 1 / 2 = 0.5, EIR3 = 0, ratio = ∞. Round 4: ECR4 = 1 / 1 = 1.0, EIR4 = 0, error reset to zero.
[0099] The absorption state is reached, indicating convergence. Number of iterations = 4.
[0100] Final Summary: "Founded in 2018 and headquartered in Shanghai, technology company A completed a Series B financing round of 200 million yuan in 2023. By 2025, the company had exceeded 5 million users, and its core product, the AI writing assistant, had more than 1.2 million monthly active users." This embodiment demonstrates the application of the present invention in factual consistency error correction of long text summaries. The error propagation chain successfully models the temporal development and proportional relationship between data, and the reflection phase ensures the overall logical consistency of the corrected data, effectively avoiding new inconsistencies that may be caused by isolated corrections.
[0101] During the development of this invention, the technical solution was comprehensively verified through multiple experiments. The experimental data came from the WMT'24 machine translation dataset, the CNN / DailyMail summarization dataset, and the MBPP code generation dataset, covering three typical application scenarios: text translation, summarization generation, and code generation.
[0102] 1. Experimental setup: Baseline methods: Baseline-1: Standard LLM self-correction (single-round prompting + self-correction). Baseline-2: Multi-round iterative self-correction (fixed 5 rounds, confidence threshold 0.8). Baseline-3: Case-based retrieval error correction (KB-Retrieval + LLM correction).
[0103] Evaluation Metrics: Correction Accuracy Rate (CAR): Number of correctly corrected errors / Total number of corrections - Correction Recall Rate (CRR): Number of correctly corrected errors / Total number of errors - F1 Overall Score: 2 × CAR × CRR / (CAR + CRR) - Over-Correction Rate (OCR): Number of errors corrected to correct content / Total number of corrections - Average Iterations (AI): Average number of iterations required to reach convergence - Efficiency Improvement Rate (EIRate): (Baseline time - Method time) / Baseline time.
[0104] 2. Performance comparison of multi-task error correction.
[0105] Table 1 shows a comparison of the error correction performance of the method of this invention and the baseline method on three tasks.
[0106] Table 1 Experimental results show that the method of this invention significantly outperforms the baseline method in all three tasks: F1 score improvement: 9.8 percentage points for machine translation, 11.0 percentage points for text summarization, and 13.5 percentage points for code generation. The most significant improvement was observed in code generation, indicating that the reflect-action framework of this invention is particularly effective in handling logically complex errors. Overcorrection rate is significantly reduced: the overcorrection rate for all three tasks is reduced to below 5%, a reduction of 60%-75% compared to the baseline method, verifying the effectiveness of the overcorrection protection mechanism. Balanced improvement in accuracy and recall: unlike the baseline method which often trades off high accuracy for low recall, this invention achieves simultaneous improvement in both, thanks to the precise location of the error propagation chain and in-depth analysis of the reflective phase.
[0107] 3. Convergence efficiency experiment.
[0108] Table 2 shows a comparison of the efficiency of different convergence strategies.
[0109] Table 2 Experimental results show that the Markov adaptive convergence strategy of this invention achieves the highest convergence success rate (95.2%) among all methods, while having the fewest average iterations (2.8 rounds). Compared to a baseline of 5 fixed iterations, this invention improves the F1 score by 12.7 percentage points while reducing the number of iterations by 44% and the time consumption by 43%. Compared to fixed threshold methods, the convergence criterion of this invention is more robust, can adapt to error correction tasks of varying difficulty, and avoids the difficulty of threshold selection.
[0110] 4. Ablation test To verify the contribution of each core module, an ablation experiment (machine translation task) was conducted, as shown in Table 3.
[0111] Table 3 Ablation Experiment Results Analysis: Error Propagation Chain: After removal, the F1 score decreased by 7.0 percentage points, and the overcorrection rate increased by 2.6 percentage points, proving that error propagation chain modeling can effectively identify error associations and improve the systematic nature of error correction. Reflection Phase: After removal, the F1 score decreased by 6.0 percentage points, and the overcorrection rate increased by 3.3 percentage points, verifying the important role of the cognitive framework of "reflection before action" in improving the quality of error correction. Overcorrection Protection: After removal, the overcorrection rate surged from 3.2% to 10.7%, proving that the triple verification mechanism can effectively prevent "the more you correct, the more errors you get." Markov Convergence: After switching to a fixed threshold, the F1 score decreased by 3.1 percentage points, indicating that the adaptive convergence criterion avoids excessive iteration while ensuring quality.
[0112] Each module makes a significant contribution to the final performance, and there is a synergistic effect between the modules. The overall system performance improvement is greater than the sum of the individual contributions of each module.
[0113] 5. Detailed representation of error types Table 4 shows the corrective effects of the present invention on different types of errors (code generation task).
[0114] Table 4 The results show that the present invention is most effective at correcting simple types of errors, such as grammatical errors and terminological errors, with an F1 score of over 90%; it also achieves an F1 score of 82.3% for complex types, such as logical errors, which is significantly better than the baseline method (approximately 58%), demonstrating the advantages of the reflective-action framework in handling complex errors.
[0115] 6. Scale effect of case memory bank The experiment also verified the impact of the case memory size on error correction performance, as shown in Table 5.
[0116] Table 5 As the case library grows, the error correction performance continues to improve, demonstrating the incremental learning capability of this invention. When the number of cases reaches over 2000, the growth trend slows down, indicating that the system has good knowledge convergence.
[0117] For easier understanding, please refer to Figure 2 The present invention provides an embodiment of a language model self-correction device, comprising: The error tagging module is used to perform multimodal error detection on the recognized text output by the language model and generate a structured error tag set. The propagation path construction module is used to construct a directed error propagation graph based on the causal dependencies between errors, based on a set of structured error tags. The priority calculation module is used to calculate the importance score of each error node in the error propagation directed graph and determine the error correction priority sequence by combining topological sorting. The reflection module is used to construct a meta-inference hint template containing structured information of the directed graph of error propagation. It takes the error node, directed edge weights and propagation probability matrix as structured input, obtains the root cause analysis results of the meta-inference hint template, and generates an error reflection report. The error reflection report contains correction strategies. The correction module is used to build a round-by-round error correction prompt based on the error reflection report's correction strategy and error correction priority sequence, and to correct errors in a targeted manner according to the error correction priority from high to low. The over-correction detection module is used to detect whether the correction has introduced new errors after each round of correction. If so, a partial rollback is performed to restore the state before the correction, and an alternative correction strategy is adopted before returning to the execution correction module. If not, it jumps to the convergence determination module. The convergence determination module is used to model the error correction process as a discrete-time Markov chain. It uses the absorption state property of the Markov chain to determine the convergence of the error correction process. If the error correction process converges, the iteration stops and the correction result is output. If the error correction process does not converge, it returns to the execution correction module to perform the next round of error correction.
[0118] In one embodiment, the error marking module is specifically used for: Obtain the recognized text output by the language model for the input text; A multimodal error detection model is used to detect multimodal errors in the identified text. The various types of errors obtained from the multimodal error detection are used to generate a set of structured error tags, including terminology errors, grammatical errors, style errors, logical errors, and consistency errors.
[0119] In one embodiment, the vertex set of the error propagation directed graph is all detected error labels, the edge set is the causal dependencies between error labels, and the weight of the causal dependencies between error labels is a non-linear weighted fusion result of semantic dependency, positional adjacency, and type propagation probability.
[0120] In one embodiment, the priority calculation module uses an improved PageRank algorithm to calculate the importance score of each error node in the error propagation directed graph.
[0121] In one embodiment, the formula for calculating the importance score of each erroneous node in the error propagation directed graph is: ; in, Error node Importance score, where d is the damping coefficient. Pointing to the wrong node The set of nodes, Error node The set of nodes it points to. Error node Pointing to the wrong node edge weights, Error node Prior importance, Error node Pointing to the wrong node Edge weights.
[0122] In one embodiment, the overcorrection detection module uses a triple verification mechanism of semantic consistency, factual consistency, and syntactic correctness to detect whether the correction introduces new errors.
[0123] In one embodiment, the convergence determination module is specifically used for: The error correction process is modeled as a discrete-time Markov chain. Calculate the error correction rate and error introduction rate after each iteration; The convergence of the error correction process is determined by the ratio of the error correction rate to the error introduction rate in two consecutive rounds. If the error correction process converges, the iteration stops and the correction result is output. If the error correction process does not converge, the process returns to the correction module for the next round of error correction.
[0124] In one embodiment, the error correction process converges when the ratio of the error correction rate to the error introduction rate is lower than the convergence threshold for two consecutive rounds or when the current round reaches the maximum number of iterations.
[0125] In one embodiment, the error correction rate is calculated as follows: ; in, Let be the error correction rate after the t-th iteration. The error set after the (t-1)th iteration The error set after the t-th iteration; The formula for calculating the error introduction rate is: ; in, Let be the error correction rate after the t-th iteration.
[0126] The language model self-correction device provided by this invention is used to execute the language model self-correction method provided by this invention. Its principle and the technical effect achieved are the same as those of the language model self-correction method provided by this invention, and will not be described again here.
[0127] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or units through some interfaces, and may be electrical, mechanical, or other forms.
[0128] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0129] Furthermore, the functional units in the various embodiments of the present 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. The integrated unit can be implemented in hardware or as a software functional unit.
[0130] 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 computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or 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, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0131] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A language model self-correction method, characterized in that, include: S1. Perform multimodal error detection on the recognized text output by the language model and generate a set of structured error tags; S2. Based on the structured error tag set, construct a directed error propagation graph based on the causal dependencies between errors; S3. Calculate the importance score of each error node in the error propagation directed graph, and determine the error correction priority sequence by combining topological sorting; S4. Construct a meta-inference hint template containing structured information of the directed graph of error propagation. Take the error node, directed edge weight and propagation probability matrix as structured input, obtain the root cause analysis results of the meta-inference hint template, and generate an error reflection report. The error reflection report contains correction strategies. S5. Based on the error reflection report, the correction strategy and error correction priority sequence are used to construct a round-by-round error correction prompt, and the errors are corrected in a targeted manner in order of error correction priority from high to low. S6. After each round of correction is completed, check whether the correction has introduced new errors. If so, perform a partial rollback to restore the state before the correction, adopt the alternative correction strategy, and return to step S5. If not, proceed to step S7. S7. Model the error correction process as a discrete-time Markov chain. Use the absorption state property of the Markov chain to determine the convergence of the error correction process. If the error correction process converges, stop the iteration and output the correction result. If the error correction process does not converge, return to step S5 to perform the next round of error correction.
2. The language model self-correction method according to claim 1, characterized in that, Step S1 includes: Obtain the recognized text output by the language model for the input text; A multimodal error detection model is used to detect multimodal errors in the identified text. The various types of errors obtained from the multimodal error detection are used to generate a set of structured error tags, including terminology errors, grammatical errors, style errors, logical errors, and consistency errors.
3. The language model self-correction method according to claim 1, characterized in that, The vertex set of the error propagation directed graph is all detected error labels, and the edge set is the causal dependency between error labels. The weight of the causal dependency between error labels is a non-linear weighted fusion result of semantic dependency, positional adjacency and type propagation probability.
4. The language model self-correction method according to claim 1, characterized in that, In step S3, the improved PageRank algorithm is used to calculate the importance score of each error node in the error propagation directed graph.
5. The language model self-correction method according to claim 1, characterized in that, The formula for calculating the importance score of each erroneous node in a directed graph of error propagation is: ; in, Error node Importance score, where d is the damping coefficient. Pointing to the wrong node The set of nodes, Error node The set of nodes it points to. Error node Pointing to the wrong node edge weights, Error node Prior importance, Error node Pointing to the wrong node Edge weights.
6. The language model self-correction method according to claim 1, characterized in that, In step S6, a triple verification mechanism of semantic consistency, factual consistency, and grammatical correctness is used to detect whether the correction introduces new errors.
7. The language model self-correction method according to claim 1, characterized in that, Step S7 includes: The error correction process is modeled as a discrete-time Markov chain. Calculate the error correction rate and error introduction rate after each iteration; The convergence of the error correction process is determined by the ratio of the error correction rate to the error introduction rate in two consecutive rounds. If the error correction process converges, the iteration is stopped and the correction result is output. If the error correction process does not converge, the process returns to step S5 for the next round of error correction.
8. The language model self-correction method according to claim 7, characterized in that, The error correction process converges when the ratio of the error correction rate to the error introduction rate is lower than the convergence threshold for two consecutive rounds or when the current round reaches the maximum number of iterations.
9. The language model self-correction method according to claim 7, characterized in that, The formula for calculating the error correction rate is: ; in, Let be the error correction rate after the t-th iteration. The error set after the (t-1)th iteration The error set after the t-th iteration; The formula for calculating the error introduction rate is: ; in, Let be the error correction rate after the t-th iteration.
10. A language model self-correction device, characterized in that, include: The error tagging module is used to perform multimodal error detection on the recognized text output by the language model and generate a structured error tag set. The propagation path construction module is used to construct a directed error propagation graph based on the causal dependencies between errors, based on a set of structured error tags. The priority calculation module is used to calculate the importance score of each error node in the error propagation directed graph and determine the error correction priority sequence by combining topological sorting. The reflection module is used to construct a meta-inference hint template containing structured information of the directed graph of error propagation. It takes the error node, directed edge weights and propagation probability matrix as structured input, obtains the root cause analysis results of the meta-inference hint template, and generates an error reflection report. The error reflection report contains correction strategies. The correction module is used to build a round-by-round error correction prompt based on the error reflection report's correction strategy and error correction priority sequence, and to correct errors in a targeted manner according to the error correction priority from high to low. The over-correction detection module is used to detect whether the correction has introduced new errors after each round of correction. If so, a partial rollback is performed to restore the state before the correction, and an alternative correction strategy is adopted before returning to the execution correction module. If not, it jumps to the convergence determination module. The convergence determination module is used to model the error correction process as a discrete-time Markov chain. It uses the absorption state property of the Markov chain to determine the convergence of the error correction process. If the error correction process converges, the iteration stops and the correction result is output. If the error correction process does not converge, it returns to the execution correction module to perform the next round of error correction.
