Cognitive stimulation dialogue generation method and system based on logical reasoning and multi-task fusion
By building a multi-task fusion model, combining emotion classification, decision-making and generation tasks, the problem of lack of cognitive stimulation dialogue generation system in the existing technology is solved, and high accuracy and high-quality dialogue responses are achieved.
Patent Information
- Application Number
- CN202410999169.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2044-07-24
AI Technical Summary
The lack of generative systems for cognitive stimulus dialogue in the prior art makes it difficult to generate cognitive stimulus dialogue tasks effectively and lacks a logical thinking reasoning process of multi-task fusion.
A cognitive stimulus dialogue generation method and system based on logical reasoning and multi-task fusion is proposed. By constructing a multi-task fusion model of emotion classification model, decision-making model and generation model, and combining user statement information to make decisions and reply generation.
The accuracy of decision-making tasks and the quality of conversational responses are significantly improved, demonstrating the effectiveness and advancedness of the multi-task fusion method.
Smart Images

Figure CN118779431B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of human-computer dialogue, and more specifically to a method and system for generating cognitive stimulation dialogue based on logical reasoning and multi-task fusion. Background Art
[0002] At present, human-computer dialogue systems have always been a hot topic in artificial intelligence research. In the context of global aging, using artificial intelligence to achieve smart health care and building dialogue systems for the elderly has become an important direction for dialogue system research. Studies have shown that dialogue systems have a positive effect on improving the cognitive ability of the elderly (De Oliveira et al., 2014; Park et al., 2019). Among them, cognitive stimulation dialogue is an important psychotherapy method for restoring the cognitive function of the elderly (Tokunaga et al., 2019; Tokunaga et al., 2021). Cognitive stimulation therapy is a non-drug intervention therapy for patients with mild to severe cognitive impairment (Spector et al., 2003). Cognitive stimulation dialogue is a dialogue generated under the guidance of cognitive stimulation therapy principles for the purpose of stimulating the patient's thinking. The generative dialogue system combined with cognitive stimulation therapy has a wide range of application scenarios in the field of smart elderly care. It can be applied to home life scenarios and elderly care community service scenarios, etc., to help the elderly recover cognitively through chatting. Therefore, cognitive stimulation dialogue has urgent practical needs, application value and diverse application scenarios.
[0003] In the existing technology, most dialogue systems for the elderly focus on specific functional research in specific scenarios. For example, Tokunaga et al. (2021) proposed a robot dialogue system that uses photo stories to conduct daily cognitive training for the elderly. Navarro et al. (2018) proposed a cognitive stimulation therapy system to assess patients' cognitive impairment and emotional health to automatically generate new personalized stimulation plans. However, due to the lack of cognitive stimulation dialogue materials, there has been no research on generative systems for cognitive stimulation dialogue.
[0004] The cognitive stimulation dialogue task is different from the ordinary chat task. It is a purposeful dialogue with a relatively high task difficulty. When conducting a cognitive stimulation dialogue, the human mind will first make a decision based on the content of the current discourse, determine the applicable treatment principles, and then respond accordingly based on the results of the decision. In both the emotional support dialogue and cognitive stimulation dialogue work, a dialogue example is provided to describe the respondent's thinking process between input and response. It can be seen that the model will also refer to the human thinking process when responding, that is, making a decision first and then responding. This also shows that the cognitive stimulation dialogue task is a fusion of multiple tasks.
[0005] Therefore, how to provide a method and system for generating cognitive stimulation dialogues based on logical reasoning and multi-task fusion, regard cognitive stimulation dialogue generation as a multi-task fusion logical thinking reasoning process, improve the accuracy of decision-making tasks, and improve the quality of dialogue responses is an urgent problem that technical personnel in this field need to solve. Summary of the invention
[0006] In view of this, the present invention provides a method and system for generating cognitive stimulation dialogues based on logical reasoning and multi-task fusion, which regards cognitive stimulation dialogue generation as a multi-task fusion logical thinking reasoning process, and models the logical relationship between the sentiment classification task, the decision-making task and the dialogue response generation task as a reasoning process to guide the generation of a large language model. For the decision-making task, the present invention proposes a decision model with a hierarchical encoder structure. The results of the decision-making experiment show that the decision-making model effectively improves the accuracy of the decision-making task. For the multi-task process, the present invention proposes a multi-task fusion method to combine the models corresponding to the three tasks. The results of the generation experiment show that the multi-task fusion method of classification, decision-making and generation significantly improves the dialogue response ability, proving the effectiveness and advancement of the method.
[0007] In order to achieve the above-mentioned object, the present invention adopts the following technical scheme: a method for generating cognitive stimulation dialogue based on logical reasoning and multi-task fusion, comprising: proposing a multi-task process for generating cognitive stimulation dialogue;
[0008] Construct a multi-task fusion model based on sentiment classification model, decision model and generation model;
[0009] Training the multi-task fusion model;
[0010] Get user statement information;
[0011] The user sentence information is used to obtain the user's sentiment classification result through the sentiment classification model;
[0012] Inputting the user sentence information and the emotion classification result into the decision model to obtain the cognitive stimulation treatment principle decision result and the emotion support strategy decision result;
[0013] A dialogue prompt template of the generative model is constructed, the user sentence information, the sentiment classification model result and the decision model result are embedded in the prompt template, and input into the generative model to obtain a dialogue response.
[0014] Preferably, the multi-task process of generating cognitive stimulation dialogues includes:
[0015] Make decisions based on the current discourse content and determine applicable treatment principles;
[0016] A response is then given based on the outcome of the decision.
[0017] Preferably, BERT is used as the sentiment classification model to train the sentiment classification model.
[0018] Preferably, the decision model includes a dialogue encoding module and a label decision module;
[0019] The dialogue encoding module designs each round of dialogue into a sentence pair;
[0020] Encode each sentence pair using a sentence encoder to obtain a first encoding result;
[0021] Encode the emotional information and decision information of each round of dialogue respectively to obtain the second encoding result;
[0022] Concatenating the first encoding result and the second encoding result to obtain a dialogue encoding result;
[0023] The label decision module uses an LSTM network or a Transformer Encoder network to make a label decision on the dialogue encoding result, or uses a Transformer Encoder network to make a label decision on the dialogue encoding result to obtain decision information of the current sentence.
[0024] Preferably, an LSTM network is used to perform label decision on the dialogue encoding result, including: passing the dialogue encoding result into the LSTM network, taking the hidden layer vector at the last moment, and obtaining the decision information of the current sentence after passing the hidden layer vector through a linear layer.
[0025] Preferably, a Transformer Encoder network is used to perform label decision on the dialogue encoding result, including:
[0026] Construct a position encoding layer, which represents the contextual relationship between sentence pairs and obtains the position encoding result;
[0027] The dialogue encoding result and the position encoding result are added together and input into the TransformerEncoder network, and the hidden layer vector at the last moment is taken, and the decision information of the current sentence is obtained after passing through the linear layer.
[0028] Preferably, a dialogue prompt template of the generative model is constructed, the user sentence information, the sentiment classification model result and the decision model result are embedded in the prompt template, and input into the generative model to obtain a dialogue response, including:
[0029] The Chinese large language model ChatGLM is used as the generation model;
[0030] Design task prompt templates and response templates;
[0031] Embedding the user sentence information, the emotion classification result, the cognitive stimulation treatment principle decision result and the emotion support strategy decision result in a prompt template;
[0032] The prompt template is input into the generation model to obtain the reply content.
[0033] Preferably, the cognitive stimulation dialogue generation system based on logical reasoning and multi-task fusion includes: a first building module for building a multi-task fusion model based on a sentiment classification model, a decision model and a generation model;
[0034] A training module, used for training the multi-task fusion model;
[0035] Real-time information acquisition module, used to obtain user statement information;
[0036] A classification information acquisition module is used to obtain the user's emotion classification result through the emotion classification model according to the user's sentence information;
[0037] A decision information acquisition module, used to input the user sentence information and the emotion classification result into the decision model to obtain the decision result of the cognitive stimulation treatment principle and the decision result of the emotion support strategy;
[0038] The second building module is used to build a dialogue prompt template for the generative model;
[0039] The output module is used to embed the user sentence information, the sentiment classification model results and the decision model results into the prompt template, input them into the generation model, and obtain the dialogue response.
[0040] Through the above technical solutions, it can be known that compared with the prior art, the present invention discloses a method and system for generating cognitive stimulation dialogues based on logical reasoning and multi-task fusion, including: proposing a multi-task process for generating cognitive stimulation dialogues; constructing a multi-task fusion model based on an emotion classification model, a decision model and a generation model; training the multi-task fusion model; obtaining user sentence information; obtaining the user's emotion classification result through the emotion classification model; inputting the user sentence information and the emotion classification result into the decision model to obtain the decision result of the cognitive stimulation treatment principle and the decision result of the emotion support strategy; constructing a dialogue prompt template of the generation model, embedding the user sentence information, the emotion classification model result and the decision model result into the prompt template, and inputting it into the generation model to obtain a dialogue response. The present invention (1) proposes a multi-task process for cognitive stimulation dialogue tasks with reference to the human thinking process of making decisions first and then responding. The cognitive stimulation dialogue is divided into three subtasks, specifically, an emotion classification task, a decision task, and a large language model dialogue response generation task.
[0041] (2) For decision-making tasks, the present invention proposes a decision model DM with a hierarchical encoder structure. The results of the decision-making experiment show that the decision-making model DM effectively improves the accuracy of emotional support decisions and cognitive stimulation decisions. The generation experiment shows that as the accuracy of the decision model improves, it also has a positive promoting effect on the generation of dialogue responses by the generation model. The results of the decision-making experiment and the generation experiment prove the effectiveness of the decision-making task and the decision-making model.
[0042] (3) Aiming at the multi-task characteristics of cognitive stimulation dialogue, this paper proposes a multi-task fusion method CSMI, which integrates the sentiment classification model, decision model and large language model. The quality of dialogue response is improved, proving the effectiveness and advancement of CSMI. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0044] Figure 1 A schematic flow chart of the cognitive stimulation dialogue generation method based on logical reasoning and multi-task fusion provided by the present invention.
[0045] Figure 2 A multi-task fusion flow chart provided for an embodiment of the present invention.
[0046] Figure 3 A schematic diagram of the decision model structure provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] The embodiment of the present invention discloses a method and system for generating cognitive stimulation dialogue based on logical reasoning and multi-task fusion. (1) For cognitive stimulation dialogue tasks, a multi-task process is proposed with reference to the human thinking process of making decisions first and then responding. The cognitive stimulation dialogue is divided into three subtasks, namely, a sentiment classification task, a decision task, and a large language model dialogue response generation task. (2) For the decision task, the present invention proposes a decision model DM with a hierarchical encoder structure. The results of the decision experiment show that DM effectively improves the accuracy of sentiment support decisions and cognitive stimulation decisions. The generation experiment shows that with the improvement of the accuracy of the decision model, it also has a positive promoting effect on the generation model to generate dialogue responses. The results of the decision experiment and the generation experiment prove the effectiveness of the decision task and the decision model. (3) In view of the characteristics of multiple tasks in the cognitive stimulation dialogue process, the present invention proposes a multi-task fusion method CSMI, which integrates the sentiment classification model, the decision model and the large language model. The quality of the dialogue response is improved, proving the effectiveness and advancement of CSMI.
[0049] The embodiment of the present invention discloses a method for generating cognitive stimulation dialogue based on logical reasoning and multi-task fusion, including: proposing a multi-task process for generating cognitive stimulation dialogue;
[0050] Construct a multi-task fusion model based on sentiment classification model, decision model and generation model;
[0051] Training the multi-task fusion model;
[0052] Get user statement information;
[0053] The user sentence information is used to obtain the user's sentiment classification result through the sentiment classification model;
[0054] Inputting the user sentence information and the emotion classification result into the decision model to obtain the cognitive stimulation treatment principle decision result and the emotion support strategy decision result;
[0055] A dialogue prompt template of the generative model is constructed, the user sentence information, the sentiment classification model result and the decision model result are embedded in the prompt template, and input into the generative model to obtain a dialogue response.
[0056] Specifically, the multi-task process for generating cognitive stimulation dialogues includes:
[0057] Analyze cognitive stimulation dialogue tasks according to human thinking, that is, first make decisions based on the current discourse content and determine the applicable treatment principles;
[0058] A response is then given based on the outcome of the decision.
[0059] The model also refers to the human thinking process when replying, that is, making a decision first and then replying. Therefore, the multi-task process of generating cognitive stimulation dialogue is proposed.
[0060] Specifically, BERT is used as a sentiment classification model, and the sentiment classification model is trained.
[0061] Specifically, the decision model includes a dialogue encoding module and a label decision module;
[0062] The dialogue encoding module designs each round of dialogue into a sentence pair;
[0063] Encode each sentence pair using a sentence encoder to obtain a first encoding result;
[0064] Encode the emotional information and decision information of each round of dialogue respectively to obtain the second encoding result;
[0065] Concatenating the first encoding result and the second encoding result to obtain a dialogue encoding result;
[0066] The label decision module uses an LSTM network or a Transformer Encoder network to make a label decision on the dialogue encoding result, or uses a Transformer Encoder network to make a label decision on the dialogue encoding result to obtain decision information of the current sentence.
[0067] In a specific embodiment of the present invention, for decision-making tasks, the present invention proposes a decision model DM with a hierarchical encoder structure, which includes two stages: a dialogue encoding stage and a label decision stage. In the label decision stage, the present invention designs a decision model through two different structures; DM LSTM and DM Transformer The decision model structure is as follows: Figure 3 As shown, the embodiment of the present invention takes cognitive stimulation decision as an example to demonstrate, and emotional support decision is similar to this.
[0068] In the embodiment of the present invention, each round in the dialogue history data set is designed as a sentence pair H = [(u1, r1), ..., (u n-1 ,r n-1 )] to improve the structured expression of historical dialogues, where u represents the words of the elderly and r represents the words of the robot. In order to more effectively convey the semantic information of the sentences, the embodiment of the present invention uses the sentence encoder SentenceBERT to encode them. Then, the sentence u is combined with the current sentence n Together, we use the sentence encoder to represent the sentences, as shown in formula (1). If we assume s = (u, r), we get the conversation representation S = [s1, s2, ..., s n], specifically expressed as:
[0069]
[0070] Among them, n represents the number of dialogue turns, and d is the hidden layer dimension of the sentence encoder.
[0071] Then, the embodiment of the present invention uses two encoding layers to encode the emotional information of each round and the decision information in the historical dialogue, namely or
[0072] Among them, E e (emo) represents the encoding result of emotional information, E c (cst) represents the information encoding result of cognitive stimulation therapy principle, E s (str) represents the encoding result of emotional support strategy information, represents the shape of the matrix; n represents the number of dialogue turns, and d is the hidden layer dimension. In the embodiment of the present invention, the historical emotion information and the historical decision information are combined into a sequence, and the output result is obtained after the encoding layer: H emo , H cst and H str , Represents the encoding layer result of the placeholder.
[0073]
[0074] Among them, H emo , H cst and H str They represent the result vector sequence of emotional information encoding, the result vector sequence of cognitive stimulation treatment principle encoding and the result vector sequence of emotional support strategy encoding respectively; Indicates the encoding result of the emotional information of the user's current speech, Indicates the decision result of the cognitive stimulation treatment principle of the user's speech in the previous round, Indicates the decision result of the emotional support strategy of the user's speech in the previous round.
[0075] The output result of the encoding layer is spliced with the corresponding encoding result of each round of dialogue to obtain the dialogue encoding result after information enhancement: the dialogue encoding result that integrates emotional and cognitive stimulus decision information and conversation coding that incorporates emotion and computational linguistics to support decision making
[0076]
[0077] A conversation is a sequence with a sequential relationship and contextual connection. Therefore, in the label decision stage of the embodiment of the present invention, two different structures, a long short-term memory network (LSTM) and a Transformer Encoder, are used.
[0078] Specifically, an LSTM network is used to perform label decision on the dialogue encoding result, including: passing the dialogue encoding result into the LSTM network to obtain the hidden layer vector at the last moment, and obtaining the decision information of the current sentence after the hidden layer vector passes through a linear layer.
[0079] The embodiment of the present invention takes the hidden layer vector at the last moment, which represents an abstraction and summary of the entire sequence information.
[0080] Among them, LSTM is regarded as a recurrent neural network model with time series characteristics. It can effectively capture the temporal association between sentence pairs during model training, thus helping to deeply understand the context of the conversation. The dialogue encoding result is passed into LSTM to obtain the result G cst and G str , take the hidden layer vector at the last moment and After the linear layer, we get the decision information of the current sentence, W l Predict the weight matrix for the decision:
[0081]
[0082] l cst Represents the decision-making results of cognitive stimulation therapy principles, l str Represents the emotional support strategy decision outcome.
[0083] Specifically, a Transformer Encoder network is used to make label decisions on the dialogue encoding results, including:
[0084] Construct a position encoding layer, which represents the contextual relationship between sentence pairs and obtains the position encoding result;
[0085] The dialogue encoding result and the position encoding result are added together and input into the TransformerEncoder network, and the hidden layer vector sum at the last moment is taken, and the decision information of the current sentence is obtained after passing through the linear layer.
[0086] Among them, Transformer Encoder is a model based on the self-attention mechanism, which can effectively model the relationship between words in a sentence through self-attention, thereby achieving a deep understanding of the dialogue information. In order to promote the Transformer Encoder to have a deeper understanding of the relationship between sentences, the embodiment of the present invention adopts a position encoding layer E p Indicates the contextual relationship between sentence pairs. Where n represents the number of conversation rounds, d is the hidden layer dimension, and the hidden layer dimension is consistent with the hidden layer vector dimension of the sentence encoder. Add the conversation encoding result and the position encoding result and pass them into the Transformer Encoder to get the result M cst and M str , take the hidden layer vector of the last layer and After the linear layer, we get the decision information of the current sentence, W l Predict the weight matrix for the decision:
[0087]
[0088] Specifically, a dialogue prompt template of the generative model is constructed, the user sentence information, the sentiment classification model result and the decision model result are embedded in the prompt template, and input into the generative model to obtain a dialogue response, including:
[0089] The Chinese large language model ChatGLM is used as the generation model;
[0090] Designing a task prompt template and a reply template; the prompt template includes a task prompt template and a reply template;
[0091] Embedding the user sentence information, the emotion classification result, the cognitive stimulation treatment principle decision result and the emotion support strategy decision result in a prompt template;
[0092] The prompt template is input into the generation model to obtain the reply content.
[0093] For the large language model, the embodiment of the present invention selects the Chinese large language model ChatGLM as the generation model, and adopts a prompt-based method to design a clear and efficient prompt template, designing the task explanation and logical process into a prompt template, and embedding it in the dialogue template of the generation model. The task prompt template is embedded after the "Ask:" in the ChatGLM dialogue template and spliced at the beginning of each dialogue, aiming to more effectively guide the large language model to understand the decision-making task and enhance its understanding of the label semantic information. The task prompt template is designed as follows: "You are a chat robot with cognitive stimulation and emotional support functions. Your chat partner is an elderly person. You need to choose an appropriate reply based on the cognitive stimulation strategy and emotional support strategy. Now start the computational linguistics chat: {user input}". For the reply prompt template, this paper regards the logical relationship between the three tasks, that is, "determine the reply based on the user's emotions and speech", as a complex logical thinking process, and designs prompts to guide the generation of the large language model. The reply template is designed as follows: "According to the emotion in the user's speech [{emotion label}], the cognitive stimulation therapy that should be selected is [{principle label}], and the emotional support strategy used is [{strategy label}], so the reply is". The reply prompt template is embedded after the "Answer:" in the ChatGLM dialogue template. Then the large language model is fine-tuned. During fine-tuning, the placeholders in the template will be replaced with specific label information.
[0094] In a specific embodiment of the present invention, the dialogue prompt template is as follows:
[0095] Q: You are a chatbot with cognitive stimulation and emotional support functions. Your chat partner is an elderly person. You need to choose appropriate responses based on cognitive stimulation and emotional support strategies. Start chatting now: I can’t see anything clearly now.
[0096] Answer: According to the emotion in the user's speech [sad], the cognitive stimulation therapy that should be chosen is [asking questions], and the emotional support strategy used is [asking questions to the user], so the reply is: Is it because of some reason?
[0097] Q: It’s a bit presbyopic.
[0098] Answer: According to the emotion [disgust] in the user's speech, the cognitive stimulation therapy that should be chosen is [asking questions], and the emotional support strategy to be used is [asking questions to the user], so the reply is: Do you feel a little dizzy if you look at a lot of things?
[0099] Q: Yes.
[0100] Answer: According to the emotion in the user's speech, which is [sad], the cognitive stimulation therapy that should be chosen is [comfort the user], and the emotional support strategy used is [provide useful information], so the reply is.
[0101] The reply prompt template is embedded after "Answer:" in the ChatGLM dialogue template. Then the large language model is fine-tuned. During fine-tuning, the placeholders in the template will be replaced with specific label information. The dialogue reply obtained is: Don't overuse your eyes!
[0102] The model of the multi-task fusion method is shown in the figure Figure 1 As shown. First, the current discourse is subjected to sentiment classification to obtain sentiment classification information. Then, the current discourse and its historical dialogue and sentiment information are combined through the decision model to obtain two decision information, namely cognitive stimulation treatment principle and emotional support strategy. Finally, combining the results of the sentiment classification model and the decision model, all required information is embedded in the dialogue template, and the dialogue response is obtained through the generation model. The embodiment of the present invention uses cognitive stimulation as a non-drug psychotherapy method for elderly people with cognitive impairment, which plays an important role in improving the cognitive ability of the elderly.
[0103] Specifically, when training the model, the training data set uses the CSConv data set;
[0104] The CSConv dataset is a Chinese cognitive stimulation dialogue dataset, which is aimed at cognitive stimulation dialogue tasks for the elderly. It contains 2,600 dialogues, and each sentence is annotated with three category labels. Then, a generative dialogue model that integrates multi-source knowledge is proposed, achieving the best results currently.
[0105] Specifically, in the CSConv dataset, three types of labels are annotated for each sentence u: sentiment label u emo 、Principles of cognitive stimulation therapy Tagsu cst , Emotional Support Strategies Tags strategy . In the work of Jiang et al. (2023), the authors converted each label into a word for encoding, concatenated it with the sentence encoding and input it into the generation model, so no corresponding Chinese label was given. In the embodiment of the present invention, the emotion labels and cognitive stimulation therapy principle labels are translated into Chinese according to the interpretation in the work of Jiang et al. (2023), and then summarized into corresponding Chinese labels, such as the emotion classification Chinese label comparison table shown in Table 1 and the cognitive stimulation therapy principle Chinese label comparison table shown in Table 2.
[0106] Table 1
[0107]
[0108] Table 2
[0109]
[0110] For the emotional support strategy labels, according to the examples given by Liu et al. (2021), they are summarized into corresponding Chinese labels, as shown in Table 3, the Chinese label comparison table of emotional support strategies.
[0111] The decision-making task should predict the emotional support strategy or cognitive stimulation treatment principle to be adopted by the machine response. Therefore, according to the definition of the decision-making task, the embodiment of the present invention reorganizes the CSConv dataset. emo , leave the emotional support strategy tag r in the machine reply sentence r strategy and cognitive stimulation therapy principles tags cst .
[0112] Table 3
[0113]
[0114] The embodiment of the present invention proposes a cognitively stimulated dialogue generation method based on logical reasoning and multi-task integration, proposes a multi-task process, and designs a multi-task integration method based on this, hereinafter referred to as CSMI (Cognitively Stimulated dialogue based on Multi-task Integration). The embodiment of the present invention divides the cognitively stimulated dialogue task into three subtasks, namely, classification task, decision-making task and large language model dialogue response generation task.
[0115] Specifically, first, the embodiment of the present invention selects BERT as the sentiment classification model, reorganizes the data set for the sentiment classification task, and uses the data set to fine-tune the model. Second, the embodiment of the present invention constructs a decision model, which includes two main stages: dialogue encoding and label decision. In the label decision stage, the embodiment of the present invention designs two structures, namely, the decision model based on LSTM, hereinafter referred to as DM LSTM (DecisionModel-LSTM), and the decision model based on Transformer Encoder, hereinafter referred to as DM Transformer (Decision Model-Transformer). 3. The embodiment of the present invention adopts a prompting method to further improve the understanding and reasoning ability of the large language model. Finally, combining the results of the classification model and the decision model, the models corresponding to the three tasks are fused together to guide the large language model to generate dialogue responses.
[0116] The embodiment of the present invention discloses a cognitive stimulation dialogue generation system based on logical reasoning and multi-task fusion, including: a first building module, used to build a multi-task fusion model based on a sentiment classification model, a decision model and a generation model;
[0117] A training module, used for training the multi-task fusion model;
[0118] Real-time information acquisition module, used to obtain user statement information;
[0119] A classification information acquisition module is used to obtain the user's emotion classification result through the emotion classification model according to the user's sentence information;
[0120] A decision information acquisition module, used to input the user sentence information and the emotion classification result into the decision model to obtain the decision result of the cognitive stimulation treatment principle and the decision result of the emotion support strategy;
[0121] The second building module is used to build a dialogue prompt template for the generative model;
[0122] The output module is used to embed the user sentence information, the sentiment classification model results and the decision model results into the prompt template, input them into the generation model, and obtain the dialogue response.
[0123] The multi-task fusion method proposed in the embodiment of the present invention is as follows: Figure 2 As shown, the cognitive stimulation dialogue task is divided into three subtasks, namely, classification task, decision-making task and dialogue response generation task. The embodiment of the present invention regards the logical relationship between the three tasks as a complex logical reasoning process (by analyzing the human thinking process, that is, making decisions first and then replying), and guides the large language model through prompts to generate dialogue responses. The classification task is the classification of emotional information, the decision-making task is specifically divided into cognitive stimulation treatment decision-making and emotional support strategy decision-making, and the generation task is to generate the model to make corresponding responses using the guidance of emotional information and decision-making information.
[0124] For decision-making tasks, an embodiment of the present invention proposes a decision model with a hierarchical encoder structure. In the encoding stage, by incorporating historical conversations, emotional information, and historical decision information, the encoding representation of the conversation is enhanced, thereby improving the decision accuracy and providing more accurate information for the generation model. For the generation model, there is still a large span from emotional information and decision information to reply generation. The generation model must not only understand the meaning of the label, but also shoulder the responsibility of understanding the instructions behind the emotional information and decision information. Since its emergence, the large language model has demonstrated amazing reasoning ability and the ability to obey instructions. It can understand the instruction information well and respond accordingly, and has a better understanding of the meaning behind different label information. Therefore, the embodiment of the present invention uses a large language model as a generation model, and uses a prompt-based method to explore the deep understanding and reasoning ability of the large language model.
[0125] The specific research contributions of the embodiments of the present invention are summarized as follows:
[0126] (1) For the cognitive stimulation dialogue task, the embodiment of the present invention refers to the human thinking process of making decisions first and then responding, and proposes a multi-task process. The cognitive stimulation dialogue is divided into three subtasks, namely, the sentiment classification task, the decision-making task, and the large language model dialogue response generation task.
[0127] (2) For decision-making tasks, the embodiment of the present invention proposes a decision model DM with a hierarchical encoder structure. The results of the decision-making experiment show that DM effectively improves the accuracy of emotional support decisions and cognitive stimulation decisions. The generation experiment shows that as the accuracy of the decision model improves, it also has a positive promoting effect on the generation of dialogue responses by the generation model. The results of the decision-making experiment and the generation experiment prove the effectiveness of the decision-making task and the decision model.
[0128] (3) In view of the multi-task characteristics of cognitive stimulation dialogue, the embodiment of the present invention proposes a multi-task fusion method CSMI, which integrates the sentiment classification model, decision model and large language model. A large number of experiments were conducted, and the results showed that CSMI improved the quality of dialogue responses, proving the effectiveness and advancement of CSMI.
[0129] In a specific embodiment of the present invention, the feasibility of the embodiment of the present invention is verified by experiments, as follows:
[0130] 1. Experimental setup
[0131] In the sentiment classification model, the pre-trained model used in the embodiment of the present invention is bert-base-Chinese, and the learning rate is set to 2e-5. In the decision model, the pre-trained model used by the sentence encoder is sbert-base-chinese-nli, and the learning rate is set to 2e-5. The learning rates of LSTM and Transformer Encoder are 1e-4, the batch size is 8, and the cumulative number of steps is 4. The vector dimension of the sentiment information and decision information encoding layer is set to 32, and the maximum historical dialogue length of the input is set to 3 rounds of dialogue. For the generation model, we designed a task prompt template and a reply prompt template, added them to the reply template of ChatGLM, and used the Ptuning method to fine-tune ChatGLM. Set the maximum sequence length to 512, the batch size to 16, and the cumulative number of steps to 2.
[0132] 2. Evaluation indicators
[0133] In the evaluation of the decision model, this study selected accuracy and F1-score as the main evaluation indicators. Accuracy is intended to measure the number of labels correctly predicted by the model, while F1-score comprehensively considers precision and recall, providing an evaluation standard for the comprehensive performance of the model.
[0134] This study follows the work of predecessors and uses BLEU as an indicator to evaluate the quality of dialogue generation. BLEU focuses on measuring the semantic similarity between the generated text and the reference text. ROUGE is also introduced to evaluate the quality of dialogue generation. ROUGE focuses on evaluating the coverage and completeness of the information in the generated text. Usually, these two indicators are used in combination to comprehensively evaluate the performance of the model. In addition, this study also counted BERTScore to measure the semantic similarity between the generated text and the reference text, further enriching the evaluation dimension.
[0135] 3. Comparative experiment
[0136] In order to comprehensively evaluate the performance of the decision model proposed in the embodiment of the present invention on the decision-making task, this study designed a series of comparative experiments involving a variety of deep learning models, including the decision model DM based on LSTM. LSTM And the decision model DM built based on Transformer Encoder Transformer . In addition, in order to ensure the comprehensiveness and depth of the evaluation, the embodiment of the present invention also incorporates a large language model as a baseline method for the decision model. Since the large language model has reasoning capabilities, the embodiment of the present invention attempts to let the large language model itself play the role of a decision model. Chain of Thought (CoT) is a method for designing prompts, that is, in addition to the input and output of the task, the prompt also contains the intermediate steps of reasoning. Since there is a logical relationship from input to output in cognitive stimulation dialogue tasks, the embodiment of the present invention chooses to use the CoT method to let the large language model itself serve as a decision model, and the design of the chain of thought refers to the reply prompt template.
[0137] As shown in Table 4, the decision-making task comparison experimental results, DM Transformer and DM LSTM The accuracy and F1 score of the two decision-making tasks are higher than other baselines, which proves that the two decision-making models DM Transforme r and DM LSTM Effective and advanced.
[0138] Table 4
[0139]
[0140] For the dialogue response generation task, with the above classification model, decision model and large language model ChatGLM as the backbone, this paper constructs the following variant models: (1) Fine-tuning version (ChatGLM): directly fine-tune ChatGLM using the CSConv dataset. (2) Thought chain-based fine-tuning (CLC): fine-tune the large language model using the thought chain method. (3) Multi-task fusion method (CSMI): fine-tune the large language model using a prompt-based method. In addition, the embodiment of the present invention demonstrates the advanced nature of this research method by comparing it with previous research results on the CSConv dataset. Including: CDialGPTbase and CDialGPTlarge trained on different versions of LCCC datasets; GPT2-chitchat trained on chat corpus; Distil-Cluecorpussmall (Radford et al., 2019) and Cluecorpussmall (Radford et al., 2019) trained on the CLUECorpusSmall corpus, and the Chinese cognitive stimulation dialogue system CSD proposed by Jiang et al. (2023).
[0141] Table 5
[0142]
[0143] As shown in Table 5, the score of the CSMI method is higher than that of previous work, which proves the effectiveness and advancement of the multi-task fusion method. At the same time, the scores of CSMI and different decision models increase with the improvement of decision accuracy, indicating that decision information has a positive guiding effect on the generation model, proving the effectiveness and advancement of the multi-task fusion method. However, the scores of CSMI and different decision models are slightly lower than those of ChatGLM and CSMI-true labels, because if the decision strategy is different from the true value, the generated response will be very different from the true response. This shows that it is important to learn decision information when no true label is provided.
[0144] 4. Ablation experiment
[0145] In order to further verify the performance of the decision model and the prompt template on the large language model, a series of ablation experiments are designed in the embodiment of the present invention.
[0146] Table 6
[0147]
[0148] The embodiment of the present invention conducts experiments by taking whether to incorporate emotional information and decision information into dialogue encoding as a control condition. Table 6 shows the decision model DM composed of LSTM. LSTM, for each part of the design, the ablation experiment results on the cognitive stimulation decision task. It can be seen that historical dialogue information, emotional information and historical decision information are all important for the decision model DM LSTM Among them, the contribution of sentiment information and historical decision information is more prominent, indicating that the model can effectively utilize sentiment and decision information to further improve the decision-making ability of the model.
[0149] This paper also conducted experiments by controlling different prompt template information for the large language model. As shown in Table 7, the large language model ablation experiment based on the prompt template shows that the model fine-tuned with the reply prompt template is better than the model fine-tuned directly. It can be seen that using the reasoning process between the three tasks as a reply prompt further improves the large language model's ability to understand label information. After adding the task prompt template, the BLEU-4 and ROUGE-L scores both increased by about 1.5, which proves that the prompt-based method can stimulate the large language model's deep understanding and reasoning ability of the task, indicating the effectiveness of the prompt-based method.
[0150] Table 7
[0151]
[0152] 5. Manual evaluation
[0153] In the dialogue generation task, automatic evaluation indicators often have limitations because they cannot reflect the gap between the results generated by the model and the reference target in terms of deep semantics and fluency. Therefore, this paper conducts manual evaluation to measure the generation ability of the model from the following three main evaluation perspectives:
[0154] Fluency: Whether the machine response is fluent and conforms to Chinese grammar.
[0155] Supportability: Whether the model responses are helpful.
[0156] Decision matching degree: whether the machine response can generate corresponding response content based on the given decision information.
[0157] The embodiment of the present invention selects CSMI-DM LSTMAs the model object for manual evaluation, its generation results on the test set are retained. This study selected three dialogue topics with high frequency from the test set as the evaluation content, namely, question-asking games, recalling the past, and sharing life, a total of three complete multi-round dialogues. The measurement standards of the above evaluation criteria are all 1-5 points, representing unacceptable-excellent respectively. This study invited 5 evaluators to participate in the manual evaluation, and the results are shown in Table 8. Overall, both fluency and decision matching have reached a good level. The supportive score shows that the evaluators believe that the responses given by the machine in the conversation can provide some help. The decision matching score is relatively high, indicating that the decision information, as an instruction, can well guide the large language model to generate responses.
[0158] Table 8
[0159]
[0160] 6. Sample Analysis
[0161] The embodiment of the present invention selects a dialogue sample from the results generated by the test set as an analysis example, and saves the intermediate results of sentiment classification and decision-making when it is generated, as shown in Table 9. The old man shared his handicraft work, but felt that he did not do it perfectly, and gave a reply of "But I don't know how to match the colors, and it is very messy." For the old man's answer, the sentiment classification model classifies the current sentence as sad, and the decision model gives a decision result of comforting the user and providing encouragement. The generation model gives a reply based on the above results, "No! I think it is very creative, it's amazing." The model's reply comforts the old man while giving affirmation and encouragement that he thinks it is very creative. It can be seen that sentiment information and decision information can be used as an instruction to guide the large language model to generate highly relevant replies. It also shows that the correctness of sentiment and decision judgment will affect subsequent generation. It shows the importance of learning sentiment information and decision information, and proves the effectiveness of the multi-task fusion method.
[0162] Table 9
[0163]
[0164] The embodiment of the present invention regards the cognitive stimulation dialogue task as a multi-task fusion reasoning process with classification, decision-making and generation tasks. The decision data set was reorganized, and a decision model with a hierarchical encoder was designed. The sentiment classification model, decision model and generation model were integrated together, and a multi-task fusion method was proposed. Both the decision-making experiment and the generation experiment proved the effectiveness and advancement of this research method. This progress in the research of the embodiment of the present invention provides a new perspective for the cognitive stimulation dialogue task, which not only expands the understanding of the cognitive stimulation dialogue task, but also provides valuable reference and inspiration for future research in related fields. At the same time, it also opens up a new direction for cognitive stimulation dialogue in combining large language models.
[0165] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0166] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A cognitive stimulation dialogue generation method based on logical reasoning and multi-task fusion, characterized in that: include: Propose a multi-task process for cognitively stimulating dialogue generation; Construct a multi-task fusion model based on sentiment classification model, decision model and generation model; Training the multi-task fusion model; Get user statement information; The user sentence information is used to obtain the user's sentiment classification result through the sentiment classification model; Inputting the user sentence information and the emotion classification result into the decision model to obtain the cognitive stimulation treatment principle decision result and the emotion support strategy decision result; A dialogue prompt template of the generative model is constructed, the user sentence information, the sentiment classification model result and the decision model result are embedded in the prompt template, and input into the generative model to obtain a dialogue response.
2. The cognitive stimulation dialogue generation method based on logical reasoning and multi-task fusion according to claim 1 is characterized in that: The multi-task process of generating cognitive stimulation dialogues includes: Make decisions based on the current discourse content and determine applicable treatment principles; A response is then given based on the outcome of the decision.
3. The cognitive stimulation dialogue generation method based on logical reasoning and multi-task fusion according to claim 1 is characterized in that: BERT is used as a sentiment classification model, and the sentiment classification model is trained.
4. The cognitive stimulation dialogue generation method based on logical reasoning and multi-task fusion according to claim 1 is characterized in that: The decision model includes a dialogue encoding module and a label decision module; The dialogue encoding module designs each round of dialogue into a sentence pair; Encode each sentence pair using a sentence encoder to obtain a first encoding result; Encode the emotional information and decision information of each round of dialogue respectively to obtain the second encoding result; Concatenating the first encoding result and the second encoding result to obtain a dialogue encoding result; The label decision module uses an LSTM network or a Transformer Encoder network to make a label decision on the dialogue encoding result, or uses a Transformer Encoder network to make a label decision on the dialogue encoding result to obtain decision information of the current sentence.
5. The cognitive stimulation dialogue generation method based on logical reasoning and multi-task fusion according to claim 4 is characterized in that: The LSTM network is used to make label decisions on the dialogue encoding results, including: passing the dialogue encoding results into the LSTM network, taking the hidden layer vector at the last moment, and obtaining decision information of the current sentence after the hidden layer vector passes through a linear layer.
6. The cognitive stimulation dialogue generation method based on logical reasoning and multi-task fusion according to claim 4 is characterized in that: A Transformer Encoder network is used to make label decisions on the dialogue encoding results, including: Construct a position encoding layer, which represents the contextual relationship between sentence pairs and obtains the position encoding result; The dialogue encoding result and the position encoding result are added together and input into the Transformer Encoder network, and the hidden layer vector at the last moment is taken, and the decision information of the current sentence is obtained after passing through the linear layer.
7. The cognitive stimulation dialogue generation method based on logical reasoning and multi-task fusion according to claim 1 is characterized in that: Constructing a dialogue prompt template of the generative model, embedding the user sentence information, sentiment classification model results and decision model results in the prompt template, and inputting them into the generative model to obtain a dialogue response, including: The Chinese large language model ChatGLM is used as the generation model; Design task prompt templates and response templates; Embedding the user sentence information, the emotion classification result, the cognitive stimulation treatment principle decision result and the emotion support strategy decision result in a prompt template; The prompt template is input into the generation model to obtain the reply content.
8. A cognitive stimulation dialogue generation system based on logical reasoning and multi-task fusion, characterized by: include: The first building module is used to build a multi-task fusion model based on sentiment classification model, decision model and generation model; A training module, used for training the multi-task fusion model; Real-time information acquisition module, used to obtain user statement information; A classification information acquisition module is used to obtain the user's emotion classification result through the emotion classification model according to the user's sentence information; A decision information acquisition module, used to input the user sentence information and the emotion classification result into the decision model to obtain the decision result of the cognitive stimulation treatment principle and the decision result of the emotion support strategy; The second building module is used to build a dialogue prompt template for the generative model; The output module is used to embed the user sentence information, the sentiment classification model results and the decision model results into the prompt template, input them into the generation model, and obtain the dialogue response.
Citation Information
Patent Citations
Conversation recommendation system based on prompt learning
CN114880444A
Intelligent dialogue system in psychological field
CN117609486A