Task-based dialogue model training method and device, equipment and medium
The task-based dialogue model training method enhances domain-related data recognition by prioritizing domain characters and training on masked text, improving user interaction experience.
Patent Information
- Application Number
- CN202310629613.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-30
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2043-05-30
AI Technical Summary
Current task-based dialogue system models do not conduct targeted training on domain-related data, leading to inaccurate recognition results and poor user interaction experiences.
A task-based dialogue model training method that involves filtering domain and common characters, applying a higher masking priority to domain characters, and training a general language model on masked domain-related text to enhance boundary perception and accuracy.
Improves the task-based dialogue system's ability to recognize domain-related data accurately, enhancing user interaction experience.
Smart Images

Figure CN119066158A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of natural language processing technology, and in particular to a task-based dialogue model training method, device, equipment and medium. Background Art
[0002] Task-based dialogue systems can complete dialogue interactions with users and help users achieve what they want to do. They are of great significance in human-computer interaction. The task-based dialogue system realizes dialogue through the task-based dialogue system model. The training of the task-based dialogue system model is a combination of task-based dialogue and general model training in the context of multiple vertical domains, multiple tasks, and multiple data types in the big data era.
[0003] The current task-based dialogue system models do not conduct targeted training on domain-related data, such as domain-related proper nouns. As a result, the recognition results of the task-based dialogue system models on domain-related data are not accurate enough and the user interaction experience is poor. Summary of the invention
[0004] In order to solve the above technical problems, the present disclosure provides a task-based dialogue model training method, device, equipment and medium.
[0005] A first aspect of the present disclosure provides a task-based dialogue model training method, the method comprising:
[0006] Obtain domain-related original text;
[0007] Filter domain characters and common characters in the original text, where domain characters are characters related to the domain;
[0008] Based on the preset text mask probability and the first mask probability corresponding to the domain characters and the second mask probability corresponding to the universal characters, the characters in the original text are masked to obtain the target masked text, the mask priority of the domain characters is greater than the mask priority of the universal characters, and the first mask probability is greater than the second mask probability;
[0009] With the goal of predicting masked characters in a target masked text, a general language model is trained based on the target masked text to obtain a trained first task-type dialogue model.
[0010] A second aspect of the present disclosure provides a task-based dialogue model training device, the device comprising:
[0011] The first acquisition module is used to acquire original text related to the field;
[0012] A screening module is used to screen domain characters and common characters in the original text, where domain characters are characters related to the domain;
[0013] A first masking module is used to perform masking processing on characters in the original text based on a preset text masking probability and a first masking probability corresponding to the domain characters and a second masking probability corresponding to the universal characters to obtain a target masked text, wherein the masking priority of the domain characters is greater than the masking priority of the universal characters, and the first masking probability is greater than the second masking probability;
[0014] The first training module is used to train a general language model based on the target masked text with the goal of predicting masked characters in the target masked text to obtain a trained first task-based dialogue model.
[0015] A third aspect of the present disclosure provides a computer device, the device comprising:
[0016] A memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the task-based dialogue model training method of the first aspect mentioned above can be implemented.
[0017] A fourth aspect of the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the task-based dialogue model training method of the first aspect can be implemented.
[0018] Compared with the prior art, the technical solution provided by the present invention has the following advantages:
[0019] The present invention obtains original text related to a domain; selects domain characters and common characters in the original text, wherein the domain characters are characters related to the domain; based on a preset text mask probability and a first mask probability corresponding to the domain characters and a second mask probability corresponding to the common characters, masks the characters in the original text to obtain a target mask text, wherein the mask priority of the domain characters is greater than the mask priority of the common characters, and the first mask probability is greater than the second mask probability; with the goal of predicting masked characters in the target mask text, trains a common language model based on the target mask text to obtain a trained first task-based dialogue model, adopts a mask strategy that enhances domain characters, and trains a task-based dialogue system model based on the domain-related mask text, thereby improving the boundary perception capability of the task-based dialogue system model for domain-related data and the accuracy of identifying domain-related data, thereby improving the user's interactive experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0021] 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0022] Figure 1 is a flow chart of a task-based dialogue model training method provided by an embodiment of the present disclosure;
[0023] Figure 2 is a flowchart of another task-based dialogue model training method provided by an embodiment of the present disclosure;
[0024] Figure 3 is a flowchart of another task-based dialogue model training method provided by an embodiment of the present disclosure;
[0025] Figure 4 is a structural diagram of a task-based dialogue model training device provided by an embodiment of the present disclosure;
[0026] Figure 5 It is a structural diagram of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0028] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0029] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0030] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one or operation from another or operation, and do not necessarily require or imply any such actual relationship or order between these or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including a..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0031] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0032] The task-based dialogue system can complete the dialogue interaction with the user and help the user achieve what the user wants to do. It is of great significance in human-computer interaction. The task-based dialogue system realizes the dialogue through the task-based dialogue system model. The training of the task-based dialogue system model is a combination of task-based dialogue and general model training in the context of multi-vertical domains, multi-tasks, and multi-data types in the big data era. The difference from general model training is that the data for training the task-based dialogue system model is more business-related. In addition to unsupervised data, some supervised data may also be used for training. In the selection of training tasks, in addition to using tasks of the masked language model task type, tasks similar or consistent with downstream tasks will also be used, such as reply generation, reply selection, slot extraction, etc.
[0033] The current task-based dialogue system model does not conduct targeted training on domain-related data, such as domain-related proper nouns or terms, resulting in inaccurate recognition results of the task-based dialogue system model for domain-related data and poor user interaction experience.
[0034] In response to the defects of related technologies in the training of task-based dialogue models, the embodiments of the present disclosure provide a task-based dialogue model training method, apparatus, equipment and medium, which adopt a masking strategy for domain character enhancement and train the task-based dialogue system model based on domain-related masked text. This can improve the task-based dialogue system model's ability to perceive the boundaries of domain-related data and the accuracy of identifying domain-related data, thereby improving the user's interactive experience.
[0035] The task-based dialogue model training method provided by the embodiments of the present disclosure can be executed by a computer device, which can be understood as any device with processing and computing capabilities. The device can include but is not limited to mobile terminals such as smart phones, laptops, personal digital assistants (PDAs), tablet computers (PADs), vehicle-mounted terminals, wearable devices, etc., as well as fixed electronic devices such as digital TVs, desktop computers, smart home devices, etc.
[0036] In order to better understand the inventive concept of the embodiments of the present disclosure, the technical solutions of the embodiments of the present disclosure are described below in conjunction with exemplary embodiments.
[0037] Figure 1 is a flowchart of a task-based dialogue model training method provided by an embodiment of the present disclosure, such as Figure 1 As shown, the task-based dialogue model training method provided in this embodiment includes the following steps:
[0038] Step 110: Obtain domain-related original text.
[0039] The field of the embodiments of the present disclosure can be understood as a business field or a knowledge field, and may include fields such as music, automobiles, and food.
[0040] In the disclosed embodiment, the computer device can obtain domain-related original text, that is, the original text includes characters of the domain. For example, the computer device can obtain general text corpus from existing online open source channels, and the acquisition channels can include but are not limited to encyclopedias, news from various news websites, forums, social media and other channels, and then filter the original text including domain data therefrom. For example, the domain-related data can be retrieved as original text in the general text corpus through a pre-constructed searcher.
[0041] Step 120: Filter domain characters and common characters in the original text, where domain characters are characters related to a domain.
[0042] In the embodiment of the present disclosure, the characters in the original text may include domain characters related to the domain and general universal characters. For example, the domain characters in the music domain may include characters related to song names, singers, music albums, etc. Universal characters may include other characters besides domain characters.
[0043] In the disclosed embodiment, after obtaining the original text related to a field, the computer device may filter the original text for field characters and common characters.
[0044] In some embodiments, filtering domain characters and common characters in the original text may include steps 1101-1103:
[0045] Step 1101: De-duplicate characters in the original text to obtain a target original text.
[0046] In the disclosed embodiment, after obtaining the domain-related original text, the computer device may perform deduplication processing on the characters in the original text, that is, delete the repeated characters in the original text to obtain the target original text.
[0047] Step 1102: Obtain the first representative characters of each field and the second representative characters of each common part.
[0048] In the disclosed embodiment, the first representative character of a field can be understood as a character that can represent the field, that is, a character that appears more frequently among the characters of the field, that is, a high-frequency character of the field. The second representative character of the common part can be understood as a character that can represent the common part, that is, a character that appears more frequently among the characters of the common part, that is, a high-frequency character of the common part.
[0049] In the disclosed embodiment, the computer device may obtain the first representative characters in each field and the second representative characters in each common part from a local storage space or a server.
[0050] Step 1103: Select a first preset number of first representative characters from the target original text as domain characters, and select a second preset number of second representative characters as universal characters.
[0051] In the embodiment of the present disclosure, the computer device can select a first preset number of first representative characters from the target original text as domain characters, and select a second preset number of second representative characters as common characters. Specifically, starting from the beginning of the target original text, the first preset number of first representative characters can be selected as domain characters of the original text, and starting from the beginning of the target original text, the second preset number of second representative characters can be selected as common characters of the original text.
[0052] Among them, the first preset number and the second preset number can be the same or different. The first preset number and the second preset number can be set as needed. For example, the first preset number of first representative characters and the second preset number of second representative characters should be able to cover more than 95% of the characters in the target original text. No specific limitation is made here.
[0053] Step 130: Based on the preset text mask probability and the first mask probability corresponding to the domain characters and the second mask probability corresponding to the universal characters, the characters in the original text are masked to obtain the target masked text, the mask priority of the domain characters is greater than the mask priority of the universal characters, and the first mask probability is greater than the second mask probability.
[0054] In the disclosed embodiments, masking can be understood as replacing characters with mask marks to achieve the purpose of shielding or covering characters. The computer device can perform masking on the characters in the original text based on the preset text masking probability and the first masking probability corresponding to the domain characters and the second masking probability corresponding to the universal characters to obtain the target masked text corresponding to the original text. Among them, the masking priority of the domain characters is greater than the masking priority of the universal characters, that is, the domain characters are masked first, and the first masking probability is greater than the second masking probability. The text masking probability, the first masking probability corresponding to the domain characters, and the second masking probability corresponding to the universal characters can all be set as needed, and are not specifically limited here.
[0055] In some embodiments, based on a preset text mask probability and a first mask probability corresponding to a domain character and a second mask probability corresponding to a universal character, masking the characters in the original text to obtain a target masked text may include steps 1301-1307:
[0056] Step 1301: Obtain the total number of characters contained in the original text, as well as the first number of domain characters contained in the original text and the second number of universal characters contained in the original text.
[0057] In the embodiment of the present disclosure, the computer device may obtain the total number of characters included in the original text, as well as the first number of domain characters and the second number of universal characters included in the original text.
[0058] Step 1302: Calculate a first product of a preset mask probability and a total number, and use the first product as the target character number of the target mask in the original text.
[0059] In the embodiment of the present disclosure, the computer device may calculate a first product of a preset mask probability and a total number, and use the first product as the target character number of the target mask in the original text.
[0060] Step 1303: Calculate the second product of the first mask probability corresponding to the domain character and the first quantity, and use the second product as the first character quantity of the target mask.
[0061] In the disclosed embodiment, the computer device may calculate a second product of the first mask probability corresponding to the domain character and the first quantity, and use the second product as the first character quantity of the target mask.
[0062] Step 1304: Mask the domain characters of the first number of characters to obtain a first masked text.
[0063] In the disclosed embodiment, the computer device may perform mask processing on the first number of domain characters to obtain a first masked text.
[0064] Step 1305: When the number of the first characters is equal to the number of target characters, determine the first masked text as the target masked text.
[0065] In the embodiments of the present disclosure, when the number of the first characters is equal to the number of target characters, at this time all the masked characters are domain characters, and the first masked text can be determined as the target masked text.
[0066] Step 1306: When the number of the first characters is less than the number of target characters, calculate the third product of the second masking probability corresponding to the general characters and the second quantity, and use the third product as the second number of characters of the target mask.
[0067] In the embodiments of the present disclosure, when the number of the first characters is less than the number of target characters, calculate the third product of the second masking probability corresponding to the general characters and the second quantity, and use the third product as the second number of characters of the target mask.
[0068] Step 1307: Mask the general characters with the second number of characters in the first masked text to obtain a second masked text, and determine the second masked text as the target masked text.
[0069] In the embodiments of the present disclosure, the computer device can mask the general characters with the second number of characters in the first masked text to obtain a second masked text, and determine the second masked text as the target masked text.
[0070] For example, if the original text A is "I want to listen to the songs of Zhou Xiaomou X", where "Zhou Xiaomou" and "songs X" are domain characters related to the music field, and the rest of the characters are general characters. The total number of characters in the original text A is 10, the first number of domain characters in this text is 6, the second number of general characters is 4, the preset text masking probability is 30%, the first masking probability corresponding to the domain characters is 50%, and the second masking probability corresponding to the general characters is 25%. Then the first product of the preset masking probability and the total quantity is 3, that is, the number of target characters of the target mask in this text is 3, and 3 characters in this text will be masked. The second product of the first masking probability corresponding to the domain characters and the first quantity is 3, that is, the first number of characters of the target mask is 3, and 3 domain characters in this text will be masked. Mask the domain characters with the first number of characters to obtain the first masked text: "[CLS] I want to listen to <extra_ide_0> <extra_ide_1> mou's <extra_ide_2> song X [SEP]". The first masked characters are "Zhou", "Xiao", and "song". At this time, the number of the first characters is equal to the number of target characters, that is, all the masked characters are domain characters, so the first masked text can be determined as the target masked text.
[0071] Step 140 , with the goal of predicting masked characters in the target masked text, a general language model is trained based on the target masked text to obtain a trained first task-based dialogue model.
[0072] The universal language model in the embodiments of the present disclosure can be understood as a language model trained based on universal text. For example, the universal language model can be a model built based on the T5-Base structure of the translation Transformer model. The structure of the model is mainly an encoder-decoder model structure plus a word embedding layer with position information. The encoder consists of 12 encoding layers, the decoder consists of 12 decoding layers, and the hidden layer dimension of the model is 768. The universal language model in the embodiments of the present disclosure can also be other language models, which are not specifically limited here.
[0073] In the disclosed embodiment, after obtaining the target masked text, the computer device can input the target masked text into a general language model, train the general language model with the goal of predicting the masked characters in the target masked text, and obtain a trained first task-type dialogue model.
[0074] In some embodiments, with the goal of predicting masked characters in a target masked text, training a general language model based on the target masked text to obtain a trained first task-based dialogue model may include steps 1401-1403:
[0075] Step 1401: input the target mask text into the general language model, predict the masked characters in the target mask text based on the general language model, and generate target characters.
[0076] In the disclosed embodiment, after obtaining the target mask text, the computer device can input the target mask text into the universal language model, and predict the masked characters in the target mask text based on the universal language model to generate the target characters. In the disclosed embodiment, the universal language model can use an autoregressive decoding method, that is, predicting the current character from left to right by combining previously predicted characters.
[0077] Step 1402: Perform vector conversion on the target character and the masked character corresponding to the target character to obtain a target feature vector corresponding to the target character and a real feature vector corresponding to the masked character.
[0078] In the disclosed embodiment, the masked character corresponding to the target character is the real character corresponding to the target character. The computer device can perform vector conversion on the target character and the masked character corresponding to the target character to obtain the target feature vector corresponding to the target character and the real feature vector corresponding to the masked character.
[0079] Step 1403: Input the target feature vector and the true feature vector into a preset loss function to calculate the loss value of the target character relative to the masked character.
[0080] In the disclosed embodiment, the computer device may input the target feature vector and the real feature vector into a preset loss function, calculate the loss value of the target character relative to the masked character, and update the weight parameters of the model through back propagation of the model.
[0081] Among them, the preset loss function can be a general autoregressive type loss function, such as a cross-entropy loss function (Cross-Entropy Loss), which calculates the cross entropy between the predicted target character and the actual masked character, and then calculates the gradient value of the back propagation of the model parameters, and updates the weight parameters of the model through the gradient value.
[0082] Step 1404: Based on the target mask text, the general language model is iteratively trained until the loss value converges to obtain a first task-based dialogue model.
[0083] In the disclosed embodiment, the computer device can iteratively train the general language model based on the target mask text, that is, for each target mask text, forward propagation is performed to calculate the loss value, and back propagation is performed to update the model parameters until the loss value converges and the training stop condition is met, thereby obtaining the first task-based dialogue model.
[0084] The disclosed embodiment obtains original text related to a domain; selects domain characters and common characters in the original text, wherein the domain characters are characters related to the domain; based on a preset text mask probability and a first mask probability corresponding to the domain characters and a second mask probability corresponding to the common characters, masks the characters in the original text to obtain a target masked text, wherein the masking priority of the domain characters is greater than the masking priority of the common characters, and the first masking probability is greater than the second masking probability; with the goal of predicting masked characters in the target masked text, a common language model is trained based on the target masked text to obtain a trained first task-based dialogue model, and a masking strategy for enhancing domain characters is adopted, and a task-based dialogue system model is trained based on the domain-related masked text, so as to improve the boundary perception capability of the task-based dialogue system model for domain-related data and the accuracy of identifying domain-related data, thereby improving the user's interactive experience.
[0085] Figure 2 is a flowchart of a task-based dialogue model training method provided by an embodiment of the present disclosure, such as Figure 2 As shown, the task-based dialogue model training method provided in this embodiment includes the following steps:
[0086] Step 210: Obtain general text.
[0087] In the embodiments of the present disclosure, general text can be understood as general natural language text. A computer device can obtain general text from channels such as encyclopedias, news on various news websites, forums, social media, etc.
[0088] Step 220: Based on a preset masking probability, perform masking processing on the characters in the general text to obtain a general masked text.
[0089] In the embodiments of the present disclosure, a computer device can perform masking processing on the characters in the general text based on a preset masking probability to obtain a general masked text.
[0090] For example, if the general text B is "I want to listen to the songs of Zhou Xiaomou X", the number of characters included in the general text B is 10, and the preset text masking probability is 30%, then the product of the preset masking probability and the number of characters is 3, that is, the number of target masked characters in this text is 3. Perform masking processing on the characters in the general text B, and the obtained general masked text is: "[CLS] I want <extra_ide_0> <extra_ide_1> Xiaomou's <extra_ide_2> song X [SEP]", and the masked characters are "listen", "Zhou", and "song".
[0091] Step 230: With the goal of predicting the masked characters in the general masked text, train the general language model based on the general masked text to obtain a trained first language model.
[0092] In the embodiments of the present disclosure, after obtaining the general masked text, a computer device can input the general masked text into the general language model, with the goal of predicting the masked characters in the general masked text, and train the general language model based on the general masked text to obtain a trained first language model.
[0093] Specifically, with the goal of predicting the masked characters in the general masked text, training the general language model based on the general masked text to obtain a trained first language model may include steps 2301 - 2304:
[0094] Step 2301: Input the general masked text into the general language model, and predict the masked characters in the general masked text based on the general language model to generate predicted characters.
[0095] In the embodiments of the present disclosure, after obtaining the general masked text, a computer device can input the general masked text into the general language model, and predict the masked characters in the general masked text based on the general language model to generate predicted characters. In the embodiments of the present disclosure, the general language model can adopt an autoregressive decoding method, that is, predict the current character by successively combining the previously predicted characters from left to right.
[0096] Step 2302: Perform vector conversion on the predicted character and the masked character corresponding to the predicted character to obtain a first feature vector corresponding to the predicted character and a second feature vector corresponding to the masked character.
[0097] In the disclosed embodiment, the masked character corresponding to the predicted character is the real character corresponding to the predicted character. The computer device can perform vector conversion on the predicted character and the masked character corresponding to the predicted character to obtain a first feature vector corresponding to the predicted character and a second feature vector corresponding to the masked character.
[0098] Step 2303: Input the first feature vector and the second feature vector into a preset loss function to calculate the loss value of the predicted character relative to the masked character.
[0099] In the disclosed embodiment, the computer device may input the first feature vector and the second feature vector into a preset loss function, calculate the loss value of the predicted character relative to the masked character, and update the weight parameters of the model through the back propagation of the model. The preset loss function may be a general autoregressive type loss function, such as a cross-entropy loss function (Cross-Entropy Loss), by calculating the cross entropy between the predicted character and the real masked character, and then calculating the gradient value of the back propagation of the model parameters, and updating the weight parameters of the model through the gradient value.
[0100] Step 2304: Based on the universal mask text, iteratively train the universal language model until the loss value converges to obtain a first language model.
[0101] In the disclosed embodiment, the computer device may iteratively train the universal language model based on the universal mask text, that is, for each universal mask text, forward propagation is performed to calculate the loss value, and back propagation is performed to update the model parameters until the loss value converges and the training stop condition is met, thereby obtaining the first language model.
[0102] Step 240: Obtain domain-related original text.
[0103] Step 250: Filter domain characters and common characters in the original text, where domain characters are characters related to the domain.
[0104] Step 260: Based on the preset text mask probability and the first mask probability corresponding to the domain characters and the second mask probability corresponding to the universal characters, the characters in the original text are masked to obtain the target masked text, the mask priority of the domain characters is greater than the mask priority of the universal characters, and the first mask probability is greater than the second mask probability.
[0105] The contents of steps 240-260 in the embodiment of the present disclosure can refer to the contents of the above steps 110-130, which will not be repeated here.
[0106] Step 270 , with the goal of predicting masked characters in the target masked text, the first language model is trained based on the target masked text to obtain a trained first task-based dialogue model.
[0107] In the disclosed embodiment, the computer device may input the target masked text into the first language model, with the goal of predicting the masked characters in the target masked text, and train the first language model based on the target masked text to obtain a trained first task-based dialogue model.
[0108] Therefore, we can first train the general language model based on general text to improve the accuracy of the general language model in recognizing general text and obtain the first language model. Then, we can adopt a masking strategy for domain character enhancement and continue to train the first language model based on domain-related masked text to obtain a task-based dialogue model. This can further improve the accuracy of the task-based dialogue system model in recognizing domain-related data and improve the user's interactive experience.
[0109] Figure 3 is a flowchart of a task-based dialogue model training method provided by an embodiment of the present disclosure, such as Figure 3 As shown, the task-based dialogue model training method provided in this embodiment includes the following steps:
[0110] Step 310: Obtain domain-related original text.
[0111] Step 320: Filter domain characters and common characters in the original text, where domain characters are characters related to the domain.
[0112] Step 330: Based on the preset text mask probability and the first mask probability corresponding to the domain characters and the second mask probability corresponding to the universal characters, the characters in the original text are masked to obtain the target masked text, the mask priority of the domain characters is greater than the mask priority of the universal characters, and the first mask probability is greater than the second mask probability.
[0113] Step 340 : With the goal of predicting masked characters in the target masked text, a general language model is trained based on the target masked text to obtain a trained first task-based dialogue model.
[0114] The contents of steps 310-340 in the embodiment of the present disclosure may refer to the contents of the above steps 110-140, which will not be repeated here.
[0115] Step 350: construct task-type sample data related to multiple task types, where the task-type sample data includes request text and output text.
[0116] The task types in the embodiments of the present disclosure can be understood as the task types corresponding to the task-based dialogue system processing data, which may include text classification, reading comprehension, slot extraction, knowledge question and answering and other task types.
[0117] In the disclosed embodiment, the computer device can construct task-type sample data related to multiple task types to enhance the task-type dialogue model to learn more relevant task data and enhance the generalization ability and robustness of the model. The task-type sample data may include request text and output text, and the output text can be understood as the reply text to the request text.
[0118] In some embodiments, the computer device may obtain supervised sample data related to multiple task types, and construct task-type sample data related to multiple task types based on the supervised sample data. Specifically, supervised sample data related to multiple task types may be obtained from open source data websites, competition public data, university research institutions, and other channels.
[0119] In some other embodiments, constructing task-type sample data related to multiple task types may include steps 3501-3503:
[0120] Step 3501: Obtain supervised sample data and real request data related to multiple task types.
[0121] In the disclosed embodiment, the computer device may obtain supervised sample data and real query data related to multiple task types. The real query data may be understood as a request text in a real context, which is a kind of unsupervised data.
[0122] In some embodiments, after obtaining the real request data, the computer device can also extract the template information in the real request data to obtain a labeled template; based on the labeled template, the data in the knowledge graph is labeled to obtain the expanded real request data.
[0123] In the embodiments of the present disclosure, a computer device may extract template information from real request data to obtain an annotation template, and the annotation template can be used for data annotation to achieve data expansion. Specifically, for example, when the downstream task is a slot extraction task type, one piece of real request data is "Input: I want to listen to the song X of Zhou Xiaomou; Output: [Singer] Zhou Xiaomou [Song Name] Song X". From this piece of data, an input template "I want to listen to [Singer]'s [Song Name]" can be obtained, where [Singer] is a normalized slot for a singer and [Song Name] is a normalized slot for a song name. This input template can be used as an annotation template. Subsequently, based on this annotation template, data expansion can be performed through a music knowledge graph such as "Zhou Xiaomou - Song Y - Album Name", and then based on the annotation template, the data in the knowledge graph can be annotated to obtain the expanded real request data.
[0124] Step 3502: Predict the result of the real request data based on a preset semi-supervised algorithm to obtain the predicted result data corresponding to the real request data.
[0125] In the embodiments of the present disclosure, a computer device may predict the result of the real request data based on a preset semi-supervised algorithm to obtain the predicted result data corresponding to the real request data.
[0126] Specifically, the preset semi-supervised algorithm may include the Self Training algorithm. First, split the supervised sample data into N parts, randomly select M (M < N) parts from the N parts of data to form a training data, train a data model, repeat the extraction of M parts of data from the N parts of data K times to obtain K parts of training data, train the model K times based on the K parts of training data (the data models used each time can be inconsistent in order to obtain better generalization), obtain K trained data models, use the K data models to predict the result of the real request data to obtain K parts of predicted data, and perform Ensemble Learning on the K parts of predicted data. For example, adopt a simple voting mechanism, count the number of each prediction result in the K parts of predicted data, and use the predicted data corresponding to the prediction result with the largest number as the fusion data representing the K parts of predicted data, that is, the predicted result data corresponding to the real request data.
[0127] Step 3503: Construct task-based sample data based on the real request data and the predicted result data.
[0128] In the embodiments of the present disclosure, a computer device may construct semi-supervised sample data based on the real request data and the predicted result data corresponding to the real request data as task-based sample data related to multiple task types.
[0129] In some other embodiments, the computer device may also obtain conversation data related to multiple task types, and construct task-type sample data related to multiple task types based on the conversation data. Specifically, conversation-related data such as forum posts, social media discussions, and customer service conversations related to multiple task types may be collected, and the conversation-related data may be cleaned and screened to construct task-type sample data related to multiple task types.
[0130] Step 360: According to the preset prompt template, prompt information is added to the request text of the task-type sample data to construct the target request text.
[0131] In the disclosed embodiment, after constructing task-type sample data related to multiple task types, the computer device can add prompt information to the request text of the task-type sample data according to a preset prompt template to construct a target request text.
[0132] The prompt information can be explicit text or a learnable token. The prompt information can include at least one of the task type, task content, task knowledge, and task goal. Adding prompt information to the request text of task-type sample data can give the model certain context information, that is, tell or guide the model what task to do next.
[0133] The preset prompt template may include at least one of [task type], [task content], [task knowledge], and [task goal]. [Task type] refers to the downstream task type, such as text classification, reading comprehension, slot extraction, etc. [task content] can be the original request text, [task knowledge] can be an optional information, and the broad definition such as external encyclopedia knowledge, search return content, API return content, etc. can all be constructed into task knowledge, and [task goal] can be the prompt content that describes what the task needs to do. For example, the request text of the task-type sample data can be constructed as: "[task type] describes the type of task [task content] request text [task knowledge] related domain knowledge [task goal] describes the goal to be achieved by the task".
[0134] For example, when the task type is a slot extraction task, the task sample data is the request text: "[CLS] I want to listen to Zhou Xiaomou's song X[SEP]", the output text: "[CLS][singer] Zhou Xiaomou [song name] song X[SEP]", based on the preset prompt template, the target request text constructed is: [CLS][task type] slot extraction [task content] I want to listen to Zhou Xiaomou's song X [task target] The slots of this text are<extra_id_0> [SEP], the output text is: "[CLS]<extra_id_0> [Singer] Zhou Xiaomou [Song Name] Song X<extra_id_1> [SEP]”.
[0135] When the task type is a knowledge question-answering task, the task sample data is the request text: "[CLS] When was Zhou Xiaomou's song X released? "Song X" is a song sung by Zhou Xiaomou, written by Fang, composed by Zhou Xiaomou, arranged by Zhong, and included in Zhou Xiaomou's album of the same name "Song X" released on August 3, 2004 [SEP]", and the output text is: "[CLS] August 3, 2004 [SEP]". Based on the preset prompt template, the target request text constructed is: "[CLS] [Task type] Knowledge question-answering [Task content] When was Zhou Xiaomou's song X released [Task knowledge] "Song X" is a song sung by Zhou Xiaomou, written by Fang, composed by Zhou Xiaomou, arranged by Zhong, and included in Zhou Xiaomou's album of the same name "Song X" released on August 3, 2004 [Task goal] The answer to the question based on the knowledge text is<extra_id_0> [SEP]", the output text is: "[CLS]<extra_id_0> August 3, 2004<extra_id_1> [SEP]”.
[0136] Step 370: Based on the target request text and the output text, the first task-based dialogue model is trained to obtain a second task-based dialogue model.
[0137] In the disclosed embodiment, the computer device may train the first task-based dialogue model based on the target request text and the output text to obtain the second task-based dialogue model.
[0138] Therefore, by adding prompt information to the request text of task-type sample data related to multiple task types, the model can be given certain contextual information, that is, telling or guiding the model what task to do next, and then training the task-type dialogue model again with the task-type sample data, the generalization and robustness of the model can be enhanced, and the model's ability to perceive the boundaries of domain-related data and the accuracy of the model in identifying domain-related data can be further improved, thereby improving the user's interactive experience.
[0139] In some embodiments of the present disclosure, after obtaining the trained first task-based dialogue model, the computer device can obtain the domain-related pending request text, input the pending request text into the task-based dialogue model trained in any of the above embodiments, process the pending request text based on the task-based dialogue model, and obtain the target reply text corresponding to the pending request text output by the task-based dialogue model. In this way, the accuracy of the task-based dialogue model's processing results for domain-related data can be improved, and the user's interactive experience can be improved.
[0140] Figure 4Schematic diagram of a task-based dialogue model training device provided by an embodiment of the present disclosure, which can be understood as the above-mentioned computer device or some functional modules in the above-mentioned computer device. Figure 4 As shown, the task-based dialogue model training device 400 may include:
[0141] A first acquisition module 410 is used to acquire original text related to a field;
[0142] A screening module 420 is used to screen domain characters and common characters in the original text, where the domain characters are characters related to the domain;
[0143] The first masking module 430 is used to perform masking processing on characters in the original text based on a preset text masking probability and a first masking probability corresponding to the domain characters and a second masking probability corresponding to the universal characters to obtain a target masked text, wherein the masking priority of the domain characters is greater than the masking priority of the universal characters, and the first masking probability is greater than the second masking probability;
[0144] The first training module 440 is used to train the general language model based on the target masked text with the goal of predicting the masked characters in the target masked text to obtain a trained first task-based dialogue model.
[0145] Optionally, the screening module 420 includes:
[0146] The deduplication submodule is used to perform deduplication processing on characters in the original text to obtain the target original text;
[0147] A first acquisition submodule is used to acquire first representative characters in each field and second representative characters in each common part;
[0148] The selection submodule is used to select a first preset number of first representative characters from the target original text as domain characters, and select a second preset number of second representative characters as common characters.
[0149] Optionally, the first mask module 430 includes:
[0150] A second acquisition submodule is used to acquire the total number of characters contained in the original text, as well as a first number of domain characters contained in the original text and a second number of common characters contained in the original text;
[0151] A first calculation submodule, used to calculate a first product of a preset mask probability and a total number, and use the first product as the target character number of the target mask in the original text;
[0152] A second calculation submodule is used to calculate a second product of the first mask probability corresponding to the domain character and the first quantity, and use the second product as the first character quantity of the target mask;
[0153] A first masking submodule, used for performing masking processing on the field characters of the first character quantity to obtain a first masked text;
[0154] A first determination submodule, configured to determine the first mask text as a target mask text when the first character quantity is equal to the target character quantity;
[0155] A third calculation submodule is used to calculate a third product of the second mask probability corresponding to the universal character and the second number when the first character number is less than the target character number, and use the third product as the second character number of the target mask;
[0156] The second masking submodule is used to perform masking processing on a second number of common characters in the first masking text to obtain a second masking text, and determine the second masking text as the target masking text.
[0157] Optionally, the first training module 440 includes:
[0158] A first prediction submodule, used for inputting the target mask text into the general language model, predicting the masked characters in the target mask text based on the general language model, and generating target characters;
[0159] A conversion submodule is used to perform vector conversion on the target character and the masked character corresponding to the target character to obtain a target feature vector corresponding to the target character and a real feature vector corresponding to the masked character;
[0160] A fourth calculation submodule, used for inputting the target feature vector and the real feature vector into a preset loss function to calculate the loss value of the target character relative to the real character;
[0161] The first training submodule is used to iteratively train the general language model based on the target mask text until the loss value converges to obtain a first task-based dialogue model.
[0162] Optionally, the task-based dialogue model training device 400 includes:
[0163] A general text acquisition module, used to acquire general text;
[0164] A second masking module is used to perform masking processing on characters in the general text based on a preset masking probability to obtain a general masked text;
[0165] A second training module is used to train a general language model based on the general mask text with the goal of predicting masked characters in the general mask text to obtain a trained first language model;
[0166] The first training module 440 includes:
[0167] The second training submodule is used to train the first language model based on the target masked text with the goal of predicting the masked characters in the target masked text to obtain a trained first task-based dialogue model.
[0168] Optionally, the task-based dialogue model training device 400 includes:
[0169] The first construction module is used to construct task-type sample data related to multiple task types, and the task-type sample data includes request text and output text;
[0170] The second construction module is used to add prompt information to the request text of the task-type sample data according to a preset prompt template to construct a target request text;
[0171] The third training module is used to train the first task-based dialogue model based on the target request text and the output text to obtain a second task-based dialogue model.
[0172] Optionally, the first building block includes:
[0173] The third acquisition submodule is used to obtain supervised sample data and real request data related to multiple task types;
[0174] The second prediction submodule is used to predict the result of the real request data based on a preset semi-supervised algorithm to obtain prediction result data corresponding to the real request data;
[0175] The construction submodule is used to construct task-based sample data based on real request data and prediction result data.
[0176] Optionally, the first building block includes:
[0177] The extraction submodule is used to extract the template information in the real request data to obtain the marked template;
[0178] The annotation submodule is used to annotate the data in the knowledge graph based on the annotation template to obtain the expanded real request data.
[0179] Optionally, the prompt information includes at least one of task type, task content, task knowledge, and task objective.
[0180] The task-based dialogue model training device provided in the embodiments of the present disclosure can implement the method of any of the above embodiments, and its execution method and beneficial effects are similar, which will not be repeated here.
[0181] The embodiments of the present disclosure also provide a computer device, which includes a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the method of any of the above embodiments can be implemented, and its execution method and beneficial effects are similar and will not be repeated here.
[0182] Figure 5 is a schematic diagram of the structure of a computer device provided by an embodiment of the present disclosure, such as Figure 5 As shown, the computer device 500 may include a processor 510 and a memory 520, wherein the memory 520 stores a computer program 521, and when the computer program 521 is executed by the processor 510, the method provided by any of the above embodiments can be implemented, and its execution method and beneficial effects are similar, which will not be repeated here.
[0183] Of course, to simplify, Figure 5 Only some of the components related to the present invention in the computer device 500 are shown, and components such as a bus, an input / output interface, an input device, and an output device are omitted. In addition, according to specific application conditions, the computer device 500 may also include any other appropriate components.
[0184] An embodiment of the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method of any of the above embodiments can be implemented. The execution method and beneficial effects are similar and will not be repeated here.
[0185] The above-mentioned computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0186] The computer program may be written in any combination of one or more programming languages to write program codes for performing the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer device, partially on the user's device, as a separate software package, partially on the user's computer device and partially on a remote computer device, or entirely on a remote computer device or server.
[0187] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0188] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0189] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those 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 disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A task-based dialogue model training method, characterized in that: include: Obtain domain-related original text; Screening domain characters and common characters in the original text, wherein the domain characters are domain-related characters; Based on a preset text mask probability and a first mask probability corresponding to the domain character and a second mask probability corresponding to the universal character, masking the characters in the original text to obtain a target masked text, wherein the mask priority of the domain character is greater than the mask priority of the universal character, and the first mask probability is greater than the second mask probability; With the goal of predicting masked characters in the target masked text, a general language model is trained based on the target masked text to obtain a trained first task-based dialogue model.
2. The method according to claim 1, characterized in that The step of screening common characters and domain characters corresponding to a domain in the original text includes: Performing a deduplication process on the characters in the original text to obtain a target original text; Obtaining the first representative character in each field and the second representative character in each common part; A first preset number of first representative characters are selected from the target original text as the domain characters, and a second preset number of second representative characters are selected as the universal characters.
3. The method according to claim 1, characterized in that The step of performing masking on the characters in the original text based on the preset text masking probability and the first masking probability corresponding to the domain character and the second masking probability corresponding to the universal character to obtain the target masked text includes: Acquire the total number of characters contained in the original text, as well as the first number of domain characters contained in the original text and the second number of universal characters contained in the original text; Calculating a first product of the preset mask probability and the total number, and using the first product as the target character number of the target mask in the original text; Calculate a second product of a first mask probability corresponding to the domain character and the first quantity, and use the second product as the first character quantity of the target mask; Masking the first number of field characters to obtain a first masked text; When the first number of characters is equal to the target number of characters, determining the first mask text as the target mask text; When the first number of characters is less than the target number of characters, calculating a third product of the second mask probability corresponding to the universal character and the second number, and using the third product as the second number of characters of the target mask; Masking is performed on the second number of common characters in the first mask text to obtain a second mask text, and the second mask text is determined as the target mask text.
4. The method according to claim 1, characterized in that: The method aims to predict the masked characters in the target masked text, trains a general language model based on the target masked text, and obtains a trained first task-based dialogue model, including: Inputting the target masked text into a universal language model, predicting masked characters in the target masked text based on the universal language model, and generating target characters; Performing vector conversion on the target character and the masked character corresponding to the target character to obtain a target feature vector corresponding to the target character and a real feature vector corresponding to the masked character; Inputting the target feature vector and the real feature vector into a preset loss function to calculate the loss value of the target character relative to the real character; Based on the target mask text, the general language model is iteratively trained until the loss value converges, thereby obtaining the first task-based dialogue model.
5. The method according to claim 1, characterized in that Before obtaining the field-related original text, the method further includes: Get the generic text; Based on a preset mask probability, masking is performed on the characters in the general text to obtain a general masked text; With the goal of predicting masked characters in the universal mask text, a universal language model is trained based on the universal mask text to obtain a trained first language model; The method of training a general language model based on the target masked text with the goal of predicting the masked characters in the target masked text to obtain a trained first task-based dialogue model includes: With the goal of predicting masked characters in the target masked text, a first language model is trained based on the target masked text to obtain a trained first task-based dialogue model.
6. The method according to claim 1, characterized in that After the general language model is trained based on the target masked text with the goal of predicting the masked characters in the target masked text to obtain the trained first task-based dialogue model, the method further includes: Constructing task-type sample data related to multiple task types, wherein the task-type sample data includes a request text and an output text; According to a preset prompt template, prompt information is added to the request text of the task-type sample data to construct a target request text; Based on the target request text and the output text, the first task-based dialogue model is trained to obtain a second task-based dialogue model.
7. The method according to claim 6, characterized in that The step of constructing task-type sample data related to multiple task types includes: Obtain supervised sample data and real request data related to multiple task types; Predicting the result of the real request data based on a preset semi-supervised algorithm to obtain prediction result data corresponding to the real request data; The task-type sample data is constructed based on the actual request data and the prediction result data.
8. The method according to claim 7, characterized in that After obtaining supervised sample data and real request data related to multiple task types, the method further includes: Extracting template information from the real request data to obtain a marked template; Based on the annotation template, the data in the knowledge graph is annotated to obtain the expanded real request data.
9. The method according to claim 6, characterized in that The prompt information includes at least one of task type, task content, task knowledge, and task goal.
10. A task-based dialogue model training device, characterized in that: include: The first acquisition module is used to acquire original text related to the field; A screening module, used for screening domain characters and common characters in the original text, wherein the domain characters are characters related to a domain; A first masking module is used to perform masking processing on characters in the original text based on a preset text masking probability and a first masking probability corresponding to the domain character and a second masking probability corresponding to the universal character to obtain a target masked text, wherein the masking priority of the domain character is greater than the masking priority of the universal character, and the first masking probability is greater than the second masking probability; The first training module is used to train a general language model based on the target masked text with the goal of predicting masked characters in the target masked text to obtain a trained first task-based dialogue model.
11. A computer device, characterized in that: include: A memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the task-based dialogue model training method as described in any one of claims 1 to 9 is implemented.
12. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the task-based dialogue model training method as described in any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Language model training method and prediction method
CN110196894A
Text processing method, text processing device, electronic equipment and storage medium
CN114330238A
Training method and device for pre-training language model
CN114579699A
Text recognition model training method and text recognition method
CN115019316A
Text character changing method and device, electronic equipment and storage medium
CN115576436A
