Emotion dialogue generation method and system based on large model

By using causal emotion serialization and emotion arc vector construction, and combining the current user's words to generate emotional dialogue responses, this solves the problem of the lack of depth and insight in existing emotional dialogue generation methods, and achieves an intelligent improvement in emotional dialogue generation.

CN120851041BActive Publication Date: 2025-12-12WEST LAKE XINCHEN (HANGZHOU) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511325043.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-17
Publication Date
2025-12-12
Estimated Expiration
2045-09-17

AI Technical Summary

Technical Problem

Existing methods for generating emotional dialogues based on large language models struggle to capture and understand the transition of users' emotional states from one to another and their inherent causal relationships. This results in generated responses lacking depth and insight, failing to provide personalized, highly empathetic communication.

Method used

By acquiring the target user's dialogue history and performing causal sentiment serialization, a sentiment arc vector is constructed. This vector is then combined with the current user's utterance to generate a target sentiment strategy. The information is then input into a finely tuned large language model to generate a sentiment dialogue response.

Benefits of technology

It achieves in-depth modeling and forward-looking utilization of the entire process of user emotional evolution, significantly improving the intelligence level and interaction quality of emotional dialogue generation, and ensuring accurate grasp of the emotional context and deep empathy in responses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120851041B_ABST
    Figure CN120851041B_ABST
Patent Text Reader

Abstract

The application discloses a large model-based emotional dialogue generation method and system, relating to the field of emotional dialogue generation, which first performs causal emotion analysis and serialization processing on the complete dialogue history of a target user, and then abstracts and vectorizes the captured emotional dynamic evolution track. Subsequently, based on the vectorized representation, the current user's speech is combined to plan a forward-looking reply emotion strategy. Finally, the original dialogue history, emotion evolution analysis results, and planned emotion strategy are structured and integrated to construct a unified context prompt, which is input into a fine-tuned large language model to obtain the final emotional dialogue reply. In this way, through deep modeling and forward-looking utilization of the whole process of user emotional evolution, the emotional context can be accurately grasped, and the intelligent level and interaction quality of emotional dialogue generation are significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of emotional dialogue generation, and more specifically, to a large model-based emotional dialogue generation method and system. BACKGROUND

[0002] With the rapid progress of artificial intelligence technology, especially the rise of large language models (LLMs), the mode of human-computer interaction is undergoing profound changes. Dialogue systems have evolved from traditional task-oriented question-answering to intelligent companions capable of open-domain, multi-turn interaction. In this evolution process, merely achieving accurate information transmission cannot meet the growing interaction needs of users, especially in psychological counseling, emotional companionship, and personalized services, users expect to obtain responses with emotional temperature and empathy. Therefore, endowing dialogue systems with emotional intelligence, enabling them to understand and respond to users' emotional states, is crucial for improving user experience, establishing trust relationships, and providing deep humanistic care.

[0003] In the prior art, large language model-based emotional dialogue generation methods generally focus on identifying and responding to the immediate emotions expressed by users in the latest round of dialogue. These methods, while able to generate superficially appropriate emotional replies to some extent, their understanding of emotions is often static and isolated, generally lacking the ability to deeply model and effectively utilize the emotional dynamic evolution trajectory of users throughout the entire dialogue history. Specifically, existing technologies are difficult to capture and understand the flow process of emotional states from one to another and their inherent causal relationships, such as the complete emotional chain from initial surprise to worry and finally to comfort. This shallow processing of emotional context results in replies generated by the model that may conform to the current situation but lack depth and insight, failing to truly touch the core drivers of users' emotional changes, thereby severely limiting the potential and effectiveness of dialogue systems in providing personalized, high-empathy communication.

[0004] Therefore, there is an urgent need for an optimized large model-based emotional dialogue generation method and system. SUMMARY

[0005] To solve the above technical problems, the present application is proposed.

[0006] According to an aspect of the present application, a large model-based emotional dialogue generation method is provided, which comprises: obtaining a dialogue history of a target user; performing causal emotion serialization on the dialogue history of the target user to obtain a causal emotion sequence; constructing an emotional arc vector based on the causal emotion sequence; performing target emotion strategy generation on a current user utterance based on the emotional arc vector to obtain a target emotion vector; inputting the dialogue history, the causal emotion sequence, the current user utterance and the target emotion vector into a prompt word template to obtain a final input sequence; and inputting the final input sequence into a fine-tuned large language model to obtain an emotional dialogue reply.

[0007] According to another aspect of the present application, a large model-based emotional dialogue generation system is provided, which comprises: a dialogue history obtaining module for obtaining a dialogue history of a target user; a causal emotion serialization module for performing causal emotion serialization on the dialogue history of the target user to obtain a causal emotion sequence; an emotional arc construction module for constructing an emotional arc vector based on the causal emotion sequence; a target emotion strategy generation module for performing target emotion strategy generation on a current user utterance based on the emotional arc vector to obtain a target emotion vector; a prompt word template integration module for inputting the dialogue history, the causal emotion sequence, the current user utterance and the target emotion vector into a prompt word template to obtain a final input sequence; and an emotional dialogue generation module for inputting the final input sequence into a fine-tuned large language model to obtain an emotional dialogue reply.

[0008] Compared with the prior art, the large model-based emotional dialogue generation method and system provided by the present application first performs causal emotion analysis and serialization processing on the complete dialogue history of the target user, and then abstracts and vectorizes the emotional dynamic evolution trajectory captured therein. Subsequently, based on the vectorized representation, the reply emotion strategy is planned in a forward-looking manner in combination with the current user utterance. Finally, the original dialogue history, the emotional evolution analysis result and the planned emotional strategy are structured and integrated to construct a unified context prompt, which is input into a fine-tuned large language model to obtain a final emotional dialogue reply. In this way, through deep modeling and forward-looking utilization of the whole process of user emotional evolution, the emotional context can be accurately grasped, and the intelligent level and interaction quality of emotional dialogue generation are significantly improved. BRIEF DESCRIPTION OF DRAWINGS

[0009] The above and other objects, features and advantages of the present application will become more apparent from the following detailed description of embodiments of the present application taken in conjunction with the accompanying drawings. The accompanying drawings are intended to provide a further understanding of embodiments of the present application and are incorporated in and constitute a part of the specification, illustrate embodiments of the present application and serve to explain the present application, but do not limit the present application. In the drawings, the same reference numerals generally refer to the same components or steps throughout the drawings.

[0010] Figure 1 Flowchart of the method for generating an emotional dialogue based on a large model according to an embodiment of the present application.

[0011] Figure 2 Data flow diagram of the method for generating an emotional dialogue based on a large model according to an embodiment of the present application.

[0012] Figure 3 Flowchart of sub-step S2 of the method for generating an emotional dialogue based on a large model according to an embodiment of the present application.

[0013] Figure 4 Flowchart of sub-step S23 of the method for generating an emotional dialogue based on a large model according to an embodiment of the present application.

[0014] Figure 5 Flowchart of sub-step S4 of the method for generating an emotional dialogue based on a large model according to an embodiment of the present application.

[0015] Figure 6 Flowchart of sub-step S5 of the method for generating an emotional dialogue based on a large model according to an embodiment of the present application.

[0016] Figure 7 Flowchart of sub-step S52 of the method for generating an emotional dialogue based on a large model according to an embodiment of the present application.

[0017] Figure 8 Block diagram of the system for generating an emotional dialogue based on a large model according to an embodiment of the present application. DETAILED DESCRIPTION

[0018] Embodiments of the present disclosure will be described in more detail by referring to the drawings. While certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be embodied in various forms and should not be construed as being limited to the embodiments set forth herein, but rather, the embodiments are provided so that the present disclosure can be more thoroughly and completely understood. It is understood that the drawings of the present disclosure and the embodiments are for exemplary purposes only and should not be construed as limiting the scope of protection of the present disclosure.

[0019] In view of the problems in the background art, the present application proposes a method for generating an emotional dialogue based on a large model. Figure 1 Flowchart of the method for generating an emotional dialogue based on a large model according to an embodiment of the present application. Figure 2 Data flow diagram of the method for generating an emotional dialogue based on a large model according to an embodiment of the present application. As Figure 1 and Figure 2As shown, the large model-based emotional dialogue generation method comprises the following steps: S1, obtaining the dialogue history of a target user; S2, performing causal emotion serialization on the dialogue history of the target user to obtain a causal emotion sequence; S3, constructing an emotional arc vector based on the causal emotion sequence; S4, performing target emotion strategy generation on the current user utterance based on the emotional arc vector to obtain a target emotion vector; S5, inputting the dialogue history, the causal emotion sequence, the current user utterance, and the target emotion vector into a prompt word template to obtain a final input sequence; and S6, inputting the final input sequence into a fine-tuned large language model to obtain an emotional dialogue reply.

[0020] In the large model-based emotional dialogue generation method described above, the step S1, obtaining the dialogue history of a target user. It can be understood that, since the generation of emotional dialogue needs to be based on the complete emotional evolution context of the user, relying only on the current user utterance cannot capture the emotional dynamic association, and lacks the acquisition and utilization of the dialogue history, which will lead to the generated reply being easy to deviate from the emotional context and lack of deep empathy. Based on this, the present application obtains the dialogue history of the target user to provide support for the original data for the subsequent steps, ensuring that the subsequent analysis can cover the complete process of the generation and evolution of emotions. In this way, it can avoid one-sidedness of emotional understanding caused by information missing, lay a data foundation for generating coherent replies that conform to the user's emotional trajectory, and at the same time make the subsequent causal attribution link traceable to the historical causes of the generation of emotions, thereby improving the depth and accuracy of emotional understanding.

[0021] In particular, in one possible embodiment, the implementation process of the step S1 is as follows: first, determine the unique identifier of the target user, which is the registered account ID of the user in the dialogue system or the session unique identifier, through which the subject of the dialogue history to be obtained can be accurately locked, preventing confusion with the dialogue data of other users. Second, call the historical data storage unit of the dialogue system, which uses a structured database to store user dialogue data, and the data content includes the timestamp of each round of dialogue, user utterance text, and system historical reply text. Based on the unique identifier of the target user, send a data query instruction to the storage unit, which explicitly includes the user identifier and the data extraction range, i.e. all historical interaction data before the current session is initiated. Then, perform time sequence arrangement and redundancy elimination on the original data returned by the storage unit, arrange the user utterance and system reply in the order of the timestamp of the dialogue occurrence, delete invalid information such as null characters and log identifiers generated in the data transmission process, and finally form a dialogue history list in rounds, containing complete interaction content, to ensure that the subsequent causal emotion serialization step can directly perform data processing based on the list.

[0022] In the aforementioned large-model-based emotional dialogue generation method, step S2 involves performing causal emotional serialization on the target user's dialogue history to obtain a causal emotional sequence. It should be understood that extracting emotions from a single round in isolation cannot capture the dynamic evolution of user emotions, and the generated responses are prone to lacking emotional coherence. Therefore, this application performs causal emotional serialization on the target user's dialogue history to bind the user's emotions in each round of dialogue to their causes, and organizes them into a structured causal emotional sequence according to the temporal order of the dialogue rounds. This provides complete emotional data containing temporal information and causal relationships for the subsequent construction of emotional arc vectors, ensuring that the generation of subsequent emotional strategies can trace the evolution of user emotions from history to the present, and avoiding a disconnect between response strategies and user emotional logic caused by fragmented emotional information.

[0023] In particular, in one specific embodiment, Figure 3 This is a flowchart of sub-step S2 of the large-model-based emotion dialogue generation method according to an embodiment of this application. Figure 3 As shown, step S2 includes: S21, extracting the first [unclear text - possibly a number] from the target user's dialogue history. The user's statement and the first The context history of each user's speech; S22, the first... A pre-trained sentiment classification model based on the user's verbal input is used to obtain the first... The sentiment vector; S23, for the first... The user's statement and the first Causal fragment extraction is performed on the contextual history of each user's speech to obtain the first... The first causal segment; S24, for the first... Round ID, Number The first causal fragment and the first The first emotion vector is structured and encapsulated to obtain the second emotion vector. A cause-and-effect emotion.

[0024] Specifically, step S21 involves extracting the first [unclear text - possibly a number] from the target user's dialogue history. The user's statement and the first The contextual history of each user's discourse. It should be understood that, since the target user's dialogue history is a continuous, holistic text, direct analysis of it can easily obscure the sentiment context of each turn. Therefore, this application further extracts the contextual history of the first user's discourse from the target user's dialogue history. This method uses individual user discourse and its contextual history to define a precise contextual scope for sentiment analysis and causal extraction of single-round user discourse, clarifying the preceding and following interaction information corresponding to that round of discourse, and ensuring the accuracy of subsequent analysis of the second round of discourse. The sentiment classification and causal extraction of each user's discourse are based on their actual interaction scenarios, providing a fundamental support for the accuracy of causal sentiment data in each round.

[0025] In particular, in one possible embodiment, the step S21 is implemented as follows: first, the dialogue history of the target user is sequentially numbered by round, the round to be processed is determined, the original speech text issued by the user in the round is extracted, and invalid information such as line breaks and special symbols in the text is removed. Second, the range of context history is defined: if the context history contains the system reply text of the first round and the user speech text of the second round; if the context history only retains the first user speech itself. Finally, the extracted first user speech text and the determined context history text are stored in association to form a data set containing the target speech and the background context, which is directly called by the subsequent emotion classification and causal fragment extraction steps.

[0026] Specifically, the step S22 inputs the first user speech into a pre-trained emotion classification model to obtain a first emotion vector. It should be understood that the emotion state of the first user speech exists in the form of natural language text, which cannot be directly recognized and processed by the subsequent vector calculation module. Therefore, the first user speech is further input into the pre-trained emotion classification model to convert the text form of emotional information into a vector with quantitative characteristics. The vector needs to retain the category attribute (such as joy, worry) and intensity information of the emotion, so that the subsequent construction of the emotional arc vector can be based on the quantitative emotional data to perform time sequence weight calculation, ensuring that the modeling of the emotional evolution trajectory has mathematical operability.

[0027] ​​​​​​​​​​​In particular, in one possible embodiment, the implementation process of step S22 is as follows: First, BERT-base is selected as the basic model architecture, and the pre-training dataset is a fusion dataset of SST-2 (Stanford Sentiment Treebank) and EmoBank (Sentiment Intensity Dataset). Each sample in the dataset contains text and corresponding multi-dimensional sentiment labels (joy, anger, sadness, worry, surprise, neutral) and sentiment intensity values. During pre-training, the dataset was first preprocessed, including word segmentation according to BERT model requirements, word embedding generation, and text length normalization to 128 tokens. Then, the AdamW optimizer was used with a learning rate of 2e-5 and a batch size of 32. The total loss was a weighted sum of cross-entropy loss (for sentiment categories) and mean squared error loss (for sentiment intensity). The model was trained on a GPU cluster for 10 epochs, with validation performed every 2 epochs to ensure that the model's sentiment classification accuracy on the validation set was no less than 92% and the sentiment intensity prediction error did not exceed 0.05. After pre-training, fine-tuning was performed based on the dialogue sentiment dataset relevant to this application scenario to adapt the model to sentiment analysis of dialogue text. Secondly, the... The user's utterance is preprocessed using the same method as in the pre-training stage to ensure the input format matches the model requirements. Then, the preprocessed text is input into the fine-tuned pre-trained sentiment classification model. The model extracts sentiment features through the encoding layer and outputs a 6-dimensional vector through a fully connected layer, corresponding to the intensity values ​​of the six sentiment categories. Finally, the output vector is validated to ensure that the values ​​of each dimension are within the [0,1] interval and there are no outliers. This vector is then considered the first... The sentiment vector is stored in the _th ... Causal and emotional data units for each round.

[0028] Specifically, step S23, for the first The user's statement and the first Causal fragment extraction is performed on the contextual history of each user's speech to obtain the first... The first causal fragment. This should be understandable, since only the first fragment is obtained. The sentiment vector of a user's utterance cannot clearly define the specific reason for the emotion, resulting in subsequent sentiment strategy generation only superficially matching the emotion, failing to touch the essential motivation of the user's emotion, and making it difficult to generate a response with deep empathy. Therefore, this application further addresses the issue of the [missing information - likely a specific aspect or feature]. Causal fragments are extracted from each user's discourse and its historical context to locate and extract key event text fragments that led to the user's emotions in that round of interaction. This establishes a direct link between user emotions and their causes, ensuring that subsequent causal emotion sequences simultaneously include emotional states and corresponding motivations. This provides a basis for generating response strategies that align with the root causes of user emotions, avoiding responses that merely formally match emotions without actual relevance.

[0029] In particular, in one specific embodiment, Figure 4 This is a flowchart of sub-step S23 of the large-model-based emotion dialogue generation method according to an embodiment of this application. Figure 4 As shown, step S23 includes: S231, placing the first The user's statement and the first S232, based on the context history of each user's speech, to obtain the background paragraph; A user's utterance generates a question, the question being "What key event led to the [missing information] in [missing information]?" What emotions are expressed in the user's utterance? S233, Input the background paragraph and question into a pre-trained exploratory question-answering model to obtain the aforementioned... One causal fragment.

[0030] More specifically, in step S231, the first... The user's statement and the first The context history of each user's utterance is pieced together to obtain the background paragraph. It should be understandable that, due to the... When a user's utterance exists in isolation, it lacks the preceding interactive context in which it arose. Relying solely on this utterance cannot fully present the scene details of the emotion's emergence. If directly used for causal segment extraction, it easily leads to extracted causal segments detached from the actual interactive context, failing to accurately reflect the true triggers for the emotion's emergence. Therefore, this application further... By splicing user utterances with their contextual history, the preceding interaction information corresponding to each utterance is integrated to form a background paragraph containing the complete scene, providing comprehensive contextual support for subsequent causal attribution. This ensures that the pre-trained extractive question-answering model can locate the cause of emotion based on the complete interaction scene, avoiding bias in causal segment location due to missing context. Simultaneously, it makes the causal extraction results more closely aligned with the actual logic of user emotion generation, laying the foundation for the accuracy of causal emotion sequences.

[0031] In particular, in one possible embodiment, step S231 is implemented as follows: First, clarify the... The scope of a user's discourse context history: if The context history contains the first The user's dialogue and the system's response text in each round; if The context history is empty, only the first one is retained. The user's discourse itself. Secondly, according to contextual history, the first... The text is concatenated sequentially from each user's utterance. During the concatenation process, invalid symbols (such as line breaks and special markers) are removed, and short phrase connectors (such as "then" and "to this") are used to optimize text coherence, ensuring that the concatenated text is semantically fluent and unbroken. Finally, the concatenated text undergoes integrity verification to confirm that no text segments are missing or semantic conflicts exist. The text that passes the verification is designated as the background paragraph and directly transmitted to the input unit of the extractive question-answering model for subsequent causal segment extraction.

[0032] More specifically, step S232, based on the first A user's utterance generates a question, the question being "What key event led to the [missing information] in [missing information]?" "What emotions are expressed in the user's utterance?" It is understandable that, because pre-trained extractive question-answering models require explicit question guidance to locate target information, without targeted questions, the model cannot determine whether the content to be extracted from the background paragraph is the cause of emotion, and is prone to extracting text fragments unrelated to emotion (such as ordinary event descriptions), leading to causal attribution deviating from the target. Therefore, this application further bases its approach on the... Each user's utterance generates a fixed-target question to clarify the extraction objective for the question-answering model, ensuring that the model focuses on the core content of the key events that generate emotions and avoiding ambiguity in the extraction direction. In this way, the model can accurately locate the text in the background paragraph that is directly related to the emotions, avoiding extraction bias caused by missing or ambiguous questions, significantly improving the correlation between causal fragments and emotions, and providing a guarantee for the accuracy of the emotional causal relationship in the subsequent causal emotional sequence.

[0033] Specifically, in one possible embodiment, step S232 is implemented as follows: First, the first... The core content of each user's statement is identified, and the carriers of emotional expression within the statement, such as event descriptions and emotional vocabulary, are determined to ensure that the generated questions accurately correspond to the statement. Secondly, a preset question template is invoked, which is fixed as "What key event led to the [action / event] in [the following context]?" What emotions are expressed in each user's words? (The question is incomplete and requires further context.) Each user's utterance is populated with its core content through a text replacement mechanism. For example, if a user's utterance is "The project has been postponed again," the corresponding part of the question is replaced with this content. Then, the generated questions undergo semantic validation to ensure they are grammatically correct, unambiguous, and clearly point to the emotional cause. Finally, the validated questions become the guiding questions used for causal extraction, serving as input data for the question-answering model along with the background paragraph.

[0034] More specifically, step S233 involves inputting the background paragraph and the question into a pre-trained exploratory question-answering model to obtain the first... The causal fragments are identified. It is understandable that, due to the need for precise location of causal fragments in the background paragraphs, manual extraction is inefficient and highly subjective, while ordinary text matching methods cannot deeply understand text semantics and are prone to missing or misjudging key information. Therefore, this application further inputs the background paragraphs and generated questions into a pre-trained extractive question-answering model. This leverages the model's text understanding and localization capabilities, honed through massive data training, to automatically extract the key text fragments that best explain the generation of emotion from the complete background. This achieves efficient and accurate extraction of causal fragments, ensuring that the extraction results not only conform to semantic logic but also directly correspond to the triggers of emotion, avoiding biases caused by human intervention and supporting the structured construction of subsequent causal emotion sequences.

[0035] Specifically, in one possible embodiment, step S233 is implemented as follows: First, a pre-trained extractive question-answering model is loaded. This model is based on the ELECTRA architecture and fine-tuned on SQuAD (Stanford Question Answering Dataset) and a sentiment causality-specific dataset, enabling it to locate causal-related segments from text. Second, the background paragraph and the generated question are encapsulated according to the format required by the model: the background paragraph serves as the context text, and the question serves as the query text, together forming the model input pair. Then, the input pair is fed into the model. The model locates and extracts continuous text segments by calculating the probability that each word in the background paragraph is the starting and ending point of the answer. These segments are the preliminary causal candidates. Finally, the semantic integrity of the candidate segments is checked to confirm that they can independently explain the cause of the sentiment. The segments that pass the check are the first causal candidates. The causal fragment is stored in the _th ... In the causal emotion data unit of each round.

[0036] Specifically, step S24, for the first Round ID, Number The first causal fragment and the first The first emotion vector is structured and encapsulated to obtain the second emotion vector. The first cause-and-effect emotion. This should be understandable, due to the first... The three types of data—round ID, causal fragment, and sentiment vector—are scattered across each round, making it prone to element misalignment during subsequent chronological arrangement and data retrieval, thus failing to form a unified single-round causal sentiment unit. Therefore, this application further addresses the issue of... The round ID, causal fragments, and sentiment vectors are structured and encapsulated to integrate the three types of data into a single data unit according to a preset format. This clarifies the correspondence between each data element and ensures that the causal sentiment information of each round of dialogue exists in a unified unit form. When constructing the causal sentiment sequence later, it can be directly arranged according to the unit time sequence to avoid data association errors. At the same time, it provides structured data input for the subsequent prompt word template integration step, improving the efficiency of the overall data processing flow.

[0037] Specifically, in one possible embodiment, step S24 is implemented as follows: First, a standardized data structure in key-value pair form is adopted, and fields corresponding to round identifiers, sentiment vectors, and causal fragments are set, clarifying the data type and required attributes of each field to ensure data integrity. Second, the... Round ID, Number The first emotional vector and the second Each causal fragment should be filled into its corresponding field, ensuring consistency in data type and format. Finally, the encapsulated data unit undergoes integrity and validity checks to verify for missing fields or data anomalies. The data unit that passes the checks is the [number]th [data unit]. Each causal emotion is stored in the corresponding index position of the causal emotion sequence.

[0038] In the aforementioned large-model-based emotional dialogue generation method, step S3 involves constructing an emotional arc vector based on a causal emotional sequence. It should be understood that although the causal emotional sequence links the emotional state of each round with its corresponding cause, the emotional information of each round remains dispersed, failing to reflect the different weights of the influence of emotions from different rounds on the current decision, and failing to transform the temporal evolution characteristics of emotions into a unified quantitative representation. This makes it difficult for subsequent target emotional strategy generation to accurately capture the dynamic development trend of user emotions, easily leading to a disconnect between the strategy and the logic of emotional evolution. Therefore, in a specific example of this application, step S3 includes: constructing an emotional arc vector based on the causal emotional sequence using the following formula: ;in, For the first Weights for each time step The attenuation factor is between 0 and 1. For rounds, For the first A sentiment vector, This application further constructs an emotional arc vector based on a causal emotional sequence. This vector integrates the temporal relationships and influence weights of emotions from each round, forming a unified quantitative vector that comprehensively reflects the user's emotional evolution trajectory. This allows the subsequent target emotional strategy generation module to directly grasp the overall emotional development based on this vector, avoiding short-sighted strategies caused by relying on emotional information from a single round. It ensures that the generated emotional strategy conforms to the long-term evolution logic of user emotions, while also providing support for the mathematical modeling of dynamic emotional changes, improving the accuracy of responses in terms of emotional coherence and adaptability.

[0039] In the aforementioned large-model-based emotional dialogue generation method, step S4 involves generating a target emotional strategy based on the emotional arc vector of the current user's utterance to obtain a target emotional vector. It should be understood that since the emotional arc vector is not associated with the immediate emotion of the current utterance, the strategy is prone to deviating from the current needs. Therefore, this application further generates a target emotional strategy based on the emotional arc vector and the current user's utterance. This integrates the historical development logic of the user's emotions with the current immediate emotional information, determines the appropriate emotional direction for the response to the current interaction scenario, and transforms this strategy into a quantified target emotional vector. This ensures that the generated emotional strategy both continues the continuity of the user's emotional evolution, avoiding the fragmentation of historical emotional context, and accurately matches the emotional needs conveyed by the current utterance, preventing the response from becoming disconnected from the user's current state.

[0040] In particular, in one specific embodiment, Figure 5 This is a flowchart of sub-step S4 of the large-model-based emotion dialogue generation method according to an embodiment of this application. Figure 5 As shown, step S4 includes: S41, inputting the current user utterance into a pre-trained sentiment classification model to obtain the current sentiment vector; S42, performing feature concatenation on the current sentiment vector and the sentiment arc vector to obtain the sentiment temporal progressive vector; S43, inputting the sentiment temporal progressive vector into the optimal response sentiment model based on a feedforward neural network to obtain the target sentiment vector.

[0041] Specifically, in step S41, the current user utterance is input into a pre-trained sentiment classification model to obtain the current sentiment vector. It should be understood that since the current user utterance exists in the form of natural language text, the emotional state it carries cannot be directly fused with the quantified sentiment arc vector. If it is not converted into a unified quantification form, subsequent sentiment strategy generation will not be able to simultaneously consider historical sentiment trajectories and current sentiment demands, easily leading to strategies deviating from the user's current true emotional needs. Therefore, this application further inputs the current user utterance into a pre-trained sentiment classification model to convert the current sentiment information in text form into a quantified vector with clear category and intensity attributes, ensuring that the dimension of this vector is consistent with the sentiment arc vector. This provides a unified data foundation for subsequent sentiment feature fusion, enabling the current sentiment state to be effectively combined with historical sentiment evolution trajectories, avoiding information fragmentation caused by inconsistent data formats, and accurately capturing the emotional details in the current utterance, providing a quantitative basis for generating sentiment strategies that meet immediate needs.

[0042] In particular, in one possible embodiment, the step S41 is implemented as follows: first, a pre-trained emotion classification model consistent with the processing of the emotion vectors in the target user's conversation history is loaded, which has been fine-tuned based on an emotion conversation domain-specific dataset and can accurately identify the emotional features in the conversation text. Second, the text is pre-processed according to the requirements of the model, and the text length is normalized to the fixed length adapted by the model. Then, the pre-processed utterance is input into the model, the model extracts the emotion features through the encoding layer, and the quantized emotion vector is output through the fully connected layer. Finally, the output vector is verified for effectiveness, and the current emotion vector is determined after confirming that the values in each dimension are in a reasonable interval and there is no abnormality, which is used for subsequent feature splicing.

[0043] In particular, in one possible embodiment, the step S42 is implemented as follows: first, the current emotion vector and the emotion arc vector are checked for dimension consistency to ensure that their feature dimensions are the same, avoiding dimension mismatch during splicing. Second, the feature splicing is performed according to the time sequence logic of the historical emotion and the current emotion, the emotion arc vector is taken as the first half of the spliced vector, and the current emotion vector is taken as the second half, and all feature information of the two vectors is completely preserved without compression or deletion. Then, the structure integrity of the spliced vector is checked to confirm that the total dimension is the sum of the dimensions of the two vectors, and there is no feature loss or redundancy. Finally, the spliced vector that passes the verification is defined as the emotion time sequence progressive vector, which is directly used as the input data of the best response emotion model.

[0044] In particular, in one possible embodiment, the step S42 is implemented as follows: first, the current emotion vector and the emotion arc vector are checked for dimension consistency to ensure that their feature dimensions are the same, avoiding dimension mismatch during splicing. Second, the feature splicing is performed according to the time sequence logic of the historical emotion and the current emotion, the emotion arc vector is taken as the first half of the spliced vector, and the current emotion vector is taken as the second half, and all feature information of the two vectors is completely preserved without compression or deletion. Then, the structure integrity of the spliced vector is checked to confirm that the total dimension is the sum of the dimensions of the two vectors, and there is no feature loss or redundancy. Finally, the spliced vector that passes the verification is defined as the emotion time sequence progressive vector, which is directly used as the input data of the best response emotion model.

[0045] Specifically, the step S43 inputs the emotion time sequence progressive vector into a best response emotion model based on a feedforward neural network to obtain the target emotion vector. It can be understood that, since the emotion time sequence progressive vector is not translated into a specific reply strategy, the large model cannot clearly guide the emotion. Therefore, the emotion time sequence progressive vector is further input into the best response emotion model based on the feedforward neural network, so as to map the comprehensive emotion information into a clear reply emotion strategy, and translate it into a standardized quantitative target emotion vector, to provide a clear emotion guidance basis for subsequent prompt word template integration, and ensure that the reply generated by the large model is highly matched with the user demand in terms of emotion tone and empathy direction. Meanwhile, the efficient feature mapping capability of the feedforward neural network can guarantee the real-time performance of the strategy generation, and avoid delay affecting the interactive experience.

[0046] In particular, in one possible embodiment, the implementation process of the step S43 is as follows: first, a best response emotion model based on a feedforward neural network is loaded, which includes an input layer, a hidden layer and an output layer, the hidden layer adopts a ReLU activation function, the output layer adopts a Sigmoid activation function, and the model has been fine-tuned through an emotion dialogue scene special data set (containing emotion time sequence progressive vector and optimal reply emotion strategy sample pair). Second, the emotion time sequence progressive vector is input into the input layer of the model, and after the strategy features are extracted through the non-linear transformation of the hidden layer, the features are transmitted to the output layer. Then, the output layer outputs a quantitative vector representing the reply emotion strategy, which has the same dimension as the current emotion vector. Finally, the output vector is subjected to strategy adaptability verification to confirm whether it meets the user emotion demand and the interactive scene, and after the verification is passed, the target emotion vector is determined and transmitted to the prompt word template integration module.

[0047] In particular, in another possible preferred embodiment, the step S4, based on the emotion arc vector, generates a target emotion strategy for the current user utterance to obtain a target emotion vector, includes: inputting the current user utterance into a pre-trained emotion classification model to obtain a current emotion vector, and extracting a current cause segment reflecting the cause of the current emotion, and then performing semantic coding on the current cause segment to obtain a cause semantic vector; using the cause semantic vector as a projection basis of causal correlation, respectively processing the current emotion vector and the emotion arc vector to obtain a projected current emotion vector and a projected emotion arc vector; based on the projected current emotion vector and the projected emotion arc vector, performing causal saliency screening on the cause semantic vector to obtain a causally screened cause semantic vector; after splicing the projected current emotion vector, the projected emotion arc vector and the causally screened cause semantic vector, further performing strategy projection, and then inputting into a best response emotion model based on a feedforward neural network to obtain the target emotion vector.

[0048] Specifically, first, the current user utterance is input into the pre-trained sentiment classification model to obtain a current sentiment vector. Considering that the sentiment arc vector may have a perceptual cause relative to the current sentiment vector, it is desirable to explicitly introduce the cause information of the current sentiment, extract a current cause segment reflecting the cause of the current sentiment, and further introduce the perceptual cause information of the current sentiment in addition to the current sentiment information, while dynamically determining to what extent to rely on the historical sentiment trend and to what extent to focus on the current instant sentiment, so as to establish a quantitative association between the current sentiment and the corresponding cause, and provide a causal basis for the sentiment strategy. In this way, the target sentiment vector can effectively integrate the rich causal information of the current sentiment vector and the sentiment arc vector, and can be causally coupled with the causal sentiment sequence.

[0049] Here, first, information heterogeneity needs to be addressed, that is, the sentiment arc vector represents a smooth, long-time-span trend, and the current sentiment vector represents an instantaneous, possibly sharp state. If the heterogeneity information is flattened into a one-dimensional vector by splicing, the feedforward neural network needs to learn the complex relationship between them from scratch. At the same time, if the causal sentiment sequence is not used in generating the target sentiment vector, key causal information will be missing, that is, the development of the sentiment strategy is highly dependent on the cause. For example, both are sadness, the sadness caused by failing the exam may have the best strategy of encouragement and analysis; while the sadness caused by the death of a loved one has the best strategy of deep empathy and accompaniment.

[0050] Specifically, for the current sentiment vector and the sentiment arc vector, for example, represented as and The current cause segment is semantically encoded to obtain a cause semantic vector, for example, represented as , and all have the same length, then it is desirable to use the cause semantic vector as the projection basis of the causal association to process the current sentiment vector and the sentiment arc vector respectively to obtain a projected current sentiment vector and a projected sentiment arc vector, so as to map the two types of heterogeneous vectors to the same causal semantic space, establish the internal association between them based on the sentiment cause, that is: ; wherein, represents matrix multiplication, represents the transpose operation, represents the current sentiment vector, represents the sentiment arc vector, represents the cause semantic vector, represents the projected current sentiment vector, represents the projected current sentiment vector, and represents the projected emotional arc vector, both in column vector form, which correlates the vectors from different sources in the same causal semantic space, and the current sentiment vector and the emotional arc vector are also projected into the common hidden dimension sub-causal space based on the causal correlation of the cause semantics. Moreover, since the correlation interaction provides a semantic causal coupling induction benchmark, it can improve the learning efficiency of the complex interaction relationship between history and current, state and cause.

[0051] At the same time, since the cause semantic vector itself has more semantic information density than the current sentiment vector and the emotional arc vector, the cause semantic vector can be filtered for causal significance based on the projected current sentiment vector and the projected emotional arc vector to obtain a causal filtered cause semantic vector, that is: ; wherein, represents vector addition, represents element-wise multiplication, represents the causal filtered cause semantic vector, and the hyperparameter and determine the filtering weights of the current information and the historical trend, and , for example, This can reflect the causal dynamics of empathetic response, for example, sometimes it may be necessary to focus on the long-term progress of the other party (historical trend causal significance), and sometimes it is necessary to immediately respond to the pain in front of us (current information causal significance). In this way, causal significance filtering forms semantic attention transfer based on causal correlation.

[0052] Finally, the projected current sentiment vector, the projected emotional arc vector, and the causal filtered cause semantic vector are spliced and further projected into a strategy, that is , wherein, represents a cascade function, represents matrix multiplication, as a learnable weight matrix for mapping the reflected causal correlation back into the target situation strategy space, and then inputting the best response sentiment model based on the feedforward neural network to obtain the target sentiment vector.

[0053] In this way, the target sentiment vector, due to the introduction of causal information, the generated emotional strategy will be more in line with the specific situation, achieving precision and appropriateness, and since the target sentiment vector combines the progress of the dialogue, it achieves the dynamics and flexibility of the response.

[0054] In the aforementioned large-scale model-based emotional dialogue generation method, step S5 involves inputting the dialogue history, causal emotional sequence, current user utterance, and target emotional vector into a prompt word template to obtain the final input sequence. It should be understood that since the dialogue history, causal emotional sequence, current user utterance, and target emotional vector are dispersed information modules, each carrying the original interaction record, emotional causal timeline, immediate appeal, and response emotional guidance, directly inputting them into a large-scale model can easily lead to structural chaos and illogical responses. Therefore, this application further inputs the dialogue history, causal emotional sequence, current user utterance, and target emotional vector into a prompt word template to structurally integrate the dispersed information into a unified input sequence, clarifying the functional positioning and relationships of each piece of information. This provides a clear and complete context and emotional strategy guidance for the fine-tuned large language model, avoiding comprehension biases caused by information fragmentation, and ensuring that the generated emotional dialogue response both conforms to the historical interaction context and strictly follows the target emotional strategy.

[0055] In particular, in one specific embodiment, Figure 6 This is a flowchart of sub-step S5 of the large-model-based emotion dialogue generation method according to an embodiment of this application. Figure 6 As shown, step S5 includes: S51, generating a textual sequence of the target sentiment vector to obtain a serialized control signal; S52, generating a narrative text of the causal sentiment sequence to obtain a serialized causal history; S53, concatenating the serialized control signal, serialized causal history, dialogue history, and current user utterance into components in the order of control instructions, background story, dialogue context, latest question, and generated prompts to obtain the final input sequence.

[0056] Specifically, step S51 involves generating a textual sequence from the target sentiment vector to obtain a serialized control signal. It should be understood that because the target sentiment vector is in quantized form, large models cannot parse its semantics and are prone to deviating from the strategy. Therefore, this application further generates a textual sequence from the target sentiment vector to transform the quantized sentiment strategy into natural language text control instructions that large models can understand, clearly defining the emotional tone, empathy direction, and intensity requirements that the response must follow. This ensures that the large model accurately grasps the core of the sentiment strategy when generating responses, avoiding sentiment mismatch in responses caused by misunderstandings of the quantized vector, and providing a semantically clear control module for subsequent integration of prompt word templates, ensuring the consistency of sentiment guidance throughout the generation process.

[0057] In particular, in one possible embodiment, the implementation process of step S51 is as follows: first, the emotional meanings corresponding to each dimension of the target emotional vector are parsed, and the preset emotional strategy mapping rule is combined to determine the core emotional response requirements represented by the vector, such as "empathy pacification as the core tone, supplemented by mild positive guidance, echoing the relief trend of the user's historical worry emotion". Second, the parsed emotional strategy is converted into a structured natural language text sequence. The text needs to use clear imperative expressions to avoid ambiguous or ambiguous content. Then, the generated text sequence is subjected to semantic verification to confirm that it accurately reflects the strategy orientation of the target emotional vector without semantic deviation or information omission. Finally, the text sequence that passes the verification is defined as a serialized control signal, which is directly used to fill in the control instruction module in the subsequent prompt word template, providing clear emotional generation guidance for the model.

[0058] Specifically, step S52, the causal emotional sequence is subjected to narrative text generation to obtain a serialized causal history. It should be understood that since the causal emotional sequence is a dispersed structured unit, it is difficult for the large model to analyze the emotional context and causal relationship, and the reply is easy to fragment the history. Therefore, the present application further subjects the causal emotional sequence to narrative text generation, so as to integrate the dispersed multi-round causal emotional information into coherent natural language narrative text, clearly presenting the cause of each round of emotion, emotional state and time sequence evolution relationship. In this way, the large model can intuitively understand the origin and development of user emotional changes, ensuring that the generated reply not only matches the current emotion, but also echoes the historical emotional causes, avoiding content that contradicts the past emotional logic, while providing complete emotional background support for the model, improving the depth of empathy and the coherence of the reply.

[0059] In particular, in one specific embodiment, Figure 7 The flowchart of sub-step S52 of the large model-based emotional dialogue generation method according to the embodiment of the present application. As shown in Figure 7 S52, it includes: S521, extracting a first causal emotion from the causal emotional sequence; S522, extracting a dominant emotional label corresponding to the largest component value from the first causal emotion; S523, injecting the dominant emotional label, the round ID and the first cause segment into a preset sentence template to obtain a first round causal emotional description sentence.

[0060] More specifically, the step S521 extracts the first causal emotion from the causal emotion sequence. It should be understood that since the causal emotion sequence needs to clearly indicate the starting node of the emotion evolution, otherwise the narrative cannot fully present the context. Therefore, the present application further extracts the first causal emotion from the causal emotion sequence to lock the initial round data of the emotion evolution, obtain the emotion state, cause and round identifier of this round, and provide core information for the starting part of the narrative text. In this way, it can ensure that the narrative text starts from the starting point of the emotion evolution, so that the large model can clearly grasp the initial background of the emotion, avoid the split of the emotion history context caused by the lack of initial round information, and lay a foundation for the subsequent complete presentation of the emotion time evolution logic.

[0061] In particular, in one possible embodiment, the implementation process of the step S521 is as follows: first, confirm the round ordering rule of the causal emotion sequence, clearly store the sequence in the time sequence order from small to large according to the round ID, and the first data unit corresponds to the initial interaction round. Secondly, call the sequence data reading interface, locate the first causal emotion data unit with index 0 in the sequence, and extract the round ID, cause segment and emotion vector encapsulated in the unit. Then, perform integrity check on the extracted first causal emotion data, confirm that the round ID is the smallest positive integer, the cause segment is non-empty text, the emotion vector meets the preset dimension requirement, and there is no data loss or format abnormality. Finally, temporarily store the first causal emotion data that passes the verification in the special data cache unit, and directly use it for subsequent dominant emotion label extraction and first round description sentence generation, to ensure that the initial round information can be accurately connected to the subsequent processing link.

[0062] More specifically, the step S522 extracts the dominant emotion label corresponding to the component with the maximum value from the first causal emotion. It should be understood that since the emotion vector of the first causal emotion is multi-dimensional quantitative data, the emotion direction is ambiguous, and the large model is difficult to identify the starting keynote. Therefore, the present application further extracts the dominant emotion label corresponding to the component with the maximum value from the emotion vector of the first causal emotion, to clearly indicate the core emotion state of the user in the initial round, and convert the quantitative emotion intensity into a semantic emotion category identifier. In this way, it can ensure that the emotion description of the initial round focuses on the core emotion, so that the large model can intuitively grasp the starting keynote of the emotion evolution, avoid the initial emotion cognitive bias caused by the mixed multi-dimensional information of the emotion vector, and provide a clear starting point for the clear presentation of the emotion evolution logic in the subsequent narrative text.

[0063] In particular, in a possible embodiment, the implementation process of step S522 is as follows: first, the meaning of each dimension of the emotion vector in the first causal emotion is analyzed, and according to the preset emotion dimension mapping table, the emotion category corresponding to each dimension is determined, for example, dimension 0 corresponds to worry, dimension 1 corresponds to joy, etc. Second, all component values of the emotion vector are traversed, the component with the maximum value is selected, and the dimension index corresponding to the component is determined. Then, the emotion dimension mapping table is queried according to the dimension index to obtain the emotion category name corresponding to the dimension, for example, if the component with the maximum value corresponds to dimension 0, the dominant emotion label is worry. Finally, the extracted dominant emotion label is verified for effectiveness, and it is confirmed that there is no label mismatch in the mapping relationship between the dimension of the maximum component of the emotion vector. The label that passes the verification is temporarily stored and used for subsequent first round causal emotion description sentence generation.

[0064] More specifically, in step S523, the dominant emotion label, the round ID and the first cause segment are injected into the preset sentence template to obtain the first round causal emotion description sentence. It can be understood that since the dominant emotion label, the round ID and the first cause segment are three types of dispersed information, the association between emotion and cause is not clear. Therefore, the three types of information are further injected into the preset sentence template to integrate the dispersed information into a natural language sentence with unified structure and coherent semantics, clearly present the association between the round identification, the core emotion and the cause of the emotion in the initial round, and ensure that the corresponding logic between emotion and cause is clear in the starting part of the narrative text, lay a foundation for coherent narration of subsequent multiple rounds of emotion evolution, and avoid confusion of the cause-and-effect relationship due to dispersed information.

[0065] In particular, in a possible embodiment, the implementation process of step S523 is as follows: first, a preset sentence template is loaded, the template format is “in the [round ID]th round of dialogue, the user expresses [dominant emotion label] core emotion due to [cause segment content]”, and the template reserves filling positions corresponding to the three types of information. Second, the temporarily stored round ID, the first cause segment and the dominant emotion label are filled into the corresponding positions of the template, for example, if the round ID = 1, the cause segment is “mentioning that the project delivery time is approaching but the progress is lagging behind”, and the dominant emotion label is worry, the filled content is “in the 1st round of dialogue, the user expresses worry core emotion due to mentioning that the project delivery time is approaching but the progress is lagging behind”. Then, the sentence after filling is adjusted for smoothness, redundant characters are deleted, and the expression logic is optimized to ensure that the sentence is semantically smooth and free of syntax errors. Finally, the adjusted sentence is verified for semantics to confirm that it accurately reflects the association relationship and has no information omission or semantic deviation. The sentence is the first round causal emotion description sentence, which is used for constructing the starting part of the narrative text. By traversing each causal emotion unit in the sequence, a piece of text describing the emotion and the cause of each round of dialogue is generated, and finally a coherent serialized causal history is spliced.

[0066] Specifically, the step S53 assembles the serialized control signal, the serialized causal history, the dialogue history and the current user utterance in the order of the control instruction, the background story, the dialogue context, the latest question and the generated prompt to obtain the final input sequence. It can be understood that, since the serialized control signal, the serialized causal history, the dialogue history and the current user utterance are independent information components, respectively corresponding to the emotional strategy guidance, the emotional history background, the complete interaction record and the immediate appeal, if not integrated in a fixed logical order, it is easy to cause the information of the large model to be confused and the reply to deviate. Therefore, the present application further assembles the above components in the fixed order of the control instruction, the background story, the dialogue context, the latest question and the generated prompt to construct a final input sequence with unified structure and clear information hierarchy, and clearly defines the function of each component in the model reply generation process, thereby significantly improving the accuracy, emotional adaptability and context coherence of the reply, reducing the redundant calculation of the model on information association, and improving the generation efficiency.

[0067] In particular, in one possible embodiment, the implementation process of the step S53 is as follows: first, the components are assembled in the preset module order in sequence, the serialized control signal is filled in as the control instruction module first, then the serialized causal history is connected as the background story module, then the complete dialogue history arranged in the interaction time sequence is attached as the dialogue context module, then the current user utterance is entered as the latest question module, and finally the generated prompt statement such as “generate a dialogue reply that meets the requirements of the emotional strategy, fits the historical context and is natural in language based on all the above information” is supplemented. Then, the spliced text is handled for connection, and short transition sentences are added between the modules to avoid content breakage and ensure overall fluency. Finally, the structural integrity and information accuracy of the overall sequence are verified to confirm that the function positioning of each module is clear and there is no content repetition or omission, and the text is the final input sequence which is directly used to input the fine-tuned large language model to generate an emotional dialogue reply.

[0068] In the above-mentioned large model-based emotional dialogue generation method, the step S6 inputs the final input sequence into the fine-tuned large language model to obtain an emotional dialogue reply. Specifically, the present application inputs the final input sequence into the fine-tuned large language model to convert the structured input information into a natural language reply that meets the emotional strategy and fits the context based on the adaptability of the model to the emotional dialogue scene, ensures that the generated reply not only continues the user emotional evolution logic but also accurately matches the target emotional strategy, avoids emotional mismatch or context fragmentation, significantly improves the interaction quality and user empathy experience of emotional dialogue, and meets the core needs of emotional replies in psychological counseling, emotional companionship and other scenarios.

[0069] In particular, in one possible embodiment, the implementation of step S6 is as follows: first, load the fine-tuned large language model, which is based on a large language model based on the Transformer architecture, and complete fine-tuning on a sentiment dialogue dedicated dataset (containing multi-round sentiment interaction samples, and the corresponding relationship between sentiment strategies and replies). During the training process, the model's understanding of sentiment strategy instructions and control of contextual sentiment continuity are optimized. Second, perform model input format adaptation processing on the final input sequence, complete preprocessing according to the text encoding specification required by the model, and ensure that the sequence can be effectively parsed by the model without format compatibility problems. Then, input the adapted final input sequence into the model, and the model extracts the context information and sentiment strategy features in the sequence through the encoding layer, and outputs natural language reply text according to the sentiment dialogue generation logic through the decoding layer. Finally, perform sentiment adaptation and contextual coherence verification on the generated reply to confirm that the reply conforms to the target sentiment strategy, has no historical sentiment logic conflict, and the language is natural and fluent, and the verification is passed. The final sentiment dialogue reply can be directly fed back to the target user.

[0070] In summary, the large model-based sentiment dialogue generation method based on the embodiments of the present application is illustrated, which first performs causal sentiment analysis and sequential processing on the complete dialogue history of the target user, and then abstracts and vectorizes the captured sentiment dynamic evolution track. Subsequently, based on the vectorized representation, the reply sentiment strategy is planned in a forward-looking manner combined with the current user utterance. Finally, the original dialogue history, sentiment evolution analysis result and planned sentiment strategy are structured and integrated to construct a unified context prompt, which is sent to the fine-tuned large language model to obtain the final sentiment dialogue reply. In this way, through deep modeling and forward-looking use of the whole process of user sentiment evolution, the sentiment context can be accurately grasped, and the intelligent level and interaction quality of sentiment dialogue generation are significantly improved.

[0071] Figure 8 A block diagram of the large model-based sentiment dialogue generation system according to the embodiments of the present application. As shown in FIG. 1, the system comprises a dialogue history acquisition module 101, a dialogue history processing module 102, a dialogue history analysis module 103, a dialogue history planning module 104, a dialogue history generation module 105, and a dialogue history output module 106. Figure 8As shown, the large model-based emotional dialogue generation system 100 according to the embodiment of the present application comprises: a dialogue history acquisition module 110 configured to acquire a dialogue history of a target user; a causal emotion serialization module 120 configured to perform causal emotion serialization on the dialogue history of the target user to obtain a causal emotion sequence; an emotional arc construction module 130 configured to construct an emotional arc vector based on the causal emotion sequence; a target emotion strategy generation module 140 configured to perform target emotion strategy generation on a current user utterance based on the emotional arc vector to obtain a target emotion vector; a prompt word template integration module 150 configured to input the dialogue history, the causal emotion sequence, the current user utterance and the target emotion vector into a prompt word template to obtain a final input sequence; and an emotional dialogue generation module 160 configured to input the final input sequence into a fine-tuned large language model to obtain an emotional dialogue reply.

[0072] As described above, the large model-based emotional dialogue generation system 100 according to the embodiment of the present application can be implemented in various wireless terminals, such as a server with a large model-based emotional dialogue generation algorithm, etc. In one possible implementation, the large model-based emotional dialogue generation system 100 according to the embodiment of the present application can be integrated into a wireless terminal as a software module and / or a hardware module. For example, the large model-based emotional dialogue generation system 100 can be a software module in the operating system of the wireless terminal, or can be an application program developed for the wireless terminal; of course, the large model-based emotional dialogue generation system 100 can also be one of the many hardware modules of the wireless terminal.

[0073] Alternatively, in another example, the large model-based emotional dialogue generation system 100 and the wireless terminal can also be separate devices, and the large model-based emotional dialogue generation system 100 can be connected to the wireless terminal through a wired and / or wireless network, and transmit interaction information in an agreed data format.

[0074] Here, those skilled in the art can understand that the specific operations of each step in the above large model-based emotional dialogue generation system have been described in detail above with reference to the description of the large model-based emotional dialogue generation method of Figures 1 to 7 the above, and therefore, the repeated description thereof will be omitted.

Claims

1. A large model-based emotional dialogue generation method, characterized in that, The method comprises the following steps: obtaining a dialogue history of a target user; causal emotion serialization of the dialogue history of the target user to obtain a causal emotion sequence, wherein the dialogue history of the target user is subjected to the causal emotion serialization processing, so as to bind the user emotion in each round of dialogue with the cause thereof and arrange the user emotion in each round of dialogue into a structured causal emotion sequence in the time sequence of the dialogue rounds; Based on the causal sentiment sequence, an emotional arc vector is constructed, including: constructing the emotional arc vector based on the causal sentiment sequence using the following formula: ;in, For the first Weights for each time step The attenuation factor is between 0 and 1. For rounds, For the first A sentiment vector, For emotional arc vectors; target emotion strategy generation of a current user utterance based on an emotion arc vector to obtain a target emotion vector; inputting the dialogue history, the causal emotion sequence, the current user utterance and the target emotion vector into a prompt word template to obtain a final input sequence; inputting the final input sequence into a fine-tuned large language model to obtain an emotional dialogue reply.

2. The large model-based emotional dialogue generation method according to claim 1, characterized in that, The causal emotion serialization of the dialogue history of the target user to obtain the causal emotion sequence comprises: extracting a first user utterance and a context history of the first user utterance from a dialog history of a target user user​ The first A pre-trained sentiment classification model based on the user's verbal input is used to obtain the first... One emotional vector; For the first The user's statement and the first Causal fragment extraction is performed on the contextual history of each user's speech to obtain the first... A fragment of cause; Structural packaging is performed on the first round ID, the first cause segment, and the first emotion vector to obtain a first cause emotion. ​​​​ 3. The large model-based emotional dialogue generation method according to claim 2, characterized in that, For the first The user's statement and the first Causal fragment extraction is performed on the contextual history of each user's speech to obtain the first... The causal fragments include: concatenating a first user utterance and a context history of the first user utterance to obtain a background passage; concatenating a first user utterance and a context history of the first user utterance to obtain a background passage;​ Based on the first user utterance, generate a question, the question being "What key event led to the sentiment expressed in the first user utterance?" inputting the background paragraph and the question into a pre-trained extractive question answering model to obtain the first cause segment.

4. The large model-based emotional dialogue generation method according to claim 1, characterized in that, The target emotion strategy generation of the current user utterance based on the emotion arc vector to obtain the target emotion vector comprises: inputting the current user utterance into a pre-trained emotion classification model to obtain a current emotion vector; feature splicing of the current emotion vector and the emotion arc vector to obtain an emotion time sequence progressive vector; inputting the emotion time sequence progressive vector into a best response emotion model based on a feedforward neural network to obtain the target emotion vector. 5.The large model-based emotional dialogue generation method according to claim 1, characterized in that, The inputting of the dialogue history, the causal emotion sequence, the current user utterance and the target emotion vector into the prompt word template to obtain the final input sequence comprises: textual sequence generation of the target emotion vector to obtain a sequence control signal; narrative text generation of the causal emotion sequence to obtain a sequence causal history; component splicing of the sequence control signal, the sequence causal history, the dialogue history and the current user utterance in the order of a control instruction, a background story, a dialogue context, a latest question and a generation prompt to obtain the final input sequence.

6. The large model-based emotional dialogue generation method according to claim 5, characterized in that, The narrative text generation of the causal emotion sequence to obtain the sequence causal history comprises: extracting a first causal emotion from the causal emotion sequence; extracting a dominant emotion label corresponding to a numerical maximum component from the first causal emotion; injecting the dominant emotion label, a round ID and a first cause segment into a preset sentence template to obtain a first round causal emotion description sentence.

7. A large model-based emotional dialogue generation system, characterized by, The method comprises the following steps: a dialogue history obtaining module is configured to obtain a dialogue history of a target user; a causal emotion serialization module is configured to perform causal emotion serialization on the dialogue history of the target user to obtain a causal emotion sequence, wherein the dialogue history of the target user is subjected to the causal emotion serialization processing, so as to bind the user emotion in each round of dialogue with the cause thereof and arrange the user emotion in each round of dialogue into a structured causal emotion sequence in the time sequence of the dialogue rounds; An affective arc construction module for constructing an affective arc vector based on a causal affective sequence, comprising: constructing an affective arc vector based on the causal affective sequence with a formula as follows: ; wherein, is a weight of a t h time step, is a decay factor between 0 and 1, is a round, is a t h affective vector, is an affective arc vector. a target emotion strategy generation module is configured to perform target emotion strategy generation of a current user utterance based on an emotion arc vector to obtain a target emotion vector; a prompt word template integration module is configured to input the dialogue history, the causal emotion sequence, the current user utterance and the target emotion vector into a prompt word template to obtain a final input sequence; an emotional dialogue generation module is configured to input the final input sequence into a fine-tuned large language model to obtain an emotional dialogue reply.

Citation Information

Patent Citations

  • Conversation result generation method, display device and server

    CN117807179A

  • KR20200111595A