Psychological counseling system based on large language model and automatic generation of user portrait
By deploying a large language model for psychological counseling and a dynamic user profiling system locally, the system addresses the issues of insufficient professionalism, weak personalization, and privacy risks in existing psychological counseling systems. This enables professional and personalized psychological counseling services, improving counseling quality and user trust.
Patent Information
- Application Number
- CN202511429535.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-30
- Publication Date
- 2026-02-24
AI Technical Summary
Existing psychological counseling systems based on large language models suffer from insufficient professionalism, weak personalization, and privacy risks. General models lack professional guidance, static user profiles cannot capture users' emotional fluctuations, and calls to third-party cloud services pose a risk of data leakage.
The system employs a locally deployed large language model for psychological counseling, dynamically generates multi-dimensional user profiles through dialogue history, adjusts dialogue logic in closed-loop interactions, and displays user profiles using a visualization explanation module. This ensures that the model follows professional counseling procedures and eliminates the risk of data leakage.
It has enabled professional and personalized psychological counseling services, provided precise responses, improved counseling quality and user trust, reduced the risk of privacy leaks, and enhanced system transparency and adaptability.
Smart Images

Figure CN121565388A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of psychological counseling technology, specifically a psychological counseling system based on large language models and user profiles that are automatically generated. Background Technology
[0002] With the expansion of the global population suffering from sub-optimal mental health and the imbalance between supply and demand for traditional psychological counseling resources, digital psychological counseling systems based on artificial intelligence technology are gradually becoming an important direction to supplement traditional services. Among them, "psychological counseling systems based on large language models and user profiles" is one of the core solutions currently being focused on in the field. It aims to achieve the large-scale and normalized supply of psychological counseling services through the natural dialogue capabilities of large language models and the personalized analysis capabilities of user profiles.
[0003] In existing technologies, the application of such systems generally follows a simplified logic of "dialogue interaction - basic analysis": large language models often directly adopt general dialogue models (such as ChatGPT, Claude, etc.) or lightweight script-based AI, achieving basic emotional responses only through preset dialogue templates or general semantic understanding; user profiles mostly rely on static information actively filled in by users (such as age, occupation, and basic type of distress), lacking the ability to automatically extract and dynamically update information from the dialogue process; in terms of deployment, most systems choose to call model interfaces through third-party cloud services to reduce the technical and hardware costs of local deployment, with only a few high-privacy scenarios attempting simplified local deployment.
[0004] However, existing technologies have significant shortcomings: First, they lack professionalism. General-purpose language models have not been trained on professional psychological counseling procedures, making them prone to disordered responses and a lack of professional guidance. Script-based AI, on the other hand, is unable to cope with complex psychological needs due to its rigid language. Second, they lack personalization. Static user profiles cannot capture dynamic characteristics such as user emotional fluctuations and cognitive patterns, making it difficult for models to provide accurate responses that match the user's deep background. Third, they pose significant privacy risks. Calling third-party cloud services requires the transmission of sensitive user dialogue data, which poses a risk of data leakage and fails to meet the stringent confidentiality requirements of the psychological counseling field. These problems severely restrict the practical application value of the system. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a psychological counseling system based on large language models and user profiles for automatic generation, which solves the problems of insufficient professional expertise, weak personalization, and privacy risks in psychological counseling.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a psychological counseling system based on large language models and user profiles for automatic generation, comprising:
[0007] Large Language Model for Psychological Counseling: Configured to run a large language model that is trained or fine-tuned for professional psychological counseling knowledge, executes the psychological counseling interaction process and outputs interaction data;
[0008] User profile building module: connected to the psychological counseling big language model, configured to extract user profiles from the psychological feature dimensions of the interaction data;
[0009] Closed-loop interaction module: It is connected to the user profile construction module and the psychological counseling big language model respectively, and is configured to feed back the user profile to the psychological counseling big language model in order to dynamically adjust its psychological counseling interaction logic;
[0010] Visualization Explanation Module: Configured to parse and render the structured user profile into a graphical knowledge representation for display.
[0011] Preferably, the user profile building module extracts information from the dialogue history to generate a user profile by sending a structured extraction instruction to the psychological counseling big language model, and dynamically updates the user profile based on the multi-turn dialogue history.
[0012] Preferably, the psychological characteristics of multiple dimensions include, but are not limited to, at least five of the following: emotional state, cognitive pattern, psychological needs and goals, coping mechanism, and social support relationship.
[0013] Preferably, the closed-loop interaction module dynamically adjusts its dialogue logic by injecting the user profile into the context or system instructions of the psychological counseling big language model.
[0014] Preferred options also include:
[0015] Data storage module: Configured to differentiate between structured interactive data and unstructured profile data;
[0016] Effectiveness evaluation module: configured to evaluate the system's performance using professional indicators of psychological counseling and interactive performance indicators;
[0017] The visualization explanation module is specifically configured to: parse and render the interactive logic explanation information of the structured user profile or psychological counseling language model into a graphical knowledge representation for display, wherein the graphical knowledge representation is a knowledge graph.
[0018] Preferably, the psychological counseling interaction process is oriented towards administrator roles and ordinary user roles, wherein: the administrator role is configured to manage system parameters, monitor profile data, and the running parameters of the psychological counseling big language model; the ordinary user role is configured to initiate psychological counseling interaction and view their own profile information through the visualization explanation module.
[0019] Preferably, the psychological counseling big language model is configured to be deployed and run locally to reduce the risk of privacy leakage of psychological counseling interaction data.
[0020] Preferably, the training data for the psychological counseling big language model includes a professional psychological counseling dataset, which covers real psychological counseling cases and standardized intervention procedures.
[0021] Preferably, the data storage module is configured to store profile data in association with user unique identifiers, thereby enabling versioned management of user profiles.
[0022] This invention provides a psychological counseling system based on large language models and user profiles for automatic generation. It has the following beneficial effects:
[0023] 1. This invention utilizes a locally deployed, finely tuned psychological counseling language model based on a PsyBP professional dataset (including real-world cases and standardized processes) to ensure that interactions follow the six-stage process of professional counseling. Simultaneously, it automatically generates multi-dimensional dynamic user profiles and injects them into the dialogue, allowing the model to provide accurate responses based on user backgrounds, avoiding repetitive questions and generic replies. Local deployment also eliminates the risk of data leakage, addressing the existing system's lack of professionalism, weak personalization, and privacy concerns, thereby improving counseling quality and user trust.
[0024] 2. This invention uses a visualization module to parse structured profiles and model interaction logic into graphical representations such as knowledge graphs, solving the black box problem of AI decision-making and making it easier for users to understand the evaluation results; the system ensures reliability by verifying the effect through a professional + performance indicator evaluation system and comparative experiments; at the same time, it supports administrators to manage parameters and monitor data, and ordinary users to initiate consultations and view profiles, adapting to the needs of different roles and enhancing the system's transparency and adaptability to practical applications. Attached Figure Description
[0025] Figure 1 This is a system architecture diagram of the present invention;
[0026] Figure 2 This is a diagram illustrating the user file storage structure of the present invention;
[0027] Figure 3 This is a schematic diagram of the overall process for steps two and three of the present invention;
[0028] Figure 4 This is a diagram illustrating the results of expert human evaluation for this invention.
[0029] Figure 5 This is a diagram illustrating the automated evaluation results of the present invention;
[0030] Figure 6 This is an example diagram illustrating the multi-turn dialogue effect of the present invention;
[0031] Figure 7 This is the user profile details interface of the present invention;
[0032] Figure 8 The first conversation comparison image after the portrait was injected into the model in this invention. Detailed Implementation
[0033] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0034] Please see the appendix Figure 1 This invention provides a psychological counseling system based on large language models and user profiles for automatic generation.
[0035] Example 1: Implementation of the System's Core Closed Loop (Core Workflow)
[0036] When a user initiates a psychological counseling dialogue through the front-end interface, the system begins to operate:
[0037] I. Professional Dialogue Interaction: User input is sent to the backend server. The backend invokes a locally deployed psychological counseling language model (e.g., a specialized model based on the Qwen2.5-7B model, fine-tuned using LoRA technology with a professional psychological counseling dataset). This model inherently follows the six-stage process of Single-Session Therapy (① Establishing Relationship ② Problem Exploration ③ Problem Confirmation ④ Explanation and Education ⑤ Strategy Intervention Implementation ⑥ Summary and Outlook), generating a professionally guided response and returning it to the user. This process ensures the professionalism and flow of the interaction, distinguishing it from the disordered dialogue of general chatbots. The typical multi-turn dialogue effect of this system is as follows: Figure 6 As shown, this demonstrates the process of guiding the model from 'empathic reassurance' to 'problem exploration'.
[0038] II. Automated Profile Generation: After several rounds of dialogue, the system can manually or automatically trigger the user profile building module. This module constructs a highly structured extraction prompt, which explicitly requests the extraction of features from the dialogue history across multiple dimensions, such as "emotional state," "cognitive pattern," and "social support." A typical format for this prompt is as follows: Figure 2As shown, this instruction, along with the current user's entire dialogue history, is fed into the aforementioned psychological counseling language model. After analyzing the text, the model outputs a well-structured text report that meets the requirements, i.e., a structured user profile. The generated profile is named 'User Profile_YYYYMMDD_HHMMSS.txt' and stored in the 'user_data / {uid} / portrait / ' directory, thus achieving persistent recording and version management of user status. User profile extraction and structured prompts include:
[0039] You are a professional psychological counselor and text analysis expert. Below, the user will provide you with a complete dialogue. Please extract information based on the following nine points to generate a structured user profile (using either an ordered or unordered list in Markdown format). Do not continue the dialogue, add irrelevant content, or fabricate anything not mentioned in the original record; simply write what is not mentioned.
[0040] 1. Basic information (age, gender, occupation, living conditions);
[0041] 2. Emotional state (emotional changes and fluctuations, the root cause of emotional problems, and whether the user can clearly express their emotions);
[0042] 3. Psychological needs and goals (the patient's psychological needs and treatment goals);
[0043] 4. Coping mechanisms (Observe the patient's coping mechanisms when facing stress, and assess the effectiveness of their emotion regulation and coping strategies);
[0044] 5. Cognitive Patterns (Identify the patient's thinking patterns, self-evaluation, and attribution patterns, and analyze the relationship between their cognitive biases and negative emotions);
[0045] 6. Social support and interpersonal relationships (understanding the patient's social support system and interpersonal interaction patterns to help assess the impact of their social environment on mental health);
[0046] 7. Quality of life (the patient's health status, work stress, and life balance reflect their overall quality of life and psychological state);
[0047] 8. Cognitive and affective tendencies (assessing patients' emotional management abilities and expectations for the future by analyzing their optimistic or pessimistic attitudes);
[0048] 9. Response during consultation (attitude towards the counselor and the advice given).
[0049] III. User Profile Feedback and Application: The closed-loop interaction module begins operation. The system reads the newly generated user profile file and preprocesses it, for example, by adding a guiding text before the text: "The following is a background profile of the current user; please use it as a reference for subsequent dialogues." Subsequently, the module dynamically injects this processed profile text into the ongoing dialogue session. Specifically, this text is appended to the end of the system instruction (SystemPrompt) that guides the model's behavior. The above profile generation-injection process logic is as follows: Figure 3 As shown.
[0050] IV. Personalized Closed-Loop Response: As the user continues the next round of dialogue, their input messages, dialogue history, and enhanced system commands injected into the user profile are all fed into the model. At this point, the model can "see" and understand the user's deep background, thus providing a highly personalized response: it may no longer ask for known basic information, but can correlate the user's current emotional fluctuations with long-term cognitive patterns recorded in the profile, and provide more precise empathy and intervention suggestions. Specifically, without a profile, the model might generate a general response (e.g., "Why aren't you focused on revising your paper?"), while with a profile, it will generate a precise response based on the user's background (e.g., "You mentioned earlier that the experimental data isn't organized yet, and the communication with your supervisor hasn't been resolved. Are these things still causing you a lot of stress, so you're not focused on revising your paper?"). The difference in effect between the two is as follows: Figure 8 As shown. At this point, the system has completed a full closed loop, with each interaction building upon the previous understanding, thus continuously deepening the user's understanding and optimizing the consultation effect.
[0051] Example 2: Visual Explanation of User Profiles (describes how user profiles are transformed from structured text into visual knowledge representations);
[0052] When a user or administrator requests to view a user profile:
[0053] The backend interface calls the parsing function to read the structured text profile generated in Example 1. This text typically has a clear hierarchical relationship (e.g., indicated by indentation).
[0054] The function scans the text line by line, identifies the hierarchy based on indentation, and constructs a tree-like hierarchical data structure in memory. For example, "emotional state" is the root node, and its child nodes are "significant emotional fluctuations" and "root cause is work stress".
[0055] The system then converts this tree structure into a standardized data format required by front-end visualization libraries (such as vis.js, D3.js, ECharts, etc.), for example, a JSON object containing two arrays: nodes and edges. Each node contains attributes such as id and label; each edge contains attributes such as from (source node id) and to (target node id).
[0056] This JSON data is returned to the front end via an API interface. After receiving the data, the front-end JavaScript code calls the rendering engine of the visualization library.
[0057] The visualization library uses algorithms such as Force-Directed Layout to automatically calculate node positions and draw an interactive knowledge graph on the browser canvas. A typical user interface is shown below. Figure 7 As shown, in this visualization, the user ID serves as the central node, each dimension (such as emotional state and cognitive pattern) as a first-level node, and the specific behaviors under each dimension as second-level nodes, all connected by edges. Users can interact with the visualization by dragging, zooming, and clicking to view details, thereby intuitively and deeply understanding the system's evaluation results, greatly enhancing the system's transparency and interpretability. This visualization format can also be replaced with a tree structure or a dimension radar chart.
[0058] Example 3: System Privacy Protection and Model Professionalism (explains how the system protects privacy and ensures model professionalism);
[0059] Privacy Guarantee: The psychological counseling language model and related services (such as profile generation) are deployed on the user's organization's local servers or private cloud environment. All user dialogue data and generated profile data are processed and stored within the internal network, without being transmitted to third-party public cloud APIs. This approach fundamentally eliminates the risk of data leakage to external companies, meeting the extreme requirements for privacy and confidentiality in the field of psychological counseling.
[0060] Model Specialization: The core of this system, the psychological counseling language model, is not a general-purpose model but a product of specialized training. Its training data comes from a meticulously constructed professional psychological counseling dataset (PsyBP dataset). This dataset not only contains a large amount of real psychological counseling dialogue, but more importantly, this data has been reconstructed and labeled according to professional counseling processes (SAT therapy, acceptance and commitment therapy, one-time unit counseling model), ensuring that the model learns standardized counseling logic with therapeutic factors, rather than simple dialogue patterns. This fine-tuning process based on professional data specifically involves: using Qwen2.5-7B as the base model, employing LoRA (low-rank adaptation) technology to fine-tune it for 3 epochs on the PsyBP professional dataset, with a quantization level of 4. During training, a cosine learning rate regulator (initial learning rate 1.0e-5) and 16-bit half-precision floating-point calculations are used—these parameter settings are the technical foundation for the model to output professional and reliable content.
[0061] Example 4: System Performance Verification
[0062] To verify the effectiveness of this system, we designed a comparative experiment:
[0063] Experimental Setup: The system of this invention (using the PsyBPLLM model) was used as the experimental group, and compared with several existing open-source psychological counseling models (such as MindChat, EmoLLM, etc.). All model parameters were standardized to Qwen2.5-7B to eliminate performance differences in baseline models due to parameter limitations. Evaluation Methods: A combination of human expert evaluation and automated evaluation was employed. Human evaluation involved professional psychological counselors scoring the model responses across eight dimensions, including "empathic reassurance," "problem analysis," and "professional guidance." As shown in Table 1, automated evaluation used a high-level large language model (such as ChatGPT-o1), referencing expert evaluation methods and scales. Simultaneously, "process compliance" and "stage transition accuracy" were also evaluated to measure the model's adherence to professional processes.
[0064] To clarify the calculation standards for these two process evaluation indicators, their formulas are defined as follows:
[0065]
[0066] To quantitatively assess the degree to which the large language model of psychological counseling adheres to the professional counseling process, the following assessment rules for "follow-up of dialogue process steps" were developed:
[0067] Predefined consultation process steps (6 stages in total):
[0068] Phase 1 (Initial Assessment Phase): Collect basic user information and build trust through friendly greetings and expressions of empathy;
[0069] Phase 2 (Problem Exploration Phase): Gain a deeper understanding of the details of the user's problem, explore background events, social support, and coping strategies;
[0070] Phase 3 (Problem Confirmation Phase): Comprehensively analyze the dialogue information, clarify the cause of the problem, and reach a consensus with the user;
[0071] Phase 4 (Explanation and Education Phase): Explain the causes and mechanisms of the problem from a psychological perspective, express empathy, and enhance user confidence;
[0072] Phase 5 (Intervention and Strategy Implementation Phase): Propose targeted intervention strategies, encourage users to try different methods, and strengthen social support;
[0073] Phase 6 (Summary and Outlook Phase): Summarize the content of this consultation, acknowledge user progress, express continued support, and form a positive outlook.
[0074] Assessment operation requirements:
[0075] 1. For each dialogue segment, check whether it covers the above 6 stages;
[0076] 2. Calculate the "actual number of process steps followed" using the formula "Dialogue process step compliance rate = (number of process steps followed / 6) × 100%" (expressed as a percentage);
[0077] 3. For each dialogue, briefly explain "the steps that were effectively presented", "the steps that were missing", and "whether the order of the steps was inappropriate".
[0078]
[0079] To quantify the rationality of the transitions between different stages in the psychological counseling big language model, an assessment rule for "stage transition accuracy" was established:
[0080] The assessment object is the transition process between adjacent stages in a dialogue (such as from stage 1 to stage 2, stage 2 to stage 3, etc.).
[0081] Transition Compliance Standards: The transition between stages must be "accurate, natural and in line with the consulting logic", that is, it must be a smooth transition from the current stage to the next reasonable stage (for example, a natural transition from stage 1 "preliminary assessment" to stage 2 "problem exploration", rather than jumping directly from stage 1 to stage 3 "problem confirmation").
[0082] Assessment operation requirements:
[0083] 1. For each dialogue segment, analyze the transition process between all adjacent stages to determine if there is a reasonable stage transition;
[0084] 2. Count the number of conversations that correctly completed the phase transition (the number of transitions that met compliance standards);
[0085] 3. Calculate the result as a percentage using the formula: "Stage Transfer Accuracy = (Number of dialogues correctly transferred to the stage / Total number of dialogues) × 100%";
[0086] 4. For each dialogue segment, briefly explain the "accurate transitions", "problematic transitions" (such as abrupt transitions or reversed order) and "missing transitions".
[0087] Among them, process compliance is used to determine whether the dialogue strictly follows the predetermined stages, and stage transition accuracy is used to evaluate the accuracy of the transitions between stages. We use the advanced large language models ChatGPT-o1 and ChatGPT-o3-mini-high for evaluation, and take the average of the two results as the final evaluation value.
[0088] Table 1. Detailed Explanation of Evaluation Indicators
[0089]
[0091] Experimental Results: Experimental results show that the PsyBPLLM model of this invention significantly outperforms the baseline model in most professional indicators, while maintaining competitiveness in response speed. (See attached document for details.) Figures 4-5 As shown in Tables 2 and 3, this demonstrates that the present invention achieves a good balance between "professionalism" and "efficiency." Furthermore, internal user testing (33 people) showed that over 75% of users expressed "relatively satisfied" or "very satisfied" with the system's functionality, professionalism, and overall satisfaction, and the vast majority of users expressed a willingness to continue using it.
[0092] Table 2 Overall Model Comparison Table
[0093]
[0094] Table 3 Internal Test Evaluation Table
[0095]
[0096] In summary, through the technical solutions described in the above embodiments, the present invention successfully constructs a highly professional, deeply personalized, highly interpretable, and safe and reliable psychological counseling system, effectively overcoming the shortcomings of the prior art.
[0097] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A psychological counseling system based on large language models and user profiles for automatic generation, characterized in that: include: Large Language Model for Psychological Counseling: Configured to run a large language model that is trained or fine-tuned for professional psychological counseling knowledge, executes the psychological counseling interaction process and outputs interaction data; User profile building module: connected to the psychological counseling big language model, configured to extract user profiles from the psychological feature dimensions of the interaction data; Closed-loop interaction module: It is connected to the user profile construction module and the psychological counseling big language model respectively, and is configured to feed back the user profile to the psychological counseling big language model in order to dynamically adjust its psychological counseling interaction logic; Visualization Explanation Module: Configured to parse and render user profiles into graphical knowledge representations for display.
2. The psychological counseling system based on large language models and user profiles for automatic generation as described in claim 1, characterized in that, The user profile building module extracts information from the dialogue history to generate user profiles by sending structured extraction instructions to the psychological counseling big language model, and dynamically updates the user profiles based on the multi-turn dialogue history.
3. The psychological counseling system based on large language models and user profiles for automatic generation as described in claim 1, characterized in that, The psychological characteristics of multiple dimensions include at least five of the following: emotional state, cognitive pattern, psychological needs and goals, coping mechanism, and social support relationship.
4. The psychological counseling system based on large language models and user profiles for automatic generation as described in claim 1, characterized in that, The closed-loop interaction module dynamically adjusts its dialogue logic by injecting user profiles into the context or system instructions of the psychological counseling big language model.
5. The psychological counseling system based on large language models and user profiles for automatic generation as described in claim 1, characterized in that, Also includes: Data storage module: Configured to differentiate between structured interactive data and unstructured profile data; Effectiveness evaluation module: configured to evaluate the system's performance using professional indicators of psychological counseling and interactive performance indicators; The visualization explanation module is specifically configured to: parse and render the interactive logic explanation information of the structured user profile or psychological counseling language model into a graphical knowledge representation for display, wherein the graphical knowledge representation is a knowledge graph.
6. The psychological counseling system based on large language models and user profiles for automatic generation as described in claim 1, characterized in that, The psychological counseling interaction process is open to both administrator and ordinary user roles. The administrator role is configured to manage system parameters, monitor profile data, and the running parameters of the psychological counseling big language model. The ordinary user role is configured to initiate psychological counseling interactions and view their own profile information through the visualization explanation module.
7. The psychological counseling system based on large language models and user profiles for automatic generation as described in claim 1, characterized in that, The psychological counseling big language model is configured to be deployed and run locally to reduce the risk of privacy leakage of psychological counseling interaction data.
8. The psychological counseling system based on large language models and user profiles for automatic generation as described in claim 1, characterized in that, The training data for the large language model of psychological counseling includes a professional dataset of psychological counseling, which covers real psychological counseling cases and standardized intervention procedures.
9. The psychological counseling system based on large language models and user profiles for automatic generation as described in claim 5, characterized in that, The data storage module is configured to store profile data associated with a user's unique identifier, thereby enabling versioned management of user profiles.