A dialogue chain multi-dimensional semantic enhancement method based on MCP agent negotiation and voting mechanism

By using the MCP agent negotiation and voting mechanism and a large language model to generate and score multiple candidate dialogue chains, the problem of insufficient autonomous expression and consensus decision-making in multi-agent systems is solved, and efficient multi-turn dialogue and high-quality response output are achieved.

CN120851040BActive Publication Date: 2026-06-26NANJING DOLPHIN INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANJING DOLPHIN INTELLIGENT TECH CO LTD
Filing Date
2025-07-17
Publication Date
2026-06-26

Smart Images

  • Figure CN120851040B_ABST
    Figure CN120851040B_ABST
Patent Text Reader

Abstract

The application provides a dialogue chain multi-dimensional semantic enhancement method based on MCP agent negotiation and voting mechanism, relates to the field of artificial intelligence, and comprises the following steps: outputting multiple candidate dialogue chains based on a large language model; performing multi-dimensional semantic enhancement on the multiple candidate dialogue chains to obtain multiple enhanced dialogue chains; outputting corresponding dialogue chain scores for each enhanced dialogue chain by each preset agent; screening multiple dialogue chain scores to obtain target consistency scores with score values greater than a preset ranking in the multiple dialogue chain scores; determining target dialogue chains corresponding to each target consistency score in the multiple enhanced dialogue chains; calculating the number of votes corresponding to each target dialogue chain, and outputting a target dialogue chain corresponding to the highest number of votes as an optimal dialogue chain. The application solves the problem that the existing multi-agent system is driven by a single control center to execute tasks, lacks autonomous expression and consensus decision mechanism of individual agents, and has the problem of low efficiency of multi-round dialogue.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence, and in particular to a method for multidimensional semantic enhancement of dialogue chains based on the MCP agent negotiation and voting mechanism. Background Technology

[0002] With the continuous integration of artificial intelligence, especially large language model (LLM) and multi-agent cooperative (MCP) technologies, multi-agent systems are gradually evolving from task-execution architectures to complex swarm intelligence architectures with cognitive collaboration capabilities.

[0003] Current multi-agent systems are widely used in scenarios such as task collaboration, knowledge-based question answering, and dialogue systems. However, existing multi-agent systems mostly rely on a single control center to drive agents to perform tasks, lacking autonomous expression and consensus decision-making mechanisms for individual agents, resulting in inefficient multi-turn dialogues.

[0004] Therefore, there is an urgent need for a method to enhance the multidimensional semantics of dialogue chains based on the MCP agent negotiation and voting mechanism. Summary of the Invention

[0005] This application provides a method for multidimensional semantic enhancement of dialogue chains based on the MCP agent negotiation and voting mechanism. It solves the problem that existing multi-agent systems mostly drive agents to perform tasks through a single control center, lack autonomous expression and consensus decision-making mechanisms for individual agents, and suffer from low efficiency in multi-round dialogues.

[0006] The first aspect of this application provides a method for multi-dimensional semantic enhancement of dialogue chains based on an MCP agent negotiation and voting mechanism. The method includes: inputting the target input structure into a large language model and outputting multiple candidate dialogue chains based on the large language model; constructing a preset rule base and performing multi-dimensional semantic enhancement on the multiple candidate dialogue chains based on the preset rule base to obtain multiple enhanced dialogue chains; outputting a corresponding dialogue chain score for each enhanced dialogue chain through each preset agent; filtering the multiple dialogue chain scores to obtain a target consistency score among the multiple dialogue chain scores that is greater than a preset ranking; determining the target dialogue chain corresponding to each target consistency score among the multiple enhanced dialogue chains; calculating the number of votes corresponding to each target dialogue chain based on the negotiation and voting mechanism, and outputting the target dialogue chain with the highest number of votes as the optimal dialogue chain.

[0007] Optionally, the target input structure is input into a large language model, and multiple candidate dialogue chains are output based on the large language model. Specifically, this includes: obtaining the global target task, the current round of dialogue context, and agent ontology information as the target input structure; constructing a knowledge graph query module, a named entity recognition module, and a relation extraction module; obtaining key entity information in the target input structure based on the named entity recognition module; obtaining potential semantic relationships between key entity information based on the relation extraction module; dynamically matching predefined query templates based on key entity information and potential semantic relationships, and outputting query conditions. The predefined query templates include SPARQL query templates and Cypher query templates; obtaining structured knowledge fragments that meet the matching requirements through the knowledge graph query module based on the query conditions; and inputting the structured knowledge fragments into the large language model based on the knowledge enhancement prompt template to output multiple candidate dialogue chains.

[0008] Optionally, based on the knowledge-enhanced prompt template, structured knowledge fragments are input into the large language model to output multiple candidate dialogue chains. Specifically, this includes: constructing a knowledge-enhanced prompt template based on the task type of the global target task; dynamically filling the generated prompt content with the structured knowledge fragments according to the corresponding knowledge-enhanced prompt template; calling the large language model using the enhanced generated prompt content; and outputting multiple candidate dialogue chains based on the large language model.

[0009] Optionally, multi-dimensional semantic enhancement is performed on multiple candidate dialogue chains, specifically including: performing multi-dimensional semantic enhancement on multiple candidate dialogue chains, including syntactic enhancement of candidate dialogue chains through a syntactic analyzer, discourse behavior enhancement of candidate dialogue chains through a model discourse behavior classifier, and structural consistency enhancement of candidate dialogue chains through dialogue structure templates applicable to different task scenarios.

[0010] Optionally, each enhanced dialogue chain is scored by a pre-defined agent, specifically including: scoring the enhanced dialogue chain in multiple dimensions by the pre-defined agents, including semantic similarity score, context consistency score, and knowledge consistency score, wherein the knowledge consistency score includes entity consistency score, relation consistency score, attribute consistency score, and context consistency score; constructing an agent reputation value function, and calculating a weighted average of the semantic similarity score, context consistency score, knowledge consistency score, and agent reputation value function to output the dialogue chain score.

[0011] Optionally, before calculating the number of votes for each target dialogue chain based on the negotiation and voting mechanism, and outputting the target dialogue chain with the highest number of votes as the optimal dialogue chain, it is necessary to construct a negotiation and voting mechanism, specifically including: constructing a negotiation and voting mechanism based on at least one of the following methods, including: weighted majority voting mechanism, game-theoretic negotiation mechanism, and reputation priority mechanism.

[0012] Optionally, when the negotiation and voting mechanism is a weighted majority voting mechanism, the number of votes corresponding to each target dialogue chain is calculated based on the negotiation and voting mechanism, and the target dialogue chain corresponding to the highest number of votes is output as the optimal dialogue chain. Specifically, this includes: obtaining the reputation value corresponding to each preset agent; performing weighted voting on each target dialogue chain through each preset agent based on the reputation value; and outputting the target dialogue chain corresponding to the maximum number of votes in the weighted voting results as the optimal dialogue chain.

[0013] Optionally, when the negotiation and voting mechanism is a game-theoretic negotiation mechanism, the number of votes corresponding to each target dialogue chain is calculated based on the negotiation and voting mechanism, and the target dialogue chain with the highest number of votes is output as the optimal dialogue chain. Specifically, this includes: initializing the voting preference distribution corresponding to each preset agent based on the scoring results of each preset agent on the target dialogue chain, where the voting preference distribution represents the voting probability of the preset agent on each target dialogue chain; during each round of the game, a global voting distribution is formed by summing the voting preferences of all preset agents; each preset agent updates its corresponding voting preference distribution based on the global voting distribution; normalization is performed on the updated voting preference distribution in each round, and the process is iterated until the global voting distribution meets the convergence criteria; and the target dialogue chain with the highest concentration of voting preferences in the final convergence round is output as the optimal dialogue chain.

[0014] Optionally, when the negotiation and voting mechanism is a reputation-first mechanism, the number of votes corresponding to each target dialogue chain is calculated based on the negotiation and voting mechanism, and the target dialogue chain with the highest number of votes is output as the optimal dialogue chain. Specifically, this includes: obtaining the reputation value corresponding to each preset agent, and obtaining the target agents that meet the preset ranking conditions based on the ranking of the reputation values; voting for each target dialogue chain by each target agent, and counting the voting results; and outputting the target dialogue chain with the highest number of votes in the voting results as the optimal dialogue chain.

[0015] Optionally, after calculating the number of votes for each target dialogue chain based on the negotiation and voting mechanism, and outputting the target dialogue chain with the highest number of votes as the optimal dialogue chain, the method further includes: performing a group consensus assessment on the voting results of the negotiation and voting mechanism according to a preset method, which includes the Gini coefficient calculation method and the entropy calculation method; if the group consensus assessment does not meet the preset assessment conditions, then performing operations including but not limited to the following: re-performing the negotiation and voting mechanism, or directly deciding to select the optimal dialogue chain through an arbitration agent; if the group consensus assessment meets the preset assessment conditions, then the optimal dialogue chain is taken as the final output.

[0016] A second aspect of this application provides a multi-dimensional semantic enhancement device for dialogue chains based on the MCP agent negotiation and voting mechanism. The device includes a dialogue chain generation module, a dialogue chain enhancement module, a dialogue chain scoring module, and a dialogue chain output module, wherein...

[0017] The dialogue chain generation module is used to input the target input structure into a large language model and output multiple candidate dialogue chains based on the large language model.

[0018] The dialogue chain enhancement module is used to build a preset rule base and perform multi-dimensional semantic enhancement on multiple candidate dialogue chains based on the preset rule base to obtain multiple enhanced dialogue chains.

[0019] The dialogue chain scoring module is used to output a corresponding dialogue chain score for each enhanced dialogue chain through various preset agents.

[0020] The dialogue chain output module is used to filter multiple dialogue chain scores, obtain the target consistency score among the multiple dialogue chain scores with a score value greater than the preset ranking; determine the target dialogue chain corresponding to each target consistency score among multiple enhanced dialogue chains; calculate the number of votes corresponding to each target dialogue chain based on the negotiation and voting mechanism, and output the target dialogue chain corresponding to the highest number of votes as the optimal dialogue chain.

[0021] A third aspect of this application provides an electronic device including a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described above.

[0022] A fourth aspect of this application provides a computer-readable storage medium storing a computer program, which is executed by a processor using the method described in any of the foregoing descriptions.

[0023] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:

[0024] 1. Input the target input structure into a large language model and output multiple candidate dialogue chains based on the large language model; construct a preset rule base and perform multi-dimensional semantic enhancement on the multiple candidate dialogue chains based on the preset rule base to obtain multiple enhanced dialogue chains; output the corresponding dialogue chain score for each enhanced dialogue chain through each preset agent; filter the multiple dialogue chain scores and obtain the target consistency score with a score value greater than the preset ranking among the multiple dialogue chain scores; determine the target dialogue chain corresponding to each target consistency score among the multiple enhanced dialogue chains; calculate the number of votes corresponding to each target dialogue chain based on the negotiation and voting mechanism, and output the target dialogue chain with the highest number of votes as the optimal dialogue chain, thereby improving the knowledge accuracy and semantic consistency of the candidate content, realizing multi-agent collaborative expression optimization oriented towards task objectives, and solving problems such as unfocused response content, redundant and conflicting individual outputs, and lack of consensus convergence path in traditional multi-turn dialogue.

[0025] 2. Based on the task type of the global target task, construct knowledge enhancement prompt templates; dynamically fill the generated prompt content with structured knowledge fragments according to the corresponding knowledge enhancement prompt templates; use the enhanced generated prompt content to call the large language model, and output multiple candidate dialogue chains based on the large language model, thereby improving the performance of the content generated by the large language model in terms of professionalism, structural integrity and task fit, and enhancing the controllability and knowledge coverage depth of the multi-agent generated expression.

[0026] 3. Construct a negotiation and voting mechanism based on at least one of the following methods: weighted majority voting mechanism, game-theoretic negotiation mechanism, and reputation priority mechanism, so as to realize the dynamic fusion and credible evaluation of the expression content among multiple agents, improve the efficiency of group consensus and the decision quality of the optimal response output, and effectively avoid response bias, conflict imbalance or the neglect of high-quality expression. Attached Figure Description

[0027] Figure 1 This is a flowchart illustrating a method for multidimensional semantic enhancement of dialogue chains based on the MCP agent negotiation and voting mechanism provided in an embodiment of this application.

[0028] Figure 2 This is a schematic diagram of a multidimensional semantic enhancement device for a dialogue chain based on the MCP agent negotiation and voting mechanism provided in an embodiment of this application;

[0029] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0030] Explanation of reference numerals in the attached diagram: 21. Dialogue chain generation module; 22. Dialogue chain enhancement module; 23. Dialogue chain scoring module; 24. Dialogue chain output module; 301. Processor; 302. Communication bus; 303. User interface; 304. Network interface; 305. Memory. Detailed Implementation

[0031] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.

[0032] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to and includes any or all possible combinations of one or more of the listed items.

[0033] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0034] To enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings.

[0035] Please refer to Figure 1 The diagram illustrates a flowchart of a multi-dimensional semantic enhancement method for dialogue chains based on the MCP agent negotiation and voting mechanism provided in this application embodiment. The flowchart mainly includes the following steps: S101 to S106.

[0036] Step S101: Input the target input structure into the large language model, and output multiple candidate dialogue chains based on the large language model.

[0037] Specifically, during the current round of dialogue, the target input structure is obtained and input into the large language model, which then generates multiple candidate dialogue chains.

[0038] In one possible implementation, step S101 further includes: acquiring the global target task, the current round of dialogue context, and agent ontology information as the target input structure; constructing a knowledge graph query module, a named entity recognition module, and a relation extraction module; acquiring key entity information in the target input structure based on the named entity recognition module; acquiring potential semantic relationships between key entity information based on the relation extraction module; dynamically matching predefined query templates based on key entity information and potential semantic relationships, and outputting query conditions, the predefined query templates including SPARQL query templates and Cypher query templates; acquiring structured knowledge fragments that meet the matching requirements through the knowledge graph query module based on the query conditions; and inputting the structured knowledge fragments into the large language model based on the knowledge enhancement prompt template to output multiple candidate dialogue chains.

[0039] Specifically, the target input structure includes, but is not limited to, the following three parts: the global target task, the current dialogue context, and the agent ontology information. Each part constitutes the core supporting information for the input prompt content, and its specific structure and semantic meaning are as follows:

[0040] The global objective task refers to the overall semantic goal or functional instruction that the current multi-agent collaborative system needs to complete in a dialogue scenario. It is usually encoded using a structured task representation method (such as JSON format). Its content includes the type of objective task (such as technical question answering, decision assistance, information clarification, etc.), objective intent (such as obtaining suggestions, proposing solutions, completing diagnosis, etc.), task decomposition units (such as a list of sub-tasks to be completed), evaluation criteria (such as merit weights, consistency indicators, response conditions, etc.), and priority attributes (such as labels for high-priority objectives). This part serves as a unified semantic driving benchmark for all agents when generating dialogue chains, ensuring that the generated content is convergent and the objective is consistent.

[0041] The current round of dialogue context refers to the history of dialogue states and interaction trajectories that need to be referenced in the current dialogue round. It is usually represented by a sequence structure and includes historical question-answer pairs (such as pairs of content between previous user questions and system responses), dialogue state labels (such as the intent recognition results and state transition flags for each round), contextual entity annotation results (such as domain terms and professional keywords obtained from named entity recognition), dialogue referential relationship chains (such as pronoun anaphora mapping), and turn number and timestamp information. The above contextual information together constitutes the contextual constraints and semantic coherence guarantee basis when the language model generates candidate chains.

[0042] Agent ontology information refers to the structural attributes and individual preferences possessed by each MCP agent during task processing. This primarily includes domain-specific tags (such as identifiers for finance, healthcare, and education), the scope of the knowledge graph index (i.e., the knowledge subgraphs or retrieval entry points possessed by the agent), language expression style preferences (such as formal / colloquial, level of detail, and stylistic bias), and role behavior parameters (such as whether the agent prefers to offer suggestions, confirm facts, or has a tendency to deny). Agent ontology information is used to guide each agent in generating differentiated candidate dialogue chains when faced with the same input structure, thereby achieving a balance between diverse expression and collaborative consensus.

[0043] After the target input structure is input, the named entity recognition module is first invoked to extract entities from the current round of dialogue context, identifying key entity information, including but not limited to names of people, places, organizations, product names, technical terms, and numerical indicators. The named entity recognition module preferably uses a model based on the BERT-CRF architecture, combining a pre-trained language model with conditional random fields for sequence labeling, outputting structured entity recognition results to build the foundation for subsequent entity queries in the knowledge graph.

[0044] After identifying key entities, the relation extraction module is invoked to identify the latent semantic relationships between these entities. Contextual semantic representations are obtained using the BERT model, and relation triples between entities are output via the Softmax relation classifier. These triples are in the form of (subject, relation, object), encompassing mapping items that conform to the semantics of knowledge graph relations, such as "manufacturer relationship," "applicable scenario," and "publishing information." The named entity recognition module and the relation extraction module work together to form a knowledge requirement analysis subsystem, used to dynamically generate knowledge graph query conditions.

[0045] Based on the identified key entities and relational semantics, a standard query statement is constructed by matching a pre-defined SPARQL query template or a Cypher query template. The SPARQL template is used to access the RDF / OWL structured knowledge platform, while the Cypher template is used to access the Neo4j-based graph database platform. Entity information is replaced and filled into the named entity placeholders in the query statement, and relational intents are mapped to query attributes or edge types. Implicit query targets can be further supplemented by combining the intent of the current round of dialogue, such as introducing "competitive relationships" or "evaluation metrics" as enhancement conditions. The constructed query statement is executed through the knowledge graph query module to obtain structured knowledge fragments. These fragments contain entity attributes (such as launch date, manufacturer), entity relationships (such as applicable scenarios, competing products), and their associated value items.

[0046] The structured knowledge fragments returned by the query are mapped and populated into a predefined knowledge-enhanced prompt template to form a knowledge-enhanced prompt input. This prompt template is determined based on the target task type and dialogue intent, and includes template elements such as attribute slots, entity slots, and expression style instructions. By dynamically injecting knowledge fragments into the template slots, a complete generated prompt content containing factual support and semantic instructions is constructed. This content is then input into a large language model to generate candidate dialogue chains, thereby achieving semantic control and professional consistency improvement based on external knowledge supplementation. This process ensures that the generated candidate dialogue chains not only conform to the current context constraints and task intent, but also demonstrate accurate referencing of structured knowledge and professional expression, forming a high-quality input foundation for subsequent consistency scoring and negotiation voting processing of the candidate chains.

[0047] In one possible implementation, step S101 further includes: constructing a knowledge enhancement prompt template based on the task type of the global target task; dynamically filling the generated prompt content with structured knowledge fragments according to the corresponding knowledge enhancement prompt template; calling the large language model using the enhanced generated prompt content; and outputting multiple candidate dialogue chains based on the large language model.

[0048] Specifically, in one possible implementation, step S101 further includes: constructing a knowledge-enhanced prompt template based on the task type of the global target task; dynamically filling the generated prompt content with structured knowledge fragments according to the corresponding knowledge-enhanced prompt template; using the enhanced generated prompt content to call a large language model, and outputting multiple candidate dialogue chains based on the large language model. The construction process depends on the semantic features of the task type, the required content slots, and the pragmatic style requirements. Differentiated prompt templates are constructed for different task types as follows:

[0049] When the global objective task is a technical question-and-answer task, the constructed knowledge-enhanced prompt template typically includes a question restatement unit, a knowledge background instruction unit, and an answer style constraint unit. The question restatement unit guides the large language model to focus on the question's core. The knowledge background instruction unit lists key attributes extracted from structured knowledge fragments, such as "product name," "release date," "applicable scenario," and "competitor information," presented in a standardized format. The answer style constraint unit prompts the language model to output a formal, concise, and technically accurate answer. For example, the template structure is as follows: "Generate a professional and accurate answer based on the following knowledge background: Knowledge Background: Product Name: {entity}, Launch Date: {launch_date}, Applicable Scenario: {applicable_scenario}, Competitor Information: {competitor_info}. Current Question: {current_user_query}. Please ensure formal language style and clear logic."

[0050] When the task type is decision support, the knowledge enhancement prompt template is built around the core structure of "option guidance + comparison criteria + recommendation output". First, it lists multiple comparable entities (such as products and solutions) through structured fragments. Second, it sets evaluation indicator slots (such as performance, cost, applicability, etc.). Finally, it explicitly instructs the model to make a rational recommendation and output the reasons. For example, the template structure is: "Based on the following solution information, compare them from the {evaluation_criteria} dimension, recommend the optimal solution, and explain the reasons. Solution list: Solution A: {option_A_info}, Solution B: {option_B_info}. Please output the recommendation results and provide a concise analysis."

[0051] When the task type is instructional explanation, the template emphasizes a three-part structure of "introduction-explanation-summary," with structured knowledge fragments used to fill in the core teaching content (such as definitions, principles, and application scenarios) to guide the language model in outputting content in a layered manner. For example, the template structure is: "Please conduct an instructional explanation of the following concepts, including introduction, core explanation, and summary. Teaching knowledge: Concept name: {concept}, Principle points: {principle}, Application examples: {application_example}. The language should be concise and clear, suitable for non-specialist readers."

[0052] When the task type is information clarification, the template emphasizes the construction of comparison and error correction mechanisms. Structured knowledge fragments are used to identify correct information, and the output is compared with the original question or misunderstanding, prompting the language model to correct content deviations. A template structure is as follows: "The user's current question has a misunderstanding. Please clarify based on the following facts: Correct information: Product model: {entity}, Release date: {launch_date}, Feature: {feature_info}. Current question: {user_misunderstanding}. Please generate a clarification and guide the user to understand the correct viewpoint."

[0053] When the task type is opinion negotiation, the template design emphasizes position labeling, supporting arguments, and multi-round guidance. Structured knowledge fragments are used to fill in supporting / opposing reasons, guiding the large language model to generate expressive content with dialogue strategies and semantic extensibility. A template structure is as follows: "Based on the following information supporting the viewpoint, please generate a statement of assertion and raise negotiable follow-up questions. Supporting evidence: {evidence}, dialogue context: {dialogue_context}. Please output your position statement and guide the other party to further respond."

[0054] Under the above-mentioned task types, structured knowledge fragments and task-oriented templates work together to generate prompts. Each prompt is dynamically populated and then used as a Prompt input into the large language model to generate multiple candidate dialogue chains with semantic accuracy, knowledge credibility, and style fit, for use by subsequent consistency scoring and voting mechanisms.

[0055] Step S102: Construct a preset rule base, and perform multi-dimensional semantic enhancement on multiple candidate dialogue chains based on the preset rule base to obtain multiple enhanced dialogue chains.

[0056] Specifically, by constructing a pre-defined rule base and performing multi-dimensional semantic enhancement on multiple candidate dialogue chains based on this rule base, the semantic integrity, interaction rationality, and knowledge credibility of the candidate dialogue chains can be improved. The rule base includes, but is not limited to, grammatical rules, discourse behavior rules, structural template rules, and domain-specific rules.

[0057] Grammar rules: Grammar rules are used to ensure the standardization of candidate dialogue chains in language expression, avoiding grammatical errors, ambiguities, or incomplete expressions. These mainly include: Syntactic integrity rules: checking whether sentences contain basic components such as subject, predicate, and object, and whether there are incomplete or broken sentences; Ambiguous sentence detection rules: checking for grammatical ambiguity (such as unclear pronoun reference or long-distance dependency errors); Redundant expression detection rules: checking for repetitive information and lengthy expressions, and suggesting optimization and compression; Complex sentence structure standardization rules: marking and standardizing complex sentence relationships such as parallel, adversative, causal, and conditional clauses to ensure logical clarity; Voice and tense consistency rules: verifying the consistency of tense and voice between main clauses and subordinate clauses, and within sentences.

[0058] Discourse Behavior Rules: Discourse behavior rules are used to ensure that candidate dialogue chains are consistent with the current dialogue intent plan at the pragmatic level, enhancing the naturalness of interaction and the coherence of intent. They mainly include: Discourse Behavior Classification Rules: Candidate dialogue chains are classified into the following discourse behavior types: Question, Statement, Suggestion, Request, Confirmation, Rebuttal, Thanking, etc.; Figure 1 Consistency Rule: Checks whether the discourse behaviors in the candidate dialogue chain match the planned dialogue intent. For example, if the current round's intent is "Suggestion Proposal," the candidate chain should contain suggestive expressions; if there are a large number of information query expressions, it is considered an intention deviation. Behavior Sequence Reasonableness Rule: Based on the dialogue context, restricts illegal discourse behavior sequences. If two consecutive rounds consist of confirmation requests, it suggests introducing new information behaviors (such as asking questions or making statements) to drive the dialogue forward.

[0059] Structural Template Rules: Structural template rules are used to ensure that the candidate dialogue chain meets the expected task-oriented dialogue requirements in terms of overall chapter structure. These mainly include: Task Type Templates: Templates are defined for different dialogue tasks (such as teaching, technical Q&A, and decision assistance). For example: Teaching: "Introduction → Explanation → Summary"; Technical Q&A: "Question Restatement → Analysis → Response"; Decision Assistance: "Option Listing → Advantages and Disadvantages Analysis → Recommendation"; Paragraph / Content Unit Requirements: Each template specifies the required paragraph units and their order. The candidate dialogue chain must cover all requirements; if any are missing, they are supplemented through a template filling mechanism; Logical Relationship Constraint Rules: Logical relationships between paragraphs are validated, such as the evaluation of advantages and disadvantages must precede the final recommendation.

[0060] Domain-Specific Rules: Domain-specific rules are used to ensure the professionalism and knowledge consistency of candidate dialogue chains within a specific application domain. These mainly include: Domain Terminology Standardization Rules: Mandating the use of standardized terminology in candidate dialogue chains to avoid colloquial or non-standard expressions. For example, the medical field requires the use of ICD-10 coded standard terminology; Factual Consistency Rules: Verifying factual statements (entities, relationships) involved in the candidate chain using a knowledge graph (such as Neo4j + SPARQL queries), and lowering the score and weight when false or inconsistent statements are found; Style Standardization Rules: Specifying the expected language style within the domain, such as academic, formal, or concise, and performing style matching evaluation on the candidate chain; Sensitive Information Filtering Rules: Maintaining prohibited sensitive words and taboo topics within the domain through a rule base, filtering or rewriting if they appear in the candidate chain.

[0061] In one possible implementation, step S102 further includes: performing multi-dimensional semantic enhancement on multiple candidate dialogue chains. The multi-dimensional semantic enhancement includes performing syntactic enhancement on the candidate dialogue chains through a syntactic analyzer, performing discourse behavior enhancement on the candidate dialogue chains through a model discourse behavior classifier, and performing structural consistency enhancement on the candidate dialogue chains through dialogue structure templates applicable to different task scenarios.

[0062] Syntactic enhancement: The SpaCy parser is used to perform dependency parsing on candidate dialogue chains; it checks whether they conform to predefined syntax tree rules (whether they contain necessary subject-verb-object structures; whether they avoid ambiguous clauses; whether there are redundant or incoherent structures); if they conform to the rules, they are automatically adjusted or marked as low-priority candidates.

[0063] Voice Action Enhancement: A fine-tuned BERT model voice action classifier is used to identify voice actions in candidate dialogue chains, categorized as (Question, Statement, Suggestion, Request, Confirmation). The system verifies whether the voice action matches the dialogue intent plan in the current dialogue context. The dialogue intent plan is dynamically generated by the agent before generating candidate dialogue chains, based on the current dialogue context and the global task goal, through the following methods: 1. Defining a dialogue intent library: The system maintains a predefined dialogue intent library based on task types. Intents include, but are not limited to: InformationSeeking, IntentConfirmation, OpinionExpression, SuggestionProposal, and DecisionSupport. II. Intent Inference Module: Before each round of dialogue, the IntentInferenceModule dynamically generates an intent plan for that round based on: the current round's context (including historical question-and-answer sessions and multi-round state tracking); and the global task objective (AgentProfile, such as domain of expertise and preferences). This is achieved through a Large Language Model (LLM) combined with an intent inference prompt template. The format can be structured JSON. III. Intent Plan Distribution and Sharing: The generated dialogue intent plan serves as auxiliary input when generating candidate dialogue chains for the current round. It is passed to each MCP agent and used in the rule enhancement module to verify whether the candidate chains match the intended dialogue. Figure 1 To.

[0064] Enhanced Dialogue Structure Templates: Based on the current task objectives, select appropriate dialogue structure templates. For example, use an "introduction-explanation-summary" structure for instructional dialogues; a "question-analysis-answer" structure for technical Q&A; and a "option presentation-advantages and disadvantages evaluation-recommendation" structure for decision-making discussions. Forcefully verify that the candidate chain covers all paragraphs or content units required by the template. Supplement missing units through a template-filling mechanism.

[0065] Domain knowledge consistency enhancement: The knowledge graph verification module is activated to perform consistency checks on entities and relationships in the candidate chain. Rules include: whether entity references are correct (e.g., product names, terminology); whether relationship statements are consistent with facts in the knowledge graph; and whether there are logical contradictions or false information.

[0066] Step S103: Each preset agent outputs a corresponding dialogue chain score for each enhanced dialogue chain.

[0067] Specifically, the enhanced dialogue chain is scored in multiple dimensions by a pre-set intelligent agent. The multi-dimensional scores include semantic similarity score, context consistency score, and knowledge consistency score. The knowledge consistency score includes entity consistency score, relation consistency score, attribute consistency score, and context consistency score.

[0068] Entity Consistency Score: The entity consistency score is used to evaluate whether entities in the augmented dialogue chain match known entities in the knowledge graph. Scoring Criteria: Complete Match: The entity mentioned in the augmented dialogue chain completely matches an entity in the knowledge graph (e.g., the product name "Smart Home Product A" matches the name stored in the graph) → Score 1. Partial Match: The entity name or description in the augmented dialogue chain does not completely match the entity in the graph (e.g., slight spelling or description differences) → Score 0.5. No Match: The entity in the augmented dialogue chain has no corresponding entity in the knowledge graph → Score 0.

[0069] Relationship Consistency Score: The relationship consistency score is used to evaluate whether the relationships between entities in the augmented dialogue chain conform to the predefined relationships in the knowledge graph. Scoring Criteria: Complete Consistency: The relationships between entities described in the augmented dialogue chain are completely consistent with the relationships defined in the knowledge graph (e.g., the relationship between "Smart Home Product A" and "Applicable Scenarios" is clearly stated in the graph) → Score 1. Partial Consistency: The relationships between entities described in the augmented dialogue chain are not completely consistent with the relationships in the graph (e.g., there are discrepancies in the relationship type or attribute description) → Score 0.5. Inconsistency: The relationships described in the augmented dialogue chain do not match in the knowledge graph or have significant semantic conflicts (e.g., a candidate chain mentions that "Smart Home Product A" is applicable to the "Automobile" scenario, but there is no such description in the graph) → Score 0.

[0070] Attribute Consistency Score: The attribute consistency score is used to evaluate whether the entity attribute values ​​in the augmented dialogue chain are consistent with the entity attribute values ​​in the knowledge graph. Scoring Criteria: Complete Consistency: The entity attribute described in the augmented dialogue chain is completely consistent with the value in the knowledge graph (e.g., the launch date of "Smart Home Product A" is "May 2022," which is consistent with the graph) → Score 1. Partial Consistency: The entity attribute in the augmented dialogue chain differs somewhat from the attribute value in the graph (e.g., the candidate chain mentions that "Smart Home Product A" was launched in "2021," while the graph states "2022") → Score 0.5. Inconsistency: The attribute in the augmented dialogue chain is inconsistent with the attribute in the graph or has no corresponding attribute (e.g., the candidate chain incorrectly mentions that the price of "Smart Home Product A" is "100 yuan," but the graph states "500 yuan") → Score 0.

[0071] Contextual Consistency Score: The contextual consistency score assesses whether the contextual information in the enhanced dialogue chain matches the context inferred from the knowledge graph. Scoring Criteria: Consistent: The content of the enhanced dialogue chain is completely consistent with the context or event sequence inferred from the graph (e.g., the context that "Smart Home Product A" is applicable to "Smart Home Scenarios" perfectly matches the graph's inference) → Score 1. Partially Consistent: There are some differences between the enhanced dialogue chain and the context inferred from the graph, but these are tolerable (e.g., the description of the applicable scenario differs slightly from the graph, but does not affect understanding) → Score 0.5. Inconsistent: The context of the enhanced dialogue chain is completely inconsistent with the inference in the graph (e.g., classifying a specific product into different application scenarios) → Score 0.

[0072] Knowledge Consistency Total Score: This score is a weighted average of the four scores above, calculated using preset weights. The weights can be adjusted for different application scenarios; for example, entity consistency score, relation consistency score, attribute consistency score, and context consistency score can each have a weight of 25%. Total Score Formula: Knowledge Consistency Total Score = (Entity Consistency Score x 0.25) + (Relationship Consistency Score x 0.25) + (Attribute Consistency Score x 0.25) + (Context Consistency Score x 0.25). Range: The score ranges from 0 to 1, where 0 indicates that the enhanced dialogue chain is completely inconsistent with the knowledge graph, and 1 indicates complete consistency.

[0073] A trust score function is constructed to calculate the dialogue chain score by weighted averaging of semantic similarity score, context consistency score, knowledge consistency score, and the trust score function. Since each MCP (Multi-Agent Cooperative agent) independently generates one or more enhanced dialogue chains based on its own perspective and knowledge in the above steps, the system will face different expression suggestions from multiple agents. To find the most semantically reasonable, task-appropriate, and knowledge-consistent chain among these candidate solutions, and to ensure that the result reflects collective wisdom rather than individual bias, a group negotiation and voting mechanism must be introduced to achieve consensus formation and optimal output selection among agents without relying on central control. Each agent scores other enhanced dialogue chains, considering factors such as semantic similarity to the target task (e.g., using BERTScore), context consistency (e.g., using a dialogue consistency model / NLI model), and the trust score of the candidate chain generator. The optimal candidate chain (Consensus Dialogue Chain) for the current round is selected based on the voting results and used either as a unified response in the system output or as input for the next round of LLM to drive multi-round dialogue evolution.

[0074] Step S104: Filter the multiple dialogue chain scores and obtain the target consistency score among the multiple dialogue chain scores whose score value is greater than the preset ranking.

[0075] Specifically, collect the set of all enhanced dialogue chains generated by the MCP agents in the above steps. Assume there are N agents in the current round, and each agent... generate These enhanced dialogue chains are aggregated to form a set C= .in . This represents the total number of enhanced dialogue chains, which is the total number of enhanced dialogue chains generated by all MCP agents. This indicates the number of agents participating in the collaboration in the current round. This represents the number of enhanced dialogue chains generated by the i-th agent. It is the sum of the number of enhanced dialogue chains generated by all agents. Each agent considers all enhanced dialogue chains in the candidate pool. The dialogue chain score is obtained by assigning a score, and the scoring formula is as follows:

[0076]

[0077] in, The objective consistency score given by the i-th agent to the j-th enhanced dialogue chain. The semantic similarity score for the j-th enhanced dialogue chain is... For the context consistency score of the j-th enhanced dialogue chain, To score for knowledge consistency, Let α, β, γ be the agent's reputation value function. These are weighting coefficients that can be dynamically adjusted based on the application scenario.

[0078] Semantic similarity score In this invention, the semantic similarity score is used to measure the degree of semantic matching between the enhanced dialogue chain and the system-defined task goal, denoted as:

[0079]

[0080] in, To describe the target text for structured tasks, the semantic similarity calculation function is implemented as follows: based on BERT vector cosine similarity, the pre-trained language model BERT is used to enhance the dialogue chain. With mission objectives Each is encoded as a vector: , Calculate the cosine similarity between the two. For advanced deep learning models used in Natural Language Processing (NLP) tasks:

[0081]

[0082] The score range is [0,1] and can be directly used as... .

[0083] Context consistency score : Measuring Enhanced Dialogue Chains Whether it maintains logical and semantic consistency with the current round's dialogue context. The goal is to avoid: newly generated candidate chains "jumping to a topic"; logical contradictions; and violations of the dialogue history's intent / state. Calculation method: using an NLI model (Natural Language Inference Model). Principle: Using the context as a premise. Enhancing the dialogue chain... As a hypothesis, the NLI model is used to determine whether the context implies and supports the candidate chain. Common NLI model structure: Input: (Context, Output: Three types of labels: Entailment → Consistent; Neutral → Partially Consistent; Contradiction → Inconsistent. Corresponding scoring mapping:

[0084]

[0085] Tool examples: Commonly used NLI models: Roberta-large-mnli, Deberta-v3-mnli, Bert-mnli, etc.

[0086] Knowledge Consistency Score The following has been explained in detail in step S103.

[0087] Agent reputation value function : Generate the reputation value of the candidate chain agent, where It is the j-th enhanced dialogue chain, which belongs to a certain intelligent agent. Generated. Which agent generated this candidate chain? The agent reputation value function is used to reflect the reputation of each agent. The overall performance quality across multiple rounds of historical collaboration. The goal is to: trust agents with a good historical performance → give them greater voting weight; and suppress agents that frequently output low-quality results → reduce their voting influence. Agent reputation value function implementation:

[0088]

[0089] in, Intelligent agent The proportion of candidate chains that were ultimately selected in the historical rounds (number of rounds selected / total number of rounds participated in). Intelligent agent Historical average knowledge consistency score; Intelligent agent Historical average contextual consistency score; Arbitration / human feedback score (positive is positive, negative is negative); Weighting coefficients can be configured according to the use case, ensuring that the weights of each contribution are reasonable. Ultimately... Normalized to the [0,1] interval, it serves as the voting weight of the agent in the weighted majority voting. The higher the Trust, the greater the voting influence.

[0090] Each agent Scoring of all candidate chains Normalization is performed to form a standardized scoring matrix. After that, each intelligent agent The target consistency score is selected from the dialogue chain scores, and those scores are greater than the preset ranking. The preset ranking can be set according to the number of enhanced dialogue chains; this application does not limit the setting of the preset ranking. For example, for the first... An agent provides N dialogue chain scores, with a preset ranking set to K. The N dialogue chain scores are then sorted from largest to smallest, and the top K largest dialogue chain scores are taken as the target consistency scores with scores greater than the preset ranking.

[0091] Step S105: Determine the target dialogue chain corresponding to each target consistency score in multiple enhanced dialogue chains.

[0092] Specifically, according to the description of step S104, the enhanced dialogue chain corresponding to the target consistency score with a score value greater than the preset ranking is obtained as the target dialogue chain.

[0093] Step S106: Calculate the number of votes for each target dialogue chain based on the negotiation and voting mechanism, and output the target dialogue chain with the highest number of votes as the optimal dialogue chain.

[0094] Specifically, the negotiation and voting mechanism is constructed based on at least one of the following methods: weighted majority voting, game-theoretic negotiation, and reputation-first mechanism. Specifically, weighted majority voting involves different voting weights for each agent; game-theoretic negotiation involves simulating game strategies to find a Nash equilibrium; reputation-first mechanism only adopts recommendations from the top N agents in terms of reputation; and group consensus assessment involves calculating the Gini coefficient or information entropy to determine whether consensus has been reached if scores are concentrated.

[0095] Weighted Majority Voting (WMD) is used to obtain the reputation value of each pre-defined agent. Based on the reputation value, each pre-defined agent performs a weighted vote on each target dialogue chain. The target dialogue chain with the largest number of votes in the weighted voting results is output as the optimal dialogue chain. Each agent selects the Top-K target dialogue chains for voting based on the scoring results, and each vote is weighted according to the agent's current reputation value to form the candidate chain's vote count. Weighted Majority Voting (WMVote) is suitable for scenarios where agents have significantly different reputations and agents with better historical performance are desired to have greater voting weight; scenarios where not all agents are equally trustworthy and it is necessary to ensure that group decisions are not "dragged off" by low-quality agents; and scenarios where efficient negotiation and fast single-round convergence are required, avoiding complex game theory (e.g., high real-time systems, online dialogue systems). Typical application scenarios include: agent groups with long-term learning agents (veterans) and new agents (new recruits) → requiring weighted voting based on reputation differences; online dialogue recommendation, requiring rapid selection of the current optimal answer chain, unsuitable for multi-round complex game theory; and enterprise decision-making dialogues, requiring trusted expert agents to have high voting weight and auxiliary agents to have low voting weight. Specific implementation function:

[0096] Input preparation: Candidate pool There are a total of T target dialogue chains. Each agent... There is a corresponding reputation value Each intelligent agent Give the top-K items in the candidate pool Voting (K is configurable).

[0097] Voting process: by scoring function Sort and select Top-K candidate chains. Give each target dialogue chain Cast one vote, voting weight = Initialize the total number of votes for each target dialogue chain. For all intelligent agents Each vote cast → Obtain the weighted vote vector of all target dialogue chains. Select Target dialogue chain This serves as the optimal dialogue chain for the current round. This means "take the maximum value for all j".

[0098] Game-Theoretic Voting initializes the voting preference distribution of each pre-defined agent based on their rating of the target dialogue chain. This distribution represents the agent's probability of voting on each target dialogue chain. During each round of the game, a global voting distribution is formed by aggregating the voting preferences of all pre-defined agents. Each pre-defined agent updates its corresponding voting preference distribution based on this global distribution. Normalization is performed on the updated voting preference distribution for each round, iterating until the global voting distribution meets the convergence criteria. The target dialogue chain with the highest concentration of voting preferences in the final convergence round is output as the optimal dialogue chain. The core purpose of Game-Theoretic Voting is not to allow agents to "determine the outcome with a single vote," but rather to allow agents to gradually adjust their voting preferences through multiple rounds of negotiation and voting. Through the game process, the group ultimately reaches a "stable consensus" (approximately Nash equilibrium) before forming the final voting result. The core objectives are to address the following scenarios: large initial voting disagreements → adjustments are made round by round through strategy optimization; avoiding "one-vote-determined wins and losses" by certain agents → multiple rounds of dynamic trade-offs; and "gradual convergence" of group opinions → better reflection of collective wisdom.

[0099] Specific steps for implementing game-theoretic negotiation: Each agent Initial pairing of candidate pool There is a set of voting preference distributions

[0100]

[0101] The voting preference distribution is derived from the scoring function standardization. During each round of the game, the voting preferences of the pre-defined agents from the previous round are summarized to calculate the global voting distribution. :.

[0102]

[0103] Each agent Observe the global voting distribution Determine whether you need to adjust your voting preference distribution:

[0104]

[0105] in, : is the learning rate, used to adjust the convergence speed; For intelligent agents right The utility function for the current round can be designed as follows:

[0106]

[0107] item Driven by ratings, it tends to support dialogue chains targeting high-rated items. Driven by scarcity, we tend to avoid blindly following trends and explore dialogue chains targeting low-scoring individuals. This is to prevent negative infinity in the logarithm calculation, taking the smallest positive number. Normalization is performed on the voting preference distribution after each round of updates. Then, normalize to a valid probability distribution:

[0108]

[0109] Then, a convergence check is performed, and the process is iterated until the global voting distribution meets the convergence criteria, i.e., each round is monitored. Does the distribution change converge?

[0110]

[0111] like (Stop threshold), or reaching the maximum number of iterations. If the convergence condition is met, the game is stopped, and the player outputs the vote preference concentration at the current convergence round. As the final weighted voting result.

[0112] A reputation-first selection mechanism is used to obtain the reputation value of each preset agent and select target agents that meet the preset ranking conditions based on the reputation value ranking. Each target agent votes on each target dialogue chain, and the voting results are tallied. The target dialogue chain with the highest number of votes is output as the optimal dialogue chain. If each agent already has a reputation value, the following steps are taken: Current reputation value ∈[0,1]. Sort the data in descending order to obtain the ranking. Then, select the top-ranked items from the sorted list. Each agent is considered a "reputation-first agent set". That is, the set of target intelligent agents. Only allowed The agents in this round of voting participate, while the other agents do not. The subsequent process of weighted vote tallying and selecting the optimal dialogue chain is the same as the weighted majority voting mechanism, but only uses... The voting weights are used in the calculation. The optimal dialogue chain is selected based on the voting results of the retained agents.

[0113] In one possible implementation, step S106 further includes: performing a group consensus assessment on the voting results of the negotiation and voting mechanism according to a preset method, the preset method including the Gini coefficient calculation method and the entropy calculation method; if the group consensus assessment does not meet the preset assessment conditions, then performing operations including but not limited to the following: re-performing the negotiation and voting mechanism, or directly selecting the optimal dialogue chain through an arbitration agent; if the group consensus assessment meets the preset assessment conditions, then using the optimal dialogue chain as the final output.

[0114] Specifically, after multiple agents independently score and vote, the candidate dialogue chain ultimately forms a voting result distribution. However, a concentration of votes does not necessarily indicate that the group has reached a consensus. Sometimes, the apparent difference in vote counts may actually reflect underlying disagreements (such as several agents strongly opposing the proposal). Therefore, a group consensus assessment metric is needed to quantitatively determine whether the current round of voting results reflects group consensus, whether it can be directly output, or whether renegotiation is required.

[0115] Gini coefficient calculation method: Calculation of normalized voting distribution:

[0116]

[0117] Gini coefficient calculation formula:

[0118]

[0119] The Gini coefficient essentially measures the dispersion (concentration) of the voting distribution. A higher Gini indicates that most votes are concentrated on a few candidate chains, indicating high group consensus; a lower Gini indicates that votes are scattered across many candidate chains, indicating significant group disagreement, and it is not advisable to output the results directly at this time.

[0120] Entropy calculation method: Entropy calculation formula:

[0121]

[0122] Normalized entropy calculation:

[0123]

[0124] Entropy essentially measures the uniformity of information distribution. A high entropy value indicates a very even voting result, representing significant disagreement among agents; a low entropy value indicates concentrated voting, representing a high degree of consensus among agents. (Gini threshold) For example, 0.6; normalized entropy threshold For example, 0.4. If Gini < or If the consensus is insufficient and the group consensus assessment does not meet the preset assessment conditions, then the following actions will be taken, including but not limited to: re-initiating a negotiation and voting mechanism, or directly selecting the optimal dialogue chain through an arbitration agent. If Gini... or The optimal dialogue chain is then used as the final output. Furthermore, a final output confirmation process can be performed to ensure that the output quality meets application requirements. Confidence determination: Determine whether the difference between the optimal dialogue chain and the second-highest voted target dialogue chain exceeds the confidence threshold δ. Syntactic and pragmatic consistency verification: Perform syntactic analysis and pragmatic consistency checks on the optimal dialogue chain, correct non-standard expressions, and improve output fluency.

[0125] The above-mentioned negotiation and voting mechanisms can dynamically select voting strategies based on the following conditions: if the scenario requires real-time performance or the context dialogue is a fast-response dialogue, or the Gini value is high / entropy value is low, then the weighted majority voting mechanism is preferred; if the Gini value is low / entropy value is high, then the game-theoretic negotiation mechanism is preferred; if there are significant differences in the reputation of the agents, then the reputation-first mechanism is preferred; if the scenario is a complex task negotiation, then a combination of the reputation-first mechanism and the game-theoretic negotiation mechanism is selected.

[0126] Please refer to Figure 2 This document illustrates a schematic diagram of a multi-dimensional semantic enhancement device for dialogue chains based on an MCP agent negotiation and voting mechanism, provided in an embodiment of this application. The device includes a dialogue chain generation module 21, a dialogue chain enhancement module 22, a dialogue chain scoring module 23, and a dialogue chain output module 24.

[0127] The dialogue chain generation module 21 is used to input the target input structure into the large language model and output multiple candidate dialogue chains based on the large language model.

[0128] The dialogue chain enhancement module 22 is used to build a preset rule base and perform multi-dimensional semantic enhancement on multiple candidate dialogue chains based on the preset rule base to obtain multiple enhanced dialogue chains.

[0129] The dialogue chain scoring module 23 is used to output a corresponding dialogue chain score for each enhanced dialogue chain through each preset agent.

[0130] The dialogue chain output module 24 is used to filter multiple dialogue chain scores, obtain the target consistency score among the multiple dialogue chain scores whose score value is greater than the preset ranking; determine the target dialogue chain corresponding to each target consistency score among multiple enhanced dialogue chains; calculate the number of votes corresponding to each target dialogue chain based on the negotiation and voting mechanism, and output the target dialogue chain corresponding to the highest number of votes as the optimal dialogue chain.

[0131] In one possible implementation, the dialogue chain generation module 21 is used to input the target input structure into a large language model and output multiple candidate dialogue chains based on the large language model. Specifically, it includes: obtaining the global target task, the current round of dialogue context, and agent ontology information as the target input structure; constructing a knowledge graph query module, a named entity recognition module, and a relation extraction module; obtaining key entity information in the target input structure based on the named entity recognition module; obtaining potential semantic relationships between key entity information based on the relation extraction module; dynamically matching predefined query templates based on key entity information and potential semantic relationships, and outputting query conditions. The predefined query templates include SPARQL query templates and Cypher query templates; obtaining structured knowledge fragments that meet the matching requirements through the knowledge graph query module based on the query conditions; and inputting the structured knowledge fragments into the large language model based on the knowledge enhancement prompt template to output multiple candidate dialogue chains.

[0132] In one possible implementation, the dialogue chain generation module 21 is used to input structured knowledge fragments into a large language model based on a knowledge-enhanced prompt template to output multiple candidate dialogue chains. Specifically, it includes: constructing a knowledge-enhanced prompt template based on the task type of the global target task; dynamically filling the generated prompt content with the structured knowledge fragments according to the corresponding knowledge-enhanced prompt template; calling the large language model using the enhanced generated prompt content; and outputting multiple candidate dialogue chains based on the large language model.

[0133] In one possible implementation, the dialogue chain enhancement module 22 is used to perform multi-dimensional semantic enhancement on multiple candidate dialogue chains, specifically including: performing multi-dimensional semantic enhancement on multiple candidate dialogue chains, the multi-dimensional semantic enhancement including performing syntactic enhancement on candidate dialogue chains through a syntactic analyzer, performing discourse behavior enhancement on candidate dialogue chains through a model discourse behavior classifier, and performing structural consistency enhancement on candidate dialogue chains through dialogue structure templates applicable to different task scenarios.

[0134] In one possible implementation, the dialogue chain scoring module 23 is used to output a corresponding dialogue chain score for each enhanced dialogue chain through various preset agents. Specifically, it includes: performing multi-dimensional scoring on the enhanced dialogue chain through preset agents, the multi-dimensional scoring including semantic similarity score, context consistency score, and knowledge consistency score, wherein the knowledge consistency score includes entity consistency score, relation consistency score, attribute consistency score, and context consistency score; constructing an agent reputation value function, and performing a weighted average calculation on the semantic similarity score, context consistency score, knowledge consistency score, and agent reputation value function to output the dialogue chain score.

[0135] In one possible implementation, the dialogue chain output module 24 is used to construct a negotiation and voting mechanism before calculating the number of votes corresponding to each target dialogue chain based on the negotiation and voting mechanism and outputting the target dialogue chain with the highest number of votes as the optimal dialogue chain. Specifically, the negotiation and voting mechanism is constructed based on at least one of the following methods: weighted majority voting mechanism, game-theoretic negotiation mechanism, and reputation priority mechanism.

[0136] In one possible implementation, the dialogue chain output module 24 is used to calculate the number of votes corresponding to each target dialogue chain based on the negotiation and voting mechanism when the negotiation and voting mechanism is a weighted majority voting mechanism, and output the target dialogue chain corresponding to the highest number of votes as the optimal dialogue chain. Specifically, this includes: obtaining the reputation value corresponding to each preset agent; performing weighted voting on each target dialogue chain through each preset agent based on the reputation value; and outputting the target dialogue chain corresponding to the maximum number of votes in the weighted voting results as the optimal dialogue chain.

[0137] In one possible implementation, the dialogue chain output module 24 is used to calculate the number of votes corresponding to each target dialogue chain based on the negotiation and voting mechanism when the negotiation and voting mechanism is a game-like negotiation mechanism, and output the target dialogue chain with the highest number of votes as the optimal dialogue chain. Specifically, this includes: initializing the voting preference distribution corresponding to each preset agent based on the scoring results of each preset agent on the target dialogue chain, where the voting preference distribution represents the voting probability of the preset agent on each target dialogue chain; during each round of the game, summarizing the voting preferences of all preset agents to form a global voting distribution; each preset agent updating its corresponding voting preference distribution based on the global voting distribution; performing normalization processing on the updated voting preference distribution in each round, and iterating until the global voting distribution meets the convergence judgment condition; and outputting the target dialogue chain with the highest concentration of voting preferences in the final convergence round as the optimal dialogue chain.

[0138] In one possible implementation, the dialogue chain output module 24 is used to calculate the number of votes corresponding to each target dialogue chain based on the negotiation and voting mechanism when the negotiation and voting mechanism is a reputation-first mechanism, and output the target dialogue chain corresponding to the highest number of votes as the optimal dialogue chain. Specifically, this includes: obtaining the reputation value corresponding to each preset agent, and obtaining the target agents that meet the preset ranking conditions based on the ranking of the reputation values; voting for each target dialogue chain by each target agent, and counting the voting results; and outputting the target dialogue chain corresponding to the maximum number of votes in the voting results as the optimal dialogue chain.

[0139] In one possible implementation, the dialogue chain output module 24 is used to calculate the number of votes for each target dialogue chain based on the negotiation and voting mechanism, and output the target dialogue chain with the highest number of votes as the optimal dialogue chain. Then, it performs a group consensus evaluation on the voting results of the negotiation and voting mechanism according to a preset method, which includes the Gini coefficient calculation method and the entropy calculation method. If the group consensus evaluation does not meet the preset evaluation conditions, it performs operations including but not limited to the following: re-perform the negotiation and voting mechanism, or directly decide to select the optimal dialogue chain through an arbitration agent. If the group consensus evaluation meets the preset evaluation conditions, it uses the optimal dialogue chain as the final output.

[0140] It should be noted that the above embodiments of the apparatus are only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0141] This application also provides an electronic device. (See reference...) Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include: at least one processor 301, at least one communication bus 302, a user interface 303, at least one network interface 304, and a memory 305.

[0142] The communication bus 302 is used to enable communication between these components.

[0143] The user interface 303 may include a display screen and a camera. Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.

[0144] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).

[0145] The processor 301 may include one or more processing cores. The processor 301 connects to various parts of the server using various interfaces and lines, and performs various server functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 305, and by calling data stored in memory 305. Optionally, the processor 301 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 301 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 301 and may be implemented as a separate chip.

[0146] The memory 305 may include random access memory (RAM) or read-only memory. Optionally, the memory 305 may include a non-transitory computer-readable storage medium. The memory 305 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 305 may also be at least one storage device located remotely from the aforementioned processor 301. (Refer to...) Figure 3 The memory 305, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a dialogue chain multidimensional semantic enhancement application based on the MCP agent negotiation and voting mechanism.

[0147] exist Figure 3In the illustrated electronic device, the user interface 303 is primarily used to provide an input interface for the user and acquire user input data. The processor 301 can be used to call the multi-dimensional semantic enhancement application based on the MCP agent negotiation and voting mechanism, stored in the memory 305. When executed by one or more processors 301, the electronic device performs one or more of the methods described in the above embodiments. It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps can be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0148] This application also provides a computer-readable storage medium storing instructions. When executed by one or more processors, these instructions cause an electronic device to perform one or more of the methods described in the above embodiments.

[0149] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0150] In the various embodiments provided in this application, it should be understood that the disclosed apparatus 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 through some service interface; the indirect coupling or communication connection between apparatuses or units may be electrical or other forms.

[0151] 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.

[0152] Furthermore, the functional units in the various embodiments of this application 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.

[0153] 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 device (CMD). Based on this understanding, the technical solution of this application, 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 memory 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 of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, portable hard drives, magnetic disks, or optical disks.

[0154] The above description is merely an exemplary embodiment disclosed in this application and should not be construed as limiting the scope of this application. Any equivalent changes and modifications made in accordance with the teachings of this application shall still fall within the scope of this application.

[0155] This application is intended to cover any variations, uses, or adaptations disclosed herein that follow the general principles disclosed herein and include common knowledge or customary technical means in the art that are not described in this application.

Claims

1. A method for multi-dimensional semantic enhancement of dialogue chains based on MCP agent negotiation and voting mechanism, characterized in that, The method includes: The target input structure is input into a large language model, and multiple candidate dialogue chains are output based on the large language model; A preset rule base is constructed, and multiple candidate dialogue chains are semantically enhanced in multiple dimensions based on the preset rule base to obtain multiple enhanced dialogue chains; Each preset intelligent agent outputs a corresponding dialogue chain score for each enhanced dialogue chain. Filter the multiple dialogue chain scores and select the enhanced dialogue chain with a score value greater than a preset ranking as the target dialogue chain; The number of votes for each target dialogue chain is calculated based on a negotiation and voting mechanism, and the target dialogue chain with the highest number of votes is output as the optimal dialogue chain. Before calculating the number of votes for each target dialogue chain based on the negotiation and voting mechanism and outputting the target dialogue chain with the highest number of votes as the optimal dialogue chain, the negotiation and voting mechanism needs to be constructed. Specifically, it includes constructing the negotiation and voting mechanism based on at least one of the following methods: a weighted majority voting mechanism, a game-theoretic negotiation mechanism, and a reputation-first mechanism; wherein, the steps of the game-theoretic negotiation mechanism include: based on each preset intelligent agent's opinion on the target dialogue chain... The scoring results of the target dialogue chain are used to initialize the voting preference distribution corresponding to each of the preset agents, whereby the voting preference distribution represents the voting probability of the preset agent on each target dialogue chain. During each round of the game, a global voting distribution is formed by summing the voting preferences of all the preset agents. Each preset agent updates its corresponding voting preference distribution based on the global voting distribution. Normalization is performed on the updated voting preference distribution for each round, and the process is iterated until the global voting distribution meets the convergence criteria. The target dialogue chain with the highest concentration of voting preferences in the final convergence round is output as the optimal dialogue chain.

2. The method according to claim 1, characterized in that, The step of inputting the target input structure into a large language model and outputting multiple candidate dialogue chains based on the large language model specifically includes: The global target task, the current round of dialogue context, and the agent ontology information are obtained as the target input structure. Construct a knowledge graph query module, a named entity recognition module, and a relationship extraction module; The named entity recognition module obtains key entity information in the target input structure. Based on the relationship extraction module, the potential semantic relationships between the key entity information are obtained; Based on the key entity information and the potential semantic relationships, a predefined query template is dynamically matched, and query conditions are output. The predefined query templates include SPARQL query templates and Cypher query templates. Based on the query conditions, the knowledge graph query module obtains structured knowledge fragments that meet the matching requirements; Based on the knowledge-enhanced prompt template, the structured knowledge fragments are input into the large language model to output multiple candidate dialogue chains.

3. The method according to claim 2, characterized in that, The step of inputting the structured knowledge fragments into the large language model based on the knowledge-enhanced prompt template to output multiple candidate dialogue chains specifically includes: Based on the task type of the global target task, the knowledge enhancement prompt template is constructed; The structured knowledge fragments are dynamically populated with generated prompts according to the corresponding knowledge enhancement prompt templates; The enhanced generated prompt content is used to invoke the large language model, and multiple candidate dialogue chains are output based on the large language model.

4. The method according to claim 1, characterized in that, The multi-dimensional semantic enhancement of the multiple candidate dialogue chains specifically includes: The multi-dimensional semantic enhancement is performed on multiple candidate dialogue chains. The multi-dimensional semantic enhancement includes syntactic enhancement of the candidate dialogue chains through a syntactic analyzer, discourse behavior enhancement of the candidate dialogue chains through a model discourse behavior classifier, and structural consistency enhancement of the candidate dialogue chains through dialogue structure templates applicable to different task scenarios.

5. The method according to claim 1, characterized in that, The step of outputting a corresponding dialogue chain score for each enhanced dialogue chain through various preset intelligent agents specifically includes: The enhanced dialogue chain is scored in multiple dimensions by the preset intelligent agent. The multi-dimensional scoring includes semantic similarity score, context consistency score, and knowledge consistency score, wherein the knowledge consistency score includes entity consistency score, relation consistency score, attribute consistency score, and context consistency score. Construct an agent reputation value function, and calculate a weighted average of the semantic similarity score, the context consistency score, the knowledge consistency score, and the agent reputation value function to output the dialogue chain score.

6. The method according to claim 1, characterized in that, When the negotiation and voting mechanism is the weighted majority voting mechanism, the calculation of the number of votes for each target dialogue chain based on the negotiation and voting mechanism, and the output of the target dialogue chain with the highest number of votes as the optimal dialogue chain, specifically includes: Obtain the reputation value corresponding to each of the preset intelligent agents; Based on the reputation value, each of the preset intelligent agents performs weighted voting on each of the target dialogue chains; The target dialogue chain corresponding to the maximum number of votes in the weighted voting results is output as the optimal dialogue chain.

7. The method according to claim 1, characterized in that, When the negotiation and voting mechanism is the reputation-first mechanism, the calculation of the number of votes for each target dialogue chain based on the negotiation and voting mechanism, and the output of the target dialogue chain with the highest number of votes as the optimal dialogue chain, specifically includes: Obtain the reputation value corresponding to each of the preset intelligent agents, and obtain the target intelligent agents that meet the preset ranking conditions based on the ranking of the reputation values; Each target agent votes on each target dialogue chain, and the voting results are tallied. The target dialogue chain corresponding to the maximum number of votes in the voting results is output as the optimal dialogue chain.

8. The method according to claim 1, characterized in that, After calculating the number of votes for each target dialogue chain based on the negotiation and voting mechanism, and outputting the target dialogue chain with the highest number of votes as the optimal dialogue chain, the method further includes: The voting results of the negotiation and voting mechanism are evaluated for group consistency according to a preset method, which includes the Gini coefficient calculation method and the entropy calculation method. If the group consensus assessment does not meet the preset assessment conditions, the negotiation and voting mechanism will be repeated, or the optimal dialogue chain will be selected directly by an arbitration agent. If the group consensus assessment meets the preset assessment conditions, then the optimal dialogue chain will be the final output.