A dialogue state tracking method based on prompt learning
By manually designing the prompt text and automatic learning of the pre-trained model, combined with Seq2Seq and pointer generation network, the problem of inflexible prompt design and inaccurate slot value in human-computer dialogue state tracking is solved, and the generalization of the dialogue state tracking model is achieved. Ability and slot value generation capabilities under open vocabulary.
Patent Information
- Application Number
- CN202410857999.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-08-23
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing technology, in human-computer dialogue state tracking, the Prompt-based method has a heavy design workload and is not flexible enough, making it difficult to adapt to different models and tasks. Moreover, the existing model has repeated decoding and slot values in dialogue state tracking under an open vocabulary. Insufficient precision problem.
The manually designed Prompt text is used for initialization, and through automatic learning and fine-tuning of the pre-trained model, combined with the Seq2Seq structure and pointer generation network, a continuous Prompt word vector that adapts to the model is generated to realize the training of the dialogue state tracking model and the generation of slot values.
It improves the generalization ability and domain scalability of the model, and solves the problems of inflexible Prompt design and inaccurate slot values. At the same time, it retains the generation ability under an open vocabulary and can directly extract slot values from input sentences.
Smart Images

Figure CN118394920B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of human-computer dialogue in natural language processing, and in particular to a dialogue state tracking method based on prompt learning. Background Art
[0002] With the breakthrough of natural language technology, human-computer dialogue systems are increasingly widely used in human-computer interaction, intelligent customer service and other fields. In the human-computer dialogue scenario, dialogue state tracking is responsible for the real-time maintenance and update of each dialogue state. As a key part of the entire system, its effect has a direct and crucial impact on the completion of the task. With the introduction of GPT3, prompt-based methods have become popular. In the field of dialogue state tracking, prompt-based methods often use manually designed discrete prompts. However, this design method, which is labor-intensive, needs to be designed for different data, and it is difficult to guarantee the quality of each prompt text; it is not flexible enough and difficult to adapt to different models and tasks.
[0003] Secondly, many current dialogue state tracking models are based on predefined ontologies. Given all possible dialogue state slot values in the system, a classifier is then used to determine whether each dialogue state is updated with the current slot value. This method artificially simplifies the range of slot values and does not support the tracking of dialogue states under an open vocabulary, so it has great limitations in practical applications. Recently, models based on open vocabulary have been proposed one after another, expanding the range of dialogue state slot values to the entire vocabulary. Among them, the Seq2Seq-based model can use the decoder to directly generate slot values. However, for some keywords, there will be a problem of repeated decoding. In addition, some methods use the idea of pointers to directly mark the corresponding slot values in the dialogue sentences between users and the system. However, this method cannot solve the problem that some words in the slot values cannot be directly found in the dialogue sentences.
[0004] In the prior art, the T5 pre-trained model is used as the encoder and decoder to directly generate the dialogue state between the system and the user's speech. BERT is used as the encoder and decoder, and the attention-mask matrix is used to control BERT for state prediction and slot value generation, which realizes the flat modeling of the encoder and decoder, improves the efficiency of the model, and solves the problem that the model using the layered decoder cannot be jointly optimized. These generative models can get rid of the limitations of data samples, but the generated slot values are often not accurate enough. The task-based dialogue is completed in an end-to-end manner, and the dialogue state is used as the intermediate part of the output, but the dialogue state generated in this way is overly dependent on the training data, and the effect is not very good. Summary of the invention
[0005] The present invention discloses a dialog state tracking method based on Prompt learning, which uses artificially designed Prompt prompt text for initialization, and then fine-tunes the Prompt through automatic learning of a pre-trained model to obtain a continuous Prompt word vector that is more suitable for the model, thereby achieving stronger generalization ability and domain scalability.
[0006] The purpose of the present invention is achieved by at least one of the following technical solutions.
[0007] A method for tracking dialog states based on prompt learning includes the following steps:
[0008] S1. Given a dialogue dataset, construct a set of artificial prompt texts, initialize the T5 pre-trained model, and modify the dialogue dataset to Prompt through automatic learning of the T5 pre-trained model, taking the artificially constructed Prompt text as the standard, generate the corresponding word vector and perform fine-tuning to obtain a continuous Prompt word vector that is more suitable for the T5 pre-trained model;
[0009] S2. Combine the Seq2Seq structure and the pointer generation network to build and train a dialogue state tracking model. In the dialogue state tracking model, the probability distribution of the input sequence extracted by the pointer generation network and the probability distribution of the vocabulary output by the decoder of the T5 pre-trained model are combined to obtain the final distribution.
[0010] S3. For data that need to track the dialogue state, use unsupervised methods to extract keyword information from the data to obtain preprocessed data. Then input the preprocessed data into the trained dialogue state tracking model to obtain the final distribution. Finally, the maximum probability of the final distribution is output as the intention and slot value of the dialogue state.
[0011] Furthermore, in step S1, the given dialogue dataset is in the form of task-based multi-discussion dialogue data. , including multiple rounds of conversation histories between users and customer service in multiple set fields, as well as the user intentions and slot-value pairs contained in the conversations.
[0012] Furthermore, step S1 specifically includes the following steps:
[0013] S1.1. According to the characteristics of the dialogue state tracking task, a set of discrete prompt texts are manually constructed, where each prompt text is represented as ;in n is the length of the text, Prompt text The n words; use Tokenizer to Tokenize the Prompt text Encode and get Prompt word vector in space , Prompt text The n The encoding vector of each word; the parameters of the T5 pre-trained model are initialized as , that is, initialized to the parameters of the T5 pre-trained model itself, and the conversation data set is the multi-round conversation between the system and the user and keywords Encode using the Tokenizer of the T5 pre-trained model and compare it with the Prompt word vector Splice to get the synthetic input sequence ;
[0014]
[0015] S1.2. Fix the parameters of the T5 pre-trained model to the initialization parameters , the synthetic input sequence Input into the T5 pre-trained model, without going through the pointer generation network, directly predict the dialogue state slot value for fine-tuning the Prompt word vector; for a set of Prompt prompt texts converted into word vectors , define the ensemble prediction distribution as:
[0016]
[0017] Among them, the learned mixing weight exist By maximizing the set prediction distribution, we can get the local optimal continuous prompt word vector ,in x For user statements, y is the dialogue state corresponding to the sentence; Indicates a given x After getting y The conditional probability of Indicates a given , the probability that the T5 pre-trained model outputs y;
[0018] The loss function is:
[0019]
[0020] Among them, the synthetic input sequence is updated using the gradient descent method through the back propagation algorithm , which minimizes the loss function and obtains the fine-tuned Prompt word vector ;
[0021] S1.3. Fine-tune the Prompt word vector Send it to the initialized T5 pre-trained model, which will predict and generate the fine-tuned Prompt word vector The blank content in the middle is the slot value of the dialogue, and the continuous prompt word vector is obtained ; This step fits the input-output relationship of the T5 pre-trained model to mask the language modeling task, and improves the performance of the T5 pre-trained model in the dialogue state tracking task; but it is only the first step of improvement, and the T5 pre-trained model is still in the initialization state, and subsequent steps are needed to further strengthen the T5 pre-trained model.
[0022] Further, in step S2, the dialogue state tracking model includes a T5 pre-trained model and a pointer generation network;
[0023] In the dialogue state tracking model, the continuous prompt word vector obtained in step S1 is input into the T5 pre-trained model to obtain the attention weight distribution and attention context vector; the attention context vector is input into the pointer generation network to obtain the vocabulary probability distribution and generation pointer; the attention weight distribution and the vocabulary probability distribution are combined through the generation pointer to obtain the final distribution, and the maximum value of the distribution is taken to obtain the final slot value pair and intent.
[0024] Furthermore, the T5 pre-trained model includes a multi-head attention module, an encoder and a decoder; the multi-head attention module includes multiple self-attention heads;
[0025] Continuous Prompt word vector In the input attention module, each self-attention head will vector the same continuous prompt word The word vector of Vector and word vector of Multiply the vectors and get the Prompt concatenated word vector through self-attention The multi-head self-attention weight vector , multi-head self-attention weight vector Including position information; unlike the BERT model, the T5 pre-trained model does not add absolute position encoding to the word vector of the input sequence, but adds relative position encoding when calculating the self-attention weight.
[0026] Calculating the multi-head self-attention weight vector When there is a concept of relative position coding, relative position coding Depends on word vector and word vector The relative distance ; In order to represent all possible relative distances with a limited number of position codes, the distances exceeding the length will be truncated; relative position coding The calculation formula is as follows and Two steps:
[0027]
[0028]
[0029] in, and They are the first step relative position encoding and the second step relative position encoding respectively; and are the weight vectors of the first-step relative position encoding and the second-step relative position encoding, which can be in the form of trainable parameters or trigonometric functions. and They are the minimum and maximum values of the first step relative position encoding and the second step relative position encoding respectively; is the truncation function;
[0030] First, by calculating the first step relative position encoding Get location information:
[0031]
[0032]
[0033] in, Indicates The self-attention head is used to i The word and j The attention weights between words, and For the The parameter matrix of the Q vector and K vector in the self-attention head, G is the number of heads in the multi-head attention module, yes The dimension of , and then the attention weight Normalized to get is the final weight;
[0034] In calculating context weight When adding the second step relative position encoding :
[0035]
[0036] represents the context weight at time 0;
[0037] Then use Bahdanau attention on the hidden layer of the encoder and the hidden layer of the decoder in the T5 pre-trained model to calculate the attention weight distribution of each word; for the continuous prompt word vector input with the encoder The corresponding hidden layer and the decoder at time The hidden layer , respectively use and The weight matrix is linearly transformed so that and The dimensions are the same; after adding the two transformed parts, the tanh activation function is used to obtain the attention weight distribution vector ; Finally, the attention weight distribution vectors of all words are normalized by softmax to obtain the attention weight distribution of each word , as follows:
[0038]
[0039]
[0040] in, yes The transpose of is the bias parameter of the multi-head attention module;
[0041] Use the calculated word attention weight distribution , the continuous prompt word vector input to the encoder Middle i word vector The corresponding hidden layer Do the weighted sum to get the attention context vector at time t :
[0042]
[0043] Among them, the attention context vector Contains all The contextual semantic information of all words in the input sequence at any time, Constitute the attention weight distribution of the entire time t; so far, the output attention weight distribution of the T5 pre-training model is obtained and the attention context vector ,in yes and Splicing .
[0044] Furthermore, in the pointer generation network, the attention context vector output by the T5 pre-trained model is and the decoder hidden state After splicing, passing through two layers of fully connected layers and Softmax activation function, we get the probability distribution of the vocabulary :
[0045]
[0046] in, is the training parameter;
[0047] Then the attention context vector And the vocabulary probability distribution Combined, the calculation generates the pointer , used to control the source of generated words; for Generating pointer of time , is the pointer set at each moment, calculated as follows:
[0048]
[0049] in, for The hidden layer input of the decoder at time t, , , All of them are pointers to generate network training parameters. for sigmod function; pointer The value range is ,pointer The larger the value is, the more sources the generated words come from, that is, most of the words come from the vocabulary; pointer The smaller it is, the fewer sources of generated words, that is, most of the words come from the original input sequence;
[0050] So far, we have obtained the output vocabulary probability distribution of the pointer generation network ,and Generating pointer of time .
[0051] Furthermore, in the dialogue state tracking model, the attention weight value And the vocabulary probability distribution pass Generating pointer of time Combined, calculate the final generation probability distribution:
[0052]
[0053] in, Expressive words Probability distribution in vocabulary The value on Represents the sum of attention weights for each word vector; Generate network words for pointers At the moment The probability value on all words The probability value of the final probability distribution .
[0054] Furthermore, in step S2, the negative log-likelihood is taken as the loss function, and the entire generated time length is defined as T , the loss function of the pointer generation network for:
[0055]
[0056] By training this loss function, we get the parameters of the entire dialogue state tracking model , in are the post-training parameters of the T5 pre-trained model, It is the parameter after the pointer generates the network training.
[0057] Furthermore, step S3 specifically includes the following steps:
[0058] S3.1. For each sentence in the data that needs to track the dialogue state To perform word segmentation, , As a word list, then remove stop words to get the candidate words after filtering each sentence, and finally form a word list of the words in each sentence , ,in r For sentence length:
[0059]
[0060] in Refers to the word segmentation operation; Refers to the operation of removing stop words;
[0061] S3.2. Use word list The candidate words filtered in each sentence are used to build a candidate word graph using the co-occurrence window , where Vec represents the node set of the candidate word graph, and Edg represents the edge set of the candidate word graph
[0062] combine, Indicates the number of nodes; Represents the first a nodes, , No.a The weight of the node Indicates the importance of the node in the candidate word graph. Initially, ; For the first a Nodes and c The line connecting the nodes , its weight Indicates a Nodes and c The co-occurrence relationship between nodes. Initially, the weight of each edge ; Then, the weight of each node is iteratively calculated until the result converges:
[0063]
[0064]
[0065] in, is a list of the initial weights of all nodes, Indicates a The initial weight of each node. The closer a word is to the front and the more times it appears, the greater its weight. If a word appears in multiple positions in a conversation, the weights are added together. Indicates a The set of all nodes that have connections to each node; Indicates c A collection of nodes that are not connected; Represents the damping coefficient, the value range is [0,1], Indicates a Nodes Final weight;
[0066] S3.3, sort the candidate words in each sentence in descending order according to their weights, and take the top as keywords , Sort by weight x If there are two keywords that are connected in the text, the two keywords will be merged into one keyword.
[0067] S3.4, the result obtained in step S3.3 Keywords in Dig it out as the final input , input into the dialogue state tracking model PDST trained in S2, and get the final distribution. The maximum value of the distribution is the dialogue slot value Slot With intention Intent :
[0068] .
[0069] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0070] 1. The present invention uses artificially designed Prompt text for initialization, and then fine-tunes the Prompt through automatic learning of a pre-trained model to obtain a continuous Prompt word vector that is more suitable for the model, thereby achieving stronger generalization ability and domain scalability, and improving the problem that the current artificially designed Prompt text is not flexible enough and cannot guarantee quality.
[0071] 2. Since the dialogue state tracking model based on an open vocabulary list may have the problem of repeated decoding for certain keywords, and the model based on the pointer idea cannot solve the problem that some words in the slot value cannot be directly found in the dialogue sentence, the present invention combines the Seq2Seq structure with the idea of pointers, and uses a pointer generation network on the basis of the T5 pre-trained model encoder and decoder to combine the probability distribution of the input sequence extracted by the pointer network with the probability distribution of the vocabulary output by the T5 decoder. While retaining the ability to generate slot values under the open vocabulary, the model is given the ability to directly extract slot values from the input sentence, combining the advantages of both.
[0072] 3. In task-based dialogues, users’ speech usually revolves around their goals. The present invention designs a feature enhancement method that combines dialogue sentence keywords, and uses keyword information extracted by unsupervised methods to give dialogue sentences richer features, so that the model pays attention to the more important parts of the dialogue sentences. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 A schematic diagram of the steps of a method for tracking a dialog state based on prompt learning in an embodiment of the present invention;
[0074] Figure 2 is a structural diagram of a dialogue state tracking model in an embodiment of the present invention;
[0075] Figure 3 Schematic diagram for comparing the Prompt learning process in an embodiment of the present invention. DETAILED DESCRIPTION
[0076] The technical solution of the present invention is described below in conjunction with the accompanying drawings in the embodiments of the present invention. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0077] Example:
[0078] A dialogue state tracking method based on prompt learning, such as Figure 1 , Figure 2and Figure 3 As shown, the following steps are included:
[0079] S1. Given a dialogue dataset, construct a set of artificial prompt texts, initialize the T5 pre-trained model, and modify the dialogue dataset to Prompt through automatic learning of the T5 pre-trained model, taking the artificially constructed Prompt text as the standard, generate the corresponding word vector and perform fine-tuning to obtain a continuous Prompt word vector that is more suitable for the T5 pre-trained model;
[0080] Figure 3 An example of converting an artificially constructed prompt text to a continuous prompt word vector is given. The artificially constructed prompt text is "Given the following dialogue history <x>and keywords <k>, Dialogue <d>Which slot in <s>Is it what the user is looking for?". The continuous prompt word vector is [ , <x> , , <k> , <s>, , <d>, , ]
[0081] In one embodiment, the given dialogue dataset is in the form of task-based multi-discussion dialogue data. , including multiple rounds of conversation histories between users and customer service in multiple set fields, as well as the user intentions and slot-value pairs contained in the conversations.
[0082] Step S1 specifically includes the following steps:
[0083] S1.1. According to the characteristics of the dialogue state tracking task, a set of discrete prompt texts are manually constructed, where each prompt text is represented as ;in n is the length of the text, Prompt text The n words; use Tokenizer to Tokenize the Prompt text Encode and get Prompt word vector in space , Prompt text The n The encoding vector of each word; the parameters of the T5 pre-trained model are initialized as , that is, initialized to the parameters of the T5 pre-trained model itself, and the conversation data set is the multi-round conversation between the system and the user and keywords Encode using the Tokenizer of the T5 pre-trained model and compare it with the Prompt word vector Splice to get the synthetic input sequence ;
[0084]
[0085] S1.2. Fix the parameters of the T5 pre-trained model to the initialization parameters , the synthetic input sequence Input into the T5 pre-trained model, without going through the pointer generation network, directly predict the dialogue state slot value for fine-tuning the Prompt word vector; for a set of Prompt prompt texts converted into word vectors , define the ensemble prediction distribution as:
[0086]
[0087] Among them, the learned mixing weight exist By maximizing the set prediction distribution, we can get the local optimal continuous prompt word vector ,in x For user statements, y is the dialogue state corresponding to the sentence; Indicates a given x After getting y The conditional probability of Indicates a given , the probability that the T5 pre-trained model outputs y;
[0088] The loss function is:
[0089]
[0090] Among them, the synthetic input sequence is updated using the gradient descent method through the back propagation algorithm , which minimizes the loss function and obtains the fine-tuned Prompt word vector ;
[0091] S1.3. Fine-tune the Prompt word vector Send it to the initialized T5 pre-trained model, which will predict and generate the fine-tuned Prompt word vector The blank content in the middle is the slot value of the dialogue, and the continuous prompt word vector is obtained ; This step fits the input-output relationship of the T5 pre-trained model to mask the language modeling task, and improves the performance of the T5 pre-trained model in the dialogue state tracking task; but it is only the first step of improvement, and the T5 pre-trained model is still in the initialization state, and subsequent steps are needed to further strengthen the T5 pre-trained model.
[0092] S2. Combine the Seq2Seq structure and the pointer generation network to build and train a dialogue state tracking model. In the dialogue state tracking model, the probability distribution of the input sequence extracted by the pointer generation network and the probability distribution of the vocabulary output by the decoder of the T5 pre-trained model are combined to obtain the final distribution.
[0093] The dialogue state tracking model includes the T5 pre-trained model and the pointer generation network;
[0094] In the dialogue state tracking model, the continuous prompt word vector obtained in step S1 is input into the T5 pre-trained model to obtain the attention weight distribution and attention context vector; the attention context vector is input into the pointer generation network to obtain the vocabulary probability distribution and generation pointer; the attention weight distribution and the vocabulary probability distribution are combined through the generation pointer to obtain the final distribution, and the maximum value of the distribution is taken to obtain the final slot value pair and intent.
[0095] The T5 pre-trained model includes a multi-head attention module, an encoder and a decoder; the multi-head attention module includes multiple self-attention heads;
[0096] Continuous Prompt word vector In the input attention module, each self-attention head will vector the same continuous prompt word The word vector of Vector and word vector of Multiply the vectors and get the Prompt concatenated word vector through self-attention The multi-head self-attention weight vector , multi-head self-attention weight vector Including position information; unlike the BERT model, the T5 pre-trained model does not add absolute position encoding to the word vector of the input sequence, but adds relative position encoding when calculating the self-attention weight.
[0097] In one embodiment, when calculating the multi-head self-attention weight vector When there is a concept of relative position coding, relative position coding Depends on word vector and word vector The relative distance ; In order to represent all possible relative distances with a limited number of position codes, the distances exceeding the length will be truncated; relative position coding The calculation formula is as follows and Two steps:
[0098]
[0099]
[0100] in, and They are the first step relative position encoding and the second step relative position encoding respectively; and are the weight vectors of the first-step relative position encoding and the second-step relative position encoding, which can be in the form of trainable parameters or trigonometric functions. and They are the minimum and maximum values of the first step relative position encoding and the second step relative position encoding respectively; is the truncation function;
[0101] First, by calculating the first step relative position encoding Get location information:
[0102]
[0103]
[0104] in, Indicates The self-attention head is used to i The word and j The attention weights between words, and For the The parameter matrix of the Q vector and K vector in the self-attention head, G is the number of heads in the multi-head attention module, yes The dimension of , and then the attention weight Normalized to get is the final weight;
[0105] In calculating context weight When adding the second step relative position encoding :
[0106]
[0107] represents the context weight at time 0;
[0108] Then use Bahdanau attention on the hidden layer of the encoder and the hidden layer of the decoder in the T5 pre-trained model to calculate the attention weight distribution of each word; for the continuous prompt word vector input with the encoder The corresponding hidden layer and the decoder at time The hidden layer , respectively use and The weight matrix is linearly transformed so that and The dimensions are the same; after adding the two transformed parts, the tanh activation function is used to obtain the attention weight distribution vector ; Finally, the attention weight distribution vectors of all words are normalized by softmax to obtain the attention weight distribution of each word , as follows:
[0109]
[0110]
[0111] in, yes The transpose of is the bias parameter of the multi-head attention module;
[0112] Use the calculated word attention weight distribution , the continuous prompt word vector input to the encoder Middle i word vector The corresponding hidden layer Do the weighted sum to get the attention context vector at time t :
[0113]
[0114] Among them, the attention context vector Contains all The contextual semantic information of all words in the input sequence at any time, Constitute the attention weight distribution of the entire time t; so far, the output attention weight distribution of the T5 pre-training model is obtained and the attention context vector ,in yes and Splicing .
[0115] In the pointer generation network, the attention context vector output by the T5 pre-trained model is and the decoder hidden state After splicing, passing through two layers of fully connected layers and Softmax activation function, we get the probability distribution of the vocabulary :
[0116]
[0117] in, is the training parameter;
[0118] Then the attention context vector And the vocabulary probability distribution Combined, the calculation generates a pointer , used to control the source of generated words; for Generating pointer of time , is the pointer set at each moment, calculated as follows:
[0119]
[0120] in, for The hidden layer input of the decoder at time t, , , All of them are pointers to generate network training parameters. for sigmod function; pointer The value range is ,pointer The larger the value is, the more sources the generated words come from, that is, most of the words come from the vocabulary; pointer The smaller it is, the fewer sources of generated words, that is, most of the words come from the original input sequence;
[0121] So far, we have obtained the output vocabulary probability distribution of the pointer generation network ,and Generating pointer of time .
[0122] In the dialogue state tracking model, the attention weight value And the vocabulary probability distribution pass Generating pointer of time Combined, calculate the final generation probability distribution:
[0123]
[0124] in, Expressive words Probability distribution in vocabulary The value on Represents the sum of attention weights for each word vector; Generate network words for pointers At the moment The probability value on all words The probability value of the final probability distribution .
[0125] Take the negative log-likelihood as the loss function and define the entire generated time length as T , the loss function of the pointer generation network for:
[0126]
[0127] By training this loss function, we get the parameters of the entire dialogue state tracking model , in are the post-training parameters of the T5 pre-trained model, It is the parameter after the pointer generates the network training.
[0128] S3. For the data that needs to be tracked for the dialogue state, use an unsupervised method to extract the keyword information of the data to obtain the preprocessed data, and then input the preprocessed data into the trained dialogue state tracking model to obtain the final distribution. Finally, the maximum probability of the final distribution is output as the intention and slot value of the dialogue state, which specifically includes the following steps:
[0129] S3.1. For each sentence in the data that needs to track the dialogue state To perform word segmentation, such as Figure 2 The conversation history in "System: In which area would you like to look for a hotel? User: There is an Ashley Hotel in East Town.", , As a word list, then remove stop words to get the candidate words after filtering each sentence, and finally form a word list of the words in each sentence , ,in r For sentence length:
[0130]
[0131] in Refers to the word segmentation operation; Refers to the operation of removing stop words; for Figure 2 The prompt word "gives the following conversation history <x>With keywords <k>, users are looking for hostel of name What is it?”
[0132] S3.2. Use word list The candidate words filtered in each sentence are used to build a candidate word graph using the co-occurrence window , where Vec represents the node set of the candidate word graph, and Edg represents the edge set of the candidate word graph
[0133] combine, Indicates the number of nodes; Represents the first a nodes, , No. a The weight of the node Indicates the importance of the node in the candidate word graph. Initially, ; For the first a Nodes and c The line connecting the nodes , its weight Indicates a Nodes and c The co-occurrence relationship between nodes. Initially, the weight of each edge ; Then, the weight of each node is iteratively calculated until the result converges:
[0134]
[0135]
[0136] in, is a list of the initial weights of all nodes, Indicates a The initial weight of each node. The closer a word is to the front and the more times it appears, the greater its weight. If a word appears in multiple positions in a conversation, the weights are added together. Indicates a The set of all nodes that have connections to each node; Indicates c A collection of nodes that are not connected; represents the damping coefficient, and its value range is [0,1]. In one embodiment, it is 0.85. Indicates a Nodes Final weight;
[0137] S3.3, sort the candidate words in each sentence in descending order according to the weight, corresponding to the position sorting module in Figure 2, and take the first as keywords , Sort by weight x If there are two keywords that are connected in the text, the two keywords will be merged into one keyword.
[0138] S3.4, the result obtained in step S3.3 Keywords in Dig it out as the final input , input into the dialogue state tracking model PDST trained in S2, and get the final distribution. The maximum value of the distribution is the dialogue slot value Slot With intention Intent :
[0139] .
[0140] correspond Figure 2 The top distribution graph shows the maximum value for "Ashley Hotel".
[0141] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that a variety of equivalent changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.< / k> < / x> < / d> < / s> < / k> < / x> < / s> < / d> < / k> < / x>
Claims
1. A method for tracking dialog states based on prompt learning, characterized in that: The following steps are involved: S1. Given a dialogue dataset, construct a set of artificial prompt texts, initialize the T5 pre-trained model, and modify the dialogue dataset to Prompt through automatic learning of the T5 pre-trained model, taking the artificially constructed Prompt text as the standard, generate the corresponding word vector and perform fine-tuning to obtain a continuous Prompt word vector that is more suitable for the T5 pre-trained model; S2. Combine the Seq2Seq structure and the pointer generation network to build and train the dialogue state tracking model; In the dialogue state tracking model, the probability distribution of the input sequence extracted by the pointer generation network is combined with the probability distribution of the vocabulary output by the decoder of the T5 pre-trained model to obtain the final distribution; S3. For data that need to track the dialogue state, use unsupervised methods to extract keyword information from the data to obtain preprocessed data. Then input the preprocessed data into the trained dialogue state tracking model to obtain the final distribution. Finally, the maximum probability of the final distribution is output as the intention and slot value of the dialogue state.
2. According to the method of claim 1, the method is characterized in that: In step S1, the given dialogue dataset is in the form of task-based multi-discussion dialogue data , including multiple rounds of conversation histories between users and customer service in multiple set fields, as well as the user intentions and slot-value pairs contained in the conversations.
3. According to the method of claim 2, the method is characterized in that: Step S1 specifically includes the following steps: S1.
1. According to the characteristics of the dialogue state tracking task, a set of discrete prompt texts are manually constructed, where each prompt text is represented as ;in n is the length of the text, Prompt text The n words; use Tokenizer to Tokenize the Prompt text Encode and get Prompt word vector in space , Prompt text The n The encoding vector of each word; the parameters of the T5 pre-trained model are initialized as , that is, initialized to the parameters of the T5 pre-trained model itself, and the conversation data set is the multi-round conversation between the system and the user and keywords Encode using the Tokenizer of the T5 pre-trained model and compare it with the Prompt word vector Splice to get the synthetic input sequence ; S1.
2. Fix the parameters of the T5 pre-trained model to the initialization parameters , the synthetic input sequence Input into the T5 pre-trained model to directly predict the dialog state slot value for fine-tuning the Prompt word vector; for a set of Prompt prompt texts converted into word vectors , define the ensemble prediction distribution as: Among them, the learned mixing weight exist By maximizing the set prediction distribution, we can get the local optimal continuous prompt word vector ,in x For user statements, y is the dialogue state corresponding to the sentence; Indicates a given x After getting y The conditional probability of Indicates a given , the probability that the T5 pre-trained model outputs y; The loss function is: Among them, the synthetic input sequence is updated using the gradient descent method through the back propagation algorithm , which minimizes the loss function and obtains the fine-tuned Prompt word vector ; S1.
3. Fine-tune the Prompt word vector Send it to the initialized T5 pre-trained model, which will predict and generate the fine-tuned Prompt word vector The blank content in the middle is the slot value of the dialogue, and the continuous prompt word vector is obtained .
4. The method for tracking dialog states based on prompt learning according to claim 1, characterized in that: In step S2, the dialogue state tracking model includes a T5 pre-trained model and a pointer generation network; In the dialogue state tracking model, the continuous prompt word vector obtained in step S1 is input into the T5 pre-trained model to obtain the attention weight distribution and attention context vector; the attention context vector is input into the pointer generation network to obtain the vocabulary probability distribution and generation pointer; the attention weight distribution and the vocabulary probability distribution are combined through the generation pointer to obtain the final distribution, and the maximum value of the distribution is taken to obtain the final slot value pair and intent.
5. According to claim 4, a method for tracking dialog states based on prompt learning is characterized in that: The T5 pre-trained model includes a multi-head attention module, an encoder and a decoder; the multi-head attention module includes multiple self-attention heads; Continuous Prompt word vector In the input attention module, each self-attention head will vector the same continuous prompt word The word vector of Vector and word vector of Multiply the vectors and get the Prompt concatenated word vector through self-attention The multi-head self-attention weight vector , multi-head self-attention weight vector including location information; Calculating the multi-head self-attention weight vector When there is a concept of relative position coding, relative position coding Depends on word vector and word vector The relative distance ; In order to represent all possible relative distances with a limited number of position codes, the distances exceeding the length will be truncated; relative position coding The calculation formula is as follows and Two steps: in, and They are the first step relative position encoding and the second step relative position encoding respectively; and are the weight vectors of the first-step relative position encoding and the second-step relative position encoding, in the form of trainable parameters or trigonometric functions, and They are the minimum and maximum values of the first step relative position encoding and the second step relative position encoding respectively; is the truncation function; First, by calculating the first step relative position encoding Get location information: in, Indicates The self-attention head is used to i The word and j The attention weights between words, and For the The parameter matrix of the Q vector and K vector in the self-attention head, G is the number of heads in the multi-head attention module, yes The dimension of , and then the attention weight Normalized to get is the final weight; In calculating context weight When adding the second step relative position encoding : represents the context weight at time 0; Then use Bahdanau attention on the hidden layer of the encoder and the hidden layer of the decoder in the T5 pre-trained model to calculate the attention weight distribution of each word; for the continuous prompt word vector input with the encoder The corresponding hidden layer and the decoder at time The hidden layer , respectively use and The weight matrix is linearly transformed so that and The dimensions are the same; after adding the two transformed parts, the tanh activation function is used to obtain the attention weight distribution vector ; Finally, the attention weight distribution vectors of all words are normalized by softmax to obtain the attention weight distribution of each word , as follows: in, yes The transpose of is the bias parameter of the multi-head attention module; Use the calculated word attention weight distribution , the continuous prompt word vector input to the encoder Middle i word vector The corresponding hidden layer Do the weighted sum to get the attention context vector at time t : Among them, the attention context vector Contains all The contextual semantic information of all words in the input sequence at any time, Constitute the attention weight distribution of the entire time t; so far, the output attention weight distribution of the T5 pre-training model is obtained and the attention context vector ,in yes and Splicing .
6. A method for tracking dialog states based on prompt learning according to claim 5, characterized in that: In the pointer generation network, the attention context vector output by the T5 pre-trained model is and the decoder hidden state After splicing, passing through two layers of fully connected layers and Softmax activation function, we get the probability distribution of the vocabulary : in, is the training parameter; Then the attention context vector And the vocabulary probability distribution Combined, the calculation generates a pointer , used to control the source of generated words; for Generating pointer of time , is the pointer set at each moment, calculated as follows: in, for The hidden layer input of the decoder at time t, , , All of them are pointers to generate network training parameters. for sigmod function; pointer The value range is ,pointer The larger the value is, the more sources the generated words come from, that is, most of the words come from the vocabulary; pointer The smaller it is, the fewer sources of generated words, that is, most of the words come from the original input sequence; So far, we have obtained the output vocabulary probability distribution of the pointer generation network ,and Generating pointer of time .
7. The method for tracking dialog states based on prompt learning according to claim 6, characterized in that: In the dialogue state tracking model, the attention weight value And the vocabulary probability distribution pass Generating pointer of time Combined, calculate the final generation probability distribution: in, Expressive words Probability distribution in vocabulary The value on Represents the sum of attention weights for each word vector; Generate network words for pointers At the moment The probability value on all words The probability value gets the final probability distribution .
8. The method for tracking dialog states based on prompt learning according to claim 7, characterized in that: In step S2, the negative log-likelihood is taken as the loss function, and the time length of the entire generation is defined as T , the loss function of the pointer generation network for: By training this loss function, we get the parameters of the entire dialogue state tracking model ,in are the post-training parameters of the T5 pre-trained model, It is the parameter after the pointer generates the network training.
9. A method for tracking dialog states based on prompt learning according to any one of claims 1 to 8, characterized in that: Step S3 specifically includes the following steps: S3.
1. For each sentence in the data that needs to track the dialogue state To perform word segmentation, , As a word list, then remove stop words to get the candidate words after filtering each sentence, and finally form a word list of the words in each sentence , ,in r For sentence length: in Refers to the word segmentation operation; Refers to the operation of removing stop words; S3.
2. Use word list The candidate words filtered in each sentence are used to build a candidate word graph using the co-occurrence window , where Vec represents the node set of the candidate word graph, and Edg represents the edge set of the candidate word graph combine, Indicates the number of nodes; Represents the first a nodes, , No. a The weight of the node Indicates the importance of the node in the candidate word graph. Initially, ; For the first a Nodes and c The line connecting the nodes , its weight Indicates a Nodes and c The co-occurrence relationship between nodes. Initially, the weight of each edge ; Then, the weight of each node is iteratively calculated until the result converges: in, is a list of the initial weights of all nodes, Indicates a The initial weight of each node. The closer a word is to the front and the more times it appears, the greater its weight. If a word appears in multiple positions in a conversation, the weights are added together. Indicates a The set of all nodes that have connections to each node; Indicates c A collection of nodes that are not connected; Represents the damping coefficient, the value range is [0,1], Indicates a Nodes Final weight; S3.3, sort the candidate words in each sentence in descending order according to their weights, and take the top as keywords , Sort by weight x Keywords: S3.4, the obtained in step S3.3 Keywords in Dig it out as the final input , input into the dialogue state tracking model PDST trained in S2, and get the final distribution. The maximum value of the distribution is the dialogue slot value Slot With intention Intent : 。 10. The method for tracking dialog states based on prompt learning according to claim 9, characterized in that: In step S3.3, if two keywords are connected in the text, the two keywords are merged into one keyword.
