Interactive depression preliminary screening method based on large language model

Through fine-tuning of the large language model and controlling the dialogue process with finite state machine, the problems of low efficiency and difficult dialogue process control in the existing technology of large language model in the initial screening of depression are solved, and more efficient and personalized depression is achieved Screening and psychological comfort effects.

CN119226918APending Publication Date: 2024-12-31NORTHWESTERN POLYTECHNICAL UNIV

Patent Information

Application Number
CN202411185215.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-27
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

The existing large language models have hallucinations in the initial screening of depression, difficulty in providing personalized answers, and difficulty in controlling the dialogue process, resulting in low efficiency and low screening efficiency.

Method used

By fine-tuning the open source large language model and combining with finite state machines to control the dialogue process, interactive initial screening of depression can be achieved, and the accuracy of topic judgment and the targetedness of dialogue are improved.

Benefits of technology

It improves the efficiency of screening for patients with depression, provides more personalized and empathetic responses, reduces interview time, improves the fluency and efficiency of conversations, and significantly improves the accuracy of judgment of depression tendencies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226918A_ABST
    Figure CN119226918A_ABST
Patent Text Reader

Abstract

An interactive depression preliminary screening method based on a large language model comprises the steps that data collection and preprocessing are conducted, a divided data set is used for conducting model fine adjustment on an open-source pre-trained Chinese large model, and the large language model is obtained; performing topic control in a dialogue process by using a finite-state machine, and performing topic classification and severity judgment on user answers by calling a large language model; dialogue content of a user is received and converted into a text to be transmitted back to a server side, a finite-state machine judges and gives a score according to topic classification and severity of a large language model, the next action is judged based on the score, a next question returned to the client side is obtained, and meanwhile, the large language model is called to perform psychological comfort for answer content of the user; after all the topics are inquired, the score of the user in each type of topics is calculated, and a test result is output. According to the application, the screening efficiency of the depression patients is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of artificial intelligence technology, and specifically relates to an interactive depression screening method based on a large language model. Background Art

[0002] Due to the severe shortage of professional psychologists and the limited opportunities for patients to contact them, depression remains one of the serious mental health threats worldwide. In order to alleviate this situation, artificial intelligence has become an emerging tool for large-scale depression detection and diagnosis. Since traditional physiological signal detection (such as EEG, etc.) uses an invasive data collection method, it will cause patients to resist and thus affect the accuracy of the data. Therefore, conversational agents related to mental health have become a promising technical solution for early depression detection. Among them, the emergence of chatbots has realized the assessment of patients' cognitive or emotional states through depression rating scales (such as PHQ-9 and GAD-7). However, in a face-to-face human-computer environment, potential patients with depression are often reluctant to express their true mental state, and traditional chatbots are difficult to provide flexible and sufficient clinical dialogues. Therefore, this type of dialogue system is still far from completing the task of depression detection in actual clinical environments.

[0003] Large language models refer to trained neural networks in the field of natural language processing. Compared with small models, large language models are characterized by huge parameter scales, usually reaching tens of billions or even more, stronger generalization capabilities for various downstream tasks, and unique emergency capabilities for handling complex tasks, such as scenario learning, small sample prompts, command following, etc. These dynamic capabilities greatly improve the effectiveness of language models, thereby enabling artificial intelligence algorithms to reach new levels of efficiency and productivity.

[0004] At present, the application of big models to the medical field, especially in the field of psychotherapy, mainly has the following problems:

[0005] 1. The big model itself has the problem of hallucination, that is, the generated content is meaningless or not faithful to the source content provided. At the same time, it is difficult for the general big model to generate personalized answers for each patient, which is different from the empathetic response of psychologists in real scenarios.

[0006] 2. The existing large model makes it difficult to control the interview process for patients with depression. During the conversation, there will be repetitions, omissions, and incorrect topic judgments. Other means are needed to ensure the correct conduct of the interview process.

[0007] In summary, applying large models to the initial screening process for mental health has problems with low targetedness and efficiency of conversations, as well as low screening efficiency. Summary of the invention

[0008] In order to overcome the above problems, the purpose of this application is to propose an interactive depression screening method based on a large language model. The method of fine-tuning the open source large model and controlling the direction of the dialogue process with a finite state machine is used to achieve interactive depression screening, thereby improving the screening efficiency of patients with depression. By fine-tuning the large model, the accuracy of topic judgment also exceeds that of models with the same parameter level or models with higher parameter amounts.

[0009] In order to achieve the above purpose, the technical solution adopted in this application is as follows:

[0010] An interactive depression screening method based on a large language model comprises the following steps:

[0011] Step 1: Collect and preprocess data, and divide it into training set, validation set and test set. Use the divided data set to fine-tune the open source pre-trained Chinese large model to obtain a large language model.

[0012] Step 2: Use a finite state machine to control topics during the conversation. Topic types include "whether you are in a low mood", "whether you have lost interest", "whether you are in good health", and "whether you have suicidal tendencies". When the system is initialized, the state is set to judge "whether you are in a low mood" and the set initial questions are given; the large language model is used to classify topics and judge the severity of user answers. If the question answered by the current user does not match the topic of the interview process, a question of the same topic type is selected from the topic of the interview process to ask again;

[0013] Step 3: Receive the user's conversation content and convert it into text to send back to the server. The finite state machine gives a score based on the topic classification and severity of the large language model, determines the next action based on the score, and returns the next question to the client. At the same time, the large language model is called to provide psychological comfort based on the user's answer.

[0014] Step 4: When all the topics in step 2 have been asked, calculate the user's score in each type of topic. For the scores corresponding to different questions in the same type of topic, take the average value as the severity of the topic and output the test results.

[0015] Data collection includes three parts: answers to fixed questions answered by hospital patients and volunteers, a scale for assessing the severity of depression filled out by hospital patients and volunteers, and a doctor-patient conversation data set collected from the Internet; data preprocessing is: for the collected data, the speech-to-text API is called to convert it into text, and the collected questions are compared and labeled with the scale scores, and the answers to each question are divided into four categories according to the PHQ-9 standard: 0 means no depressive tendency in the answer, 1, 2, 3 means that the answer contains a certain depressive tendency, and the degree is proportional to the score; for some data that failed to be escaped or no content was collected, they were cleaned by writing scripts, and the cleaned conversations, scores, corresponding questions, and topics were spliced ​​into json format.

[0016] The specific model fine-tuning is as follows: the open source pre-trained Chinese large model selects GLM4-9b, uses Transformer as the backbone architecture, places RMS Norm after the residual link, uses a single linear layer for output token prediction, and replaces the ReLU activation function with the SwigLU activation function; by adding two low-rank matrices to the pre-trained Chinese large model parameters for correction, the parameter update scale is constrained.

[0017] Use LoRA to freeze the weight parameters of the pre-trained Chinese large model, add additional network layers to the pre-trained Chinese large model, and only train the parameters of the newly added network layers;

[0018] Each piece of training data is split into two parts. The first part is input into the original pre-trained Chinese model, and the output is h1. The second part is input into the network layer to be trained, and the output is h2. H1 and h2 are merged at the top layer to get h. The parameters of h are used for classification or generation, and the loss value is calculated. Back propagation is performed based on the loss value to update the parameters in the newly added network layer.

[0019] The next tag is predicted based on the pre-trained Chinese big model. The cross entropy of each training data is used to calculate the loss value between the predicted sequence obtained by the pre-trained Chinese big model and the actual sequence. During the training, different learning rates are assigned to the two low-rank matrices of LoRA, and new hyperparameters are introduced to fine-tune the rank value of the low-rank matrix. At the same time, the optimal rank value is found through multiple trainings to minimize the loss value and achieve the best dialogue effect.

[0020] The two topics of "whether the mood is low" and "whether there is loss of interest" are used as the first and second jumps of the initial state of the finite state machine. When the large language model determines that the user does not show depressive tendencies in the answers to these two topics, the interview is ended, the conclusion of the user's health is returned, and the interview answers are saved at the same time; when the large language model determines that the sum of the scores of the two topics is greater than 0, it jumps to the third topic of "whether the physical condition is good" and the fourth topic of "whether there is suicidal tendency". After the finite state machine completes the third and fourth topics, it jumps to the end state, processes the topic scores, and resets them to the initial state.

[0021] In each type of topic, when the first answer is judged to be 0 points, in order to ensure that the user's answer is sufficient and avoid misjudgment of the large language model, a new question will be extracted under the same type of topic for inquiry. If there is a difference in judgment, multiple questions will be extracted and a vote will be taken to judge whether the current topic has a depressive tendency.

[0022] When the finite state machine jumps to the topic of "Are you in good health?", it extracts certain questions for inquiry and takes the average of the scores as the topic score.

[0023] Psychological comfort is combined with the next question and returned to the client in the format of a message. The client calls the tts model to convert it into speech, and uses digital human technology to generate a digital human video of the psychologist for playback.

[0024] The scores of the four types of topics were added up, and the severity of depressive symptoms was assessed using the Patient Health Questionnaire-9 scale, with 0-4 points indicating no depression and 4 points or above indicating a tendency toward depression.

[0025] An interactive depression screening system based on a large language model, including:

[0026] Model training module: data collection, preprocessing, and division into training set, validation set and test set. The divided data set is used to fine-tune the open source pre-trained Chinese large model to obtain a large language model.

[0027] Topic control module: Use finite state machines to control topics during the conversation. Topic types include "whether you are in low mood", "whether you have lost interest", "whether you are in good physical condition" and "whether you have suicidal tendencies". When the system is initialized, the state is set to judge "whether you are in low mood" and the set initial questions are given; the large language model is used to classify topics and judge the severity of user answers. If the question answered by the current user does not match the topic of the interview process, a question of the same topic type is selected from the topic of the interview process to ask again;

[0028] Conversation content receiving and returning module: The user's conversation content is received and converted into text and sent back to the server. The finite state machine gives a score based on the topic classification and severity judgment of the large language model, and determines the next action based on the score, and returns the next question to the client. At the same time, the large language model is called to provide psychological comfort to the user based on the content of the answer.

[0029] Result output module: When all questions about the topic have been asked, the user's score in each category of topic is calculated. For the scores corresponding to different questions in the same category of topic, the average value is taken as the severity of the topic, and the test results are output.

[0030] Compared with the prior art, the beneficial effects of this application are:

[0031] 1. This application fine-tunes the open-source pre-trained Chinese model to enable the model to be competent for the classification of depression-related topics and the judgment of severity. In addition, the model can also undertake the tasks of psychological counseling and psychological comfort, providing more personalized and empathetic responses, thereby helping patients relieve psychological pressure. After experimental verification, the model has shown good robustness and accuracy in these tasks, with significant emotion recognition effects and practical application value.

[0032] 2. This application extracts the core elements of the interview by deeply studying the communication process between actual psychologists and patients, and condenses the content of psychological interviews, which usually last up to 1 hour, into four core topics. Based on these topics, a state machine mechanism is designed. The state machine dynamically adjusts the direction of the conversation through the context of the conversation, making the human-computer conversation more fluent and interactive. This design not only effectively reduces the interview time, but also improves the pertinence and efficiency of the conversation. It can simulate real psychological counseling scenarios and has excellent application effects.

[0033] 3. This application combines text-to-speech (TTS) technology with digital human technology and applies it to the human-computer dialogue system, which not only makes the voice output of the dialogue more natural and humane, but also gives the virtual image more realistic expression ability, enhancing the user's immersive experience. Through this integrated solution, the quality of human-computer dialogue has been significantly improved, and the interaction between users and digital humans has a more friendly and emotional connection, with the advantages of simple operation and rich user experience.

[0034] The method proposed in this application uses a large language model and a finite state machine to simulate the process of a psychologist talking and consulting with a patient, screens in four dimensions, and conducts efficient, intelligent, and natural conversations with the user during the process, providing appropriate and effective psychotherapy, and designs two versions, mobile and desktop, to adapt to different application scenarios, which helps to improve the traditional psychotherapy process and provide preventive mental health and psychotherapy self-care for more people. Therefore, it is of great significance to screen the potential population of depression on a large scale, reduce the workload of psychologists, and improve the efficiency of consultation. In addition, after testing, the accuracy of this application in judging the patient's depressive tendency also performed well in the same type of model, which has strong practical significance. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 This is a flow chart of the method of this application.

[0036] Figure 2 This is a flowchart of the topic control module of this application.

[0037] Figure 3 This is a comparison chart of the confusion matrices of different models in the embodiments of this application. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solution and advantages of the present application more clear, the present application is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described here are only used to explain the present application and are not used to limit the present application.

[0039] This application provides an interactive depression screening method based on a large language model. The whole process can include four modules: model training module, topic control module, dialogue content receiving and returning module, and result output module. By designing a finite state machine to enhance the dialogue interaction ability of the large model, the process of psychologists talking and asking questions with patients is digitized, providing patients with accurate and effective psychological comfort, and the accuracy of judging patients' depressive tendencies is higher than other models. For the field of initial screening and treatment of depression, it provides a new idea and method.

[0040] An interactive depression screening method based on a large language model, comprising:

[0041] Step 1: Fine-tune the open-source pre-trained Chinese model using real scale and conversation data collected by the hospital;

[0042] Step 1-1: Data collection and preprocessing;

[0043] The data used for model training includes three parts: answers to fixed questions answered by hospital patients and volunteers (18 questions designed by professional psychologists for depression), scales for assessing the severity of depression filled out by hospital patients and volunteers (PHQ-9, GAD-7, HAMD-17, etc.), and doctor-patient dialogue datasets collected from the Internet (D4, etc.);

[0044] The data collection environment mainly includes relatively quiet environments such as school psychological counseling rooms and hospital psychological treatment rooms. The standards for subjects are jointly formulated by the team of attending psychiatrists in the Department of Psychiatry. The age range of subjects is required to be 15-65 years old, regardless of gender. The attending physician uses the Chinese version of the Mini International Neuropsychiatric Interview (MINI) and PHQ-9 and other scales to assess whether the subjects have depression and mark the labels. During the evaluation process, as long as other mental illnesses or major physical illnesses need to be excluded, ensure that the differences mainly come from the factor of depression. The experiment was reviewed and approved by the hospital ethics committee. During the experiment, only subjects are allowed to be present to exclude the influence of others. The lighting of the scene needs to be adjusted to a comfortable state. The subjects are required to sit in a comfortable chair and find a more comfortable state for themselves. At the same time, they should move their bodies as little as possible or make sounds unrelated to the experiment. They should keep a normal distance from the computer equipment and recording equipment in front of them.

[0045] In the data preprocessing stage, for each piece of collected data, the speech-to-text API is called to convert it into text, and the collected questions are compared and annotated with the scale scores. The answers to each question are divided into four categories according to the PHQ-9 standard: 0 (no depressive tendency in the answer), 1, 2, 3 (the answer contains a certain depressive tendency, the degree is proportional to the score, and 3 points indicate a serious depressive tendency in the conversation); the medical diagnosis of professional doctors in the existing hospital psychological clinic is used to mark whether the subject is a depression patient; in the labeling process, there will be situations where the subject's self-evaluation is inconsistent with the actual answer or even completely different. In this case, the experience and judgment of the attending physician are used to annotate the controversial data; for some data that failed to be converted or no content was collected, scripts are written to clean it, and the cleaned conversations, scores, corresponding questions, and topics are spliced ​​into json format for subsequent model training;

[0046] At the same time, we collected the existing data sets of conversations between depression patients and psychologists, eliminated some useless data based on the topics required by the design system, and modified the data set according to the theory of cognitive behavioral therapy (a common treatment method in psychological diagnosis and treatment) in order to conform to the sequential logic of subsequent interview topics; finally, we organized more than 2,000 multi-round conversations for subsequent training, also in json format.

[0047] Step 1-2: Model fine-tuning and optimization;

[0048] Shuffle the data set processed in step 1-1 and divide it into training set, validation set and test set in a ratio of 6:1:3; the selected pre-trained model is GLM4-9b in the GLM series, whose Chinese capability exceeds that of llama3 with similar parameters, and has basic Chinese conversation and comprehension capabilities. At the same time, the parameter level is adapted to conventional hardware devices, which is convenient for later deployment;

[0049] The pre-trained model uses Transformer as the backbone architecture, adjusts the order of layer normalization and residual connection, places RMS Norm after the residual connection, uses a single linear layer for output token prediction, and replaces the ReLU activation function with GeLUs; our fine-tuning method uses LoRA (low rank adaptation), which adds two low-rank matrices (A, B) to the model parameters for correction, constrains the parameter update scale, and can achieve efficient fine-tuning while maintaining the original model architecture under low hardware conditions;

[0050] Furthermore, we use LoRA to freeze the pre-trained model weight parameters. When the original model parameters are frozen, we add additional network layers to the model and only train the parameters of these newly added network layers. Each training data X is split into two parts. The first part is input into the original pre-trained model, and the second part is input into the network layer to be trained. The output part is divided into h1 and h2. h1 is output from the pre-trained large model. h1 is the forward calculation process obtained by fixed parameters. The output obtained from the newly introduced network layer is h2. h2 is affected by the W parameter in the newly introduced network layer. h1 and h2 are merged at the top layer to obtain h. The parameters of h are used to do the classification. Classification or generation, the calculated loss is only back-propagated to update the parameters in the newly introduced network layer, namely W; the next tag is predicted based on the pre-trained model, and the cross entropy loss is calculated between the predicted sequence obtained by the model and the real sequence for each training data; because the pre-trained language model has a lower "intrinsic dimension", it can still be effectively learned despite random projection to a smaller subspace; during training, by assigning different learning rates to the two LoRA matrices, new hyperparameters are introduced to fine-tune the rank value of the matrix, and the optimal rank value is found through multiple trainings, so that the loss is minimized and the actual dialogue effect of the model is optimized.

[0051] Step 2: Topic control module;

[0052] By observing the conversations between hospital patients and doctors and some internationally accepted diagnostic criteria for depression, we found that most topics in the communication between psychologists and patients with depression can be classified into four categories: including asking patients whether they have been depressed recently, whether they have lost interest, whether they are in good health, and whether they have suicidal tendencies; therefore, we use the answers to the above four topics as the basis for the initial screening of depression, and design a finite state machine based on the question jump logic of the "Brief International Neuropsychiatric Interview Examination" to control the topic of the conversation process;

[0053] Furthermore, we use the two topics of depression and loss of interest as the first and second jumps of the initial state of the state machine. When the model finds that the subject does not show depression in the answers to these two topics, the interview ends without further questions. The conclusion that the subject is healthy is returned and the interview answers are saved. When the model determines that the sum of the scores of the two topics is greater than 0, it jumps to the third topic of physical condition and the fourth topic of suicidal tendency.

[0054] Furthermore, in each topic, when the first answer is judged to be 0 points, in order to ensure that the subject's answer is sufficient and avoid the model's misjudgment, a new question will be extracted under the same topic for inquiry. If there is a difference in judgment, multiple questions will be extracted, and a vote will be taken to judge whether the current topic has a depressive tendency; if the content topic answered by the current user does not match the topic of the interview process, a question of the same topic type will be selected from the topic of the interview process to ask again until all questions of the same type are asked or the content topic answered by the user is the same as the topic of the process; when the state machine jumps to the topic of physical condition, the system will extract a certain number of fixed questions for inquiry, and take the average of the scores as the topic score. This is because the subject may be in physical discomfort caused by non-depression during the test, so as to prevent such situations from interfering with the model's judgment and avoid such incidents through multi-angle inquiry; when the state machine completes the physical topic and the topic of suicidal tendency, the state machine will jump to the end state, process the topic score, and reset it to the initial state.

[0055] Step 3: The dialogue returns;

[0056] In the client design of this dialogue system, the subject answers the system's questions once through a microphone device; the voice data is first converted into text locally on the client, and then the text data is transmitted back to the server; the server calls the large language model in step 2, performs topic classification and score judgment based on the text, and transmits these results to the state machine; the state machine determines the next action to be taken based on the judgment result and generates the next question to be returned to the client;

[0057] At the same time, the system will call the big model again to generate corresponding psychological comfort and guidance information based on the subject's previous answers; these comforting contents and the system's next question are integrated into a data packet in a message format and returned to the client;

[0058] After receiving the message, the client will call the TTS (text-to-speech) model to convert the text content into speech to ensure that the speech expression is natural and fluent. In addition, the system will also use digital human technology to generate a digital human video with the image of a psychologist, and present the generated psychological comfort and next questions to the subjects in the form of voice and visualization, enhancing the interactive effect and immersion.

[0059] Step 4: Result output;

[0060] In step 2, when all four types of topics have been asked, the system will calculate a score for the severity of each topic reflected by the user. The score comes from the topic severity determined by the large model in step 2. For different questions in the same topic, the average value will be taken as the severity of the topic. The scores of the four topics will be added up and the severity of depressive symptoms will be judged according to the standards of the Patient Health Questionnaire-9 scale. 0-4 points indicate no depression, and 4 points or above indicate a tendency to depression. When the output is returned for the last time, the diagnostic results of the process are also returned to the front end as output.

[0061] First, the user starts by clicking on the test. The front end sends a sign indicating the start of the conversation to the back end. The back end starts the API service of the large language model and resets the initial topic. The front end recognizes the user's voice input as text through speech-to-text technology and saves it and sends it to the back end in the format of an HTTP message. The back end listens to the request for an answer and calls the large model twice to generate an answer. The first call makes the model judgement on the topic and severity (a score system, with severity increasing from 0 to 3). At the same time, the state machine decides whether to jump to the topic and the content of the next question based on the judgment result. In the second call, the large model acts as a psychologist to provide empathetic comfort to the user input. After the two calls are completed, the response content generated by the second call is combined with the next question and sent back to the front end in the form of an HTTP message. The front end uses text-to-speech technology to convert the received backend response into audio for playback. Finally, when the state machine determines that the topic can be ended, it will calculate the score in the entire interview process and add it to the answer, and return an interview end sign to the front end.

[0062] An interactive depression screening system based on a large language model, including:

[0063] Model training module: data collection, preprocessing, and division into training set, validation set and test set. The divided data set is used to fine-tune the open source pre-trained Chinese large model to obtain a large language model.

[0064] Topic control module: Use finite state machines to control topics during the conversation. Topic types include "whether you are in low mood", "whether you have lost interest", "whether you are in good physical condition" and "whether you have suicidal tendencies". When the system is initialized, the state is set to judge "whether you are in low mood" and the set initial questions are given; the large language model is used to classify topics and judge the severity of user answers. If the question answered by the current user does not match the topic of the interview process, a question of the same topic type is selected from the topic of the interview process to ask again;

[0065] Conversation content receiving and returning module: The user's conversation content is received and converted into text and sent back to the server. The finite state machine determines the next action based on the topic classification and severity of the large language model, and returns the next question to the client. At the same time, the large language model is called to provide psychological comfort to the user based on the content of the answer.

[0066] Result output module: After all four types of topics have been asked, the user's score in each type of topic is calculated. For different questions in the same type of topic, the average value is taken as the severity of the topic, and the test results are output.

[0067] Example:

[0068] The purpose of this application is to improve the accuracy of initial screening and treatment of depression, reduce the psychological defense of patients, and improve the screening efficiency of psychologists for depression patients. The functions of this application are generally realized from four modules.

[0069] This embodiment uses Python programming language as the programming language, the experimental hardware condition is RTX 4090*1, the training method selects the parameter efficient fine-tuning method LoRA, and the training parameters are set to: the rank of the LoRA matrix is ​​8, the expansion factor of the LoRA layer is 32, the dropout rate used in the LoRA layer is 0.1, and the maximum input and output length of the model is set to 512 tokens.

[0070] exist Figure 1 In the model training module, the training data needs to be processed first. The format is json. Each data contains three elements, namely System Prompt, User, and Assistant, which represent system prompt words, user input, and model output respectively. System Prompt is designed into two categories, one for topic classification and score calculation tasks, and the other for giving the model an empathetic psychologist role to make it natural and humane. The training data was collected from more than 220 subjects, of which the ratio of depression patients to healthy people was 6:4.

[0071] The essence of the LoRA algorithm is an approximate numerical decomposition technique for low-rank decomposition of the feature matrix, which can greatly reduce the number of parameters of the feature matrix. The loss function is:

[0072] L(θ)=-∑[y*log(p)+(1-y)*log(1-p)]

[0073] Among them, θ is the parameter of the model, y is the label, and p is the probability predicted by the model. Through back propagation and parameter update, the model will continuously optimize the weights and biases to better adapt to specific tasks. During the multi-round dialogue training process, we only calculate the loss of the last Assistant part and use Adam as the optimizer.

[0074] Figure 2 In the specific flow chart of the topic control module, the initial topic state is set to "emotion", the system gives the set questions, and then judges the topic and severity when the user answers for the first time. If the topic matches and the severity score is greater than 0, the score is saved and the state jumps to the next state "interest"; if the topic does not match or the severity score is 0, the current state is maintained, and a question that has not been asked is extracted from the question list (if all questions in the current state have been asked, the current state is ended and the next state is jumped). In this way, if there is no negative tendency in the two categories of emotions and interests, it will be judged as a healthy state without depression tendency, and the interview process will be ended directly. Otherwise, the questioning will continue until the four categories of topics have obtained corresponding scores and the questioning ends.

[0075] Figure 1 In the topic return module, the big model and state machine are called once to determine the next question to be returned. At the same time, the big model is called a second time to provide psychological comfort and guidance for the user's reply; the psychological comfort is combined with the next question and sent to the front end in the format of an HTTP message, which is converted into voice for output.

[0076] Figure 1 In the result output module, when all four types of topics have been asked, the system will calculate the score of the severity reflected by the user in each topic. The score comes from the topic severity determined by the large model in step 2. For different questions in the same topic, the average value will be taken as the severity of the topic. The scores of the four topics will be added up, and the severity of depressive symptoms will be judged according to the standards of the Patient Health Questionnaire-9 scale. 0-4 points indicate no depression, and 4 points or above indicate a tendency to depression. When the output is returned for the last time, the diagnostic result of the process is also returned to the front end as output.

[0077] Experimental results:

[0078] Table 1 shows the comparison results of the model of this application with ChatGLM-9b, GPT4 and ChatGLM-130B in the classification test set of judging the depression score of the subjects' answers. Sklearn is used to calculate the average precision, recall, and F1 to evaluate the classification results. The results show that the method of this application is better than the baseline model ChatGLM-9b, indicating the effectiveness of the training. And in most cases, it is better than GPT-4 and GLM-130B. When performing 4 classifications, the scores of all models are significantly lower than those of 2 classifications (only classifying answers as having depression tendency and not having depression tendency). This shows that although the large model can better distinguish whether there is a depression tendency in the answer, it has not yet mastered the severity classification of patients with depression tendency.

[0079]

[0080] Table 1 Comparison results on the depression level classification test set

[0081] This application not only focuses on the depression severity classification results, but also focuses on the model's classification results for topics. Figure 3 It is a comparison diagram of the confusion matrices of different models in the embodiments of this application, where: Figure 3 (a) corresponds to GPT-4, Figure 3 (b) Corresponding to GLM-130B, Figure 3 (c) corresponds to ChatGLM-9b, Figure 3 (d) The comparison results of this application on the classification test set of the depression score of the subjects' answers. The darker the color of the matrix diagonal in the figure, the more accurate the topic judgment is. The blue area outside the diagonal is the case of incorrect topic judgment. It can be seen that except for the model proposed in this application, other models have judged the topic as "other", indicating that the model including GPT4 has inaccurate judgment on the topic of "interest". In addition, it was found that the model had better control performance on the two topics of "physical condition" and "suicide", which may be related to the high-frequency and highly representative topic words that appeared in the conversation.

[0082] After completing the topic judgment and severity judgment of the system's single answer in the conversation, the actual judgment results of the subjects were tested and compared. The three indicators of accuracy, specificity and sensitivity are used to neutralize the evaluation model. The three indicators are calculated based on the gold standard. The gold standard is a method recognized by the current clinical medical community to diagnose a certain disease. Pathological diagnosis and recognized clinical diagnostic standards are commonly used gold standard diagnostic methods. At the same time, a clear diagnosis obtained through long-term clinical follow-up can also be used as the basis for gold standard diagnosis. The vertical columns are divided into "case group" and "control group" according to the gold standard diagnosis, that is, positive and negative, while the diagnostic test results to be predicted are arranged horizontally. When the two groups of objects are tested simultaneously, the positive results are listed as the first row of the diagnostic test and the negative results are listed as the second row, thus forming a table:

[0083]

[0084] Table 2 Gold standard diagnosis table

[0085] Among them, TP represents true positive, which is the number predicted as positive in the case group; FP represents false positive, which is the number predicted as positive in the control group; FN represents false negative, which is the number predicted as negative in the case group; TN represents true negative, which is the number predicted as negative in the control group.

[0086] Accuracy is a commonly used evaluation indicator in classification models. Accuracy indicates the proportion of correct results predicted by the model. The specific calculation formula is as follows:

[0087]

[0088] Sensitivity refers to the ability to correctly detect patients who actually have the disease. It represents the ratio of people who test positive for the disease to those who actually have the disease. The specific formula is as follows:

[0089]

[0090] A highly sensitive test result can effectively rule out a disease. If the highly sensitive model test result is negative, it can effectively rule out that the subject also has the disease, because it rarely misdiagnoses people with the disease. However, when the highly sensitive model test result is positive, it does not necessarily have a role in the diagnosis of the disease. For example, when used on sick patients, all patients test positive, making the test 100% sensitive. However, sensitivity does not take into account false positives. A false test is also positive for all healthy patients, with a false positive rate of 100%, making it unable to detect or "diagnose" the disease.

[0091] Specificity refers to the ability to correctly detect healthy people who do not actually have the disease. It represents the ratio of people who test negative for the disease to those who do not have the disease. The specific formula is as follows:

[0092]

[0093] In contrast to sensitivity, a positive result from a test with a high degree of specificity is useful for the diagnosis of a disease. A positive result therefore indicates a high probability that the disease is present, since the test rarely produces positive results in healthy people. Likewise, a negative result from a high specificity test is not necessarily helpful in ruling out a disease. For example, a test that always returns a negative test result would have a specificity of 100%, since the specificity does not take into account false negatives. A test like this that is negative for a patient with the disease would make it impossible to rule out the disease.

[0094] Using the evaluation criteria of accuracy, sensitivity and specificity, the test results of our model are shown in Table 2. A specificity of 1 means that we did not make any misjudgment in all the depressed subjects, which proves the effectiveness of the system.

[0095]

[0096] Table 3 Test results of subjects

[0097] In summary, through the implementation of this application, the previous outpatient consultation method for depression can be improved, providing doctors and patients with a reliable, lightweight depression screening tool, reducing the workload of doctors, improving consultation efficiency and reducing patients' medical costs.

[0098] The above embodiments are only for illustrating the technical concept and features of the present application, and their purpose is to enable ordinary technicians in the field to understand the content of the present application and implement it accordingly, and they cannot be used to limit the protection scope of the present application. Any equivalent changes or modifications made according to the essence of the content of the present application should be included in the protection scope of the present application.

Claims

1. An interactive depression screening method based on a large language model, characterized in that: The following steps are involved: Step 1: Collect and preprocess data, and divide it into training set, validation set and test set. Use the divided data set to fine-tune the open source pre-trained Chinese large model to obtain a large language model. Step 2: Use a finite state machine to control topics during the conversation. Topic types include "whether the mood is low", "whether there is loss of interest", "whether the physical condition is good" and "whether there is suicidal tendency". When the system is initialized, the state is set to judge "whether the mood is low" and the set initial question is given; the large language model is called to classify the topic and judge the severity of the user's answer. If the question answered by the current user does not match the topic of the interview process, select a question of the same topic type from the topic of the interview process to ask again; Step 3: Receive the user's conversation content and convert it into text to send back to the server. The finite state machine gives a score based on the topic classification and severity of the large language model, determines the next action based on the score, and returns the next question to the client. At the same time, the large language model is called to provide psychological comfort based on the user's answer. Step 4: When all the topics in step 2 have been asked, calculate the user's score in each type of topic. For the scores corresponding to different questions in the same type of topic, take the average value as the severity of the topic and output the test results.

2. The interactive depression screening method based on a large language model according to claim 1, characterized in that: Data collection includes three parts: answers to fixed questions from hospital patients and volunteers, a scale for assessing the severity of depression filled out by hospital patients and volunteers, and a doctor-patient conversation data set collected from the Internet; The data preprocessing is as follows: for the collected data, the speech-to-text API is called to convert it into text, the collected questions are compared with the scale scores, and the answers to each question are divided into four categories according to the PHQ-9 standard: 0 means no depressive tendency in the answer, 1, 2, 3 means that the answer contains a certain degree of depressive tendency, and the degree is proportional to the score; for some data that failed to be converted or no content was collected, they are cleaned by writing scripts, and the cleaned conversations, scores, corresponding questions, and topics are spliced ​​into json format.

3. The interactive depression screening method based on a large language model according to claim 1, characterized in that: The specific model fine-tuning is as follows: the open source pre-trained Chinese large model selects GLM4-9b, uses Transformer as the backbone architecture, places RMS Norm after the residual link, uses a single linear layer for output token prediction, and replaces the ReLU activation function with the SwigLU activation function; by adding two low-rank matrices to the pre-trained Chinese large model parameters for correction, the parameter update scale is constrained.

4. The interactive depression screening method based on a large language model according to claim 3, characterized in that: Use LoRA to freeze the weight parameters of the pre-trained Chinese large model, add additional network layers to the pre-trained Chinese large model, and only train the newly added network layer parameters; Each piece of training data is split into two parts. The first part is input into the original pre-trained Chinese model, and the output is h1. The second part is input into the network layer to be trained, and the output is h2. H1 and h2 are merged at the top layer to get h. The parameters of h are used for classification or generation, and the loss value is calculated. Back propagation is performed based on the loss value to update the parameters in the newly added network layer. The next tag is predicted based on the pre-trained Chinese big model. The cross entropy of each training data is used to calculate the loss value between the predicted sequence obtained by the pre-trained Chinese big model and the actual sequence. During the training, different learning rates are assigned to the two low-rank matrices of LoRA, and new hyperparameters are introduced to fine-tune the rank value of the low-rank matrix. At the same time, the optimal rank value is found through multiple trainings to minimize the loss value and achieve the best dialogue effect.

5. The interactive depression screening method based on a large language model according to claim 1, characterized in that: The two topics of "whether the mood is low" and "whether there is loss of interest" are used as the first and second jumps of the initial state of the finite state machine. When the large language model determines that the user does not show depressive tendencies in the answers to these two topics, the interview ends, returns to the conclusion that the user is healthy, and saves the interview answers. When the large language model determines that the sum of the scores of the two topics is greater than 0, it jumps to the third topic of "whether the physical condition is good" and the fourth topic of "whether there is suicidal tendency". After the finite state machine completes the third and fourth topics, it jumps to the end state, processes the topic scores, and resets them to the initial state.

6. The interactive depression screening method based on a large language model according to claim 5, characterized in that: In each type of topic, when the first answer is judged to be 0 points, in order to ensure that the user's answer is sufficient and avoid misjudgment of the large language model, a new question will be extracted under the same type of topic for inquiry. If there is a difference in judgment, multiple questions will be extracted and a vote will be taken to judge whether the current topic has a depressive tendency.

7. The interactive depression screening method based on a large language model according to claim 5, characterized in that: When the finite state machine jumps to the topic of "Are you in good health?", it extracts certain questions for questioning and takes the average of the scores as the topic score.

8. The interactive depression screening method based on a large language model according to claim 1, characterized in that: Psychological comfort is combined with the next question and returned to the client in the format of a message. The client calls the tts model to convert it into speech, and uses digital human technology to generate a digital human video of the psychologist for playback.

9. The interactive depression screening method based on a large language model according to claim 1, characterized in that: The scores of the four types of topics were added up, and the severity of depressive symptoms was assessed using the Patient Health Questionnaire-9 scale, with 0-4 points indicating no depression and 4 points or above indicating a tendency toward depression.

10. An interactive depression screening system based on a large language model, characterized in that: include: Model training module: data collection, preprocessing, and division into training set, validation set and test set. The divided data set is used to fine-tune the open source pre-trained Chinese large model to obtain a large language model. Topic control module: Use finite state machines to control topics during the conversation. Topic types include "whether the mood is low", "whether there is loss of interest", "whether the physical condition is good" and "whether there is suicidal tendency". When the system is initialized, the state is set to judge "whether the mood is low" and the set initial questions are given; the large language model is used to classify the topic and judge the severity of the user's answer. If the question answered by the current user does not match the topic of the interview process, a question of the same topic type is selected from the topic of the interview process to ask again; Conversation content receiving and returning module: The user's conversation content is received and converted into text and sent back to the server. The finite state machine gives a score based on the topic classification and severity judgment of the large language model, and determines the next action based on the score, and returns the next question to the client. At the same time, the large language model is called to provide psychological comfort to the user based on the content of the answer. Result output module: When all questions about the topic have been asked, the user's score in each category of topic is calculated. For the scores corresponding to different questions in the same category of topic, the average value is taken as the severity of the topic, and the test results are output.

Citation Information

Patent Citations

  • Depression interview dialogue generation method based on pre-training language model

    CN113780012A

  • Large language model reply method and system capable of automatically adjusting cue word, terminal and medium

    CN117407498A

  • Mental health screening auxiliary diagnosis and dialogue data set generation method

    CN117912667A

  • Depression risk assessment method and system based on psychological scale and AIGC large model

    CN118467686A

Cited By

  • Depression risk screening optimization method and system based on large and small model linkage

    CN120452777A

  • Digital sand table multi-modal data analysis method based on intelligent chat robot

    CN121583544A

  • A digital sand table multi-modal data analysis method based on an intelligent chat robot

    CN121583544B