Large model multi-round dialogue contradiction identification and correction method, system, device and medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-12
- Publication Date
- 2026-08-11
AI Technical Summary
[0007]为了解决现有技术中存在的矛盾检测维度单一、修正与检测相互割裂、缺乏差异化修正策略选择以及部署成本高等问题,本发明提供一种大模型多轮对话矛盾识别与修正方法、系统、设备及介质,以解决上述技术缺陷问题
(1)通过构建并增量式更新对话状态图,并结合语义层、约束层、意图层三个维度的矛盾检测机制,能够全面、精准地识别多轮对话中的事实冲突、约束违反及意图漂移,为后续修正提供准确的依据,从而有效提升对话系统在多轮交互中的输出连贯性与可靠性。
Smart Images

Figure CN122173591B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, specifically to a method, system, device, and medium for identifying and correcting contradictions in large-scale multi-turn dialogues. Background Technology
[0002] With the rapid development of large language models, multi-turn dialogue systems based on these models have been widely applied in human-computer interaction scenarios such as customer service, medical consultation, and technical solution design. In these scenarios, the model needs to maintain consistency between its output content and historical dialogue logic throughout continuous multi-turn interactions. However, existing dialogue consistency maintenance or contradiction detection technologies still have the following technical shortcomings: First, the contradiction detection dimension is too narrow. Existing solutions mainly focus on the consistency comparison of factual information (such as entity attribute values), lacking the ability to systematically detect dynamic user constraints (such as budget restrictions, preference exclusion, and mandatory conditions) and the drift of deep user intentions, making it difficult to cope with the diverse contradiction types in complex dialogue scenarios.
[0003] Secondly, the contradiction correction and detection mechanisms are disconnected. Most existing methods adopt a simple "detection equals correction" strategy, without setting up a quantitative evaluation of the effectiveness of the correction results, and also lack a closed-loop feedback adjustment mechanism based on the evaluation results. This may lead to the introduction of new errors in the corrected response, making it impossible to guarantee the quality of the correction.
[0004] Furthermore, there is a lack of differentiated correction strategies. Existing technologies fail to distinguish whether the contradiction is caused by inference errors in the large model itself or by users actively changing their preferences or correcting information during the conversation. They also fail to dynamically match corresponding correction methods according to different levels of the contradiction (factual layer, constraint layer, intent layer), resulting in rigid correction methods and a poor user experience.
[0005] Furthermore, existing technologies typically rely on fine-tuning the basic large model or focusing on context filtering and problem integrity verification, making it difficult to complete contradiction identification and correction in real time and at low cost during the inference stage.
[0006] Therefore, there is an urgent need in this field for a large-scale multi-turn dialogue contradiction identification and correction method that can identify and correct various contradictions in multi-turn dialogues in real time and efficiently during the reasoning stage, and can distinguish the source of contradictions, dynamically select correction strategies, and verify the quality of correction results. Summary of the Invention
[0007] To address the problems of single-dimensional contradiction detection, disconnect between correction and detection, lack of differentiated correction strategy selection, and high deployment costs in existing technologies, this invention provides a method, system, device, and medium for large-scale multi-turn dialogue contradiction identification and correction, thereby resolving the aforementioned technical deficiencies.
[0008] This invention proposes a method for identifying and correcting contradictions in large-scale multi-turn dialogues, comprising the following steps: S1. After each round of dialogue, extract the semantic information of the user input or the output of the large language model in the current round, and use an incremental update algorithm to construct and update the dialogue state graph. The dialogue state graph includes a set of nodes and a set of edges. Each node corresponds to a semantic unit. Each semantic unit contains subject, relation, object and confidence information. The set of edges includes temporal edges and logical edges. S2. Based on the updated dialogue state graph, multi-level contradiction detection is performed through the rule engine to obtain contradiction detection results. Multi-level contradiction detection includes semantic layer contradiction detection, constraint layer contradiction detection, and intent layer contradiction detection. Among them, semantic layer contradiction detection is used to identify contradictions where the attribute values of the same entity are inconsistent in different rounds; constraint layer contradiction detection is used to detect whether the current output or user intent violates the constraints previously set by the user; and intent layer contradiction detection is used to detect whether there is a deviation in the understanding of user intent by the large language model between different rounds. S3. When the contradiction detection result indicates that a contradiction exists, determine whether the current round is a user-initiated change based on the preset change pattern words in the user input. If it is a user-initiated change, update the dialogue state graph with the new information as core information and generate a confirmation reply. If it is not a user-initiated change, execute the corresponding correction strategy according to the triggered contradiction level to obtain a corrected reply. The correction strategies include: using an initial locking strategy for semantic layer contradictions, a clarification generation strategy for constraint layer contradictions, and an annotation and recording strategy for intent layer contradictions. S4. Input the corrected response into the quality assessment model to calculate four scores, including: factual consistency score, logical coherence score, fluency score, and constraint satisfaction score; determine the output method or trigger a secondary correction process based on the relationship between the weighted comprehensive result of the four scores and the preset threshold.
[0009] Preferably, step S1 uses an incremental update algorithm to construct and update the dialogue state graph, specifically including the following sub-steps: S11. A semantic parser is built using a large language model through prompt word engineering. The semantic parser extracts all semantic units from the semantic information. Each semantic unit is output in a structured data format, which includes subject field, relation field, object field and confidence field. S12. Map each semantic unit to a node and assign node attributes, including unique identifier, subject, relationship, object, dialogue turn identifier, core information marker, weight, timestamp, and confidence level. S13. Perform core information determination for each node. If a node meets one of the following conditions, mark the core information of the node as true and fix the weight of the node to the preset maximum value. Condition 1: The number of times the same subject and relationship is explicitly emphasized or repeated by the user in the dialogue history reaches a preset threshold. Condition 2: The node belongs to the domain's predefined core fact base; Condition 3: The out-degree of a node in the dialogue state graph is greater than or equal to a preset dependency threshold. For nodes whose core information is marked as false, the node's weight is updated exponentially after each new round of dialogue. When the weight is lower than the preset obsolescence threshold, the node is marked as an obsolescence node. S14. Calculate the similarity between subjects of different nodes using weighted Jaccard similarity, and establish temporal edges for nodes describing the same subject; use a semantic vector model to encode the object of a node and the subject of another node into vectors, calculate the cosine similarity, and establish logical edges when the cosine similarity exceeds a preset similarity threshold.
[0010] Preferably, in step S2, performing semantic layer contradiction detection specifically includes the following sub-steps: S211. Traverse all node pairs in the dialogue state graph that have the same subject and the same relationship; S212. Extract the objects of node pairs and calculate the normalized edit distance similarity; S213. When the normalized edit distance similarity is less than the preset semantic consistency threshold, it is determined that there is a semantic contradiction in the node pair. The execution of constraint layer conflict detection specifically includes the following sub-steps: S221. In the dialogue state graph, nodes belonging to the preset constraint type set are identified by matching the relation fields using regular expressions, thus forming a constraint node set. S222. For the response to be generated in the current round or the user's current input, parse the numerical value, entity, or action. S223. For each constraint node in the constraint node set, perform constraint satisfaction checks based on the relation type of the constraint node using the parsed values, entities, or actions, and record nodes that violate constraints to the violation set. S224. Calculate the constraint layer conflict score. The constraint layer conflict score is the ratio of the number of violation cluster nodes to the number of constraint cluster nodes. When the constraint layer conflict score is greater than zero, a constraint layer conflict is triggered. The execution intent layer contradiction detection specifically includes the following sub-steps: S231. Input the historical dialogue into the large language model, extract the output vector of the last hidden layer before the output layer of the large language model, and take the hidden state of the last word as the historical intent vector; input the complete context into the large language model, extract the output vector of the last hidden layer before the output layer of the large language model, and take the hidden state of the last word as the current intent vector; calculate the cosine similarity between the current intent vector and the historical intent vector; when the cosine similarity is less than the preset drift sensitivity threshold, trigger the intent drift contradiction; S232. Maintain a dynamic intent tag set. Use a large language model to classify the current dialogue context hierarchically to obtain the intent tag for the current round. Compare the intent tag for the current round with the intent tag for the previous round. If they are different, further determine: if the intent tag for the current round belongs to the preset change type intent and the intent tag for the previous round does not belong to the preset change type intent, then it is determined that the user actively changed the intent; otherwise, it is determined that the model's understanding is contradictory.
[0011] Preferably, in step S3, determining whether the current round is a user-initiated change based on the preset change pattern words in the user's current input specifically includes: using regular expressions to match the preset change pattern word set in the user's current input; if the match is successful, it is determined to be a user-initiated change, the core information of the node corresponding to the new information is marked as true and updated to the dialogue state graph, and a confirmation reply is generated; if the match fails, it is determined to be a non-user-initiated change.
[0012] Preferably, in step S3, a first-time locking strategy is used for semantic layer contradictions, a clarification generation strategy is used for constraint layer contradictions, and an annotation and recording strategy is used for intent layer contradictions, wherein: The initial locking strategy is as follows: find all nodes with the same subject and the same relationship as the current conflicting node in the dialogue state graph, select the node with the smallest timestamp as the initial node, replace the conflicting object value in the current response with the object value of the initial node, and obtain the corrected response. The clarification generation strategy is as follows: generate query statements based on the nodes that violate constraints detected in step S2. The query statements contain both constraint content and conflict content. The query statements are then output as the corrected response. The annotation and recording strategy is as follows: keep the original response content unchanged, and add metadata annotations at the end of the original response content. The metadata annotations include intent drift identifiers, previous round intent tags, and current round intent tags.
[0013] Preferably, in step S4, four scores are calculated, and a weighted comprehensive result is obtained based on the four scores, specifically including: S411. Obtain all nodes marked as true from the dialogue state graph to form a core node set. For each core node, check whether there is any conflicting information in the corrected response obtained in step S3 with the object value of the core node. Define a conflict detection function, which returns the first value when a conflict exists, and the second value otherwise. Calculate the factual consistency score based on the conflict detection results of each core node. The calculation expression is:
[0014] in, For the core node set, As the core node, This is the corrected reply. This is a collision detection function; S412. Input the historical dialogue and the revised response into the large language model to obtain a logical coherence score, and calculate the logical coherence rating based on the logical coherence score. The calculation expression is:
[0015] in, Score for logical coherence. The preset maximum score; S413. Calculate the perplexity of the corrected response using a large language model. The calculation expression is:
[0016] in, This is the corrected reply. for The number of lexical units, The conditional probability of each lexical unit is calculated; then, the perplexity score is obtained by normalizing the perplexity score. The calculation expression is:
[0017] in, For the degree of confusion, To preset the baseline perplexity, The preset scaling factor; S414. Obtain the constraint node set from the dialogue state graph, perform a constraint satisfaction check on each constraint node, and count the number of nodes that violate the constraints; calculate the constraint satisfaction score based on the number of nodes that violate the constraints and the constraint node set. The calculation expression is:
[0018] in, The number of nodes that violated the constraints. For the constraint node set; S415. Calculate the weighted sum of the four scores as the weighted composite result. The calculation expression is:
[0019] in, For preset weighting coefficients, Score for factual consistency. Scoring for logical coherence, Rate the smoothness. Score the constraint satisfaction.
[0020] Preferably, in step S4, the output method or the triggering of a secondary correction process is determined based on the relationship between the weighted synthesis result and the preset threshold, specifically including the following sub-steps: S421. When the weighted comprehensive result is greater than or equal to the first preset threshold, the corrected response is used as the final output, and the correction strategy and weighted comprehensive result of this round are stored as positive samples in the correction experience pool. S422. When the weighted composite result is greater than or equal to the second preset threshold and less than the first preset threshold, the phrases or sentences in the corrected response that cause the decrease in the factual consistency score or constraint satisfaction score are replaced with synonyms, the sentence structure is adjusted or information is supplemented, a new response is generated, and the weighted composite result of the new response is recalculated. S423. When the weighted comprehensive result is less than the second preset threshold, a secondary correction process is triggered. The current corrected response and the weighted comprehensive result corresponding to the current corrected response are used as negative feedback. At the same time, the similarity threshold for semantic layer contradiction detection and the drift sensitivity threshold for intent layer contradiction detection are increased by a preset amount. Steps S2 to S4 are executed again, and the preset number of retries is retried. If it still fails, a preset safe response is output.
[0021] This invention also proposes a large-scale multi-turn dialogue contradiction identification and correction system for implementing any of the methods described above. The system includes: The dialogue state tracking module is configured to extract semantic information from the user input or the output of the large language model in the current round after each round of dialogue, and to construct and update the dialogue state graph using an incremental update algorithm. The dialogue state graph includes a set of nodes and a set of edges. Each node corresponds to a semantic unit, and each semantic unit contains subject, relation, object and confidence information. The set of edges includes temporal edges and logical edges. The multi-level contradiction detection module is configured based on the updated dialogue state graph. It performs multi-level contradiction detection through the rule engine to obtain contradiction detection results. Multi-level contradiction detection includes semantic layer contradiction detection, constraint layer contradiction detection, and intent layer contradiction detection. Semantic layer contradiction detection is used to identify contradictions where the attribute values of the same entity are inconsistent in different rounds. Constraint layer contradiction detection is used to detect whether the current output or user intent violates the constraints previously set by the user. Intent layer contradiction detection is used to detect whether there is a deviation in the understanding of user intent by the large language model between different rounds. The progressive correction module is configured to determine whether the current round of user input was initiated by the user when the contradiction detection result indicates a contradiction. If it was initiated by the user, the new information is updated to the dialogue state graph as core information and a confirmation reply is generated. If it was not initiated by the user, the corresponding correction strategy is executed according to the level of contradiction triggered to obtain a corrected reply. The correction strategies include: an initial locking strategy for semantic layer contradictions, a clarification generation strategy for constraint layer contradictions, and an annotation and recording strategy for intent layer contradictions. The quality self-assessment module is configured to input the corrected response into the quality assessment model, calculate four scores: factual consistency score, logical coherence score, fluency score, and constraint satisfaction score. The output method or triggering of a secondary correction process is then determined based on the relationship between the weighted comprehensive result of the four scores and a preset threshold.
[0022] The present invention also proposes a terminal device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, it implements the steps of any of the above-described large-model multi-turn dialogue contradiction identification and correction methods.
[0023] The present invention also proposes a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-described large-model multi-turn dialogue contradiction identification and correction methods.
[0024] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) By constructing and incrementally updating the dialogue state graph, and combining the contradiction detection mechanism of the three dimensions of semantic layer, constraint layer and intent layer, it is possible to comprehensively and accurately identify factual conflicts, constraint violations and intent drift in multi-turn dialogue, providing accurate basis for subsequent correction, thereby effectively improving the output coherence and reliability of the dialogue system in multi-turn interaction.
[0025] (2) By using regular expressions to match preset change pattern words, it is possible to accurately distinguish between user-initiated changes and model errors, avoid erroneous correction of reasonable user needs, and reduce the user's error correction burden. At the same time, for contradictions in the semantic layer, constraint layer, and intent layer, three differentiated correction strategies are adopted respectively: initial locking, clarification generation, and annotation recording, making the correction process more natural and flexible, and improving user satisfaction.
[0026] (3) A four-dimensional quality assessment model is introduced, which includes factual consistency score, logical coherence score, fluency score and constraint satisfaction score. Based on the comparison results of the comprehensive score and the preset threshold, the decision is made to directly output, make local fine adjustments or trigger a secondary correction process, forming a closed-loop feedback mechanism of "detection-correction-evaluation-re-correction", which reduces the probability of introducing new errors during the correction process and ensures the correctness and fluency of the corrected content.
[0027] (4) All the above steps are completed in the reasoning stage. There is no need to retrain or fine-tune the parameters of the existing large language model. This can significantly improve the performance of the existing dialogue system and has good versatility and transferability. Attached Figure Description
[0028] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments, taken with reference to the accompanying drawings: Figure 1 This is a flowchart of a method for identifying and correcting contradictions in multi-turn dialogues within a large model; Figure 2 This is a schematic diagram of a large-scale multi-turn dialogue contradiction identification and correction system; Figure 3 This is a schematic diagram of the structure of a computer system suitable for implementing the embodiments of the present invention. Detailed Implementation
[0029] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.
[0030] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0031] Figure 1 The flowchart of the method for identifying and correcting contradictions in multi-turn dialogues in a large model is shown. (Refer to...) Figure 1 This invention proposes a method for identifying and correcting contradictions in large-scale multi-turn dialogues, comprising the following steps: Step S1: After each round of dialogue, extract the semantic information from the user input or the output of the large language model in the current round, and construct and update the dialogue state graph using an incremental update algorithm. The dialogue state graph includes a set of nodes and a set of edges. Each node corresponds to a semantic unit, and each semantic unit contains subject, relation, object, and confidence information. The edge set includes temporal edges and logical edges. Step S1 specifically includes the following sub-steps: S11: A semantic parser is built using a large language model through prompt word engineering. The semantic parser extracts all semantic units from the semantic information. Each semantic unit is output in a structured data format, which includes subject field, relation field, object field, and confidence field.
[0032] For example, a structured prompt word can be designed to guide a large language model in extracting semantic units: This prompt word requires the model to extract all semantic units from the dialogue text. Each semantic unit contains a subject, relation, object, and confidence level. The subject and object must be entities or explicit references in the text; the relation must be normalized to predefined predicates, such as "age is", "budget is less than", and "location is". The confidence level is assigned between 0.7 and 1.0 based on the explicitness of the text, with a confidence level below 0.7 assigned to vague references. The model outputs a dataset containing the subject, relation, object, and confidence level fields. For example, from the user input "I am 25 years old this year", a semantic unit can be extracted with the subject "User A", the relation "age is", the object "25 years old", and a confidence level of 0.98.
[0033] S12: Map each semantic unit to a node and assign node attributes, including unique identifier, subject, relationship, object, dialogue turn identifier, core information marker, weight, timestamp, and confidence level.
[0034] Specifically, a globally unique identifier is generated for each extracted semantic unit, the current dialogue round number is recorded, the initial value of the core information tag is set to false, the initial weight is set to 1.0, the current system timestamp is recorded, and the confidence value obtained during extraction is retained.
[0035] S13: Perform core information determination for each node. If a node meets one of the following conditions, the core information of the node is marked as true, and the weight of the node is fixed to the preset maximum value. For nodes whose core information is marked as false, after each new round of dialogue, the weight of the node is updated in an exponential decay manner. When the weight is lower than the preset obsolescence threshold, the node is marked as an obsolescence node.
[0036] The conditions include: Condition 1: The same subject and relationship are explicitly emphasized or repeated by the user a certain number of times in the dialogue history, reaching a preset threshold. For example, if a user emphasizes "My budget is 5000 yuan" twice, then that node is marked as core information.
[0037] Condition 2: The node belongs to the domain's predefined core fact base. For example, in a medical consultation scenario, the predefined core fact base contains {age, allergy history, past medical history}. If the relationship of a node is "age is", it is marked as core information.
[0038] Condition 3: The out-degree of a node in the dialogue state graph (i.e., the number of logical edges originating from that node) is greater than or equal to a preset dependency threshold. If the information of this node is frequently referenced by multiple subsequent nodes, it is marked as core information.
[0039] For nodes marked as core information, their weight is fixed at 1.0 and never decays. For non-core nodes, after each new round of dialogue, the weight of each existing non-core node is updated according to the following formula:
[0040] in, For nodes Weights before update For nodes Updated weights; The attenuation coefficient ranges from 0.9 to 0.99 (0.95 is the default value in this embodiment). When the updated weight is lower than the preset obsolescence threshold (e.g., 0.2), the node is marked as an "obsolescence node" and will be ignored or downweighted in subsequent contradiction detection.
[0041] S14: Use weighted Jaccard similarity to calculate the similarity between subjects of different nodes, and establish temporal edges for nodes describing the same subject; use a semantic vector model to encode the object of a node and the subject of another node into vectors, calculate cosine similarity, and establish logical edges when the cosine similarity exceeds a preset similarity threshold.
[0042] Specifically, for any two nodes and Let their main strings be respectively and Each main string is split into a set of tokens, denoted as . and Calculate the weighted Jaccard similarity. :
[0043] When the similarity is greater than the preset similarity threshold (0.8 in this embodiment), a temporal edge is established between the two nodes to represent the evolution of information of the same subject with each round of dialogue.
[0044] For logical edges, use Sentence. The BERT semantic vector model encodes the object of a node and the subject of another node to obtain a vector representation. Let node... The object encoding vector is ,node The main encoding vector is Calculate cosine similarity. :
[0045] When the cosine similarity is greater than the preset similarity threshold (0.8 in this embodiment), a logical edge is established to indicate that there is a reasoning dependency between the two nodes (for example, the object of the previous node is the argument of the next node).
[0046] Step S2: Based on the updated dialogue state graph, perform multi-level contradiction detection through the rule engine to obtain the contradiction detection results. Multi-level contradiction detection includes semantic layer contradiction detection, constraint layer contradiction detection, and intent layer contradiction detection; among them, semantic layer contradiction detection is used to identify contradictions where the attribute values of the same entity are inconsistent in different rounds; constraint layer contradiction detection is used to detect whether the current output or user intent violates the constraints previously set by the user; and intent layer contradiction detection is used to detect whether there is a deviation in the understanding of user intent by the large language model between different rounds.
[0047] Step S2 specifically includes the following three parallel detection branches: (a) Semantic layer contradiction detection S211: Traverse all pairs of nodes in the dialogue state graph that have the same subject and the same relationship.
[0048] S212: Extract the objects of node pairs and calculate the normalized edit distance similarity. :
[0049] in, Two strings and Edit distance, For object string Length, For object string The length.
[0050] S213: When the normalized edit distance similarity is less than the preset semantic consistency threshold (0.8 by default in this embodiment), the node pair is determined to have a semantic contradiction. For example, if the user says "age 25 years old" in the first round and the user says "age 30 years old" in the third round, the calculated edit distance similarity is less than 0.8, thus triggering a semantic contradiction.
[0051] (ii) Detection of contradictions in the constraint layer S221: In the dialogue state graph, nodes belonging to a preset constraint type set are identified by matching relation fields using regular expressions, thus forming a constraint node set. Preset constraint types include "budget less than or equal to", "price not exceeding", "preference exclusion", and "must include".
[0052] S222: For the response to be generated in the current round or the user's current input, parse the numerical value, entity, or action. For example, parse the price value 6000 from the user input "I need a phone for 6000 yuan"; parse the color entity "red" from the model's response "Recommend the red one".
[0053] S223: For each constraint node in the constraint node set, perform a constraint satisfaction check based on the constraint node's relation type, using the parsed values, entities, or actions, and record nodes that violate constraints in the violation set. Example of a check rule: If the relation is "budget less than or equal to", extract all price values from the responses. If any price is greater than the object value of the constraint node, it is considered a violation.
[0054] If the relationship is "preference exclusion", search for the object value (e.g., "red") of the constraint node in the response. If a match is found, it is determined to be a violation.
[0055] S224: Calculate the constraint layer conflict score :
[0056] When the score is greater than 0, a constraint layer conflict is triggered.
[0057] (III) Detection of contradictions at the intention level Intent-layer contradiction detection comprises two parallel sub-steps: S231: Input the historical dialogue into the large language model, extract the output vector of the last hidden layer before the output layer of the large language model, and take the hidden state of the last word as the historical intent vector; input the complete context into the large language model, extract the output vector of the last hidden layer before the output layer of the large language model, and take the hidden state of the last word as the current intent vector; calculate the cosine similarity between the current intent vector and the historical intent vector; when the cosine similarity is less than the preset drift sensitivity threshold, trigger the intent drift contradiction.
[0058] Specifically, let the historical dialogue sequence be... After concatenating them, input them into the large language model, and take the hidden state of the last word in the last hidden layer before the output layer as... Similarly, Dialogue with the current round spliced together Extracting from the same model Calculate cosine similarity. :
[0059] when When the value is less than the preset drift sensitivity threshold (0.65 in this embodiment), the intention drift conflict is triggered.
[0060] S232: Maintain a dynamic intent tag set. Use a large language model to classify the current dialogue context hierarchically to obtain the intent tag for the current round. Compare the intent tag for the current round with the intent tag for the previous round. If they are different, further determine: if the intent tag for the current round belongs to the preset change type intent and the intent tag for the previous round does not belong to the preset change type intent, then it is determined that the user actively changed the intent; otherwise, it is determined that the model's understanding is contradictory.
[0061] In this embodiment, a hierarchical classification approach is used to identify the intent of the current dialogue context using a large language model. Specifically, predefined primary intents include consultation, operation, casual conversation, and correction; among them, secondary intents under the consultation category include product consultation, price consultation, and after-sales consultation. Using the current dialogue context and historical intent tags as input, the model is required to output the most suitable intent tag for the current round, prioritizing selection from historical intent tags; if no match can be found, a new tag is generated. After obtaining the intent tag for the current round, it is compared with the intent tag from the previous round. If they differ and the current tag is "correction" while the previous tag was not "correction," it is determined that the user actively changed the intent; otherwise, it is determined that there is a model misunderstanding or contradiction.
[0062] Step S3: When the contradiction detection result indicates a contradiction, determine whether the current round is a user-initiated change based on the preset change pattern words in the user input. If it is a user-initiated change, update the dialogue state graph with the new information as core information and generate a confirmation reply. If it is not a user-initiated change, execute the corresponding correction strategy according to the triggered contradiction level to obtain a corrected reply. The correction strategies include: using an initial locking strategy for semantic layer contradictions, a clarification generation strategy for constraint layer contradictions, and an annotation and recording strategy for intent layer contradictions.
[0063] Specifically, the method for determining whether a change was initiated by the user is to use regular expressions to match preset change pattern words in the user's current input. In this embodiment, preset change pattern words include words such as "correct," "modify," "actually," "I misspoke," "the previous one doesn't count," "this time it's the standard," and "not...but," which indicate the user's intention to actively correct or change. If a match is successful, it is determined that the change was initiated by the user, and the following steps are executed: Set the core information of the node corresponding to the new information to true and update the node to the dialogue state graph; then generate a confirmation reply, such as: "The record has been updated according to your latest information and the new information content has been confirmed." Then skip all correction strategies and directly output the confirmation reply.
[0064] If the matching fails, it is determined to be a non-user-initiated change, and handled according to the actual conflict level triggered in step S2: For semantic layer contradictions, a first-lock strategy is adopted: All nodes with the same subject and relationship as the currently conflicting node are searched in the dialogue state graph. The node with the smallest timestamp is selected as the first node, and the conflicting object value in the current response is replaced with the object value of the first node, resulting in a corrected response. The principle of this strategy is that the model should adhere to the earliest correct fact unless explicitly changed by the user.
[0065] For constraint-layer contradictions, a clarification generation strategy is adopted: Based on the nodes violating constraints detected in step S2, an inquiry statement is generated, containing both the constraint content and the conflicting information. For example: a user previously set a budget of no more than 5,000 yuan, but the currently recommended phone price is 6,000 yuan. The generated inquiry statement is: "You previously mentioned a budget of no more than 5,000 yuan, but the currently recommended phone price is 6,000 yuan, which is inconsistent. Should the latest price be used, or should the budget be adjusted?" This inquiry statement is output as the corrected response, returning control of the conversation to the user.
[0066] To address intent-layer contradictions, an annotation and recording strategy is employed: the original response content remains unchanged, while an invisible metadata annotation is appended to the end. This metadata annotation records intent drift information, including intent drift identifiers, the previous round's intent tag, and the current round's intent tag. For example, when a user's intent changes from a product inquiry to a price inquiry, this change is recorded in the annotation. This annotation does not affect the user-visible response text and is only used for downstream log analysis or to trigger proactive inquiries, thus ensuring the smoothness of the dialogue.
[0067] Step S4: Input the revised response into the quality assessment model to calculate four scores: factual consistency, logical coherence, fluency, and constraint satisfaction. The output method or triggering of a secondary revision process is determined based on the relationship between the weighted average of the four scores and a preset threshold. Step S4 specifically includes the following sub-steps: S411: Obtain all core information from the dialogue state graph. The nodes marked as true constitute the core node set. For each core node Check the corrected response obtained in step S3. Does the data contain information that conflicts with object values of the core node? Define a conflict detection function. Returning 1 if a conflict exists, otherwise returning 0. Calculate the fact consistency score based on the conflict detection results of each core node. The expression is:
[0068] S412: Engaging in Historical Dialogue and the revised reply Input a large language model and have it score the logical coherence of the corrected response relative to the dialogue history, ranging from 0 to 10. 0-3 indicates completely illogical and incoherent; 4-6 indicates partially relevant but with obvious jumps or contradictions; 7-8 indicates basically coherent and logically sound; and 9-10 indicates perfect coherence and rigorous logic. The model should only output a numerical score. The model's output score is recorded as follows: Calculate the logical coherence score The expression is:
[0069] in To set the maximum score, 10 is used in this embodiment.
[0070] S413: Calculate the perplexity of the corrected response using a large language model. The expression is:
[0071] in In reply The number of lexical units, This represents the conditional probability of each word given the preceding context. The perplexity score is then normalized to obtain the fluency score. :
[0072] in The preset baseline perplexity is set to 10 in this embodiment. The preset scaling factor (100 in this embodiment) is used to crop the result to the [0,1] interval.
[0073] S414: Obtain the set of constraint nodes from the dialogue state graph Perform a constraint satisfaction check on each constraint node (using the same method as step S223), and count the number of nodes that violate the constraints. Calculate the constraint satisfaction score. :
[0074] S415: Calculate the weighted sum of the four scores as the weighted composite result. :
[0075] in These are preset weighting coefficients. In this embodiment, each is set to 0.25 by default; however, they can be dynamically adjusted in specific application scenarios (such as financial consulting), for example, increasing the weights of factual consistency and constraint satisfaction to 0.35.
[0076] After obtaining the weighted composite result, the output method or a secondary correction process is determined based on the comparison result with the preset threshold. The specific steps include the following: S421: When When the value is greater than or equal to the first preset threshold (0.8 in this embodiment), the corrected response is taken as the final output, and the correction strategy and weighted synthesis result of this round are stored as positive samples in the correction experience pool for subsequent model optimization or Few Shot example.
[0077] S422: When When the score is greater than or equal to the second preset threshold (0.6 in this embodiment) and less than the first preset threshold, phrases or sentences in the corrected response that cause a decrease in the factual consistency score or constraint satisfaction score are replaced with synonyms, adjusted in sentence structure, or supplemented with information to generate a new response. Then, the weighted comprehensive result of the new response is recalculated. In this embodiment, a template-based non-autoregressive text editor (local rewriter) is used to perform the above fine-tuning operation, and the fine-tuning is retried a maximum of a preset number of times (e.g., 2 times).
[0078] S423: When If the response falls below the second preset threshold, a secondary correction process is triggered: the current corrected response and its corresponding weighted composite result are dynamically added as negative feedback to the prompts used for contradiction detection in step S2 and the prompts used for correction strategies in step S3. Simultaneously, the similarity threshold for semantic-layer contradiction detection and the drift sensitivity threshold for intent-layer contradiction detection are increased by a preset amount (e.g., the Jaccard similarity threshold is increased from 0.7 to 0.8, and the intent drift threshold is increased from 0.65 to 0.7). Then, steps S2 to S4 are re-executed. The entire secondary correction process is retried a maximum of a preset number of times (e.g., 3 times). If it still fails, a preset safe response is output, such as: "Sorry, I encountered some logical contradictions and cannot provide a reliable answer. Could you rephrase your question?".
[0079] Through the above steps, the present invention forms a complete closed loop of "detection-correction-evaluation-re-correction", which significantly improves the accuracy and reliability of conflict handling in multi-round dialogues.
[0080] Further reference Figure 2 As an implementation of the above method, this invention also provides a large-scale multi-turn dialogue contradiction identification and correction system 200 for implementing the above method. The system includes: The dialogue state tracking module 210 is configured to extract semantic information from the user input or the output of the large language model in the current round after each round of dialogue, and to construct and update the dialogue state graph using an incremental update algorithm. The dialogue state graph includes a set of nodes and a set of edges. Each node corresponds to a semantic unit, and each semantic unit contains subject, relation, object, and confidence information. The set of edges includes temporal edges and logical edges.
[0081] The multi-layered contradiction detection module 220, configured based on the updated dialogue state graph, performs semantic layer contradiction detection, constraint layer contradiction detection, and intent layer contradiction detection through a rule engine to obtain contradiction detection results. Specifically, semantic layer contradiction detection identifies contradictions where the attribute values of the same entity are inconsistent across different rounds; constraint layer contradiction detection detects whether the current output or user intent violates previously set constraints; and intent layer contradiction detection detects whether there are discrepancies in the large language model's understanding of the user's intent across different rounds.
[0082] The progressive correction module 230 is configured to, when the contradiction detection result indicates a contradiction, determine whether the current round's change was initiated by the user based on the preset change pattern words in the user's input. If it was initiated by the user, the new information is updated as core information in the dialogue state graph and a confirmation response is generated. If it was not initiated by the user, the corresponding correction strategy is executed according to the triggered contradiction level to obtain a corrected response. The correction strategies include: an initial locking strategy for semantic layer contradictions, a clarification generation strategy for constraint layer contradictions, and an annotation and recording strategy for intent layer contradictions.
[0083] The quality self-assessment module 240 is configured to input the corrected response into the quality assessment model and calculate four scores, including: factual consistency score, logical coherence score, fluency score, and constraint satisfaction score. The output method or triggering of a secondary correction process is determined based on the relationship between the weighted comprehensive result of the four scores and the preset threshold.
[0084] The present invention also proposes a terminal device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, it implements the steps of any of the above-described large-model multi-turn dialogue contradiction identification and correction methods.
[0085] The present invention also proposes a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-described large-model multi-turn dialogue contradiction identification and correction methods.
[0086] The following is for reference. Figure 3 It shows a schematic diagram of the structure of a computer system 300 suitable for implementing terminal devices or servers of the present invention. Figure 3 The terminal device or server shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.
[0087] like Figure 3As shown, the computer system 300 includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 302 or programs loaded from storage section 308 into random access memory (RAM) 303. The RAM 303 also stores various programs and data required for the operation of the computer system 300. The CPU 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0088] The following components are connected to I / O interface 305: an input section 306 including a keyboard, mouse, etc.; an output section 307 including a liquid crystal display (LCD) and speakers, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN card and a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to I / O interface 305 as needed. A removable medium 311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 310 as needed so that computer programs read from it can be installed into storage section 308 as needed.
[0089] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 309, and / or installed from removable medium 311. When the computer program is executed by central processing unit (CPU) 301, it performs the functions defined in the methods of this invention. It should be noted that the computer-readable medium described in this invention can be a computer-readable signal medium or a computer-readable medium or any combination thereof. The computer-readable medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this invention, a computer-readable medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable medium that can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0090] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0091] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0092] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention is not limited to the specific combination of the above-described technical features, but also includes other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in this invention.
Claims
1. A large model multi-round dialogue contradiction identification and correction method, characterized in that, Includes the following steps: S1. After each round of dialogue, extract the semantic information of the current round of user input or the output of the large language model, and use an incremental update algorithm to construct and update the dialogue state graph. The dialogue state graph includes a set of nodes and a set of edges. Each node corresponds to a semantic unit. Each semantic unit contains subject, relation, object and confidence information. The set of edges includes temporal edges and logical edges. S2. Based on the updated dialogue state graph, perform multi-level contradiction detection through the rule engine to obtain contradiction detection results. The multi-level contradiction detection includes semantic layer contradiction detection, constraint layer contradiction detection, and intent layer contradiction detection. The semantic layer contradiction detection is used to identify contradictions where the attribute values of the same entity are inconsistent in different rounds. The constraint layer contradiction detection is used to detect whether the current output or user intent violates the constraints previously set by the user. The intent layer contradiction detection is used to detect whether there is a deviation in the understanding of user intent by the large language model between different rounds. S3. When the contradiction detection result indicates a contradiction, determine whether the current round is a user-initiated change based on the preset change pattern words in the user input. If it is a user-initiated change, update the dialogue state diagram with the new information as core information and generate a confirmation reply. If it is not a user-initiated change, execute the corresponding correction strategy according to the triggered contradiction level to obtain a corrected reply. The correction strategy includes: using an initial locking strategy for semantic layer contradictions, using a clarification generation strategy for constraint layer contradictions, and using an annotation and recording strategy for intent layer contradictions. S4. Input the corrected response into the quality assessment model to calculate four scores, including: factual consistency score, logical coherence score, fluency score, and constraint satisfaction score; determine the output method or trigger a secondary correction process based on the relationship between the weighted comprehensive result of the four scores and a preset threshold.
2. The large model multi-round dialogue contradiction identification and correction method according to claim 1, characterized in that, Step S1 uses an incremental update algorithm to construct and update the dialogue state graph, specifically including the following sub-steps: S11. A semantic parser is constructed using a large language model through prompt word engineering. The semantic parser extracts all semantic units from the semantic information. Each semantic unit is output in a structured data format, which includes a subject field, a relation field, an object field, and a confidence field. S12. Map each semantic unit to a node and assign node attributes, including unique identifier, subject, relationship, object, dialogue turn identifier, core information marker, weight, timestamp, and confidence level. S13. Perform core information determination for each node. If a node meets one of the following conditions, then mark the core information of the node as true and fix the weight of the node to a preset maximum value. Condition 1: The number of times the same subject and relationship is explicitly emphasized or repeated by the user in the dialogue history reaches a preset threshold. Condition 2: The node belongs to the domain-predefined core fact base; Condition 3: The out-degree of the node in the dialogue state graph is greater than or equal to a preset dependency threshold. For nodes whose core information is marked as false, after each new round of dialogue, the weight of the node is updated in an exponential decay manner. When the weight is lower than the preset obsolescence threshold, the node is marked as an obsolescence node. S14. Calculate the similarity between subjects of different nodes using weighted Jaccard similarity, and establish temporal edges for nodes describing the same subject. A semantic vector model is used to encode the object of a node and the subject of another node into vectors, and cosine similarity is calculated. When the cosine similarity exceeds a preset similarity threshold, a logical edge is established.
3. The large model multi-round dialogue contradiction identification and correction method of claim 1, wherein, In step S2, performing semantic layer contradiction detection specifically includes the following sub-steps: S211. Traverse all node pairs in the dialogue state graph that have the same subject and the same relationship; S212. Extract the objects of node pairs and calculate the normalized edit distance similarity; S213. When the normalized edit distance similarity is less than the preset semantic consistency threshold, it is determined that the node pair has a semantic layer contradiction. The execution of constraint layer conflict detection specifically includes the following sub-steps: S221. In the dialogue state diagram, nodes belonging to the preset constraint type set are identified by matching the relationship field using regular expressions, thus forming a constraint node set. S222. For the response to be generated in the current round or the user's current input, parse the numerical value, entity, or action. S223. For each constraint node in the constraint node set, according to the relationship type of the constraint node, perform constraint satisfaction checks using the parsed values, entities, or actions, and record the nodes that violate the constraints to the violation set. S224. Calculate the constraint layer conflict score, which is the ratio of the number of violation cluster nodes to the number of constraint cluster nodes. When the constraint layer conflict score is greater than zero, a constraint layer conflict is triggered. The execution intent layer contradiction detection specifically includes the following sub-steps: S231. Input the historical dialogue into the large language model, extract the output vector of the last hidden layer before the output layer of the large language model, and take the hidden state of the last word as the historical intent vector; input the complete context into the large language model, extract the output vector of the last hidden layer before the output layer of the large language model, and take the hidden state of the last word as the current intent vector. Calculate the cosine similarity between the current intent vector and the historical intent vector; when the cosine similarity is less than a preset drift sensitivity threshold, trigger an intent drift conflict. S232. Maintain a dynamic intent tag set, and use a large language model to perform hierarchical classification of the current dialogue context to obtain the intent tags for the current round. The intent tag of the current round is compared with the intent tag of the previous round. If they are different, further judgment is made: if the intent tag of the current round belongs to the preset change type intent and the intent tag of the previous round does not belong to the preset change type intent, it is determined that the user actively changed the intent; otherwise, it is determined that the model's understanding is contradictory.
4. The large model multi-round dialogue contradiction identification and correction method of claim 1, wherein, In step S3, it is determined whether the current round is a user-initiated change based on the preset change pattern words in the user's input. Specifically, this includes: using regular expressions to match the preset change pattern word set in the user's current input; if the match is successful, it is determined to be a user-initiated change, the core information of the node corresponding to the new information is marked as true and updated to the dialogue state graph, and a confirmation reply is generated; if the match fails, it is determined to be a non-user-initiated change.
5. The large model multi-round dialogue contradiction identification and correction method according to claim 1, characterized in that, In step S3, a first-time locking strategy is used for semantic layer contradictions, a clarification generation strategy is used for constraint layer contradictions, and an annotation and recording strategy is used for intent layer contradictions, wherein: The initial locking strategy is as follows: find all nodes with the same subject and the same relationship as the current conflicting node in the dialogue state graph, select the node with the smallest timestamp as the initial node, replace the conflicting object value in the current response with the object value of the initial node, and obtain the corrected response. The clarification generation strategy is as follows: generate query statements based on the nodes that violate constraints detected in step S2. The query statements contain constraint content and conflict content, and output the query statements as the corrected response. The annotation and recording strategy is as follows: keep the original response content unchanged, and attach metadata annotations to the end of the original response content. The metadata annotations include intent drift identifiers, previous round intent tags, and current round intent tags.
6. The large model multi-round dialogue contradiction identification and correction method of claim 1, wherein, Step S4 calculates four scores and obtains a weighted composite result based on these four scores, specifically including: S411、From the dialogue state graph, obtain all core information markers as true nodes to form a core node set. For each core node, check whether there is information in the modified reply obtained in step S3 that conflicts with the object value of the core node. Define a conflict detection function that returns a first value when there is a conflict and a second value otherwise. Calculate the factual consistency score based on the conflict detection results of each core node The calculation expression is: wherein, is a set of core nodes, is a core node, is a revised reply, is a conflict detection function; S412、input the historical dialogue and the revised reply into a large language model to obtain a logical coherence score, and calculate a logical coherence score according to the logical coherence score The expression is calculated as wherein, is scored for logical coherence, is a pre-set maximum score; S413、using the large language model to calculate the perplexity of the modified reply The expression is calculated as wherein, is the revised response, is the number of wordpieces, is the conditional probability of each wordpiece; then the fluency score is normalized to obtain the fluency score , the calculation expression is: wherein, is a perplexity, is a preset reference perplexity, is a preset scaling factor; In S414, a constraint node set is obtained from the dialogue state graph, a constraint satisfaction check is performed on each constraint node, the number of nodes that violate constraints is counted, and a constraint satisfaction degree score is calculated according to the number of nodes that violate constraints and the constraint node set. The calculation expression is: wherein, is the number of nodes that violate the constraint, is the set of constraint nodes; S415, calculating a weighted sum of the four scores as a weighted composite result The expression is calculated as wherein, is a preset weight coefficient, is a factual consistency score, is a logical coherence score, is a fluency score, is a constraint satisfaction score.
7. The large model multi-round dialogue contradiction identification and correction method according to claim 1, characterized in that, In step S4, the output method or the triggering of a secondary correction process is determined based on the relationship between the weighted synthesis result and the preset threshold, specifically including the following sub-steps: S421. When the weighted synthesis result is greater than or equal to the first preset threshold, the corrected response is taken as the final output, and the correction strategy and weighted synthesis result of this round are stored as positive samples in the correction experience pool. S422. When the weighted comprehensive result is greater than or equal to the second preset threshold and less than the first preset threshold, the phrases or sentences in the corrected response that cause the factual consistency score or constraint satisfaction score to decrease are replaced with synonyms, the sentence structure is adjusted or information is supplemented, a new response is generated, and the weighted comprehensive result of the new response is recalculated. S423. When the weighted comprehensive result is less than the second preset threshold, a secondary correction process is triggered. The current corrected response and the weighted comprehensive result corresponding to the current corrected response are used as negative feedback. At the same time, the similarity threshold for semantic layer contradiction detection and the drift sensitivity threshold for intent layer contradiction detection are increased by a preset amount. Steps S2 to S4 are executed again, and the preset number of retries is retried. If it still fails, a preset safe response is output.
8. A large model multi-round dialogue contradiction identification and correction system, configured to implement the method of any one of claims 1 to 7, characterized in that, The system includes: The dialogue state tracking module is configured to extract semantic information from the user input or the output of the large language model in the current round after each round of dialogue, and to construct and update the dialogue state graph using an incremental update algorithm. The dialogue state graph includes a set of nodes and a set of edges. Each node corresponds to a semantic unit, and each semantic unit contains subject, relation, object and confidence information. The set of edges includes temporal edges and logical edges. A multi-level contradiction detection module is configured based on the updated dialogue state graph. It performs multi-level contradiction detection through a rule engine to obtain contradiction detection results. The multi-level contradiction detection includes semantic layer contradiction detection, constraint layer contradiction detection, and intent layer contradiction detection. The semantic layer contradiction detection is used to identify contradictions where the attribute values of the same entity are inconsistent in different rounds. The constraint layer contradiction detection is used to detect whether the current output or user intent violates the constraints previously set by the user. The intent layer contradiction detection is used to detect whether there is a deviation in the understanding of user intent by the large language model between different rounds. A progressive correction module is configured to, when the contradiction detection result indicates a contradiction, determine whether the current round is a user-initiated change based on the preset change pattern words in the user input. If it is a user-initiated change, the new information is updated as core information to the dialogue state diagram and a confirmation reply is generated. If it is not a user-initiated change, the corresponding correction strategy is executed according to the triggered contradiction level to obtain a corrected reply. The correction strategy includes: a first-time locking strategy for semantic layer contradictions, a clarification generation strategy for constraint layer contradictions, and an annotation and recording strategy for intent layer contradictions. The quality self-assessment module is configured to input the corrected response into the quality assessment model, calculate four scores, including: factual consistency score, logical coherence score, fluency score, and constraint satisfaction score, and then determine the output method or trigger a secondary correction process based on the relationship between the weighted comprehensive result of the four scores and a preset threshold.
9. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the large-model multi-turn dialogue contradiction identification and correction method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 9. When the computer program is executed by the processor, it implements the steps of the large-model multi-turn dialogue contradiction identification and correction method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Multi-round inquiry method and system based on large language model and session state tracking
CN121687564A
Dialogue intention recognition and correction method based on knowledge graph
CN121882190A