Digital patient conversation generation method and system based on multi-round conversation

By using a digital patient dialogue generation method based on multi-turn dialogue, and combining GRU and Tranformer models with background information, the problem of the speaker's emotional state being affected by multiple factors is solved, and more accurate patient dialogue generation is achieved.

CN117874205BActive Publication Date: 2026-07-31HEFEI UNIV OF TECH
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HEFEI UNIV OF TECH
Filing Date
2024-01-16
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Current technology fails to effectively consider the influence of various factors on the speaker's emotional state during the conversation, resulting in an inability to accurately learn the patient's conversational style.

Method used

A digital patient dialogue generation method based on multi-turn dialogue is adopted. By using GRU, multi-head attention mechanism and Tranformer model, the patient's dialogue history is collected and quantified, combined with background information, to predict the patient's psychological and emotional state at the next moment and generate a response. The total loss function training model is constructed.

Benefits of technology

This improved the model's ability to accurately learn patient dialogue patterns, generating responses that better suit patients and enhancing the accuracy of dialogue generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117874205B_ABST
    Figure CN117874205B_ABST
Patent Text Reader

Abstract

This invention provides a method, system, storage medium, and electronic device for generating digital patient dialogues based on multi-turn dialogue, relating to the field of dialogue generation technology. The invention includes: collecting and quantifying the patient's dialogue history; obtaining the historical sentence sets of the patient and their interlocutors and using them as input to a GRU; correspondingly obtaining the first and second hidden states; combining the encoded results of background information, using a multi-head attention mechanism to predict the classification result of the patient's psychological emotion at the next moment, and constructing an emotion classification loss accordingly; based on the predicted classification result of the patient's psychological emotion at the next moment, generating the patient's response at the next moment through a masked multi-head self-attention mechanism of Tranformer, and constructing a patient response loss accordingly; finally generating the response of the patient to be analyzed at the next moment. By incorporating the patient's background information, it is beneficial to select vocabulary that better matches the patient to generate a complete response, enabling the model to learn the patient's dialogue style more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of dialogue generation technology, and more specifically to a method, system, storage medium, and electronic device for generating digital patient dialogues based on multi-turn dialogues. Background Technology

[0002] Simulating the speech patterns of mental patients to create digital mental patients can facilitate other activities, such as building emotional dialogue data. This technology involves techniques such as sentiment analysis and emotion transfer.

[0003] For example, the paper "MISC: A MIXed Strategy-Aware Model Integrating COMET for Emotional Support Conversation" at ACL 2022 utilizes common-sense reasoning COMET to analyze text and enhance the sentiment state encoder. The emergence of such methods has significantly improved the model's ability to recognize and analyze sentiment.

[0004] For example, in the patent "CN109615077A - Dialogue-based Emotional State Modeling and Emotional Transfer Method and Apparatus", the probability of user emotional transfer under different emotional stimuli is sampled and statistically analyzed to construct an emotional transfer matrix. This inspires consideration of the contribution of different information to emotional transfer.

[0005] However, none of the above solutions take into account that the speaker's emotional state may be affected by many different factors in the conversation, such as the conversation scene, the conversation topic, and the stimuli from the interlocutor, which makes it impossible to accurately learn the patient's conversational style. Summary of the Invention

[0006] (a) Technical problems to be solved

[0007] To address the shortcomings of existing technologies, this invention provides a method, system, storage medium, and electronic device for generating digital patient dialogues based on multi-turn conversations. This solves the technical problem that the speaker's emotional state may be affected by many different factors in the conversation, making it impossible to accurately learn the patient's dialogue style.

[0008] (II) Technical Solution

[0009] To achieve the above objectives, the present invention provides the following technical solution:

[0010] A method for generating digital patient dialogue based on multi-turn dialogue, using a psychological patient dialogue model including GRU, multi-head attention mechanism, and Tranformer, and comprising the following steps:

[0011] Collect and quantify the patient's dialogue history, and obtain the historical sentence sets of the patient and their interlocutors respectively;

[0012] The patient's and their conversation partner's historical statements are used as inputs to the GRU to obtain the first and second hidden states respectively.

[0013] Based on the first and second hidden states and the encoding results of the background information, the multi-head attention mechanism is used to predict the classification result of the patient's psychological emotions at the next moment, and an emotion classification loss is constructed accordingly.

[0014] Based on the predicted classification results of the patient's psychological emotions in the next moment, the patient's response in the next moment is generated through the masked multi-head self-attention mechanism of the Tranformer, and the patient response loss is constructed accordingly.

[0015] Based on the emotion classification loss and patient response loss, a total loss function is constructed and the psychological patient dialogue model is trained until convergence.

[0016] The dialogue history of the patient to be analyzed is used as input to the converged dialogue model of the mental patient to generate the patient's response at the next moment.

[0017] Preferably, the process of collecting and quantizing the patient's historical dialogue dataset, and obtaining the historical statement sets of the patient and their interlocutors, includes:

[0018] Collect the dialogue history of the patient and their interlocutor. in x and y represent the speaker and the patient, respectively, N. c The selected dialogue sequence length, d model For the selected vector dimension;

[0019] When the dialogue reaches round t+1, the dialogue history... C t+1 In Based on the conversion of the Bert pre-trained model Get

[0020] Among them, C' t+1 Divided into a collection of patients' historical statements and the historical statement collection of the interlocutors

[0021] Preferably, the encoding result of pre-acquired background information includes:

[0022] Collect background information Based on the Bert pre-trained model, the corresponding encoded results are converted. Where, N BThe length of the selected background information sequence.

[0023] Preferably, the step of predicting the patient's psychological and emotional classification result at the next moment using the multi-head attention mechanism based on the first and second hidden states and the encoding result of background information, and constructing an emotion classification loss accordingly, includes:

[0024] Set the number of attention heads to n. head B′ is used as the query vector. As key vectors and value vectors; the calculation formula is as follows:

[0025] Q i =B′W i Q

[0026] K i =MW i K

[0027] V i =MW i V

[0028]

[0029]

[0030] s t+1 =FFN(s′) t+1 )

[0031] Among them, in attention head i, W i Q W i K W i V These are the weight matrices for the query vector, key vector, and value vector, respectively.

[0032] The classification results of the patient's psychological and emotional state at the predicted time t+1 are used to determine the patient's psychological and emotional state. t+1 After passing through a fully connected layer, the classification of patients' psychological emotions is achieved, with a total of s. n Emotion category, the tags for emotion category are Using the cross-entropy loss function:

[0033]

[0034]

[0035] Among them, L s The loss function is the emotion classification loss of all responses from the patient from time 0 to t+1.

[0036] Preferably, the step of generating the patient's response for the next moment based on the predicted classification result of the patient's psychological emotions at the next moment, through the masked multi-head self-attention mechanism of the Tranformer, and constructing the patient response loss accordingly, includes:

[0037] Patient's response Where r i For the word in the reply, n c for The sequence length, O is the sequence { <bos>,r1,r2,...,r nc-1 The hidden state obtained through the Tranformer masked multi-head self-attention mechanism is generated in the following way:

[0038] A t =CROSS-ATTENTION(O,C t+1 )

[0039] A u =CROSS-ATTENTION(O,U t+1 )

[0040] A s =CROSS-ATTENTION(O,s t+1 )

[0041] A b =CROSS-ATTENTION(O,B′)

[0042] O′=FFN(A t +A u +A s +A b +O)

[0043] in, right The predicted probability;

[0044] Received incomplete response O k ={ <bos>,r1,r2,...,r k },get Therefore, we can know r k+1 And update O k For O k+1 ;

[0045] Based on this, a loss function for patient responses is constructed:

[0046]

[0047] Preferably, the total loss function is expressed as L = L r +L s .

[0048] A digital patient dialogue generation system based on multi-turn dialogue, based on a psychological patient dialogue model, wherein the psychological patient dialogue model includes GRU, multi-head attention mechanism and Tranformer, and the digital patient dialogue generation system includes:

[0049] The vectorization module is used to collect and quantize the patient's dialogue history, and obtain the historical sentence sets of the patient and their interlocutors respectively.

[0050] The analysis module is used to take the historical statements of the patient and their interlocutor as input to the GRU and obtain the first and second hidden states accordingly.

[0051] The prediction module is used to predict the classification result of the patient's psychological emotion at the next moment based on the first and second hidden states and the encoding result of the background information, using the multi-head attention mechanism, and to construct the emotion classification loss accordingly.

[0052] The generation module is used to generate the patient's response at the next moment based on the predicted classification result of the patient's psychological emotions at the next moment, through the masked multi-head self-attention mechanism of the Tranformer, and to construct the patient response loss accordingly.

[0053] The training module is used to construct a total loss function based on the emotion classification loss and the patient response loss, and to train the psychological patient dialogue model until convergence.

[0054] The application module is used to take the dialogue history of the patient to be analyzed as input to the converged psychological patient dialogue model and generate the patient's response at the next moment.

[0055] A storage medium storing a computer program for generating digital patient dialogues based on multi-turn conversations, wherein the computer program causes a computer to execute the digital patient dialogue generation method as described above.

[0056] An electronic device, comprising:

[0057] One or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs including methods for performing the digital patient dialogue generation method as described above.

[0058] (III) Beneficial Effects

[0059] This invention provides a method, system, storage medium, and electronic device for generating digital patient dialogues based on multi-turn dialogue. Compared with existing technologies, it has the following advantages:

[0060] This invention includes: collecting and quantifying a patient's dialogue history; obtaining the historical sentence sets of the patient and their interlocutors and using them as input to a GRU; and obtaining the first and second hidden states accordingly; combining the encoded results of background information, using a multi-head attention mechanism to predict the classification result of the patient's psychological emotion in the next moment, and constructing an emotion classification loss accordingly; based on the predicted classification result of the patient's psychological emotion in the next moment, generating the patient's response in the next moment through a masked multi-head self-attention mechanism of Tranformer, and constructing a patient response loss accordingly; constructing a total loss function based on the emotion classification loss and the patient response loss, and training the psychological patient dialogue model until convergence. Thus, the response of the patient to be analyzed in the next moment is generated. By introducing the patient's background information, it is beneficial to select vocabulary that is more consistent with the patient to generate a complete response, enabling the model to learn the patient's dialogue style more accurately. Attached Figure Description

[0061] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0062] Figure 1 A block diagram illustrating a method for generating digital patient dialogue based on multi-turn dialogue, provided in an embodiment of the present invention;

[0063] Figure 2 This is a schematic diagram of the structure of a dialogue model for mental patients provided in an embodiment of the present invention. Detailed Implementation

[0064] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention are described clearly and completely. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0065] This application provides a method, system, storage medium, and electronic device for generating digital patient dialogues based on multi-turn dialogues. This addresses the technical problem that the speaker's emotional state may be affected by many different factors in the dialogue, making it impossible to accurately learn the patient's dialogue style.

[0066] The technical solution in this application is to solve the above-mentioned technical problems, and the general idea is as follows:

[0067] In this embodiment of the invention, for the transfer of emotions in patients, the GRU structure is used to explore the mutual influence mechanism of the psychological states of both parties in the dialogue, understand the verbal content of others and the patient's previous psychological changes, and use attention mechanisms to generate a simulated digital patient's psychological state after the transfer based on the patient's background information. Theoretically, this method has a good effect on the transfer of emotions in the dialogue process, and it conforms to the dialogue process of people in daily life.

[0068] In reality, an individual's life experiences and personality have a certain influence on their way of communicating with others and their emotional responses. Therefore, when generating responses, "background" information about the patient is introduced. This helps to select words that are more in line with the patient's personality to generate a complete response, enabling the model to learn the patient's conversational style more accurately.

[0069] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.

[0070] Example:

[0071] like Figure 1 As shown, this embodiment of the invention provides a method for generating digital patient dialogue based on multi-turn dialogue, based on... Figure 2 The illustrated patient dialogue model includes GRU, multi-head attention mechanism, and Tranformer. The digital patient dialogue generation method includes:

[0072] S1. Collect and quantify the patient's dialogue history, and obtain the historical sentence sets of the patient and their dialogue partners respectively;

[0073] S2. The historical statements of the patient and their conversation partners are used as inputs to the GRU to obtain the first and second hidden states respectively.

[0074] S3. Based on the first and second hidden states and the encoding results of the background information, the multi-head attention mechanism is used to predict the classification result of the patient's psychological emotions at the next moment, and an emotion classification loss is constructed accordingly.

[0075] S4. Based on the predicted classification results of the patient's psychological emotions in the next moment, the patient's response in the next moment is generated through the masked multi-head self-attention mechanism of the Tranformer, and the patient response loss is constructed accordingly.

[0076] S5. Based on the emotion classification loss and patient response loss, construct the total loss function and train the psychological patient dialogue model until convergence;

[0077] S6. Use the dialogue history of the patient to be analyzed as input to the converged psychological patient dialogue model, and generate the patient's response at the next moment.

[0078] By incorporating the patient's background information, this invention helps to select vocabulary that better matches the patient's speech patterns and generate complete responses, enabling the model to learn the patient's dialogue style more accurately.

[0079] The following will detail each step of the above solution:

[0080] In step S1, the patient's dialogue history is collected and quantified, obtaining the historical sentence sets of the patient and their interlocutors; including:

[0081] Collect the dialogue history of the patient and their interlocutor. in x and y represent the speaker and the patient, respectively, N. c The selected dialogue sequence length, d model For the selected vector dimension;

[0082] When the dialogue reaches round t+1, the dialogue history... C t+1 In Based on the conversion of the Bert pre-trained model Get

[0083] Among them, C' t+1 Divided into a collection of patients' historical statements and the historical statement collection of the interlocutors

[0084] The following is Convert to The formula:

[0085]

[0086]

[0087]

[0088] In particular, background information can also be collected in this step. Similarly, the BERT pre-trained model is converted into the corresponding encoded results. Where, N B The length of the selected background information sequence.

[0089] In step S2, the historical statements of the patient and their conversation partner are used as inputs to the GRU to obtain the first and second hidden states respectively.

[0090] This step will and After passing through the GRU, consecutive hidden states are obtained. and in Its function is to model the internal emotional changes of individuals in a dialogue, helping the system to better understand and analyze the emotional state of the participants in the dialogue.

[0091] In step S3, based on the first and second hidden states and the encoding results of the background information, the multi-head attention mechanism is used to predict the classification result of the patient's psychological emotions at the next moment, and an emotion classification loss is constructed accordingly.

[0092] Using the personality influence generated by background information B′, the emotional state of others at time t+1. The emotional stimuli generated are based on the patient's past emotional state. Using a multi-head attention mechanism to predict the patient's psychological state. t+1 This is to guide patients in recovering and generating new cells.

[0093] Accordingly, this step includes:

[0094] Set the number of attention heads to n. head B′ is used as the query vector. As key vectors and value vectors; the calculation formula is as follows:

[0095] Q i =B′W i Q

[0096] K i =MW i K

[0097] V i =MW i V

[0098]

[0099]

[0100] s t+1 =FFN(s′) t+1 )

[0101] Among them, in attention head i, W i Q W i K W i V These are the weight matrices for the query vector, key vector, and value vector, respectively.

[0102] The classification results of the patient's psychological and emotional state at the predicted time t+1 are used to determine the patient's psychological and emotional state. t+1 After passing through a fully connected layer, the classification of patients' psychological emotions is achieved, with a total of s. n Emotion category, the tags for emotion category are Using the cross-entropy loss function:

[0103]

[0104]

[0105] Among them, L s The loss function is the emotion classification loss of all responses from the patient from time 0 to t+1.

[0106] In step S4, based on the predicted classification results of the patient's psychological emotions at the next moment, the patient's response at the next moment is generated through the masked multi-head self-attention mechanism of the Tranformer, and the patient response loss is constructed accordingly.

[0107] Dialogue History Information C t The entire conversation contains the main theme and is related to the patient's responses; the previous segment U... t Includes the main content of the current conversation and the patient's psychological state. t+1 It is related to the emotions expressed in the patient's response.

[0108] Accordingly, this step includes:

[0109] Patient's response Where r i For the word in the reply, n c for The sequence length, O is the sequence length. The hidden state obtained through the Tranformer mask multi-head self-attention mechanism is generated in the following way:

[0110] A t =CROSS-ATTENTION(O,C t+1 )

[0111] A u =CROSS-ATTENTION(O,U t+1 )

[0112] A s =CROSS-ATTENTION(O,s t+1 )

[0113] A b =CROSS-ATTENTION(O,B′)

[0114] O′=FFN(A t +A u +A s +A b +O)

[0115] in, right The predicted probability;

[0116] Received incomplete response O k ={ <bos>,r1,r2,...,r k },get Therefore, we can know r k+1 And update O k For O k+1 ;

[0117] Based on this, a loss function for patient responses is constructed:

[0118]

[0119] In step S5, based on the emotion classification loss and the patient response loss, a total loss function is constructed and the psychological patient dialogue model is trained until convergence.

[0120] Based on the descriptions in steps S3 and S4, the total loss function can be expressed as L = L r +L s .

[0121] In step S6, the dialogue history of the patient to be analyzed is used as input to the converged psychological patient dialogue model to generate the patient's response at the next moment.

[0122] This invention enables the analysis of emotional transfer patterns and the extraction of dialogue patterns from mental patients, allowing digital mental patients to mimic real-life mental patients and exhibit similar emotional activities and language styles. It can be used to construct an emotional support dialogue dataset for mental patients, providing diverse digital mental patient roles in multi-role emotional support dialogues under different background information of mental patients.

[0123] In addition to this, various mental health patients can be constructed based on this model to engage in dialogue with digital psychologists, which can help train digital psychologists online. This allows digital psychologists to fully learn and update their existing experience, thereby gaining better communication skills and other information, further enhancing the performance of digital psychologists.

[0124] Specific applications include, but are not limited to:

[0125] (1) Clinical practice: Psychologists can use the dialogues generated by this model to communicate and treat mental health patients. This model can help psychologists better understand the patient's psychological state and needs, thereby providing more personalized treatment plans.

[0126] (2) Training of psychologists: The training of psychologists requires a lot of practical experience and case analysis. The digital dialogue generation model of mental patients can provide more examples and cases for training, helping trainees to better cultivate the skills and experience of psychologists.

[0127] (3) Data collection and analysis: Through the digital generation of dialogues of mental patients, a large amount of verbal and emotional data of mental patients can be collected to conduct research such as emotion analysis and emotion recognition, providing data support for scientific research in the field of mental health.

[0128] This invention provides a digital patient dialogue generation system based on multi-turn dialogue, using a psychological patient dialogue model, which includes GRU, multi-head attention mechanism, and Tranformer. The digital patient dialogue generation system includes:

[0129] The vectorization module is used to collect and quantize the patient's dialogue history, and obtain the historical sentence sets of the patient and their interlocutors respectively.

[0130] The analysis module is used to take the historical statements of the patient and their interlocutor as input to the GRU and obtain the first and second hidden states accordingly.

[0131] The prediction module is used to predict the classification result of the patient's psychological emotion at the next moment based on the first and second hidden states and the encoding result of the background information, using the multi-head attention mechanism, and to construct the emotion classification loss accordingly.

[0132] The generation module is used to generate the patient's response at the next moment based on the predicted classification result of the patient's psychological emotions at the next moment, through the masked multi-head self-attention mechanism of the Tranformer, and to construct the patient response loss accordingly.

[0133] The training module is used to construct a total loss function based on the emotion classification loss and the patient response loss, and to train the psychological patient dialogue model until convergence.

[0134] The application module is used to take the dialogue history of the patient to be analyzed as input to the converged psychological patient dialogue model and generate the patient's response at the next moment.

[0135] This invention provides a storage medium storing a computer program for generating digital patient dialogues based on multi-turn dialogues, wherein the computer program causes a computer to execute the digital patient dialogue generation method described above.

[0136] This invention provides an electronic device, comprising:

[0137] One or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs including methods for performing the digital patient dialogue generation method as described above.

[0138] It is understood that the digital patient dialogue generation system, storage medium and electronic device based on multi-turn dialogue provided in the embodiments of the present invention correspond to the digital patient dialogue generation method based on multi-turn dialogue provided in the embodiments of the present invention. The explanation, examples and beneficial effects of the relevant content can be referred to the corresponding parts of the digital patient dialogue generation method, and will not be repeated here.

[0139] In summary, compared with existing technologies, it has the following beneficial effects:

[0140] 1. By incorporating the patient's background information, this embodiment of the invention helps to select vocabulary that better matches the patient to generate a complete response, enabling the model to learn the patient's dialogue style more accurately.

[0141] 2. The embodiments of the present invention utilize the BERT model and attention mechanism to improve the understanding of multi-turn dialogue context, thereby obtaining more accurate dialogue information.

[0142] 3. Based on the dialogue information, this invention models the process of changes in the patient's psychological state and proposes to use information such as the patient's personality and condition, and adopt a multi-head cross-attention mechanism to predict the patient's psychological state after the transfer.

[0143] 4. In the patient response generation process, this embodiment of the invention utilizes dialogue history information, patient psychological state, patient background information, and adjacent utterance information to achieve cross-attention and obtain vector results, which are then combined to obtain an accurate response result.

[0144] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0145] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.< / bos> < / bos> < / bos>

Claims

1. A method for generating digital patient dialogue based on multi-turn dialogue, characterized in that, Based on a dialogue model for mental patients, which includes GRU, multi-head attention mechanisms, and Tranformer, the method for generating digital patient dialogue includes: Collect and quantify the patient's dialogue history, and obtain the historical sentence sets of the patient and their interlocutors respectively; The patient's and their conversation partner's historical statements are used as inputs to the GRU to obtain the first and second hidden states respectively. Based on the first and second hidden states and the encoding results of the background information, the multi-head attention mechanism is used to predict the classification result of the patient's psychological emotions at the next moment, and an emotion classification loss is constructed accordingly. Based on the predicted classification results of the patient's psychological emotions in the next moment, the patient's response in the next moment is generated through the masked multi-head self-attention mechanism of the Tranformer, and the patient response loss is constructed accordingly. Based on the emotion classification loss and patient response loss, a total loss function is constructed and the psychological patient dialogue model is trained until convergence. The dialogue history of the patient to be analyzed is used as input to the converged dialogue model of the mental patient to generate the patient's response at the next moment. The step involves using the multi-head attention mechanism to predict the patient's emotional classification result at the next moment based on the first and second hidden states, combined with the encoding results of background information, and constructing an emotion classification loss accordingly; including: Set the number of attention headers to , As a query vector As key vectors and value vectors, where, These represent the speaker and the patient, respectively; the calculation formula is as follows: Among them, in the attention head middle, These are the weight matrices for the query vector, key vector, and value vector, respectively. For the selected vector dimension; Predict Classification results of patients' psychological and emotional states at any time After passing through a fully connected layer, the classification of patients' psychological and emotional states is achieved, totaling [number missing]. Emotion category, the tags for emotion category are Using the cross-entropy loss function: in, The loss function is the emotion classification loss of all responses from the patient from time 0 to t+1. A collection of historical dialogue statements between the patient and their interlocutor; The process involves generating the patient's response for the next moment based on the predicted classification of the patient's psychological and emotional state, using the masked multi-head self-attention mechanism of the Tranformer, and constructing the patient response loss accordingly; including: Patient's response ={ },in for The sequence length, The hidden state obtained through the Tranformer mask multi-head self-attention mechanism is generated in the following way: in, = right The predicted probability, when During the dialogue rounds, the dialogue history , The encoding result for background information; Received incomplete reply = ,get Therefore, it can be concluded that And update for ; Based on this, a loss function for patient responses is constructed: 。 2. The digital patient dialogue generation method as described in claim 1, characterized in that, The process of collecting and quantifying the patient's historical dialogue dataset involves obtaining sets of historical statements from the patient and their interlocutors, including: Collect the dialogue history of the patient and their interlocutor. ,in , They represent the speaker and the patient, respectively. Selected dialogue sequence length, For the selected vector dimension; when During the dialogue, the dialogue history ,Will In Based on the conversion of the Bert pre-trained model To obtain ; Among them, Divided into a collection of patients' historical statements and the historical statement set of the interlocutors. .

3. The digital patient dialogue generation method as described in claim 2, characterized in that, The encoding results of pre-acquired background information include: Collect background information Based on the BERT pre-trained model, the corresponding encoded results are converted. ;in, The length of the selected background information sequence.

4. The digital patient dialogue generation method as described in claim 1, characterized in that, The total loss function is expressed as: .

5. A digital patient dialogue generation system based on multi-turn dialogue, characterized in that, Based on a dialogue model for mental patients, including GRU, multi-head attention mechanisms, and Tranformer, the digital patient dialogue generation system is used to execute the digital patient dialogue generation method according to any one of claims 1 to 4, including: The vectorization module is used to collect and quantize the patient's dialogue history, and obtain the historical sentence sets of the patient and their interlocutors respectively. The analysis module is used to take the historical statements of the patient and their interlocutor as input to the GRU and obtain the first and second hidden states accordingly. The prediction module is used to predict the classification result of the patient's psychological emotion at the next moment based on the first and second hidden states and the encoding result of the background information, using the multi-head attention mechanism, and to construct the emotion classification loss accordingly. The generation module is used to generate the patient's response at the next moment based on the predicted classification results of the patient's psychological emotions at the next moment, through the masked multi-head self-attention mechanism of the Tranformer, and to construct the patient response loss accordingly. The training module is used to construct a total loss function based on the emotion classification loss and the patient response loss, and to train the psychological patient dialogue model until convergence. The application module is used to take the dialogue history of the patient to be analyzed as input to the converged psychological patient dialogue model and generate the patient's response at the next moment.

6. A storage medium, characterized in that, It stores a computer program for generating digital patient dialogues based on multi-turn conversations, wherein the computer program causes a computer to perform the digital patient dialogue generation method as described in any one of claims 1 to 4.

7. An electronic device, characterized in that, include: One or more processors; Memory; And one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs including methods for performing the digital patient dialogue generation method as described in any one of claims 1 to 4.