Multi-agent collaborative role large model same-environment personality generation method and related product
By employing a multi-agent collaborative role-based large-scale model for generating empathic personalities, the problems of personality consistency and context matching in multi-agent collaborative dialogue are solved, enabling dynamic optimization of dialogue quality and improving the coherence and adaptability of the dialogue.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-28
- Publication Date
- 2026-03-27
AI Technical Summary
Existing intelligent dialogue systems suffer from insufficient personality consistency and context matching in multi-role large-model collaborative dialogue scenarios. This leads to personality drift and context deviation in long dialogues, making it difficult to maintain consistency and adapt to changing situations in multi-turn dialogues.
A multi-agent collaborative role model-based personality generation method is adopted. By initializing multiple role models and configuring personality parameters, and combining static and dynamic dialogue context parameters, personality consistency and context matching scores are calculated in real time. Iterative correction is performed to adjust the output and ensure the overall quality of the output.
It achieves personality consistency and situational matching in long dialogues using a large multi-role model, reduces inconsistencies in character traits, improves the coherence and relevance of dialogues, and enhances adaptability and robustness to abnormal situations.
Smart Images

Figure CN121745150A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application is suitable for the field of artificial intelligence, and in particular relates to a role large model personality generation method based on multi-agent collaboration, a role large model personality generation device based on multi-agent collaboration, a computer device, and a computer readable storage medium. BACKGROUND
[0002] In recent years, the development of large-scale pre-training language models has enabled intelligent dialogue systems to be widely used in customer service, education, companionship, and other fields. Role large models based on pre-training language models can simulate different roles and engage in multi-round interactive dialogue with users. In practical applications, different scenarios often require role large models to exhibit specific personality characteristics (for example, polite and professional in customer service scenarios, patient and meticulous in education scenarios, and empathetic and caring in psychological companionship scenarios), and to remain consistent with the current context. However, existing dialogue technologies still have obvious deficiencies in the consistency of role personality and context matching. In particular, in multi-role large model collaborative dialogue scenarios, as the number of dialogue rounds increases, the personality of the role large model is prone to drift, resulting in inconsistent performance before and after. Different role large models may have biases in understanding the dialogue context, leading to inconsistencies between the dialogue content and the dialogue context. In related technologies, role personality descriptions are usually pre-set at the beginning of the dialogue or fixed rules are used to constrain the personality of the role large model. However, these methods lack a mechanism 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 artificial feedback attempt to improve dialogue consistency, but have issues such as high data cost, insufficient generalization ability, and difficulty in covering diverse dialogue contexts. Therefore, how to continuously maintain the consistency of the personality of the role large model in multi-round dialogue and ensure that the output matches the current context has become a technical problem that needs to be solved. SUMMARY
[0003] The embodiments of the present application provide a role large model personality generation method based on multi-agent collaboration, a role large model personality generation device based on multi-agent collaboration, a computer device, and a computer readable storage medium, which can ensure the consistency of personality while considering the context matching degree of multiple role large models in collaborative dialogue.
[0004] To facilitate understanding of the technical solutions of the present application, the key terms involved in the technical solutions of the present application are described as follows (the term description in this section is only used to explain the present application and should not be understood as an additional limitation on the protection scope) : Role large model: refers to a large-scale pre-training language model instance that can play a specific role in dialogue and generate natural language output; the role large model can exhibit pre-set personality characteristics through fine-tuning, parameter efficient fine-tuning, or prompt engineering.
[0005] Static dialogue context parameters: refer to a set of context information that is set once at the start of the dialogue and remains unchanged in principle during the dialogue, including but not limited to role identity description, scene background (place / time / environment), task or business constraint conditions, etc.
[0006] Dynamic dialogue context parameter vector: refers to a shared context representation that is dynamically maintained and updated in real time during the dialogue, preferably encoded in vector form. The dynamic dialogue context parameter vector at least includes: an encoded representation of the static dialogue context parameters, and a dynamic context code of the current dialogue context (historical round summary, latest user input, environmental state variable, emotional state, etc.); the dynamic dialogue context parameter vector is shared by multiple role large models.
[0007] Personality parameters: refer to a set of parameters used to quantitatively represent the target personality characteristics of the role large model, which can be represented in the form of a vector or a configuration table, containing several personality dimensions and their weights (such as tone affinity, expression formality, empathy intensity, professionalism, etc.).
[0008] Personality consistency score: refers to the consistency score between the dialogue output and the personality parameters of the target role large model, which is used to measure whether the output conforms to the preset personality in terms of language style, tone, behavior logic, etc.
[0009] Context matching score: refers to the matching score between the dialogue output and the dynamic dialogue context parameter vector, which is used to measure whether the output fits the current shared context and whether it is closely related to the context and constraints.
[0010] Comprehensive quality score: refers to the total score obtained by fusing the personality consistency score and the context matching score. The higher the comprehensive quality score, the better the dialogue output in terms of personality consistency and context matching.
[0011] Correction iteration: refers to the process of adjusting the personality parameters of the role large model and / or generating constraints and regenerating the dialogue output according to the bias source of the personality consistency score and the context matching score when the comprehensive quality score does not reach the score threshold; the correction iteration can be set with a number threshold to avoid infinite loop.
[0012] In a first aspect, the present application provides a multi-agent collaborative role large model context personality generation method, comprising: Initializing multiple role large models and configuring corresponding personality parameters for each role large model; The static dialogue context parameters of the multi-role large model collaborative dialogue are configured, and a dynamic dialogue context parameter vector is initialized based on the static dialogue context parameters and the current dialogue history, wherein the dynamic dialogue context parameter vector at least includes a vector representation of the static dialogue context parameters, a vector representation of context information of the current dialogue turn, an environment state variable shared by the multiple roles, and a dialogue history summary vector, and is shared by the multiple role large models; In each dialogue turn, a target role large model to be spoken is determined from the multiple role large models, and a dialogue output is generated by the target role large model according to the current dialogue input, the personality parameters of the target role large model, and the dynamic dialogue context parameter vector; The personality consistency score and the context matching score are calculated, and the personality consistency score and the context matching score are fused to obtain a comprehensive quality score; If the comprehensive quality score does not reach a score threshold, a correction strategy is determined according to the personality consistency score and the context matching score, and the personality parameters of the target role large model and / or the generation constraints are adjusted and the dialogue output is regenerated according to the correction strategy until the target role large model generates a dialogue output with a comprehensive quality score reaching the score threshold or the number of correction iterations reaches a number threshold; the dialogue output with the comprehensive quality score reaching the score threshold is published, or the dialogue output with the highest comprehensive quality score in the iteration process is published when the number of correction iterations reaches the number threshold, and then the dynamic dialogue context parameter vector and the personality parameters of the target role large model are updated based on the comprehensive quality score, and the next dialogue turn is entered until the dialogue ends.
[0013] Optionally, in an embodiment, the comprehensive quality score is obtained by fusing the personality consistency score and the context matching score, comprising: According to the respective weight coefficients of the personality consistency score and the context matching score, the weighted sum of the personality consistency score and the context matching score is calculated as the comprehensive quality score. For example, let and be the weight coefficients of the personality consistency score and the context matching score , then it can be expressed as: , and satisfies (when not biased, the value of can be taken as 1).
[0014] Optionally, in an embodiment, the correction strategy is determined according to the personality consistency score and the context matching score, comprising: If the personality consistency score is lower than the context matching score, the correction strategy is determined as enhancing the weight of the related deviation personality dimension in the personality parameters of the target role large model, injecting personality reinforcement prompts, and / or regenerating the dialogue output; If the context matching score is lower than the personality consistency score, the correction strategy is determined as supplementing the missing context elements of the dialogue output in the dialogue input and / or injecting context reinforcement prompts.
[0015] Optionally, in an embodiment, the personality consistency score and the context matching score of the dialogue output are calculated, comprising: For each context dimension of the dynamic dialogue context parameter vector, a matching degree score of the dialogue output on the context dimension is calculated, and the matching degree scores of the context dimensions are fused to obtain the context matching score of the dialogue output. For each personality dimension of the personality parameters of the target role large model, a matching degree score of the dialogue output on the personality dimension is calculated, and the matching degree scores of the personality dimensions are fused to obtain the personality consistency score of the dialogue output.
[0016] Optionally, in an embodiment, the personality parameters of the target role large model are updated, comprising: A positive personality dimension in the personality parameters of the target role large model relative to the personality consistency score is determined, and the weight of the positive personality dimension is enhanced according to a preset proportion.
[0017] Optionally, in an embodiment, the multi-agent collaborative role large model context personality generation method provided by the embodiment of the application further comprises: The dialogue scene to which the current dialogue belongs is determined according to the dynamic dialogue context parameter vector, and a score threshold is determined according to the dialogue scene.
[0018] As used in the specification and the appended claims, the term "if' can be interpreted as meaning "when the stated condition is met", "as soon as the stated condition is met" or "in response to a determination / detection that the stated condition or event" is used to indicate that the corresponding steps are performed when the triggering condition is established, and the meaning should not be interpreted as requiring strict time sequence, exclusive condition or certain causality.
[0019] Similarly, the phrase "if determined" or "if it is detected that [the described condition or event]" can be interpreted according to the context as meaning "as soon as determined" or "in response to determination" or "as soon as [the described condition or event] is detected" or "in response to detection of [the described condition or event]".
[0020] In a second aspect, the application provides a multi-agent collaborative role large model context personality generation device, comprising: A role initialization module is configured to initialize a plurality of role large models and configure corresponding personality parameters for each role large model. a context initialization module configured to configure static dialogue context parameters of the multi-role large model collaborative dialogue, and initialize a dynamic dialogue context parameter vector based on the static dialogue context parameters and a current dialogue history, wherein the dynamic dialogue context parameter vector at least includes an encoded representation of the static dialogue context parameters and a dynamic context code of the current dialogue context, and is shared by the plurality of role large models; a dialogue generation module configured to determine a target role large model to be spoken in the plurality of role large models at each dialogue turn, and generate dialogue output by the target role large model according to the current dialogue input, the personality parameters of the target role large model, and the dynamic dialogue context parameter vector; a quality scoring module configured to calculate a personality consistency score and a context matching score of the dialogue output, and fuse the personality consistency score and the context matching score to obtain a comprehensive quality score; a dialogue correction module configured to determine a correction strategy according to the personality consistency score and the context matching score when the comprehensive quality score does not reach a score threshold, and adjust the personality parameters of the target role large model and / or the generation constraints to regenerate the dialogue output, and repeat the iteration until the comprehensive quality score reaches the score threshold or the number of correction iterations reaches a number threshold; a parameter updating module configured to publish the dialogue output whose comprehensive quality score reaches the score threshold, or publish the dialogue output whose comprehensive quality score is the highest in the iteration process when the number of correction iterations reaches the number threshold, and update the dynamic dialogue context parameter vector and the personality parameters of the target role large model to enter the next dialogue turn until the dialogue ends.
[0021] Optionally, in an embodiment, the quality scoring module is configured to calculate a weighted sum of the personality consistency score and the context matching score as the comprehensive quality score according to respective weight coefficients of the personality consistency score and the context matching score. For example, assuming that and are the weight coefficients of the personality consistency score and the context matching score , then the comprehensive quality score can be represented as: , and satisfies (when not biased, the weight coefficients can be taken as ).
[0022] Optionally, in an embodiment, the dialogue correction module is configured to determine the correction strategy as enhancing the weight of a related deviation personality dimension in the personality parameters of the target role large model, injecting a personality reinforcement prompt, and / or regenerating the dialogue output when the personality consistency score is lower than the context matching score; or determine the correction strategy as supplementing a missing context element of the dialogue output in the dialogue input and / or injecting a context reinforcement prompt when the context matching score is lower than the personality consistency score.
[0023] 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.
[0024] 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.
[0025] 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.
[0026] 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.
[0027] 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.
[0028] 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
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.
[0030] Figure 1 is an application environment schematic diagram of the role large model personality generation method provided by the embodiment of the present application. Figure 2 is an architecture schematic diagram of the role large model personality generation system provided by the embodiment of the present application.
[0031] Figure 3 is a flow schematic diagram of the role large model personality generation method provided by the embodiment of the present application. Figure 4 is a flow schematic diagram of the quality scoring of the dialogue output in the embodiment of the present application. Figure 5 is a flow schematic diagram of the iterative correction in the embodiment of the present application. Figure 6 is a structure schematic diagram of the role large model personality generation device provided by the embodiment of the present application. Figure 7 is a structure schematic diagram of the computer device provided by the embodiment of the present application. DETAILED DESCRIPTION
[0032] In the following description, specific details are set forth in order to provide a thorough understanding of the embodiments of the present application. However, persons skilled in the art will understand that the present application can be practiced without these specific details. In other instances, well-known systems, structures, circuits, and methods have not been described in detail in order to not unnecessarily obscure the description of the present application.
[0033] It should be understood that when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0034] It should also be understood that the term "and / or" used in the specification and the appended claims of the present application means any combination of one or more of the associated listed items and all possible combinations thereof, and includes these combinations.
[0035] As used in the description of the application and the appended claims, the term “if’ can be interpreted to mean “upon a determination” or “in response to a determination” or “upon the occurrence of” or “in response to the occurrence of,” depending on the context.
[0036] Similarly, the phrase “if it is determined” or “if [the described condition or event] is detected” can be interpreted to mean “upon a determination” or “in response to a determination” or “upon the occurrence of [the described condition or event]” or “in response to the occurrence of [the described condition or event],” depending on the context.
[0037] In addition, the terms “first,” “second,” “third,” etc. as used in the description of embodiments herein and in the appended claims are used for distinguishing between similar elements and not necessarily for describing a sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of use in either order.
[0038] The phrase “one or more of’ as used herein means “one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve or more” unless otherwise specified.
[0039] It is to be understood that the sequence of steps in the following embodiments does not necessarily mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the application.
[0040] Reference will now be made to the drawings, wherein Figure 1 , Figure 1 is an application environment schematic diagram of the multi-agent collaborative role large model co-context personality generation method provided by the application. As an implementation manner, the multi-agent collaborative role large model co-context personality generation method provided by the application can be applied to a server 100, the server 100 and a terminal device 200 are connected through a network, and the server 100 is used to provide a multi-role dialogue service for the terminal device 200. Wherein, the network is a medium for providing a communication link between the server 100 and the terminal device 200, and can include various connection types, such as a wired communication link, a wireless communication link, etc., and the embodiments of the application do not limit this.
[0041] It should be noted that, Figure 1 The server 100, the network and the terminal device 200 in the figure are only schematic. According to actual needs, there can be any number of servers 100. For example, the server 100 can be implemented by an independent physical server, or by a server cluster composed of multiple servers, or by a distributed system, etc., and the terminal device 200 can be any device such as a mobile phone, a tablet, a desktop computer, a notebook computer, etc.
[0042] In some embodiments, the server 100 is deployed with multiple role large models, the server 100 can initialize the multiple role large models, and configure a corresponding personality parameter for each role large model; configure a static dialogue context parameter for the multiple role large models to have a collaborative dialogue, and initialize a dynamic dialogue context parameter vector for the multiple role large models to have a collaborative dialogue according to the static dialogue context parameter; in each dialogue turn, determine a target role large model to be spoken from the multiple role large models, and generate a dialogue output or a response result through the target role large model according to a current dialogue input, a personality parameter of the target role large model and the dynamic dialogue context parameter vector, wherein the current dialogue input can come from a human user of the terminal device 200; then, calculate a personality consistency score and a context matching score of the dialogue output, and fuse the personality consistency score and the context matching score to obtain a comprehensive quality score; if the comprehensive quality score reaches a score threshold, the dialogue output whose comprehensive quality score reaches the score threshold is published, displayed to the human user by the terminal device 200, and the dynamic dialogue context parameter vector and the personality parameter of the target role large model are updated to enter the next dialogue turn until the dialogue ends.
[0043] Please refer to Figure 2 , Figure 2 is an architecture schematic diagram of a multi-agent collaborative role large model same-context personality generation system provided by the application.
[0044] In an optional implementation, in order to realize the "consistent understanding" of the multiple role large models to the same dialogue context, a context parameter management module (which can also be implemented by a database / shared memory / message queue) is arranged on the server side, for centralized storage and maintenance of the static dialogue context parameter and the dynamic dialogue context parameter vector. After each dialogue turn ends, the context parameter management module synchronizes (for example, broadcasts) the updated dynamic dialogue context parameter vector to all role large models (for example, Figure 2The role large model 1 to the role large model N in the role large model cluster, wherein each role large model has respective personality parameters P1 to PN, so that each role large model reasons and responds based on the same shared context representation when subsequently generated, thereby avoiding answer bias caused by inconsistent understanding of the context between multiple roles. The target role large model (determined from the role large model cluster) can receive a dialogue input input by a user through a terminal, and generate a dialogue output based on the dialogue input and the current dynamic dialogue context parameter vector.
[0045] Further, the server side can also set a quality score module and a dialogue correction module to form a closed loop: the quality score module receives the dialogue output of the target role large model and the current dynamic dialogue context parameter vector to calculate the personality consistency score and the context matching score, and outputs the 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 bias source (personality dimension or context dimension) and adjusts the personality parameters of the target role large model and / or the generation constraints, and then triggers the target role large model to regenerate the output; when the comprehensive quality score meets the standard, the dialogue output with the comprehensive quality score meeting the standard is published to the terminal, and the terminal displays it to the user, in addition, the role large 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.
[0046] Please refer to Figure 3 The flowchart of the role large model same context personality generation method disclosed in the embodiment of the application is as shown in Figure 3 The flowchart of the role large model same context personality generation method can be as follows: In S110, a plurality of role large models are initialized, and each role large model is configured with corresponding personality parameters.
[0047] The role large model is a large language model that plays a specific role (such as a customer service representative, a teacher, a psychological consultant, etc.) in a dialogue and generates a large language model consistent with the personality of the role.
[0048] In specific implementation, the role large model can be obtained by retraining and adjusting a pre-trained large language model, and the training and fine-tuning method can select appropriate strategies according to specific application scenarios and data conditions. For example, first, a large-scale pre-trained language model is selected as a base model (for example, a mainstream pre-trained language model architecture with tens of billions of parameters is selected, such as an architecture based on an attention mechanism), which is trained on a large amount of general corpus and has rich language generation capability. Subsequently, the large-scale pre-trained language model is endowed with specific personality characteristics, and a supervised fine-tuning method can be used: collect or construct dialog corpus related to the target personality, and continue to train the large-scale pre-trained language model. The dialog corpus can include a large number of question and answer dialogues reflecting a certain target personality, for example, the corpus of customer service personality can be derived from customer service chat records, the corpus of education personality can be derived from teacher-student dialogues, and the corpus of psychological companion personality can be derived from psychological counseling dialogue cases, etc. In these corpora, the replies of the large-scale pre-trained language model all conform to the expected personality characteristics. By minimizing the loss function of the difference between the model reply and the expected reply, the model parameters of the large-scale pre-trained language model are iteratively adjusted, so that it gradually learns to adopt an expression manner conforming to the target personality in a similar context. For personality types with insufficient dialog corpus, data augmentation or transfer learning techniques can be used to generate high-quality dialog corpus. For example, the large-scale pre-trained language model itself can be used to generate some simulated dialogues conforming to the personality setting to expand the dialog corpus. If necessary, a small amount of artificially written personality description sentences can also be introduced as training signals to guide the large-scale pre-trained language model to converge to a specific personality, and finally obtain a role large model with specific personality characteristics.
[0049] To facilitate the deployment of multiple personalities, the training of the role large model can also use lightweight fine-tuning techniques such as low-rank adaptation (LoRA) or prompt tuning, which can adapt different personality roles by updating only a small number of parameters while preserving the capabilities of the base model. In specific implementation, a small group of adaptation parameters is trained for each personality during training, and saved as a personality parameter plug-in; during inference, the personality parameter plug-in is applied to the base model, so that the base model can be switched to the corresponding personality role, realizing efficient deployment of "one model, multiple uses", without maintaining completely independent model instances for each personality. When a new role personality needs to be added, there is no need to retrain a large model, only a small-scale personality parameter plug-in needs to be trained, which greatly reduces the training overhead and storage cost.
[0050] In addition, the prompt engineering technology can be used to guide the large-scale pre-trained language model to exhibit the target personality characteristics through the designed personality prompt words without modifying the model parameters of the large-scale pre-trained language model. For example, for the customer service personality, the personality prompt template “You are a professional customer service with an affable tone but not formal, and can empathize with the emotions of users” can be used.
[0051] In one specific implementation example of the present application, a Transformer model with 7 billion parameters is used as a base model, which is fine-tuned and optimized as described above. During the fine-tuning process, a data corpus of about 200,000 rounds of multi-round dialogue is used, covering three typical personalities of customer service, education, and psychological escort (each type of corpus accounts for about the same proportion), to ensure that the model learns each personality trait fully. The adaptive optimizer (such as the commonly used first-order optimization algorithm) is used for fine-tuning, the initial learning rate is set to , the batchsize is about 32, and the training lasts for about 3 epochs. The loss function adopts a multi-objective combination form: ; Among them, is the cross-entropy loss, which supervises the model to generate correct replies; is the personality consistency loss, which constrains the semantic alignment between the model output and the target personality description through contrastive learning; is the context matching loss, which ensures that the reply is natural and appropriate in the dialogue context, , are adjustable weight coefficients.
[0052] The optimization of the above multi-objective loss function prompts the base model to adjust in the direction of reducing personality and context deviation when updating the parameters in the backward propagation. Through this training strategy of the multi-objective loss function, the base model is guided to pay more attention to maintaining the consistency of the personality and the adaptability to the dialogue context while ensuring the basic quality of the dialogue content generation.
[0053] Optionally, to further improve the personality consistency and context matching degree in long dialogue, the present application can also optimize and train the role large model combined with reinforcement learning: the comprehensive quality score obtained by fusing the personality consistency score and the context matching score is used as the reward signal, through multiple rounds of interaction with the dialogue environment (the environment can be constructed by historical dialogue data or a simulated user model), the policy gradient algorithm (such as the proximal policy optimization PPO) is used to update the generation strategy of the role large model, so that the output with high comprehensive quality score is positively reinforced, and the output with low score is suppressed, thereby reducing the frequency of triggering correction in the subsequent reasoning stage and improving the overall dialogue stability.
[0054] The following takes the server as the execution subject to describe in detail the role large model co-situation personality generation method provided by the application, In the embodiment of the application, the server is initialized and configured before the dialogue starts. The server reads and loads the model parameters required by each role large model, and completes the initialization of the role large model. For example, if the role large model is obtained by fine-tuning a large-scale pre-trained language model, the server loads the fine-tuned model parameters during initialization; for the implementation of the prompt engineering, the server injects the personality prompt template after loading the model parameters required by the large-scale pre-trained language model.
[0055] In addition, to ensure that the role large model stably outputs replies in line with the set personality characteristics in the dialogue, the server also configures corresponding personality parameters for each role large model. The personality parameters are used to quantify and represent a parameter set of personality characteristics of the role large model, which can be in the form of a vector or a configuration table, including but not limited to numerical indicators of dimensions such as tone affinity, expression formality, and empathy strength. By adjusting the personality parameters, the style of the content generated by the role large model can be affected, so that it is more in line with the personality setting of the role large model. For example, for a customer service personality, the tone affinity is set to 0.92, the expression formality is set to 0.85, and the empathy strength is set to 0.88; for an educational personality, the tone affinity is set to 0.86, the expression formality is set to 0.75, and the empathy strength is set to 0.91; for a psychological companion personality, the tone affinity is set to 0.95, the expression formality is set to 0.62, and the empathy strength is set to 0.96.
[0056] In S120, static dialogue context parameters of the multi-role large model cooperative dialogue are configured, the static dialogue context parameters at least including participant role setting, scene background description and environmental constraint condition; and a dynamic dialogue context parameter vector is initialized based on the static dialogue context parameters and dialogue history, the dynamic dialogue context parameter vector at least including vector representation of the static dialogue context parameters, vector representation of the context information of the current dialogue turn, environment state variable shared by multiple roles, and dialogue history summary vector, and shared by multiple role large models.
[0057] The context parameters are a set of parameters for describing the dialogue context of the multi-role large model collaborative dialogue, which is composed of static dialogue context parameters and a dynamic dialogue context parameter vector. The static dialogue context parameters are set once at the start of the dialogue and cover the role setting of the participating dialogue (such as the number of roles, role type, and identity description), as well as the scene background description (such as location, time, environment, etc.), and related environmental constraints (such as business / task constraints, etc. Prior information); the dynamic dialogue context parameter vector includes references to static dialogue context parameters, as well as context content, changes in inter-role relationships, topic shift trends, and emotional states that evolve in real time with the dialogue process, and the dimensions and content are specific to the application scenario. For example, in the customer scenario, the dynamic information can include the current dialogue topic, user emotional state, historical interaction round, problem solving progress, etc.; in the multi-role role-playing simulation, the dynamic information can also include the scene timeline, the known environmental events of each role, etc.
[0058] In the embodiments of the present application, the server configures the static context parameters required for the multi-role large model collaborative dialogue according to the actual dialogue needs, and initializes the dynamic dialogue context parameter vector based on the 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 the text information component therein, it can be encoded into a real number vector through a pre-trained language model embedding; for numerical classification, it can be directly incorporated into a real number vector after normalization, obtaining the vector representation of the dynamic dialogue context parameter vector, denoted as .
[0059] It should be noted that as the dialogue process advances, the server continuously injects new dynamic information into the dynamic dialogue context parameter vector , so that it is updated in real time and dynamically evolves, ensuring that each role large model always generates responses based on the latest dialogue context.
[0060] In S130, at each dialogue turn, the target role large model to be spoken is determined among the plurality of role large models, and the dialogue output is generated through the target role large model according to the current dialogue input, the personality parameters of the target role large model, and the dynamic dialogue context parameter vector.
[0061] In an embodiment of the present application, at the beginning of each round of dialogue, the server obtains the dialogue input of the current dialogue round. The dialogue input can be input by a human user through a terminal device, or can come from the dialogue output generated by other role large models in the previous round. Subsequently, the server selects a role large model to be spoken from the plurality of role large models according to a preset strategy, denoted as a target role large model, which can be dynamically decided based on role task priority, context relevance score or real-time emotion adaptation degree; after selecting the target role large model, the server drives the target role large model to generate dialogue output consistent with the personality setting and the dialogue context by taking the personality parameters of the target role large model, the current dialogue input and the current dynamic dialogue context parameter vector as joint input.
[0062] It should be noted that the role large model can be mathematically represented as a dialogue generation function, which can be formally denoted as At the first round of dialogue, the role large model is determined as the target role large model, and the dialogue output generated by the role large model can be represented as: , wherein represents the dialogue input of the current dialogue round, represents the personality parameters of the target role large model, represents the vector representation of the dynamic dialogue context parameter vector of the current dialogue round, represents the dialogue output generated by the role large model .
[0063] In S140, the personality consistency score and the context matching score of the dialogue output are calculated, and the comprehensive quality score is obtained by fusing the personality consistency score and the context matching score.
[0064] Please refer to Figure 4 To ensure that each round of dialogue output meets the requirements, the server also performs quality scoring on the dialogue output generated by the target role large model, including two dimensions of personality consistency and context matching.
[0065] Firstly, the server maps the dialogue output generated by the target role large model to a vector representation , wherein the server can obtain the vector representation of the dialogue output by using a semantic encoding model such as the context representation model, or can obtain the vector representation of the dialogue output by using a mean value of a word embedding matrix representation. .
[0066] Subsequently, the server calculates a personality consistency score of the dialogue output. Exemplarily, the server can employ cosine similarity to calculate the personality consistency score , which is expressed as: ; wherein, represents the vector numerical value of the personality parameter of the target role model , “ ” represents the vector dot product, represents the Euclidean norm of the vector. It can be understood that the value of calculated by the above formula ranges from [-1, 1], and for the convenience of evaluation, the server further linearly normalizes to the interval [0, 1], wherein 1 represents complete consistency, and 0 represents complete inconsistency. When and are both non-negative feature vectors, the cosine similarity itself is already in the range of [0, 1], and can be directly used at this time.
[0067] In addition, the server also calculates a context matching score of the dialogue output. Exemplarily, the server also employs cosine similarity to calculate the context matching score , which is expressed as: ; After calculating the cosine similarity to obtain , the server also normalizes it to the interval [0, 1]. In specific implementation, to avoid division by zero error, a very small value (such as ) can be added to the denominator in the calculation formula, so as to ensure the stability of the calculation when or is close to 0.
[0068] Finally, the server fuses the personality consistency score and the context matching score obtained above to obtain a comprehensive quality score of the dialogue output. The fusion manner of the two is not specifically limited herein, including but not limited to taking the arithmetic mean, minimum value, maximum value, weighted sum, etc.
[0069] Exemplarily, the server employs the weighted sum manner to calculate the comprehensive quality score , which is expressed as: To avoid the inconvenience of reading caused by only expressing the formula object in words, the comprehensive quality score can be expressed in words as: the comprehensive quality score personality consistency score context matching score .
[0070] ; wherein, and are non-negative weight coefficients for balancing the personality consistency score and the context matching score the importance of the two dimensions, and satisfy: ; for example, when no bias is applied to either dimension, it is desirable to achieve equal weight for both.
[0071] After the above calculation, the comprehensive quality score is normalized to the range [0, 1], and a larger value indicates better performance in personality consistency and context matching.
[0072] In S150, if the comprehensive quality score reaches the score threshold, the dialogue output with the comprehensive quality score reaching the score threshold is published, and the dynamic dialogue context parameter vector and the personality parameters of the target role large model are updated and then the next dialogue round is entered until the dialogue ends; or, if the comprehensive quality score does not reach the score threshold, a correction strategy is determined according to the personality consistency score and the context matching score, and the personality parameters of the target role large model and / or the generation constraints are adjusted and the dialogue output is regenerated according to the correction strategy until the target role large model generates dialogue output with a comprehensive quality score reaching the score threshold or the number of correction iterations reaches the number threshold; the dialogue output with the comprehensive quality score reaching the score threshold is published, or the dialogue output with the highest comprehensive quality score in the iteration process is published when the number of correction iterations reaches the number threshold, and then the next dialogue round is entered based on the updated dynamic dialogue context parameter vector and the personality parameters of the target role large model until the dialogue ends.
[0073] It should be noted that the present embodiment is also configured with a score threshold for constraining whether the dialogue output meets the standard, and when the comprehensive quality score reaches the score threshold , it is determined that the dialogue output meets the standard, and when the comprehensive quality score does not reach the score threshold , it is determined that the dialogue output does not meet the standard. The score threshold may be set according to actual application requirements, for example, a higher threshold is selected for a strict requirement scenario to pursue higher consistency.
[0074] When the server determines that the dialogue output meets the standard, that is, the comprehensive quality score of the dialogue output reaches the score threshold, the server publishes the dialogue output to the recipient of the current dialogue round, which can be a human user or a role large model that will respond next.
[0075] 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.
[0076] 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.
[0077] 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.
[0078] 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.
[0079] Please refer to Figure 5 The server first analyzes the personality consistency score. Context matching score The specific value is 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 big model and regenerate the dialogue output. This process is iterated until the target character big model generates dialogue output with a comprehensive quality score that reaches the scoring threshold.
[0080] 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.
[0081] After executing the determined correction strategy, the server re-generates the dialogue output through the role large model. Generally, one correction can significantly improve the score. If the comprehensive quality score of the re-generated dialogue output still does not reach the score threshold, the server can continue to adjust according to the adjustment effect of the last correction. For example, if the personality consistency score is significantly improved after the first correction, but the context matching score is still low, the server can focus on strengthening the context matching dimension during the second correction, that is, the correction strategy of the context matching dimension is preferably selected.
[0082] It should be noted that excessive iterations will increase the response time of the server at this time, affecting the user experience. Therefore, the number of iterations of the correction is also constrained by the number threshold in the embodiments of the present application. The number threshold can be set according to the application scenario. Generally, the value range of the number threshold is configured to be 1-3. In the case that the user has a high tolerance for response time, the value range of the number threshold can be configured to be 1-5. In the embodiments of the present application, the number threshold is configured to be , that is, the role large model is allowed to re-generate at most twice based on the initial generation in each dialogue round. If the comprehensive quality scores of the dialogue outputs generated by the two corrections are both less than the score threshold, the server publishes the dialogue output with the highest comprehensive quality score in the iteration process, and then updates the dynamic dialogue context parameter vector to enter the next dialogue round.
[0083] In other embodiments, when the determined correction strategy includes enhancing the weight of the related deviation personality dimension in the personality parameter of the target role large model, the server can record the cumulative determination number of different personality dimensions being determined as the deviation personality dimension. When the cumulative determination number of a certain personality dimension reaches a preset threshold, the server can enhance the weight of the personality dimension in the personality parameter, and reset the cumulative determination number of the personality dimension. In this way, by online fine-tuning the personality parameter, the role large model can gradually strengthen the personality traits that are easy to miss. In addition, in order to ensure the overall stability of the personality of the role large model, when the cumulative determination number of a certain personality dimension reaches a preset threshold, the server can enhance the weight of the personality dimension in the personality parameter according to a preset proportion, wherein the preset proportion is configured to be not more than 10%.
[0084] In other embodiments, the server also records the executed correction strategy and the score change brought by the executed correction strategy. When enough data is accumulated, the server can analyze which deviations frequently occur in which context, and accordingly improve the model training or perfect the correction strategy, so that the role large model needs to trigger the correction less in the future.
[0085] In other embodiments, the triggering condition of the rectification process can not only be based on the comprehensive quality score, but also set more granular rules according to specific scenarios. For example, in some high-sensitivity scenarios, when either the personality consistency score or the context matching score is below the score threshold, the rectification process is triggered regardless of whether the comprehensive quality score reaches the score threshold; for example, for a newly online insufficiently trained role model, a higher score threshold can be temporarily used to more strictly filter the output. In specific implementation, those skilled in the art can adjust the score threshold strategy according to actual needs to balance the quality of the reply and the timeliness of the response.
[0086] Optionally, in an embodiment, the rectification strategy is determined according to the personality consistency score and the context matching score, comprising: If the personality consistency score is lower than the context matching score, the rectification strategy is determined to be to enhance the weight of the related deviated personality dimension in the personality parameters of the target role model, inject personality reinforcement prompts, and / or regenerate the dialogue output. If the context matching score is lower than the personality consistency score, the rectification strategy is determined to be to supplement the missing context elements of the dialogue output in the dialogue input and / or inject context reinforcement prompts.
[0087] When the personality consistency score is lower than the context matching score, and the context matching score reaches the score threshold, the server determines that the main deviation source is the personality consistency dimension, and accordingly determines the rectification strategy to be to enhance the weight of the related deviated personality dimension in the personality parameters of the target role model (i.e., the personality dimension in the personality parameters that matches the score threshold), inject personality reinforcement prompts, and / or regenerate the dialogue output (i.e., directly regenerate the dialogue output). For example, the server can select one or more of the foregoing rectification strategies according to the difference between the personality consistency score and the context matching score, such as when the difference between the two is small, the server can only enhance the weight of the related deviated personality dimension in the personality parameters of the target role model, or inject personality reinforcement prompts (e.g., please reply to the user with very polite and patient language, avoid using harsh wording), and when the difference between the two is large, the server enhances the weight of the related deviated personality dimension in the personality parameters of the target role model while injecting personality reinforcement prompts.
[0088] When the context matching score is lower than the personality consistency score, and the personality consistency score reaches the score threshold, the server determines that the main deviation source is the context matching dimension, and accordingly determines the rectification strategy to be to supplement the missing context elements of the dialogue output in the dialogue input and / or inject context reinforcement prompts.
[0089] For example, the server can analyze the dialogue context, identify missing contextual elements in the dialogue output, and assume that the user mentioned in the previous dialogue turn that he is an old man, but the dialogue output generated by the target role large model does not take into account that the user is an old man. The supplemented contextual element can be "the user mentioned earlier that he is an old man", which can guide the role large model to generate more understandable dialogue output.
[0090] In other embodiments, if the personality consistency score and the context matching score are both below the score threshold, the server can integrate the above personality consistency and context matching two-dimensional correction strategies, and weight the guidance of the two aspects of personality consistency and context matching.
[0091] In an optional implementation, the correction strategy rules can be pre-set to select the correction strategy according to the deviation relationship between the personality consistency score and the context matching score. For example, only as an example and does not constitute a limitation: Condition: low personality consistency score and normal / high context matching score Personality correction strategy: increase the weight of the deviated personality dimension in the personality parameter (for example, increase the dimension weight of "politeness / empathy strength" by a preset step), inject personality reinforcement prompts (for example, "please reply with more polite, more patient, and more empathetic language"), and regenerate the dialogue output; Condition: low context matching score Context correction strategy: extract missing context elements from the dialogue history and supplement them to the dialogue input (for example, user identity, confirmed facts, task constraints), inject context reinforcement prompts (for example, "please strictly answer around the current scene and known facts, avoid deviating from the topic"), and regenerate the dialogue output; Condition: both personality consistency score and context matching score are low Comprehensive correction strategy: simultaneously enhance personality parameter constraints and context element supplementation, and regenerate dialogue output, if necessary, iterate according to the number threshold.
[0092] Optionally, in an embodiment, the personality consistency score and the context matching score of the dialogue output are calculated, including: For each context dimension of the dynamic dialogue context parameter vector, calculate the matching degree score of the dialogue output in the context dimension, and fuse the matching degree scores of each context dimension to obtain the context matching score of the dialogue output; For each personality dimension of the personality parameter of the target role large model, calculate the matching degree score of the dialogue output in the personality dimension, and fuse the matching degree scores of each personality dimension to obtain the personality consistency score of the dialogue output.
[0093] In an embodiment of the present application, for each context dimension (such as context, scene, dialogue topic, etc.) of the dynamic dialogue context parameter vector, the server calculates a matching degree score of the dialogue output on the context dimension , denoted as: ; wherein, represents the vector component of the vector representation of the dynamic dialogue context parameter vector on the i-th context dimension, is the vector representation of the dialogue output generated by the target role large model, represents the vector dot product, represents the Euclidean norm of the vector.
[0094] Subsequently, the server fuses the matching degree scores of each context dimension to obtain a context matching score of the dialogue output , denoted as: ; wherein, represents the weight coefficient of the i-th context dimension, which can be valued according to actual needs.
[0095] Similarly, for each personality dimension (such as tone affinity, expression formality, empathy strength, etc.) of the personality parameter of the target role large model, the server calculates a matching degree score of the dialogue output on the personality dimension , denoted as: ; wherein, represents the vector numerical representation of the j-th personality dimension in the personality parameter of the target role large model.
[0096] Subsequently, the server fuses the matching degree scores of each personality dimension to obtain a personality consistency score of the dialogue output , denoted as: ; wherein, represents the weight coefficient of the j-th personality dimension, which can be valued according to actual needs.
[0097] As above, through the more refined personality consistency scoring method and context matching scoring method as above, more accurate personality consistency scores and context matching scores can be obtained.
[0098] Optionally, in an embodiment, updating the personality parameter of the target role large model comprises: determining a positive personality dimension in the personality parameter of the target role large model relative to the personality consistency score, and enhancing the weight of the positive personality dimension according to a preset proportion.
[0099] In the updating of the personality parameters of the target role large model, the server first determines the positive personality dimension in the personality parameters of the target role large model relative to the personality consistency score, that is, the personality dimension whose matching degree score reaches the score threshold. Subsequently, the server enhances the weight of the positive personality dimension according to the preset proportion. For example, the server determines that the empathy intensity in the personality parameters is a positive personality dimension, and assumes that the configured preset proportion is 4%. If the empathy intensity is 0.82, the server enhances it by 4% to 0.85.
[0100] Optionally, in an embodiment, the multi-agent collaborative role large model co-personality generation method provided by the embodiment of the application further includes: According to the dynamic dialogue context parameter vector, the dialogue scene to which the current dialogue belongs is determined, and the score threshold is determined according to the dialogue scene.
[0101] In the embodiment of the application, in order to balance the reply quality and the response time delay, the server dynamically adjusts the score threshold according to the dialogue scene. Specifically, the server first determines the dialogue scene to which the current dialogue belongs according to the dynamic dialogue context parameter vector, and then determines the score threshold suitable for the current dialogue turn according to the preset correspondence between the dialogue scene and the score threshold.
[0102] For example, for a dialogue scene that requires strictness (such as medical consultation, legal question and answer, etc.), a higher score threshold can be set, such as 0.9, and for a dialogue scene that requires fast response (such as chatting, customer service, etc.), a lower score threshold can be set, such as 0.6.
[0103] In order to facilitate the understanding of the multi-agent collaborative role large model co-personality generation method provided by the application, the following will be described in combination with specific dialogue scenes: Customer service scenario: the role large model acts as a customer service robot and communicates with the user in multiple rounds. Static dialogue context parameters include customer service personnel role setting (such as "patient, polite, professional"), company business knowledge base and service process specification, etc. During the dialogue process, the dynamic dialogue context parameter vector records the user's current problem type, emotional state and provided solution steps, etc. Through personality consistency + context matching score, the server ensures that each reply of the role large model meets the polite and professional personality required by the company and is closely related to the user's problem context. For example, when encountering an emotionally agitated user, the role large model may be harsh due to the complexity of the context, and the server immediately finds that the personality consistency is low, and then adjusts the tone of the role large model, and strengthens the weights of the "patience level" and "empathy strength" two personality dimensions, so that it responds to the user's confusion more patiently, thereby resolving the user's emotions. In the whole service dialogue, no matter how the user's question changes, the role large model will always maintain a friendly and patient attitude (i.e. high personality consistency), and the answer given strictly according to the product information provided by the company and the current problem background (i.e. high context matching). Compared with ordinary customer service robots without using the mechanism of the present application, the present application can effectively avoid inappropriate tone or irrelevant answers, and improve user satisfaction and consistent perception of brand service. Practical tests show that after introducing the present application scheme, the user's satisfaction rate with the customer service robot is significantly improved, especially in long conversations and multiple follow-up questions, the role large model still maintains stable service standards, which reflects the significant practical value of the present application scheme in the customer service scenario.
[0104] Education scenario: The present application can also be applied in an intelligent education tutoring system to realize personalized teaching dialogue. Static dialogue context parameters include teacher role setting (e.g. knowledgeable and patient), teaching subject and student grade level, etc. Dynamic dialogue context parameter vector dynamically maintains current course theme, student mastered knowledge points, student emotion, concentration, etc. A role large model plays a virtual teacher and interacts with students (which can be real people or simulated by another role large model) in a question and answer manner. Through the method of the present application, the virtual teacher can maintain a unified personality style throughout the teaching dialogue - both showing profound knowledge and always responding to the students with a patient and encouraging tone. For example, when the student repeatedly answers the question incorrectly and appears to be discouraged, the dynamic dialogue context parameter vector will reflect this state, and if the role large model fails to reflect the appropriate encouragement and comfort in a certain reply, the correction mechanism will adjust its response mode to add encouraging language to help the student regain confidence; at the same time, it ensures that the explanation content continues to remain simple and easy to understand, and is consistent with the current level of the student. On the other hand, if the role large model has a tendency to explain knowledge that is too difficult or off topic (for example, using concepts that are beyond the student's level, resulting in a decrease in context matching score), the server will also detect and correct it in time, guiding it to explain in a simpler way or return to the topic. In actual teaching tests, the virtual teacher using the present application can more flexibly adapt to student feedback: it will not suddenly increase the difficulty beyond the student's understanding because of one or two correct answers, nor will it change the initial intention of patient guidance when the student makes a mistake. The entire teaching process is coherent and natural. Students generally reflect that the intelligent teacher "always has a mild attitude and explains in a gradual and progressive manner", and the learning experience is good. This shows that the present application effectively guarantees the consistency of teaching personality and content rhythm in the education dialogue scenario, and helps to improve the effectiveness of teaching interaction.
[0105] Psychological companion scenario: The present application can also be applied to a dialogue system for psychological counseling or emotional companion, to help provide empathetic care for long-term communication experience. The basic context parameters include the role setting of the psychological counselor (such as "empathy, patience, active guidance"), the scene of the dialogue (online chat or offline interview), and the general background of the user. During the dialogue, the dynamic dialogue context parameter vector continuously summarizes the user's current psychological state, main distress, and emotional changes, and other information. The role large model acts as a virtual psychological counselor and engages in dialogue with the user. Through the dual constraints of personality consistency and context matching, the server ensures that the virtual psychological counselor always shows an empathetic understanding attitude no matter how long the dialogue lasts, and provides appropriate responses around the user's problems. For example, when the user complains about negative emotions for a long time, the virtual psychological counselor still maintains a patient and gentle tone in subsequent replies, and can quote the details mentioned by the user earlier to show understanding and concern, without becoming perfunctory or impatient due to repeated topics or time passing. If a round of reply shows signs of harshness or deviation, the server will intervene and adjust in time to make the reply return to the track of caring listening. Through the feedback of double scoring, the virtual psychological counselor establishes a coherent and credible image in the user's multiple interactions: neither suddenly showing impatience or carelessness, nor forgetting important details previously disclosed by the user, but can always make the user feel valued and understood. According to the feedback of real user tests, compared with ordinary chat models that do not use the mechanism of the present application, the virtual psychological counselor using the present application has a significant improvement in the temperature and continuity of the dialogue, and users are more willing to communicate with it for a long time and obtain emotional comfort. This further proves the practical value of the present application in psychological companion scenarios that require high personality consistency.
[0106] To verify the effectiveness of the present application, comparative experiments were also conducted in the above three typical dialogue scenarios. In each scenario, several real or simulated dialogues were selected for testing, with a sample size of 50 rounds of multi-turn dialogue. The role large model used is a Transformer model with about 7 billion parameters, and has been fine-tuned with about 200,000 rounds of multi-turn dialogue corpus. The dialogue corpus covers three types of personality scenarios: customer service, education, and psychological companion, with roughly equal proportions, enabling the model to have various personality traits. The control group uses the traditional method (only provides fixed personality setting prompts at the beginning of the dialogue, without dynamic scoring and correction in the middle), and the experimental group uses the personality consistency + context matching double scoring and correction mechanism of the present application.
[0107] In all test dialogues, the comprehensive quality scores of each round of role large model responses are recorded, and the average comprehensive quality scores of each dialogue throughout the whole process are calculated as evaluation indicators. The statistical results show that the average comprehensive quality scores of the experimental group dialogues are significantly higher than those of the control group. Specifically, in the customer service scenario, the average comprehensive quality score of the control group is about 0.80, which is improved to about 0.93 after using the method of the application, and the standard deviation is reduced from 0.10 to 0.04; in the education scenario, the average is about 0.78, which is improved to 0.94, and the standard deviation is reduced from 0.12 to 0.05; in the psychological companion scenario, the average of the control group is about 0.70, which is improved to 0.90, and the standard deviation is reduced from 0.15 to 0.06. The data of the three groups of scenes are subjected to independent sample t test, and it is concluded that the score improvement has statistical significance (p value is less than 0.01). Overall, the comprehensive quality scores of the experimental group dialogues are improved by about 15% to 20% on average, and the volatility is significantly reduced. This shows that the application effectively reduces the abnormal responses that do not conform to the personality or situation by real-time evaluation and adjustment, making the dialogue performance of the role large model more stable and consistent.
[0108] In addition to the above quantitative evaluation indicators, artificial quality evaluation is also conducted. Among them, multiple evaluation personnel conduct blind evaluation and scoring on the collected dialogue samples. The artificial evaluation adopts a unified scoring standard, and each evaluation personnel scores the dialogue from the personality consistency, situation matching degree and overall naturalness three dimensions with 1-5 points (5 points for the highest). To verify the consistency of the scores of different evaluation personnel, the Fleiss Kappa consistency coefficient of the evaluation results is calculated, and the result is about 0.82, indicating that the artificial scoring has high reliability. The evaluation results show that the experimental group is better than the control group in all dimensions: the average score of personality consistency is improved by about 0.8 points (5 points for full score), the situation relevance is improved by about 1.0 points, and the overall naturalness is improved by about 0.7 points.
[0109] Based on the above quantitative evaluation results and artificial evaluation results, it can be determined that the application has achieved significant results in maintaining the personality consistency and situation matching of the dialogue.
[0110] It should be noted that in addition to the above typical dialogue scenarios, the application can also be applied to various dialogue scenarios that require personality shaping and situation understanding, including but not limited to the following aspects: Games and interactive entertainment: In the scenarios of role-playing games, virtual anchors, etc., the introduction of the application can give each virtual character a persistent and stable personality setting, and adapt to the situation according to the plot and player interaction. The dialogue between multiple NPCs (non-player characters) or between NPCs and players will be more coherent and interesting, and the character setting of each character will not be confused. For example, in a detective game, each suspect NPC will always maintain their own unique personality and tone, and respond to the development of the game situation in a way that is consistent with their identity, improving the game immersion.
[0111] Smart assistant and customer management: For products such as smart speakers and smart assistants, the present application can be used to build assistant roles with different personality styles and ensure that they are consistent in style and context in long-term interaction with users. For example, a fitness coach type assistant always shows a positive and sunny personality, provides encouragement when the user's mood is low or training is lax, and dynamically adjusts the communication strategy according to the user's state on that day, which will bring better user stickiness and satisfaction.
[0112] Medical inquiry and consultation advisor: The present application can be applied to medical inquiry robots, multi-department collaborative diagnosis systems and other scenarios. Different department or professional role large models have their own professional background and communication style, share patient condition context parameters, ensure information synchronization between multiple role large models, and communicate with patients in a unified friendly personality, reducing information gaps and repeated questions and answers, and making patients feel consistent care. For financial advisors, legal consultants and other scenarios, multiple role large models can also work together using the present application to ensure consistent and rigorous professional answers and communicate with consistent service personality (such as reliable and honest).
[0113] Intelligent writing and content generation collaboration: In long story creation, multi-role script dialogue and other content generation tasks, the method of the present application can be used to maintain the uniformity of the language style of each role large model. When multiple role large models collaborate to create a novel, each role large model is responsible for the dialogue or perspective description of different characters, and through the double scoring constraint and correction mechanism, the personality of the characters can be prevented from being distorted, and the consistency of the plot can be ensured. Sharing the plot context in the dynamic dialogue context parameter vector makes all role large models understand the story background consistently, thereby generating a coherent multi-perspective novel text.
[0114] In addition, the method of the present application can also be used for consistency control and context adaptation of the personality of each role in a multi-language dialogue system. For example, in an English environment, personality expression may be direct and enthusiastic, while in a Japanese environment, it may be indirect and polite. The present application can adjust the personality parameter weight to match cultural differences, while the cultural context is included in the dynamic dialogue context parameter vector, so that the output conforms to local customs. In this way, the role large model of the multi-language version can still maintain the personality consistency and context fit in their respective language and culture, providing a consistent and localized experience for global users.
[0115] It can be known from the above that the role large model same-context personality generation scheme provided by the application can make multiple role large models keep the consistency of respective personality characteristics in long conversations through the dual scoring mechanism of personality consistency and context matching, significantly reduces the phenomenon of contradiction between role personalities and incoherence of tone style, secondly, the application introduces dynamic dialogue context parameter vector unified management dialogue context, ensures the consistency of understanding of dialogue context of all role large models, thereby avoiding the answer deviation caused by information asymmetry or misunderstanding of context between roles in the dialogue, greatly improving the coherence and relevance of the multi-role large model collaborative dialogue, thirdly, the real-time personality correction iteration mechanism of the application enables the system to automatically correct abnormal output during operation without manual intervention or offline retraining, enhances the adaptability and robustness to abnormal situations. Through the above technical means, the application guarantees personality consistency while taking into account context matching degree, realizes dynamic optimization of dialogue quality, overcomes the limitations of relying on static preset or rule control, and avoids the cost brought by blindly increasing training data and model complexity.
[0116] In order to better implement the above multi-agent collaborative role large model same-context personality generation method, the embodiment of the application further provides a corresponding multi-agent collaborative role large model same-context personality generation device. The meanings of the terms are the same as in the above multi-agent collaborative role large model same-context personality generation method, and the specific implementation details are referred to the description in the method embodiment above.
[0117] Please refer to Figure 6 The multi-agent collaborative role large model same-context personality generation device can 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 updating module 260. The detailed description of each functional module is as follows: The role initialization module 210 is configured to initialize multiple role large models and configure corresponding personality parameters for each role large model; The context initialization module 220 is configured to configure static dialogue context parameters for multi-role large model collaborative dialogue, and initialize a dynamic dialogue context parameter vector based on the static dialogue context parameters and the current dialogue history, wherein the dynamic dialogue context parameter vector at least includes an encoding representation of the static dialogue context parameters and a dynamic context encoding of the current dialogue context, and is shared by the multiple role large models; The dialogue generation module 230 is configured to determine a target role large model to be spoken in the multiple role large models in each dialogue turn, and generate dialogue output through the target role large model according to the current dialogue input, the personality parameters of the target role large model, and the dynamic dialogue context parameter vector; The quality scoring module 240 is configured to calculate the personality consistency score and the context matching score of the dialogue output, and fuse the personality consistency score and the context matching score to obtain a comprehensive quality score. The dialogue rectification module 250 is configured to, when the comprehensive quality score fails to reach a score threshold, determine a rectification strategy according to the personality consistency score and the context matching score, and adjust the personality parameters of the target role large model and / or the generation constraint to regenerate the dialogue output, and repeat the iteration until the comprehensive quality score reaches the score threshold or the number of rectification iterations reaches a number threshold. The parameter updating module 260 is configured to publish the dialogue output whose comprehensive quality score reaches the score threshold, or publish the dialogue output whose comprehensive quality score is the highest in the iteration process when the number of rectification iterations reaches the number threshold, and update the dynamic dialogue context parameter vector and the personality parameters of the target role large model to enter the next dialogue round until the dialogue ends.
[0118] Optionally, in an embodiment, the quality scoring module 240 is configured to calculate a weighted sum of the personality consistency score and the context matching score as the comprehensive quality score according to respective weight coefficients of the personality consistency score and the context matching score.
[0119] Optionally, in an embodiment, the dialogue rectification module 250 is configured to, when the personality consistency score is lower than the context matching score, determine the rectification strategy as enhancing the weight of a related deviation personality dimension in the personality parameters of the target role large model, injecting a personality reinforcement prompt, and / or regenerating the dialogue output; or when the context matching score is lower than the personality consistency score, determine the rectification strategy as supplementing a context element missing in the dialogue output in the dialogue input and / or injecting a context reinforcement prompt.
[0120] Optionally, in an embodiment, the quality scoring module 240 is configured to, for each context dimension of the dynamic dialogue context parameter vector, calculate a matching degree score of the dialogue output on the context dimension, and fuse the matching degree scores of the context dimensions to obtain the context matching score of the dialogue output; and for each personality dimension of the personality parameters of the target role large model, calculate a matching degree score of the dialogue output on the personality dimension, and fuse the matching degree scores of the personality dimensions to obtain the personality consistency score of the dialogue output.
[0121] Optionally, in an embodiment, the parameter updating module 260 is configured to determine a positive personality dimension in the personality parameters of the target role large model relative to the personality consistency score, and enhance the weight of the positive personality dimension according to a preset proportion.
[0122] Optionally, in an embodiment, the multi-agent collaborative role large model co-context personality generation device provided by the application further comprises a threshold determination module configured to determine a dialogue scene to which the current dialogue belongs according to the dynamic dialogue context parameter vector, and determine a score threshold according to the dialogue scene.
[0123] The specific limitations of the multi-agent collaborative role large model co-context personality generation device can refer to the limitations of the multi-agent collaborative role large model co-context personality generation method described above, and will not be repeated here. Each module in the multi-agent collaborative role large model co-context personality generation device described above can be realized by software, hardware and their combinations in whole or in part. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so that the processor calls and executes the operations corresponding to each module.
[0124] In an embodiment, a computer device is provided, and its internal structure diagram can be as shown in Figure 7 The computer device includes a processor, a memory, a network interface and a database connected by a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the computer device is configured to connect with an external wireless client and provide wireless network access services for the connected wireless client. When the computer device is configured as a server, the computer program is executed by the processor to implement the multi-agent collaborative role large model co-context personality generation method provided by the application, such as: Initialize a plurality of role large models, and configure corresponding personality parameters for each role large model; Configure static dialogue context parameters for the collaborative dialogue of the plurality of role large models, and initialize a dynamic dialogue context parameter vector based on the static dialogue context parameters and the current dialogue history, wherein the dynamic dialogue context parameter vector at least includes a vector representation of the static dialogue context parameters, a vector representation of the context information of the current dialogue turn, an environment state variable shared by the plurality of role large models, and a dialogue history summary vector, and is shared by the plurality of role large models; At each dialogue turn, determine a target role large model to be spoken from the plurality of role large models, and generate a dialogue output through the target role large model according to the current dialogue input, the personality parameters of the target role large model and the dynamic dialogue context parameter vector; Calculate the personality consistency score and the context matching score of the dialogue output, and fuse the personality consistency score and the context matching score to obtain a comprehensive quality score; If the comprehensive quality score does not reach the score threshold, a rectification strategy is determined according to the personality consistency score and the context matching score, and the rectification strategy is executed to adjust the personality parameters of the target role large model and / or the generation constraint, and the dialogue output is regenerated until the target role large model generates dialogue output with a comprehensive quality score reaching the score threshold or the number of rectification iterations reaches the number threshold; the dialogue output with the comprehensive quality score reaching the score threshold is published, or the dialogue output with the highest comprehensive quality score in the iteration process is published when the number of rectification iterations reaches the number threshold, and the dynamic dialogue context parameter vector and the personality parameters of the target role large model are updated based on the comprehensive quality score, and then the next dialogue turn is entered until the dialogue ends.
[0125] In an embodiment, a computer device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the method for generating a same-context personality of a role large model in multi-agent collaboration in the above embodiment when executing the computer program.
[0126] In an embodiment, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method for generating a same-context personality of a role large model in multi-agent collaboration in the above embodiment.
[0127] Those of ordinary skill in the art can understand that all or part of the processes in the above embodiments can be completed by a computer program instructing related hardware, and the computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above embodiments can be included. Any reference to memory, storage, database or other medium used in the embodiments of the present application 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. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0128] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.
[0129] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
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 role-based large models, and initialize dynamic dialogue context parameter vectors based on the static dialogue context parameters and the current dialogue history. The dynamic dialogue context parameter vectors include 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 are shared by multiple role-based large models. In each dialogue round, a target role model to speak is determined from among multiple role models, and 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. 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 until the target role 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 system publishes dialogue outputs with a comprehensive quality score that reaches the stated score threshold, or publishes dialogue outputs with the highest comprehensive quality score during the iteration process when the number of correction iterations reaches the stated number threshold. After updating the dynamic dialogue context parameter vector and the personality parameters of the target role model based on the comprehensive quality score, the system proceeds to the next dialogue round until the dialogue ends.
2. 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 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 for personality in the same context as described in claim 1, characterized in that, The step of determining the correction strategy based on the personality consistency score and the situational fit score includes: If the personality consistency score is lower than the situational matching score, the corrective strategy is determined to be to enhance the weight of the relevant biased personality dimensions in the personality parameters of the target role model, inject personality reinforcement prompts, and / or regenerate the dialogue output. If the situational matching score is lower than the personality consistency score, then the corrective strategy is determined to be to supplement the missing situational elements in the dialogue input and / or inject situational reinforcement prompts.
4. The method for generating a multi-agent collaborative role-based large-scale model personality in the same context as described in claim 3, 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.
5. The method for generating a multi-agent collaborative role model in a shared context according to claim 1, characterized in that, The updating of the personality parameters of the target character model includes: Determine the positive personality dimension in the personality parameters of the target role model relative to the personality consistency score, and increase the weight of the positive personality dimension according to a preset ratio.
6. 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-5, 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.
7. 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 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. 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 comprehensive 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 iteratively until the comprehensive quality score reaches the scoring threshold or the number of correction iterations reaches the number threshold. The parameter update module publishes dialogue outputs with a comprehensive quality score that reaches the score threshold, or publishes dialogue outputs with the highest comprehensive 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 model, it enters the next dialogue round until the dialogue ends.
8. The multi-agent collaborative role-based large-scale model personality generation device according to claim 7, characterized in that, The dialogue correction module is used to determine the correction strategy as follows if the personality consistency score is lower than the situational matching score: to enhance the weight of the relevant deviation personality dimension in the personality parameters of the target role model, inject personality reinforcement prompts, and / or regenerate the dialogue output. If the situational matching score is lower than the personality consistency score, then the corrective strategy is determined to be to supplement the missing situational elements in the dialogue input and / or inject situational reinforcement prompts.
9. 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 6.
10. 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 6.
Citation Information
Patent Citations
Personalized reply generation method fusing role reasoning and adaptive attention
CN118113833A
Role dialogue method based on large model, intelligent agent, equipment and storage medium
CN119047578A
Role playing chat robot implementation method based on human background large language model
CN119646140A
Dialogue generation method and system
CN120725142A
Virtual historical character dialogue method and system with role knowledge and context awareness
CN121352040A