A personality-based emotional intensity controllable dialogue generation method
By quantifying the personality traits of a dialogue system and converting them into emotional intensity values, and combining deep learning and generative language models, the problem of uncontrollable emotional intensity in emotional dialogue systems is solved. This enables the generation of dialogues with controllable emotional intensity based on personality traits, thereby improving the effectiveness of humanized communication.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING INST OF TECH
- Filing Date
- 2022-11-23
- Publication Date
- 2026-04-17
AI Technical Summary
Existing emotional dialogue systems cannot freely generate responses with controllable emotional intensity. In particular, when considering personality traits, the data-driven approach is limited, making it difficult to generate responses that conform to different personality characteristics.
By introducing psychological knowledge, the personality of the dialogue system is quantified and converted into emotional intensity values. Combining deep learning technology and generative language models, an emotional intensity loss function is constructed using a word type discriminator and Gaussian distribution, enabling the dialogue system to generate controllable responses with emotional intensity that are consistent with the user's personality.
The generated dialogue response can naturally control the intensity of emotions based on the user's personality traits, solving the data limitation problem of existing emotional dialogue systems and improving the effect of humanized communication.
Smart Images

Figure CN116166778B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of open-domain emotional dialogue systems in natural language processing, and particularly relates to a method for generating dialogues with controllable emotional intensity based on personality. Technical Background
[0002] Dialogue systems are a crucial part of natural language processing, and emotion is one of the essential characteristics of dialogue systems. Most existing emotion-driven dialogue systems are designed from a data-driven perspective, which often limits them to emotion datasets and prevents them from freely generating responses with controllable emotional intensity. When it comes to generating responses with personality traits, different personalities should generate responses with different emotional intensities based on their individual personality characteristics. Generating responses directly using a data-driven approach is subject to greater data constraints, and the appropriate emotional intensity also presents a problem.
[0003] With the continuous development of the field of psychology, psychological research on emotions can be combined to achieve emotion-related tasks in the field of natural language processing. Personality can be well expressed numerically to represent personality traits, and emotions can also be quantified using the PAD emotion model. Psychology has relevant formulas for the conversion between these two. When generating responses in a dialogue system, introducing these formulas can easily control the emotional intensity that different personalities and emotions should reflect in the generated response. Combined with generative language models and plug-and-play language model algorithms, the developed dialogue system can naturally generate dialogue responses with controllable emotional intensity based on personality. Summary of the Invention
[0004] The main objective of this invention is to provide a personality-based method for generating dialogues with controllable emotional intensity. This method introduces psychological knowledge into dialogue generation within natural language processing (NLP). By quantifying the personality of the dialogue system and converting these personality values into intensity values for specified emotions, deep learning technology is used to achieve controllable dialogue generation based on personality classification. Since the emotional intensity of the responses generated by the dialogue system to user input is controlled by the personality values, after obtaining the user's personality values, these values are input into a deep learning model. The deep learning model outputs a dialogue system personality that matches the user's personality, thereby enabling the generation of responses tailored to different personalities, ensuring that the emotional intensity of the generated responses matches the user's personality. This addresses related technical problems in the field of NLP dialogue generation, including intelligent customer service, dialogue recommendation, personalized article generation, emotional guidance, and intelligent companionship.
[0005] The objective of this invention is achieved through the following technical solution.
[0006] This invention discloses a personality-based method for controlling the emotional intensity of dialogue generation. It introduces psychological knowledge into dialogue generation within natural language processing (NLP). By quantifying the personality of the dialogue system and converting these personality values into numerical values for the intensity of a specified emotion, it achieves the requirement that the emotional intensity of the generated responses varies depending on the given personality. This invention introduces a word type discriminator during the language model training phase to determine the type of generated words, thereby employing different strategies for inference during the prediction phase, making the model more closely match real data. Based on the idea of a plug-and-play language model, it uses a dictionary labeled with emotional intensity and combines it with a Gaussian distribution to construct an emotional intensity loss function, enhancing the probability distribution of corresponding emotional words generated at a specified emotional intensity. In practical application, a deep learning model is first used to obtain the user's personality. Based on the user's personality, a deep learning model is then used to obtain the dialogue system's personality. Based on the trained model and the dialogue system's personality, the dialogue system can generate emotional responses to user input under a given personality without retraining, ensuring that the emotional intensity of the generated responses matches the user's personality, thus solving related technical problems in the field of dialogue generation within natural language processing.
[0007] To achieve the above objectives, the technical method adopted by the present invention is as follows:
[0008] This invention discloses a method for generating dialogue with controllable emotional intensity based on personality, comprising the following steps:
[0009] Step 1: Train the dialogue system using the sentiment dialogue dataset. The dialogue system consists of a generative model and a type classifier. The generative model is obtained by fine-tuning a pre-trained language model and fully connected layers using the sentiment dialogue dataset. During the inference phase, it receives user input from the user. This user input is trained on the generative model, which outputs probability values distributed across the model's vocabulary and a hidden layer vector representation of the user input. The type classifier is connected after the generative model. During the training phase, it receives the hidden layer vector output by the generative model and outputs the probability that the generated word belongs to sentiment or non-sentiment words. This probability is used to determine the type of the generated word, facilitating the use of different strategies for inference in the prediction phase of subsequent steps, making the dialogue generation model more closely match real-world data.
[0010] Step 1.1: Fine-tune the pre-trained language model and fully connected layers using the sentiment dialogue dataset to obtain the dialogue generation model. The fine-tuning method is implemented as follows:
[0011] Constructing the input for the pre-trained language model:
[0012] ,
[0013] The input contains two special markers, [CLS] and [SEP]. [CLS] indicates the start of user input, and [SEP] indicates the end of user input and the start of the model response. This represents the nth word in the user input. This represents the nth word in the model response. This input is fed into a pre-trained language model to obtain its output:
[0014]
[0015] in This represents the vector representation of the nth word in the user input. This represents the vector representation of the nth word in the model response. A fully connected layer follows the pre-trained model, and the input to the fully connected layer is... The output dimension is the size of the model vocabulary. Based on the output of the fully connected layer, probabilistic sampling is performed to obtain the generated sentence:
[0016] ,
[0017] in and The positions correspond one-to-one, and the cross-entropy loss function is calculated as follows:
[0018]
[0019] Step 1.2: By introducing a word type discriminator during the generative model training phase described in Step 1.1, the type classifier receives the hidden layer vectors output by the pre-trained model during the training phase. It outputs the probability that the generated word belongs to sentiment words and non-sentiment words, determines the type of the generated word, and then adopts different strategies for reasoning in the prediction stage, so that the generated dialogue is more consistent with real data.
[0020] The type classifier uses a neural network model. The input is the hidden layer output of the pre-trained model at the predicted word position at the current time step. The output is the probability distribution of the two categories. Its purpose is to determine whether the current predicted word is a common word or a sentiment word. The input of the pre-trained model at time t is as follows:
[0021]
[0022] The model output is as follows:
[0023]
[0024] The definitions of each parameter are the same as described in step 1.1, and the type classifier receives... As input,
[0025] The output is , Indicates that the response is followed by The word after The type, 0 indicates For ordinary words, 1 indicates For sentiment words, during the training phase, the type classifier outputs the predicted category for the complete input, and the cross-entropy loss function is calculated as follows:
[0026]
[0027] Step 1.3: Based on the cross-entropy loss function obtained in Step 1.1 and the cross-entropy loss function obtained in step 1.2 Construct the overall loss function for the fine-tuning process. According to the total loss function of the fine-tuning process Gradient descent is used to update the parameters of the generative model and the type classifier. In other words, the dialogue system is trained using the sentiment dialogue dataset to obtain the trained dialogue system.
[0028] Step 2: Obtain the user's personality score, which can be achieved through a questionnaire survey.
[0029] Step 3: Using deep learning methods, the user personality values obtained in Step 2 are used as input to the dialogue generation model. After processing, the dialogue generation model outputs a dialogue system personality value that matches the user's personality.
[0030] Step 4: The personality value of the dialogue system obtained in Step 3 is used to calculate the emotional intensity value of the dialogue system, that is, to convert the personality value of the dialogue system into an intensity value for the specified emotion.
[0031] Preferably, the PAD three-dimensional emotion model is used to measure emotions, and the Big Five personality model is used to measure personality. The Big Five personality values are mapped to the PAD emotion space, and the PAD emotion space values are further used to calculate the emotion intensity value of the dialogue system. The specific implementation method of step four is as follows:
[0032] Step 4.1: The Big Five personality traits comprise five dimensions: Openness, Conscientiousness, Extraversion, Agreeableness, and Neuroticism. When quantifying the Big Five personality traits, each dimension's value is fixed between [0, 1]. For example, when the Big Five personality traits in the dialogue system are [0.3, 0.3, 0.1, 0.2, 0.8], the personality traits are characterized by frequent anxiety, impulsivity, and emotional fragility. In the PAD three-dimensional model, P represents pleasure, A represents arousal, and D represents dominance. Each dimension's value ranges between [-1, 1]. For example, the PAD value for anger is represented as [-0.51, 0.59, 0.25]. The Big Five personality traits obtained in Step 3 can be converted into PAD values using the following formula.
[0033]
[0034] Step 4.2: Obtain the PAD value of the emotion category to be generated by the dialogue system by looking up a table. Perform matrix multiplication between the PAD value obtained by looking up the table and the PAD value calculated in step 4.1 to obtain the intensity value of the emotion that matches the personality of the dialogue system and the emotion to be generated. The emotion intensity value is denoted as Eei, where the subscript e represents the emotion category and i represents the emotion intensity under this emotion category.
[0035] Step 5: Based on the plug-and-play language model, a dictionary with sentiment intensity annotations is used, and a sentiment intensity loss function is constructed using a Gaussian distribution. This increases the probability distribution of generated sentiment words at specified sentiment intensities. Controllable responses generated by the dialogue system are obtained based on probability sampling of the generated words. In the inference generation stage of the dialogue generation model, the pre-trained model receives user input, and the type classifier receives the output of the pre-trained model. The type classifier predicts whether the currently generated word is a common word or a sentiment word, and then decodes it according to different categories.
[0036] Step Six: When the dialogue generation model generates ordinary words (non-sentiment words) at the current time, the dialogue generation model decodes and generates normally according to the following formula, where LM is the pre-trained language model, and H... t Let s represent the hidden layer vector of the language model at time t. t O represents the generated word of the model at time t. t+1 This is a vector used to calculate the probability distribution of the (t+1)th word generated by the model, and W is the model parameter of the fully connected layer in the generation model.
[0037]
[0038]
[0039] Step 7: When the dialogue generation model generates sentiment words at the current moment, the dialogue generation model decodes them according to the idea of plug-and-play language model and combined with Gaussian distribution.
[0040] Step 7.1: Calculate using the formula for generating ordinary words to obtain p. t+1 This is denoted as the probability distribution of the generated words obtained without interference.
[0041] Step 7.2: Calculate the sentiment intensity E of the generated word based on the probability distribution of the generated word in Step 7.1. ei The probability is then used to further calculate the emotional intensity loss value. The formula for calculating the emotional intensity loss value is as follows:
[0042]
[0043] Wherein, BoWprobs represents the probability distribution of words belonging to the sentiment dictionary with sentiment intensity annotation in the generated word probability distribution, N is a Gaussian distribution with a mean of E. ei The variance is var, and affectInt is the sentiment intensity value in the corresponding dictionary for the sentiment word. The mean is set to the sentiment intensity to be generated. The generation probability of sentiment words with the same sentiment intensity as the given sentiment intensity is increased, while the generation probability of other sentiment words is decreased. The variance value can be set freely, and the variance represents the allowable actual sentiment intensity within E. ei The fluctuation value;
[0044] Step 7.3: Update H' according to the following gradient descent formula. t value;
[0045]
[0046] Step 7.4: Place H' t Substituting the value into the ordinary word calculation formula yields the new p' t+1 , denoted as the probability of the generated word after interference;
[0047] Step 7.5: Place p' t+1 Substitute into step 7.2 to calculate Loss affect Simultaneously calculate p' t+1 With p t+1 The KLD divergence is calculated, and the sum of the two yields the Loss.
[0048] Step 7.6: Update H' according to the following formula t ;
[0049]
[0050] Iteration steps 7.4, 7.5, and 7.6 are performed a total of n times for p'. t+1 Sampling is performed to obtain sentiment words in the response.
[0051] Step 8: Combine the ordinary words obtained in Step 6 with the emotional words obtained in Step 7 to obtain a response with emotional intensity that matches the user's personality, that is, to achieve controllable dialogue generation based on personality emotional intensity.
[0052] It also includes step nine, which, based on the emotionally charged response obtained in step eight that matches the user's personality, addresses technical issues related to dialogue generation in the field of natural language processing. These technical issues include intelligent customer service, dialogue recommendation, personalized article generation, emotional guidance, and intelligent companionship.
[0053] Applying this method to intelligent customer service allows the system to identify and understand user questions, analyze user intent through semantic analysis, and communicate with users in a human-like manner to provide customer service. By deriving an intelligent customer service personality based on the user's personality, the system can enhance the degree of humanization and thus improve user satisfaction.
[0054] The method is applied to personalized article generation. The personality of the intelligent author and the theme of the article are set according to the target audience. The intelligent author automatically generates articles according to the theme while meeting the personality requirements, thereby improving the audience's satisfaction with the articles.
[0055] Applying this method to intelligent companionship, the companion will perceive the user's emotions during the interaction process and adjust its own personality and interactive behavior accordingly. Through long-term interaction with the user, the intelligent companion will gradually form its own personality system through deep learning technology, continuously iterate and upgrade, and improve the user's mental health.
[0056] Beneficial effects:
[0057] 1. The present invention discloses a personality-based method for generating dialogue with controllable emotional intensity. It utilizes a deep learning model to output a dialogue system personality that matches the user's personality, adopts the Big Five personality traits as a numerical measure of personality, converts personality into emotional intensity, and uses emotional intensity to change the probability distribution of generated words to generate dialogue responses with controllable emotional intensity, so that the emotional intensity of the generated response matches the user's personality, wherein the emotional intensity is determined by personality.
[0058] 2. The present invention discloses a personality-based method for generating dialogue with controllable emotional intensity, which adopts a Gaussian distribution. The emotional intensity is used as the mean of the Gaussian distribution, and the amplitude of emotional fluctuations in the generated response is used as the variance of the Gaussian distribution. The Gaussian distribution is used to increase the probability value of emotional words that meet the emotional intensity requirements and decrease the probability value of emotional words that do not meet the emotional intensity requirements, thereby generating dialogue responses with controllable emotional intensity from the emotional word level.
[0059] 3. The present invention discloses a personality-based method for generating dialogue with controllable emotional intensity, which is based on the gradient accumulation generation method of emotional loss. By calculating the gradient of the emotional loss function and accumulating the calculated gradient, the hidden layer vector value is changed, which further guides the change of the probability distribution of emotional words. This allows the model to generate dialogue responses with controllable emotional intensity without retraining the model when the personality changes.
[0060] 4. The present invention discloses a personality-based method for generating dialogue with controllable emotional intensity, which is applied to the field of dialogue generation in natural language processing and solves related technical problems, such as intelligent customer service, dialogue recommendation, personalized article generation, emotional guidance, and intelligent companionship. Attached Figure Description
[0061] Figure 1 This is a flowchart of the personality-based, emotion-intensity-controllable dialogue generation method of the present invention;
[0062] Figure 2 This example demonstrates the generation of a structure diagram for the response during the model inference phase.
[0063] Figure 3 This is a structural diagram of the model of the present invention; Detailed Implementation
[0064] To better illustrate the purpose and advantages of the present invention, the invention will be further described below in conjunction with the accompanying drawings and examples.
[0065] Example 1:
[0066] In this example, the GPT2 model is selected as the pre-trained language model, and the DailyDialog dataset is used as the sentiment dialogue dataset for the fine-tuning stage. The user input is: Are things still going badly with your houseguest?.
[0067] The specific settings of the embodiment model are as follows: Figure 2 As shown, the model is based on plug-and-play and Gaussian distribution, which changes the generation probability of emotional words according to the emotional intensity, thereby generating dialogue responses with controllable emotional intensity.
[0068] like Figure 1 As shown in the figure, this embodiment discloses a personality-based method for generating dialogue with controllable emotional intensity. The specific implementation steps are as follows:
[0069] Step 1:
[0070] Step 1.1: Fine-tune the GPT2 model and fully connected layers using the DailyDialog dataset to obtain the generative model. The fine-tuning method is implemented as follows:
[0071] Constructing the input for the GPT2 model:
[0072] ,
[0073] The input contains two special markers, [CLS] and [SEP]. [CLS] indicates the start of the dialogue input, and [SEP] indicates the end of the dialogue input and the start of the GPT2 model response. This represents the nth word in the dialogue input. This represents the nth word in the dialogue response. Feeding this input into the GPT2 model yields the GPT2 model output:
[0074]
[0075] in This represents the vector representation of the nth word in the dialogue input. This represents the vector representation of the nth word in the dialogue response. It is followed by a fully connected layer in the GPT2 model. The input to the fully connected layer is... The output dimension is the size of the GPT2 model vocabulary. Based on the output of the fully connected layer, probability sampling is performed to obtain the generated sentence:
[0076] ,
[0077] in and The positions correspond one-to-one, and the cross-entropy loss function is calculated as follows:
[0078]
[0079] Step 1.2: By introducing a word type discriminator during the generative model training phase described in Step 1.1, the type classifier receives the hidden layer vectors output by the pre-trained model during the training phase. It outputs the probability that the generated word belongs to sentiment words and non-sentiment words, determines the type of the generated word, and then adopts different strategies for inference in the prediction stage, so that the model is more closely matched with the real data.
[0080] The type classifier uses a fully connected layer. The input is the hidden layer output of the GPT2 model at the predicted word position at the current time step. The output is the probability distribution of the two categories. Its purpose is to determine whether the current predicted word is a normal word or a sentiment word. The input to the pre-trained model at time t is as follows:
[0081]
[0082] The model output is as follows:
[0083]
[0084] The definitions of each parameter are the same as described in step 1.1, and the type classifier receives... As input,
[0085] The output is , Indicates that the response is followed by The word after The type, 0 indicates For ordinary words, 1 indicates For sentiment words, during the training phase, the type classifier outputs the predicted category for the complete input, and the cross-entropy loss function is calculated as follows:
[0086]
[0087] Step 1.3: Based on the cross-entropy loss function obtained in Step 1.1 and the cross-entropy loss function obtained in step 1.2 Construct the overall loss function for the fine-tuning process. According to the total loss function of the fine-tuning process Gradient descent is used to update the parameters of the generative model and the type classifier. The DailyDialog dataset is used to train the dialogue system, resulting in the trained dialogue system.
[0088] Step 2: Obtain the user's Big Five personality score [0.2, 0.4, 0.1, 0.3, 0.7] using a questionnaire survey.
[0089] Step 3: Using deep learning methods, the user personality values obtained in Step 2 are used as input to the deep model. After processing, the model outputs a dialogue system personality value that matches the user's personality [0.3, 0.3, 0.1, 0.2, 0.8].
[0090] Step 4: The personality value of the dialogue system obtained in Step 3 is used to calculate the emotional intensity value of the dialogue system, that is, to convert the personality value of the dialogue system into an intensity value for the specified emotion.
[0091] The PAD three-dimensional emotion model is used to measure emotions, and the Big Five personality model is used to measure personality. The Big Five personality values are mapped to the PAD emotion space, and the PAD emotion space values are further used to calculate the emotion intensity value of the dialogue system. The specific implementation method of step four is as follows:
[0092] Step 4.1: The Big Five personality traits include five dimensions: Openness, Conscientiousness, Extraversion, Agreeableness, and Neuroticism. When quantifying the Big Five personality traits, the value range for each dimension is fixed between [0, 1]. In the PAD three-dimensional model, P represents pleasantness, A represents arousal, and D represents dominance. The value range for each dimension is between [-1, 1]. The Big Five personality traits values obtained in Step 3 can be converted into PAD values using the following formula. The calculated PAD values are [0.291, -0.351, 0.122].
[0093]
[0094] Step 4.2: Obtain the PAD value [-0.51, 0.59, 0.25] for the anger category to be generated by the dialogue system by looking up a table. Perform matrix multiplication between the PAD value obtained from the table lookup and the PAD value calculated in Step 4.1 to obtain the intensity value Eei = -0.325 that matches the personality of the dialogue system and the emotion to be generated, where the subscript e represents the emotion category and i represents the emotion intensity under this emotion category. The personality of the dialogue system has an extraversion dimension of 0.1 and an openness dimension of 0.3, indicating that this personality is biased towards introversion, and the emotion intensity of -0.325 when expressing anger is reasonable.
[0095] Step 5: Based on the plug-and-play language model concept, a dictionary with sentiment intensity annotations is used, combined with a Gaussian distribution to construct a sentiment intensity loss function, increasing the probability distribution of generated sentiment words at specified sentiment intensities. Controllable responses generated by the dialogue system are obtained based on probability sampling of the generated words. In the model inference generation stage, the pre-trained model receives user input, and the type classifier receives the pre-trained model output. The type classifier predicts whether the currently generated word is a normal word or a sentiment word, and then decodes it according to different categories.
[0096] Step Six: Current Generated Word is a Normal Word: When the generated word is a non-sentiment word at the current time step, the model decodes and generates normally according to the following formula, where LM is the GPT2 language model, and H... t Let s represent the hidden layer vector of the language model at time t. t O represents the generated word of the model at time t. t+1 This is a vector used to calculate the probability distribution of the (t+1)th word generated by the model, and W is the model parameter of the fully connected layer in the generation model.
[0097]
[0098]
[0099] Step 7: Current Generated Word is a Sentiment Word: When the generated word is a sentiment word at the current time step, the model decodes it using the plug-and-play language model approach combined with a Gaussian distribution. The steps are as follows:
[0100] Step 7.1: Calculate using the formula for generating ordinary words to obtain p. t+1 This is denoted as the probability distribution of the generated words obtained without interference.
[0101] Step 7.2: Calculate the sentiment intensity E of the generated word based on the probability distribution of the generated word in Step 7.1. ei The probability is -0.325, which is used to further calculate the emotional intensity loss value. The formula for calculating the emotional intensity loss value is as follows:
[0102]
[0103] Wherein, BoWprobs represents the probability distribution of words belonging to the sentiment dictionary with sentiment intensity annotation in the generated word probability distribution, N is a Gaussian distribution with a mean of E. ei = -0.325, variance is var = 0.1, affectInt is the sentiment intensity value in the corresponding dictionary of sentiment words, the mean is set to the sentiment intensity to be generated, the generation probability of sentiment words with the same sentiment intensity as the given sentiment intensity is increased, and the generation probability of other sentiment words is decreased, the variance value can be set arbitrarily, the variance represents the allowable actual sentiment intensity within E ei The fluctuation value;
[0104] Step 7.3: Update H' according to the following gradient descent formula. t value;
[0105]
[0106] Step 7.4: Place H' t Substituting the value into the ordinary word calculation formula yields the new p' t+1 , denoted as the probability of the generated word after interference;
[0107] Step 7.5: Place p' t+1 Substitute into step 7.2 to calculate Loss affect Simultaneously calculate p' t+1 With p t+1 The KLD divergence is calculated, and the sum of the two yields the Loss.
[0108] Step 7.6: Update H' according to the following formula t ;
[0109]
[0110] Iteration steps 7.4, 7.5, and 7.6 are performed a total of n times for p'. t+1 Sampling is performed to obtain sentiment words in the response.
[0111] The original response was: Getting worse. That was the last straw. The response generated using the method of this invention is: Getting worse. I can't stand it. Compared to the original, the response generated by the model matches the emotional intensity of anger, i.e., -0.325, indicating that the model generated a dialogue response with controllable emotional intensity.
[0112] The above detailed description further illustrates the purpose, technical solution, and beneficial effects of the invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A personality-based affective intensity controllable dialogue generation method, characterized by: Includes the following steps: Step 1: Train the dialogue system using the sentiment dialogue dataset. The dialogue system consists of a generative model and a type classifier. The generative model is obtained by fine-tuning a pre-trained language model and fully connected layers using the sentiment dialogue dataset. During the inference phase, it receives user input. After training, the generative model outputs probability values distributed across its vocabulary and a hidden layer vector representation of the user input. The type classifier is connected after the generative model. During the training phase, it receives the hidden layer vector output by the generative model and outputs the probability that the generated word belongs to sentiment or non-sentiment words. This probability is used to determine the type of the generated word, facilitating the use of different strategies for inference in the prediction phase of subsequent steps, making the dialogue generation model more closely match the real data. Step 2: Obtain the user's personality score; Step 3: Using deep learning methods, the user personality values obtained in Step 2 are used as input to the dialogue generation model. After processing, the dialogue generation model outputs a dialogue system personality value that matches the user's personality. Step 4: The personality value of the dialogue system obtained in Step 3 is used to calculate the emotional intensity value of the dialogue system, that is, to convert the personality value of the dialogue system into an intensity value for the specified emotion; The PAD three-dimensional emotion model is used to measure emotions, and the Big Five personality model is used to measure personality. The Big Five personality values are mapped to the PAD emotion space, and the PAD emotion space values are further used to calculate the emotion intensity value of the dialogue system. The specific implementation method of step four is as follows. Step 4.1: The Big Five personality traits include five dimensions: Openness, Conscientiousness, Extraversion, Agreeableness, and Neuroticism. When quantifying the Big Five personality traits, the value range for each dimension is fixed between [0, 1]. In the PAD three-dimensional model, P represents pleasantness, A represents arousal, and D represents dominance. The value range for each dimension is between [-1, 1]. The Big Five personality traits values obtained in Step 3 can be converted into PAD values using the following formula. Step 4.2: Obtain the PAD value of the emotion category to be generated by the dialogue system through a lookup table. Perform a matrix multiplication between the PAD value obtained from the lookup table and the PAD value calculated in Step 4.1 to obtain the intensity value of the emotion that matches the personality of the dialogue system and the emotion to be generated. This emotion intensity value is denoted as... , where the subscript e represents the emotion category and i represents the emotion intensity under this emotion category; Step 5: Based on the plug-and-play language model, a dictionary with sentiment intensity annotations is used, and a sentiment intensity loss function is constructed by combining it with a Gaussian distribution. The probability distribution of the corresponding sentiment words generated under a specified sentiment intensity is increased. Based on the probability sampling of the generated words, a controllable response generated by the dialogue system is obtained. In the inference generation stage of the dialogue generation model, the pre-trained model receives user input, and the type classifier receives the output of the pre-trained model. The type classifier predicts whether the current generated word is a common word or a sentiment word, and then decodes it according to different categories. Step Six: When the dialogue generation model generates ordinary words at the current time step, the dialogue generation model decodes and generates words normally according to the following formula, where LM is a pre-trained language model, and H... t Let s represent the hidden layer vector of the language model at time t. t O represents the generated word of the model at time t. t+1 This is a vector used to calculate the probability distribution of the (t+1)th word generated by the model, and W is the model parameter of the fully connected layer in the generation model. Step 7: When the dialogue generation model generates sentiment words at the current moment, the dialogue generation model decodes them using a plug-and-play language model combined with a Gaussian distribution; Step 8: Combine the ordinary words obtained in Step 6 with the emotional words obtained in Step 7 to obtain a response with emotional intensity that matches the user's personality, that is, to achieve controllable dialogue generation based on personality emotional intensity.
2. The personality-based emotional intensity controllable dialogue generation method of claim 1, wherein: It also includes step nine, which, based on the emotionally charged response that matches the user's personality obtained in step eight, solves related technical problems in the field of natural language processing dialogue generation. These related technical problems include intelligent customer service, dialogue recommendation, personalized article generation, emotional guidance, and intelligent companionship. When applied to intelligent customer service, the intelligent customer service will identify and understand the questions raised by users, analyze user intent through semantic analysis, and communicate with users in a human way to provide customer service. The intelligent customer service personality is derived based on the user's personality, which can improve the degree of humanization of the intelligent customer service and thus improve user satisfaction. It is applied to personalized article generation. The intelligent author sets the personality of the author and the theme of the article based on the target audience. The intelligent author automatically generates articles according to the theme while meeting the personality requirements, thereby improving the audience's satisfaction with the articles. When applied to intelligent companionship, the intelligent companion will sense the user's emotions during the interaction process, and then adjust its own personality and interactive behavior. In the long-term interaction with the user, the intelligent companion will gradually form its own personality system through deep learning technology, continuously iterate and upgrade, and improve the user's mental health.
3. The personality-based emotional intensity controllable dialogue generation method according to claim 1 or 2, characterized in that: The implementation method for step one is as follows: Step 1.1: Fine-tune the pre-trained language model and fully connected layers using the sentiment dialogue dataset to obtain the dialogue generation model; the fine-tuning method is specifically implemented as follows: Constructing the input for the pre-trained language model: , The input contains two special markers, [CLS] and [SEP]. [CLS] indicates the start of user input, and [SEP] indicates the end of user input and the start of the model response. This represents the nth word in the user input. This represents the nth word in the model response; this input is fed into the pre-trained language model to obtain the pre-trained language model output: in This represents the vector representation of the nth word in the user input. This represents the vector representation of the nth word in the model response. A fully connected layer follows the pre-trained model, and the input to the fully connected layer is... The output dimension is the size of the model vocabulary. Based on the output of the fully connected layer, probabilistic sampling is performed to obtain the generated sentence: , wherein with one-to-one correspondence with the positions of the, the cross-entropy loss function is calculated as follows: Step 1.2: By introducing a word type discriminator during the generative model training phase described in Step 1.1, the type classifier receives the hidden layer vectors output by the pre-trained model during the training phase. The output is the probability that the generated word belongs to sentiment words and non-sentiment words. The type of generated word is determined so that different strategies are used for reasoning in the prediction stage, making the generated dialogue more consistent with real data. The type classifier uses a neural network model. The input is the hidden layer output of the pre-trained model at the predicted word position at the current time step. The output is the probability distribution of the two categories. Its purpose is to determine whether the current predicted word is a common word or a sentiment word. The input of the pre-trained model at time t is as follows: The model output is as follows: where each parameter definition is the same as described in step 1.1, said type classifier receives as input, The output is , Indicates that the response is followed by The word after The type, 0 indicates For ordinary words, 1 indicates For sentiment words, during the training phase, the type classifier outputs the predicted category for the complete input, and the cross-entropy loss function is calculated as follows: Step 1.3: Based on the cross-entropy loss function obtained in Step 1.1 and the cross-entropy loss function obtained in step 1.2 Construct the overall loss function for the fine-tuning process. According to the total loss function of the fine-tuning process Gradient descent is used to update the parameters of the generative model and the type classifier. In other words, the dialogue system is trained using the sentiment dialogue dataset to obtain the trained dialogue system.
4. The personality-based method for generating dialogue with controllable emotional intensity as described in claim 3, characterized in that: Step seven is implemented as follows: Step 7.1: Calculate the p according to the formula of common word generation t+1 denoted as the probability distribution of the generated word without interference term; Step 7.2: Calculate the sentiment intensity E of the generated word based on the probability distribution of the generated word in Step 7.
1. ei The probability is then used to further calculate the emotional intensity loss value. The formula for calculating the emotional intensity loss value is as follows: Wherein, BoWprobs represents the probability distribution of words belonging to the sentiment dictionary with sentiment intensity annotation in the generated word probability distribution, N is a Gaussian distribution, and the sentiment intensity value E ei Let be the mean of a Gaussian distribution, var be the variance, and affectInt be the sentiment intensity value in the corresponding dictionary for the sentiment word, along with the sentiment intensity E. ei The generation probability of the same sentiment word is increased, while the generation probability of other sentiment words is decreased. The variance value can be freely set, and the variance represents the allowable actual sentiment intensity within E. ei The fluctuation value; Step 7.3: Update H' according to the following gradient descent formula t value; Step 7.4: Substitute the value of H t into the general word computation formula to get a new p t+1 , denoted as the probability of the generated word after interference; Step 7.5: Place p' t+1 Substitute into step 7.2 to calculate Loss affect Simultaneously calculate p' t+1 With p t+1 The KLD divergence is calculated, and the sum of the two yields the Loss. Step 7.6: Update H' as follows t ; Iterate steps 7.4, 7.5, 7.6 n times for p' t+1 Sample the response for affective words.
Citation Information
Patent Citations
Personalized human-computer emotional session system
CN108846073A
Intelligent dialogue generation method and device, computer equipment and computer storage medium
CN110990543A