A method for building a dialogue model based on deep learning

By introducing dialogue action sequence coding and history coding into the task-based dialogue model, combined with belief states, the problem of the model ignoring dialogue historical action information is solved, the accuracy and efficiency of reply generation are improved, and the dialogue progress is clear and the information is accurate. master.

CN114996416BActive Publication Date: 2024-09-13EAST CHINA NORMAL UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210333739.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-31
Publication Date
2024-09-13
Estimated Expiration
2042-03-31

AI Technical Summary

Technical Problem

Existing task-based dialogue models ignore dialogue historical action information, resulting in the generation results being unable to accurately grasp the relevant information discussed previously, which may cause the model to generate meaningless or contradictory responses.

Method used

A dialogue model construction method based on deep learning is used to predict the next round of dialogue actions through a combination of dialogue action sequence coding, history coding and belief states, and use this information to generate replies to avoid repeated or conflicting replies.

Benefits of technology

It improves the reply generation ability of the dialogue model, reduces the generation of redundant replies, ensures a clear understanding of the model's dialogue progress and the accurate grasp of information, and improves the task completion rate and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114996416B
    Figure CN114996416B
Patent Text Reader

Abstract

The present invention discloses a method for constructing a dialogue model based on deep learning. The model is composed of a dialogue action encoding model, a dialogue history encoding model, a dialogue action prediction model and a dialogue reply generation model. The dialogue action encoding model and the dialogue history encoding model are used to encode the historical dialogue action sequence and the dialogue history; the dialogue action prediction model is used to predict the next round of dialogue actions, and finally the dialogue reply generation model is used to generate replies. The dialogue model improves the accuracy of generating replies by predicting historical dialogue actions and the next round of dialogue actions. By encoding the dialogue history, it can avoid generating repeated and redundant information, which can effectively speed up the efficiency of the task-based dialogue system in practical applications and improve the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of task-based dialogue models, and specifically to building a dialogue model that can communicate with users and complete tasks in as few dialogue rounds as possible, which can usually be used in scenarios such as hotel reservations and air ticket reservations. Background Art

[0002] Task-based dialogue systems have attracted widespread attention from academia and industry due to their high commercial value. In recent years, thanks to the explosive growth of data and the development of artificial intelligence technology, task-based dialogue systems have also been further developed.

[0003] The dialogue model needs to understand the user's sentences and make corresponding replies. However, directly replying to users based on historical dialogues often results in the generation of some general and meaningless replies, such as "I don't know" and "That's great". Therefore, researchers use dialogue action prediction to assist in guiding the generation of replies, and use dialogue action prediction to explore the direction of subsequent dialogues, so as to assist in guiding the reply generation model to generate replies in a fixed direction, so as to avoid the model from generating some meaningless or wrong replies. In recent years, some work has proposed the MARCO model and achieved good results. Based on the previous work, this model proposes to regard dialogue action prediction as a sequence generation task, and jointly train the action prediction task and the reply generation task, so that the model can achieve a high improvement in the completion rate of the task. However, the MARCO model only considers the historical information of historical dialogues, but ignores the information of historical dialogue actions. In this way, the generation model cannot accurately grasp the relevant information discussed in the previous text, which may cause the model to forget the corresponding information, making the generated results similar to the results of the previous text, or contradicting the results of the previous text. Therefore, how to add historical dialogue action information to the dialogue model has high research value. Summary of the invention

[0004] The purpose of the present invention is to propose a dialogue model construction method based on deep learning and collaborative generation of dialogue action sequences in response to the fact that the existing task-based dialogue model ignores the sequence information of historical dialogue actions. The historical dialogue actions are modeled in the model to enhance the model's ability to generate responses.

[0005] The specific technical solution for achieving the purpose of the present invention is:

[0006] A method for building a conversation model based on deep learning. During the construction process, the method requires a conversation dataset containing the following contents:

[0007] Contains the conversation history of both parties, T = {U 1 , R 1 , ..., Un-1 , R n-1 , U n},U i represents the sentence asked by the user in the i-th round, R i represents the response of round i;

[0008] The dialogue action sequence A containing each dialogue purpose in the dialogue history = {a 1 , a 2 , a 3 , ..., a n}, for any action a i Contain any number of words;

[0009] The dialogue database D containing the information needed to complete the task = {d 1 , d 2 , ..., d n} indicates that it is used for information query;

[0010] The dialogue belief state V = {v 1 , v 2 , v 3 , ..., v n}, the belief state of round i is v i ={s 1 =p 1 ,s 2 =p 2 , ..., s k =p k}, where s i is the information slot required to complete the task, p i is its corresponding value; the construction process is as follows:

[0011] 1) Encode historical dialogue action sequences

[0012] Set the historical dialogue action sequence A up to the current round to A = a 1 , a 2 , a 3 , ..., a cur Splice, add independent labels [ACT] and [EOS] before and after each dialogue action, and add the label [CLS] before the entire spliced ​​character sequence to get the final spliced ​​sequence: A cat =[CLS][ACT]a 1 [EOS][ACT]a 2 [EOS]...[ACT]a cur [EOS]; Use the TransformerEncoder model to implement the dialogue action encoding model ACTEncoder, and convert Acat Enter the specific formula as follows:

[0013]

[0014] ACTEncoder(A cat )=TransformerEncoder(A cat , A cat , A cat )

[0015] TransformerEncoder(A cat , A cat , A cat )=FFN(MultiHead(A cat , A cat , A cat ))

[0016] FFN(x)=LN(Relu(xW 1 +b 1 )W 2 +b 2 +x)

[0017] MultiHead(Q,K,V)=Concat(head 1 , ..., head h )W O +Q

[0018] head i =LN(Attention(QW i Q , KW i K , VW i V ))

[0019]

[0020] Among them, ACTEncoder represents the dialogue action encoding model, TransformerEncoder represents the TransformerEncoder model, FFN represents linear operation, MultiHead represents multi-head attention mechanism calculation, Attention represents attention mechanism calculation, Q, K, V are the input vectors of the attention mechanism, LN represents LayerNorm, Relu is the activation function, and W 1 , W 2 , b 1 , b 2 , W O , W iQ , W i K , W i V is a deep learning trainable parameter, d k represents the dimension of the hidden layer in the Transformer structure, Q, K, V represent the input matrix, K T is the transpose of K, Concat represents the concatenation operation; the vector of [CLS] character calculated by the dialogue action encoding model is taken as the feature representation of the historical dialogue action sequence, denoted as As the output of the dialogue action encoding model;

[0021] 2) Encode the conversation history

[0022] The conversation history T = {U 1 , R 1 , ..., U t-1 , R t-1 , U t} and the dialogue database information D = {d 1 , d 2 , ..., d n} are concatenated and recorded as E. The Transformer Encoder model is used to implement the conversation history encoding model HisEncoder, and E is input. The specific formula is as follows:

[0023] E = concat[T; D]

[0024] H e =HisEncoder(E)

[0025] HisEncoder(E)=TransformerEncoder(E,E,E)

[0026] Concat represents the concatenation operation, TransformerEncoder represents the TransformerEncoder model, and HisEncoder represents the conversation history encoding model;

[0027] The final output H e It represents the encoded information of the conversation history, which is the output of the conversation history encoding model;

[0028] 3) Predict the next round of dialogue actions

[0029] Using the encoded information H of the conversation history e , Feature representation of historical dialogue action sequences And the dialogue belief state V = {v 1 , v 2 , v3 , ..., v n} to predict the next round of actions, first transform the historical dialogue action sequence A = a 1 , a 2 , a 3 , ..., a cur Combine with the belief state V;

[0030]

[0031] in Represents the representation vector of the dialogue belief state at step t, through v t Calculated using one-hot encoding, The action sequence A=a represents the dialogue 1 , a 2 , a 3 , ..., a cur The embedding vector of the input word in step t, W b Represents trainable parameters, each step Composition Matrix Then, we use TransformerDecoder to build the dialogue action prediction model ActDecoder, and input the encoded information H of the dialogue history. e , Historical Dialogue Action Sequence Encoding and U a To do the calculation:

[0032] C a =ActDecoder(U a , O, O)

[0033] ActDecoder(U a ,O,O)=TransformerDecoder(U a , O, O)

[0034]

[0035] TransformerDecoder(U a , O, O)

[0036] =FFN(MultiHead(MultiHead(U a , U a , U a ), O, O))

[0037]

[0038] Among them C arepresents the output of the dialogue action prediction model ActDecoder, TransformerDecoder represents the TransformerDecoder model, Represents C a The vector of step t, concat means concatenating two vectors, and predicting the next word a through linear mapping FFN and activation function softmax t , and the results of each step of the dialogue action prediction model Combine to get the encoding information of the next round of dialogue action

[0039] 4) Generate a response

[0040] Use the next round of dialogue action information encoding H a , Historical Dialogue Action Sequence Encoding With the dialogue history encoding H e To generate responses, we use the TransformerDecoder model to build a dialogue response generation model ResDecoder. The model generation process uses an autoregressive method to generate responses step by step, generating a word y at each step. t , the generated words form the reply Y = {y 0 ,y 1 , ..., y t}, when the first step is initialized, Y = {[BOS]}, where [BOS] is a special label. The results generated in each subsequent step will be added to Y to help the subsequent generation; the specific formula is as follows:

[0041]

[0042]

[0043] M r = TransformerDecoder(G r , H a , H a )

[0044] C r = TransformerDecoder(G r , O, O)

[0045]

[0046]

[0047] Among them, M r and C ris the encoding of the output result of the TransfromerDecoder model, concat represents the concatenation operation, O is the encoding of the concatenated vector result, represents the encoding of the t-th step generation result in the generation result Y, Indicates the encoding of the results from step 1 to step t-1 in the generated result Y, It means M r and C r The encoding of step t in , y t represents the word generated in step t, y 1:t-1 Represents the word results generated from step 1 to step t-1;

[0048] The overall dialogue model is composed of the dialogue action encoding model, the dialogue history encoding model, the dialogue action prediction model and the dialogue response generation model. The loss function calculation during the training process will be divided into two parts: the loss calculation of dialogue action generation and the loss calculation of dialogue response generation, which are denoted as and

[0049]

[0050]

[0051] where a i * and i * Represent the real dialogue action A in the dataset * And the real dialogue reply Y * The word generated in the i-th step, θ represents the parameters of the dialogue model, T represents the dialogue history, D represents the dialogue database, V represents the belief state, and They represent the loss function for dialogue action generation and the loss function for dialogue response generation respectively; and the following formula is used to balance the two functions:

[0052]

[0053] where σ 1 , σ 2 represents the learnable parameters, This is the loss function used by the entire dialogue model.

[0054] The present invention forms a dialogue model by using a dialogue action encoding model, a dialogue history encoding model, a dialogue action prediction model and a dialogue response generation model. Different model structures are used to complete different tasks, so that the results of each part are more accurate, and the influence of the differences between different tasks on the overall performance is avoided, and finally the entire dialogue model is made more accurate and efficient; wherein the dialogue history encoding model helps the dialogue model to better perceive the history, reduces the probability of generating redundant responses, and improves the efficiency of the model; the dialogue action encoding model captures the historical action information, and helps the dialogue model to have a clear understanding of the progress of the current dialogue; the dialogue action prediction model generates the next round of dialogue actions based on the results of the dialogue action encoding model, and avoids the next round of dialogue actions from being repeated or conflicting with the previous ones; and Entering the dialogue belief state to help predict the next round of dialogue actions allows the model to recognize the current information it has acquired and avoid repeated questioning of existing information in the next round of actions; and when the dialogue response generation model uses the dialogue action prediction model results, it uses the representation of the next round of dialogue actions output by the model. In this way, the gradient transfer of the entire model can be guaranteed, making the optimization process smoother; the dialogue response generation model perceives the next round of dialogue actions in advance, clarifies the direction of the response to be generated, and reduces the uncertainty of generation; and the dialogue action prediction model predicts multiple actions that need to be executed when predicting the next round of actions. In this way, the dialogue response generation model generates responses that meet multiple actions at the same time, so that the entire conversation can end faster and save user time.

[0055] When optimizing the model, different loss functions are used for the dialogue action generation model and the dialogue response generation model. and This makes full use of the data set during the optimization process, speeds up the optimization of the model, and reduces the cost of computing resources; the overall loss function Using trainable parameters σ 1 , σ 2 To balance the two parts of the loss function, it avoids the problem of manual parameter adjustment in previous methods. It automatically finds the appropriate balance point through optimization, which also makes the final result more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION

[0057] The present invention is further described in detail below in conjunction with specific embodiments and drawings. The process, conditions, experimental methods, etc. for implementing the present invention, except for the contents specifically mentioned below, are all common knowledge and common common sense in the art and are not particularly limited by the present invention.

[0058] See also Figure 1 The present invention proposes a method for constructing a dialogue model based on deep learning, which can be trained on any dialogue dataset that meets the following requirements, including:

[0059] Contains the conversation history of both parties, T = {U 1 , R 1 , ..., U n-1 , R n-1 , U n},U i represents the sentence asked by the user in the i-th round, R i represents the response of round i;

[0060] The dialogue action sequence A containing each dialogue purpose in the dialogue history = {a 1 , a 2 , a 3 , ..., a n}, for any action a i Contain any number of words;

[0061] The dialogue database D containing the information needed to complete the task = {d 1 , d 2 , ..., d n} indicates that it is used for information query;

[0062] The dialogue belief state V = {v 1 , v 2 , v 3 , ..., v n}, the belief state of round i is v i ={s 1 =p 1 ,s 2 =p 2 , ..., s k =p k}, where s i is the information slot required to complete the task, p i is its corresponding value;

[0063] 1) Encode historical dialogue action sequences

[0064] The historical dialogue action sequence contains the system's historical decisions. This part of the content is crucial to the entire dialogue system. It is the feedback to the user's understanding of the sentence and is also the core of the dialogue response. Therefore, adding historical dialogue actions to the model can make the model more accurate in dialogue action prediction and response generation. Suppose the sequence of historical dialogue actions is A = a 1 , a2 , a 3 , ..., a n , for any action a i contains any number of words, for example, "hotel-notification-region" indicates that the action is to inform the user about the region where the hotel is located in the hotel reservation field. 1 , a 2 , a 3 , ..., a cur Splice, add independent labels [ACT] and [EOS] before and after each dialogue action, and add the label [CLS] before the entire spliced ​​character sequence to get the final spliced ​​sequence: A cat =[CLS][ACT]a 1 [EOS][ACT]a 2 [EOS]...[ACT]a cur [EOS]; Use the Transformer Encoder model to implement the dialogue action encoding model ACTEncoder, and convert A cat Enter the specific formula as follows:

[0065]

[0066] ACTEncoder(A cat )=TransformerEncoder(A cat , A cat , A cat )

[0067] TransformerEncoder(A cat , A cat , A cat )=FFN(MultiHead(A cat , A cat , A cat ))

[0068] FFN(x)=LN(Relu(xW 1 +b 1 )W 2 +b 2 +x)

[0069] MultiHead(Q,K,V)=Concat(head 1 , ..., head h )W O +Q

[0070] head i=LN(Attention(QW i Q , KW i K , VW i V ))

[0071]

[0072] Among them, ACTEncoder represents the dialogue action encoding model, TransformerEncoder represents the TransformerEncoder model, FFN represents linear operation, MultiHead represents multi-head attention mechanism calculation, Attention represents attention mechanism calculation, Q, K, V are the input vectors of the attention mechanism, LN represents LayerNorm, Relu is the activation function, W 1 , W 2 , b 1 , b 2 , W O , W i Q , W i k , W i V is a deep learning trainable parameter, d k represents the dimension of the hidden layer in the Transformer structure, Q, K, V represent the input matrix, K T is the transpose of K, Concat represents the concatenation operation; the vector of [CLS] character calculated by the dialogue action encoding model is taken as the feature representation of the historical dialogue action sequence, denoted as As the output of the dialogue action encoding model;

[0073] 2) Encode the conversation history

[0074] The conversation history T = {U 1 , R 1 , ..., U t-1 , R t-1 , U t} and the dialogue database information D = {d 1 , d 2 , ..., d n} are spliced ​​together. These database information are used for information query, recorded as E. The TransformerEncoder model is used to implement the conversation history encoding model HisEncoder, and E is input. The specific formula is as follows:

[0075] E = concat[T; D]

[0076] He =HisEncoder(E)

[0077] HisEncoder(E)=TransformerEncoder(E,E,E)

[0078] Concat represents the concatenation operation, TransformerEncoder represents the TransformerEncoder model, and HisEncoder represents the conversation history encoding model;

[0079] The final output H e is the encoded information representing the conversation history, which is the output of the conversation history encoding model

[0080] 3) Predict the next round of dialogue actions

[0081] Using the encoded information H of the conversation history e , Feature representation of historical dialogue action sequences And the dialogue belief state V = {v 1 , v 2 , v 3 , ..., v n} to predict the next round of actions. The model uses a generative approach to predict the next round of dialogue actions. Compared with the previous classification method, the sequence generation method allows the model to generate multiple actions at the same time, no longer limited to only one action per round of dialogue. First, the historical dialogue action sequence A = a 1 , a 2 , a 3 , ..., a cur Combined with the belief state V, the information in the dialogue belief state can be used to guide the generation of the next round of dialogue actions;

[0082]

[0083] in Represents the representation vector of the dialogue belief state at step t, through v t Calculated using one-hot encoding, The action sequence A=a represents the dialogue 1 , a 2 , a 3 , ..., a cur The embedding vector of the input word in step t, W b Represents trainable parameters, each step Composition Matrix Then, we use TransformerDecoder to build the dialogue action prediction model ActDecoder, and input the encoded information H of the dialogue history.e , Historical Dialogue Action Sequence Encoding and U a To do the calculation:

[0084] C a =ActDecoder(U a , O, O)

[0085] ActDecoder(U a ,O,O)=TransformerDecoder(U a , O, O)

[0086]

[0087] TransformerDecoder(U a , O, O)

[0088] =FFN(MultiHead(MultiHead(U a , U a , U a ), O, O))

[0089]

[0090] Among them C a represents the output of the dialogue action prediction model ActDecoder, TransformerDecoder represents the TransformerDecoder model, Represents C a The vector of step t, concat means concatenating two vectors, and predicting the next word a through linear mapping FFN and activation function softmax t , and the model will be the result of each step Combine to get the encoding information of the next round of dialogue action

[0091] 4) Generate a response

[0092] Use the next round of dialogue action information encoding H a , Historical Dialogue Action Sequence Encoding With the dialogue history encoding H e To generate responses, we use the TransformerDecoder model to build a dialogue response generation model ResDecoder. The model generation process uses an autoregressive method to generate responses step by step, generating a word y at each step. t , the generated words form the reply Y = {y 0 ,y 1 , ..., yt}, when the first step is initialized, Y = {[BOS]}, where [BOS] is a special label, and the results generated in each subsequent step will be added to Y to help subsequent generation. The specific formula of the model is as follows:

[0093]

[0094]

[0095] M r = TransformerDecoder(G r , H a , H a )

[0096] C r = TransformerDecoder(G r , O, O)

[0097]

[0098]

[0099] Among them, M r and C r is the encoding of the output result of TransfromerDecoder, concat represents the concatenation operation, O is the encoding of the vector result after concatenation, represents the encoding of the t-th step generation result in the generation result Y, Indicates the encoding of the results from step 1 to step t-1 in the generated result Y, It means M r and C r The encoding of step t in , y t represents the word generated in step t, y 1:t-1 Represents the word results generated from step 1 to step t-1;

[0100] The overall dialogue model is composed of a dialogue action encoding model, a dialogue history encoding model, a dialogue action prediction model, and a dialogue response generation model. The loss function calculation during the training process will be divided into two parts: the loss calculation for dialogue action generation and the loss calculation for dialogue response generation, which are denoted as and

[0101]

[0102]

[0103] where a i * andi * Represent the real dialogue action A in the dataset * And the real dialogue reply Y * The word generated in step i, θ represents the parameters of the dialogue model, T represents the dialogue history, D represents the dialogue database, and V represents the belief state. The following formula is used to balance the two functions:

[0104]

[0105] Where σ represents the learnable parameters.

[0106] Example

[0107] Given a conversation history:

[0108] {"I'm looking for a more expensive hotel in the central region.","There are many hotels in the central region. Are you looking for any special dishes?","Are there any Caribbean dishes?","I didn't find anything suitable. You can change the search criteria.","Are there any restaurants that serve European dishes?","I found 2 relatively expensive European restaurants and 1 relatively expensive modern European restaurant. Which one do you prefer?","I don't have a clear preference."}

[0109] And the dialogue action:

[0110] {"Restaurant-Recommendation-Selection&Region, Restaurant-Question-Dishes","Restaurant-Sorry-Empty","Restaurant-Selection-Empty, Restaurant-Notice-Dishes&Price&Selection"}

[0111] Because the dialogue action is mainly to guide the system's response, the dialogue action corresponds to the 2nd, 4th, and 6th sentences in the dialogue history. Because the dialogue belief state and dialogue database are relatively large, the dialogue belief state here only lists the relevant dialogue belief state corresponding to the last dialogue history:

[0112] {"cuisine" = "European", "price" = "high", "region" = "central"}

[0113] And list the conversation database information involved in the final reply:

[0114] {"address":"City Center Public School","area":"Center","cuisine":"European","id":"19245","introduction":"Eraina Restaurant offers a variety of famous dishes and drinks from France, Spain and Italy, as well as Greek dishes for vegetarians","location":[52.203708,0.119082],"name":"Eraina","phone":"01223368786","code":"cb23rh","price":"expensive","type":"restaurant"}

[0115] The dialogue model first uses the dialogue action encoding module to encode the concatenated historical dialogue actions "[CLS][ACT] Restaurant-Recommendation-Select & Region, Restaurant-Question-Dishes[SEP][ACT] Restaurant-Sorry-Nothing[SEP]..." and takes the representation corresponding to [CLS] as the feature representation of the historical dialogue action sequence.

[0116] Then, the conversation history encoding module is used to encode the conversation history. The conversation history "I want to find a hotel in the central area that is a little more expensive. ... I don't have a clear preference." and the conversation database information are input into the conversation history encoding model to obtain the conversation history encoding information H e .

[0117] The dialogue action prediction model uses the concatenated sequence of historical dialogue actions "restaurant-recommendation-selection & region, restaurant-question-dish, restaurant-sorry-empty..." and the feature representation of the historical dialogue action sequence and the encoded information H of the conversation history e To help the model predict the encoding information H of the next round of dialogue action a

[0118] Finally, by using the next round of dialogue action information encoding H a , Historical Dialogue Action Sequence Encoding With the dialogue history encoding H e And Y = {[BOS]} is input into the dialogue response generation model to obtain the output y1 = "Esaina", y1 is concatenated to the end of Y Y = {[BOS], Esaina}, and the next input is obtained to obtain the next step output y2 = "provide", and so on, to get the final output Y = {[BOS], Esaina, provides European dishes, and the price is relatively expensive}.

Claims

1. A method for building a conversation model based on deep learning. The method requires a conversation dataset containing the following contents during the construction process: Contains the conversation history of both parties, T = {U1, R1, ..., U t-1 , R t-1 , U t},U i represents the sentence asked by the user in the i-th round, R i represents the response of round i; The dialogue action sequence A = {a1, a2, a3, ..., a n}, for any action a i Contain any number of words; The dialogue database D = {d1, d2, ..., d n} indicates that it is used for information query; The dialogue belief state V = {v1, v2, v3, ..., v n}, the belief state of round i is v i ={s1=p1, s2=p2,...,s k =p k}, where s i is the information slot required to complete the task, p i is its corresponding value; the construction process is as follows: 1) Encode historical dialogue action sequences The historical dialogue action sequence A = a1, a2, a3, ..., a cur Splice, add independent labels [ACT] and [EOS] before and after each dialogue action, and add the label [CLS] before the entire spliced ​​character sequence to get the final spliced ​​sequence: A cat =[CLS][ACT]a1[EOS][ACT]a2[EOS]...[ACT]a cur [EOS]; Use the TransformerEncoder model to implement the dialogue action encoding model ACTEncoder, and convert A cat Enter the specific formula as follows: ACTEncoder(A cat )=TransformerEncoder(A cat , A cat , A cat ) TransformerEncoder(A cat , A cat , A cat )=FFN(MultiHead(A cat , A cat , A cat )) FFN(x)=LN(Relu(xW1+b1)W2+b2+x) MultiHead(Q,K,V)=Concat(head1,...,head h )W O +Q ACTEncoder represents the dialogue action encoding model, TransformerEncoder represents the TransformerEncoder model, FFN represents the linear operation, MultiHead represents the multi-head attention mechanism calculation, Attention represents the attention mechanism calculation, Q, K, V are the input vectors of the attention mechanism, LN represents LayerNorm, Relu is the activation function, W1, W2, b1, b2, W O , W i Q , is a deep learning trainable parameter, d k represents the dimension of the hidden layer in the Transformer structure, Q, K, V represent the input matrix, K T is the transpose of K, Concat represents the concatenation operation; the vector of [CLS] character calculated by the dialogue action encoding model is taken as the feature representation of the historical dialogue action sequence, denoted as As the output of the dialogue action encoding model; 2) Encode the conversation history The conversation history T = {U1, R1, ..., U t-1 , R t-1 , U t} and dialogue database information D = {d1, d2, ..., d n} are concatenated and recorded as E. The Transformer Encoder model is used to implement the conversation history encoding model HisEncoder, and E is input. The specific formula is as follows: E = concat[T; D] H e =HisEncoder(E) HisEncoder(E)=TransformerEncoder(E,E,E) Concat represents the concatenation operation, TransformerEncoder represents the TransformerEncoder model, and HisEncoder represents the conversation history encoding model; The final output H e It represents the encoded information of the conversation history, which is the output of the conversation history encoding model; 3) Predict the next round of dialogue actions Using the encoded information H of the conversation history e , Feature representation of historical dialogue action sequences And the dialogue belief state V = {v1, v2, v3, ..., v n} to predict the next round of actions, first transform the historical dialogue action sequence A = a1, a2, a3, ..., a cur Combine with the belief state V; in Represents the representation vector of the dialogue belief state at step t, through v t Calculated using one-hot encoding, The action sequence A represents the dialogue = a1, a2, a3, ..., a cur The embedding vector of the input word in step t, W b Represents trainable parameters, each step Composition Matrix Then, we use TransformerDecoder to build the dialogue action prediction model ActDecoder, and input the encoded information H of the dialogue history. e , Historical Dialogue Action Sequence Encoding And Ua to calculate: C a =ActDecoder(U a ,0,0) ActDecoder(U a ,0,0)=TransformerDecoder(u a ,0,0) TransformerDecoder(U a ,O,O)=FFN(MultiHead(MultiHead(U a , U a , U a ), O, O)) Among them C a represents the output of the dialogue action prediction model ActDecoder, TransformerDecoder represents the TransformerDecoder model, Represents C a The vector of step t, concat means concatenating two vectors, and predicting the next word a through linear mapping FFN and activation function softmax t , and the results of each step of the dialogue action prediction model Combine to get the encoding information of the next round of dialogue action 4) Generate a response Use the next round of dialogue action information encoding H a , Historical Dialogue Action Sequence Encoding With the dialogue history encoding H e To generate responses, we use the TransformerDecoder model to build a dialogue response generation model ResDecoder. The model generation process uses an autoregressive method to generate responses step by step, generating a word y at each step. t , the generated words form the reply Y = {y0, y1, ..., y t}, when the first step is initialized, Y = {[BOS]}, where [BOS] is a special label. The results generated in each subsequent step will be added to Y to help the subsequent generation; the specific formula is as follows: M r = TransformerDecoder(G r , H a , H a ) C r = TransformerDecoder(G r ,0,0) Among them, M r and C r is the encoding of the output result of the TransfromerDecoder model, concat represents the concatenation operation, and 0 is the encoding of the vector result after concatenation. represents the encoding of the t-th step generation result in the generation result Y, Indicates the encoding of the results from step 1 to step t-1 in the generated result Y, It means M r and C r The encoding of step t in , y t represents the word generated in step t, y1:t-1 Represents the word results generated from step 1 to step t-1; The overall dialogue model is composed of the dialogue action encoding model, the dialogue history encoding model, the dialogue action prediction model and the dialogue response generation model. The loss function calculation during the training process will be divided into two parts: the loss calculation of dialogue action generation and the loss calculation of dialogue response generation, which are denoted as and in, θ represents the parameters of the dialogue model, T represents the dialogue history, D represents the dialogue database, and V represents the belief state. and They represent the loss function for dialogue action generation and the loss function for dialogue response generation respectively; and the following formula is used to balance the two functions: Where σ, σ represents the learnable parameters, This is the loss function used by the entire dialogue model.

Citation Information

Patent Citations

  • Dialogue generation method based on a long-short-term memory neural network

    CN109918493A

  • Dialogue system, a dialogue method, a method of generating data for training a dialogue system, a system for generating data for training a dialogue system and a method of training a dialogue system

    US20200152184A1

  • System and Method for Automatic Task-Oriented Dialog System

    US20210089588A1