Task-oriented dialogue model training method and device, equipment and medium

CN119066158BActive Publication Date: 2026-10-09BEIJING CO WHEELS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310629613.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-30
Publication Date
2026-10-09
Estimated Expiration
2043-05-30

AI Technical Summary

Technical Problem

[0003]目前的任务型对话系统模型,对于领域相关的数据,例如领域相关的专有名词,并没有进行针对性的训练,导致任务型对话系统模型对领域相关数据的识别结果不够准确,用户的交互体验较差

Benefits of technology

[0009]本公开提供的技术方案与现有技术相比具有如下优点:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119066158B_ABST
    Figure CN119066158B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a task-oriented dialogue model training method, a dialogue method, an apparatus, a device and a medium. In the present disclosure, a domain-related original text is obtained; domain characters and general characters are filtered from the original text, the domain characters being domain-related characters; based on a preset text mask probability, a first mask probability corresponding to the domain characters and a second mask probability corresponding to the general characters, the characters in the original text are subjected to mask processing to obtain a target mask text, the mask priority of the domain characters being higher than that of the general characters, and the first mask probability being higher than the second mask probability; based on the target mask text, a general language model is trained with the masked characters in the target mask text as a target to obtain a trained first task-oriented dialogue model, which can improve the boundary perception ability of the task-oriented dialogue system model for domain-related data and the accuracy of recognizing domain-related data, and improve the user's interactive experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of natural language processing technology, and in particular to a method, apparatus, device and medium for training a task-oriented dialogue model. Background Technology

[0002] Task-oriented dialogue systems enable interactive conversations with users, helping them achieve their desired goals and holding significant importance in human-computer interaction. These systems achieve dialogue through task-oriented dialogue system models. The training of these models represents a combination of task-oriented dialogue and general model training within the context of the big data era, encompassing multiple domains, tasks, and data types.

[0003] Current task-oriented dialogue system models are not specifically trained for domain-related data, such as domain-specific terms, resulting in inaccurate recognition results and poor user interaction experience. Summary of the Invention

[0004] To address the aforementioned technical issues, this disclosure provides a method, apparatus, device, and medium for training a task-oriented dialogue model.

[0005] The first aspect of this disclosure provides a method for training a task-oriented dialogue model, the method comprising: Retrieve the original text related to the domain; Filter the original text for domain-specific characters and general characters. Domain-specific characters are those related to a particular domain. Based on the preset text mask probability and the first mask probability corresponding to the domain character and the second mask probability corresponding to the general character, the characters in the original text are masked to obtain the target mask text. The mask priority of the domain character is greater than the mask priority of the general character, and the first mask probability is greater than the second mask probability. The goal is to predict the masked characters in the target masked text. The general language model is trained based on the target masked text to obtain the trained first task-oriented dialogue model.

[0006] A second aspect of this disclosure provides a task-oriented dialogue model training apparatus, the apparatus comprising: The first acquisition module is used to acquire the original text related to the domain. The filtering module is used to filter domain characters and general characters in the original text. Domain characters are characters related to a specific domain. The first masking module is used to mask the characters in the original text based on the preset text masking probability, the first masking probability corresponding to the domain character, and the second masking probability corresponding to the general character, to obtain the target masked text. The masking priority of the domain character is greater than that of the general 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 prediction of the masked characters in the target masked text as the target, to obtain a trained first task-oriented dialogue model.

[0007] A third aspect of this disclosure provides a computer device comprising: The system includes a memory and a processor, wherein the memory stores a computer program that, when executed by the processor, enables the task-oriented dialogue model training method described in the first aspect above.

[0008] The fourth aspect of this disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the task-oriented dialogue model training method of the first aspect described above.

[0009] The technical solution provided in this disclosure has the following advantages compared with the prior art: This disclosure involves obtaining domain-related raw text; filtering domain characters and general characters from the raw text, with domain characters being domain-related characters; masking the characters in the raw text based on preset text mask probabilities and the first mask probability corresponding to the domain characters and the second mask probability corresponding to the general characters, to obtain target masked text, where the mask priority of domain characters is greater than that of general characters, and the first mask probability is greater than the second mask probability; using the predicted masked characters in the target masked text as the target, training a general language model based on the target masked text to obtain a trained first task-oriented dialogue model. By adopting a masking strategy that enhances domain characters and training the task-oriented dialogue system model based on domain-related masked text, the boundary perception capability of the task-oriented dialogue system model for domain-related data and the accuracy of identifying domain-related data can be improved, thereby enhancing the user's interactive experience. Attached Figure Description

[0010] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0011] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 This is a flowchart of a task-oriented dialogue model training method provided in an embodiment of this disclosure; Figure 2 This is a flowchart of another task-oriented dialogue model training method provided in this embodiment of the disclosure; Figure 3 This is a flowchart of another task-oriented dialogue model training method provided in this disclosure embodiment; Figure 4 This is a schematic diagram of the structure of a task-oriented dialogue model training device provided in an embodiment of this disclosure; Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this disclosure. Detailed Implementation

[0013] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0014] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.

[0015] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0016] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one OR operation from another, and do not necessarily require or imply any such actual relationship or order between these OR operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0017] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0018] Task-oriented dialogue systems enable interactive conversations with users, helping them achieve their desired goals and holding significant importance in human-computer interaction. These systems achieve dialogue through task-oriented dialogue system models. The training of these models represents a combination of task-oriented dialogue and general model training within the context of the big data era, encompassing multiple domains, tasks, and data types. The difference lies in the fact that task-oriented dialogue system models utilize more business-relevant data. Besides unsupervised data, they may also employ some supervised data for training. Furthermore, in selecting training tasks, in addition to tasks similar to or consistent with downstream tasks, such as response generation, response selection, and slot extraction, they may use tasks designed for masking language models.

[0019] Current task-oriented dialogue system models are not specifically trained for domain-related data, such as domain-specific terms, resulting in inaccurate recognition results and poor user interaction experience.

[0020] To address the shortcomings of related technologies in training task-oriented dialogue models, this disclosure provides a method, apparatus, device, and medium for training task-oriented dialogue models. It employs a masking strategy that enhances domain-specific characters and trains the task-oriented dialogue system model based on domain-related masked text. This can improve the task-oriented dialogue system model's ability to perceive the boundaries of domain-related data and the accuracy of identifying domain-related data, thereby enhancing the user's interactive experience.

[0021] The task-oriented dialogue model training method provided in this disclosure can be executed by a computer device. This device can be understood as any device with processing and computing capabilities. This device may include, but is not limited to, mobile terminals such as smartphones, laptops, personal digital assistants (PDAs), tablet computers (PADs), in-vehicle terminals, and wearable devices, as well as fixed electronic devices such as digital TVs, desktop computers, and smart home devices.

[0022] To better understand the inventive concept of the embodiments of this disclosure, the technical solutions of the embodiments of this disclosure will be described below in conjunction with exemplary embodiments.

[0023] Figure 1 This is a flowchart of a task-oriented dialogue model training method provided in an embodiment of this disclosure, such as... Figure 1 As shown, the task-oriented dialogue model training method provided in this embodiment includes the following steps: Step 110: Obtain the original text related to the domain.

[0024] The field of this disclosure can be understood as a business field or knowledge field, and may include fields such as music, automobiles, and food.

[0025] In this embodiment of the disclosure, the computer device can acquire domain-related raw text, that is, the raw text includes characters related to the domain. For example, the computer device can acquire general text corpora from existing open-source online channels, such as encyclopedias, news websites, forums, social media, etc., and then filter the raw text that includes domain data. For example, a pre-constructed retrieval tool can be used to retrieve domain-related data from the general text corpus as the raw text.

[0026] Step 120: Filter the original text for domain characters and general characters. Domain characters are characters related to a domain.

[0027] In this embodiment of the disclosure, the characters in the original text may include domain-specific characters and general characters. For example, domain-specific characters in the music field may include characters related to song titles, artists, and music albums. General characters may include other characters besides domain-specific characters.

[0028] In this embodiment of the disclosure, after obtaining the original text related to the domain, the computer device can filter domain characters and general characters in the original text.

[0029] In some embodiments, filtering domain characters and general characters in the original text may include steps 1101-1103: Step 1101: Remove duplicate characters from the original text to obtain the target original text.

[0030] In this embodiment of the disclosure, after obtaining the original text related to the domain, the computer device can perform deduplication on the characters in the original text, that is, delete the repeated characters in the original text to obtain the target original text.

[0031] Step 1102: Obtain the first representative character for each field and the second representative character for each general part.

[0032] In this embodiment of the disclosure, the first representative character of the domain can be understood as a character that can represent the domain, that is, a character that appears frequently in the domain, which is a high-frequency character in the domain. The second representative character of the general part can be understood as a character that can represent the general part, that is, a character that appears frequently in the general part, which is a high-frequency character in the general part.

[0033] In this embodiment of the disclosure, the computer device can obtain the first representative character of each domain and the second representative character of each general part from local storage space or a server.

[0034] 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 general characters.

[0035] In this embodiment of the present disclosure, the computer device can select a first preset number of first representative characters as domain characters and a second preset number of second representative characters as general characters from the target original text. Specifically, it can select the first preset number of first representative characters as domain characters of the original text starting from the beginning of the target original text, and it can select the second preset number of second representative characters as general characters of the original text starting from the beginning of the target original text.

[0036] The first preset quantity and the second preset quantity can be the same or different. The first preset quantity and the second preset quantity can be set as needed. For example, the first representative character of the first preset quantity and the second representative character of the second preset quantity should be able to cover more than 95% of the characters in the target original text. No specific limitation is made here.

[0037] Step 130: Based on the preset text mask probability and the first mask probability corresponding to the domain character and the second mask probability corresponding to the general character, perform masking processing on the characters in the original text to obtain the target mask text. The mask priority of the domain character is greater than the mask priority of the general character, and the first mask probability is greater than the second mask probability.

[0038] In this embodiment, masking can be understood as replacing characters with mask markers to achieve the purpose of obscuring or concealing characters. A computer device can perform masking on characters in the original text based on preset text mask probabilities, a first mask probability corresponding to domain characters, and a second mask probability corresponding to general characters, to obtain the target masked text corresponding to the original text. The mask priority of domain characters is higher than that of general characters; that is, domain characters are masked preferentially, and the first mask probability is higher than the second mask probability. The text mask probabilities, the first mask probability corresponding to domain characters, and the second mask probability corresponding to general characters can all be set as needed, and are not specifically limited here.

[0039] In some embodiments, based on preset text mask probabilities and a first mask probability corresponding to domain characters and a second mask probability corresponding to general characters, the characters in the original text are masked to obtain the target masked text, which may include steps 1301-1307: Step 1301: Obtain the total number of characters contained in the original text, as well as the first number of domain characters and the second number of general characters contained in the original text.

[0040] In this embodiment of the disclosure, the computer device can obtain the total number of characters contained in the original text, as well as a first number of domain characters and a second number of general characters contained in the original text.

[0041] Step 1302: Calculate the first product of the preset text mask probability and the total number, and use the first product as the number of target characters in the target mask in the original text.

[0042] In this embodiment of the present disclosure, the computer device can calculate a first product of a preset text mask probability and a total number, and use the first product as the number of target characters in the target mask of the original text.

[0043] 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.

[0044] In this embodiment of the disclosure, the computer device can 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.

[0045] Step 1304: Mask the first number of domain characters to obtain the first masked text.

[0046] In this embodiment of the disclosure, the computer device can perform masking processing on a first number of domain characters to obtain a first masked text.

[0047] Step 1305: determining the first masked text as the target masked text when the first number of characters equals the target number of characters.

[0048] In the embodiments of the present disclosure, when the first number of characters equals the target number of characters, all masked characters are domain characters at this time, and the computer device can determine the first masked text as the target masked text.

[0049] Step 1306: when the first number of characters is less than the target number of characters, calculating a third product of a second masking probability corresponding to general characters and a second number, and taking the third product as a second number of characters of the target mask.

[0050] In the embodiments of the present disclosure, when the first number of characters is less than the target number of characters, the computer device can calculate the third product of the second masking probability corresponding to general characters and the second number, and take the third product as the second number of characters of the target mask.

[0051] Step 1307: performing masking processing on the second number of general characters in the first masked text to obtain a second masked text, and determining the second masked text as the target masked text.

[0052] In the embodiments of the present disclosure, the computer device can perform masking processing on the second number of general characters in the first masked text to obtain a second masked text, and determine the second masked text as the target masked text.

[0053] For example, if the original text A is "I want to listen to Song X by Zhou Xiaomou", wherein "Zhou Xiaomou" and "Song X" are domain characters related to the music field, and the remaining characters are general characters, the total number of characters contained in original text A is 10, the first number of domain characters contained in the text is 6, the second number of general characters contained therein is 4, a preset text masking probability is 30%, a first masking probability corresponding to domain characters is 50%, a second masking probability corresponding to general characters is 25%, then a first product of the preset masking probability and the total number is 3, that is, the target number of characters of the target mask in the text is 3, and 3 characters in the text will be masked; a second product of the first masking probability corresponding to domain characters and the first number is 3, that is, the first number of characters of the target mask is 3, and 3 domain characters in the text will be masked. After masking processing is performed on the first number of domain characters, the obtained first masked text is: <[BOS_never_used_51bce0c785ca2f68081bfa7d91973934]> I want to listen to <extra_ide_0><extra_ide_1>ou's <extra_ide_2>ng X[SEP], the first masked characters are "Z", "h", "S". At this time, the first number of characters equals the target number of characters, that is, all masked characters are domain characters, so the first masked text can be determined as the target masked text.

[0054] Step 140: Using the masked characters in the target masked text as the target, train the general language model based on the target masked text to obtain the trained first task-oriented dialogue model.

[0055] The general language model in this embodiment can be understood as a language model trained on general text. For example, the general language model can be a model built on the T5-Base structure of the Transformer translation model. The structure of this model is mainly an encoder-decoder model structure plus a word embedding layer with positional 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 general language model in this embodiment can also be other language models, which are not specifically limited here.

[0056] In this embodiment of the disclosure, after obtaining the target masked text, the computer device can input the target masked text into a general language model, and train the general language model with the prediction of the masked characters in the target masked text as the target, to obtain a trained first task-oriented dialogue model.

[0057] In some embodiments, with the goal of predicting the 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-oriented dialogue model, which may include steps 1401-1403: Step 1401: Input the target masked text into the general language model, predict the masked characters in the target masked text based on the general language model, and generate the target characters.

[0058] In this embodiment of the disclosure, after obtaining the target masked text, the computer device can input the target masked text into a general language model, and predict the masked characters in the target masked text based on the general language model to generate the target character. In this embodiment of the disclosure, the general language model can adopt an autoregressive decoding method, that is, predicting the current character sequentially from left to right by combining the previously predicted characters.

[0059] Step 1402: Perform vector transformation 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.

[0060] In this embodiment of the disclosure, 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.

[0061] Step 1403: Input the target feature vector and the real feature vector into the preset loss function, and calculate the loss value of the target character relative to the masked character.

[0062] In this embodiment of the disclosure, the computer device can 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 backpropagation of the model.

[0063] The preset loss function can be a general autoregressive loss function, such as the cross-entropy loss function. It calculates the cross-entropy between the predicted target character and the actual masked character, and then calculates the gradient value of the model parameters during backpropagation. The gradient value is used to update the model's weight parameters.

[0064] Step 1404: Based on the target masked text, iteratively train the general language model until the loss value converges to obtain the first task-oriented dialogue model.

[0065] In this embodiment of the disclosure, 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 backward propagation is performed to update the model parameters until the loss value converges and the training stopping condition is met, thus obtaining the first task-oriented dialogue model.

[0066] In this embodiment, the following steps are taken: First, original text relevant to the domain is acquired. Then, domain characters and general characters are filtered from the original text, with domain characters being those relevant to the domain. Based on preset text masking probabilities and the first masking probability corresponding to the domain characters and the second masking probability corresponding to the general characters, the characters in the original text are masked to obtain target masked text. The masking priority of domain characters is greater than that of general characters, and the first masking probability is greater than the second masking probability. Using the predicted masked characters in the target masked text as the target, a general language model is trained based on the target masked text to obtain a trained first task-oriented dialogue model. By employing a masking strategy that enhances domain characters and training the task-oriented dialogue system model based on domain-related masked text, the boundary awareness capability of the task-oriented dialogue system model for domain-related data and the accuracy of identifying domain-related data can be improved, thereby enhancing the user's interactive experience.

[0067] Figure 2 This is a flowchart of a task-oriented dialogue model training method provided in an embodiment of this disclosure, such as... Figure 2 As shown, the task-oriented dialogue model training method provided in this embodiment includes the following steps: Step 210: Obtain general text.

[0068] In the embodiments of the present disclosure, general text may be understood as general natural language text. A computer device may acquire general text from channels such as encyclopedias, news from various news websites, forums, and social media.

[0069] Step 220: Perform masking processing on characters in the general text based on a preset text masking probability, to obtain a general masked text.

[0070] In the embodiments of the present disclosure, a computer device may perform masking processing on characters in the general text based on a preset text masking probability, to obtain a general masked text.

[0071] For example, if the general text B is "I want to listen to the song X by Xiao Mou Zhou", the number of characters contained in 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, 3 characters in the text are target masked characters. After masking processing is performed on the characters in general text B, the obtained general masked text is: "<[BOS_never_used_51bce0c785ca2f68081bfa7d91973934]> I want <extra_ide_0><extra_ide_1>Xiao Mou's <extra_ide_2>ng X[SEP]", and the masked characters are "listen", "Zhou" and "so".

[0072] Step 230: With the goal of predicting the masked characters in the general masked text, train a general language model based on the general masked text, to obtain a trained first language model.

[0073] In the embodiments of the present disclosure, after obtaining the general masked text, a computer device may input the general masked text into a general language model, and train the general language model based on the general masked text with the goal of predicting the masked characters in the general masked text, to obtain a trained first language model.

[0074] Specifically, training the general language model based on the general masked text with the goal of predicting the masked characters in the general masked text to obtain the trained first language model may include steps 2301-2304: Step 2301: Input the general masked text into the general language model, predict the masked characters in the general masked text based on the general language model, and generate predicted characters.

[0075] In the embodiments of the present disclosure, after obtaining the general masked text, a computer device may input the general masked text into the general language model, predict the masked characters in the general masked text based on the general language model, and generate predicted characters. In the embodiments of the present disclosure, the general language model may adopt an autoregressive decoding method, that is, sequentially predict the current character from left to right by combining the previously predicted characters.

[0076] Step 2302: Perform vector transformation on the predicted character and the masked character corresponding to the predicted character to obtain the first feature vector corresponding to the predicted character and the second feature vector corresponding to the masked character.

[0077] In this embodiment of the disclosure, 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 the first feature vector corresponding to the predicted character and the second feature vector corresponding to the masked character.

[0078] Step 2303: Input the first feature vector and the second feature vector into the preset loss function, and calculate the loss value of the predicted character relative to the masked character.

[0079] In this embodiment of the disclosure, the computer device can 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 model's weight parameters through backpropagation. The preset loss function can be a general autoregressive loss function, such as the cross-entropy loss function, which calculates the cross-entropy between the predicted character and the actual masked character, then calculates the gradient value of the model parameters during backpropagation, and uses the gradient value to update the model's weight parameters.

[0080] Step 2304: Based on the universal masked text, iteratively train the universal language model until the loss value converges to obtain the first language model.

[0081] In this embodiment of the disclosure, the computer device can iteratively train a general language model based on a general masked text. That is, for each general masked text, forward propagation is performed to calculate the loss value, and backward propagation is performed to update the model parameters until the loss value converges and the training stopping condition is met, thus obtaining the first language model.

[0082] Step 240: Obtain the original text related to the domain.

[0083] Step 250: Filter the original text for domain characters and general characters. Domain characters are characters related to a domain.

[0084] Step 260: Based on the preset text mask probability and the first mask probability corresponding to the domain character and the second mask probability corresponding to the general character, perform masking processing on the characters in the original text to obtain the target mask text. The mask priority of the domain character is greater than the mask priority of the general character, and the first mask probability is greater than the second mask probability.

[0085] The content of steps 240-260 in this embodiment can be referred to the content of steps 110-130 above, and will not be repeated here.

[0086] Step 270: Using the masked characters in the target masked text as the target, train the first language model based on the target masked text to obtain the trained first task-oriented dialogue model.

[0087] In this embodiment of the present disclosure, the computer device can input the target masked text into the first language model, with the prediction of the masked characters in the target masked text as the target, and train the first language model based on the target masked text to obtain a trained first task-oriented dialogue model.

[0088] Therefore, we can first train a general language model based on general text to improve the accuracy of the general language model in recognizing general text and obtain a first language model. Then, we can use a masking strategy to enhance domain characters and continue to train the first language model based on domain-related masked text to obtain a task-oriented dialogue model. This can further improve the accuracy of the task-oriented dialogue system model in recognizing domain-related data and improve the user's interactive experience.

[0089] Figure 3 This is a flowchart of a task-oriented dialogue model training method provided in an embodiment of this disclosure, such as... Figure 3 As shown, the task-oriented dialogue model training method provided in this embodiment includes the following steps: Step 310: Obtain the original text related to the domain.

[0090] Step 320: Filter the original text for domain characters and general characters. Domain characters are characters related to a domain.

[0091] Step 330: Based on the preset text mask probability and the first mask probability corresponding to the domain character and the second mask probability corresponding to the general character, perform masking processing on the characters in the original text to obtain the target mask text. The mask priority of the domain character is greater than the mask priority of the general character, and the first mask probability is greater than the second mask probability.

[0092] Step 340: Using the masked characters in the target masked text as the target, train the general language model based on the target masked text to obtain the trained first task-oriented dialogue model.

[0093] The content of steps 310-340 in this embodiment can be referred to the content of steps 110-140 above, and will not be repeated here.

[0094] Step 350: Construct task-type sample data related to multiple task types. The task-type sample data includes request text and output text.

[0095] The task type in this embodiment can be understood as the task type corresponding to the data processing of the task-oriented dialogue system, which may include task types such as text classification, reading comprehension, slot extraction, and knowledge question answering.

[0096] In this embodiment of the disclosure, the computer device can construct task-type sample data related to multiple task types to enhance the task-type dialogue model's ability to learn more relevant task data, thereby improving the model's generalization ability and robustness. The task-type sample data may include request text and output text, where the output text can be understood as a response to the request text.

[0097] In some embodiments, the computer device can acquire 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 can be obtained from open-source data websites, publicly available competition data, university research institutions, and other sources.

[0098] In other embodiments, constructing task-type sample data related to multiple task types may include steps 3501-3503: Step 3501: Obtain supervised sample data and real request data related to multiple task types.

[0099] In this embodiment of the disclosure, the computer device can acquire supervised sample data and real query data related to multiple task types. Real query data can be understood as request text in a real context, which is a type of unsupervised data.

[0100] In some embodiments, after obtaining the real request data, the computer device can also extract template information from the real request data to obtain an annotation template; based on the annotation template, the data in the knowledge graph is annotated to obtain the expanded real request data.

[0101] In the embodiments of the present disclosure, a computer device may extract template information from real request data to obtain an annotation template, which can be used for data annotation and implement data expansion. Specifically, for example, when the downstream task is a slot filling task type, one piece of real request data therein is "input: I want to listen to song X by Xiao Mou Zhou; output: [singer] Xiao Mou Zhou [song name] song X". From this piece of data, an input template "I want to listen to [singer]'s [song name]" can be obtained, wherein [singer] is a normalized slot for singer, and [song name] is a normalized slot for song name. This input template can be used as an annotation template. Subsequently, based on the annotation template, data expansion can be performed through a music knowledge graph such as "Xiao Mou Zhou - song Y - album name", and then data in the knowledge graph is annotated based on the annotation template to obtain expanded real request data.

[0102] Step 3502: Predicting a result of the real request data based on a preset semi-supervised algorithm to obtain prediction result data corresponding to the real request data.

[0103] In the embodiments of the present disclosure, a computer device may predict a result of the real request data based on a preset semi-supervised algorithm to obtain prediction result data corresponding to the real request data.

[0104] Specifically, the preset semi-supervised algorithm may include a Self Training algorithm. Firstly, supervised sample data is split into N parts, M (M<N) parts of data are randomly extracted from the N parts of data to form a piece of training data, and a data model is trained. M parts of data are repeatedly extracted from the N parts of data for K times to obtain K pieces of training data. Based on the K pieces of training data, the model is trained K times (the data models used each time can be different, so as to obtain better generalization performance), and K trained data models are obtained. The K data models are used to predict the result of the real request data to obtain K pieces of prediction data, and ensemble learning is performed on the K pieces of prediction data. For example, a simple voting mechanism is adopted, the number of each prediction result in the K pieces of prediction data is counted, and the prediction data corresponding to the prediction result with the largest number is taken as fused data representing the K pieces of prediction data, that is, the prediction result data corresponding to the real request data.

[0105] Step 3503: Constructing task-type sample data based on the real request data and the prediction result data.

[0106] In the embodiments of the present disclosure, a computer device may construct semi-supervised sample data based on the real request data and the prediction result data corresponding to the real request data, as task-type sample data related to a plurality of task types.

[0107] In some other embodiments, the computer device can also acquire dialogue data related to multiple task types, and construct task-type sample data related to multiple task types based on the dialogue data. Specifically, this can be achieved by collecting dialogue-related data such as forum posts, social media discussions, and Renren customer service conversations related to multiple task types, cleaning and filtering the dialogue-related data, and constructing task-type sample data related to multiple task types.

[0108] Step 360: According to the preset prompt template, add prompt information to the request text of the task-type sample data to construct the target request text.

[0109] In this embodiment of the disclosure, 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 the target request text.

[0110] The prompts can be explicit text or learnable tokens, and can include at least one of the following: task type, task content, task knowledge, and task objective. Adding prompts to the request text for task-oriented sample data provides the model with contextual information, essentially telling or guiding the model what task to perform next.

[0111] The preset prompt template can include at least one of [Task Type], [Task Content], [Task Knowledge], and [Task Objective]. [Task Type] refers to the downstream task type, such as text classification, reading comprehension, or slot extraction. [Task Content] can be the original request text. [Task Knowledge] can be optional information; broadly defined, it includes external encyclopedic knowledge, search results, and API responses. [Task Objective] can be a prompt describing what the task requires. For example, the request text for task-type sample data can be constructed as: "[Task Type] Describes the type of task; [Task Content] Request text; [Task Knowledge] Relevant domain knowledge; [Task Objective] Describes the objective to be achieved by this task."

[0112] For example, when the task type is slot extraction, the task sample data has the request text "[CLS] I want to listen to Zhou Xiaomou's song X [SEP]", and the output text "[CLS][Singer] Zhou Xiaomou [Song Name] Song X [SEP]". Based on the preset prompt template, the constructed target request text is: "[CLS][Task Type] Slot Extraction [Task Content] I want to listen to Zhou Xiaomou's song X [Task Objective]". This text has the following slots:<extra_id_0> [SEP], the output text is: "[CLS"<extra_id_0> [Singer] Zhou Xiaomou [Song Title] Song X<extra_id_1> [SEP]”.

[0113] When the task type is a knowledge-based question-and-answer task, the task-type sample data is a request text of: "[CLS] When was Zhou Xiaomou's song X released? 'Song X' is a song sung by Zhou Xiaomou, with lyrics by Fang Moumou, music by Zhou Xiaomou, and arrangement by Zhong Moumou. It is included in Zhou Xiaomou's self-titled album '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 constructed target request text is: "[CLS][Task Type] Knowledge-based Question-and-Answer [Task Content] When was Zhou Xiaomou's song X released? [Task Knowledge] 'Song X' is a song sung by Zhou Xiaomou, with lyrics by Fang Moumou, music by Zhou Xiaomou, and arrangement by Zhong Moumou. It is included in Zhou Xiaomou's self-titled album 'Song X' released on August 3, 2004 [Task Objective] The response to the question based on this knowledge text is..."<extra_id_0> [SEP]”, the output text is: “[CLS]”.<extra_id_0> August 3, 2004<extra_id_1> [SEP]”.

[0114] Step 370: Based on the target request text and the output text, train the first task-oriented dialogue model to obtain the second task-oriented dialogue model.

[0115] In this embodiment of the disclosure, the computer device can train a first task-oriented dialogue model based on the target request text and the output text to obtain a second task-oriented dialogue model.

[0116] Therefore, by adding prompts to the request text of task-related sample data related to multiple task types, the model can be given certain contextual information, that is, to tell or guide the model what task to do next. Then, the task-related sample data can be used to retrain the task-related dialogue model, which can enhance the model's generalization ability and robustness, further improve the model's ability to perceive the boundaries of domain-related data and the accuracy of the model in recognizing domain-related data, and improve the user's interactive experience.

[0117] In some embodiments of this disclosure, after obtaining a trained first task-oriented dialogue model, the computer device can acquire domain-related request text to be processed, input the request text to be processed into the task-oriented dialogue model trained in any of the above embodiments, and process the request text to be processed based on the task-oriented dialogue model to obtain the target response text corresponding to the request text output by the task-oriented dialogue model. This can improve the accuracy of the task-oriented dialogue model in processing domain-related data and enhance the user's interactive experience.

[0118] Figure 4This is a schematic diagram of the structure of a task-oriented dialogue model training device provided in an embodiment of this disclosure. This device can be understood as the aforementioned computer equipment or a functional module within the aforementioned computer equipment. Figure 4 As shown, the task-oriented dialogue model training device 400 may include: The first acquisition module 410 is used to acquire domain-related raw text; The filtering module 420 is used to filter domain characters and general characters in the original text. Domain characters are characters related to a domain. The first masking module 430 is used to mask the characters in the original text based on the preset text masking probability, the first masking probability corresponding to the domain character, and the second masking probability corresponding to the general character, to obtain the target masked text. The masking priority of the domain character is greater than that of the general character, and the first masking probability is greater than that of the second masking probability. The first training module 440 is used to train a general language model based on the target masked text, with the prediction of the masked characters in the target masked text as the target, to obtain a trained first task-oriented dialogue model.

[0119] Optionally, the above-mentioned filtering module 420 includes: The deduplication submodule is used to remove duplicate characters from the original text to obtain the target original text; The first acquisition submodule is used to acquire the first representative character in each field and the second representative character of each common part; The selection submodule is used to select a first preset number of first representative characters as domain characters from the target original text, and to select a second preset number of second representative characters as general characters.

[0120] Optionally, the first mask module 430 mentioned above includes: The second acquisition submodule is used to acquire the total number of characters contained in the original text, as well as the first number of domain characters and the second number of general characters contained in the original text; The first calculation submodule is used to calculate the first product of the preset text mask probability and the total number, and use the first product as the number of target characters in the target mask in the original text. The second calculation submodule is used to 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; The first masking submodule is used to mask the first number of domain characters to obtain the first masked text. The first determination submodule is used to determine the first mask text as the target mask text when the number of first characters is equal to the number of target characters; The third calculation submodule is used to calculate the third product of the second mask probability corresponding to the general character and the second quantity when the number of first characters is less than the number of target characters, and use the third product as the number of second characters of the target mask; The second masking submodule is used to mask the second number of general characters in the first masking text to obtain the second masking text, and then determine the second masking text as the target masking text.

[0121] Optionally, the first training module 440 mentioned above includes: The first prediction submodule is used to input the target masked text into the general language model, predict the masked characters in the target masked text based on the general language model, and generate the target characters. The conversion submodule is used to 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. The fourth calculation submodule is used to input 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; The first training submodule is used to iteratively train the general language model based on the target masked text until the loss value converges, thus obtaining the first task-oriented dialogue model.

[0122] Optionally, the aforementioned task-oriented dialogue model training device 400 includes: The general text acquisition module is used to acquire general text. The second masking module is used to mask characters in general text based on preset text masking probabilities to obtain general masked text. The second training module is used to train the general language model based on the general masked text with the goal of predicting the masked characters in the general masked text, so as to obtain the trained first language model. The first training module 440 mentioned above includes: The second training submodule is used to train the first language model based on the target masked text, with the prediction of the masked characters in the target masked text as the target, to obtain the trained first task-oriented dialogue model.

[0123] Optionally, the aforementioned task-oriented dialogue model training device 400 includes: The first construction module is used to construct task-type sample data related to multiple task types. The task-type sample data includes request text and output text. The second construction module is used to add prompt information to the request text of the task-type sample data according to the preset prompt template, and construct the target request text. The third training module is used to train the first task-oriented dialogue model based on the target request text and the output text, so as to obtain the second task-oriented dialogue model.

[0124] Optionally, the first building module mentioned above includes: The third acquisition submodule is used to acquire supervised sample data and real request data related to multiple task types. The second prediction submodule is used to predict the results of the real request data based on a preset semi-supervised algorithm, and obtain the prediction result data corresponding to the real request data. The construction submodule is used to build task-oriented sample data based on real request data and prediction result data.

[0125] Optionally, the first building module mentioned above includes: The extraction submodule is used to extract template information from the actual request data to obtain labeled templates; The annotation submodule is used to annotate data in the knowledge graph based on annotation templates to obtain expanded real request data.

[0126] Optionally, the above prompts may include at least one of the following: task type, task content, task knowledge, and task objective.

[0127] The task-oriented dialogue model training device provided in this disclosure can implement the methods of any of the above embodiments, and its execution method and beneficial effects are similar, so they will not be described again here.

[0128] This disclosure also provides a computer device, which includes a processor and a memory, wherein the memory stores a computer program. When the computer program is executed by the processor, it can implement the methods of any of the above embodiments. The execution method and beneficial effects are similar, and will not be described again here.

[0129] Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this disclosure, such as... Figure 5 As shown, the computer device 500 may include a processor 510 and a memory 520. The memory 520 stores a computer program 521. When the computer program 521 is executed by the processor 510, it can implement the method provided in any of the above embodiments. Its execution mode and beneficial effects are similar and will not be described again here.

[0130] Of course, for the sake of simplicity, Figure 5 Only some of the components of the computer device 500 relevant to the present invention are shown in this illustration; components such as buses, input / output interfaces, input devices, and output devices are omitted. In addition, the computer device 500 may include any other suitable components depending on the specific application.

[0131] This disclosure provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the methods of any of the above embodiments. The execution method and beneficial effects are similar, and will not be described again here.

[0132] The aforementioned computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0133] The computer program described above can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this disclosure. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer device, partially on the user's device, as a standalone 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.

[0134] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0135] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0136] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily 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 this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for training a task-oriented dialogue model, characterized in that, include: Retrieve the original text related to the domain; Filter the original text for domain-specific characters and general characters, where the domain-specific characters are domain-related characters; Based on the preset text mask probability, the first mask probability corresponding to the domain character, and the second mask probability corresponding to the general character, the characters in the original text are masked to obtain the target mask text. The mask priority of the domain character is greater than that of the general character, and the first mask probability is greater than that of the second mask probability. With the goal of predicting the 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-oriented dialogue model. The method of masking characters in the original text based on preset text mask probabilities, a first mask probability corresponding to the domain character, and a second mask probability corresponding to the general character to obtain target masked text includes: Obtain the total number of characters contained in the original text, as well as the first number of domain characters and the second number of general characters contained in the original text; Calculate the first product of the preset text mask probability and the total number, and use the first product as the number of target characters in the target mask of the original text; Calculate the product of the first mask probability corresponding to the domain character and the first number of characters, and use the second product as the first character number of the target mask; The first number of domain characters are masked to obtain the first masked text; When the number of the first characters is equal to the number of the target characters, the first mask text is determined as the target mask text; When the number of the first character is less than the number of the target character, calculate the third product of the second mask probability corresponding to the general character and the second number, and use the third product as the second character number of the target mask; The second number of common characters in the first mask text are masked to obtain the second mask text, and the second mask text is determined as the target mask text.

2. The method according to claim 1, characterized in that, The step of filtering general characters and domain-specific characters in the original text includes: The original text is deduplicated to obtain the target original text; Retrieve 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 general characters.

3. The method according to claim 1, characterized in that, The step of predicting the masked characters in the target masked text as the objective, and training a general language model based on the target masked text to obtain a trained first task-oriented dialogue model includes: The target masked text is input into a general language model, and the masked characters in the target masked text are predicted based on the general language model to generate the target characters; The target character and the masked character corresponding to the target character are vectorized to obtain the target feature vector corresponding to the target character and the real feature vector corresponding to the masked character. Input 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 masked text, the general language model is iteratively trained until the loss value converges, thus obtaining the first task-oriented dialogue model.

4. The method according to claim 1, characterized in that, Before obtaining the domain-related raw text, the method further includes: Get general text; Based on a preset text masking probability, the characters in the general text are masked to obtain the general masked text; With the goal of predicting the masked characters in the general masked text, a general language model is trained based on the general masked text to obtain a trained first language model; The step of training a general language model based on the target masked text to obtain a trained first task-oriented dialogue model, with the goal of predicting the masked characters in the target masked text, includes: With the goal of predicting the 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-oriented dialogue model.

5. The method according to claim 1, characterized in that, After training a general language model based on the target masked text to obtain a trained first task-oriented dialogue model, the method further includes: Construct task-type sample data related to multiple task types, wherein the task-type sample data includes request text and output text; 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; Based on the target request text and the output text, the first task-oriented dialogue model is trained to obtain the second task-oriented dialogue model.

6. The method according to claim 5, characterized in that, The construction of task-related sample data for multiple task types includes: Obtain supervised sample data and real request data related to multiple task types; The results of the real request data are predicted based on a preset semi-supervised algorithm to obtain the predicted result data corresponding to the real request data. The task-type sample data is constructed based on the real request data and the prediction result data.

7. The method according to claim 6, characterized in that, After obtaining supervised sample data and real request data related to multiple task types, the method further includes: Template information is extracted from the actual request data to obtain labeled templates; Based on the annotation template, the data in the knowledge graph is annotated to obtain expanded real request data.

8. The method according to claim 5, characterized in that, The prompt information includes at least one of the following: task type, task content, task knowledge, and task objective.

9. A task-oriented dialogue model training device, characterized in that, include: The first acquisition module is used to acquire the original text related to the domain. A filtering module is used to filter domain characters and general characters in the original text, wherein the domain characters are domain-related characters; The first masking module is used to mask the characters in the original text based on a preset text masking probability, a first masking probability corresponding to the domain character, and a second masking probability corresponding to the general character, to obtain the target masked text. The masking priority of the domain character is greater than that of the general character, and the first masking probability is greater than that of 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 the masked characters in the target masked text, so as to obtain a trained first task-oriented dialogue model. The first mask module is further configured to obtain the total number of characters contained in the original text, as well as the first number of domain characters and the second number of general characters contained in the original text; Calculate the first product of the preset text mask probability and the total number, and use the first product as the number of target characters in the target mask of the original text; Calculate the product of the first mask probability corresponding to the domain character and the first number of characters, and use the second product as the first character number of the target mask; The first number of domain characters are masked to obtain the first masked text; When the number of the first characters is equal to the number of the target characters, the first mask text is determined as the target mask text; When the number of the first character is less than the number of the target character, calculate the third product of the second mask probability corresponding to the general character and the second number, and use the third product as the second character number of the target mask; The second number of common characters in the first mask text are masked to obtain the second mask text, and the second mask text is determined as the target mask text.

10. A computer device, characterized in that, include: A memory and a processor, wherein the memory stores a computer program that, when executed by the processor, implements the task-oriented dialogue model training method as described in any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the task-oriented dialogue model training method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Text processing method, text processing device, electronic equipment and storage medium

    CN114330238A

  • Text recognition model training method and text recognition method

    CN115019316A