Psychological counseling simulation method and system based on fine-tuning large language model
Through the psychological counseling simulation method based on the fine-tuning large language model, the problem of low training efficiency of traditional simulation methods is solved, efficient and diverse psychological counseling simulation training is achieved, and users' professional abilities are improved.
Patent Information
- Application Number
- CN202411827810.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-25
AI Technical Summary
Traditional psychological counseling simulation methods have limitations in training efficiency and coverage, especially when there are large numbers of students or wide geographical distribution, face-to-face guidance is expensive and unrealistic.
A psychological counseling simulation method based on a fine-tuned large language model is adopted. By selecting the first simulated role and dialogue scenario by the user, the target large language model is used to generate dialogue content of the second simulated role, and real-time interaction is conducted based on the reply content input by the user, and a psychological counseling simulation report is generated to evaluate the dialogue fluency and emotional recognition accuracy.
It improves the training efficiency and coverage of psychological counseling simulation, provides diversified simulation scenarios and high-level feedback guidance, helps users improve their professional abilities, and solves the problem of low training efficiency in traditional methods.
Smart Images

Figure CN119884297A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a psychological consultation simulation method and system based on a fine-tuned large language model. Background Art
[0002] In the field of mental health, the learning and practice of psychological counseling techniques are crucial to the growth of counselors.
[0003] However, traditional training methods, such as face-to-face drills or video analysis, are limited in terms of training efficiency and coverage. Especially when the number of trainees is large or geographically dispersed, face-to-face instruction becomes impractical and costly.
[0004] This shows that the psychological counseling simulation method in the relevant technology has the technical problem of low training efficiency. Summary of the invention
[0005] The present invention provides a psychological counseling simulation method and system based on fine-tuning a large language model, which is used to solve the defect of low training efficiency of the psychological counseling simulation method in the prior art, realize accurate simulation of different roles in dialogue scenarios, and provide users with diversified simulation scenarios and feedback guidance.
[0006] The present invention provides a psychological consultation simulation method based on fine-tuning a large language model, comprising the following steps.
[0007] Determine a first simulated role and a dialogue scenario selected by a user; based on the first simulated role and the dialogue scenario, generate dialogue content of a second simulated role through a target large language model; wherein, the first simulated role and the second simulated role include: a counselor and a subject, and the second simulated role is different from the first simulated role; the dialogue scenario is used to simulate the psychological counseling process between the counselor and the subject; in response to the user inputting the reply content of the first simulated role to the dialogue content, generate interactive content of the second simulated role through the target large language model based on the reply content; perform question and answer analysis based on the dialogue content, the reply content and the interactive content to obtain a psychological counseling simulation report, wherein the psychological counseling simulation report is used to evaluate the dialogue fluency and emotion recognition accuracy of the first simulated role.
[0008] According to a psychological counseling simulation method based on a fine-tuned large language model provided by the present invention, before generating the dialogue content of the second simulated character through the target large language model based on the first simulated character and the dialogue scene, the method also includes: based on the psychological counseling corpus dataset in question-and-answer mode, repeatedly performing the following process until a preset number threshold is reached, and determining the fine-tuned large language model with the highest evaluation score as the target large language model, wherein the psychological counseling corpus dataset has been divided into a training set and an evaluation set according to a preset ratio: based on the training set, fine-tuning the pre-trained large language model through low-rank matrix decomposition and quantization to obtain a fine-tuned large language model; inputting the evaluation set into the fine-tuned large language model to obtain a generated text and a generated summary output by the fine-tuned large language model; based on the generated text and the generated summary, determining the evaluation score of the fine-tuned large language model, wherein the evaluation score is determined by at least one generation task evaluation indicator, and the generation task evaluation indicators include: comprehensive matching score, recall summary evaluation score, confusion, diversity, and type tag ratio score.
[0009] According to a psychological counseling simulation method based on a fine-tuned large language model provided by the present invention, before determining the evaluation score of the fine-tuned large language model based on the generated text and the generated summary, the method also includes: determining the number of matching words and the number of non-matching words between the generated text and the reference text in the evaluation set; determining the ratio between the number of matching words and the total number of words in the generated text as the precision rate; determining the ratio between the number of matching words and the total number of words in the reference text as the recall rate; determining an F2 score based on the precision rate and the recall rate, wherein the F2 score is a weighted balance based on the precision rate and the recall rate; determining a penalty factor based on the number of matching words and the number of non-matching words; and determining a comprehensive matching score of the fine-tuned large language model based on the F2 score and the penalty factor.
[0010] According to a psychological counseling simulation method based on a fine-tuned large language model provided by the present invention, before determining the evaluation score of the fine-tuned large language model based on the generated text and the generated summary, the method also includes: determining a first recall score based on the number of matches of n-tuples between the generated summary and the reference summary in the evaluation set; determining a second recall score based on the longest common subsequence between the generated summary and the reference summary in the evaluation set; determining a first position weight of the longest common subsequence in the generated summary, and determining a second position weight of the longest common subsequence in the reference summary in the evaluation set; determining a third recall score based on the first position weight and the second position weight; and determining a recall summary evaluation score of the fine-tuned large language model based on the first recall score, the second recall score and the third recall score.
[0011] According to a psychological counseling simulation method based on a fine-tuned large language model provided by the present invention, before determining the evaluation score of the fine-tuned large language model based on the generated text and the generated summary, the method further includes: determining a first difference value based on the ratio between the number of different words in the generated text and the total number of words in the generated text; determining a second difference value based on the ratio between the number of different bigrams in the generated text and the total number of bigrams in the generated text; determining the diversity of the fine-tuned large language model based on the first difference value and the second difference value; determining the type-token ratio score of the fine-tuned large language model based on the ratio between the number of types of the generated text and the number of tags of the generated text; and determining the perplexity of the fine-tuned large language model for the evaluation set according to the following formula: ; in, Indicates confusion, represents the total number of words in the evaluation set, represents the first words, Indicates that the fine-tuned large language model is word, predict the The probability of a word.
[0012] According to a psychological counseling simulation method based on a fine-tuned large language model provided by the present invention, the method also includes: obtaining a case consultation text dataset, a subject feedback and evaluation dataset, and a consultation dialogue record dataset, wherein the case consultation text dataset, the subject feedback and evaluation dataset, and the consultation dialogue record dataset have all been pre-converted into a question-and-answer mode; determining the dialogue scene of each case consultation text in the case consultation text dataset; determining the subject emotion of each subject feedback and evaluation in the subject feedback and evaluation dataset; determining the dialogue turn of each consultation dialogue record in the consultation dialogue record dataset; and constructing a psychological counseling corpus dataset in a question-and-answer mode based on the dialogue scene of each case consultation text, the subject emotion of each subject feedback and evaluation, and the dialogue turn of each consultation dialogue record.
[0013] The present invention also provides a psychological consultation simulation system based on a fine-tuned large language model, comprising the following modules: a determination module, for determining a first simulation role and a dialogue scenario selected by a user; A generation module, used to generate the dialogue content of the second simulated character through the target large language model based on the first simulated character and the dialogue scene; wherein the first simulated character and the second simulated character include: a counselor and a subject, and the second simulated character is different from the first simulated character; the dialogue scene is used to simulate the psychological counseling process between the counselor and the subject; an interaction module, used to respond to the user input of the first simulated character's reply to the dialogue content, and generate the interactive content of the second simulated character through the target large language model based on the reply content; an analysis module, used to perform question and answer analysis based on the dialogue content, the reply content and the interactive content to obtain a psychological counseling simulation report, wherein the psychological counseling simulation report is used to evaluate the dialogue fluency and emotion recognition accuracy of the first simulated character.
[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the psychological counseling simulation method based on fine-tuning a large language model as described above is implemented.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the psychological counseling simulation methods based on fine-tuning a large language model as described above.
[0016] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned psychological counseling simulation methods based on fine-tuning a large language model.
[0017] The psychological counseling simulation method and system based on fine-tuning large language model provided by the present invention can be applicable to various psychological counseling situations and meet the needs of different users or training by allowing users to select a first simulated role (counselor or subject) and setting the dialogue scene as a psychological counseling process; the dialogue content of a second simulated role matching the first simulated role can be automatically generated through the target large language model, thereby improving the authenticity and interactivity of the dialogue; the reply content of the first simulated role input by the user is responded to, and the interactive content of the second simulated role is generated through the large language model based on these replies; the real-time interactive mechanism makes the simulation process more dynamic and realistic, which helps users better understand and experience the psychological counseling process; based on the dialogue content, reply content and interactive content, question and answer analysis can be performed, and a psychological counseling simulation report can be generated; not only the dialogue fluency of the first simulated role is evaluated, but also its emotion recognition accuracy is evaluated; thereby solving the technical problem of low training efficiency in the psychological counseling simulation method in the related art. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced one by one below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 It is a flow chart of the psychological consultation simulation method based on fine-tuning the large language model provided by the present invention.
[0020] Figure 2 It is a schematic diagram of the application of the target large language model provided by the present invention in the AI psychological counseling simulation system.
[0021] Figure 3 It is a schematic diagram of the overall process of the psychological consultation simulation method based on fine-tuning the large language model provided by the present invention.
[0022] Figure 4 It is a structural schematic diagram of the psychological consultation simulation system based on the fine-tuning large language model provided by the present invention.
[0023] Figure 5 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] As an auxiliary tool, the psychological counseling simulation system is designed to help mental health practitioners conduct practical training, scenario exercises and improve coping skills. In the field of mental health, the learning and practice of psychological counseling techniques are crucial to the growth of counselors. However, traditional training methods (such as face-to-face exercises or video analysis) are limited in training efficiency and coverage. Especially when the number of trainees is large or the geographical distribution is wide, face-to-face guidance becomes impractical and costly.
[0026] In recent years, the development of large language models (LLMs) in the field of natural language processing has provided new possibilities for psychological counseling simulation. Through training on large-scale text data, LLMs can fluently generate diverse texts and understand complex semantic relationships, greatly improving the system's ability to simulate human language and behavior. Therefore, the psychological counseling simulation system built with large language models can provide an interactive and scenario-rich learning environment for psychological counselors, students, and mental health practitioners, helping them master counseling techniques and improve coping strategies.
[0027] Based on this demand, the present invention proposes a psychological consultation simulation method and system based on fine-tuning a large language model. By fine-tuning the large language model, the system can accurately simulate different roles in the consultation dialogue scenario, provide users with a variety of simulation scenarios and high-level feedback guidance, and help them improve their professional capabilities.
[0028] The present invention proposes a psychological counseling simulation method and system based on a fine-tuned large language model, which aims to provide a multi-dimensional simulation of psychological counseling scenarios through intelligent interaction. By introducing an optimized language model, the scenario reproduction of the real scene can be achieved.
[0029] Optionally, the psychological counseling simulation method based on the fine-tuning large language model of the embodiment of the present application can be executed by a server, or by a terminal device, or jointly by a server and a terminal device, taking the example of the psychological counseling simulation method based on the fine-tuning large language model in this embodiment being executed by a server.
[0030] Figure 1is a flow chart of a psychological consultation simulation method based on fine-tuning a large language model provided by the present invention, such as Figure 1 As shown, the method includes the following steps.
[0031] Step 101, determining a first simulated role and a dialogue scene selected by a user.
[0032] In the embodiment of the present invention, multi-role simulation is supported, covering common consulting dialogue roles (such as consultants, subjects, observers, etc.), and natural dialogue flows are generated through a large language model. The dialogue and emotional state of each role are automatically generated by the large language model to ensure diverse dialogue scenarios.
[0033] Users can select a specific simulated role (such as a novice counselor or a subject with mental health problems) in the visual interface, which will automatically adjust the conversation style and content according to the role characteristics, simulating various emotional reactions and problems that may be encountered in a real consultation process.
[0034] Users can set up different consultation scenarios according to their needs (such as anxiety management, emotional counseling, self-esteem building, etc.). The large language model is used to generate personalized scenarios and dialogue content, providing users with targeted training opportunities.
[0035] For example, a graphical user interface (GUI) or command line interface (CLI) can be used to allow users to select characters and set scenes. GUI can be more intuitive and friendly, while CLI may be more concise and efficient. Scene settings can be implemented through drop-down menus, text boxes, or selection boxes so that users can easily enter or select the required information.
[0036] Step 102: Based on the first simulated character and the dialogue scene, generate the dialogue content of the second simulated character through the target large language model.
[0037] The first simulated role and the second simulated role include: a counselor and a subject, and the second simulated role is different from the first simulated role; the dialogue scene is used to simulate the psychological counseling process between the counselor and the subject; In the embodiment of the present invention, based on the first simulated role and the dialogue scenario selected by the user, the pre-trained large language model is used to generate the dialogue content of the second simulated role. In this scenario, the second simulated role is a role corresponding to the first simulated role, that is, if the first simulated role is a counselor, then the second simulated role is a subject; and vice versa.
[0038] The large language model is trained based on a large amount of psychological counseling dialogue data to capture the language characteristics, communication methods and emotional expressions of counselors and subjects in the dialogue. Therefore, the generated dialogue content should be able to reflect the authenticity and interactivity of the psychological counseling process.
[0039] In the dialogue generation stage, the first simulated role and dialogue scenario selected by the user are used as input, and then the dialogue content of the second simulated role is generated using the large language model. The generated dialogue content can be presented to the user in the form of text, voice or video. At the same time, in response to the user inputting the reply content, the interactive content of the second simulated role is generated based on the reply content to achieve real-time interaction and feedback.
[0040] Step 103 , in response to the user inputting the reply content of the first simulated character to the conversation content, generating the interactive content of the second simulated character through the target large language model based on the reply content.
[0041] In the embodiment of the present invention, dynamic response is supported, and the progress of the consultation dialogue is adjusted in real time according to the user's input. For example, when the user consultant role asks a question, the subject role will respond accordingly according to the preset scenario and user input. This mechanism simulates the real-time interaction in real consultation.
[0042] For example, as the first simulated role (consultant), after receiving the generated initial conversation content, the user will enter the reply content according to his or her own understanding and role setting. The user's reply content is received and processed by the target large language model, including parsing the text information in the reply, identifying the user's intention and emotion, etc.
[0043] Based on the processed reply content, the target large language model is used to generate the interaction content of the second simulated character (subject). The large language model will generate reasonable responses that conform to the character's characteristics based on the previous conversation history, the current reply content, and the character's settings. The generated interaction content of the second simulated character is added to the conversation history to facilitate the generation and understanding of subsequent conversations.
[0044] Finally, the generated interactive content of the second simulated character is presented to the user so that the user can continue to participate in the conversation.
[0045] Step 104, performing question-and-answer analysis based on the conversation content, reply content, and interactive content to obtain a psychological counseling simulation report, wherein the psychological counseling simulation report is used to evaluate the conversation fluency and emotion recognition accuracy of the first simulated character.
[0046] In the embodiment of the present invention, a real-time feedback mechanism is set up to provide multi-level feedback analysis after the consultation dialogue is completed, including consultation skill evaluation (such as listening, empathy, questioning skills), emotion recognition accuracy, conversation fluency, etc., so as to help users improve their consultation skills.
[0047] As a result, users can obtain detailed conversation analysis reports, including changes in psychological states, emotion recognition, etc. This analysis report provides suggestions for improvement, helping counselor trainees to make targeted improvements after each simulation.
[0048] For example, the conversation content of the entire psychological counseling simulation process is collected, including the questions asked by the first simulated character, the responses of the second simulated character, and the subsequent interactive content. Timestamps are added to each part of the conversation to analyze the rhythm and fluency of the conversation. At the same time, key information in the conversation is marked, such as emotional expressions, important points, etc.
[0049] Analyze whether the turn-taking in the conversation is natural and smooth, that is, whether the first simulated character can ask questions or respond to the second simulated character's replies in a timely manner. Evaluate whether the first simulated character's language is coherent and whether it uses appropriate conjunctions and transition sentences to guide the conversation. Analyze the first simulated character's reaction speed after receiving the second simulated character's reply based on the timestamp to evaluate the immediacy and interactivity of their conversation.
[0050] The emotional expressions in the conversation are labeled through a pre-trained neural network model. This can include positive emotions (such as happiness and satisfaction), negative emotions (such as sadness and anger), and neutral emotions. The accuracy of the first simulated character's emotion recognition of the second simulated character is compared with its actual emotional expression. For example, it can be measured by calculating the accuracy or recall rate of emotion recognition. Analyze whether the first simulated character gives appropriate feedback or response after recognizing the emotions of the second simulated character to evaluate its emotion processing ability and empathy.
[0051] In some embodiments, the structure of the psychological counseling simulation report is preset, including an introduction, a conversation fluency analysis, an emotion recognition accuracy analysis, a summary and suggestions, etc. Based on the analysis results, specific feedback and improvement suggestions are provided to the first simulated character to help it improve its conversation fluency and emotion recognition accuracy.
[0052] Through the above steps of the embodiment of the present invention, the user is allowed to select the first simulated role (counselor or subject) and set the dialogue scene as a psychological counseling process that can be applicable to a variety of psychological counseling situations to meet the needs of different users or training; through the fine-tuned target large language model, the dialogue content of the second simulated role that matches the first simulated role can be automatically generated, thereby improving the authenticity and interactivity of the dialogue; the reply content of the first simulated role input by the user is responded to, and the interactive content of the second simulated role is generated through the large language model based on these replies; the real-time interactive mechanism makes the simulation process more dynamic and realistic, which helps users better understand and experience the psychological counseling process; based on the dialogue content, reply content and interactive content, question and answer analysis can be performed, and a psychological counseling simulation report can be generated; not only the dialogue fluency of the first simulated role is evaluated, but also its emotion recognition accuracy is evaluated; thereby solving the technical problem of low training efficiency in the psychological counseling simulation method in the related technology.
[0053] According to a psychological consultation simulation method based on a fine-tuned large language model provided by the present invention, before generating the dialogue content of the second simulated role through the target large language model based on the first simulated role and the dialogue scene, the method further includes: Based on the psychological counseling corpus dataset in the question-answering mode, the following process is repeated until the preset number threshold is reached, and the fine-tuned large language model with the highest evaluation score is determined as the target large language model, where the psychological counseling corpus dataset has been divided into a training set and an evaluation set according to a preset ratio: Based on the training set, the pre-trained large language model is fine-tuned through low-rank matrix decomposition and quantization to obtain a fine-tuned large language model; Input the evaluation set into the fine-tuned large language model to obtain the generated text and generated summary output by the fine-tuned large language model; Based on the generated text and generated summary, the evaluation score of the fine-tuned large language model is determined, where the evaluation score is determined based on multiple generation task evaluation indicators, including: comprehensive matching score, recall summary evaluation score, perplexity, diversity, and type tag ratio score.
[0054] Here, the comprehensive matching score is the METEOR score, the recall summary evaluation score is the ROUGE score, and the TTR score is the type tag ratio score; In this embodiment of the present invention, 80% of the data is randomly selected from each round of fine-tuning data set as a training set, 10% as a validation set, and 10% as a test set; the following resources and environment are used to fine-tune the pre-trained large language model: Ubuntu20.04 operating system, PyTorch; CUDA12.3; TensorBoard monitoring and logging; server configuration: IntelXeon8375c*2; 512G memory; A100 (80G video memory)*8; configure config file parameters, including data storage path, SFT fine-tuning parameters, etc.; execute train.py and monitor logs.
[0055] In some embodiments, Q-LoRA (Quantized Low-Rank Adaptation) is an efficient fine-tuning method, mainly used for fast adaptation and fine-tuning of large pre-trained models. It combines low-rank adaptation (LoRA) and quantization technology to reduce the computational overhead and memory usage when fine-tuning the model.
[0056] Q-LoRA introduces low-rank matrix decomposition to adjust the parameters of the pre-trained large language model, while using quantization technology to reduce the memory footprint of the model. In this way, fine-tuning can be performed effectively even when the graphics memory is limited.
[0057] Low-rank matrix factorization is a technique that decomposes a high-dimensional matrix into the product of two or more low-dimensional matrices. In deep learning models, weight matrices usually have very high dimensions, which leads to a large number of parameters and computations. Through low-rank matrix factorization, these high-dimensional matrices can be approximated as the product of low-dimensional matrices, thereby reducing the number of parameters and simplifying the calculation.
[0058] In some embodiments, a weight matrix in a pre-trained large language model is subjected to low-rank matrix decomposition to obtain two or more low-dimensional matrices. The decomposed low-dimensional matrix is used to reconstruct the original weight matrix. For example, commonly used low-rank matrix decomposition methods include singular value decomposition (SVD), non-negative matrix decomposition (NMF), etc.
[0059] The model output of the pre-trained large language model can be expressed by the following formula: in, represents the model output of the pre-trained large language model, represents the model input of the pre-trained large language model, Represents the forward propagation function of the pre-trained large language model; represents the raw parameters of the pre-trained large language model, represents the parameter changes generated by low-rank adaptation.
[0060] Low-rank adaptation can refer to the following formula: in, represents the parameter change of low-rank adaptation generation, They are represented as different low-rank matrices, which are usually initialized randomly with a small scale.
[0061] The quantization process can refer to the following formula: in, Indicates that the original parameters , converted into quantized parameters , to reduce computational requirements.
[0062] Quantization is a method of converting model parameters from high precision (such as 32-bit floating point numbers) to low precision (such as 8-bit integers), which can significantly reduce the model's memory footprint and computational requirements while maintaining good model performance.
[0063] In some embodiments, the parameters of the pre-trained large language model are converted from high precision to low precision through a quantization function. The quantization function can map the original parameter values to the quantized values.
[0064] In an embodiment of the present invention, a quantization function is used to reduce the memory usage of a pre-trained large language model, and the quantization function may be normal distribution 4-bit quantization and double quantization.
[0065] 4-bit NormalFloat Quantization can be expressed as: in, represents the quantization level, Represents the standard normal distribution The quantile function of Indicates the number of quantization bits, Represents the index of the quantization level, from 0 to , which is used to estimate the boundaries of each quantization interval. By calculating the quantiles of the standard normal distribution, the data distribution is compressed into a fixed interval range. This method ensures that each interval of the data has the same number, thereby optimizing the information theoretical representation efficiency.
[0066] Double Quantization can be expressed as: represents double quantization, Represents the initial data or coefficients stored in 32-bit floating point (FP32) format. Indicates that The data or coefficients obtained after quantization to k bits (k-bit). Here k is a positive integer representing the number of quantization bits; Represents a k-bit wide weight or parameter for further quantization or processing; Dequantization (or decoding) of quantized data, i.e., converting quantized data back to values closer to the format or range of the original data; Represents 4-bit wide weights or parameters.
[0067] Here, the 32-bit floating point number Quantized to k bits, we get ; Then, the k-bit quantized result is dequantized to obtain an intermediate value; then, this intermediate value and the 4-bit wide weight are used Some form of calculation or weighting is performed; finally, the calculation result is dequantized (or possibly another form of conversion) to obtain the final "double quantization" result.
[0068] In an embodiment of the present invention, the preprocessed data set is divided according to a preset ratio (such as 80% training set, 10% evaluation set, and 10% test set, and the specific ratio can be adjusted according to actual conditions).
[0069] Ensure that the training set, evaluation set, and test set are consistent in terms of topic distribution, question types, etc. to avoid data bias.
[0070] Perform low-rank matrix decomposition on the pre-trained large language model to reduce the complexity of the model and reduce the amount of computation. Quantize the decomposed matrix to further compress the model and accelerate the inference process.
[0071] The pre-trained model is fine-tuned using the question-answering data in the training set to better adapt it to the question-answering task in the field of psychological counseling. During the fine-tuning process, hyperparameters such as learning rate and batch size can be adjusted to optimize model performance.
[0072] The questions in the evaluation set are input into the fine-tuned large language model to obtain the answer text and summary generated by the model. Ensure that the generated text and summary are reasonable in terms of grammar, semantics, and logic, and consistent with relevant knowledge in the field of psychological counseling.
[0073] The generated text and summary are evaluated based on multiple generation task evaluation indicators (such as METEOR score, ROUGE score, perplexity, diversity, and TTR score). The METEOR score is used to evaluate the similarity between the generated text and the reference text; the ROUGE score is used to evaluate the quality between the generated summary and the reference summary; the perplexity is used to measure the grammatical and semantic fluency of the generated text; the diversity is used to evaluate the richness of the generated text in vocabulary and sentence structure; the TTR score (Type-Token Ratio) is used to measure the diversity of vocabulary usage in the generated text. The performance of the fine-tuned large language model is determined based on the comprehensive score of these evaluation indicators.
[0074] The fine-tuning and evaluation process is repeated until the preset number of times is reached or the model performance is no longer significantly improved. In each iteration, the model is fine-tuned according to the evaluation score, and different hyperparameters and training strategies are tried to optimize the model performance.
[0075] After all iterations are completed, the fine-tuned large language model with the highest evaluation score is selected as the target large language model to ensure that the target large language model has excellent performance and stability in question-answering tasks in the field of psychological counseling.
[0076] Through the embodiments of the present invention, combined with low-rank matrix decomposition and quantization technology, the number of parameters and memory usage of the pre-trained model can be effectively reduced, so that it can be effectively fine-tuned even in a low-memory environment. This not only helps to reduce the deployment cost of the model, but also improves the flexibility and scalability of the model.
[0077] According to a psychological consultation simulation method based on fine-tuning a large language model provided by the present invention, before determining the evaluation score of the fine-tuned large language model based on the generated text and the generated summary, the method also includes: Determine the number of matching words and non-matching words between the generated text and the reference text in the evaluation set; Determine the ratio between the number of matching words and the total number of words in the generated text as the precision; Determine the ratio between the number of matching words and the total number of words in the reference text as the recall rate; Determine the F2 score based on precision and recall, where the F2 score is a weighted balance between precision and recall; Determining a penalty factor based on the number of matching words and the number of non-matching words; Based on the F2 score and the penalty factor, the comprehensive matching score of the fine-tuned large language model is determined.
[0078] In the embodiment of the present invention, the comprehensive matching score, namely the METEOR score (Metric for Evaluation of Translation with Explicit ORdering), is an indicator for automatically evaluating the quality of text generation, and is particularly widely used in machine translation tasks. METEOR is designed to overcome the limitations of some traditional evaluation indicators (such as BLEU), especially it can consider synonyms, word form changes and semantic information, so as to provide a more accurate text similarity evaluation. Determining the METEOR score specifically includes the following steps: Step 1, matching calculation: Calculate the number of matching words (including synonyms and word forms) between the generated text and the reference text.
[0079] Step 2, Precision and Recall: Calculate the precision and recall.
[0080] The calculation of precision and recall can refer to the following formula: in, Indicates the accuracy, represents the number of matching words between the generated text and the reference text in the evaluation set, Indicates the total number of words in the generated text.
[0081] in, represents the recall rate, Indicates the number of matching words. Indicates the total number of words in the reference text.
[0082] Step 3: Determine the F2 score.
[0083] In symptom diagnosis or fraud detection, missing an important positive example (such as a depressed patient or a fraudulent behavior) may lead to serious consequences, so a higher recall rate is required.
[0084] The F2 score is an indicator used in the field of machine learning to evaluate the performance of classification models. The F2 score is a variant of the F1 score. It is based on the two basic indicators of precision and recall, but gives a higher weight to recall. In a binary classification problem, precision indicates the proportion of samples predicted to be positive that are truly positive, while recall indicates the proportion of all samples that are truly positive that are correctly predicted.
[0085] The F2 score can be expressed by the following formula: represents the F2 score, represents the weight factor, represents the recall rate, Indicates accuracy.
[0086] Step 4: Determine the penalty factor.
[0087] In the METEOR scoring, the penalty factor is mainly used to evaluate the fluency and coherence of the word order between the candidate text and the reference text. When there is a large difference between the word order of the candidate text and the reference text, the penalty factor will give a corresponding deduction to reflect the impact of this word order inconsistency on the text quality.
[0088] The penalty factor can be expressed by the following formula: represents the penalty factor, Indicates the number of non-matching words, Indicates the number of matching words.
[0089] Step 5, determine the METEOR score.
[0090] In the embodiment of the present invention, the METEOR score can be expressed by the following formula: in, represents the METEOR score, represents the F2 score, Represents the penalty factor.
[0091] Through the embodiments of the present invention, by combining precision and recall, the quality of the text generated by the model can be comprehensively evaluated, taking into account both accuracy and coverage. The F2 score is a weighted balance of precision and recall, and the emphasis on recall is adjusted by adjusting the weight coefficient. When the generated text is very different from the reference text, the penalty factor will have the effect of reducing the overall score, thereby reflecting the quality problem of the text generated by the model. The METEOR score is calculated based on multiple factors such as precision, recall, and penalty factor. It not only takes into account the word matching between the generated text and the reference text, but also takes into account factors such as the length and content quality of the text. Through the METEOR score, the quality of the text generated by the fine-tuned large language model can be comprehensively and objectively evaluated.
[0092] According to a psychological consultation simulation method based on fine-tuning a large language model provided by the present invention, before determining the evaluation score of the fine-tuned large language model based on the generated text and the generated summary, the method also includes: determining a first recall score based on the number of matches of n-grams between the generated summary and reference summaries in the evaluation set; determining a second recall score based on the longest common subsequence between the generated summary and a reference summary in the evaluation set; Determine a first position weight of the longest common subsequence in the generated summary, and determine a second position weight of the longest common subsequence in the reference summary in the evaluation set; determining a third recall score based on the first position weight and the second position weight; Based on the first recall score, the second recall score, and the third recall score, a recall summary evaluation score of the fine-tuned large language model is determined.
[0093] In an embodiment of the present invention, the recall summary evaluation score, i.e., the ROUGE score, is mainly used to evaluate the summary generation task and calculate the degree of overlap between the generated summary and the reference summary, wherein the ROUGE score includes: ROUGE-N (i.e., the first recall score), ROUGE-L (i.e., the second recall score), and ROUGE-W (i.e., the third recall score).
[0094] ROUGE-N is used to calculate the n-gram overlap between the generated summary and the reference summary, which can be expressed by the following formula: represents the text summary evaluation index N, Indicates the number of n-grams (i.e., n-tuples) that match between the generated summary and the reference summary; Represents the number of all n-grams in the reference summary; represents the sum of all possible n-grams. In actual calculations, this usually means traversing all n-grams in the reference summary and the generated summary and counting their number.
[0095] ROUGE-L is used to calculate the longest common subsequence between the generated summary and the reference summary, which can be specifically expressed by the following formula: represents the text summary evaluation index L, the longest common subsequence (LCS, Longest Common Subsequence) between the generated summary (Y) and the reference summary (X), Indicates a reference summary and generate a summary The length of the longest common subsequence between Indicates a reference summary The module length, Generate summary The module length, Represents the maximum value function.
[0096] ROUGE-W is used to calculate weighted n-gram overlap, taking into account the position information of n-grams.
[0097] Longest Common Subsequence (LCS): LCS refers to the longest sequence that appears in the same order (but not necessarily consecutively) in two sequences. In ROUGE-W, LCS is used to measure the similarity between the generated text and the reference text. ROUGE-W weights LCS to better reflect the importance of the consecutive matching parts in the generated text. This helps to improve the accuracy and reliability of the evaluation results.
[0098] The calculation method of ROUGE-W can specifically include: determining the LCS between the generated text and the reference text; calculating the weighted score based on the matching of words in the LCS. ROUGE-W usually gives higher weights to consecutively matched words to reflect their importance in the generated text; finally, the weighted score is normalized to obtain the final score of ROUGE-W. This score is usually between 0 and 1, and the higher the score, the higher the similarity between the generated text and the reference text.
[0099] Through the embodiment of the present invention, in order to comprehensively evaluate the quality of the generated summary, multiple evaluation indicators including ROUGE-N, ROUGE-L and ROUGE-W are used. These indicators can reflect the similarity and difference between the generated summary and the reference summary from different perspectives.
[0100] According to a psychological consultation simulation method based on fine-tuning a large language model provided by the present invention, before determining the evaluation score of the fine-tuned large language model based on the generated text and the generated summary, the method further includes: Determining a first difference value based on a ratio between the number of different words in the generated text and the total number of words in the generated text; determining a second difference value based on a ratio between the number of different bigrams in the generated text and the total number of bigrams in the generated text; Determining the diversity of the fine-tuned large language model based on the first difference value and the second difference value; Determine the type-token ratio score of the fine-tuned large language model based on the ratio between the number of types of the generated text and the number of tokens of the generated text; Determine the perplexity of the fine-tuned large language model on the evaluation set according to the following formula: ; in, Indicates confusion, represents the total number of words in the evaluation set, represents the first words, It means that the fine-tuned large language model is word, predict the The probability of a word.
[0101] In the embodiment of the present invention, diversity (Distinct-N): The Distinct-N indicator calculates the ratio of different n-grams (i.e., n-tuples) in the generated text, which is used to measure the diversity of the text. Distinct-1 (calculating the diversity of a single word) and Distinct-2 (calculating the diversity of bigrams) are usually used.
[0102] The first distinct value is determined by the following formula: in, represents the first distinct value, represents the number of different words in the generated text, Indicates the total number of words in the generated text.
[0103] The second different value is determined by the following formula: in, represents the second different value, represents the number of different bigrams in the generated text, Represents the total number of bigrams in the generated text.
[0104] A weighted operation is performed on the first different value and the second different value based on a preset weight to determine the diversity of the fine-tuned large language model.
[0105] In the embodiment of the present invention, the Type-Token Ratio (TTR) is used to measure the ratio between types (different words) and tokens (total number of words) in a text. The TTR score can also reflect the diversity of the text, which can be specifically expressed by the following formula: in, represents the type-token ratio (i.e., the type-token ratio score), Indicates the number of types of generated text, Represents the number of tokens in the generated text.
[0106] The higher the TTR, the more different words are used in the description text, and the higher the lexical diversity. Conversely, the lower the TTR, the more repeated words are used in the description text, and the lower the lexical diversity. For shorter texts, TTR may be high because it is difficult to repeat a large number of words in short texts. For longer texts, TTR is usually lower because long texts are more likely to contain repeated words.
[0107] Determine the perplexity of the fine-tuned large language model on the evaluation set according to the following formula: in, Indicates confusion, represents the total number of words in the evaluation set, represents the first words, It means that the fine-tuned large language model is word, predict the The probability of a word.
[0108] In the embodiment of the present invention, perplexity is used to measure the uncertainty of the model on the test data. The lower the perplexity, the more accurate the model's understanding of the text is, and the more the generated text conforms to the context.
[0109] Perplexity can be used as an auxiliary indicator for model tuning to identify the weaknesses of the model on specific tasks. By reducing the perplexity, the performance of the model on the generation task can be further improved.
[0110] Through the embodiments of the present invention, the diversity of vocabulary usage of a fine-tuned large language model when generating text can be evaluated. By calculating the ratio between the number of different words (number of types) and the total number of words (number of tokens) in the generated text, the richness of vocabulary usage of the model when generating text can be intuitively reflected; by calculating the perplexity of the model on the evaluation set, the degree of fit of the model to the data and the fluency and coherence of the generated text can be evaluated.
[0111] According to a psychological consultation simulation method based on fine-tuning a large language model provided by the present invention, the method further includes: Obtain a case consultation text dataset, a subject feedback and evaluation dataset, and a consultation dialogue record dataset, wherein the case consultation text dataset, the subject feedback and evaluation dataset, and the consultation dialogue record dataset have all been pre-converted into a question-answering mode; Determine the dialogue scene of each case consultation text in the case consultation text dataset; determining a subject emotion for each subject feedback and evaluation in the subject feedback and evaluation dataset; Determine the conversation turn of each consultation conversation record in the consultation conversation record dataset; Based on the dialogue scenes of each case consultation text, the emotions of each subject's feedback and evaluation, and the dialogue turns of each consultation dialogue record, a psychological consultation corpus dataset in question-and-answer mode is constructed.
[0112] To fine-tune the large language model, the quantity and quality of the data set are the most critical contents. In the embodiment of the present invention, a large amount of psychological consultation and psychology-related text, audio, and video source data are collected, and the data is sorted and cleaned. The steps are as follows: Data sources: Data sources include actual psychological counseling cases, psychology textbooks, counseling technology training materials, etc., to ensure that the model can generate content and responses consistent with actual counseling scenarios. The model fine-tuning process focuses on the control of semantic understanding and emotional expression to ensure the authenticity and adaptability of the simulation.
[0113] Classification and sorting: Classify the data into psychological counseling case analysis, psychological professional knowledge (theory, school, norms, laws, etc.), convert all into question-and-answer mode, and form themes and rounds; Data cleaning: All expected data will be carefully checked, and non-compliant and poor-quality data will be deleted. The cleaning is completed through system and manual methods. The system based on corpus quality inspection calls multiple large language models to vote, obtains the quality score of each corpus, and is reviewed by psychological industry experts to obtain the final corpus data that meets the requirements.
[0114] Finally, the corpus data is obtained, refer to the following Table 1: Table 1
[0115] In the embodiment of the present invention, a case consultation text dataset is collected, including the dialogue texts in various psychological consultation scenarios. A subject feedback and evaluation dataset is collected, including the subject's feelings and evaluation after the consultation. A consultation dialogue record dataset is collected, including the complete consultation dialogue record.
[0116] Convert the three datasets mentioned above to question-answer mode. This may involve splitting the continuous conversation text into question-answer pairs, or adding additional tags or metadata to existing question-answer pairs. Clean the data to remove noise and irrelevant information.
[0117] For the case consultation text dataset, natural language processing techniques (such as named entity recognition and keyword extraction) are used to determine the conversation scene. For the subject feedback and evaluation dataset, sentiment analysis techniques are used to determine the subject's emotions. For the consultation conversation record dataset, the turn information of the conversation is directly recorded.
[0118] Combine the extracted features with the original data to construct a psychological counseling corpus dataset in question-and-answer mode. Add necessary metadata to each question-and-answer pair, such as dialogue scene labels, emotion labels, and dialogue turn information. Verify the constructed dataset to ensure the accuracy and completeness of the data.
[0119] Through the above steps, a high-quality question-answering psychological counseling corpus dataset can be constructed, providing strong support for the development of an efficient and personalized psychological counseling dialogue system.
[0120] The following describes an example of a psychological counseling simulation method based on a fine-tuned large language model provided by the present invention in an actual application scenario.
[0121] For example, determine the fine-tuned large language model with the highest evaluation score as the target large language model: the average statistical values of the comprehensive 8-round test results are shown in Table 2 below, and the corresponding model is selected based on the best performance round result.
[0122] Table 2
[0123] Based on the results, the model of the last round (8 rounds) is selected as the target large language model.
[0124] refer to Figure 2 , Figure 2 It is a schematic diagram of the application of the target large language model provided by the present invention in the AI psychological counseling simulation system, which includes: counseling exercises, specifically including: background introduction, exercise goals, prompts, a first simulated role, a second simulated role, a user input box, end of exercise, visit interpretation and speech prompts, etc.
[0125] refer to Figure 3 , Figure 3 It is a schematic diagram of the overall process of the psychological counseling simulation method based on fine-tuning the large language model provided by the present invention, which includes original data (audio, video, text related to psychological supervision), data cleaning (including expert review), model training, evaluation and verification (8 rounds of parameter adjustment and training based on the evaluation results), result confirmation and integrated system, and users include psychological counselors.
[0126] The counseling simulation system of the present invention supports role-playing in a variety of psychological situations, allowing users to simulate counseling conversations in different scenarios such as anxiety management, stress coping, and self-esteem building. Compared with traditional training, this system is highly flexible and allows trainees to quickly switch roles and practice skills in different situations.
[0127] With a built-in real-time feedback mechanism, the system can provide comprehensive conversation analysis and improvement suggestions after each simulation. Emotion recognition and instant feedback help counselors master key counseling skills, such as identifying the subject's underlying emotional state and responding appropriately, thereby improving counseling effectiveness.
[0128] The system supports multiple role settings such as consultants and subjects, and can simulate real consultation situations. The collaborative generation of large language models ensures the coherence and authenticity of the interaction, helping users to better apply the skills they have learned in actual consultations.
[0129] The present invention provides an efficient and convenient learning platform for psychological counselors, which can replace some traditional on-site internships. All data are encrypted and anonymized to ensure the security of user privacy and the compliance of system applications.
[0130] The system supports personalized role selection and scenario setting, allowing users to customize consulting scenarios as needed, providing a customized experience that meets practical applications. All user data is strictly protected and anonymized to ensure the security of user privacy.
[0131] Through model fine-tuning, the system supports multiple roles such as consultants, subjects, and observers, forming a highly simulated interactive scenario to help consultant trainees improve their consulting skills. The model optimizes the emotion recognition and feedback mechanism during training, can generate accurate emotion analysis for users, and provide detailed feedback reports after the conversation to help users understand the potential meaning of different emotional states.
[0132] Contains a large number of real consultation dialogue records, covering consultation situations of different topics and emotions. These data help the model accurately understand consultation language, emotional expression and problem handling methods. Consultation skills, psychological intervention methods and professional knowledge are extracted from psychology textbooks and training materials to ensure that the dialogue content generated by the model meets the standards of mental health.
[0133] The psychological counseling simulation system based on the fine-tuning large language model provided by the present invention is described below. The psychological counseling simulation system based on the fine-tuning large language model described below and the psychological counseling simulation method based on the fine-tuning large language model described above can be referenced to each other.
[0134] refer to Figure 4 , Figure 4 It is a structural schematic diagram of the psychological consultation simulation system based on the fine-tuning large language model provided by the present invention.
[0135] A determination module 401 is used to determine a first simulated role and a dialogue scene selected by a user; A generation module 402 is used to generate the dialogue content of the second simulated character through the target large language model based on the first simulated character and the dialogue scene; The first simulated role and the second simulated role include: a counselor and a subject, and the second simulated role is different from the first simulated role; the dialogue scene is used to simulate the psychological counseling process between the counselor and the subject; Interaction module 403, for responding to the user input of the reply content of the first simulated character to the dialogue content, and generating the interaction content of the second simulated character through the target large language model based on the reply content; The analysis module 404 is used to perform question-answer analysis based on the conversation content, reply content and interaction content to obtain a psychological counseling simulation report, wherein the psychological counseling simulation report is used to evaluate the conversation fluency and emotion recognition accuracy of the first simulated character.
[0136] Specifically, the psychological counseling simulation system based on fine-tuning the large language model provided by the present invention can implement all the method steps implemented in the above-mentioned psychological counseling simulation method embodiment based on fine-tuning the large language model, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.
[0137] Figure 5 is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute a psychological counseling simulation method based on a fine-tuned large language model, the method comprising: determining a first simulation role and a dialogue scene selected by a user; based on the first simulation role and the dialogue scene, generating a dialogue content of a second simulation role through a target large language model; wherein the first simulation role and the second simulation role include: a counselor and a subject, and the second simulation role is different from the first simulation role; the dialogue scene is used to simulate the psychological counseling process between the counselor and the subject; in response to the user inputting the reply content of the first simulation role to the dialogue content, generating the interactive content of the second simulation role through the target large language model based on the reply content; performing question and answer analysis based on the dialogue content, the reply content and the interactive content to obtain a psychological counseling simulation report, wherein the psychological counseling simulation report is used to evaluate the dialogue fluency and emotion recognition accuracy of the first simulation role.
[0138] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0139] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the psychological counseling simulation method based on the fine-tuning large language model provided by the above-mentioned methods, the method including: determining a first simulated role and a dialogue scene selected by a user; based on the first simulated role and the dialogue scene, generating the dialogue content of the second simulated role through a target large language model; wherein the first simulated role and the second simulated role include: a counselor and a subject, and the second simulated role is different from the first simulated role; the dialogue scene is used to simulate the psychological counseling process between the counselor and the subject; in response to the user input of the first simulated role's reply content to the dialogue content, generating the interactive content of the second simulated role through the target large language model based on the reply content; performing question and answer analysis based on the dialogue content, the reply content and the interactive content to obtain a psychological counseling simulation report, wherein the psychological counseling simulation report is used to evaluate the dialogue fluency and emotion recognition accuracy of the first simulated role.
[0140] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the psychological counseling simulation method based on the fine-tuned large language model provided by the above-mentioned methods, the method comprising: determining a first simulated role and a dialogue scene selected by a user; based on the first simulated role and the dialogue scene, generating the dialogue content of the second simulated role through a target large language model; wherein the first simulated role and the second simulated role include: a counselor and a subject, and the second simulated role is different from the first simulated role; the dialogue scene is used to simulate the psychological counseling process between the counselor and the subject; in response to the user input of the first simulated role's reply content to the dialogue content, generating the interactive content of the second simulated role through the target large language model based on the reply content; performing question and answer analysis based on the dialogue content, the reply content and the interactive content to obtain a psychological counseling simulation report, wherein the psychological counseling simulation report is used to evaluate the dialogue fluency and emotion recognition accuracy of the first simulated role.
[0141] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0142] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0143] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A psychological consultation simulation method based on fine-tuning a large language model, characterized in that: include: Determine a first simulated role and dialogue scenario selected by a user; Based on the first simulated character and the dialogue scenario, generating dialogue content of the second simulated character through the target large language model; The first simulated role and the second simulated role include: a counselor and a subject, and the second simulated role is different from the first simulated role; the dialogue scene is used to simulate the psychological counseling process between the counselor and the subject; In response to the user inputting reply content of the first simulated character to the conversation content, generating interactive content of the second simulated character through the target large language model based on the reply content; A question-and-answer analysis is performed based on the conversation content, the reply content, and the interactive content to obtain a psychological counseling simulation report, wherein the psychological counseling simulation report is used to evaluate the conversation fluency and emotion recognition accuracy of the first simulated character.
2. The psychological consultation simulation method based on fine-tuning a large language model according to claim 1 is characterized in that: Before generating the dialogue content of the second simulated character by using the target large language model based on the first simulated character and the dialogue scenario, the method further includes: Based on the psychological counseling corpus dataset in the question-answer mode, the following process is repeated until the preset number threshold is reached, and the fine-tuned large language model with the highest evaluation score is determined as the target large language model, wherein the psychological counseling corpus dataset has been divided into a training set and an evaluation set according to a preset ratio: Based on the training set, fine-tune the pre-trained large language model through low-rank matrix decomposition and quantization to obtain a fine-tuned large language model; Inputting the evaluation set into the fine-tuned large language model to obtain a generated text and a generated summary output by the fine-tuned large language model; Based on the generated text and the generated summary, an evaluation score of the fine-tuned large language model is determined, wherein the evaluation score is determined by at least one generation task evaluation indicator, and the generation task evaluation indicator includes: a comprehensive matching score, a recall summary evaluation score, a perplexity, a diversity, and a type tag ratio score.
3. The psychological consultation simulation method based on fine-tuning the large language model according to claim 2 is characterized in that: Before determining the evaluation score of the fine-tuned large language model based on the generated text and the generated summary, the method further includes: Determining the number of matching words and the number of non-matching words between the generated text and the reference text in the evaluation set; Determine the ratio between the number of matching words and the total number of words in the generated text as the precision rate; Determine the ratio between the number of matching words and the total number of words in the reference text as the recall rate; Determining an F2 score based on the precision and the recall, wherein the F2 score is based on a weighted balance of the precision and the recall; Determining a penalty factor based on the number of matching words and the number of non-matching words; Based on the F2 score and the penalty factor, a comprehensive matching score of the fine-tuned large language model is determined.
4. The psychological consultation simulation method based on fine-tuning a large language model according to claim 2 is characterized in that: Before determining the evaluation score of the fine-tuned large language model based on the generated text and the generated summary, the method further includes: determining a first recall score based on a number of matches of n-grams between the generated summary and reference summaries in the evaluation set; determining a second recall score based on a longest common subsequence between the generated summary and a reference summary in the evaluation set; Determining a first position weight of the longest common subsequence in the generated summary, and determining a second position weight of the longest common subsequence in the reference summary in the evaluation set; determining a third recall score based on the first position weight and the second position weight; A recall summary evaluation score of the fine-tuned large language model is determined based on the first recall score, the second recall score, and the third recall score.
5. The psychological consultation simulation method based on fine-tuning a large language model according to claim 2 is characterized in that: Before determining the evaluation score of the fine-tuned large language model based on the generated text and the generated summary, the method further includes: Determining a first difference value based on a ratio between the number of different words in the generated text and the total number of words in the generated text; determining a second difference value based on a ratio between the number of different bigrams in the generated text and the total number of bigrams in the generated text; Determining the diversity of the fine-tuned large language model based on the first different value and the second different value; Determining a type-token ratio score of the fine-tuned large language model based on a ratio between the number of types of the generated text and the number of tokens of the generated text; The perplexity of the fine-tuned large language model on the evaluation set is determined according to the following formula: ; in, Indicates confusion, represents the total number of words in the evaluation set, represents the first words, Indicates that the fine-tuned large language model is word, predict the The probability of a word.
6. The psychological consultation simulation method based on fine-tuning a large language model according to claim 2 is characterized in that: The method further comprises: Acquire a case consultation text dataset, a subject feedback and evaluation dataset, and a consultation dialogue record dataset, wherein the case consultation text dataset, the subject feedback and evaluation dataset, and the consultation dialogue record dataset have all been pre-converted into a question-answering mode; Determining a dialogue scene of each case consultation text in the case consultation text dataset; determining a subject emotion of each subject feedback and evaluation in the subject feedback and evaluation dataset; Determining a conversation turn of each consultation conversation record in the consultation conversation record data set; Based on the dialogue scene of each case consultation text, the subject emotions fed back and evaluated by each subject, and the dialogue turns of each consultation dialogue record, a psychological consultation corpus dataset in question-and-answer mode is constructed.
7. A psychological consultation simulation system based on fine-tuning a large language model, characterized in that: include: A determination module, used to determine a first simulated role and a dialogue scene selected by a user; A generation module, configured to generate the dialogue content of the second simulated character through a target large language model based on the first simulated character and the dialogue scenario; The first simulated role and the second simulated role include: a counselor and a subject, and the second simulated role is different from the first simulated role; the dialogue scene is used to simulate the psychological counseling process between the counselor and the subject; an interactive module, configured to generate interactive content of the second simulated character through the target large language model based on the reply content input by the user to the first simulated character for the conversation content; An analysis module is used to perform question-and-answer analysis based on the conversation content, the reply content and the interactive content to obtain a psychological counseling simulation report, wherein the psychological counseling simulation report is used to evaluate the conversation fluency and emotion recognition accuracy of the first simulated character.
8. 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, the psychological counseling simulation method based on the fine-tuning large language model as described in any one of claims 1 to 6 is implemented.
9. 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, the psychological counseling simulation method based on a fine-tuned large language model as described in any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the psychological counseling simulation method based on a fine-tuned large language model as described in any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Model training method and device, electronic equipment and storage medium
CN120068983A