Multi-agent collaborative role large model same-world personality generation method and related products
By employing a multi-agent collaborative role-based large-scale model for generating personality in the same context, and by calculating and adjusting personality consistency and context matching scores in real time, the problem of personality drift and context deviation in multi-agent collaborative dialogue is solved, thereby achieving dynamic optimization and stability improvement of dialogue quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- LIANGSHENG DIGITAL CREATIVE DESIGN (HANGZHOU) CO LTD
- Filing Date
- 2026-02-28
- Publication Date
- 2026-06-16
AI Technical Summary
Existing dialogue technologies struggle to maintain consistency in character personalities and contextual matching in multi-role, large-scale collaborative dialogue scenarios, leading to personality drift and contextual deviation in long conversations. Furthermore, existing methods suffer from high data costs and insufficient generalization capabilities.
A multi-agent collaborative role model-based personality generation method is adopted. By initializing multiple role models and configuring personality parameters, combined with static and dynamic dialogue context parameters, personality consistency and context matching scores are calculated in real time, and iterative correction is performed to ensure the consistency and matching of the output.
It significantly improves the coherence and relevance of collaborative dialogue in multi-role large models, reduces inconsistencies in character traits, enhances adaptability and robustness to abnormal situations, and avoids the need for manual intervention or offline retraining.
Smart Images

Figure CN121745150B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method for generating a multi-agent collaborative role-large model in the same context, a device for generating a multi-agent collaborative role-large model in the same context, a computer device, and a computer-readable storage medium. Background Technology
[0002] In recent years, the development of large-scale pre-trained language models has enabled intelligent dialogue systems to be widely used in various fields such as customer service, education, and companionship. Based on pre-trained language models, large role models can simulate different roles and engage in multi-turn interactive dialogues with users. In practical applications, different scenarios often require large role models to exhibit specific personality traits (e.g., customer service scenarios require politeness and professionalism, education scenarios require patience and rigor, and psychological companionship scenarios require empathy and care), and to remain consistent with the current context. However, existing dialogue technologies still have significant shortcomings in terms of role personality consistency and context matching. Especially in collaborative dialogue scenarios involving multiple large role models, as the number of dialogue rounds increases, the personality of the large role model is prone to drift, resulting in inconsistent performance; different large role models may have differing understandings of the dialogue context, leading to dialogue content that does not match the context. Related technologies typically constrain the personality of the large role model by pre-setting role personality descriptions at the beginning of the dialogue or using fixed rules, but these methods lack mechanisms for dynamic evaluation and adjustment of the dialogue, and cannot effectively prevent personality drift and context deviation in long dialogues. Some model fine-tuning methods based on human feedback attempt to improve dialogue consistency, but they suffer from high data costs, insufficient generalization ability, and difficulty in covering diverse dialogue scenarios. Therefore, how to maintain the personality consistency of the large role model in multi-turn dialogues and ensure that the output matches the current situation has become an urgent technical problem to be solved. Summary of the Invention
[0003] This invention provides a method for generating a multi-agent collaborative role model in contextual personality, a device for generating a multi-agent collaborative role model in contextual personality, a computer device, and a computer-readable storage medium, which enables multiple role models to maintain personality consistency while taking into account contextual matching during collaborative dialogue.
[0004] To facilitate understanding of the technical solution of this invention, the key terms involved in the technical solution of this invention are explained as follows (the terminology explanation in this section is only used to explain this invention and should not be construed as an additional limitation on the scope of protection):
[0005] Large-scale character models refer to large-scale pre-trained language model instances that can play specific roles in dialogues and generate natural language output; large-scale character models can present preset personality traits through fine-tuning, efficient parameter fine-tuning, or cue engineering.
[0006] Static dialogue context parameters: refer to a set of contextual information that is set once when the dialogue is started and remains unchanged in principle during the dialogue, including but not limited to the description of the roles of the participants in the dialogue, the scene background (location / time / environment), task or business constraints, etc.
[0007] Dynamic dialogue context parameter vector: refers to a shared context representation that is dynamically maintained and updated in real time during the dialogue process, preferably encoded in vector form. The dynamic dialogue context parameter vector includes at least: the encoded representation of static dialogue context parameters, and the dynamic context encoding of the current dialogue context (historical turn summary, latest user input, environmental state variables, emotional state, etc.); the dynamic dialogue context parameter vector is shared by multiple role models.
[0008] Personality parameters: These are a set of parameters used to quantify the target personality traits of the large role model. They can be represented by vectors or configuration tables and include several personality dimensions and their weights (such as tone of friendliness, formality of expression, empathy intensity, professionalism, etc.).
[0009] Personality consistency score: refers to the degree of consistency between the dialogue output and the personality parameters of the target character model. It is used to measure whether the output conforms to the preset personality in terms of language style, tone, and behavioral logic.
[0010] Context matching score: refers to the score of the degree of matching between the dialogue output and the dynamic dialogue context parameter vector. It is used to measure whether the output fits the current shared context and whether it closely follows the context and constraints.
[0011] Overall quality score: refers to the total score obtained by combining personality consistency score and situation fit score. The higher the overall quality score, the better the dialogue output is in terms of personality consistency and situation fit.
[0012] Correction iteration: refers to the process of adjusting the personality parameters and / or generation constraints of the role model and regenerating the dialogue output based on the source of deviation between the personality consistency score and the situation matching score when the overall quality score fails to reach the scoring threshold. Correction iteration can be set with a threshold number of iterations to avoid infinite loops.
[0013] In a first aspect, the multi-agent collaborative role-based large-scale model personality generation method provided by the present invention includes:
[0014] Initialize multiple character models and configure corresponding personality parameters for each character model;
[0015] Configure static dialogue context parameters for collaborative dialogue among multiple role-based large models, and initialize dynamic dialogue context parameter vectors based on static dialogue context parameters and the current dialogue history. The dynamic dialogue context parameter vectors include at least the vector representation of static dialogue context parameters, the vector representation of context information of the current dialogue round, the environmental state variables shared by multiple roles, and the dialogue history summary vector, and are shared by multiple role-based large models.
[0016] In each dialogue round, the target role model to speak is determined among multiple role models, and the dialogue output is generated through the target role model based on the current dialogue input, the personality parameters of the target role model, and the dynamic dialogue context parameter vector.
[0017] Calculate the personality consistency score and situational fit score of the dialogue output, and fuse the personality consistency score and situational fit score to obtain a comprehensive quality score;
[0018] If the overall quality score does not reach the scoring threshold, a correction strategy is determined based on the personality consistency score and situational matching score. The correction strategy is then executed to adjust the personality parameters and / or generation constraints of the target role's large model and regenerate the dialogue output until the target role's large model generates a dialogue output with an overall quality score that reaches the scoring threshold or the number of correction iterations reaches the number threshold. The dialogue output with an overall quality score that reaches the scoring threshold is published, or the dialogue output with the highest overall quality score during the iteration process is published when the number of correction iterations reaches the number threshold. The dynamic dialogue situational parameter vector and the personality parameters of the target role's large model are updated based on the overall quality score before entering the next dialogue round, until the dialogue ends.
[0019] Optionally, in one embodiment, a comprehensive quality score is obtained by fusing the personality consistency score and the situational fit score, including:
[0020] Based on the respective weighting coefficients of the personality consistency score and the situation fit score, a weighted sum of the personality consistency score and the situation fit score is calculated as the comprehensive quality score. For example, let... and Personality consistency score Context matching score The weighting coefficients can then be expressed as: And satisfy (If there is no bias, it can be taken) ).
[0021] Optionally, in one embodiment, determining a corrective strategy based on personality consistency score and situation fit score includes:
[0022] If the personality consistency score is lower than the situational matching score, the corrective strategy is to enhance the weight of the relevant biased personality dimensions in the personality parameters of the target role's large model, inject personality reinforcement prompts, and / or regenerate the dialogue output.
[0023] If the situational fit score is lower than the personality consistency score, the corrective strategy is to supplement the missing situational elements in the dialogue input and / or inject situational reinforcement cues.
[0024] Optionally, in one embodiment, calculating the personality consistency score and situational fit score of the dialogue output includes:
[0025] For each context dimension of the dynamic dialogue context parameter vector, calculate the matching score of the dialogue output on that context dimension, and fuse the matching scores of each context dimension to obtain the context matching score of the dialogue output.
[0026] For each personality dimension of the target character's large model, calculate the matching score of the dialogue output on that personality dimension, and merge the matching scores of each personality dimension to obtain the personality consistency score of the dialogue output.
[0027] Optionally, in one embodiment, updating the personality parameters of the target character's large model includes:
[0028] Identify the positive personality dimensions relative to the personality consistency score in the personality parameters of the target role's large model, and increase the weight of this positive personality dimension according to a preset ratio.
[0029] Optionally, in one embodiment, the multi-agent collaborative role-based large-scale model personality generation method provided by the present invention further includes:
[0030] The dialogue scenario to which the current dialogue belongs is determined based on the dynamic dialogue scenario parameter vector, and the scoring threshold is determined based on the dialogue scenario.
[0031] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when the condition is met," "once the condition is met," or "in response to determining / detecting the condition or event," to indicate that a corresponding step is performed when the triggering condition is met, and its meaning should not be construed as requiring a strict temporal order, an exclusive condition, or a necessary causal relationship.
[0032] Similarly, the phrases “if determined” or “if [the described condition or event] is detected” can be interpreted, depending on the context, as meaning “once determined” or “in response to determined” or “once [the described condition or event] is detected” or “in response to the detection of [the described condition or event]”.
[0033] Secondly, the multi-agent collaborative role-based large-scale model personality generation device provided by the present invention includes:
[0034] The character initialization module is used to initialize multiple large character models and configure corresponding personality parameters for each large character model.
[0035] The context initialization module is used to configure the static dialogue context parameters for collaborative dialogue among multiple role models, and to initialize the dynamic dialogue context parameter vector based on the static dialogue context parameters and the current dialogue history. The dynamic dialogue context parameter vector includes at least the encoded representation of the static dialogue context parameters and the dynamic context encoding of the current dialogue context, and is shared by multiple role models.
[0036] The dialogue generation module is used to determine the target role model to speak among multiple role models in each dialogue round, and generate dialogue output through the target role model based on the current dialogue input, the personality parameters of the target role model, and the dynamic dialogue context parameter vector.
[0037] The quality scoring module is used to calculate the personality consistency score and situation matching score of the dialogue output, and to combine the personality consistency score and situation matching score to obtain a comprehensive quality score;
[0038] The dialogue correction module is used to determine a correction strategy based on the personality consistency score and the situation matching score when the overall quality score does not reach the scoring threshold. The correction strategy is then executed to adjust the personality parameters and / or generation constraints of the target role model and regenerate the dialogue output. This process is repeated until the overall quality score reaches the scoring threshold or the number of correction iterations reaches the number threshold.
[0039] The parameter update module publishes dialogue outputs when the overall quality score reaches the score threshold, or publishes the dialogue output with the highest overall quality score during the iteration process when the number of correction iterations reaches the number threshold. After updating the dynamic dialogue context parameter vector and the personality parameters of the target role's large model, it enters the next dialogue round until the dialogue ends.
[0040] Optionally, in one embodiment, the quality scoring module is used to calculate a weighted sum of the personality consistency score and the situational fit score as a comprehensive quality score based on the respective weight coefficients of the personality consistency score and the situational fit score. For example, suppose... and Personality consistency score Context matching score The weighting coefficients can then be expressed as: And satisfy (If there is no bias, it can be taken) ).
[0041] Optionally, in one embodiment, the dialogue correction module is used to determine, when the personality consistency score is lower than the situational matching score, the correction strategy is to enhance the weight of the relevant biased personality dimension in the personality parameters of the target role's large model, inject personality reinforcement prompts, and / or regenerate the dialogue output; or when the situational matching score is lower than the personality consistency score, the correction strategy is to supplement the missing situational elements in the dialogue input and / or inject situational reinforcement prompts.
[0042] Optionally, in one embodiment, the quality scoring module is used to: calculate the matching score of the dialogue output on each context dimension of the dynamic dialogue context parameter vector, and fuse the matching scores of each context dimension to obtain the context matching score of the dialogue output; and calculate the matching score of the dialogue output on each personality dimension of the personality parameters of the target role model, and fuse the matching scores of each personality dimension to obtain the personality consistency score of the dialogue output.
[0043] Optionally, in one embodiment, the parameter update module is used to determine the positive personality dimension relative to the personality consistency score in the personality parameters of the target character model, and to increase the weight of the positive personality dimension according to a preset ratio.
[0044] Optionally, in one embodiment, the multi-agent collaborative role model contextual personality generation device provided by the present invention further includes a threshold determination module, which is used to determine the dialogue scenario to which the current dialogue belongs based on the dynamic dialogue scenario parameter vector, and to determine the scoring threshold based on the dialogue scenario.
[0045] Thirdly, the computer device provided by the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the multi-agent collaborative role model empathy personality generation method provided by the present invention.
[0046] Fourthly, the computer-readable storage medium provided by the present invention stores a computer program, which, when executed by a processor, implements the multi-agent collaborative role-based large-scale model empathic personality generation method provided by the present invention.
[0047] This invention provides a multi-agent collaborative role-model-based personality generation scheme. Through a dual scoring mechanism of personality consistency and situational matching, it enables multiple role-models to maintain consistency in their personality traits during long dialogues, significantly reducing inconsistencies in character traits and inconsistent tone of voice. Secondly, this invention introduces a dynamic dialogue situation parameter vector to uniformly manage the dialogue situation, ensuring that all role-models understand the dialogue situation consistently, thereby avoiding answer deviations caused by information asymmetry or situational misunderstandings between roles and greatly improving the coherence and relevance of multi-role-model collaborative dialogues. Thirdly, the real-time personality correction iteration mechanism of this invention allows the system to automatically correct abnormal outputs during operation without manual intervention or offline retraining, enhancing its adaptability and robustness to abnormal situations. Through these technical means, this invention ensures personality consistency while also considering situational matching, achieving dynamic optimization of dialogue quality. This overcomes the limitations of relying solely on static presets or rule control, and avoids the costs associated with unnecessarily increasing training data and model complexity. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1 This is a schematic diagram of an application environment for the multi-agent collaborative role-based large model personality generation method provided in this embodiment of the invention;
[0050] Figure 2 This is a schematic diagram of the architecture of the multi-agent collaborative role-based large model personality generation system provided in this embodiment of the invention.
[0051] Figure 3 This is a flowchart illustrating the multi-agent collaborative role-based large model personality generation method provided in this embodiment of the invention.
[0052] Figure 4 This is a schematic diagram of the process for scoring the quality of dialogue output in an embodiment of the present invention;
[0053] Figure 5 This is a schematic diagram of the iterative correction process in an embodiment of the present invention;
[0054] Figure 6 This is a schematic diagram of the structure of the multi-agent collaborative role-model empathy personality generation device provided in an embodiment of the present invention;
[0055] Figure 7This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0056] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.
[0057] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0058] It should also be understood that the term “and / or” as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0059] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when the condition is met," "once the condition is met," or "in response to determining / detecting the condition or event," to indicate that a corresponding step is performed when the triggering condition is met, and its meaning should not be construed as requiring a strict temporal order, an exclusive condition, or a necessary causal relationship.
[0060] Similarly, the phrases “if determined” or “if [the described condition or event] is detected” can be interpreted, depending on the context, as meaning “once determined” or “in response to determined” or “once [the described condition or event] is detected” or “in response to the detection of [the described condition or event]”.
[0061] Furthermore, in the description of this invention and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0062] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of the invention include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0063] It should be understood that the sequence number of each step in the following embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0064] Please refer to Figure 1 , Figure 1 This is a schematic diagram illustrating an application environment of the multi-agent collaborative role-based large-scale model and context-based personality generation method provided by this invention. As one implementation, the multi-agent collaborative role-based large-scale model and context-based personality generation method provided by this invention can be applied to a server 100. The server 100 and terminal device 200 are connected via a network. The server 100 provides multi-role dialogue services to the terminal device 200. The network serves as the medium for providing a communication link between the server 100 and the terminal device 200, and can include various connection types, such as wired communication links, wireless communication links, etc. This embodiment of the invention does not limit this.
[0065] It should be noted that, Figure 1 The server 100, network, and terminal device 200 shown are merely illustrative. Depending on actual needs, there can be any number of servers 100. For example, the server 100 can be implemented by a standalone physical server, a server cluster consisting of multiple servers, or a distributed system, etc., and the terminal device 200 can be any device such as a mobile phone, tablet, desktop computer, or laptop.
[0066] In some embodiments, server 100 deploys multiple role models. Server 100 can initialize multiple role models and configure corresponding personality parameters for each role model; configure static dialogue context parameters for collaborative dialogue among multiple role models, and initialize dynamic dialogue context parameter vectors for collaborative dialogue among multiple role models based on the static dialogue context parameters; in each dialogue round, determine the target role model to speak among the multiple role models, and generate dialogue output or response results through the target role model based on the current dialogue input, the personality parameters of the target role model, and the dynamic dialogue context parameter vector, wherein the current dialogue input may come from a human user of terminal device 200; subsequently, calculate the personality consistency score and context matching score of the dialogue output, and fuse the personality consistency score and context matching score to obtain a comprehensive quality score; if the comprehensive quality score reaches the scoring threshold, publish the dialogue output with the comprehensive quality score reaching the scoring threshold, which is displayed to the human user by terminal device 200, and update the dynamic dialogue context parameter vector and the personality parameters of the target role model before entering the next dialogue round, until the dialogue ends.
[0067] Please refer to Figure 2 , Figure 2 This is a schematic diagram of the architecture of the multi-agent collaborative role-based large model personality generation system provided by the present invention.
[0068] In an optional implementation, to achieve a "consistent understanding" of the same dialogue context across multiple role-based large models, a context parameter management module (which can also be implemented using a database / shared memory / message queue) is set up on the server side to centrally store and maintain static dialogue context parameters and dynamic dialogue context parameter vectors. After each dialogue round, the context parameter management module synchronizes (e.g., broadcasts) the updated dynamic dialogue context parameter vectors to all role-based large models (e.g., ...). Figure 2 The large-scale role model cluster comprises role models 1 to N, each with its own personality parameters P1 to PN. This ensures that all role models reason and respond based on the same shared contextual representation during subsequent generation, thus avoiding answer bias caused by inconsistent understanding of the context among multiple roles. The target role model (determined from the role model cluster) can receive dialogue input from the user through the terminal and generate dialogue output based on this dialogue input and the current dynamic dialogue context parameter vector.
[0069] Furthermore, the server side can also be configured with a quality scoring module and a dialogue correction module to form a closed loop: the quality scoring module receives the dialogue output of the target role model and the current dynamic dialogue context parameter vector to calculate the personality consistency score and context matching score, and outputs a comprehensive quality score; when the comprehensive quality score does not meet the standard, the dialogue correction module selects the corresponding correction strategy according to the source of the deviation (personality dimension or context dimension) and adjusts the personality parameters and / or generation constraints of the target role model, and then triggers the target role model to regenerate the output; when the comprehensive quality score meets the standard, the dialogue output with the comprehensive quality score meets the standard is published to the terminal and displayed to the user. In addition, the role model also sends a parameter update signal to the context parameter management module, instructing the context parameter management module to update the dynamic dialogue context parameter vector and enter the next round of dialogue.
[0070] Please refer to Figure 3 This is a flowchart illustrating a method for generating a multi-agent collaborative role model in a shared context, as disclosed in an embodiment of the present invention. Figure 3 As shown, the process of this multi-agent collaborative role model-based personality generation method can be summarized as follows:
[0071] In S110, multiple character models are initialized, and corresponding personality parameters are configured for each character model.
[0072] A role model is a large language model that generates a personality that matches a specific role (such as a customer service representative, teacher, or psychological consultant) in a conversation.
[0073] In practical implementation, the large-scale role model can be obtained by secondary training and adjustment of a pre-trained large-scale language model. The training and fine-tuning methods can be selected according to the specific application scenario and data conditions. For example, firstly, a large-scale pre-trained language model is selected as the base model (e.g., a mainstream pre-trained language model architecture with billions of parameters, such as an attention-based architecture). This large-scale pre-trained language model is trained on a massive general corpus and possesses rich language generation capabilities. Subsequently, specific personality traits are assigned to the large-scale pre-trained language model, which can be achieved using supervised fine-tuning: collecting or constructing dialogue corpora related to the target personality, and then further training the large-scale pre-trained language model in a targeted manner. The dialogue corpus can include a large number of question-and-answer dialogues that embody a certain target personality. For example, the corpus for a customer service personality can come from customer service chat logs, for an educational personality from teacher-student dialogue texts, and for a psychological support personality from psychological counseling dialogue cases, etc. In these corpora, the responses of the large-scale pre-trained language model all conform to the expected personality traits. By iteratively adjusting the model parameters of a large-scale pre-trained language model through a loss function that minimizes the difference between the model's response and the expected response, the model gradually learns to adopt expressions consistent with the target personality in similar contexts. For personality types with insufficient dialogue data, data augmentation or transfer learning techniques can be used to generate high-quality dialogue data. For example, leveraging the generative capabilities of the large-scale pre-trained language model itself, inputting a personality setting allows the model to generate simulated dialogues that conform to that personality setting, thereby expanding the dialogue data. If necessary, a small number of manually written personality descriptions can be introduced as training signals to guide the large-scale pre-trained language model towards convergence towards a specific personality, ultimately resulting in a large-scale character model with specific personality traits.
[0074] To facilitate the deployment of multiple personalities, the training of the large character model can employ lightweight fine-tuning techniques such as Low-Rank Adaptation (LoRA) or Prompt Tuning. These techniques allow for adaptation to different personality characters by updating only a small number of parameters while preserving the capabilities of the base model. In practice, a small set of adaptation parameters is trained separately for each personality during training and saved as a personality parameter plugin. During inference, this plugin is applied to the base model, allowing it to switch to the corresponding personality character. This achieves efficient deployment with a single model for multiple uses, eliminating the need to maintain completely independent model instances for each personality. When adding a new personality, there's no need to retrain the massive model; only a small number of personality parameter plugins need to be trained and updated, significantly reducing training overhead and storage costs.
[0075] In addition, prompt engineering techniques can be used to guide a large-scale pre-trained language model to exhibit target personality traits without modifying its parameters. For example, for a customer service personality, a personality prompt template such as "You are a professional customer service representative with a friendly yet formal tone who can empathize with users' emotions" can be used.
[0076] In a specific implementation example of this invention, a Transformer model with 7 billion parameters is used as the base model, and the above-mentioned fine-tuning training and optimization are performed on it. During the fine-tuning training, approximately 200,000 rounds of multi-turn dialogue data were used, covering three typical personality types: customer service, education, and psychological support (each type of data has a roughly equal proportion) to ensure that the model fully learns each personality trait. The fine-tuning training uses an adaptive optimizer (such as a commonly used first-order optimization algorithm), with an initial learning rate set to... The batch size is approximately 32, and the model converges after about 3 epochs of training. The loss function uses a multi-objective combination form:
[0077] ;
[0078] in, The cross-entropy loss is used to supervise the model in generating correct responses; To address the personality consistency loss, the output of the contrastive learning constraint model is semantically aligned with the target personality description. To mitigate context-matching loss, ensure responses are natural and appropriate within the context of the conversation. , These are adjustable weighting coefficients.
[0079] The optimization of the aforementioned multi-objective loss function prompts the base model to adjust towards reducing personality and situational biases during backpropagation parameter updates. Through this multi-objective loss function training strategy, the base model is guided to pay more attention to maintaining personality consistency and adaptability to the dialogue context while ensuring the basic quality of dialogue content generation.
[0080] Optionally, to further improve personality consistency and context matching in long dialogues, this invention can also combine reinforcement learning to optimize the training of the large role model: the comprehensive quality score obtained by fusing personality consistency score and context matching score is used as a reward signal. Through multiple rounds of interaction with the dialogue environment (the environment can be constructed from historical dialogue data or simulated user models), the generation strategy of the large role model is updated using a policy gradient algorithm (such as Proximal Policy Optimization, PPO). This ensures that the output of high comprehensive quality score is positively reinforced and the output of low score is suppressed, thereby reducing the frequency of triggering corrections in subsequent reasoning stages and improving the overall dialogue stability.
[0081] The following section provides a detailed description of the multi-agent collaborative role model-based personality generation method provided by this invention, using the server as the execution entity.
[0082] In this embodiment of the invention, the server performs initialization configuration before the dialogue begins. Specifically, the server reads and loads the model parameters required for each character's large-scale model, completing the initialization of the character's large-scale model. For example, if the character's large-scale model is obtained through fine-tuning a large-scale pre-trained language model, the server loads the fine-tuned model parameters during initialization; for implementations using a prompting project, the server injects a personality prompt template after loading the model parameters required for the large-scale pre-trained language model.
[0083] Furthermore, to ensure that the character models consistently output responses that align with their established personality traits during dialogues, the server configures corresponding personality parameters for each character model. These personality parameters are a set of parameters used to quantify and represent the personality traits of the character model. They can be in the form of vectors or configuration tables, and include, but are not limited to, numerical indicators of dimensions such as tone friendliness, formality, and empathy intensity. By adjusting these personality parameters, the style of the content generated by the character model can be influenced, making it more consistent with the character model's personality setting. For example, for the customer service personality, tone friendliness is set to 0.92, formality to 0.85, and empathy intensity to 0.88; for the education personality, tone friendliness is set to 0.86, formality to 0.75, and empathy intensity to 0.91; and for the psychological support personality, tone friendliness is set to 0.95, formality to 0.62, and empathy intensity to 0.96.
[0084] In S120, static dialogue context parameters for collaborative dialogue among multiple large role models are configured. The static dialogue context parameters include at least the setting of participating roles, the description of scene background, and environmental constraints. Based on the static dialogue context parameters and the dialogue history, a dynamic dialogue context parameter vector is initialized. The dynamic dialogue context parameter vector includes at least the vector representation of the static dialogue context parameters, the vector representation of the context information of the current dialogue round, the environmental state variables shared by multiple roles, and the dialogue history summary vector, and is shared by multiple large role models.
[0085] Context parameters are a set of parameters used to describe the dialogue context of a large-scale collaborative dialogue involving multiple roles. They consist of static dialogue context parameters and a dynamic dialogue context parameter vector. Static dialogue context parameters are set once at the start of the dialogue and include the roles involved (such as the number of roles, role types, and other identity descriptions), the scene background (such as location, time, and environment), and relevant environmental constraints (such as prior information like business / task constraints). The dynamic dialogue context parameter vector includes references to the static dialogue context parameters, as well as dynamic information that evolves in real-time with the dialogue, such as changes in relationships between roles, topic shifts, and emotional states. Its dimensions and content are specifically determined by the application scenario. For example, in a customer scenario, dynamic information might include the current dialogue topic, user emotional state, historical interaction rounds, and problem-solving progress. In multi-role-playing simulations, dynamic information might also include the scene timeline and known environmental events for each role.
[0086] In this embodiment of the invention, the server configures static context parameters required for collaborative dialogue among multiple large role models according to actual dialogue needs, and initializes a dynamic dialogue context parameter vector based on these static dialogue context parameters and the dialogue history. In specific implementation, the dynamic dialogue context parameter vector can be encoded in vector form. For example, for textual information components, it can be embedded and encoded into real-number vectors through a pre-trained language model; for numerical classifications, it can be mapped to normalized values and directly incorporated into a real-number vector to obtain the vector representation of the dynamic dialogue context parameter vector, denoted as […]. .
[0087] It should be noted that as the dialogue progresses, the server continuously injects new dynamic information into the dynamic dialogue context parameter vector. This allows the system to update and evolve dynamically in real time, ensuring that the large model for each role always generates responses based on the latest dialogue context.
[0088] In S130, in each dialogue round, the target role model to speak is determined among multiple role models, and the dialogue output is generated through the target role model based on the current dialogue input, the personality parameters of the target role model, and the dynamic dialogue context parameter vector.
[0089] In this embodiment of the invention, at the start of each round of dialogue, the server obtains the dialogue input for the current round. This dialogue input can be input by a human user through a terminal device, or it can come from the dialogue output generated by other role models in the previous round. Subsequently, the server selects the role model to speak from multiple role models according to a preset strategy, denoted as the target role model. This strategy can be dynamically decided based on role task priority, context relevance score, or real-time emotion fit. After selecting the target role model, the server uses its personality parameters, the current dialogue input, and the current dynamic dialogue context parameter vector as joint inputs to drive the target role model to generate dialogue output that conforms to its personality settings and is consistent with the dialogue context.
[0090] It should be noted that, mathematically, a large character model can be represented as a dialogue generation function. Formally, a large character model can be denoted as... In the dialogue During the rotation, the large model of the character The target character model was identified, and the character model was used. The generated dialogue output can be represented as: ,in This indicates the dialogue input for the current dialogue turn. This represents the personality parameters of the target character's overall model. A vector representation of the dynamic dialogue context parameter vector for the current dialogue turn. Represented as a large character model The generated dialogue output.
[0091] In S140, the personality consistency score and situational fit score of the dialogue output are calculated, and the personality consistency score and situational fit score are combined to obtain the comprehensive quality score.
[0092] Please refer to the reference. Figure 4 To ensure that the output of each round of dialogue meets the requirements, the server also performs a quality score on the dialogue output generated by the target character's large model, including two dimensions: personality consistency and situational matching.
[0093] First, the server outputs the dialogue generated from the target character's large model. Mapping to vector representation The server can use semantic encoding models, such as context representation models, to obtain the dialogue output. vector representation Alternatively, the dialogue output can be obtained using methods such as the mean value represented by the word embedding matrix. vector representation .
[0094] Subsequently, the server calculates the personality consistency score of the dialogue output. For example, the server may use cosine similarity to calculate the personality consistency score. , represented as:
[0095] ;
[0096] in, Represents the personality parameters of the target role model Vector numerical representation, " represents the vector dot product, Let represent the Euclidean norm of the vector. It is understandable that the above formula yields... The value range is [-1, 1]. For ease of evaluation, the server further... Perform linear normalization mapping to the [0,1] interval, letting 1 represent complete consistency and 0 represent complete inconsistency. When and When all eigenvectors are non-negative, the cosine similarity is already within the range [0,1]. It can be used directly.
[0097] In addition, the server also calculates a context matching score for the dialogue output. For example, the server also uses cosine similarity to calculate the context matching score. , represented as:
[0098] ;
[0099] Obtained by cosine similarity calculation The server then normalizes it to the [0, 1] interval. In practice, to avoid division by zero errors, a minimum value can be added to the denominator in the calculation. (like ), to ensure or The calculation is stable when the value is close to 0.
[0100] Finally, the server integrates the personality consistency scores calculated above. Context matching score This yields a comprehensive quality score for the dialogue output. No specific restrictions are placed on the method of merging the two values; it may include, but is not limited to, taking the arithmetic mean, minimum value, maximum value, or weighted sum.
[0101] For example, the server uses a weighted sum to calculate the overall quality score. , represented as:
[0102] To avoid inconvenience for reviewers by expressing it solely as a formula, the overall quality score can be represented in words as: Overall Quality Score Personality Consistency Score Context matching score .
[0103] ;
[0104] in, and These are non-negative weighting coefficients used to balance personality consistency scores. Context matching score The importance of two dimensions, and satisfying the following: For example, when no bias is applied to any dimension, one can take... In order to achieve equal rights for both.
[0105] Based on the above calculations, the overall quality score is... The value range is specified as [0,1]. The larger the value, the better the dialogue output performs in terms of personality consistency and situational matching.
[0106] In S150, if the overall quality score reaches the scoring threshold, the dialogue output with the overall quality score reaching the scoring threshold is published, and the dynamic dialogue context parameter vector and the personality parameters of the target role model are updated before proceeding to the next dialogue round, until the dialogue ends; or, if the overall quality score does not reach the scoring threshold, a correction strategy is determined based on the personality consistency score and the context matching score, and the correction strategy is executed to adjust the personality parameters and / or generation constraints of the target role model and regenerate the dialogue output, until the target role model generates a dialogue output with the overall quality score reaching the scoring threshold or the number of correction iterations reaches the number threshold; the dialogue output with the overall quality score reaching the scoring threshold is published, or the dialogue output with the highest overall quality score during the iteration process is published when the number of correction iterations reaches the number threshold, and the dynamic dialogue context parameter vector and the personality parameters of the target role model are updated based on the overall quality score before proceeding to the next dialogue round, until the dialogue ends.
[0107] It should be noted that the embodiments of the present invention also include a scoring threshold. This scoring threshold is used to constrain whether the dialogue output meets the standard, and when the overall quality score is... Reaching the scoring threshold When the dialogue output is deemed satisfactory, the overall quality score is determined. The scoring threshold was not met. The dialogue output is deemed unsatisfactory at that time. Among these, the scoring threshold... It can be set according to the actual application requirements. For example, for scenarios with strict requirements, a higher threshold can be selected to pursue higher consistency.
[0108] When the server determines that the dialogue output meets the standard, that is, when the overall quality score of the dialogue output reaches the scoring threshold, the server publishes the dialogue output to the recipient of the current dialogue round. The recipient can be a human user or the next role model to respond.
[0109] Furthermore, the server updates the dynamic dialogue context parameter vector based on the dynamic information of the current dialogue turn. This involves updating the context of the current dialogue, such as recording new questions raised by the user, changes in the environment, or the user's emotional state, resulting in a vector representation of the updated dynamic dialogue context parameter vector. ,make It can reflect the latest dialogue context.
[0110] In addition, the server updates the personality parameters of the target character's large model. For example, the server can increase the weight of each personality dimension in the personality parameters according to a preset ratio.
[0111] The server then enters the next round of dialogue loop until the dialogue end condition is met. The dialogue end condition can be set according to actual needs, such as the number of dialogue rounds reaching a threshold or the user exiting.
[0112] In this embodiment of the invention, when the overall quality score of the dialogue output generated by the target role's large model does not reach the scoring threshold, the server initiates a correction process.
[0113] Please refer to Figure 5 The server first analyzes the personality consistency score. Context matching score The specific values are used to determine the main source of deviation (personality consistency dimension or situational matching dimension, or both). Subsequently, the server determines the correction strategy corresponding to the source of deviation, and executes the correction strategy to adjust the personality parameters and / or generation constraints of the target character's large model and regenerate the dialogue output. This process is iterated until the target character's large model generates dialogue output with a comprehensive quality score that reaches the scoring threshold.
[0114] Specifically, if the overall quality score of the dialogue output generated by the target role's large model reaches the scoring threshold before the number of iterations for executing the correction strategy reaches the threshold, then the dialogue output with the overall quality score reaching the scoring threshold is published, and the dynamic dialogue context parameter vector and the personality parameters of the target role's large model are updated based on the overall quality score before proceeding to the next dialogue round, until the dialogue ends; or, if the overall quality score of the dialogue output generated by the target role's large model still does not reach the scoring threshold when the number of iterations for executing the correction strategy reaches the threshold, then the dialogue output with the highest overall quality score during the iteration process is published, and the dynamic dialogue context parameter vector and the personality parameters of the target role's large model are updated based on the overall quality score before proceeding to the next dialogue round, until the dialogue ends.
[0115] After implementing the determined correction strategy, the server regenerates the dialogue output using the large role model. Typically, one correction can significantly improve the score. If the overall quality score of the regenerated dialogue output still does not reach the scoring threshold, the server can continue to adjust based on the effect of the previous correction. For example, if the personality consistency score improves significantly after the first correction but the situational fit score remains low, the server can focus on strengthening the situational fit dimension during the second correction process, i.e., preferentially selecting a correction strategy based on the situational fit dimension.
[0116] It should be noted that excessive iterations will increase server response latency and negatively impact user experience. Therefore, this embodiment of the invention also includes a threshold number to constrain the number of correction iterations. The threshold number... This can be set according to the application scenario. Typically, the number of attempts threshold is... The value range is configured to be 1 to 3. When the user has a high tolerance for response latency, the threshold number of times can be adjusted. The value range is configured to be 1 to 5. The number of threshold values in this embodiment of the invention... Configured as In other words, each round of dialogue allows the large character model to undergo two corrections and regenerations based on an initial generation. If the overall quality score of the dialogue output generated by the two corrections does not reach the score threshold, the server will publish the dialogue output with the highest overall quality score during the iteration process, and then update the dynamic dialogue context parameter vector before entering the next dialogue round.
[0117] In other embodiments, when the determined correction strategy includes enhancing the weight of relevant biased personality dimensions in the personality parameters of the target character model, the server can record the cumulative number of times different personality dimensions are identified as biased personality dimensions. When the cumulative number of identifications for a certain personality dimension reaches a preset threshold, the server can enhance the weight of that personality dimension in the personality parameters and reset the cumulative number of identifications for that personality dimension. This allows for online fine-tuning of the personality parameters, enabling the character model to gradually strengthen easily missing personality traits. Furthermore, to ensure the overall stability of the character model's personality, when enhancing a personality dimension whose cumulative number of identifications reaches a preset threshold, the server can enhance the weight of that personality dimension in the personality parameters according to a preset ratio, where the preset ratio is configured to not exceed 10%.
[0118] In other embodiments, the server also records the error correction strategies executed and the score changes resulting from the execution of the error correction strategies. When enough data is accumulated, the server can analyze in what situations which deviations occur frequently and improve model training or refine error correction strategies accordingly, so that the large role model will need to trigger error correction less often in the future.
[0119] In other embodiments, the triggering conditions for the correction process can be based not only on the overall quality score but also on more granular rules set according to specific scenarios. For example, in some highly sensitive scenarios, when either the personality consistency score or the situational matching score falls below a scoring threshold, the correction process is triggered regardless of whether the overall quality score reaches the scoring threshold. Alternatively, for newly launched, insufficiently trained large-scale role models, a higher scoring threshold can be temporarily adopted to more rigorously filter outputs. In practical implementation, those skilled in the art can adjust the scoring threshold strategy according to actual needs to achieve a balance between response quality and timeliness.
[0120] Optionally, in one embodiment, determining a corrective strategy based on personality consistency score and situation fit score includes:
[0121] If the personality consistency score is lower than the situational matching score, the corrective strategy is to enhance the weight of the relevant biased personality dimensions in the personality parameters of the target role's large model, inject personality reinforcement prompts, and / or regenerate the dialogue output.
[0122] If the situational fit score is lower than the personality consistency score, the corrective strategy is to supplement the missing situational elements in the dialogue input and / or inject situational reinforcement cues.
[0123] Specifically, when the personality consistency score is lower than the situational matching score, and the situational matching score reaches the scoring threshold, the server determines that the main source of deviation is the personality consistency dimension. The corresponding correction strategy is to increase the weight of the relevant deviation personality dimension (i.e., the personality dimension whose matching score reaches the scoring threshold) in the target character's large-scale personality parameters, inject personality reinforcement prompts, and / or regenerate the dialogue output (i.e., directly regenerate the dialogue output). For example, the server can choose one or more of the aforementioned correction strategies based on the difference between the personality consistency score and the situational matching score. If the difference is small, the server can simply increase the weight of the relevant deviation personality dimension in the target character's large-scale personality parameters, or inject personality reinforcement prompts (e.g., please reply to the user in a very polite and patient tone, avoiding harsh wording). If the difference is large, the server increases the weight of the relevant deviation personality dimension in the target character's large-scale personality parameters while simultaneously injecting personality reinforcement prompts.
[0124] When the context matching score is lower than the personality consistency score, and the personality consistency score reaches the scoring threshold, the server determines that the main source of deviation is the context matching dimension, and accordingly determines the correction strategy to supplement the missing context elements in the dialogue input and / or inject context reinforcement prompts.
[0125] For example, the server can analyze the dialogue context and identify missing contextual elements in the dialogue output. Suppose that the user mentioned in a previous dialogue round that he is an elderly person, but the dialogue output generated by the target persona model did not take into account that the user is an elderly person, then the supplementary contextual element could be "the user mentioned before that he is an elderly person", thereby guiding the persona model to generate more understandable dialogue output.
[0126] In other embodiments, if both the personality consistency score and the situational fit score are below the scoring threshold, the server can combine the above two dimensions of personality consistency and situational fit correction strategies to provide weighted guidance on both aspects.
[0127] In an optional implementation, pre-defined correction strategy rules can be used to select a correction strategy based on the deviation relationship between the personality consistency score and the situational fit score. An example is shown below (for illustrative purposes only and not constituting a limitation):
[0128] Conditions: Low personality consistency score and normal / high situation fit score
[0129] Personality correction strategies include: increasing the weight of biased personality dimensions in the personality parameters (e.g., adjusting the weight of dimensions such as "politeness / empathy intensity" by a preset step size), injecting personality reinforcement prompts (e.g., "Please reply with a more polite, patient, and empathetic tone"), and regenerating dialogue output.
[0130] Condition: Low situational matching score
[0131] Contextual correction strategy: Extract missing contextual elements from the dialogue history and add them to the dialogue input (e.g., user identity, confirmed facts, task constraints), inject contextual reinforcement prompts (e.g., "Please answer strictly based on the current scenario and known facts to avoid deviating from the topic"), and regenerate the dialogue output;
[0132] Conditions: Low scores on both personality consistency and situation fit.
[0133] Comprehensive corrective strategy: Simultaneously enhance personality parameter constraints and supplement contextual elements, and regenerate dialogue output, iterating according to the number of times threshold when necessary.
[0134] Optionally, in one embodiment, calculating the personality consistency score and situational fit score of the dialogue output includes:
[0135] For each context dimension of the dynamic dialogue context parameter vector, calculate the matching score of the dialogue output on that context dimension, and fuse the matching scores of each context dimension to obtain the context matching score of the dialogue output.
[0136] For each personality dimension of the target character's large model, calculate the matching score of the dialogue output on that personality dimension, and merge the matching scores of each personality dimension to obtain the personality consistency score of the dialogue output.
[0137] In this embodiment of the invention, for each context dimension (such as context, scene, dialogue topic, etc.) of the dynamic dialogue context parameter vector, the server calculates the matching score of the dialogue output on that context dimension. , represented as:
[0138] ;
[0139] in, The vector representing the dynamic dialogue context parameter vector is the vector component of the i-th context dimension. The vector representation of the dialogue output generated for the target character's large model. " represents the vector dot product, The Euclidean norm of a vector is denoted by .
[0140] Subsequently, the server integrates the matching scores from each context dimension to obtain the context matching score for the dialogue output. , represented as:
[0141] ;
[0142] in, This represents the weight coefficient for the i-th context dimension, and its value can be selected according to actual needs.
[0143] Similarly, for each personality dimension of the target character's large model (such as tone of approachability, formality of expression, and empathy intensity), the server calculates the matching score of the dialogue output on that personality dimension. , represented as:
[0144] ;
[0145] in, This represents the vector numerical representation of the j-th personality dimension in the personality parameters of the target character's large model.
[0146] Subsequently, the server integrates the matching scores from various personality dimensions to obtain the personality consistency score of the dialogue output. , represented as:
[0147] ;
[0148] in, This represents the weight coefficient of the j-th personality dimension, and its value can be selected according to actual needs.
[0149] As shown above, by using the more refined personality consistency scoring method and situation matching scoring method, more accurate personality consistency scores and situation matching scores can be obtained.
[0150] Optionally, in one embodiment, updating the personality parameters of the target character's large model includes:
[0151] Identify the positive personality dimensions relative to the personality consistency score in the personality parameters of the target role's large model, and increase the weight of this positive personality dimension according to a preset ratio.
[0152] When updating the personality parameters of the target character's large model, the server first determines the positive personality dimensions relative to the personality consistency score, i.e., the personality dimensions whose matching score reaches the scoring threshold. Then, the server increases the weight of this positive personality dimension according to a preset ratio. For example, if the server determines that empathy intensity is a positive personality dimension, and the preset ratio is 4%, and the empathy intensity is 0.82, the server will increase it by 4%, making it 0.85.
[0153] Optionally, in one embodiment, the multi-agent collaborative role-based large-scale model personality generation method provided by the present invention further includes:
[0154] The dialogue scenario to which the current dialogue belongs is determined based on the dynamic dialogue scenario parameter vector, and the scoring threshold is determined based on the dialogue scenario.
[0155] In this embodiment of the invention, to balance response quality and response latency, the server dynamically adjusts the scoring threshold based on the dialogue scenario. Specifically, the server first determines the dialogue scenario to which the current dialogue belongs based on a dynamic dialogue context parameter vector, and then determines the appropriate scoring threshold for the current dialogue round based on a preset correspondence between dialogue scenarios and scoring thresholds.
[0156] For example, for dialogue scenarios that require strict control (such as medical consultations and legal Q&A), a higher scoring threshold, such as 0.9, can be set, while for dialogue scenarios that require quick responses (such as casual conversations and customer service), a lower scoring threshold, such as 0.6, can be set.
[0157] To facilitate understanding of the multi-agent collaborative role-based large-scale model for generating empathic personalities provided by this invention, the following explanation is provided in conjunction with a specific dialogue scenario:
[0158] Customer Service Scenario: The large-scale role model acts as a customer service robot, engaging in multiple rounds of interaction with users. Static dialogue context parameters include customer service role settings (such as "patient, polite, professional"), the company's business knowledge base, and service process specifications. During the dialogue, dynamic dialogue context parameter vectors record information such as the user's current problem type, emotional state, and the steps of the provided solutions. Through personality consistency and context matching scoring, the server ensures that every response from the large-scale role model conforms to the company's required polite and professional personality and is closely related to the user's problem context. For example, when encountering an emotionally agitated user, the large-scale role model may momentarily adopt a harsh tone due to the complex context. The server immediately detects low personality consistency and adjusts the large-scale role model's tone, strengthening the weight of the "patience level" and "empathy intensity" personality dimensions to respond more patiently to the user's confusion, thereby resolving the user's emotions. Throughout the service dialogue, regardless of how the user's question changes, the large-scale role model will always maintain a friendly and patient attitude (i.e., high personality consistency), and the answers provided will strictly adhere to the product information provided by the company and the current problem context (i.e., high context matching). Compared to ordinary customer service robots that do not employ the mechanism of this invention, this invention can effectively avoid inappropriate tone or irrelevant answers, thereby improving user satisfaction and consistent perception of brand services. Actual testing shows that after introducing the solution of this invention, user satisfaction with the customer service robot significantly improves, especially in long conversations and with multiple follow-up questions. The overall role model maintains a stable service level, demonstrating the significant practical value of this invention in customer service scenarios.
[0159] Educational Scenario: This invention can also be applied to intelligent educational tutoring systems to achieve personalized teaching dialogues. Static dialogue scenario parameters include teacher role settings (e.g., knowledgeable and patient), teaching subjects, and student grade levels; dynamic dialogue scenario parameter vectors dynamically maintain information such as the current course topic, student's mastered knowledge points, student emotions, and concentration. A large role model acts as a virtual teacher, interacting with students (either a real person or simulated by another large role model) through question-and-answer sessions. Through this invention, the virtual teacher maintains a consistent personality throughout the teaching dialogue—demonstrating extensive knowledge while consistently responding to students with patient encouragement. For example, when a student repeatedly answers questions incorrectly and becomes discouraged, the dynamic dialogue scenario parameter vector reflects this state. If the large role model fails to provide adequate encouragement and comfort in a particular response, a correction mechanism will adjust its response, incorporating encouraging language to help the student regain confidence; simultaneously ensuring that the explanation remains simple and easy to understand, commensurate with the student's current level. On the other hand, if the virtual teacher's explanations tend to be too difficult or off-topic (e.g., using concepts beyond the students' level, leading to a drop in contextual matching scores), the server will detect and correct this promptly, guiding the teacher to explain in a simpler way or steer the discussion back to the main topic. In actual teaching tests, the virtual teacher using this invention can adapt to student feedback more flexibly: it won't suddenly increase the difficulty beyond students' comprehension after one or two correct answers, nor will it change its initial intention of patiently guiding students when they make mistakes; the entire teaching process is coherent and natural. Students generally report that the intelligent teacher is "always gentle and explains things step by step," resulting in a good learning experience. This demonstrates that this invention effectively ensures the consistency of the teaching personality and content rhythm in educational dialogue scenarios, contributing to improved teaching interaction.
[0160] Psychological Support Scenario: This invention can also be applied to dialogue systems for psychological counseling or emotional support, helping to provide a long-term communication experience of empathetic care. Basic scenario parameters include the role setting of the psychological counselor (e.g., "empathy, patience, positive guidance"), the dialogue scenario (online chat or offline meeting), and the user's general background. During the dialogue, the dynamic dialogue scenario parameter vector continuously summarizes information such as the user's current psychological state, main concerns, and emotional changes. The role model engages in dialogue with the user as a virtual psychological counselor. Through the dual constraints of personality consistency and scenario matching, the server ensures that the virtual psychological counselor always demonstrates an empathetic and understanding attitude, providing appropriate responses to the user's questions, regardless of the duration of the dialogue. For example, when a user pours out negative emotions for a long time, the virtual psychological counselor maintains a patient and gentle tone in subsequent responses, and can cite details previously mentioned by the user to show understanding and care, without becoming perfunctory or impatient due to repetitive topics or the passage of time. If a response shows signs of being abrupt or off-topic, the server will intervene in time to adjust it, bringing the response back to the track of caring listening. Through dual-rating feedback, the virtual psychological counselor establishes a consistent and credible image throughout multiple interactions with the user: it neither suddenly displays impatience or indifference, nor forgets important details previously revealed by the user, ensuring the user always feels valued and understood. Real user testing feedback shows that compared to ordinary chat models without this invention's mechanism, the virtual psychological counselor using this invention significantly improves the warmth and continuity of the conversation, making users more willing to engage in prolonged communication and gain emotional comfort. This further demonstrates the practical value of this invention in scenarios requiring a high degree of personality consistency, such as psychological support.
[0161] To verify the effectiveness of this invention, comparative experiments were conducted in the three typical dialogue scenarios mentioned above. Several real or simulated dialogues were selected for testing in each scenario, with a sample size of 50 rounds of dialogue. The large-scale role model used was a Transformer model with approximately 7 billion parameters, fine-tuned and trained using approximately 200,000 rounds of dialogue data. The dialogue data covered three personality scenarios—customer service, education, and psychological support—in roughly equal proportions, enabling the model to possess various personality traits. The control group used a traditional method (providing fixed personality setting prompts only at the beginning of the dialogue, without dynamic scoring or correction during the dialogue), while the experimental group used the dual scoring and correction mechanism of personality consistency + situational matching of this invention.
[0162] In all test dialogues, the overall quality score of each round of role-model responses was recorded, and the average overall quality score for the entire dialogue was calculated as the evaluation index. Statistical results show that the average overall quality score of the experimental group dialogues was significantly higher than that of the control group. Specifically, in the customer service scenario, the average overall quality score of the control group was approximately 0.80, which increased to approximately 0.93 after using the method of this invention, with the standard deviation decreasing from 0.10 to 0.04; in the education scenario, the average score of the control group was approximately 0.78, which increased to 0.94, with the standard deviation decreasing from 0.12 to 0.05; and in the psychological support scenario, the average score of the control group was approximately 0.70, which increased to 0.90, with the standard deviation decreasing from 0.15 to 0.06. Independent samples t-tests were performed on the data from the three scenarios, and the score improvements were statistically significant (p-values were all less than 0.01). Overall, the overall quality score of the experimental group dialogues increased by an average of approximately 15%–20%, with significantly reduced volatility. This indicates that this invention effectively reduces abnormal responses that are inconsistent with personality or context through real-time evaluation and adjustment, making the dialogue performance of the role-model more stable and consistent.
[0163] In addition to the quantitative evaluation indicators mentioned above, a human quality assessment was also conducted. Multiple assessors blindly scored the collected dialogue samples. The human assessment used a unified scoring standard, with each assessor rating the dialogues on a scale of 1 to 5 (5 being the highest) across three dimensions: personality consistency, situational relevance, and overall naturalness. To verify the consistency of scores from different assessors, the Fleiss-Kappa consistency coefficient was calculated, resulting in approximately 0.82, indicating high reliability of the human scoring. The assessment results showed that the experimental group outperformed the control group in all dimensions: the average score for personality consistency increased by approximately 0.8 points (out of 5), situational relevance increased by approximately 1.0 point, and overall naturalness increased by approximately 0.7 points.
[0164] Based on the combined quantitative and manual evaluation results, it can be determined that the present invention has achieved significant results in maintaining consistency between the dialogue personality and the context.
[0165] It should be noted that, in addition to the typical dialogue scenarios mentioned above, this invention can also be applied to various dialogue scenarios that require personality shaping and situational understanding, including but not limited to the following aspects:
[0166] Gaming and Interactive Entertainment: In role-playing games, virtual streamers, and other similar scenarios, this invention can endow each virtual character with a persistent and stable personality setting, adapting to the context based on the storyline and player interaction. Dialogues between multiple NPCs (non-player characters) or between NPCs and players will be more coherent and engaging, preventing confusion regarding each character's persona. For example, in detective games, each suspect NPC maintains their unique personality and tone, responding appropriately to the development of the game situation, thus enhancing game immersion.
[0167] Intelligent Assistants and Customer Management: For products such as smart speakers and intelligent assistants, this invention can be used to construct assistant characters with different personality styles, ensuring consistency and contextual appropriateness in long-term interactions with users. For example, a fitness coach-type assistant can consistently demonstrate a positive and cheerful personality, providing encouragement when users are feeling down or slacking off in their training, and dynamically adjusting communication strategies to adapt to the user's daily state. This will lead to better user engagement and satisfaction.
[0168] Medical Consultation and Advisory: This invention can be applied to scenarios such as medical consultation robots and multi-departmental collaborative diagnostic systems. Different departmental or professional role models possess their own professional backgrounds and communication styles. By sharing patient condition context parameters, information synchronization among multiple role models is ensured, and they communicate with patients using a consistent and friendly tone, reducing information gaps and repetitive questions and answers, allowing patients to feel continuous and consistent care. For scenarios such as financial advisory and legal consultation, multiple role models can also utilize this invention to work collaboratively, ensuring consistent and rigorous professional answers while communicating with a consistent service personality (such as reliability and integrity).
[0169] Collaborative Intelligent Writing and Content Generation: In content generation tasks such as long-form story creation and multi-character script dialogue, the method of this invention can be used to maintain the consistency of language style among each character's macro-model. When multiple character macro-models collaborate on a novel, each macro-model is responsible for the dialogue or perspective description of different characters. Through dual scoring constraints and correction mechanisms, character personality deviations can be prevented, and plot consistency can be ensured. Dynamic dialogue context parameter vectors share the plot context, enabling all character macro-models to have a consistent understanding of the story background, thereby generating coherent multi-perspective novel text.
[0170] Furthermore, the method of this invention can also be used to control the consistency of character personalities and adapt to context in multilingual dialogue systems. For example, character expressions may be direct and enthusiastic in an English environment, while they may be tactful and polite in a Japanese environment. This invention can match cultural differences by adjusting the weights of personality parameters, while the dynamic dialogue context parameter vector includes cultural context, making the output conform to local customs. In this way, the large-scale character model in multiple languages can still maintain the consistency of personality and context in their respective languages and cultures, providing a consistent and localized experience for global users.
[0171] As can be seen from the above, the multi-agent collaborative role-model context-based personality generation scheme provided by this invention, through a dual scoring mechanism of personality consistency and context matching, enables multiple role-models to maintain consistency in their personality traits during long dialogues, significantly reducing inconsistencies in character personality and inconsistent tone of voice. Secondly, this invention introduces a dynamic dialogue context parameter vector to uniformly manage the dialogue context, ensuring that all role-models have a consistent understanding of the dialogue context, thereby avoiding answer deviations caused by information asymmetry or contextual misunderstandings between roles, and greatly improving the coherence and relevance of multi-role-model collaborative dialogues. Thirdly, the real-time personality correction iteration mechanism of this invention enables the system to automatically correct abnormal outputs during operation without manual intervention or offline retraining, enhancing its adaptability and robustness to abnormal situations. Through the above technical means, this invention ensures personality consistency while taking into account context matching, achieving dynamic optimization of dialogue quality. This overcomes the limitations of relying solely on static presets or rule control, and avoids the costs associated with simply increasing training data and model complexity.
[0172] To facilitate better implementation of the above-described multi-agent collaborative role-large model contextual personality generation method, this invention also provides a corresponding multi-agent collaborative role-large model contextual personality generation device. The meanings of the terms used are the same as in the above-described multi-agent collaborative role-large model contextual personality generation method; for specific implementation details, please refer to the descriptions in the above method embodiments.
[0173] Please refer to Figure 6 The multi-agent collaborative role model contextual personality generation device may include a role initialization module 210, a context initialization module 220, a dialogue generation module 230, a quality scoring module 240, a dialogue correction module 250, and a parameter update module 260. Detailed descriptions of each functional module are as follows:
[0174] The character initialization module 210 is used to initialize multiple large character models and configure corresponding personality parameters for each large character model.
[0175] The context initialization module 220 is used to configure the static dialogue context parameters for collaborative dialogue among multiple role models, and to initialize the dynamic dialogue context parameter vector based on the static dialogue context parameters and the current dialogue history. The dynamic dialogue context parameter vector includes at least the encoded representation of the static dialogue context parameters and the dynamic context encoding of the current dialogue context, and is shared by multiple role models.
[0176] The dialogue generation module 230 is used to determine the target role model to speak among multiple role models in each dialogue round, and generate dialogue output through the target role model based on the current dialogue input, the personality parameters of the target role model, and the dynamic dialogue context parameter vector.
[0177] The quality scoring module 240 is used to calculate the personality consistency score and situation matching score of the dialogue output, and to merge the personality consistency score and situation matching score to obtain a comprehensive quality score.
[0178] The dialogue correction module 250 is used to determine a correction strategy based on the personality consistency score and the situation matching score when the overall quality score does not reach the scoring threshold. The correction strategy is then executed to adjust the personality parameters and / or generation constraints of the target role model and regenerate the dialogue output. This process is repeated until the overall quality score reaches the scoring threshold or the number of correction iterations reaches the number threshold.
[0179] The parameter update module 260 publishes dialogue outputs when the overall quality score reaches the score threshold, or publishes the dialogue output with the highest overall quality score during the iteration process when the number of correction iterations reaches the number threshold. After updating the dynamic dialogue context parameter vector and the personality parameters of the target role's large model, it enters the next dialogue round until the dialogue ends.
[0180] Optionally, in one embodiment, the quality scoring module 240 is used to calculate a weighted sum of the personality consistency score and the situational fit score as a comprehensive quality score based on the respective weight coefficients of the personality consistency score and the situational fit score.
[0181] Optionally, in one embodiment, the dialogue correction module 250 is used to determine, when the personality consistency score is lower than the situational matching score, the correction strategy is to enhance the weight of the relevant biased personality dimension in the personality parameters of the target role model, inject personality reinforcement prompts, and / or regenerate the dialogue output; or when the situational matching score is lower than the personality consistency score, the correction strategy is to supplement the missing situational elements in the dialogue input and / or inject situational reinforcement prompts.
[0182] Optionally, in one embodiment, the quality scoring module 240 is used to: calculate the matching score of the dialogue output on each context dimension of the dynamic dialogue context parameter vector, and merge the matching scores of each context dimension to obtain the context matching score of the dialogue output; and calculate the matching score of the dialogue output on each personality dimension of the personality parameters of the target role model, and merge the matching scores of each personality dimension to obtain the personality consistency score of the dialogue output.
[0183] Optionally, in one embodiment, the parameter update module 260 is used to determine the positive personality dimension relative to the personality consistency score in the personality parameters of the target character model, and to increase the weight of the positive personality dimension according to a preset ratio.
[0184] Optionally, in one embodiment, the multi-agent collaborative role model contextual personality generation device provided by the present invention further includes a threshold determination module, which is used to determine the dialogue scenario to which the current dialogue belongs based on the dynamic dialogue scenario parameter vector, and to determine the scoring threshold based on the dialogue scenario.
[0185] Specific limitations regarding the multi-agent collaborative role-based large-scale model shared-context personality generation device can be found in the limitations of the multi-agent collaborative role-based large-scale model shared-context personality generation method described above, and will not be repeated here. Each module in the aforementioned multi-agent collaborative role-based large-scale model shared-context personality generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0186] In one embodiment, a computer device is provided, the internal structure of which can be shown as follows: Figure 7 As shown. The computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and the database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface connects to external wireless clients, providing wireless network access services to the connected clients. When the computer device is configured as a server, the computer program is executed by the processor to implement the multi-agent collaborative role-based large-scale model empathic personality generation method provided by this invention, for example:
[0187] Initialize multiple character models and configure corresponding personality parameters for each character model;
[0188] Configure static dialogue context parameters for collaborative dialogue among multiple role-based large models, and initialize dynamic dialogue context parameter vectors based on static dialogue context parameters and the current dialogue history. The dynamic dialogue context parameter vectors include at least the vector representation of static dialogue context parameters, the vector representation of context information of the current dialogue round, the environmental state variables shared by multiple roles, and the dialogue history summary vector, and are shared by multiple role-based large models.
[0189] In each dialogue round, the target role model to speak is determined among multiple role models, and the dialogue output is generated through the target role model based on the current dialogue input, the personality parameters of the target role model, and the dynamic dialogue context parameter vector.
[0190] Calculate the personality consistency score and situational fit score of the dialogue output, and fuse the personality consistency score and situational fit score to obtain a comprehensive quality score;
[0191] If the overall quality score does not reach the scoring threshold, a correction strategy is determined based on the personality consistency score and situational matching score. The correction strategy is then executed to adjust the personality parameters and / or generation constraints of the target role's large model and regenerate the dialogue output until the target role's large model generates a dialogue output with an overall quality score that reaches the scoring threshold or the number of correction iterations reaches the number threshold. The dialogue output with an overall quality score that reaches the scoring threshold is published, or the dialogue output with the highest overall quality score during the iteration process is published when the number of correction iterations reaches the number threshold. The dynamic dialogue situational parameter vector and the personality parameters of the target role's large model are updated based on the overall quality score before entering the next dialogue round, until the dialogue ends.
[0192] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the multi-agent collaborative role model empathy personality generation method described in the above embodiment.
[0193] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the multi-agent collaborative role-based large-scale model personality generation method described in the above embodiment.
[0194] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0195] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0196] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for generating a multi-agent collaborative role model in a shared context, characterized in that, include: Initialize multiple character models and configure corresponding personality parameters for each character model; Configure static dialogue context parameters for collaborative dialogue among multiple large role models, and initialize a dynamic dialogue context parameter vector shared by multiple large role models based on the static dialogue context parameters and the current dialogue history. The dynamic dialogue context parameter vector includes at least a vector representation of the static dialogue context parameters, a vector representation of the context information of the current dialogue round, environmental state variables shared by multiple roles, and a dialogue history summary vector. In each dialogue round, a target role model to speak is determined from among multiple role models, and a dialogue output is generated through the target role model based on the current dialogue input, the personality parameters of the target role model, and the dynamic dialogue context parameter vector. Calculate the personality consistency score and situation matching score of the dialogue output, and fuse the personality consistency score and the situation matching score to obtain a comprehensive quality score; If the overall quality score does not reach the scoring threshold, a correction strategy is determined based on the personality consistency score and the situation matching score. When the personality consistency score is lower than the situation matching score, the correction strategy includes increasing the weight of relevant deviation personality dimensions in the personality parameters of the target role model and injecting personality reinforcement prompts. When the situation matching score is lower than the personality consistency score, the correction strategy includes supplementing the missing situational elements in the current dialogue input and / or injecting situation reinforcement prompts. The correction strategy is executed to adjust the personality parameters and / or generation constraints of the target character model and regenerate the dialogue output until the target character model generates a dialogue output with a comprehensive quality score that reaches the score threshold or the number of correction iterations reaches the number threshold; the dialogue output with a comprehensive quality score that reaches the score threshold is published, or the dialogue output with the highest comprehensive quality score during the iteration process is published when the number of correction iterations reaches the number threshold. The dynamic dialogue context parameter vector is updated based on the dynamic information of the current dialogue round, and the positive personality dimension relative to the personality consistency score in the personality parameters of the target role model is determined. The weight of the positive personality dimension is increased according to a preset ratio before entering the next dialogue round, until the dialogue ends. The positive personality dimension is the personality dimension whose matching score reaches the scoring threshold.
2. The method for generating a multi-agent collaborative role model in a shared context according to claim 1, characterized in that, The integrated quality score obtained by fusing the personality consistency score and the situational fit score includes: The weighted sum of the personality consistency score and the situation matching score is calculated as the comprehensive quality score based on the respective weight coefficients of the personality consistency score and the situation matching score.
3. The method for generating a multi-agent collaborative role-based large-scale model personality in the same context as described in claim 1, characterized in that, The calculation of the personality consistency score and situational fit score of the dialogue output includes: For each context dimension of the dynamic dialogue context parameter vector, calculate the matching score of the dialogue output on that context dimension, and fuse the matching scores of each context dimension to obtain the context matching score of the dialogue output. For each personality dimension of the target character's large model, the matching score of the dialogue output on that personality dimension is calculated, and the matching scores of each personality dimension are merged to obtain the personality consistency score of the dialogue output.
4. The method for generating a multi-agent collaborative role-based large-scale model for personality in the same context according to any one of claims 1-3, characterized in that, Also includes: The current dialogue scenario is determined based on the dynamic dialogue context parameter vector, and the scoring threshold is determined based on the dialogue scenario.
5. A multi-agent collaborative role-playing large-scale model personality generation device, characterized in that, include: The character initialization module is used to initialize multiple large character models and configure corresponding personality parameters for each large character model. The context initialization module is used to configure static dialogue context parameters for collaborative dialogue among multiple role models, and to initialize a dynamic dialogue context parameter vector shared by multiple role models based on the static dialogue context parameters and the current dialogue history. The dynamic dialogue context parameter vector includes at least the encoded representation of the static dialogue context parameters, the dynamic context encoding of the current dialogue context, the environmental state variables shared by multiple roles, and the dialogue history summary vector. The dialogue generation module is used to determine the target role model to speak among multiple role models in each dialogue round, and generate dialogue output through the target role model based on the current dialogue input, the personality parameters of the target role model, and the dynamic dialogue context parameter vector. The quality scoring module is used to calculate the personality consistency score and situation matching score of the dialogue output, and to fuse the personality consistency score and situation matching score to obtain a comprehensive quality score. The dialogue correction module is used to determine a correction strategy based on the personality consistency score and the situation matching score when the overall quality score does not reach the scoring threshold. Specifically, when the personality consistency score is lower than the situation matching score, the correction strategy includes increasing the weight of relevant deviation personality dimensions in the personality parameters of the target character model and / or injecting personality reinforcement prompts; when the situation matching score is lower than the personality consistency score, the correction strategy includes supplementing the missing situational elements in the current dialogue input and injecting situation reinforcement prompts; after adjusting the personality parameters and / or generation constraints of the target character model using the correction strategy, the dialogue output is regenerated until the target character model generates a dialogue output with an overall quality score reaching the scoring threshold or the number of correction iterations reaches the number threshold. The parameter update module is used to publish dialogue outputs with a comprehensive quality score reaching the score threshold, or to publish the dialogue output with the highest comprehensive quality score during the iteration process when the number of correction iterations reaches the number threshold. It also updates the dynamic dialogue context parameter vector based on the dynamic information of the current dialogue round, and determines the positive personality dimension in the personality parameters of the target role's large model relative to the personality consistency score. After increasing the weight of the positive personality dimension according to a preset ratio, it enters the next dialogue round until the dialogue ends. The positive personality dimension is the personality dimension with a matching score reaching the score threshold.
6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the multi-agent collaborative role-based large model empathy personality generation method according to any one of claims 1 to 4.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the multi-agent collaborative role-based large model empathy personality generation method according to any one of claims 1 to 4.