An empathetic dialogue generation method, apparatus, device and medium

CN122964240APending Publication Date: 2026-10-23NORTHWESTERN POLYTECHNICAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611459327.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-20
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0004]然而该方法采用硬分类方式将用户情绪归入单一离散类别,难以捕捉情绪的动态过渡,导致后续推理所依据的情绪与实际状态存在偏差,最终生成的共情回复虽情绪类别匹配但情感支持力度不足

Benefits of technology

本发明以多组情绪原型向量加权的连续表征形式还原情绪本身的多成分叠加特性,不再强制将情绪划归某单一情绪类别,完整保留各类情绪的占比分布信息,可更准确表征现实场景下情绪混杂交织、情绪强度高低变化、情绪平滑渐变过渡等复杂真实情绪状态,为推理目标用户的心理动机提供了一个高精度的情绪语义锚点,迫使在推理时聚焦于符合该连续情绪向量的深层因果链条,从而挖掘出与用户真实情绪状态相适配的深层心理动机,提升了共情内容与用户真实心理状态的适配精度及情感支持力度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122964240A_ABST
    Figure CN122964240A_ABST
Patent Text Reader

Abstract

The application provides an empathetic dialogue generation method, device, equipment and medium, and relates to the technical field of natural language processing. The method comprises the following steps: obtaining a context dialogue of a target user; obtaining an initial emotion vector corresponding to the context dialogue; determining a probability distribution of each emotion prototype vector based on the similarity between the initial emotion vector and a plurality of emotion prototype vectors representing different emotion categories; weighting and fusing each emotion prototype vector into a continuous emotion vector according to the probability distribution; reasoning the behavior appeal and psychological motivation of the target user from the context dialogue with the continuous emotion vector as a reasoning constraint, obtaining an explicit surface demand and an implicit psychological demand; and generating a target empathetic reply based on the context dialogue, the explicit surface demand and the implicit psychological demand.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a method, apparatus, device, and medium for generating empathetic dialogue. Background Technology

[0002] Empathic dialogue generation is a core task in the field of natural language processing and intelligent interaction. It can realize human-computer empathic interaction by recognizing the user's emotional state and generating emotionally appropriate responses, and can be used in scenarios such as emotional companionship, psychological support and intelligent customer service.

[0003] Currently, the large language model method based on thought chain reasoning is widely used as a common solution in this field. Its workflow is as follows: the dialogue history is input into the pre-trained language model, the model infers the user's discrete emotion category based on the context, and generates an intermediate reasoning logic reflecting the thought chain in natural language form according to the preset response strategy that matches the discrete emotion category. The model generates the final empathetic response based on this reasoning logic.

[0004] However, this method uses a hard classification approach to categorize user emotions into a single discrete category, which makes it difficult to capture the dynamic transition of emotions. This leads to a discrepancy between the emotions used for subsequent reasoning and the actual state, resulting in an empathetic response that, while matching the emotion category, lacks sufficient emotional support. Summary of the Invention

[0005] Therefore, it is necessary to provide a method, apparatus, device, and medium for generating empathic dialogue in response to the above-mentioned technical problems.

[0006] The following technical solution is adopted in this specification: This specification provides a method for generating empathic dialogues, including: Obtain the target user's contextual dialogue; An initial emotion vector corresponding to the context dialogue is obtained. Based on the similarity between the initial emotion vector and multiple emotion prototype vectors representing different emotion categories, the probability of each emotion prototype vector is determined. The emotion prototype vectors are weighted and fused into a continuous emotion vector according to the probability. Using the continuous emotion vector as a reasoning constraint, the behavioral demands and psychological motivations of the target user are inferred from the context dialogue to obtain explicit surface needs and implicit psychological needs. Based on the contextual dialogue, the explicit surface needs, and the implicit psychological needs, a target empathetic response is generated.

[0007] Further, obtaining the initial emotion vector corresponding to the context dialogue includes: Discrete emotion tags of the target user from the contextual dialogue; The discrete emotion labels are mapped to the VAD continuous emotion space to obtain the first spatial coordinates; the VAD continuous emotion space consists of three continuous dimensions: efficacy value, arousal value, and dominance value. The efficacy value represents the positive or negative attribute of the emotion, the arousal value represents the intensity attribute of the emotion, and the dominance value represents the sense of control attribute of the emotion; the first spatial coordinates are the combination of values ​​of the discrete emotion labels on the three continuous dimensions. The first spatial coordinates are used as the initial emotion vector.

[0008] Furthermore, the step of obtaining the continuous emotion vector includes: The second spatial coordinates of each of the emotion prototype vectors in the continuous emotion space of the VAD are obtained. The second spatial coordinates corresponding to each of the emotion prototype vectors are pre-calibrated by the emotion dictionary. The same emotion prototype vector has a fixed second spatial coordinate in all dialogue scenarios. The direction cosine values ​​between the first spatial coordinates and each of the second spatial coordinates are obtained one by one. The larger the direction cosine value, the stronger the directional consistency between the discrete emotion label and the corresponding emotion prototype vector in the continuous emotion space. The direction cosine values ​​are normalized to obtain the probability of each emotion prototype vector; the second spatial coordinates of each emotion prototype vector are weighted and summed using the probability of each emotion prototype vector as a weight coefficient to obtain the continuous emotion vector; the continuous emotion vector is a fusion coordinate point in the VAD continuous emotion space, used to represent the comprehensive emotional state corresponding to the context dialogue.

[0009] Furthermore, the acquisition of explicit surface-level needs and implicit psychological needs is achieved through a pre-trained empathic dialogue model, the pre-training of which includes: Obtain the corresponding continuous emotion vectors for multiple historical context dialogues; Using the continuous emotion vectors of each historical context dialogue as inference constraints, a large language model with a parameter scale of hundreds of billions or more is used to infer each historical context dialogue, generating multiple response inference chains. The response inference chains include continuous emotion vectors, explicit surface needs, implicit psychological needs, and empathetic responses. The quality of the multiple response inference chains is scored using multiple preset evaluation models. Based on the consistency of the scoring results of each evaluation model, the multiple response inference chains are divided into high-confidence response inference chains and low-confidence response inference chains. A hierarchical reasoning dataset is constructed by preserving the complete high-confidence response reasoning chain and filtering out the implicit psychological needs in the low-confidence response reasoning chain; A lightweight large language model is trained based on the hierarchical reasoning dataset to obtain an empathic dialogue model.

[0010] Furthermore, the step of using the continuous emotion vectors of each historical context dialogue as inference constraints, and employing a large language model with a parameter scale of hundreds of billions or more to infer each historical context dialogue, includes: Each of the aforementioned historical context dialogues is assembled into a prompt text containing a scene description, a sequence of user statements, and annotation instructions; Based on the prompt text, the large language model extracts key events and emotional expression words from the user's statements in the current historical context of the dialogue to obtain the emotion inference result. The large language model uses the emotion reasoning result as context to extract the user's directly expressed action goal or information query from the current historical context dialogue to obtain the explicit surface demand. The large language model uses the emotion inference result and the explicit surface needs as a joint context to infer the underlying psychological motivations driving the user's current expressive behavior and obtain the implicit psychological needs. The large language model uses the emotion reasoning result, the explicit surface needs, and the implicit psychological needs as a joint context to generate a response reasoning chain that matches the implicit psychological needs.

[0011] Furthermore, the step of training a lightweight large language model based on the hierarchical inference dataset to obtain an empathic dialogue model includes: In the first training phase, each sample in the hierarchical reasoning dataset is assembled into an input-target sequence according to a preset structured label format. The preset structured label format includes a label header and a label tail corresponding to the emotion reasoning result, explicit surface needs, implicit psychological needs, and empathic responses, respectively. Based on the input-target sequence, the lightweight large language model is supervised and fine-tuned using an autoregressive generation method. By minimizing the probability difference between the reasoning sequence generated by the lightweight large language model and the target sequence in the hierarchical reasoning dataset, the lightweight large language model learns the structured output format and basic logic for emotion reasoning, explicit surface needs reasoning, implicit psychological needs reasoning, and empathic responses. In the second training phase, the lightweight large language model after supervised fine-tuning is used as the initial policy model. The proximal policy optimization algorithm is used to train the initial policy model through reinforcement learning. During the training process, a reward value is calculated for each response generated by the lightweight large language model. The reward value is calculated according to a reward function, which includes at least a format correctness reward and a sentiment consistency reward. The parameters of the lightweight large language model are updated with the reward value as the optimization objective, so that the output behavior of the lightweight large language model is aligned with the preset reward standard. The lightweight large language model after completing the second training phase will be used as the empathic dialogue model.

[0012] Furthermore, generating a targeted empathetic response based on the contextual dialogue, the explicit surface needs, and the implicit psychological needs includes: The contextual dialogue and the continuous emotion vector are jointly encoded into a model input sequence; The empathic dialogue model, based on the input sequence, sequentially generates emotion inference results, explicit surface needs, implicit psychological needs, and a final empathic response using an autoregressive approach. Each generation step is conditional upon the content generated in the preceding step. The emotion inference result is a classification mapping of the continuous emotion vector onto a preset emotion category. The explicit surface needs are generated with the emotion inference result as a contextual constraint. The implicit psychological needs are generated with both the emotion inference result and the explicit surface needs as contextual constraints. The final empathic response is generated with the emotion inference result, the explicit surface needs, and the implicit psychological needs as contextual constraints. The emotion inference results, the explicit surface needs, the implicit psychological needs, and the final empathic response are output in a preset structured tag format, which includes a tag header and a tag footer corresponding to each output content.

[0013] This specification provides an empathic dialogue generation device, including: The data acquisition module is used to acquire the contextual dialogue of the target user; The reasoning module is used to obtain the initial emotion vector corresponding to the context dialogue, determine the probability of each emotion prototype vector based on the similarity between the initial emotion vector and multiple emotion prototype vectors representing different emotion categories, and weight and fuse each emotion prototype vector into a continuous emotion vector according to the probability. Using the continuous emotion vector as a reasoning constraint, the module infers the behavioral demands and psychological motivations of the target user from the context dialogue to obtain explicit surface needs and implicit psychological needs. The dialogue generation module is used to generate a target empathetic response based on the contextual dialogue, the explicit surface needs, and the implicit psychological needs.

[0014] This specification provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described empathic dialogue generation method.

[0015] This specification provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described empathic dialogue generation method.

[0016] The above-mentioned technical solutions adopted in this specification can achieve the following beneficial effects: This invention restores the multi-component superposition characteristics of emotions by using a continuous representation of multiple weighted emotion prototype vectors. It no longer forcibly classifies emotions into a single emotion category, but fully preserves the proportion and distribution information of various emotions. This can more accurately represent complex and real emotional states in real-world scenarios, such as the mixing and intertwining of emotions, the changes in emotional intensity, and the smooth and gradual transition of emotions. It provides a high-precision emotional semantic anchor point for inferring the psychological motivation of the target user, forcing the inference to focus on the deep causal chain that conforms to the continuous emotion vector. This allows for the discovery of deep psychological motivations that match the user's real emotional state, improving the accuracy of the matching between empathetic content and the user's real psychological state, as well as the strength of emotional support. Attached Figure Description

[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This document provides a flowchart illustrating a method for generating empathic dialogues. Figure 2 This is a schematic diagram of the overall architecture of the model provided in this specification; Figure 3 This is a schematic diagram of the structure of an empathic dialogue generation device provided in this specification; Figure 4 This is a schematic diagram of a computer device provided for this specification. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without creative effort are within the scope of protection of this application.

[0019] The technical solution provided by this invention can be applied to scenarios such as emotional companionship, psychological support, human-computer interaction, intelligent customer service, and virtual assistants. Existing empathic dialogue methods suffer from insufficient continuous emotion modeling, a lack of implicit need reasoning ability, and a lack of high-quality deep reasoning supervision signals, making it difficult to support the model in learning a stable empathic decision-making mechanism. To address these issues, embodiments of this application provide an empathic dialogue generation method.

[0020] The empathic dialogue generation method of the present invention is described below with reference to the accompanying drawings.

[0021] Figure 1 This is a flowchart illustrating a method for generating empathic dialogues provided in this specification, such as... Figure 1 As shown, the method includes the following: S100, Obtain the contextual dialogue of the target user.

[0022] For example, first, the contextual dialogue of the target user is obtained. This contextual dialogue is the multi-turn interaction history between the user and the dialogue agent, represented as... ,in, Represents a set of contextual dialogues. Indicates the first Round of dialogue, This indicates the current dialogue round for which a response is to be generated; where each round of user speech... Decomposed into token sequence , Indicates the first The first in the round of words Each word element, Indicates the first The total number of lexical units contained in each turn of speech. The maximum length of the speech history is set to 2048 tokens, and the maximum number of interaction turns is 10, in order to fully preserve the contextual and semantic information and provide an input basis for sentiment reasoning and demand mining.

[0023] S200. Obtain the initial emotion vector corresponding to the context dialogue. Based on the similarity between the initial emotion vector and multiple emotion prototype vectors representing different emotion categories, determine the probability of each emotion prototype vector. According to the probability, weight and fuse each emotion prototype vector into a continuous emotion vector. Using the continuous emotion vector as a reasoning constraint, infer the target user's behavioral demands and psychological motivations from the context dialogue to obtain explicit surface needs and implicit psychological needs.

[0024] For example, discrete emotional expressions in user dialogues are transformed into standardized continuous spatial representations, thereby capturing subtle emotional shifts and semantic connections. Based on this, the user's expressed intentions are decoupled into directly observable surface needs and deep psychological motivations driving behavior, providing precise cognitive conditions for subsequent generation. The input to this step is the target user's contextual dialogue, i.e., multi-turn interaction history, and the output is explicit surface needs and implicit psychological needs. Its core processing logic includes: first, constructing a continuous emotion space based on the VAD three-dimensional emotion model; then, mapping the original discrete emotion labels to 12 standardized emotion prototypes using cosine similarity; calculating weight parameters through probability-weighted fusion to generate a real-time refined continuous emotion vector for the user; and finally, using this vector as a constraint for two-layer demand reasoning, achieving decoupled modeling of functional explicit needs and emotional implicit needs.

[0025] S300 generates a target empathetic response based on contextual dialogue, explicit surface needs, and implicit psychological needs.

[0026] For example, the purpose of this step is to aggregate the obtained emotional state and dual-layered needs information into generation conditions, guiding the dialogue model to generate an empathetic response that both matches the user's emotional state and addresses their deeper psychological needs. The input to this step is the contextual dialogue, explicit surface needs, and implicit psychological needs; the output is the target empathetic response. Its core processing logic is to format the above inputs according to a preset structured format, including... <context> 、 <emotion>,<Explicit need> ,<Implicit need> After being assembled from structured tags, the data is input into a pre-trained empathic dialogue model. The model then generates emotion inference results, explicit surface needs, implicit psychological needs, and the final empathic response in an autoregressive manner, thus fully modeling the conditional probability distribution.

[0027] Based on the above Figure 1 In the illustrated embodiment, for example, step 200 above, the steps of obtaining explicit surface needs and implicit psychological needs include: Extracting discrete emotion labels from the target user's contextual dialogue. In a preferred implementation, when using the Empathetic Dialogues dataset, this dataset labels each round of dialogue with 32 discrete emotion labels. After obtaining these discrete emotion labels, they are mapped to the VAD continuous emotion space to obtain the first spatial coordinates. The VAD continuous emotion space consists of three continuous dimensions: Valence, Arousal, and Dominance. Valence represents the positive or negative attribute of the emotion, such as pleasure or displeasure; Arousal represents the intensity attribute of the emotion, such as calm or excitement; and Dominance represents the sense of control of the emotion, such as mastery or submission. The first spatial coordinates are the combination of values ​​of the discrete emotion label in the three continuous dimensions. Specifically, relying on the NRC VAD (The NRC Valence, Arousal, and Dominance Lexicon), the standard VAD three-dimensional numerical vector corresponding to the original discrete emotion label is obtained. This vector is used as the initial emotion vector.

[0028] Next, based on the similarity between the initial emotion vector and multiple emotion prototype vectors representing different emotion categories, the probability of each emotion prototype vector is determined. The multiple emotion prototype vectors represent 12 standardized emotion prototypes, including: Joy, Sadness, Anger, Fear, Surprise, Disgust, Acceptance, Anticipation, Trust, Grief, Boredom, and Calmness. Each emotion prototype corresponds to a second spatial coordinate in the VAD continuous emotion space. The coordinates are pre-calibrated by the NRC VAD dictionary, and the same emotion prototype vector has fixed second spatial coordinates in all dialogue scenarios. By obtaining the VAD vector corresponding to each prototype through the emotion dictionary, the discrete emotion is transformed into a continuous emotion space, providing a unified benchmark for subsequent fine-grained emotion perception.

[0029] Obtain the first spatial coordinates one by one With each second space coordinate The direction cosine value between the discrete emotion label and the corresponding emotion prototype vector is considered. A larger direction cosine value indicates a stronger degree of directional consistency between the discrete emotion label and the corresponding emotion prototype vector in the continuous emotion space. The formula for calculating cosine similarity is: ; in, This represents the VAD vector corresponding to the original sentiment label, i.e., the first spatial coordinates. Let VAD represent the VAD vector corresponding to the k-th emotion prototype, i.e., the second spatial coordinates. The superscript T indicates the vector transpose. This represents the L2 norm of the vector. The cosine similarity between the original emotion and 12 emotion prototypes is calculated using this formula. The emotion prototype with the highest similarity is selected as the mapping target, thus compressing and standardizing the emotion labels and alleviating the label sparsity problem.

[0030] The cosine values ​​in each direction are normalized to obtain the probability of each emotion prototype vector. Specifically, the model predicts the probability distribution of 12 emotion prototypes based on the dialogue context. ,in This represents the predicted probability of the k-th emotion prototype. Then, using the probability of each emotion prototype vector as a weighting coefficient, the second-space coordinates of each emotion prototype vector are weighted and summed to obtain a continuous emotion vector. The calculation formula is: ; in This represents the predicted probability of the k-th emotion archetype. This represents the VAD vector corresponding to the k-th emotion prototype, i.e., the second spatial coordinates. This represents the user's current continuous emotional state vector. This vector represents a fused coordinate point in the VAD continuous emotion space, used to characterize the comprehensive emotional state corresponding to the context of the dialogue. This vector simultaneously preserves category interpretability and fine-grained differences in continuous emotions. Through the above processing, accurate quantitative modeling of users' dynamic emotions is achieved.

[0031] With continuous emotion vector To constrain inference, the system deduces the target user's behavioral needs and psychological motivations from the context of the dialogue, obtaining explicit surface needs and implicit psychological needs. This inference process is implemented through a pre-trained empathic dialogue model. In the specific model architecture, continuous emotion vectors... The fusion method for inference constraints is as follows: the three dimensions of the continuous emotion vector (valence, arousal, and dominance) are embedded as special labels into the input sequence, concatenated with the token representation of the dialogue history, and jointly encoded, enabling the model to perceive the user's continuous emotional state when inferring needs. Specifically, based on the dialogue context... With continuous emotion vector Given these conditions, infer the explicit user requirements separately. With implicit psychological needs : ; Explicit needs describe the goals directly expressed by users in the text, i.e., the surface-level demands directly expressed in the user's discourse, specifically including the user's directly stated action goals or information inquiries; implicit needs describe the psychological demands that users do not explicitly express but that exist latently, i.e., the deep psychological motivations driving the user's current expressive behavior. Through this two-layer decoupling, empathy generation shifts from surface-level matching to deep-level psychological support.

[0032] As a preferred approach, in step S100, explicit surface needs and implicit psychological needs are obtained through a pre-trained empathic dialogue model. The training process of the pre-trained empathic dialogue model is as follows: Figure 2 This is a schematic diagram of the overall architecture of a model provided in this specification, such as... Figure 2 As shown, it is divided into three stages: data construction, consistency screening, and model training.

[0033] The data construction phase uses raw ED (Empathetic Dialogues) data as input, which inherently contains 32 discrete emotion labels. First, the 32 discrete emotion labels in the raw ED dialogue data are calculated based on vector similarity, and then, combined with knowledge adjustment, mapped from a 32-dimensional VAD emotion space to a 12-dimensional VAD continuous emotion space, resulting in refined emotion vectors. Subsequently, an LLM (Large Language Model) automatic annotation tool is used to perform emotion mapping processing and constraint-based demand localization processing. Demand localization processing allows the model to internally consider the thought process but prohibits direct output of the thought process. This process annotates the dialogue data, generating labels for emotion, explicit demands, implicit demands, and response reasoning chains, thus constructing the initial DEAR (Dialogue Empathy Analysis Representation) dataset. Specifically: Continuous emotion vectors corresponding to multiple historical context dialogues are obtained. The method for obtaining these continuous emotion vectors is the same as described above: based on the VAD model, discrete emotion labels are mapped to 12 emotion prototypes, and continuous emotion vectors are obtained through probability-weighted fusion. Using the continuous emotion vectors of each historical context dialogue as inference constraints, a large language model with hundreds of billions of parameters is used to infer each historical context dialogue, generating multiple response inference chains. Each response inference chain includes continuous emotion vectors, explicit surface needs, implicit psychological needs, and empathetic responses. This process specifically includes: Each historical context dialogue is assembled into a prompt text containing a scene description, a sequence of user statements, and annotation instructions. In one specific implementation, the prompt template can be designed as follows: Please output the following in sequence based on the dialogue scenario and user statements: 1. Emotional reasoning results: Identify the user's current emotional state (selected from 12 emotion categories); 2. Explicit needs: Action goals or information requests clearly expressed by the user; 3. Implicit needs: The deep psychological motivations driving users' expressive behavior (not explicitly stated); 4. Empathic Response: Responses that address the user's emotions and underlying needs.

[0034] Dialogue scenario: [Scene description]; User statements: [User remarks].

[0035] Based on the aforementioned prompt text, the large language model extracts key events and emotional expression words from the user's statements in the current historical context of the dialogue to obtain an emotion inference result. Subsequently, using the emotion inference result as context, the large language model extracts the user's directly stated action goals or information queries from the current historical context of the dialogue to obtain explicit surface needs. Using the emotion inference result and explicit surface needs as a joint context, the model infers the underlying psychological motivations driving the user's current expressive behavior to obtain implicit psychological needs. Finally, using the emotion inference result, explicit surface needs, and implicit psychological needs as a joint context, the large language model generates a response inference chain that matches the implicit psychological needs.

[0036] In one embodiment, DeepSeek-R1 is used as an automatic annotator to batch annotate dialogue data and generate structured tags including: sentiment inference results and explicit needs. Implicit demand Response inference chain. The annotation process does not introduce target response information, avoiding information leakage and backtracking bias, thereby constructing a high-quality supervised dataset.

[0037] In the consistency screening stage, the aforementioned DEAR dataset is input, and multiple independent evaluation models are used to score the labeled data on a quality scale of 1-5 across four dimensions: dialogue context, emotion, implicit needs, and explicit needs. Evaluator reliability is calculated based on the Spearman correlation coefficient, and a consistency penalty is introduced. After screening, low-quality samples are removed, and high-confidence samples are selected to generate DEAR-de (Dialogue Empathy Analysis-denoised) data with pre-defined structured label templates. Specifically: After generating multiple response inference chains, the quality of these chains is scored using multiple pre-defined evaluation models. Based on the consistency of the scoring results from each evaluation model, the response inference chains are categorized into high-confidence and low-confidence response inference chains. Specifically, three representative large language models—DeepSeek7B, Qwen38B, and Llama3-8B—are selected as evaluators to assign quality scores of 1 to 5 points to the labeled samples in the dataset. Higher scores indicate greater semantic consistency and alignment between the generated scene summary, empathy strategy, and executed actions and the dialogue context. The evaluation process uses standardized prompts, causing the model to output integer scores.

[0038] The Spearman correlation coefficient was used to calculate the reliability weight of the evaluators. ; The total number of evaluation models is 3. The Spearman correlation coefficient is used to calculate the scores of the i-th and j-th evaluation models. This formula calculates the average correlation between each evaluator's scores and those of other evaluators, serving as a measure of that evaluator's reliability. Further calculations are made to determine the final sample quality score (including a consistency penalty). ; Among them, | |=3 represents the total number of evaluation models. Let be the score of the i-th evaluation model for sample x. Let x be the standard deviation of the scores of all evaluation models for the sample x. The consistency penalty coefficient is set to 0.1. This formula weights and sums the scores based on the reliability weights of each evaluator, then subtracts the standard deviation of the scores multiplied by the penalty coefficient to penalize samples with significant disagreements among evaluators. Only samples with a mean score above a threshold and a variance below a set threshold are retained, thus selecting high-confidence samples. In this embodiment, the mean score threshold is set to 3.5 (out of 5), and the variance threshold is set to 1.0. These thresholds can be verified experimentally or set empirically, and those skilled in the art can adjust them according to actual application scenarios. The specific values ​​mentioned above do not constitute a limitation on the scope of protection of this invention. This screening process ensures that only high-quality labeled samples consistently recognized by all evaluation models enter the subsequent training set, thereby reducing noise, bias, and over-inference in implicit requirement reasoning.

[0039] A hierarchical inference dataset is constructed by preserving complete high-confidence response inference chains and filtering out implicit psychological needs in low-confidence response inference chains. Specifically, for high-confidence samples, complete inference chains are preserved: <context> 、 <emotion>,<Explicit need> Structured labels guide the model's internal inference; for low-confidence samples, only [the following are retained] <context> 、 <emotion>Remove<Implicit need> The labels and their content are directly removed to filter out implicit demand noise. By using structured labels, the model is forced to reason step by step according to human empathic cognitive logic, thereby improving interpretability and output stability.

[0040] The model training phase inputs DEAR-de data. The first stage involves supervised fine-tuning of the basic large model based on the DEAR-de data, learning emotion recognition, need inference, and structured response generation. The second stage employs PPO (Proximal Policy Optimization) for multi-objective reinforcement learning, aligning model behavior through rule-format rewards and rule-emotion rewards respectively. The model outputs structured content containing fields such as <Thinking>, <Emotion>, <Implicit Needs>, <Explicit Needs>, and <Response>, ultimately resulting in a DEAR-COT (Dialogue Empathy Analysis-Chain-of-Thought) training model with empathic reasoning capabilities. Specifically: The first training phase is supervised fine-tuning training. Each sample in the hierarchical inference dataset is assembled into an input-target sequence according to a pre-defined structured label format. This pre-defined structured label format includes a header and a footer of labels corresponding to the emotion inference result, explicit surface needs, implicit psychological needs, and empathetic responses, respectively (e.g., ...). <emotion> ...< / emotion> ,<Explicit need> ...< / Explicit need> ,<Implicit need> ...< / Implicit need> , <response> ...< / response> (etc.). Based on the input-target sequence, a lightweight large language model is supervised and fine-tuned using an autoregressive generation method. By minimizing the probability difference between the inference sequence generated by the lightweight large language model and the target sequence in the hierarchical inference dataset, the lightweight large language model learns the structured output format and basic logic for emotion inference, explicit surface demand inference, implicit psychological demand inference, and empathic response generation. The training objective is to minimize the negative log-likelihood. ; in, Represents a structured reasoning sequence. Indicates the context of the dialogue. For model parameters, This represents the total number of training samples. The training parameters are set as follows: initial learning rate is 1×102. −4 The batch size is 16, the maximum input length is 2048 tokens, the number of training rounds is 3, and the warm-up ratio is 0.1.

[0041] The second training phase is reinforcement learning training. Using the supervised fine-tuned lightweight large language model as the initial policy model, the Proximal Policy Optimization (PPO) algorithm is employed for reinforcement learning training of the initial policy model. During training, a reward value is calculated for each response generated by the lightweight large language model. The reward value is obtained according to a reward function, which includes at least a format correctness reward and a sentiment consistency reward. The reward function is defined as follows: Reward for correct formatting: ; Emotional consistency reward: ; Overall Rewards: ; in, The reward for correct formatting is calculated by checking whether the model output contains all the necessary structured labels and that the label hierarchy is correct. This represents a reward for emotional consistency, which checks whether the emotional inference results output by the model are consistent with the actual emotional labels in the context of the input dialogue. The final reward is set. Reinforcement learning training parameters are set as follows: total batch size of 128, maximum generation length of 1024 tokens, and training, validation, and test set ratio of 8:1:1. The parameters of the lightweight large language model are updated with the reward value as the optimization objective, aligning the output behavior of the lightweight large language model with the preset reward standard. The lightweight large language model after completing the second training phase is used as an empathic dialogue model.

[0042] In a preferred embodiment, the underlying large language model includes various open-source large models such as DeepSeek-7B-Chat, Qwen3 series, Llama3.2-3B, and GLM-Z1-9B. The method can be applied to the Empathetic Dialogues dataset, which contains approximately 25,000 dialogue scenarios covering 32 emotion labels. Those skilled in the art will understand that the above supplementary content does not constitute a limitation on the scope of protection of this invention.

[0043] Through the implementation of step S200 above, the present invention can bring the following beneficial effects: First, based on the VAD continuous emotion model, a refined emotion representation system is constructed, compressing and mapping the original 32 discrete emotion labels into 12 standardized emotion prototypes. This solves the problem of coarse granularity and difficulty in depicting subtle emotional changes in traditional discrete emotion labels, significantly improving the accuracy and robustness of emotion perception. Second, through the explicit-implicit dual-layer demand decoupling reasoning mechanism, both the user's surface intentions and deep psychological needs can be mined simultaneously, breaking through the limitations of existing methods that only focus on literal semantics and cannot identify implicit emotional appeals, making empathetic responses more in line with real psychology. Finally, the invention employs large language model automatic labeling (with specific prompt templates), multi-model consistency weighted scoring (calculating evaluator reliability weights through Spearman correlation coefficients and introducing consistency penalty terms, combined with a score mean threshold of 3.5 and a score variance threshold of 1.0 for screening), and hierarchical thinking chain construction (high-confidence samples retain complete labels, low-confidence samples are removed).<Implicit need> This method efficiently generates high-confidence, low-noise, high-quality supervisory data, effectively overcoming the challenges of high labeling costs, distorted implicit needs, and unreliable training signals in empathic dialogue data. These effects work synergistically to ensure the high accuracy, completeness, and reliability of the output emotional state and need information, laying a solid foundation for generating high-quality empathic responses.

[0044] Based on the above Figure 1 In the illustrated embodiment, for example, in step 300 above, generating a target empathetic response based on contextual dialogue, explicit surface needs, and implicit psychological needs includes the following steps: context dialogue With continuous emotion vector The joint encoding is used as the input sequence for the model. In one implementation, the three dimensions of the continuous emotion vector (effectiveness value, arousal value, and dominance value) can be embedded as special labels [V], [A], and [D] into the input sequence, concatenated with the token representation of the dialogue history, and jointly encoded into the empathic dialogue model.

[0045] The empathic dialogue model, based on the input sequence, sequentially generates emotion inferences, explicit surface needs, implicit psychological needs, and a final empathic response using an autoregressive approach. Each generation step is conditional upon the content generated in the preceding step. Specifically, the input is the new dialogue context. Then, the model outputs sequentially according to a fixed inference chain: Emotion inference results The emotion inference result is the classification mapping of continuous emotion vectors on preset emotion categories, that is, the emotion category with the highest probability in the 12-dimensional emotion probability distribution output by the model.

[0046] Explicit surface requirements Explicit surface-level requirements are generated using sentiment inference results as contextual constraints, describing the user's action goals or information inquiries directly expressed in the text.

[0047] Implicit psychological needs Implicit psychological needs are generated using emotional inferences and explicit surface needs as contextual constraints, describing the underlying psychological motivations driving a user's current expressive behavior.

[0048] Final Empathic Response The final empathic response is generated based on the contextual constraints of emotional inference, explicit surface needs, and implicit psychological needs.

[0049] The complete modeling conditions for the above process are distributed as follows: .

[0050] The emotion inference results, explicit surface needs, implicit psychological needs, and final empathic responses are output in a preset structured tag format. This preset structured tag format includes a tag header and tag footer corresponding to each output item, for example... <emotion>、<Explicit need>、<Implicit need>、 <response>Tags such as [list of tags]. The generation process uses autoregressive decoding, with each step based on previously generated structured content, until a complete empathy response sequence is generated.

[0051] In a specific application example of this invention, taking the dialogue of "a fire in the storage room and the loss of valuable souvenirs" as an example, the user's original dialogue interaction is as follows: Speaker: My storage room caught fire over the weekend, and several things are gone.

[0052] Listener: I'm really sad to hear this. Is the storage room insured?

[0053] Speaker: Yes. But what's lost are souvenirs and treasured old items, things that can't be replaced at all.

[0054] After receiving the dialogue input, the model first summarizes and extracts the core events of the dialogue, then sequentially performs scene understanding, emotion recognition, explicit need inference, and implicit need inference, ultimately generating an empathetic response: I completely understand. These precious keepsakes carry irreplaceable emotional value, and no amount of insurance can make up for this deep regret. Specifically, summarizing and extracting the core events of the dialogue extracts key events such as "storage room fire" and "loss of precious keepsakes"; emotion recognition identifies the user's emotion as frustration, outputting a VAD (Valuation, Arousal, Dominance) 3D emotion vector to locate the user's emotional state in the valence, arousal, and dominance 3D space; explicit need inference derives: I hope someone can understand the feeling of losing these precious keepsakes; implicit need inference derives: I yearn for someone to empathize with my inner pain and recognize the precious significance of those lost items, ultimately generating an empathetic response.

[0055] In one specific embodiment, validation was performed on the Empathetic Dialogues dataset. This dataset is an open-domain empathic dialogue dataset containing approximately 24,850 dialogues covering 32 emotion categories. The dataset is specifically divided as follows: the training set contains 19,533 dialogues and 83,496 utterances; the validation set contains 2,547 dialogues and 10,886 utterances; and the test set contains 2,767 dialogues and 11,860 utterances.

[0056] The experiment used several open-source large language models as base models, including: DeepSeek-7B-Chat, the Qwen3 series (including Qwen3-0.6B, Qwen3-4B, and Qwen3-4B-Instruct), Llama3.2-3B, and GLM-Z1-9B. In the consistency scoring phase, three representative large language models were selected as evaluators: DeepSeek7B, Qwen38B, and Llama3-8B.

[0057] Automatic evaluation metrics include: Bilingual Evaluation -1 / 2 / 3 / 4 (measures the n-gram grammatical overlap between the generated response and the reference response; higher scores indicate better generation quality), Emotional Accuracy (calculated as the percentage of the model's output emotion category that matches the dialogue reference standard emotion label), Diversity -1 / 2 (measures the lexical diversity of the generated response; higher scores indicate richer generated content), and Confusion (measures the predictive ability of the language model; lower scores indicate more fluent and natural generated text). Human evaluation dimensions include: Empathy (assessing the degree to which the response resonates with the user's emotional state), Needs Fit (assessing the accuracy with which the response matches the user's needs), Relevance (assessing the semantic coherence of the response within the dialogue context), and Fluency (assessing the naturalness and readability of the response's language). In human A / B testing, evaluators compare the generated responses of the two models across three dimensions: empathy, relevance, and fluency, judging them in a win / loss / draw format.

[0058] The main hyperparameter settings of this invention are as follows: the number of training epochs in the supervised fine-tuning stage is 3, the batch size is 16, and the initial learning rate is 1×10. -4 The maximum input length is 2048 tokens, the warm-up ratio is 0.1, the consistency screening weight λ is 0.1, the mean score threshold is set to 3.5 (out of 5), and the score variance threshold is set to 1.0. The total batch size in the reinforcement learning phase is 128, the maximum generation length is 1024 tokens, and the ratio of training, validation, and test sets is 8:1:1.

[0059] In the comparative experiments, the baseline models included: Transformer (standard Transformer generation model), MoEL (Mixture of Empathetic Listeners), EmpDG (Empathetic Dialogue Generation), KEMP (Knowledge-Enriched Empathetic Model), DCKS (Dynamic Context Knowledge Selection), E-CORE (Emotion-Cause-Oriented Response Generation), Emp-USIR (Empathetic User State Inference and Response), CAB (Context-Aware Blending), IAMM (Interactive Affective Memory Model), PDPA (Progressive Dialogue Policy Adaptation), and ReflectDiffu (Reflective Diffusion Model).

[0060] Table 1 shows the experimental results on the Empathetic Dialogues dataset.

[0061] Table 2. Dataset statistics for Empathetic Dialogues

[0062] Table 3 Main hyperparameters

[0063] Table 4. Performance of DEAR in ablation experiments

[0064] Table 5. Performance of DEAR in the training set size sensitivity experiment.

[0065] Table 6. Performance of DEAR in various backbone LLM experiments

[0066] Table 7 Performance of DEAR compared to baseline model in experiments

[0067] Table 1 compares the automatic evaluation metrics of the DEAR model with existing mainstream empathic dialogue methods on the Empathetic Dialogues dataset. The results show that the proposed method achieves the best performance in BLEU-1 / 2 / 3 / 4, emotion accuracy, Distinct-2, and perplexity (PPL), significantly outperforming all baseline models. Table 2 presents the statistics of the Empathetic Dialogues dataset, which contains 24,850 open-domain dialogues covering 32 emotion labels. Table 3 lists the main hyperparameter settings used in this invention, including the number of training rounds, batch size, consistency screening weight, and learning rate warm-up ratio. Table 4 shows the ablation experiment results of the DEAR model. Comparisons were made using the original 32-dimensional discrete emotion labels (w / 32D-e), removal of thought chain reasoning (w / oCoT), removal of implicit need reasoning (w / oImp), and removal of PPO reinforcement learning (w / oPPO). The experimental results show that removing any core module leads to a decrease in model performance, validating the necessity of continuous emotion representation, hierarchical reasoning, implicit need mining, and two-stage training. Table 5 illustrates the impact of training data scale on model performance. When the training data is reduced to 1 / 8, the model performance remains relatively robust; when the data is reduced to 1 / 16 or less, all indicators decrease significantly, demonstrating the importance of high-quality labeled data for this method. Table 6 shows the generalization results of this framework on different open-source large language platforms, covering models such as the Qwen3 series, Llama3.2-3B, and GLM-Z1-9B. The results show that this framework can stably improve the ability to generate empathic dialogues on various platforms, exhibiting architecture independence and good adaptability. Table 7 shows the results of human A / B evaluation. Compared with baseline models such as MOEL, EmpDG, and CAB, this invention achieves higher win rates in empathy and relevance, and its fluency is comparable to the best baseline, indicating that the generated responses better match the user's emotions and deep psychological needs, possessing stronger empathic support capabilities.

[0068] Overall experiments show that the VAD continuous emotion modeling, two-layer demand decoupling reasoning, high-quality data construction and two-stage training strategy proposed in this invention can significantly improve the accuracy, relevance and fluency of empathic dialogue, and outperform existing methods in both automatic indicators and human evaluation.

[0069] Ablation experiments show that removing any component—such as step-by-step cognitive chain reasoning, data scoring and sampling, or PPO training—leads to a decrease in model performance across one or more dimensions, confirming the importance of each module. Training set size analysis reveals that the model's performance stabilizes before the data volume is reduced to 1 / 8; further reduction results in a sharp performance drop, indicating that sufficient high-quality data is crucial for model adaptation. Backbone model analysis demonstrates that the framework of this invention is adaptable to various open-source LLMs, achieving excellent performance on models of different architectures and sizes, and exhibiting good generalization ability.

[0070] Figure 3 This is a schematic diagram of the structure of an empathic dialogue generation device provided by the present invention. For example, please refer to [link / reference]. Figure 3 As shown, the empathic dialogue generation device may include [the following].

[0071] The data acquisition module is used to acquire the contextual dialogue of the target user.

[0072] The reasoning module is used to obtain the initial emotion vector corresponding to the context dialogue. Based on the similarity between the initial emotion vector and multiple emotion prototype vectors representing different emotion categories, the probability of each emotion prototype vector is determined. The emotion prototype vectors are weighted and fused into a continuous emotion vector according to the probability. Using the continuous emotion vector as a reasoning constraint, the behavioral demands and psychological motivations of the target user are inferred from the context dialogue to obtain explicit surface needs and implicit psychological needs.

[0073] The dialogue generation module is used to generate empathetic responses based on contextual dialogue, explicit surface needs, and implicit psychological needs.

[0074] Specific limitations regarding the empathic dialogue generation device can be found in the limitations on empathic dialogue generation described above, and will not be repeated here. Each module in the aforementioned empathic dialogue generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0075] This specification also provides a computer-readable storage medium storing a computer program that can be used to execute the above-described... Figure 1 The provided method for generating empathic dialogues.

[0076] This instruction manual also provides Figure 4 The schematic diagram of the computer device shown is as follows: Figure 4 At the hardware level, the computer device includes a processor, internal bus, network interface, memory, and non-volatile memory, and may also include other hardware required for business operations. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it to achieve the above-mentioned functions. Figure 1 The provided method for generating empathic dialogues.

[0077] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0078] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.< / response> < / emotion> < / emotion> < / context> < / emotion> < / context> < / emotion> < / context>

Claims

1. A method for generating empathic dialogue, characterized in that, include: Obtain the target user's contextual dialogue; An initial emotion vector corresponding to the context dialogue is obtained. Based on the similarity between the initial emotion vector and multiple emotion prototype vectors representing different emotion categories, the probability of each emotion prototype vector is determined. The emotion prototype vectors are weighted and fused into a continuous emotion vector according to the probability. Using the continuous emotion vector as a reasoning constraint, the behavioral demands and psychological motivations of the target user are inferred from the context dialogue to obtain explicit surface needs and implicit psychological needs. Based on the contextual dialogue, the explicit surface needs, and the implicit psychological needs, a target empathetic response is generated.

2. The empathic dialogue generation method as described in claim 1, characterized in that, The step of obtaining the initial emotion vector corresponding to the context dialogue includes: Extract discrete emotion tags of the target user from the contextual dialogue; The discrete emotion labels are mapped to the VAD continuous emotion space to obtain the first spatial coordinates; the VAD continuous emotion space consists of three continuous dimensions: efficacy value, arousal value, and dominance value. The efficacy value represents the positive or negative attribute of the emotion, the arousal value represents the intensity attribute of the emotion, and the dominance value represents the sense of control attribute of the emotion; the first spatial coordinates are the combination of values ​​of the discrete emotion labels on the three continuous dimensions. The first spatial coordinates are used as the initial emotion vector.

3. The empathic dialogue generation method as described in claim 2, characterized in that, The steps for obtaining the continuous emotion vector include: The second spatial coordinates of each of the emotion prototype vectors in the continuous emotion space of the VAD are obtained. The second spatial coordinates corresponding to each of the emotion prototype vectors are pre-calibrated by the emotion dictionary. The same emotion prototype vector has a fixed second spatial coordinate in all dialogue scenarios. Calculate the direction cosine values ​​between the first spatial coordinates and each of the second spatial coordinates; The direction cosine values ​​are normalized to obtain the probability of each emotion prototype vector; the second spatial coordinates of each emotion prototype vector are weighted and summed using the probability of each emotion prototype vector as a weight coefficient to obtain the continuous emotion vector; the continuous emotion vector is a fusion coordinate point in the VAD continuous emotion space, used to represent the comprehensive emotional state corresponding to the context dialogue.

4. The empathic dialogue generation method as described in claim 3, characterized in that, The acquisition of explicit surface-level needs and implicit psychological needs is performed through a pre-trained empathic dialogue model, the pre-training of which includes: Obtain the corresponding continuous emotion vectors for multiple historical context dialogues; Using the continuous emotion vectors of each historical context dialogue as inference constraints, a large language model with a parameter scale of hundreds of billions or more is used to infer each historical context dialogue, generating multiple response inference chains. The response inference chains include continuous emotion vectors, explicit surface needs, implicit psychological needs, and empathetic responses. The quality of the multiple response inference chains is scored using multiple preset evaluation models. Based on the consistency of the scoring results of each evaluation model, the multiple response inference chains are divided into high-confidence response inference chains and low-confidence response inference chains. A hierarchical reasoning dataset is constructed by preserving the complete high-confidence response reasoning chain and filtering out the implicit psychological needs in the low-confidence response reasoning chain. A lightweight large language model is trained based on the hierarchical reasoning dataset to obtain an empathic dialogue model.

5. The empathic dialogue generation method as described in claim 4, characterized in that, The process involves using continuous emotion vectors from each of the historical context dialogues as inference constraints, and employing a large language model with hundreds of billions or more parameters to infer the meaning of each historical context dialogue, including: Each of the aforementioned historical context dialogues is assembled into a prompt text containing a scene description, a sequence of user statements, and annotation instructions; Based on the prompt text, the large language model extracts key events and emotional expression words from the user's statements in the current historical context of the dialogue to obtain the emotion inference result. The large language model uses the emotion reasoning result as context to extract the user's directly expressed action goal or information query from the current historical context dialogue to obtain the explicit surface demand. The large language model uses the emotion inference result and the explicit surface needs as a joint context to infer the underlying psychological motivations driving the user's current expressive behavior and obtain the implicit psychological needs. The large language model uses the emotion reasoning result, the explicit surface needs, and the implicit psychological needs as a joint context to generate a response reasoning chain that matches the implicit psychological needs.

6. The empathic dialogue generation method as described in claim 4, characterized in that, The process of training a lightweight large language model based on the hierarchical inference dataset to obtain an empathic dialogue model includes: In the first training phase, each sample in the hierarchical reasoning dataset is assembled into an input-target sequence according to a preset structured label format. The preset structured label format includes a label header and a label tail corresponding to the emotion reasoning result, explicit surface needs, implicit psychological needs, and empathic responses, respectively. Based on the input-target sequence, the lightweight large language model is supervised and fine-tuned using an autoregressive generation method. By minimizing the probability difference between the reasoning sequence generated by the lightweight large language model and the target sequence in the hierarchical reasoning dataset, the lightweight large language model learns the structured output format and basic logic for emotion reasoning, explicit surface needs reasoning, implicit psychological needs reasoning, and empathic responses. In the second training phase, the lightweight large language model after supervised fine-tuning is used as the initial policy model. The proximal policy optimization algorithm is used to train the initial policy model through reinforcement learning. During the training process, a reward value is calculated for each response generated by the lightweight large language model. The reward value is calculated according to a reward function, which includes at least a format correctness reward and a sentiment consistency reward. The parameters of the lightweight large language model are updated with the reward value as the optimization objective, so that the output behavior of the lightweight large language model is aligned with the preset reward standard. The lightweight large language model after completing the second training phase will be used as the empathic dialogue model.

7. The empathic dialogue generation method as described in claim 4, characterized in that, The process of generating a targeted empathetic response based on the contextual dialogue, the explicit surface needs, and the implicit psychological needs includes: The contextual dialogue and the continuous emotion vector are jointly encoded into a model input sequence; The empathic dialogue model, based on the input sequence, sequentially generates emotion inference results, explicit surface needs, implicit psychological needs, and a final empathic response using an autoregressive approach. Each generation step is conditional upon the content generated in the preceding step. The emotion inference result is a classification mapping of the continuous emotion vector onto a preset emotion category. The explicit surface needs are generated with the emotion inference result as a contextual constraint. The implicit psychological needs are generated with both the emotion inference result and the explicit surface needs as contextual constraints. The final empathic response is generated with the emotion inference result, the explicit surface needs, and the implicit psychological needs as contextual constraints. The emotion inference results, the explicit surface needs, the implicit psychological needs, and the final empathic response are output in a preset structured tag format, which includes a tag header and a tag footer corresponding to each output content.

8. A device for generating empathic dialogue, characterized in that, include: The data acquisition module is used to acquire the contextual dialogue of the target user; The reasoning module is used to obtain the initial emotion vector corresponding to the context dialogue, determine the probability of each emotion prototype vector based on the similarity between the initial emotion vector and multiple emotion prototype vectors representing different emotion categories, and weight and fuse each emotion prototype vector into a continuous emotion vector according to the probability. Using the continuous emotion vector as a reasoning constraint, the module infers the behavioral demands and psychological motivations of the target user from the context dialogue to obtain explicit surface needs and implicit psychological needs. The dialogue generation module is used to generate a target empathetic response based on the contextual dialogue, the explicit surface needs, and the implicit psychological needs.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the empathic dialogue generation method as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the empathic dialogue generation method as described in any one of claims 1 to 7.