A Message Generation Method for Emotion Reproduction
By constructing emotional event extraction and classification models, combining emotional event knowledge graphs, predicting the depressed emotional reproduction cycle of depressed patients and generating message reminders, the problem of inaccurate prediction of the onset cycle of depressed patients and generating relief messages in the prior art is solved, and timely relief of depressed emotions is achieved.
Patent Information
- Application Number
- CN202310301933.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-24
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2043-03-24
AI Technical Summary
The prior art is difficult to accurately predict the onset cycle and severity of patients with depression, and it is impossible to generate information that relieves patients' emotions in a timely manner.
By constructing an emotional event extraction model and an emotional event classification model, obtain historical dialogue data between users and the chat system, build an emotional event knowledge graph, use the trained model to predict the probability of reappearance of depression, and generate corresponding message reminders.
Accurately predict the depressed emotional reproduction cycle of patients with depression, generate corresponding messages to relieve patients' emotions, and reduce the possibility of patients' risk.
Smart Images

Figure CN116483984B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of information processing, and in particular, to a message generation method and system for emotion reproduction. Background Art
[0002] With the development of intelligent technologies, many patients with depression like to vent their emotions through chat systems. If the chat content between patients with depression and chat systems can be obtained, the onset cycle and severity of the patients can be predicted, and the patients can be cared for and treated in a timely manner, then the emotions of the patients can be alleviated or even their lives can be saved. Therefore, there is an urgent need in the prior art for a message generation method and system for emotion reproduction that can predict the depression emotion cycle of patients and generate corresponding messages to alleviate the emotions of patients. Summary of the Invention
[0003] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a message generation method for emotion reproduction, which can accurately predict the cycle of the reproduction of the depression emotions of patients and generate corresponding messages to alleviate the depression emotions of patients.
[0004] The purpose of the present invention can be achieved by the following technical solutions:
[0005] The present invention provides a message generation method for emotion reproduction, including the following steps:
[0006] S1: Obtain the historical conversation data between a user and a chat system, construct and train an emotion event extraction model and an emotion event classification model. The trained emotion event extraction model is used to extract emotion events and emotion event elements from the conversation data, and the trained emotion event classification model is used to classify the emotions corresponding to each piece of conversation data and generate corresponding emotion category labels. The emotion categories include positive, negative, normal, and depression;
[0007] S2: Through the trained emotion event extraction model and emotion event classification model in S1, obtain the emotion category label, emotion event, and emotion event element of each conversation. According to the emotion category label of each conversation, count the number of depression events that occur daily for the user, calculate the average daily depression event value, and use the emotion events and emotion event elements with the emotion category label of depression as the user's depression warning keywords;
[0008] S3: Use the emotion event and emotion event element as the head entity and tail entity in the emotion event knowledge graph respectively. According to the emotion category label, set the depression degree of the emotion event corresponding to the conversation data, and then construct the emotion event knowledge graph;
[0009] S4: Using the emotion event extraction model and emotion event classification model trained in S1, obtain the emotion events, emotion event elements of the depressive dialogue data, and the emotion event elements of the negative dialogue data respectively as the current context keywords.
[0010] S5: Obtain the predicted event set based on the emotion events of the current dialogue and the emotion event knowledge graph in S3.
[0011] S6: Calculate the probability value of the user's depressive context keywords according to the user's depressive context keywords in S2. Based on the current context keywords in S4 and the user's depressive context keywords, obtain the depressive keyword probability value.
[0012] S7: Train the daily depressive event regression model according to the average value of the daily depressive events in S2. From the trained daily depressive event regression model, obtain the average value of the depressive events occurring on the current day. Access the predicted event set in S5 to determine the final number of depressive events. According to the average value of the depressive events occurring on the current day and the final number of depressive events, calculate the predicted event depressive probability value. Combine with the calculation of the depressive keyword probability value in S6 to calculate the depressive emotion recurrence probability, and generate a message reminder according to the depressive emotion recurrence probability.
[0013] Preferably, in S3, the relationship between the emotion event and the emotion event element is described by the triple: event - attribute - event element. In the emotion event knowledge graph, the triples with emotion category labels of positive, negative, normal, and depressive are respectively: the first event - the first attribute - the first event element, the second event - the second attribute - the second event element, the third event - the third attribute - the third event element, the fourth event - the fourth attribute - the fourth event element; the depressive degrees are respectively: the first event - depressive degree - highest, the second event - depressive degree - high, the third event - depressive degree - low, the fourth event - depressive degree - lowest; add the first relationship between each event in the daily dialogue data.
[0014] Preferably, S6 specifically includes the following steps:
[0015] S601: For each user depressive context keyword in S2, use the attribute being the first attribute and the tail entity belonging to the user depressive warning keyword as the matching condition to match each triple in the emotion event knowledge graph, and form the depressive context triples with the successfully matched triples.
[0016] S602: Obtain the number and head entity of the depressive context triples. Query the depressive degree value corresponding to the head entity of the depressive context triples through the emotion event knowledge graph, and calculate the probability value of the user's depressive context keyword according to the depressive degree value and the number of depressive context triples.
[0017] S603: Perform a similarity match between the current context keywords in S4 and the user's depression context keywords to obtain the matching value corresponding to each word. Combine the probability value of the user's depression context keywords in S602 to obtain the current context keyword matching value;
[0018] S604: Set a first weight factor and calculate the depression keyword probability value in combination with the current context keyword matching value.
[0019] Preferably, the said S4 specifically includes the following steps:
[0020] Obtain the current conversation data between the user and the chat system. Input each piece of conversation data into the emotion event classification model trained in S1. Save the conversation data with the emotion labels of depression and negativity. Input the depression conversation data into the emotion event extraction model trained in S1, and output the emotion events and emotion event elements corresponding to the depression conversation data, which are used as the first keywords in the current context. Input the negative conversation data into the trained emotion event extraction model, and output the emotion event elements corresponding to the negative conversation data, which are used as the second keywords in the current context. The first keywords and the second keywords in the current context together constitute the current context keywords.
[0021] Preferably, the said S603 specifically includes the following steps:
[0022] Perform a cosine similarity match between each word in the first keywords in the current context and the user's depression context keywords to obtain the matching value corresponding to each word. Multiply the matching value corresponding to each word by the probability value of the user's depression context keywords to obtain the matching value corresponding to each word in the first keywords in the current context. Accumulate the matching values corresponding to each word in the first keywords in the current context. Divide the total sum of the accumulated matching values by the number of words in the first keywords in the current context to obtain the first matching value;
[0023] Perform a cosine similarity match between each word in the second keywords in the current context and the user's depression context keywords to obtain the matching value corresponding to each word. Multiply the matching value corresponding to each word by the probability value of the user's depression context keywords to obtain the matching value corresponding to each word in the second keywords in the current context. Accumulate the matching values corresponding to each word in the second keywords in the current context. Divide the total sum of the accumulated matching values by the number of words in the second keywords in the current context to obtain the second matching value.
[0024] Preferably, in S603, the formula for describing the cosine similarity match is as follows:
[0025]
[0026] where A i represents each word in the current context keywords; B iDenote the keywords in the context of user depression, where \(i\) is the index and the range is within \([1, n]\).
[0027] Preferably, step S604 specifically includes the following steps:
[0028] Set a first weight factor, where the first weight factor is a value between 0 and 1. Subtract the first weight factor from 1 to obtain the first anti - weight factor. Use the method of multiplying the first matching value by the first weight factor plus multiplying the second matching value by the first anti - weight factor to obtain the depression keyword probability value.
[0029] Preferably, step S7 specifically includes the following steps:
[0030] S701: Construct and train a daily depression event regression model based on the average value of daily depression events in S2;
[0031] S702: Input the current date into the daily depression event regression model trained in S702 to obtain the average value of depression events occurring on the current day;
[0032] S703: Set a predicted event depression preset value, initialize the number of depression events. Access each predicted event in the predicted event set of S5. When the depression level of the predicted event is greater than the predicted event depression preset value, increment the number of depression events by 1 to obtain the final number of depression events;
[0033] S704: Calculate the ratio between the final number of depression events in S703 and the average value of depression events occurring on the current day in S702 to obtain the predicted event depression probability value;
[0034] S705: Set a second weight factor, where the second weight factor is a value between 0 and 1. Subtract the second weight factor from 1 to obtain the second anti - weight factor. Use the method of multiplying the depression keyword probability value in S604 by the second weight factor plus multiplying the predicted event depression probability value in S704 by the second anti - weight factor to obtain the depression emotion recurrence probability;
[0035] S706: Set a first recurrence probability value and a second recurrence probability value. Generate a message reminder according to the size relationship between the depression emotion recurrence probability value and the first recurrence probability value and the second recurrence probability value.
[0036] Preferably, if the predicted event depression probability value in S704 is greater than or equal to 1, set the predicted event depression probability value as the first depression probability value; if it is less than 1, set the predicted event depression probability value as the second depression probability value. When the predicted event depression probability value is the first depression probability value, send a message to the user's emergency contact every preset time to pay close attention to the patient.
[0037] Preferably, step S706 is specifically:
[0038] When the recurrence probability value of the depressive mood is less than or equal to the first recurrence probability value, send a message to the current user;
[0039] When the recurrence probability value of the depressive mood is greater than the first recurrence probability value and less than or equal to the second recurrence probability value, while sending a message to the current user, provide cheerful music in a voice-playing manner, and at the same time, obtain the contact number of the user's emergency contact from the A chat system and send a message to this contact number;
[0040] When the recurrence probability value of the depressive mood is greater than the second recurrence probability value, while sending a message to the current user, provide cheerful music in a voice-playing manner, send a message to the user's emergency contact, and send a message to the user's emergency contact once every preset time.
[0041] Compared with the prior art, the present invention has the following beneficial effects:
[0042] A message generation method for emotion recurrence provided by the present invention, by obtaining the historical conversation data between the user and the chat system, constructing and training an emotion event extraction model and an emotion event classification model, using the two trained models, combining the current chat content, comprehensively determining the probability that the user will have depression again currently, generating a message and notifying the user's family in time, reducing the possibility of danger to the user. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flowchart of a message generation method for emotion recurrence provided by the present invention.
[0044] Figure 2 It is a schematic diagram of a message generation method for emotion recurrence provided by the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0045] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. This embodiment is implemented on the premise of the technical solution of the present invention, and gives the detailed implementation manner and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0046] Refer to Figure 1 and Figure 2 As shown, this embodiment provides a message generation method for emotion recurrence, including the following steps:
[0047] S1: Obtain the historical conversation data between the user and the chat system, construct and train an emotion event extraction model. The trained emotion event extraction model is used to extract emotion events and emotion event elements from the conversation data; construct and train an emotion event classification model. The trained emotion event classification model is used to classify the emotions corresponding to each conversation data and generate corresponding emotion category labels. The emotion categories include positive, negative, normal, and depressive.
[0048] Specifically, according to the user name, obtain the historical conversation data between the user and the A chat system from the conversation history storage file of the A chat system. Each piece of historical conversation data corresponds to a chat time, and the chat time includes year, month, and day. According to the chat month corresponding to the conversation data, divide the conversation data to obtain historical conversation data for different months.
[0049] Set the start month, obtain months by extracting every other month, and use the extracted months as the model training months. Upload them to the user conversation history storage module in the conversation system server. The conversation system server includes a user conversation history storage module, a model preprocessing data module, a user daily conversation history module, a user daily depressive conversation history module, and a user depressive context keyword module. The conversation data corresponding to the model training months is used as the training set, and the remaining months after extraction are used as the model validation months. The conversation data corresponding to the model validation months is used as the validation set.
[0050] For the emotion event extraction model, before training the emotion event extraction model, first preprocess the training set and the validation set. The preprocessing includes: removing punctuation marks from the training set and the validation set, and using jieba for word segmentation. Upload the processed results to the model preprocessing data module in the conversation system server. Process the results of the word segmentation through word2vec to obtain the vector representation corresponding to each conversation data; manually label the emotion events and emotion event elements corresponding to the training set and the validation set. Among them, the emotion event represents the verb in this piece of conversation data, and the emotion event element represents the noun related to the verb in this piece of conversation data.
[0051] Build a recurrent neural network model, set the first recurrent threshold and the first F1 threshold. For each iteration, input the vector representation of the training set into the built recurrent neural network model to output events and event elements. Input the output results of the recurrent neural network and the corresponding manually annotated emotion events and emotion event elements into the cross-entropy loss function to obtain a loss value. According to the loss value, use the backpropagation method to obtain the gradients of each parameter in the recurrent neural network model, and use the stochastic gradient descent optimization algorithm to update each parameter in the recurrent neural network model. After passing the first recurrent threshold, input the validation set into the recurrent neural network model and calculate the evaluation metric F1 value. When the F1 value does not reach the first F1 threshold, continue to train the recurrent neural network model for the number of times of the first recurrent threshold until the F1 value reaches the first F1 threshold, then stop training to obtain a trained emotion event extraction model. Upload the labels of each conversation history in the model training month and the model validation month to the corresponding position in the conversation history storage module corresponding to this conversation history, where the labels are composed of the corresponding emotion events and emotion event elements.
[0052] For example, if the starting month is set to January, the model training months of the emotion event extraction model are January, March, May, July, September, and November respectively, and the model validation months are February, April, June, August, October, and December; the conversation data is "Today, a colleague broke my water cup, which made me very angry". After removing punctuation and performing word segmentation, the result is: today / colleague / broke / my / water / cup / which / made / me / very / angry. The emotion events output by the emotion event extraction model are: broke, which; the emotion event elements are: colleague, water cup, angry; in this embodiment, the first recurrent threshold is 1000 and the first F1 threshold is 0.9.
[0053] For the emotion event classification model, before training the emotion event classification model, obtain the conversation histories in the model training month and the model validation month from the model preprocessing data module in the dialogue system server, input both the training set and the validation set into the Glove word vector encoder to obtain the corresponding vectorized representations; manually annotate the emotion category labels of each conversation data corresponding to the model training month and the model validation month, and the emotion category labels are positive, negative, normal, and depressive, and upload the emotion category labels of each conversation history in the model training month and the model validation month to the corresponding position in the conversation history storage module corresponding to this conversation history.
[0054] Build a Bert classification model, set the second loop threshold and the second F1 threshold, input the vectorized representation corresponding to the training set into the Bert classification model, output the emotion categories corresponding to each dialogue data, input the output result of the Bert classification model and the manually labeled emotion category labels into the cross-entropy loss function to obtain the emotion classification loss value corresponding to the dialogue data. Through backpropagation, obtain the gradients of each parameter in the Bert classification model, and use the stochastic gradient descent optimization algorithm to optimize the parameters in the Bert classification model; after passing the second loop threshold, input the validation set into the Bert classification model, calculate the evaluation index F1 value. When the F1 value does not reach the second F1 threshold, continue to train the Bert classification model for the number of times of the second loop threshold until the F1 value reaches the second F1 threshold, and stop training to obtain the emotion event classification model; in this embodiment, the second loop threshold is 1000 and the second F1 threshold is 0.95.
[0055] S2: Input all the dialogue data with days as nodes into the emotion event classification model and the emotion event extraction model trained in S1 respectively to obtain the emotion category labels, emotion events and emotion event elements of each dialogue. According to the emotion category labels of each dialogue, count the number of depressive events that occur daily for this user, calculate the average daily depressive event value, and use the emotion events and emotion event elements with the emotion category label of depression as the user's depression warning keywords.
[0056] S201: Divide the historical dialogue data with days as nodes to obtain the dialogue data of the first day, the dialogue data of the second day,..., the dialogue data of the mth day;
[0057] S202: Input each dialogue of the daily dialogue data into the emotion event classification model and the emotion event extraction model trained in S1 respectively to obtain the emotion category labels, emotion events and emotion event elements of each dialogue, and upload the daily dialogue data and the corresponding emotion category labels to the user's daily dialogue history module in the dialogue system server;
[0058] S203: In the daily dialogue data, use Python programming to access each dialogue data, and use regularization to obtain the depressive dialogue data of the first day,..., the depressive dialogue data of the mth day, that is, remove the dialogue data with emotion labels of normal, positive and negative, and only leave the dialogue data with the emotion label of depression. The dialogue with the emotion label of depression indicates that this user has had a depressive event. Count the number of depressive events that occur daily for this user respectively, accumulate the number of depressive events in the depressive dialogue data of the first day,..., the depressive dialogue data of the mth day to obtain the daily depressive event count, divide the daily depressive event count by m to obtain the average daily depressive event value, and upload it to the user's daily depressive dialogue history module in the dialogue system server;
[0059] S204: Input each conversation data in the depression conversation data on the first day, ……, and the depression conversation data on the mth day into the emotion event extraction model trained in S1, output the emotion events and emotion event elements with the emotion category label being depression, and form the user's depression context keywords with the emotion events and emotion event elements whose emotion category label is depression. Upload the user's depression context keywords to the user's depression context keyword module in the conversation system server;
[0060] S3: Construct an emotion event knowledge graph based on the emotion events and emotion event elements. The emotion event knowledge graph is used to describe the relationship between emotion events and emotion event elements, and the relationship between various events in the daily conversation data.
[0061] Specifically, take the emotion events and emotion event elements as entities in the emotion event knowledge graph, and describe the relationship between emotion events and emotion event elements in the way of triple: event - attribute - event element. In the emotion event knowledge graph, add the first relationship between various events in the daily conversation data.
[0062] According to the output results of S202 and S204, set the emotion events corresponding to the conversation data with emotion labels of depression, negative, normal, and positive as the first event, the second event, the third event, and the fourth event respectively, and set the corresponding emotion event elements as the first event element, the second event element, the third event element, and the fourth event element respectively, to obtain the triples in the emotion event knowledge graph: the first event - the first attribute - the first event element, the second event - the second attribute - the second event element, the third event - the third attribute - the third event element, the fourth event - the fourth attribute - the fourth event element;
[0063] At the same time, set the depression degree relationship of the occurrence of the first event to the highest, that is: the first event - depression degree - highest, set the depression degree relationship of the occurrence of the second event to high, that is: the second event - depression degree - high, set the depression degree relationship of the occurrence of the third event to low, that is: the third event - depression degree - low, set the depression degree relationship of the occurrence of the fourth event to the lowest, that is: the fourth event - depression degree - lowest;
[0064] In the emotion event knowledge graph, add the first relationship between various events in the conversation data on the first day, ……, and between various events in the conversation data on the mth day respectively; the events of the user's depression context keywords are all depression events, so the depression degree of the occurrence of these events is set to the highest, while the conversations with emotion category labels of negative, normal, and positive relatively speaking indicate that the depression degree of occurrence is gradually weaker in turn, so their depression degrees are set to high, low, and lowest respectively; since the events occurring daily are all related, so in the emotion event knowledge graph, associate these events, and the corresponding relationship is the first relationship.
[0065] S4: Obtain the current conversation data between the user and the chat system, input each piece of conversation data into the trained emotion event classification model, save the conversation data with emotion labels of depression and negativity, obtain x pieces of depressive conversation data and y pieces of negative conversation data, input the x pieces of depressive conversation data into the trained emotion event extraction model, output the emotion events and emotion event elements corresponding to the depressive conversation data, and use them as the first keywords in the current context. Input the y pieces of negative conversation data into the trained emotion event extraction model, output the emotion event elements corresponding to the negative conversation data, and use them as the second keywords in the current context. The first keywords and the second keywords in the current context jointly constitute the keywords in the current context.
[0066] When obtaining the keywords in the current context, the conversation data with an emotion label of negativity should not be ignored, because these conversation data may imply the user's current low mood. In order to accurately determine whether the user's current conversation is in a depressive state, the conversation data between the current user and the chat system should be comprehensively considered; however, the intensity of the user's depressive state indicated by the negative conversation data is lower than that of the depressive conversation data. Therefore, when obtaining keywords from the negative conversation data, only the event elements output by the emotion event extraction model are retained.
[0067] S5: Use Python programming to match the emotion events in the current conversation with the head entities of the triples in the emotion event knowledge graph respectively. When the match is successful, save the triple where the head entity is located. When the match fails, filter out the triple where this entity is located. Combine all the saved triples to form emotion event triples; use Python programming to traverse the emotion event triples, obtain the tail entities in the triples with the attribute of the first relationship, and get the first prediction event set; obtain each tail entity in the first prediction event set, query the corresponding depression level of the tail entity through the emotion event knowledge graph, and save it to the first prediction event set to obtain the prediction event set.
[0068] In the emotion event knowledge graph, the first relationship indicates that two events are related, that is, one event will trigger another event or the two events will occur simultaneously. Since there may be multiple triples with the emotion event triple relationship of the first relationship, these multiple tail entities form the prediction event set.
[0069] S6: Obtain the depressive context triples according to the user's depressive context keywords, query the corresponding depression level of the head entity of the depressive context triples through the emotion event knowledge graph, calculate the probability value of the user's depressive context keywords, and perform a similarity match between the keywords in the current context and the user's depressive context keywords to obtain the probability value of the depressive keywords.
[0070] S601: For each user depression context keyword, use the condition that the attribute is the first attribute and the tail entity belongs to the user depression warning keyword to match each triple in the emotion event knowledge graph. The successfully matched triples form the depression context triples.
[0071] S602: Obtain the number and head entities of the depression context triples. Query the depression degree values corresponding to the head entities of the depression context triples through the emotion event knowledge graph. Divide the obtained result by the number of depression context triples to calculate the probability value of the user depression context keyword. Upload the probability value of the user depression context keyword to the user depression context keyword module of the dialogue system server and correspond it to the user depression context keyword.
[0072] For example: The user depression context keyword is: sad. Use the condition that the attribute is the first attribute and the tail entity is sad to match and obtain the depression context triples: break - first attribute - sad, cry - first attribute - sad, fall - first attribute - sad. Then the number of depression context triples is 3, and the head entities in the depression context triples are: break, cry, fall. Query the corresponding depression degrees of the head entities break, cry, and fall in the emotion event knowledge graph, which are break - depression degree - 0.3, cry - depression degree - 0.7, fall - depression degree - 0.5 respectively. Accumulate the corresponding values of the depression degrees 0.3 + 0.7 + 0.5 = 1.5, and then divide by the number of depression context triples 1.5 / 3 = 0.5. Therefore, the probability value corresponding to the user depression context keyword sad is 0.5.
[0073] S603: Perform cosine similarity matching on each word in the current context first keyword with the user depression context keyword to obtain the matching value corresponding to each word. Multiply the matching value corresponding to each word by the probability value of the user depression context keyword to obtain the matching value corresponding to each word in the current context first keyword. Accumulate the matching values corresponding to each word in the current context first keyword. Divide the accumulated total matching value by the number of words in the current context first keyword to obtain the first matching value.
[0074] The formula for describing cosine similarity matching is as follows:
[0075]
[0076] Among them, A i represents each word in the current context keyword; B i represents the user depression context keyword, and i is the index, with the range in [1, n].
[0077] Match each word in the second keyword of the current context with the user's depression context keyword using cosine similarity to obtain the matching value corresponding to each word. Multiply the matching value corresponding to each word by the probability value of this user's depression context keyword to obtain the matching value corresponding to each word in the second keyword of the current context. Accumulate the matching values corresponding to each word in the second keyword of the current context. Divide the sum of the accumulated matching values by the number of words in the second keyword of the current context to obtain the second matching value.
[0078] S604: Set the first weight factor, where the first weight factor is a value between 0 and 1. Use 1 minus the first weight factor to obtain the first anti-weight factor. Use the method of multiplying the first matching value by the first weight factor plus the second matching value by the first anti-weight factor to obtain the depression keyword probability value.
[0079] Since the first keyword and the second keyword of the current context are obtained from the conversation history with emotion labels of depression and negativity respectively, the first keyword of the current context can better represent the state of the user's depression level, and more attention should be paid to this part of keywords; in this embodiment, the first weight factor is set to 0.8.
[0080] S7: Train the daily depression event regression model according to the average value of daily depression events in S2. Input the current date into the trained daily depression event regression model to obtain the average value of depression events occurring on the current day. Access the prediction event set in S5 to determine the final number of depression events. Calculate the prediction event depression probability value based on the average value of depression events occurring on the current day and the final number of depression events, and then calculate the depression emotion recurrence probability. Generate a message reminder according to the depression emotion recurrence probability.
[0081] S701: Construct and train the daily depression event regression model. The training process of the daily depression event regression model is specifically as follows:
[0082] Input the specific date into the pre-constructed daily depression event regression model. The label is the average value of daily depression events corresponding to each date. Input both the output result and the label of the model into the mean squared error loss function. Optimize each parameter in the daily depression event regression model through the stochastic gradient descent optimization method. After every third loop threshold number of trainings, test the model once to obtain the F1 value. Stop training until the F1 value reaches the third F1 threshold.
[0083] S702: Input the current date into the trained daily depression event regression model to obtain the average value of depression events occurring on the current day.
[0084] S703: Set the depression preset value for predicted events, initialize the number of depression events, access each predicted event in the predicted event set of S5. When the depression level of a predicted event is greater than the depression preset value for predicted events, increment the number of depression events by 1 to obtain the final number of depression events;
[0085] S704: Calculate the ratio between the final number of depression events in S703 and the average number of depression events that occurred on the current day in S702, which is the predicted event depression probability value. When the ratio is greater than or equal to 1, set the predicted event depression probability value to the first depression probability value. When the ratio is less than 1, set the predicted event depression probability value to the second depression probability value;
[0086] S705: Set the second weight factor, where the second weight factor is a value between 0 and 1. Use 1 minus the second weight factor to obtain the second anti - weight factor. Obtain the depression mood recurrence probability by multiplying the depression keyword probability value in S604 by the second weight factor and adding the predicted event depression probability value in S704 multiplied by the second anti - weight factor.
[0087] For example, over time, the user may have a situation where the depression level or the number of depression events gradually decreases or increases. Infer the situation of depression events occurring in the current conversation through the daily number of depression events and the daily average number of depression events. When the ratio between the final number of depression events and the average number of depression events that occurred on the current day is greater than 1, it indicates that the number of depression events occurring on the current day has exceeded the usual number of depression events, and at this time, the user needs to be given extra attention. In this embodiment, the second weight factor is set to 0.6.
[0088] S706: Set the first recurrence probability value and the second recurrence probability value. When the depression mood recurrence probability value is less than or equal to the first recurrence probability value, send a message to the current user. When the depression mood recurrence probability value is greater than the first recurrence probability value and less than or equal to the second recurrence probability value, while sending a message to the current user, provide cheerful music in a voice - playing manner. At the same time, obtain the contact phone number of the user's emergency contact from the A - type chat system and send a message to this contact phone number. When the depression mood recurrence probability value is greater than the second recurrence probability value, while sending a message to the current user and providing cheerful music in a voice - playing manner, send a message to the user's emergency contact and send a message to the user's emergency contact once every preset time.
[0089] For example, the first reproduction probability value is 0.4, the second reproduction probability value is 0.7, and the preset time is 2 minutes; the depression emotion reproduction probability value is not 0, indicating that the current user has a risk of experiencing a depression event. The greater the depression emotion reproduction probability, the greater the risk of experiencing a depression event. When the depression emotion reproduction probability value is less than or equal to 0.4, a message is sent to the current user: You can put down the work at hand first and look out of the window appropriately to receive the baptism of nature. When the depression emotion reproduction probability value is greater than 0.4 and less than or equal to 0.7, while sending a message to the current user, cheerful music is provided in a voice-playing manner. At the same time, the contact phone number of the user's emergency contact is obtained from the Type A chat system, and a message is sent to this contact phone number: The user currently has a risk of depression. Please pay attention in time. When the depression emotion reproduction probability value is greater than 0.7, while sending a message to the current user, cheerful music is provided in a voice-playing manner, and a message is sent to the user's emergency contact: The user currently has a high risk of depression. Please contact the user in time.
[0090] The preferred specific embodiments of the present invention have been described in detail above. It should be understood that those of ordinary skill in the art can make many modifications and variations according to the concept of the present invention without creative efforts. Therefore, all technical solutions that can be obtained by those skilled in the art in the technical field based on the concept of the present invention through logical analysis, reasoning, or limited experiments on the basis of the prior art should be within the protection scope determined by the claims.
Claims
1. A message generation method for emotion reproduction, characterized in that It includes the following steps: S1: Obtain the historical conversation data between the user and the chat system, construct and train an emotion event extraction model and an emotion event classification model. The trained emotion event extraction model is used to extract emotion events and emotion event elements from the conversation data, and the trained emotion event classification model is used to classify the emotions corresponding to each conversation data, generating corresponding emotion category labels. The emotion categories include positive, negative, normal, and depressive; S2: Through the trained emotion event extraction model and emotion event classification model in S1, obtain the emotion category label, emotion event, and emotion event elements of each conversation. According to the emotion category label of each conversation, count the number of depressive events that occur daily for the user, calculate the average daily depressive event value, and use the emotion events and emotion event elements with the emotion category label of depressive as the user's depressive warning keywords; S3: Use the emotion events and emotion event elements as the head entity and tail entity in the emotion event knowledge graph respectively. According to the emotion category label, set the depressive degree of the emotion event corresponding to the conversation data, and then construct the emotion event knowledge graph; S4: Through the trained emotion event extraction model and emotion event classification model in S1, obtain the emotion events, emotion event elements of the depressive conversation data, and the emotion event elements of the negative conversation data respectively as the current context keywords; S5: Obtain the predicted event set according to the emotion event of the current conversation and the emotion event knowledge graph in S3; S6: Calculate the probability value of the user's depressive context keywords according to the user's depressive context keywords in S2, and obtain the depressive keyword probability value according to the current context keywords in S4 and the user's depressive context keywords; S7: Train a daily depressive event regression model according to the average daily depressive event value in S2. Through the trained daily depressive event regression model, obtain the average value of the depressive events that occur on the current day, access the predicted event set in S5, determine the final number of depressive events, calculate the predicted event depressive probability value according to the average value of the depressive events that occur on the current day and the final number of depressive events, combine the calculation of the depressive keyword probability value in S6 to calculate the depressive emotion recurrence probability, and generate a message reminder according to the depressive emotion recurrence probability; 2. The method for generating a message for emotion reproduction according to claim 1, wherein In S3, the relationship between the emotion event and the emotion event element is described in the form of a triple: event - attribute - event element. In the emotion event knowledge graph, the triples with emotion category labels of positive, negative, normal, and depressive are respectively: the first event - the first attribute - the first event element, the second event - the second attribute - the second event element, the third event - the third attribute - the third event element, the fourth event - the fourth attribute - the fourth event element; the depressive degrees are respectively: the first event - depressive degree - highest, the second event - depressive degree - high, the third event - depressive degree - low, the fourth event - depressive degree - lowest; add the first relationship between each event in the daily conversation data; 3. The method for generating a message for emotion reproduction according to claim 2, wherein S6 specifically includes the following steps: S601: For each user's depression context keyword in S2, use the condition that the attribute is the first attribute and the tail entity belongs to the user's depression warning keyword to match each triple in the emotion event knowledge graph. The successfully matched triples form the depression context triples. S602: Obtain the number and head entity of the depression context triples. Query the depression degree value corresponding to the head entity of the depression context triples through the emotion event knowledge graph, and calculate the probability value of the user's depression context keyword based on the depression degree value and the number of depression context triples. S603: Perform a similarity match between the current context keyword in S4 and the user's depression context keyword to obtain the matching value corresponding to each word. Combine the probability value of the user's depression context keyword in S602 to obtain the current context keyword matching value. S604: Set the first weight factor, and calculate the depression keyword probability value in combination with the current context keyword matching value.
4. A method for generating a message for emotion reproduction according to claim 3, characterized in that The specific steps of S4 are as follows: Obtain the current conversation data between the user and the chat system. Input each piece of conversation data into the emotion event classification model trained in S1, and save the conversation data with the emotion labels of depression and negative. Input the depression conversation data into the emotion event extraction model trained in S1, and output the emotion events and emotion event elements corresponding to the depression conversation data, which are used as the first keywords in the current context. Input the negative conversation data into the trained emotion event extraction model, and output the emotion event elements corresponding to the negative conversation data, which are used as the second keywords in the current context. The first keywords and the second keywords in the current context together form the current context keyword.
5. The method for generating a message for emotion reproduction according to claim 4, wherein The specific steps of S603 are as follows: Perform a cosine similarity match between each word in the first keyword of the current context and the user's depression context keyword respectively to obtain the matching value corresponding to each word. Multiply the matching value corresponding to each word by the probability value of the user's depression context keyword to obtain the matching value corresponding to each word in the first keyword of the current context. Accumulate the matching values corresponding to each word in the first keyword of the current context, and divide the sum of the accumulated matching values by the number of words in the first keyword of the current context to obtain the first matching value. Perform a cosine similarity match between each word in the second keyword of the current context and the user's depression context keyword respectively to obtain the matching value corresponding to each word. Multiply the matching value corresponding to each word by the probability value of the user's depression context keyword to obtain the matching value corresponding to each word in the second keyword of the current context. Accumulate the matching values corresponding to each word in the second keyword of the current context, and divide the sum of the accumulated matching values by the number of words in the second keyword of the current context to obtain the second matching value.
6. The method for generating a message for emotion reproduction according to claim 5, wherein In S603, the formula for describing the cosine similarity match is as follows: Among them, A i represents each word in the keywords of the current context; B i represents the keywords of the user's depression context, and i is the index, ranging from [1, n].
7. A method for generating a message for emotion reproduction according to claim 5, characterized in that, The specific steps of S604 are as follows: Set the first weight factor, where the first weight factor is a value between 0 and 1. Use 1 minus the first weight factor to obtain the first anti-weight factor. Use the method of multiplying the first matching value by the first weight factor plus the second matching value by the first anti-weight factor to obtain the depression keyword probability value.
8. The method for generating a message for emotion reproduction according to claim 3, wherein The specific steps of S7 are as follows: S701: Construct and train a daily depression event regression model based on the average value of daily depression events in S2; S702: Input the current date into the trained daily depression event regression model in S702 to obtain the average value of depression events occurring on the current day; S703: Set a depression preset value for the predicted event, initialize the number of depression events, access each predicted event in the predicted event set of S5. When the depression level of the predicted event is greater than the depression preset value of the predicted event, increment the number of depression events by 1 to obtain the final number of depression events; S704: Calculate the ratio between the final number of depression events in S703 and the average value of depression events occurring on the current day in S702 to obtain the predicted event depression probability value; S705: Set a second weight factor, where the second weight factor is a value between 0 and 1. Subtract the second weight factor from 1 to obtain the second anti-weight factor. Obtain the depression mood recurrence probability by multiplying the depression keyword probability value in S604 by the second weight factor and adding the predicted event depression probability value in S704 multiplied by the second anti-weight factor; S706: Set a first recurrence probability value and a second recurrence probability value. Generate a message reminder according to the size relationship between the depression mood recurrence probability value and the first recurrence probability value and the second recurrence probability value.
9. The method for generating a message for emotion reproduction according to claim 8, wherein If the predicted event depression probability value in S704 is greater than or equal to 1, set the predicted event depression probability value as the first depression probability value. If it is less than 1, set the predicted event depression probability value as the second depression probability value. When the predicted event depression probability value is the first depression probability value, send a message to the user's emergency contact at regular intervals to closely monitor the patient.
10. A method for generating a message for emotion reproduction according to claim 8, characterized in that, The specific content of S706 is as follows: When the depression mood recurrence probability value is less than or equal to the first recurrence probability value, send a message to the current user; When the depression mood recurrence probability value is greater than the first recurrence probability value and less than or equal to the second recurrence probability value, while sending a message to the current user, provide cheerful music in the form of voice playback. At the same time, obtain the contact phone number of the user's emergency contact from the A-type chat system and send a message to this contact phone number; When the depression mood recurrence probability value is greater than the second recurrence probability value, while sending a message to the current user and providing cheerful music in the form of voice playback, send a message to the user's emergency contact and send a message to the user's emergency contact at regular intervals.
Citation Information
Patent Citations
Depression interview dialogue generation method based on pre-training language model
CN113780012A
Method for Detection of a Relapse Into a Depression or Mania State Based on Activity Data and / or Data Obtained by Questioning the Patient
US20220054065A1