Empathetic dialogue generation method and system based on psychological cognitive high-dimensional space
Patent Information
- Application Number
- CN202611092818.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-10-16
AI Technical Summary
这种处理方式导致对话的“共情”多为模式化模仿,缺乏对用户个体深层心理状态(如依恋类型、心理防御机制、核心信念)的深入理解与动态追踪,难以捕捉连续对话中的情绪变化和潜在需求,导致回应流于表面、缺乏针对性
第一,本申请通过引入量化计算,克服了现有模型情感理解表面化、千人一面的技术偏见。
Smart Images

Figure CN122925549A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence in natural language processing, and in particular to a method and system for generating empathic dialogues based on a high-dimensional space of psychological cognition. Background Technology
[0002] In recent years, the development of artificial intelligence (AI), especially large language models, has provided new technological pathways for the field of mental health. Large language models possess powerful language understanding and generation capabilities, can simulate human dialogue, and provide a technological foundation for building psychological support-type intelligent agents.
[0003] However, directly applying generalized large language models to psychological empathic dialogue faces multiple challenges. First, existing AI-powered emotional dialogue systems mostly employ generalized large models in conjunction with surface-level sentiment classifiers (e.g., classifying text as positive, negative, or neutral), or rely on pre-set empathic dialogue templates. This approach results in dialogue "empathy" that is largely patterned imitation, lacking a deep understanding and dynamic tracking of the user's individual psychological state (e.g., attachment style, psychological defense mechanisms, core beliefs). It struggles to capture emotional changes and underlying needs in continuous dialogue, leading to superficial and untargeted responses.
[0004] Secondly, general models and existing systems generally lack an understanding of the boundaries of psychological expertise, making it easy to overstep these boundaries in conversations, such as by offering inappropriate advice. Especially in high-risk scenarios (such as when a user is identified as having self-harm tendencies), improper handling can easily trigger serious secondary risks.
[0005] Therefore, there is an urgent need for an empathic dialogue generation solution that can deeply understand users' deep psychological cognitive state, dynamically select and execute appropriate empathy strategies, and manage professional boundaries and high-risk aspects throughout the entire process, so as to improve the authenticity, professionalism, safety and healing depth of the dialogue.
[0006] The statements herein provide only background information in relation to this invention and do not necessarily constitute prior art. Summary of the Invention
[0007] The purpose of this invention is to provide the underlying core technology of the right brain (empathy and companionship engine). By constructing a quantifiable and computable "high-dimensional feature space of psychological cognition" and combining it with temporal dialogue modeling and fine-tuning technology of large-scale psychological domain models, adaptive and hierarchical professional empathic dialogue generation can be achieved. This addresses the core pain points in the industry where artificial intelligence empathy lacks professional adaptation and is disconnected from intervention, thus building a fundamental technological barrier for professional psychological dialogue generation.
[0008] To achieve the above objectives, this invention proposes a method for generating empathic dialogues based on a high-dimensional space of psychological cognition, comprising the following steps: Receive multi-turn sequential dialogue text from visitors, preprocess the multi-turn sequential dialogue text, and generate a standardized dialogue text sequence; Using a pre-trained deep psychological cognitive feature extraction model, temporal modeling and implicit behavior recognition are performed on the standardized dialogue text sequence to extract behavioral feature vectors. The behavioral feature vector is input into a pre-trained high-dimensional space mapping network to generate a dynamic cognitive profile of the visitor in a preset high-dimensional psychological cognitive space. The dynamic cognitive profile is a feature vector containing quantized labels of multiple dimensions. Based on the dynamic cognitive profile, the optimal empathy strategy is dynamically matched from the pre-built empathy strategy knowledge base; The large language model, fine-tuned with psychological domain data, is invoked to generate empathic dialogue text adapted to the visitor based on the optimal empathy strategy and the dynamic cognitive profile. Before generating the empathic dialogue text, the current dialogue text is scanned in real time using a pre-trained high-risk identification model; when a high-risk is identified, the regular empathic dialogue generation process is blocked, and the process is forcibly switched to a crisis intervention-specific generation path.
[0009] Optionally, the step of using a pre-trained deep psychological cognitive feature extraction model to perform temporal modeling and implicit behavior recognition on the standardized dialogue text sequence, and extracting behavioral feature vectors, specifically includes: The standardized dialogue text sequence is temporally encoded using a temporal attention mechanism to output a temporal semantic feature matrix. The temporal semantic feature matrix is input into a pre-trained implicit defense behavior recognizer to extract behavioral feature vectors containing narrative logic features, defensive behavior features, and automatic thinking features.
[0010] Optionally, the high-dimensional spatial mapping network is a multi-layer fully connected neural network, whose output layer uses the Sigmoid function to normalize the values of each dimension to the 0-1 range, so as to represent the quantitative label values of the visitor in attachment style, psychological defense mechanism, core belief and emotion and narrative dimensions.
[0011] Optionally, the step of dynamically matching the optimal empathy strategy from a pre-built empathy strategy knowledge base based on the dynamic cognitive profile includes: Calculate the cosine similarity between the feature vector of the dynamic cognitive profile and the feature vectors of each strategy in the empathy strategy knowledge base; The strategy with the highest cosine similarity is selected as the optimal empathy strategy; or, when the highest cosine similarity is lower than a preset threshold, the top two strategies with the highest similarity are selected and fused to generate a fused strategy as the optimal empathy strategy.
[0012] Optionally, the invocation of the large language model fine-tuned by psychological domain data, based on the optimal empathy strategy and the dynamic cognitive profile, generates empathic dialogue text adapted to the visitor, including: Based on the optimal empathy strategy and the dynamic cognitive profile, a generation weight matrix is constructed to adjust the word generation probability of the large language model by weighting. The adjusted generation rules are integrated into a structured prompt word template, which is then input into the large language model for dialogue generation. The generated initial dialogue content is validated for compliance using a professional validation model. If the validation fails, the content is regenerated until a compliant empathetic dialogue text is generated.
[0013] Optionally, the large language model fine-tuned by psychological domain data is obtained through the following steps: Obtain desensitized real-world clinical psychological counseling time-series dialogue data and construct a fine-tuned dataset; A hierarchical lightweight fine-tuning strategy is adopted to fine-tune the basic large language model; During fine-tuning, the model is optimized using a multi-task joint loss function, which includes a basic language model loss term, a psychological professional competence alignment loss term, a professional boundary control loss term, and an empathy competence matching loss term.
[0014] On the other hand, this invention also proposes an empathic dialogue generation system based on a high-dimensional space of psychological cognition, comprising: The input and preprocessing module is used to receive multi-turn temporal dialogue text from visitors, perform preprocessing, and generate a standardized dialogue text sequence. The deep feature extraction and mapping module is used to extract behavioral feature vectors from the standardized dialogue text sequence through a pre-trained deep psychological cognitive feature extraction model, and input the behavioral feature vectors into a high-dimensional space mapping network to generate a dynamic cognitive profile of the visitor in a preset psychological cognitive high-dimensional space. The empathy strategy matching module is used to dynamically match the optimal empathy strategy from a pre-built empathy strategy knowledge base based on the dynamic cognitive profile. The dialogue generation module is used to call the large language model that has been fine-tuned by psychological domain data, and generate empathic dialogue text that is suitable for the visitor based on the optimal empathy strategy and the dynamic cognitive profile. The high-risk identification and emergency management module is used to scan the current dialogue text in real time before the dialogue generation module works. When a high-risk risk is identified, the dialogue generation module is forced to switch to the crisis intervention-specific generation path.
[0015] Optionally, the deep feature extraction and mapping module specifically includes: The temporal modeling unit is used to perform temporal encoding on the standardized dialogue text sequence through a temporal attention mechanism and output a temporal semantic feature matrix. The implicit behavior recognition unit is used to extract behavior feature vectors from the temporal semantic feature matrix through a pre-trained implicit defense behavior recognizer. The high-dimensional mapping unit is used to map the behavioral feature vector into the dynamic cognitive profile through a multi-layer fully connected neural network.
[0016] Optionally, the empathy strategy matching module is specifically used to: calculate the cosine similarity between the feature vector of the dynamic cognitive profile and the feature vector of each strategy in the empathy strategy knowledge base, and determine the optimal empathy strategy based on the cosine similarity.
[0017] Optionally, the dialogue generation module specifically includes: The weighting adaptation unit is used to construct and generate a weight matrix based on the optimal empathy strategy and the dynamic cognitive profile, and to adjust the word generation probability of the large language model by weighting. The constraint generation unit is used to integrate the adjusted generation rules into a structured prompt word template, which is then input into the large language model for dialogue generation. The post-validation unit is used to perform compliance verification on the generated preliminary dialogue content using a professional verification model. If the verification fails, it triggers regeneration.
[0018] The specific beneficial effects are as follows: First, this application overcomes the technical bias of superficial and one-size-fits-all sentiment understanding in existing models by introducing quantitative calculations.
[0019] Second, this application uses cosine similarity calculation to accurately match the user's cognitive profile with the strategy feature vectors in the empathy strategy knowledge base, achieving refined and personalized strategy adaptation. This dynamic strategy adjustment based on quantitative psychological characteristics can significantly improve the targeting of dialogue, thereby leading to significant improvements in visitor compliance and the effectiveness of psychological intervention.
[0020] Third, this application provides a safety net for the psychological dialogue system through a high-risk identification and forced path switching mechanism embedded throughout the entire process. Attached Figure Description
[0021] Figure 1 Generate an overall flowchart for adaptive empathic dialogue based on a high-dimensional space of psychological cognition; Figure 2 A flow diagram of emotional stabilization and risk guidance in high-risk crisis intervention scenarios. Detailed Implementation
[0022] The following detailed description, in conjunction with the accompanying drawings and specific embodiments, provides a further detailed explanation of the empathic dialogue generation method and system based on a high-dimensional space of psychological cognition proposed in this invention. The advantages and features of this invention will become clearer from the following description. It should be noted that the accompanying drawings are in a very simplified form and use non-precise proportions, used only to facilitate and clearly illustrate the embodiments of this invention. Please refer to the accompanying drawings to make the objectives, features, and advantages of this invention more apparent and understandable. It should be understood that the structures, proportions, sizes, etc., depicted in the accompanying drawings are only used to complement the content disclosed in the specification, for those skilled in the art to understand and read, and are not intended to limit the implementation conditions of this invention. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in proportions, or adjustments to the size, without affecting the effects and objectives achieved by this invention, should still fall within the scope of the technical content disclosed in this invention.
[0023] To address the aforementioned technical challenges, this paper presents a method for generating empathic dialogues based on a high-dimensional space of psychological cognition. Please refer to [link / reference]. Figure 1 and Figure 2 The process includes the following steps: receiving multi-turn sequential dialogue text from a visitor; preprocessing the multi-turn sequential dialogue text to generate a standardized dialogue text sequence; using a pre-trained deep psychological cognitive feature extraction model to perform temporal modeling and implicit behavior recognition on the standardized dialogue text sequence, extracting behavioral feature vectors; inputting the behavioral feature vectors into a pre-trained high-dimensional space mapping network to generate a dynamic cognitive profile of the visitor in a preset high-dimensional psychological cognitive space, wherein the dynamic cognitive profile is a feature vector containing quantified labels of multiple dimensions; dynamically matching the optimal empathy strategy from a pre-constructed empathy strategy knowledge base based on the dynamic cognitive profile; calling a large language model fine-tuned with psychological domain data to generate empathic dialogue text adapted to the visitor based on the optimal empathy strategy and the dynamic cognitive profile; wherein, before generating the empathic dialogue text, the current dialogue text is scanned in real time using a pre-trained high-risk identification model; when a high-risk is identified, the conventional empathic dialogue generation process is blocked, and a crisis intervention-specific generation path is forcibly switched.
[0024] In one embodiment of this application, the step of performing temporal modeling and implicit behavior recognition on the standardized dialogue text sequence using a pre-trained deep psychological cognitive feature extraction model to extract behavioral feature vectors specifically includes: performing temporal encoding on the standardized dialogue text sequence using a temporal attention mechanism to output a temporal semantic feature matrix; and inputting the temporal semantic feature matrix into a pre-trained implicit defensive behavior recognizer to extract behavioral feature vectors containing narrative logic features, defensive behavior features, and automatic thinking features.
[0025] In one embodiment of this application, the high-dimensional spatial mapping network is a multi-layer fully connected neural network, whose output layer uses the Sigmoid function to normalize the values of each dimension to the 0-1 range, so as to represent the quantitative label values of the visitor in attachment type, psychological defense mechanism, core belief and emotion and narrative dimensions.
[0026] In one embodiment of this application, the step of dynamically matching the optimal empathy strategy from a pre-constructed empathy strategy knowledge base based on the dynamic cognitive profile includes: calculating the cosine similarity between the feature vector of the dynamic cognitive profile and the feature vector of each strategy in the empathy strategy knowledge base; selecting the strategy with the highest cosine similarity as the optimal empathy strategy; or, when the highest cosine similarity is lower than a preset threshold, selecting the top two strategies in terms of similarity for fusion to generate a fused strategy as the optimal empathy strategy.
[0027] In one embodiment of this application, the step of calling a large language model fine-tuned by psychological domain data to generate empathic dialogue text adapted to the visitor based on the optimal empathy strategy and the dynamic cognitive profile includes: constructing a generation weight matrix based on the optimal empathy strategy and the dynamic cognitive profile to adjust the word generation probability of the large language model; integrating the adjusted generation rules into a structured prompt word template and inputting it into the large language model for dialogue generation; and performing compliance verification on the generated preliminary dialogue content through a professional verification model. If the verification fails, the text is regenerated until a compliant empathic dialogue text is generated.
[0028] In one embodiment of this application, the large language model fine-tuned by psychological domain data is trained through the following steps: acquiring desensitized real clinical psychological counseling time-series dialogue data to construct a fine-tuning dataset; employing a hierarchical lightweight fine-tuning strategy to fine-tune the basic large language model; and optimizing the model through a multi-task joint loss function during the fine-tuning process, wherein the multi-task joint loss function includes a basic language model loss term, a psychological professional competence alignment loss term, a professional boundary control loss term, and an empathy competence matching loss term.
[0029] On the other hand, this application proposes an empathic dialogue generation system based on a high-dimensional psychological cognitive space, comprising: an input and preprocessing module for receiving multi-turn temporal dialogue text from a visitor and preprocessing it to generate a standardized dialogue text sequence; a deep feature extraction and mapping module for extracting behavioral feature vectors from the standardized dialogue text sequence using a pre-trained deep psychological cognitive feature extraction model, and inputting the behavioral feature vectors into a high-dimensional space mapping network to generate a dynamic cognitive profile of the visitor in a preset high-dimensional psychological cognitive space; an empathic strategy matching module for dynamically matching the optimal empathic strategy from a pre-constructed empathic strategy knowledge base based on the dynamic cognitive profile; a dialogue generation module for calling a large language model fine-tuned by psychological domain data to generate empathic dialogue text suitable for the visitor based on the optimal empathic strategy and the dynamic cognitive profile; and a high-risk identification and emergency management module for scanning the current dialogue text in real time before the dialogue generation module operates, and forcing the dialogue generation module to switch to a crisis intervention-specific generation path when a high-risk is identified.
[0030] In one embodiment of this application, the deep feature extraction and mapping module specifically includes: The temporal modeling unit is used to perform temporal encoding on the standardized dialogue text sequence through a temporal attention mechanism and output a temporal semantic feature matrix. The implicit behavior recognition unit is used to extract behavior feature vectors from the temporal semantic feature matrix through a pre-trained implicit defense behavior recognizer. The high-dimensional mapping unit is used to map the behavioral feature vector into the dynamic cognitive profile through a multi-layer fully connected neural network.
[0031] In one embodiment of this application, the empathy strategy matching module is specifically used to: calculate the cosine similarity between the feature vector of the dynamic cognitive profile and the feature vector of each strategy in the empathy strategy knowledge base, and determine the optimal empathy strategy based on the cosine similarity.
[0032] In one embodiment of this application, the dialogue generation module specifically includes: a weight adaptation unit, used to construct a generation weight matrix based on the optimal empathy strategy and the dynamic cognitive profile, and to adjust the word generation probability of the large language model by weighting; a constraint generation unit, used to integrate the adjusted generation rules into a structured prompt word template, and input it into the large language model for dialogue generation; and a post-verification unit, used to perform compliance verification on the generated preliminary dialogue content through a professional verification model, and to trigger regeneration if the verification fails.
[0033] The quantitative labels of the high-dimensional space mapping network in attachment style, psychological defense mechanism, core belief and emotion and narrative dimensions include the following: each quantitative label is normalized to the 0-1 range by the Sigmoid function.
[0034] I. Attachment Style Dimension (16 tags in total) 1. Adult attachment classification tags: secure attachment, anxious attachment, avoidant attachment, disorganized attachment.
[0035] 2. Attachment behavior sub-labels: need for intimacy, separation anxiety level, rejection sensitivity, emotional avoidance level, autonomy need intensity, trust in others, self-worth, attachment activation threshold, emotional regulation dependence, interpersonal boundary resilience, fear of intimacy, and level of emotional expression inhibition.
[0036] II. Psychological Defense Mechanisms Dimension (48 tags in total) 1. Mature defense mechanism tags: sublimation, humor, altruism, anticipation, suppression.
[0037] 2. Neurotic defense mechanisms: rationalization, emotional isolation, rationalization, reaction formation, counteraction, displacement, repression.
[0038] 3. Immature defense mechanisms: projection, introversion, regression, splitting, denial, passive aggression, acting out, somatization, fantasy, hypochondria.
[0039] 4. Quantitative tags for defense behavior: defense activation threshold, defense strength, defense switching frequency, defense consistency, defense adaptability, and 27 sub-tags for secondary defense behavior.
[0040] III. Core Belief Dimensions (32 tags in total) 1. Core Belief Classification Tags: Incompetent Core Beliefs, Unlovable Core Beliefs, Worthless Core Beliefs, and Safety Core Beliefs.
[0041] 2. Intermediate Beliefs and Automatic Thinking Tags: 28 quantifiable tags including rule beliefs, assumption beliefs, attitudinal beliefs, catastrophic thinking, absolutist thinking, personalized attribution, black-and-white thinking, emotional reasoning, should statements, and labeling.
[0042] IV. Emotion and Narrative Dimension (32 tags in total) 1. Emotional Sub-labels: Based on Plutchik's emotion wheel, there are 8 basic emotions plus 24 composite emotion labels, which also include quantitative indicators of emotion intensity, frequency of emotion fluctuation, and duration of emotion. 2. Narrative logic tags: 8 tags including narrative coherence, thematic consistency, event attribution tendency, timeline clarity, trauma narrative avoidance, and degree of self-disclosure.
[0043] In a specific implementation scenario, the input dialogue text is: "T-2 round (visitor): I've been feeling like I'm not doing a good job lately. If my boss says even a little something to me, I can't sleep all night. I feel incredibly useless." T-1 (Visitor): I don't dare tell my friends, afraid they'll think I'm being dramatic. I can only keep it to myself, and the more I keep it to myself, the more uncomfortable I feel. T0 round (visitor): I don't even want to go to work anymore. The thought of facing my boss makes me panic. Am I really useless?
[0044] According to the empathic dialogue generation method of this application, the input text is first preprocessed and its features are extracted and mapped to a high-dimensional space. The specific execution process is as follows: 1. Preprocessing: Complete word segmentation and standardization of the dialogue text to obtain the text sequence of the three-round dialogue; 2. Temporal Modeling: Through the temporal attention mechanism, the three rounds of dialogue were temporally encoded to obtain a 768-dimensional temporal semantic feature matrix, which captured the visitor's narrative logic as "negative events → self-denial → social avoidance → emotional deterioration", with a continuous decline in mood and a clear tendency towards self-denial.
[0045] 3. Implicit Behavior Recognition: Through a defensive behavior identifier, a 256-dimensional behavioral feature vector is extracted to identify defensive behavioral characteristics of the visitor, such as "somatization, self-denial, emotional repression, and catastrophic thinking".
[0046] 4. High-dimensional mapping: The 256-dimensional feature vector is input into a pre-trained high-dimensional spatial mapping network. Through forward propagation of the neural network, a 128-dimensional cognitive feature vector is output. The core label quantization results are as follows: a) Attachment type: Anxious attachment 0.82, need for intimacy 0.78, trust in others 0.31; b) Defense mechanisms: repression 0.85, catastrophic thinking 0.91, self-attack 0.88; c) Core beliefs: Valueless core beliefs 0.92, Incompetent core beliefs 0.87; d) Emotional characteristics: sadness 0.86, anxiety 0.90, helplessness 0.88.
[0047] 5. Output: Updated dynamic cognitive profile of the visitor (128-dimensional feature vector).
[0048] Call the large language model (base Llama3-70B, LoRA fine-tuning completed) with psychological domain data, and load the model weights to the inference server.
[0049] Empathy strategy matching and dialogue generation: dynamically matching the optimal empathy strategy from an empathy strategy knowledge base, including: 1. Strategy matching: Through cosine similarity calculation, the highest matching degree between the visitor's cognitive profile vector and the "initial holding empathy" and "emotional mirroring empathy" strategies is 0.94 and 0.91, respectively. The optimal empathy strategy is determined to be initial holding plus emotional mirroring empathy.
[0050] 2. Targeted adaptation: In view of the client's anxious attachment and high self-denial, increase the weight of expressions of emotional acceptance and self-affirmation, and reduce preaching and advice.
[0051] 3. Integration Constraints: The professional boundary constraints of "acceptance without judgment, emotional mirroring, not denying feelings, and not forcibly giving advice" are input into the model for generation.
[0052] 4. Generate output dialogue: "I can sense that you're going through a lot right now, trapped by self-doubt, and even having to be careful when confiding in those around you. You must have accumulated so much resentment. Not being able to sleep all night after your boss pointed out your problems, and feeling anxious at the thought of going to work—these aren't you being dramatic; your emotions are reminding you that you've been holding on for far too long. You're not useless at all; it's already incredibly difficult for you to have endured so much pressure until now." The high-risk identification model detects the dialogue text, with a risk probability value of 0.12, indicating no high risk. It outputs the dialogue content normally and updates the current dialogue to the temporal dialogue library for dynamic updates of the cognitive profile in the next round.
[0053] The specialized psychological expertise alignment loss function in this invention is a multi-task joint loss function used to constrain model generation during model fine-tuning. The complete formula, parameter meanings, and calculation logic are explained in detail below: I. Overall formula of loss function L total = αL LM + βL prof + γL boundary + δL empathy in, L total For the total loss function, α , β , c , d The weighting coefficients for each sub-loss term are preferably set as follows in this scheme: α =0.4, β =0.3, c =0.2, d =0.1, which can be dynamically adjusted based on the training effect.
[0054] II. Detailed Explanation of Each Sub-Loss Item 1. Loss term of basic language model L LM Meaning: The autoregressive language model loss of a general large language model uses the cross-entropy loss function to ensure the fluency and semantic coherence of the text generated by the model, and to conform to the logic of natural language expression.
[0055] formula: in, N The total number of tokens used to generate the text. X Input for the dialogue context, For generating the text, the first i One token, Generate the first for the model i The probability of each token.
[0056] 2. Loss Items Related to Alignment of Psychological Professional Competence L prof Meaning: Core loss term, used to constrain the content generated by the model to meet the requirements of evidence-based intervention in psychological counseling, ensuring that the generated dialogue contains the preset core intervention points and is aligned with the professional goals of psychological counseling.
[0057] formula: =1- Jaccard similarity was used for calculation, where G Generate intervention point semantic vectors for the model. K The semantic vectors of the core points of evidence-based intervention are preset. After extracting the semantic vectors through a pre-trained language model, the ratio of the intersection to the union is calculated. The smaller the loss value, the higher the alignment between the generated content and the intervention points.
[0058] 3. Losses related to professional boundary control L boundary Meaning: This is used to constrain the content generated by the model from exceeding the professional boundaries of psychological counseling, and to avoid the inclusion of medical advice, diagnoses, illegal or irregular content, or overstepping of boundaries.
[0059] formula: in, M This represents the total number of prohibited words / semantic categories at the professional boundary. Generate text for the model in the firstj Matching score (0-1 interval) on the semantic level of prohibited categories. T The prohibited threshold is set to 0.3 in this scheme; when prohibited semantics appear in the generated content and the score exceeds the threshold, a corresponding loss value is generated to constrain the model to avoid prohibited content.
[0060] 4. Empathy ability matching loss items L empathy Meaning: Used to constrain the empathy strategy and degree of empathy in the content generated by the model, and to match them with the client's cognitive profile and consultation stage, so as to achieve adaptive empathy.
[0061] formula: = MSE ( ) Mean squared error loss is used, where Generate empathy strategy feature vectors for the text for the model. The optimal empathy strategy feature vector is used to match the target. MSE is used to calculate the mean squared error between these two feature vectors. The smaller the loss value, the higher the matching degree between the empathy strategy of the generated content and the target strategy.
[0062] In some embodiments, this application may be implemented using the following specific implementation methods.
[0063] Step 1: Detailed Implementation of Deep Feature Extraction and High-Dimensional Dynamic Mapping for Temporal Dialogue 1. Input: The system receives multi-turn time-series dialogue text between the visitor and the system. The data format includes turn ID, user ID, dialogue text, timestamp, and dialogue role (visitor or counselor).
[0064] 2. Preprocessing: The system performs word segmentation, stop word removal, punctuation standardization, colloquial text correction, and desensitization on the dialogue text to obtain a standardized dialogue text sequence.
[0065] 3. Temporal Modeling: The system introduces a temporal attention mechanism to construct a sliding dialogue window with a window length of 10 rounds. It performs temporal encoding on multi-round dialogues and outputs a temporal semantic feature matrix of the dialogue, focusing on capturing changes in narrative logic, language expression patterns, and emotional fluctuation trajectories across rounds.
[0066] 4. Implicit Behavior Recognition: The system uses pre-trained implicit defensive behavior recognizers based on BERT and CRF structures to identify temporal semantic feature matrices, extracting defensive behavior features, narrative logic features, and automatic thought features from the dialogue, and outputting a 256-dimensional behavior feature vector. BERT and CRF are two classic deep learning models in the field of Natural Language Processing (NLP).
[0067] 5. High-dimensional space mapping: The system inputs the behavioral feature vector into the pre-trained psychological cognition high-dimensional space mapping network (3-layer fully connected neural network) and outputs 128-dimensional quantized label values of the visitor's four dimensions, completing the high-dimensional space dynamic mapping.
[0068] 6. Output: The system generates a dynamic, personalized cognitive profile of the visitor (including a 128-dimensional high-dimensional feature vector and quantized label values) and updates it to the user profile database in real time.
[0069] Step Two: Detailed Implementation of Fine-tuning the Professional Capabilities of Vertical Domain Large Models Based on Massive Real Data 1. Fine-tuning preparation: The base model adopts an open-source general-purpose large language model (Llama3-70B, Qwen2-72B, ChatGLM3-66B are optional) as the base model for fine-tuning.
[0070] 2. Dataset Construction: The system constructs a fine-tuned dataset based on anonymized real clinical psychological counseling dialogue data. This dataset contains 120,000 rounds and 32,000 hours of real psychological counseling dialogues, divided into training, validation, and test sets in an 8:1:1 ratio; the annotations cover dialogue context, counselor empathetic responses, key points of psychological intervention, professional boundary rules, and intervention effect scores.
[0071] 3. Fine-tuning strategy implementation: The system adopts a hierarchical lightweight fine-tuning (LoRA) strategy, which only fine-tunes the low-rank matrices of the attention layer and feedforward neural network layer of the base model (rank is set to 8, α is set to 16, and dropout is set to 0.05), freezing more than 98% of the backbone parameters of the base model to reduce fine-tuning costs and overfitting risks.
[0072] 4. Professional Competency Alignment: During training, the system employs a specially designed psychological professional competency alignment loss function, combined with intervention effects, for RLHF (Reinforcement Learning Based on Human Feedback) optimization. The training epoch is set to 10, and the learning rate is set to 2e-4 (i.e., 2 × 10⁻⁴). -4 It employs the AdamW optimizer to achieve model fine-tuning and alignment with professional capabilities.
[0073] 5. Output: The system outputs a large language model that has completed the fine-tuning of psychological domain data. This model has the core capabilities of professional empathic expression in psychological counseling, integration of evidence-based intervention key points, and adherence to professional boundaries.
[0074] Step 3: Detailed Implementation of Hierarchical Adaptive Empathy and Generative Alignment for Cognitive Space Matching 1. Input: The system receives real-time updated 128-dimensional cognitive profiles of visitors, current consultation stage tags, current dialogue context, key points of evidence-based intervention, and professional boundary control rules.
[0075] 2. Empathy Strategy Matching: The system constructs an empathy strategy matching knowledge base. Through cosine similarity calculation, it matches the visitor's current cognitive profile vector with the strategy feature vector in the strategy base and outputs the optimal empathy strategy.
[0076] 3. Targeted Generation and Adaptation: For clients with high defensiveness, the system automatically reduces exploratory expressions and increases the weight of acceptance, holding, and empathy; for clients with anxious attachment, the system increases the weight of emotional mirroring and security confirmation expressions; for clients with avoidant attachment, the system reduces emotional intensity and increases the weight of boundary respect and rhythm adaptation expressions, thereby achieving targeted generation.
[0077] 4. Empathy-Evidence-Based Fusion Alignment: Through a constraint fusion algorithm, the system uses the core points of evidence-based intervention and professional boundary control rules as mandatory constraints during the generation of the large model. It constructs a two-layer mechanism of "prompt constraint template and post-generation verification" to ensure that the generated empathy dialogue not only conforms to the matching empathy strategy, but also deeply integrates the intervention points, and does not break through professional boundaries.
[0078] 5. Output: The system outputs adaptive empathetic dialogue text that meets professional requirements.
[0079] Step Four: Specific Implementation Methods for Professional Boundary Control and Emergency Response Generation in High-Risk Scenarios 1. Input: The system receives the current visitor's dialogue text and the time sequence characteristics of historical dialogues.
[0080] 2. Real-time detection of high-risk scenarios: The system uses a pre-trained high-risk identification model (a binary classification model built on RoBERTa) to scan the dialogue text in real time and output risk probability values; when the risk probability value is ≥0.85, the system determines that the scenario is a high-risk scenario.
[0081] 3. Forced Path Switching: Once a high-risk scenario is identified, the system immediately blocks the regular empathic dialogue generation process, forcibly activates the crisis intervention-specific generation path, locks model generation permissions, and only allows the output of dialogue content within the standardized crisis intervention process.
[0082] 4. Emergency Response Generation and Execution: The system generates dialogues step-by-step according to the preset crisis intervention process. a) Generate empathic language for ultimate emotional stabilization, with the core being emotional acceptance, understanding of risky behaviors, and non-judgmental expression, avoiding any didactic, questioning, or negating content.
[0083] b) Automated generation of safety agreement signing guidance scripts to guide visitors to confirm the current safety status, promise not to engage in high-risk behaviors, and clarify emergency contact information.
[0084] c) Reassess the visitor's emotional state and risk level after each round of dialogue. If the emotional state deteriorates and the risk probability value is <0.6, then proceed to continuous safety monitoring and low-intervention protection intervention; if the risk remains high, then a referral script will be generated to guide the visitor to the emergency medical system and psychological crisis intervention hotline, while triggering the human counselor takeover alarm mechanism.
[0085] 5. Output: The system outputs the content of safety and compliance dialogue in high-risk scenarios and simultaneously triggers risk warnings and referral processes.
[0086] Compared with existing technologies, this application provides a method and system for generating empathic dialogue based on a high-dimensional space of psychological cognition. By constructing a quantifiable high-dimensional feature space of psychological cognition, adopting a temporal attention mechanism and neural network mapping technology, combining psychological vertical domain data fine-tuning and dynamic matching of empathy strategies, and full-process high-risk management, it realizes the transformation from surface dialogue to deep psychological state intervention. It effectively solves the industry pain points of existing AI emotional dialogue systems, such as superficial empathy, disconnection from the purpose of psychological intervention, lack of deep quantification capabilities, and uncontrollable professional boundaries.
[0087] The data used in this application comes from offline psychological counseling institutions cooperating with the applicant and its own online psychological service platform. The data totals 32,000 hours and 120,000 rounds of one-on-one psychological counseling dialogue data, covering multiple sub-scenarios of psychological counseling such as individual adult counseling, emotional distress, intimate relationships, workplace psychology, and trauma intervention. All data has been completely anonymized, removing all sensitive personal information such as names, contact information, addresses, and ID numbers, and retaining only the dialogue text content and professional annotation information.
[0088] The data sources for the feature extraction and risk identification model pre-training dataset are divided into two parts: the first is publicly available and compliant psychological labeled datasets, including the CLPych psychological counseling dialogue dataset and the DAIC-WOZ depression detection dataset, which are all compliant datasets commonly used in academia and can be directly used for model pre-training; the second is our own labeled datasets, which are based on our own psychological counseling data and labeled by certified psychological counselors. We have constructed four labeled datasets: defense mechanism identification, attachment style classification, core belief identification, and high-risk identification, totaling 80,000 labeled data. All the labelers have national level 2 / 3 psychological counselor qualifications, and the labeling results have been cross-validated by two people, with an accuracy rate of ≥95%.
Claims
1. A method for generating empathic dialogue based on a high-dimensional space of psychological cognition, characterized in that, Includes the following steps: Receive multi-turn sequential dialogue text from visitors, preprocess the multi-turn sequential dialogue text, and generate a standardized dialogue text sequence; Using a pre-trained deep psychological cognitive feature extraction model, temporal modeling and implicit behavior recognition are performed on the standardized dialogue text sequence to extract behavioral feature vectors. The behavioral feature vector is input into a pre-trained high-dimensional space mapping network to generate a dynamic cognitive profile of the visitor in a preset high-dimensional psychological cognitive space. The dynamic cognitive profile is a feature vector containing quantized labels of multiple dimensions. Based on the dynamic cognitive profile, the optimal empathy strategy is dynamically matched from the pre-built empathy strategy knowledge base; The large language model, fine-tuned with psychological domain data, is invoked to generate empathic dialogue text adapted to the visitor based on the optimal empathy strategy and the dynamic cognitive profile. Before generating the empathic dialogue text, the current dialogue text is scanned in real time using a pre-trained high-risk identification model; when a high-risk is identified, the regular empathic dialogue generation process is blocked, and the process is forcibly switched to a crisis intervention-specific generation path.
2. The method as described in claim 1, characterized in that, The pre-trained deep psychological cognitive feature extraction model performs temporal modeling and implicit behavior recognition on the standardized dialogue text sequence to extract behavioral feature vectors, specifically including: The standardized dialogue text sequence is temporally encoded using a temporal attention mechanism to output a temporal semantic feature matrix. The temporal semantic feature matrix is input into a pre-trained implicit defense behavior recognizer to extract behavioral feature vectors containing narrative logic features, defensive behavior features, and automatic thinking features.
3. The method as described in claim 1, characterized in that, The high-dimensional spatial mapping network is a multi-layer fully connected neural network. Its output layer uses the Sigmoid function to normalize the values of each dimension to the 0-1 range, so as to represent the quantitative label values of the client in attachment style, psychological defense mechanism, core belief and emotion and narrative dimensions.
4. The method as described in claim 1, characterized in that, The step of dynamically matching the optimal empathy strategy from a pre-built empathy strategy knowledge base based on the dynamic cognitive profile includes: Calculate the cosine similarity between the feature vector of the dynamic cognitive profile and the feature vectors of each strategy in the empathy strategy knowledge base; The strategy with the highest cosine similarity is selected as the optimal empathy strategy; or, when the highest cosine similarity is lower than a preset threshold, the top two strategies with the highest similarity are selected and fused to generate a fused strategy as the optimal empathy strategy.
5. The method as described in claim 1, characterized in that, The method involves calling a large language model fine-tuned with psychological domain data, and generating empathic dialogue text adapted to the visitor based on the optimal empathy strategy and the dynamic cognitive profile, including: Based on the optimal empathy strategy and the dynamic cognitive profile, a generation weight matrix is constructed to adjust the word generation probability of the large language model by weighting. The adjusted generation rules are integrated into a structured prompt word template, which is then input into the large language model for dialogue generation. The generated initial dialogue content is validated for compliance using a professional validation model. If the validation fails, the content is regenerated until a compliant empathetic dialogue text is generated.
6. The method as described in claim 1, characterized in that, The large language model, fine-tuned with psychological domain data, is obtained through the following steps: Obtain desensitized real-world clinical psychological counseling time-series dialogue data and construct a fine-tuned dataset; A hierarchical lightweight fine-tuning strategy is adopted to fine-tune the basic large language model; During fine-tuning, the model is optimized using a multi-task joint loss function, which includes a basic language model loss term, a psychological professional competence alignment loss term, a professional boundary control loss term, and an empathy competence matching loss term.
7. A system for generating empathic dialogue based on a high-dimensional space of psychological cognition, characterized in that, include: The input and preprocessing module is used to receive multi-turn temporal dialogue text from visitors, perform preprocessing, and generate a standardized dialogue text sequence. The deep feature extraction and mapping module is used to extract behavioral feature vectors from the standardized dialogue text sequence through a pre-trained deep psychological cognitive feature extraction model, and input the behavioral feature vectors into a high-dimensional space mapping network to generate a dynamic cognitive profile of the visitor in a preset psychological cognitive high-dimensional space. The empathy strategy matching module is used to dynamically match the optimal empathy strategy from a pre-built empathy strategy knowledge base based on the dynamic cognitive profile. The dialogue generation module is used to call the large language model that has been fine-tuned by psychological domain data, and generate empathic dialogue text that is suitable for the visitor based on the optimal empathy strategy and the dynamic cognitive profile. The high-risk identification and emergency management module is used to scan the current dialogue text in real time before the dialogue generation module works. When a high-risk risk is identified, the dialogue generation module is forced to switch to the crisis intervention-specific generation path.
8. The system as described in claim 7, characterized in that, The deep feature extraction and mapping module specifically includes: The temporal modeling unit is used to perform temporal encoding on the standardized dialogue text sequence through a temporal attention mechanism and output a temporal semantic feature matrix. The implicit behavior recognition unit is used to extract behavior feature vectors from the temporal semantic feature matrix through a pre-trained implicit defense behavior recognizer. The high-dimensional mapping unit is used to map the behavioral feature vector into the dynamic cognitive profile through a multi-layer fully connected neural network.
9. The system as described in claim 7, characterized in that, The empathy strategy matching module is specifically used to: calculate the cosine similarity between the feature vector of the dynamic cognitive profile and the feature vector of each strategy in the empathy strategy knowledge base, and determine the optimal empathy strategy based on the cosine similarity.
10. The system as described in claim 7, characterized in that, The dialogue generation module specifically includes: The weighting adaptation unit is used to construct and generate a weight matrix based on the optimal empathy strategy and the dynamic cognitive profile, and to adjust the word generation probability of the large language model by weighting. The constraint generation unit is used to integrate the adjusted generation rules into a structured prompt word template, which is then input into the large language model for dialogue generation. The post-validation unit is used to perform compliance verification on the generated preliminary dialogue content using a professional verification model. If the verification fails, it triggers regeneration.