Dialogue detection model training method and apparatus
By pre-training historical dialogue sequences and training with sample sets, a target dialogue detection model is generated, which solves the problems of low accuracy and high resource consumption in existing technologies for dialogue data compliance detection, and achieves efficient and accurate dialogue detection.
Patent Information
- Application Number
- CN202211465242.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-22
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-11-22
AI Technical Summary
Existing technologies rely on manual reading and keyword retrieval for compliance detection of dialogue data, resulting in high human resource costs, low accuracy, high false positive rate, and low prediction accuracy.
By adjusting and processing multiple historical dialogue sequences, historical dialogue samples are generated. These samples are then pre-trained based on the BERT model and trained using a set of positive and negative dialogue samples until a target dialogue detection model that meets the training stopping condition is obtained.
It improves the prediction accuracy of the dialogue detection model, reduces the consumption of human resources, lowers the false recall probability, and enhances the accuracy of detection.
Smart Images

Figure CN115730607B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present specification relates to the technical field of computer technology, and particularly relates to a dialogue detection model training method. The present specification also relates to a dialogue detection model training device, a dialogue sequence detection method, a dialogue sequence detection device, a computing device, and a computer readable storage medium. BACKGROUND
[0002] With the development of Internet technology, online services gradually enter people's learning and life. Online communication mode can generate a large amount of dialogue data. By detecting these dialogue data, it can be determined whether the service provider appears in the process of providing consultation, problem solving and other services. The service mode or service language is not in line with the regulations.
[0003] In the prior art, when detecting the compliance of dialogue data, the method of manually reading dialogue data and keyword retrieval is usually used. However, the manual reading method needs to consume a large amount of human resources, and the accuracy is low. The keyword retrieval method directly detects keywords based on dialogue data, which has great limitations, high false recall probability and low prediction accuracy. Therefore, there is an urgent need for a dialogue detection model training method to solve the above problems. SUMMARY
[0004] Therefore, the embodiments of the present specification provide a dialogue detection model training method. The present specification also relates to a dialogue detection model training device, a dialogue sequence detection method, a dialogue sequence detection device, a computing device, and a computer readable storage medium to solve the technical defects existing in the prior art.
[0005] According to a first aspect of the embodiments of the present specification, a dialogue detection model training method is provided, comprising:
[0006] adjusting a plurality of historical dialogue sequences to obtain historical dialogue samples, and pre-training an initial dialogue detection model based on the historical dialogue samples to obtain an intermediate dialogue detection model;
[0007] The dialogue sample containing the keyword in the historical dialogue sample is regarded as a positive dialogue sample, and is stored in a positive dialogue sample set. Negative dialogue samples are screened from the historical dialogue samples and stored in a negative dialogue sample set;
[0008] extracting a to-be-processed dialogue sample from the negative dialogue sample set and the positive dialogue sample set, and labeling the to-be-processed dialogue sample to obtain a labeled dialogue sample;
[0009] training the intermediate dialogue detection model based on the labeled dialogue sample until a target dialogue detection model satisfying a training stop condition is obtained.
[0010] According to a second aspect of the embodiments of this specification, a dialogue detection model training apparatus is provided, comprising:
[0011] The pre-training module is configured to adjust and process multiple historical dialogue sequences to obtain historical dialogue samples, and pre-train the initial dialogue detection model based on the historical dialogue samples to obtain an intermediate dialogue detection model.
[0012] The storage module is configured to store dialogue samples containing keywords in the historical dialogue samples as positive dialogue samples and store them in a positive dialogue sample set, and to filter negative dialogue samples from the historical dialogue samples and store them in a negative dialogue sample set.
[0013] The extraction module is configured to extract dialogue samples to be processed from the negative dialogue sample set and the positive dialogue sample set, and to perform annotation processing on the dialogue samples to be processed to obtain annotated dialogue samples.
[0014] The training module is configured to train the intermediate dialogue detection model based on the labeled dialogue samples until a target dialogue detection model that meets the training stopping condition is obtained.
[0015] According to a third aspect of the embodiments of this specification, a dialogue sequence detection method is provided, comprising:
[0016] Obtain the dialogue sequence to be detected;
[0017] The dialogue sequence to be detected is adjusted to obtain the dialogue text to be detected.
[0018] The dialogue text to be detected is input into the target dialogue detection model for detection to obtain the detection information of the dialogue sequence to be detected.
[0019] According to a fourth aspect of the embodiments of this specification, a dialogue sequence detection apparatus is provided, comprising:
[0020] The acquisition module is configured to acquire the dialogue sequence to be detected.
[0021] The processing module is configured to adjust the sequence of dialogues to be detected to obtain the text of the dialogues to be detected;
[0022] The detection module is configured to input the dialogue text to be detected into the target dialogue detection model for detection, and obtain the detection information of the dialogue sequence to be detected.
[0023] According to a fifth aspect of the embodiments of this specification, a computing device is provided, comprising:
[0024] Memory and processor;
[0025] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of training the dialogue detection model.
[0026] According to a sixth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions, which, when executed by a processor, implement the steps of the dialogue detection model training method.
[0027] The dialogue detection model training method provided in this specification involves adjusting multiple historical dialogue sequences to obtain historical dialogue samples, and pre-training an initial dialogue detection model based on these historical dialogue samples to obtain an intermediate dialogue detection model. Dialogue samples containing keywords from the historical dialogue samples are designated as positive dialogue samples and stored in a positive dialogue sample set. Negative dialogue samples are then selected from the historical dialogue samples and stored in a negative dialogue sample set. Dialogue samples to be processed are extracted from the negative and positive dialogue sample sets and labeled to obtain labeled dialogue samples. The intermediate dialogue detection model is then trained based on the labeled dialogue samples until a target dialogue detection model that meets the training stopping condition is obtained.
[0028] One embodiment of this specification describes a method where an initial dialogue detection model is pre-trained based on multiple historical dialogue sequences, enabling the model to learn the linguistic features of the statements within the dialogue sequences. An intermediate dialogue detection model is then trained using dialogue samples from both positive and negative dialogue sample sets to obtain a trained target dialogue detection model. This allows for further model training based on pre-trained data, combined with both positive and negative dialogue samples, thereby improving the model's prediction accuracy. Attached Figure Description
[0029] Figure 1 This is a schematic diagram of a sample construction method provided in one embodiment of this specification;
[0030] Figure 2 This is a flowchart of a dialogue detection model training method provided in one embodiment of this specification;
[0031] Figure 3 This is a schematic diagram of a dialogue detection model training method provided in one embodiment of this specification;
[0032] Figure 4 This is a flowchart illustrating a dialogue detection model training method for dialogue quality inspection, provided in one embodiment of this specification.
[0033] Figure 5 This is a schematic diagram of the structure of a dialogue detection model training device provided in one embodiment of this specification;
[0034] Figure 6 This is a flowchart of a dialogue sequence detection method provided in one embodiment of this specification;
[0035] Figure 7 This is a schematic diagram of the structure of a dialogue sequence detection device provided in one embodiment of this specification;
[0036] Figure 8 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0037] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0038] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0039] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0040] First, the terms and concepts used in one or more embodiments of this specification will be explained.
[0041] Pre-trained language model: The language model is trained using a large amount of unlabeled language text to obtain model parameters. The model is initialized based on the model parameters, and then trained on the basis of the existing language model according to the specific task.
[0042] BERT (Bidirectional Encoder Representation from Transformers): A pre-training technique for natural language processing. BERT pre-trains a neural network of stacked Transformers using a large amount of unsupervised data, which is then applied to downstream tasks. Transformers can encode bidirectional information from words, enabling better text understanding.
[0043] Dialogue content quality control: Utilizing natural language processing technology to determine if any inappropriate behavior exists within the dialogue. Key areas of inspection include: inappropriate words, inappropriate actions, and service attitude.
[0044] This specification provides a method for training a dialogue detection model, and also relates to a dialogue detection model training device, a dialogue sequence detection method, a dialogue sequence detection device, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
[0045] With the development of computer technology, online services are becoming increasingly accepted, allowing service providers to communicate with users via voice, text, and other means. Applications of online services include, but are not limited to, buying and selling goods, communication between teachers and students, communication between teachers and parents, consulting services, and rental services. Online services generate a large amount of dialogue data. To ensure service quality, dialogue content can be inspected, that is, natural language processing technology can be used to determine whether there are any prohibited words or behaviors in the dialogue. The main inspection content includes, but is not limited to, prohibited words, prohibited behaviors, and service attitude. In this embodiment, prohibited words include, but are not limited to, uncivilized language and words indicating a poor attitude; prohibited behaviors include, but are not limited to, encouraging students to play games and adding private contact information.
[0046] One embodiment of this specification describes a method where an initial dialogue detection model is pre-trained based on multiple historical dialogue sequences, enabling the model to learn the linguistic features of the statements within the dialogue sequences. An intermediate dialogue detection model is then trained using dialogue samples from both positive and negative dialogue sample sets to obtain a trained target dialogue detection model. This allows for further model training based on pre-trained data, combined with both positive and negative dialogue samples, thereby improving the model's prediction accuracy.
[0047] Figure 1 This is a schematic diagram illustrating the structure of a dialogue detection model training method provided in one embodiment of this specification. In scenarios where teachers communicate with students, parents, or customer service personnel communicate with customers, resulting in dialogue records in the form of audio, video, voice, or text, a large amount of dialogue data in text or audio format is generated. For example... Figure 1As shown, when the dialogue data consists of conversations between teachers and students or parents, the one-on-one or one-to-many dialogues between teachers and students or parents can be considered as a historical dialogue sequence. A historical dialogue sequence can also be all dialogue data generated within a chat group over a period of time. Therefore, dialogues between teachers and multiple parents or students constitute multiple historical dialogue sequences. After obtaining the voice dialogues, they can be converted into text dialogue sequences. Multiple historical dialogue sequences are then processed, including deleting or modifying noisy data and integrating multiple sentences within a single historical dialogue sequence. Noisy data includes, but is not limited to, emoticons, symbols, spaces, empty sentences, short dialogues, and sentences that repeat with a repetition rate reaching a preset threshold. Integration can involve concatenating multiple sentences from a historical dialogue sequence into a single text. The initial dialogue detection model is pre-trained based on the integrated text to obtain an intermediate dialogue detection model, enabling the dialogue detection model to learn the linguistic features of the dialogue sentences in the historical dialogue sequences.
[0048] Positive and negative dialogue samples are generated based on historical dialogue samples. The system matches historical dialogue samples against a pre-defined keyword list to identify at least one positive dialogue sample containing the specified keyword, and stores this positive sample in a positive dialogue sample set. Keywords refer to prohibited words, including but not limited to uncivilized language and offensive expressions. Negative dialogue samples are randomly sampled from historical dialogue samples and stored in a negative dialogue sample set. Alternatively, historical dialogue samples can be filtered to select those without the specified keyword as negative samples. When training the intermediate dialogue detection model, dialogue samples are extracted from both the negative and positive dialogue sample sets as unprocessed samples. These unprocessed samples are then labeled to obtain labeled dialogue samples. The intermediate dialogue detection model is trained based on these labeled samples until a target dialogue detection model that meets the training stopping condition is obtained. This approach allows for retraining the model using both positive and negative dialogue samples after pre-training, improving the model's prediction accuracy.
[0049] Figure 2 The flowchart illustrates a dialogue detection model training method according to an embodiment of this specification, which specifically includes the following steps:
[0050] Step S202: Adjust and process multiple historical dialogue sequences to obtain historical dialogue samples, and pre-train the initial dialogue detection model based on the historical dialogue samples to obtain an intermediate dialogue detection model.
[0051] Specifically, historical dialogue sequences refer to dialogue data in the form of voice, recordings, or text generated between the service provider and the service recipient. Service providers include, but are not limited to, teachers, sellers, merchants, and customer service personnel, while the corresponding service recipients are consumers such as students, parents, and buyers. Historical dialogue sequences can be dialogue data generated from one-on-one communication between the service provider and the service recipient over a period of time, or dialogue data generated from communication between the service provider and multiple service recipients through a communication group.
[0052] The adjustment process refers to data cleaning and preprocessing of the historical dialogue sequence. In this embodiment, data cleaning refers to deleting or modifying noisy data contained in the dialogue sequence. Data preprocessing may involve splicing or integrating sentences contained in the dialogue sequence. Noisy data includes, but is not limited to, emoticons, symbols, spaces, empty sentences, short dialogues, and sentences that appear repeatedly with a repetition rate reaching a preset threshold in the historical dialogue sequence. The initial dialogue detection model refers to the neural network model used for pre-training. In this embodiment, the intermediate dialogue detection model may be an untrained neural network model such as BERT.
[0053] Based on this, when customer service personnel and users have a dialogue and generate dialogue data, the dialogue data of one-on-one communication between customer service personnel and users is regarded as a historical dialogue sequence. Multiple historical dialogue sequences are obtained, and each historical dialogue sequence is adjusted and processed to obtain historical dialogue samples corresponding to multiple historical dialogue sequences. The initial dialogue detection model is pre-trained based on the historical dialogue samples to obtain an intermediate dialogue detection model, which enables the intermediate dialogue detection model to learn the semantic features of dialogue statements in the historical dialogue samples.
[0054] In practical applications, when acquiring multiple historical dialogue sequences, one can use dialogue data generated between multiple customer service personnel and corresponding users within a certain time range as historical dialogue sequences, or one can use dialogue data generated between a single customer service personnel and multiple users as historical dialogue sequences. For example, using a day or a week as the time range, all dialogue data generated between all customer service personnel and multiple users within a day can be acquired and used as multiple historical dialogue sequences; alternatively, dialogue data generated between customer service personnel A and all users within a week can be used as multiple historical dialogue sequences. Adjusting multiple historical dialogue sequences can involve removing noise data such as emoticons and spaces, and replacing links with special symbols to remove noise data from the initial dialogue sequences. Then, the noise-removed dialogue sequences are concatenated according to the order in which the dialogues occurred to obtain historical dialogue samples.
[0055] Furthermore, considering that the generated historical dialogue samples contain a lot of noisy data and that the length of each dialogue utterance in the historical dialogue samples is different, it is necessary to perform denoising and integration processing on the dialogue samples to facilitate subsequent model training. The specific implementation is as follows:
[0056] The noisy data contained in each historical dialogue sequence is deleted or modified to obtain the first historical dialogue sequence for each historical dialogue sequence; each first historical dialogue sequence is integrated to obtain a historical dialogue sample.
[0057] Specifically, in this embodiment, noise data refers to data such as emoticons, symbols, special characters, links, and images in the dialogue data, as well as recurring dialogue content. Different processing methods are used for different types of noise data. Emoticons, symbols, spaces, empty sentences, short dialogues, and sentences that recur and reach a preset threshold in the dialogue sample can be deleted. For links and line breaks, links can be modified to [url], and line breaks can be replaced with spaces. Integration processing refers to the splicing of multiple statements in the dialogue sample, that is, splicing each statement sequentially according to the order of arrangement or generation of statements in the first historical dialogue sequence to form a historical dialogue sample.
[0058] Based on this, after obtaining the historical dialogue sequences, the noisy data contained in each historical dialogue sequence is deleted or modified to obtain the first historical dialogue sequence corresponding to each historical dialogue sequence. Then, each first historical dialogue sequence is integrated according to the time order or arrangement order of the dialogue statements in the historical dialogue sequence to obtain the historical dialogue sample corresponding to each historical dialogue sequence, so as to facilitate subsequent model training based on the historical dialogue sample.
[0059] For example, in a scenario where salespeople communicate with buyers, to ensure service quality and optimize communication methods, quality control is typically performed on the dialogues between them to detect the presence of prohibited words. This can be achieved by training a neural network model to perform quality control on the dialogue data. Before model training, the dialogue data between the salesperson and buyer is acquired, and the dialogue detection model is pre-trained based on this data to learn semantic features. For instance, the dialogue data between the salesperson and buyer might look like this: "Salesperson A: 1. You can click the link below to view the product [flower]; Salesperson A: 2. 'Link' Buyer B: 1. ******; ... Salesperson A: 30. ******; Buyer B: 30. ******". This dialogue data contains noise such as links and emojis (emojis like [flower]). Therefore, the links need to be replaced with [url], the emojis removed, and the dialogue between the salesperson and buyer concatenated in the correct order to form a single text for subsequent model training.
[0060] In summary, data cleaning is achieved by deleting and modifying noisy data in historical dialogue sequences. The cleaned dialogue sequences are then integrated into historical dialogue samples, which facilitates subsequent model training.
[0061] Furthermore, when pre-training the model based on historical dialogue samples, considering that these samples can be dialogue data from multiple domains, a masking method can be used for model training to enable the model to recognize different semantics. The specific implementation is as follows:
[0062] Based on a preset masking ratio, the word units to be processed are determined in the historical dialogue samples; the word units to be processed in the historical dialogue samples are masked according to a preset masking probability to obtain the dialogue samples to be trained; the initial dialogue detection model is pre-trained based on the dialogue samples to be trained to obtain the intermediate dialogue detection model.
[0063] Specifically, the preset mask ratio refers to a ratio pre-set according to the model training requirements, used to select word units to be processed from historical dialogue samples based on the mask ratio; the preset mask probability refers to a pre-set probability value, used to mask the word units to be processed based on the preset mask probability. Correspondingly, masking refers to selecting a certain number of word units corresponding to the mask probability from the word units to be processed, replacing the selected word units with special symbols, and then training the model so that the model learns the semantic features of the dialogue data; the intermediate dialogue detection model refers to the dialogue detection model obtained after pre-training the initial dialogue detection model.
[0064] Based on this, after generating historical dialogue samples, the word units to be processed are randomly selected from the historical dialogue samples according to a preset masking ratio. These word units are then masked according to a preset masking probability. The resulting dialogue data (masked) and the unmasked dialogue data from the historical dialogue samples form the training dialogue samples. The initial dialogue detection model is then pre-trained based on these training dialogue samples to obtain an intermediate dialogue detection model.
[0065] For example, after integrating the dialogue data between salespeople and buyers into a text segment, the initial dialogue detection model is trained based on a preset masking ratio of 15% and a preset masking probability. Given a historical dialogue sample of 1000 characters, 150 characters are selected from this 1000 characters for masking based on the 15% masking ratio. Then, based on a masking ratio of 8:1:1, 80% of the text from these 150 characters is replaced with "[MASK]", 10% is replaced with random characters, and 10% remains unchanged. The random characters include, but are not limited to, characters and symbols. This masking process is applied to the historical dialogue sample to obtain the training dialogue sample, which is then used for model pre-training. Figure 3 As shown in (a), the dialogue data "What did you do today?" is masked to obtain "What did [MASK] do today?", which is then input into the BERT masked language model for prediction. The output predicts "[MASK]" as "you, he, she". During training, the batch size can be set to 2048, the learning rate to 2e-4, the model warm-up to 20,000 steps, and the training to 200,000 steps to obtain the final model. To improve training efficiency, mixed precision techniques can be used during training.
[0066] In summary, by masking historical dialogue samples and pre-training the dialogue detection model based on the masked historical dialogue samples, the dialogue detection model can learn the linguistic characteristics of historical dialogue samples, thereby improving the accuracy of dialogue quality inspection.
[0067] Step S204: Select dialogue samples containing keywords from the historical dialogue samples as positive dialogue samples and store them in the positive dialogue sample set; and filter negative dialogue samples from the historical dialogue samples and store them in the negative dialogue sample set.
[0068] Specifically, after adjusting and processing multiple historical dialogue sequences to obtain historical dialogue samples, and pre-training the initial dialogue detection model based on these samples to obtain an intermediate dialogue detection model, dialogue samples containing keywords from the historical dialogue samples are stored as positive dialogue samples in a positive dialogue sample set. Similarly, negative dialogue samples are selected from the historical dialogue samples and stored in a negative dialogue sample set. This facilitates subsequent model training based on both the positive and negative dialogue sample sets. Keywords refer to prohibited words, including but not limited to uncivilized language and offensive language. Positive dialogue samples are historical dialogue samples containing keywords from multiple historical dialogue samples, while negative dialogue samples are randomly selected historical dialogue samples from multiple historical dialogue samples.
[0069] Based on this, keyword matching is performed on each historical dialogue sample using a pre-built keyword list, and at least two dialogue samples containing the keywords from multiple historical dialogue samples are selected as positive dialogue samples. At least two historical dialogue samples are randomly selected from multiple historical dialogue samples as negative dialogue samples. Positive dialogue samples are stored in a positive dialogue sample set, and negative dialogue samples are stored in a negative dialogue sample set to facilitate subsequent training of the dialogue detection model.
[0070] In practical applications, when selecting negative dialogue samples from multiple historical dialogue samples, random sampling can be performed on these samples. Since the number of dialogue samples containing keywords is relatively small, all negative dialogue samples obtained through random sampling are considered compliant. When performing keyword matching on multiple historical dialogue samples, violations can be identified for specific scenarios. This allows for the expansion of the customer service representative's dialogue data to detect any violations in their conversations with other users.
[0071] Furthermore, considering that the meaning of keywords can differ in different contexts, i.e., there are compliant samples containing keywords, after selecting samples containing keywords from the historical dialogue samples, it is necessary to further segment these samples. The specific implementation is as follows:
[0072] At least two dialogue samples containing keywords in the historical dialogue samples are used as initial dialogue samples; based on the attribute information of the at least two initial dialogue samples, the at least two initial dialogue samples are divided into positive dialogue samples and a first negative dialogue sub-sample; the historical dialogue samples are randomly sampled to obtain a second negative dialogue sub-sample; the first negative dialogue sub-sample and the second negative dialogue sub-sample are used as negative dialogue samples, and the negative dialogue samples are stored in a negative dialogue sample set, and the positive dialogue samples are stored in a positive dialogue sample set.
[0073] Specifically, the initial dialogue sample refers to the sample containing the keyword selected from the historical dialogue samples; attribute information refers to the semantic information of the statements containing the keyword in the initial dialogue sample, as well as the semantic information combined with the context; a positive dialogue sample refers to a dialogue sample in which the initial dialogue sample contains the keyword and the statement containing the keyword is a violation statement. Correspondingly, the first negative dialogue subsample refers to a dialogue sample in which the initial dialogue sample contains the keyword and the statement containing the keyword is a non-violation statement. For example, the statement "Let's play games together" in the initial dialogue sample contains the keyword "play games" and the semantics of this statement are to invite the other party to play games together, so the sample corresponding to this statement is a positive dialogue sample; the statement "Students are not allowed to play games during school hours" in the initial dialogue sample contains the keyword "play games" and the semantics of this statement are that students cannot play games while at school, so the sample corresponding to this statement is a compliant sample, i.e., the first negative dialogue subsample; the second negative dialogue subsample is a dialogue sample obtained by randomly sampling from the historical dialogue samples. Since obtaining a violation sample is a low-probability event, all randomly sampled samples are considered compliant samples.
[0074] Based on this, historical dialogue samples are filtered using a keyword list. At least two dialogue samples containing the keywords are selected as initial dialogue samples. According to the attribute information of each initial dialogue sample, these two initial dialogue samples are divided into positive dialogue samples and a first negative dialogue subsample. Historical dialogue samples are then randomly sampled, and a predetermined number of dialogue samples are selected as the second negative dialogue subsample. The first and second negative dialogue subsamples are then used as negative dialogue samples, and these negative dialogue samples are stored in a negative dialogue sample set. Positive dialogue samples are stored in a positive dialogue sample set. The first negative dialogue subsample is considered a difficult negative sample, the second negative dialogue subsample is considered an easy negative sample, and the positive dialogue samples are considered positive samples.
[0075] It should be noted that, in this embodiment, a positive sample is a sample containing keywords and containing a violation statement. For example, the sample "Please add my private contact information" expresses the meaning of adding the other party's private contact information, so this sample is a violation sample containing keywords. Correspondingly, the sample "We do not allow teachers to provide private contact information" expresses the meaning of refusing to add private contact information, so this sample is a compliant sample containing keywords, i.e., a difficult-to-bear sample. A difficult-to-bear sample can be a sample that does not contain keywords.
[0076] For example, consider the initial dialogue samples: 1. "***You can add my private contact information***" 2. "***Then I'll help you file a complaint against this salesperson***" 3. "***Our policy prohibits adding private contact information***", etc. Samples 1 and 3 both contain the keyword "private contact information", while sample 2 contains the keyword "complaint". Samples 1 and 2 are violation samples containing the keyword, i.e., positive samples, while sample 3 is a compliance sample containing the keyword, i.e., a difficult-to-bear sample. Positive samples are stored in the positive sample set, and difficult-to-bear samples are stored in the negative sample set. Then, through random sampling, easily-bearable samples are randomly selected from all samples and stored in the negative sample set.
[0077] In summary, by dividing historical dialogue samples into positive dialogue samples, first negative dialogue subsamples, and second negative dialogue subsamples, and using these samples for model training and testing, the accuracy of model predictions was improved.
[0078] Furthermore, since historical dialogue samples can be all dialogue data generated between two people within a day or a week, the amount of dialogue data is quite large. If only one dialogue statement in the dialogue data contains a keyword, processing all the dialogue data to generate the initial dialogue sample would result in unnecessary waste of resources. Therefore, the dialogue statement containing the keyword can be used as the central dialogue statement, and the initial dialogue sample can be determined based on the central dialogue statement. The specific implementation is as follows:
[0079] Identify a central dialogue statement containing keywords from the historical dialogue samples; generate an initial dialogue sample containing the central dialogue statement based on the historical dialogue samples.
[0080] Based on this, the central dialogue statement refers to the dialogue statement containing keywords in the historical dialogue sample. When multiple dialogue statements in the historical dialogue sample contain keywords, the dialogue statements containing keywords can be used as the central dialogue statements, and then an initial dialogue sample containing the central dialogue statement can be generated based on the central dialogue statement.
[0081] In practical applications, keyword matching can be performed on historical dialogue samples based on a preset keyword list. Dialogue samples containing keywords can be identified from the historical dialogue samples, and the statement containing the keyword in each dialogue sample can be used as the central dialogue statement. Then, an initial dialogue sample can be generated based on the central dialogue statement. If a historical dialogue sample contains at least two keywords, any statement containing the keyword can be selected as the central dialogue statement.
[0082] In summary, by using dialogue statements containing keywords from historical dialogue samples as central dialogue statements, and then generating initial dialogue samples based on these historical dialogue samples, the model can be trained in conjunction with the context of the central dialogue statements, thereby improving the model's prediction accuracy.
[0083] Furthermore, considering that historical dialogue samples contain a large number of dialogue statements, they cannot be directly used as training samples for the model. Taking into account the impact of semantic features on the model's prediction accuracy, a subset of dialogue statements from historical dialogue samples can be selected as initial dialogue samples. The specific implementation is as follows:
[0084] Select the preceding dialogue text and the following dialogue text corresponding to the central dialogue statement from the historical dialogue samples; combine the preceding dialogue text, the following dialogue text, and the central dialogue statement to obtain the initial dialogue sample.
[0085] Specifically, the preceding dialogue text refers to the dialogue statements in the historical dialogue samples that precede the central dialogue statement in chronological order. The number of statements in the preceding dialogue text can be set according to actual needs. Correspondingly, the following dialogue text refers to the dialogue statements in the historical dialogue samples that follow the central dialogue statement in chronological order. The number of statements in the following dialogue text can be set according to actual needs.
[0086] Based on this, a set number of preceding dialogue statements corresponding to the central dialogue statement and a set number of subsequent dialogue statements are selected from the historical dialogue samples. Within a certain time frame, the set number of preceding dialogue statements constitutes the preceding dialogue text, and the set number of subsequent dialogue statements constitutes the subsequent dialogue text. The preceding dialogue text, the subsequent dialogue text, and the central dialogue statement are then combined to obtain the initial dialogue sample.
[0087] In practical applications, the first 10 sentences and the last 10 sentences corresponding to the central dialogue statement in a dialogue sample can be selected, and the sentences generated within 12 hours can be used as the sentences associated with the central dialogue statement. Then, the initial dialogue sample is composed of the central dialogue statement, the first 10 sentences, and the last 10 sentences.
[0088] Continuing with the previous example, a salesperson communicates with a buyer, generating dialogue data: "Salesperson A: 1.******; Buyer B: 1.******; ... Salesperson A: 30.******; Buyer B: 30.******". Given that Salesperson A's 15th sentence contains the keyword "complaint", we take Salesperson A's 15th sentence as the central statement, and the 10 sentences preceding and following it in the dialogue data as related statements. Therefore, the initial dialogue sample is composed of Salesperson A's 15th sentence, the 10 sentences preceding it, and the 10 sentences following it.
[0089] In summary, by determining the preceding and following dialogue texts corresponding to the central dialogue statement, an initial dialogue sample is formed by the central dialogue statement, the preceding dialogue text, and the following dialogue text, thus obtaining the initial dialogue sample.
[0090] Step S206: Extract the dialogue samples to be processed from the negative dialogue sample set and the positive dialogue sample set, and perform annotation processing on the dialogue samples to be processed to obtain annotated dialogue samples.
[0091] Specifically, after storing the dialogue samples containing keywords from historical dialogue samples as positive dialogue samples in the positive dialogue sample set, and filtering negative dialogue samples from historical dialogue samples and storing them in the negative dialogue sample set, the dialogue samples to be processed can be extracted from the negative dialogue sample set and the positive dialogue sample set. The dialogue samples to be processed are then labeled to obtain labeled dialogue samples, which are used to train the intermediate dialogue detection model based on the labeled dialogue samples. The labeling process refers to the labeling process performed on each statement in the dialogue samples to be processed, that is, assigning a label to each statement in the dialogue samples to be processed, assigning a center label to the statements in the dialogue samples to be processed that contain keywords, and assigning non-center labels to the statements in the dialogue samples to be processed that do not contain keywords. After labeling each statement in the dialogue samples to be processed, the labeled dialogue samples are obtained.
[0092] Based on this, dialogue samples to be processed are extracted from the negative dialogue sample set and the positive dialogue sample set. The dialogue samples to be processed contain sub-samples of positive dialogue to be processed from the positive dialogue sample set and sub-samples of negative dialogue to be processed from the negative dialogue sample set. The dialogue samples to be processed are then labeled, and each dialogue statement contained in the initial dialogue sample is labeled to obtain the target dialogue sample.
[0093] In practical applications, after extracting the dialogue samples to be processed from the negative and positive dialogue sample sets, the above processing method is applied to these samples to create labeled dialogue samples before model training. The labeling process can involve labeling the dialogue statements to be detected in the dialogue samples as 1, and labeling all other statements in the dialogue samples as 0, thus generating labeled dialogue samples.
[0094] Furthermore, considering the large number of statements in the dialogue samples to be processed, it is impossible to determine which statements need to be detected during model training. In this case, the central dialogue statement that needs to be detected, as well as other statements, can be labeled separately. The specific implementation is as follows:
[0095] In the dialogue sample to be processed, identify the central dialogue statement containing keywords and the related dialogue statements that do not contain keywords; assign a first identifier to the central dialogue statement and a second identifier to the related dialogue statements to obtain labeled dialogue samples.
[0096] Specifically, the central dialogue statement refers to the statement in the dialogue sample to be processed that needs to be predicted for violations. That is, it is determined whether the central dialogue statement is a violation statement. Statements in the dialogue sample to be processed other than the central dialogue statement are related statements, which are the preceding and following statements of the central dialogue statement. Accordingly, the central dialogue statement and related dialogue statements are assigned different identifiers. The central dialogue statement is assigned a first identifier, and the related dialogue statements are assigned a second identifier. The first identifier can be a number or a symbol. When the first identifier is 1, the second identifier is 0 or other numbers. This embodiment does not specifically limit the identifiers, as long as they can serve to distinguish between the central dialogue statement and the related dialogue statements.
[0097] Based on this, when annotating the statements in the dialogue sample to be processed, the central dialogue statement containing the keyword is identified in the dialogue sample, and the statements in the dialogue sample other than the central dialogue statement are considered as related dialogue statements. Related dialogue statements can be statements in the dialogue sample that do not contain the keyword. When the dialogue sample to be processed is a positive sample and contains only one keyword, the statement containing the keyword is the central dialogue statement, and the statements that do not contain the keyword are the related dialogue statements. When the dialogue sample to be processed is a negatively sensitive sample, the statement requiring violation detection is the central dialogue statement, and the statements in the dialogue sample other than the central dialogue statement are the related dialogue statements. It should be noted that since negatively sensitive samples are randomly sampled from historical dialogue samples, the statements requiring violation detection may or may not contain the keyword. A first identifier is assigned to the central dialogue statement, and a second identifier is assigned to the related dialogue statements to obtain the annotated dialogue sample.
[0098] Following the previous example, we annotate each statement to obtain the following: Figure 3 The dialogue sample shown in (b) is generated by labeling the central statement containing the keyword as 1 and other statements as 0. The generated dialogue sample is then input into the BERT model for training to obtain the vector representation of each sentence, i.e., the text representation.
[0099] In summary, labeling the dialogue samples to be processed to obtain labeled dialogue samples facilitates subsequent model training based on the processed dialogue samples, thereby improving the model's prediction efficiency and accuracy.
[0100] Step S208: Train the intermediate dialogue detection model based on the labeled dialogue samples until a target dialogue detection model that meets the training stopping condition is obtained.
[0101] Specifically, the process involves extracting dialogue samples to be processed from the negative and positive dialogue sample sets, labeling these samples, and then training the intermediate dialogue detection model based on these labeled samples until a target dialogue detection model is obtained that meets the training stopping criteria. These criteria could include the model completing a preset number of training iterations, the model's prediction accuracy reaching a preset accuracy threshold, or the model's training time reaching a preset time range. The intermediate dialogue detection model can be an untrained neural network model such as BERT. Correspondingly, the target dialogue detection model refers to the trained dialogue detection model, which can be directly used to detect dialogue data.
[0102] Based on this, labeled dialogue samples are input into an intermediate dialogue detection model for training until a target dialogue detection model that meets the training stopping condition is obtained. In practical applications, the dialogue detection model can be a neural network model, including but not limited to the BERT model.
[0103] Furthermore, when inputting labeled dialogue samples into the intermediate dialogue detection model, considering that a model trained with fewer dialogue samples may not achieve the required prediction accuracy, multiple labeled dialogue samples can be used for model training until the training stopping condition is met to obtain the target dialogue detection model. The specific implementation is as follows:
[0104] The sample label of the labeled dialogue sample is determined according to the sample type of the labeled dialogue sample; the labeled dialogue sample is input into the intermediate dialogue detection model for detection to obtain the detection probability of the labeled dialogue sample; the intermediate dialogue detection model is trained based on the sample label, the detection probability and the loss function until the target dialogue detection model that meets the training stopping condition is obtained.
[0105] Specifically, the sample type refers to the category of the labeled dialogue samples, including positive sample type, hard-to-negate sample type, and easy-to-negate sample type. Correspondingly, the sample label is the label corresponding to the sample type. The sample label for a labeled dialogue sample of the positive sample type is "positive sample," the sample label for a labeled dialogue sample of the hard-to-negate sample type is "hard-to-negate sample," and the sample label for a labeled dialogue sample of the easy-to-negate sample type is "easy-to-negate sample." The detection probability refers to the probability of a target dialogue sample violating the rules, obtained by inputting the target dialogue sample into the dialogue detection model for prediction. The loss function is used to train the dialogue detection model. In this embodiment, the loss function can be the cross-entropy loss function or other loss functions; this embodiment does not impose any limitations on this.
[0106] Based on this, the sample labels of the labeled dialogue samples are determined according to the sample type of the labeled dialogue samples. The labeled dialogue samples are then input into the intermediate dialogue detection model for detection to obtain the detection probability of the labeled dialogue samples. The intermediate dialogue detection model is then trained based on the sample labels, detection probabilities, and loss functions until the target dialogue detection model that meets the training stopping condition is obtained. This enables the intermediate dialogue detection model to be trained based on the training set composed of positive and negative sample sets.
[0107] For example, the constructed training dialogue sample is input into the pre-trained BERT model to obtain the vector representation h of each word in the dialogue. ij ∈R L Then, average pooling is used to obtain the vector representation h of each sentence. i =avgpool(h ijThe final text representation hi is taken, and after a linear transformation and a loss function, the probability p(c|h) of the violation of the training dialogue sample is obtained. i ) = sigmoid(Wh i Finally, cross-entropy is used as the loss function to train the model. The formula for the cross-entropy loss function is as follows: Where L represents the loss value; N represents the total number of samples, and P i Let W represent the probability of correct classification, and W be the matrix of parameters to be learned. This embodiment does not impose any restrictions on the type of loss function.
[0108] In summary, the dialogue detection model training method provided in this specification involves adjusting multiple historical dialogue sequences to obtain historical dialogue samples, and pre-training an initial dialogue detection model based on these historical dialogue samples to obtain an intermediate dialogue detection model. Dialogue samples containing keywords from the historical dialogue samples are used as positive dialogue samples and stored in a positive dialogue sample set. Negative dialogue samples are also selected from the historical dialogue samples and stored in a negative dialogue sample set. Dialogue samples to be processed are extracted from both the negative and positive dialogue sample sets and labeled to obtain labeled dialogue samples. The intermediate dialogue detection model is then trained based on the labeled dialogue samples until a target dialogue detection model that meets the training stopping condition is obtained.
[0109] One embodiment of this specification describes a method where an initial dialogue detection model is pre-trained based on multiple historical dialogue sequences, enabling the model to learn the linguistic features of the statements within the dialogue sequences. An intermediate dialogue detection model is then trained using dialogue samples from both positive and negative dialogue sample sets to obtain a trained target dialogue detection model. This allows for further model training based on pre-trained data, combined with both positive and negative dialogue samples, thereby improving the model's prediction accuracy.
[0110] The following is in conjunction with the appendix Figure 4 Taking the dialogue detection model training method provided in this specification as an example in the application of dialogue quality inspection, the dialogue detection model training method will be further explained. Among other things, Figure 4 The present specification provides a flowchart of a dialogue detection model training method for dialogue quality inspection according to an embodiment of this specification, which specifically includes the following steps:
[0111] Step S402: Adjust and process multiple historical dialogue sequences to obtain historical dialogue samples.
[0112] In communication scenarios between teachers and students / parents, online voice, video, or text communication is typically used. This generates a large amount of dialogue data. To ensure communication quality, this data can be quality-checked to identify inappropriate words, violations, and to assess service attitude and response speed, thereby improving service quality. The dialogue data between teachers and parents / students can be compiled into historical dialogue sequences, which can also be dialogues generated within a specific timeframe. The supervision team can then use a keyword list and keyword matching methods to find clues to violations within this large-scale dialogue data.
[0113] The dialogue sequences used for model pre-training undergo denoising processing, including but not limited to data cleaning of symbols, emoticons, images, hyperlinks, spaces, empty sentences, and short sentences (sentences containing only one character or word) to remove noise and obtain high-quality dialogue samples. The cleaned sentences are then concatenated into a text segment according to the person associated with the sentence and the time sequence of its creation. [CLS] is used as the start marker, and [SEP] is used as the sentence segmentation marker and end marker to obtain the initial dialogue sample.
[0114] Step S404: Determine the word unit to be processed in the historical dialogue samples based on the preset mask ratio, and perform mask processing on the word unit to be processed according to the preset mask probability to obtain the dialogue sample to be trained.
[0115] Using the masked language model task, for the input historical dialogue sample, 15% of the characters are randomly selected. These 15% of the characters are replaced with [MASK] with an 80% probability, replaced with a random character with a 10% probability, and left unchanged with a 10% probability.
[0116] Step S406: Pre-train the initial dialogue detection model based on the dialogue samples to be trained to obtain the intermediate dialogue detection model.
[0117] During model training, the batch size can be set to 2048, the learning rate to 2e-4, the warm-up to 20,000 steps, and the training to 200,000 steps, resulting in a pre-trained dialogue detection model. To improve training efficiency, mixed precision techniques can be used during training.
[0118] Step S408: Identify the central dialogue statement containing the keyword in the historical dialogue sample.
[0119] After the dialogue detection model completes pre-training, i.e., training is performed based on positive and negative samples, the supervisory team specifies a keyword list, and keyword matching methods are used to find violation clues in large-scale dialogue data. At least two dialogue samples containing the keywords are used as initial dialogue samples.
[0120] In practical applications, keywords can be used to identify violations in specific scenarios, which can then be expanded to include the teacher's dialogue content. This allows for the retrieval of data on the teacher's conversations with other parents / students to identify any violations, and further uncover violations in other scenarios.
[0121] Step S410: Select the preceding dialogue text and the following dialogue text corresponding to the central dialogue statement from the historical dialogue samples, and combine the preceding dialogue text, the following dialogue text and the central dialogue statement to obtain the initial dialogue sample.
[0122] In this embodiment, keywords can be uncivilized language, overly promising terms, or words that incite users to complain or withdraw from the course. Examples include keywords like "playing games," "withdrawing from the course," "complaint," and "private contact information." The initial dialogue sample containing these keywords is used as the central dialogue statement. Then, from the historical dialogue sample, a set number of preceding and subsequent dialogue texts corresponding to the central dialogue statement are selected. This can be done by selecting the first 10 and last 10 statements of the central dialogue statement, provided they are no more than 12 hours old, to form the initial dialogue sample. If there are fewer than 10 statements within 12 hours, all statements generated within 12 hours can be selected to form the initial dialogue sample.
[0123] Step S412: Based on the attribute information of at least two initial dialogue samples, divide at least two initial dialogue samples into positive dialogue samples and first negative dialogue sub-samples.
[0124] Since statements containing keywords may or may not be in violation of rules, after identifying the initial dialogue sample containing keywords, it is necessary to determine whether the initial dialogue sample contains any violations based on its semantic information. For example, the statement "You can add my private contact information" implies guiding the user to add the teacher's private contact information, thus it is considered a violation, i.e., a positive sample. The statement "We do not allow teachers to add students' private contact information" implies that the teacher refuses to add private contact information, thus it is considered a non-violation, i.e., a difficult sample to handle.
[0125] Step S414: Randomly sample historical dialogue samples to obtain a second negative dialogue sub-sample. Store the first negative dialogue sub-sample and the second negative dialogue sub-sample as negative dialogue samples in the negative dialogue sample set, and store the positive dialogue samples in the positive dialogue sample set.
[0126] We randomly sampled some statements other than keywords from the full dialogue data. Since violations are low-probability events, these statements were considered compliant samples and denoted as easily negative samples. The easily negative samples and the difficult negative samples together formed a negative sample set, which was stored in the existing negative sample set. The positive samples were stored in the positive sample set. Then, the samples in the positive and negative sample sets were divided into training and testing sets, respectively, to facilitate subsequent model training and testing based on the negative and positive sample sets.
[0127] Step S416: Extract the dialogue samples to be processed from the negative dialogue sample set and the positive dialogue sample set, and perform annotation processing on the dialogue samples to be processed to obtain annotated dialogue samples.
[0128] Extract the dialogue samples to be processed from the negative dialogue sample set and the positive dialogue sample set, label the statements in the dialogue samples to be processed, label the statements to be predicted as 1, and label the other statements as 0 to obtain the target dialogue sample.
[0129] Step S418: Train the intermediate dialogue detection model based on the labeled dialogue samples until the target dialogue detection model that meets the training stopping condition is obtained.
[0130] The target dialogue sample is input into the dialogue detection model to obtain the vector representation of each character. Then, average pooling is used to obtain the vector representation of each sentence, resulting in the final text representation. After a linear transformation and activation function, the probability of violation is obtained. The dialogue detection model is trained using the cross-entropy loss function until a target dialogue detection model that meets the training stopping condition is obtained.
[0131] In summary, one embodiment of this specification enables an initial dialogue detection model to learn the linguistic features of statements within the dialogue sequences by pre-training it based on multiple historical dialogue sequences. Then, an intermediate dialogue detection model is trained using dialogue samples from both positive and negative dialogue sample sets to obtain a trained target dialogue detection model. This allows for further model training based on pre-trained data, combined with both positive and negative dialogue samples, thereby improving the model's prediction accuracy.
[0132] Corresponding to the above method embodiments, this specification also provides embodiments of a dialogue detection model training device. Figure 5 A schematic diagram of a dialogue detection model training device according to an embodiment of this specification is shown. Figure 5 As shown, the device includes:
[0133] The pre-training module 502 is configured to adjust and process multiple historical dialogue sequences to obtain historical dialogue samples, and pre-train an initial dialogue detection model based on the historical dialogue samples to obtain an intermediate dialogue detection model.
[0134] The storage module 504 is configured to store dialogue samples containing keywords in the historical dialogue samples as positive dialogue samples and store them in a positive dialogue sample set, and to filter negative dialogue samples from the historical dialogue samples and store them in a negative dialogue sample set.
[0135] The extraction module 506 is configured to extract dialogue samples to be processed from the negative dialogue sample set and the positive dialogue sample set, and to perform annotation processing on the dialogue samples to be processed to obtain annotated dialogue samples.
[0136] Training module 508 is configured to train the intermediate dialogue detection model based on the labeled dialogue samples until a target dialogue detection model that meets the training stopping condition is obtained.
[0137] In an optional embodiment, the pre-training module 502 is further configured to:
[0138] The noisy data contained in each historical dialogue sequence is deleted or modified to obtain the first historical dialogue sequence for each historical dialogue sequence; each first historical dialogue sequence is integrated to obtain a historical dialogue sample.
[0139] In an optional embodiment, the pre-training module 502 is further configured to:
[0140] Based on a preset masking ratio, the word units to be processed are determined in the historical dialogue samples; the word units to be processed in the historical dialogue samples are masked according to a preset masking probability to obtain the dialogue samples to be trained; the initial dialogue detection model is pre-trained based on the dialogue samples to be trained to obtain the intermediate dialogue detection model.
[0141] In an optional embodiment, the generation module 504 is further configured to:
[0142] At least two dialogue samples containing keywords in the historical dialogue samples are used as initial dialogue samples; based on the attribute information of the at least two initial dialogue samples, the at least two initial dialogue samples are divided into positive dialogue samples and a first negative dialogue sub-sample; the historical dialogue samples are randomly sampled to obtain a second negative dialogue sub-sample; the first negative dialogue sub-sample and the second negative dialogue sub-sample are used as negative dialogue samples, and the negative dialogue samples are stored in a negative dialogue sample set, and the positive dialogue samples are stored in a positive dialogue sample set.
[0143] In an optional embodiment, the generation module 504 is further configured to:
[0144] Identify a central dialogue statement containing keywords from the historical dialogue samples; generate an initial dialogue sample containing the central dialogue statement based on the historical dialogue samples.
[0145] In an optional embodiment, the generation module 504 is further configured to:
[0146] Select the preceding dialogue text and the following dialogue text corresponding to the central dialogue statement from the historical dialogue samples; combine the preceding dialogue text, the following dialogue text, and the central dialogue statement to obtain the initial dialogue sample.
[0147] In an optional embodiment, the extraction module 506 is further configured to:
[0148] In the dialogue sample to be processed, identify the central dialogue statement containing keywords and the related dialogue statements that do not contain keywords; assign a first identifier to the central dialogue statement and a second identifier to the related dialogue statements to obtain labeled dialogue samples.
[0149] In an optional embodiment, the training module 508 is further configured to:
[0150] The sample label of the labeled dialogue sample is determined according to the sample type of the labeled dialogue sample; the labeled dialogue sample is input into the intermediate dialogue detection model for detection to obtain the detection probability of the labeled dialogue sample; the intermediate dialogue detection model is trained based on the sample label, the detection probability and the loss function until the target dialogue detection model that meets the training stopping condition is obtained.
[0151] In summary, the dialogue detection model training device provided in this specification adjusts multiple historical dialogue sequences to obtain historical dialogue samples, and pre-trains an initial dialogue detection model based on these historical dialogue samples to obtain an intermediate dialogue detection model. Dialogue samples containing keywords from the historical dialogue samples are used as positive dialogue samples and stored in a positive dialogue sample set. Negative dialogue samples are also selected from the historical dialogue samples and stored in a negative dialogue sample set. Dialogue samples to be processed are extracted from the negative and positive dialogue sample sets and labeled to obtain labeled dialogue samples. The intermediate dialogue detection model is trained based on the labeled dialogue samples until a target dialogue detection model that meets the training stopping condition is obtained.
[0152] One embodiment of this specification describes a method where an initial dialogue detection model is pre-trained based on multiple historical dialogue sequences, enabling the model to learn the linguistic features of the statements within the dialogue sequences. An intermediate dialogue detection model is then trained using dialogue samples from both positive and negative dialogue sample sets to obtain a trained target dialogue detection model. This allows for further model training based on pre-trained data, combined with both positive and negative dialogue samples, thereby improving the model's prediction accuracy.
[0153] The above is an illustrative scheme of a dialogue detection model training device according to this embodiment. It should be noted that the technical solution of this dialogue detection model training device and the technical solution of the dialogue detection model training method described above belong to the same concept. For details not described in detail in the technical solution of the dialogue detection model training device, please refer to the description of the technical solution of the dialogue detection model training method described above.
[0154] Figure 6 A flowchart of a dialogue sequence detection method according to an embodiment of this specification is shown, which specifically includes the following steps:
[0155] Step S602: Obtain the dialogue sequence to be detected;
[0156] Step S604: Adjust the dialogue sequence to be detected to obtain the dialogue text to be detected;
[0157] Step S606: Input the dialogue text to be detected into the target dialogue detection model for detection to obtain the detection information of the dialogue sequence to be detected.
[0158] In practical applications, when detecting violations in dialogue sequences, the process involves acquiring the dialogue sequence to be detected, adjusting it to obtain the dialogue text to be detected. This adjustment includes data cleaning and preprocessing of the dialogue sequence. Data cleaning includes, but is not limited to, removing emoticons, symbols, and empty sentences from the dialogue sequence. Data preprocessing includes, but is not limited to, concatenating sentences within the dialogue sequence. The dialogue text is then input into a target dialogue detection model for detection, obtaining the detection information for the dialogue sequence and thus achieving the detection of violations in the dialogue sequence.
[0159] In summary, by acquiring the dialogue sequence to be detected, adjusting and processing it to obtain the dialogue text, and then inputting the text into the target dialogue detection model for detection, the detection information of the dialogue sequence is obtained. This enables the detection of dialogue quality within the sequence, identifying violations, and improving the efficiency and accuracy of quality detection through the target dialogue detection model.
[0160] Corresponding to the above method embodiments, this specification also provides embodiments of a dialogue sequence detection device. Figure 7 A schematic diagram of a dialogue sequence detection device according to an embodiment of this specification is shown. Figure 7 As shown, the device includes:
[0161] The acquisition module 702 is configured to acquire the dialogue sequence to be detected;
[0162] Processing module 704 is configured to adjust the dialogue sequence to be detected to obtain the dialogue text to be detected;
[0163] The detection module 706 is configured to input the dialogue text to be detected into the target dialogue detection model for detection, and obtain the detection information of the dialogue sequence to be detected.
[0164] In summary, by acquiring the dialogue sequence to be detected, adjusting and processing it to obtain the dialogue text, and then inputting the text into the target dialogue detection model for detection, the detection information of the dialogue sequence is obtained. This enables the detection of dialogue quality within the sequence, identifying violations, and improving the efficiency and accuracy of quality detection through the target dialogue detection model.
[0165] The above is an illustrative scheme of a dialogue detection model training device according to this embodiment. It should be noted that the technical solution of this dialogue detection model training device and the technical solution of the dialogue detection model training method described above belong to the same concept. For details not described in detail in the technical solution of the dialogue detection model training device, please refer to the description of the technical solution of the dialogue detection model training method described above.
[0166] Figure 8 A structural block diagram of a computing device 800 according to an embodiment of this specification is shown. The components of the computing device 800 include, but are not limited to, a memory 810 and a processor 820. The processor 820 is connected to the memory 810 via a bus 830, and a database 850 is used to store data.
[0167] The computing device 800 also includes an access device 840, which enables the computing device 800 to communicate via one or more networks 860. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 840 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0168] In one embodiment of this specification, the above-described components of the computing device 800 and Figure 8 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 8 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0169] The computing device 800 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 800 can also be a mobile or stationary server.
[0170] The processor 820 is used to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the above-described dialogue detection model training method.
[0171] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the dialogue detection model training method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the dialogue detection model training method described above.
[0172] An embodiment of this specification also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the above-described dialogue detection model training method.
[0173] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the technical solution of the dialogue detection model training method described above. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the dialogue detection model training method described above.
[0174] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0175] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0176] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this specification is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this specification. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this specification.
[0177] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0178] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. These embodiments have been selected and specifically described in this specification to better explain the principles and practical applications of this specification, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A method for training a dialogue detection model, characterized in that, include: Multiple historical dialogue sequences are adjusted to obtain historical dialogue samples, and an initial dialogue detection model is pre-trained based on the historical dialogue samples to obtain an intermediate dialogue detection model. Identify the central dialogue statement containing keywords from the historical dialogue sample; In the historical dialogue sample, select the preceding dialogue text and the following dialogue text corresponding to the central dialogue statement, and combine the preceding dialogue text, the following dialogue text and the central dialogue statement to obtain an initial dialogue sample; the preceding dialogue text refers to the dialogue statement in the historical dialogue sample that is arranged in chronological order before the central dialogue statement, and the following dialogue text refers to the dialogue statement in the historical dialogue sample that is arranged in chronological order after the central dialogue statement. Based on the attribute information of at least two initial dialogue samples, divide at least two initial dialogue samples into positive dialogue samples and first negative dialogue sub-samples; The historical dialogue samples are randomly sampled to obtain a second negative dialogue sub-sample. The first negative dialogue sub-sample and the second negative dialogue sub-sample are used as negative dialogue samples. The negative dialogue samples are stored in the negative dialogue sample set, and the positive dialogue samples are stored in the positive dialogue sample set. Extract dialogue samples to be processed from the negative dialogue sample set and the positive dialogue sample set, and perform annotation processing on the dialogue samples to be processed to obtain annotated dialogue samples. The intermediate dialogue detection model is trained based on the labeled dialogue samples until the target dialogue detection model that meets the training stopping condition is obtained.
2. The method according to claim 1, characterized in that, Multiple historical dialogue sequences were adjusted to obtain historical dialogue samples, including: The noisy data contained in each historical dialogue sequence is deleted or modified to obtain the first historical dialogue sequence for each historical dialogue sequence. Each first historical dialogue sequence is integrated to obtain historical dialogue samples.
3. The method according to claim 1, characterized in that, The step of pre-training the initial dialogue detection model based on the historical dialogue samples to obtain an intermediate dialogue detection model includes: The word unit to be processed is determined in the historical dialogue sample based on a preset mask ratio; The unprocessed word units in the historical dialogue samples are masked according to the preset masking probability to obtain the training dialogue samples. The initial dialogue detection model is pre-trained based on the dialogue samples to be trained to obtain an intermediate dialogue detection model.
4. The method according to claim 1, characterized in that, The step of annotating the dialogue sample to be processed to obtain annotated dialogue samples includes: In the dialogue sample to be processed, identify the central dialogue statement containing the keyword and the related dialogue statements that do not contain the keyword; Assign a first identifier to the central dialogue statement and a second identifier to the associated dialogue statements to obtain labeled dialogue samples.
5. The method according to claim 1, characterized in that, The step of training the intermediate dialogue detection model based on the labeled dialogue samples until a target dialogue detection model that meets the training stopping condition includes: The sample labels of the annotated dialogue samples are determined based on the sample type of the annotated dialogue samples; The labeled dialogue samples are input into the intermediate dialogue detection model for detection to obtain the detection probability of the labeled dialogue samples; The intermediate dialogue detection model is trained based on the sample labels, the detection probability, and the loss function until a target dialogue detection model that meets the training stopping condition is obtained.
6. A method for detecting dialogue sequences, characterized in that, include: Obtain the dialogue sequence to be detected; The dialogue sequence to be detected is adjusted to obtain the dialogue text to be detected. The dialogue text to be detected is input into the target dialogue detection model obtained by the method according to any one of claims 1-5 for detection, and the detection information of the dialogue sequence to be detected is obtained.
7. A dialogue detection model training device, characterized in that, include: The pre-training module is configured to adjust and process multiple historical dialogue sequences to obtain historical dialogue samples, and pre-train the initial dialogue detection model based on the historical dialogue samples to obtain an intermediate dialogue detection model. The storage module identifies the central dialogue statement containing keywords from the historical dialogue samples; In the historical dialogue samples, select the preceding dialogue text and the following dialogue text corresponding to the central dialogue statement, and combine the preceding dialogue text, the following dialogue text, and the central dialogue statement to obtain an initial dialogue sample; the preceding dialogue text refers to the dialogue statement in the historical dialogue samples that is arranged in chronological order before the central dialogue statement, and the following dialogue text refers to the dialogue statement in the historical dialogue samples that is arranged in chronological order after the central dialogue statement; based on the attribute information of at least two initial dialogue samples, divide at least two initial dialogue samples into a positive dialogue sample and a first negative dialogue subsample; The historical dialogue samples are randomly sampled to obtain a second negative dialogue sub-sample. The first negative dialogue sub-sample and the second negative dialogue sub-sample are used as negative dialogue samples. The negative dialogue samples are stored in the negative dialogue sample set, and the positive dialogue samples are stored in the positive dialogue sample set. The extraction module is configured to extract dialogue samples to be processed from the negative dialogue sample set and the positive dialogue sample set, and to perform annotation processing on the dialogue samples to be processed to obtain annotated dialogue samples. The training module is configured to train the intermediate dialogue detection model based on the labeled dialogue samples until a target dialogue detection model that meets the training stopping condition is obtained.
8. A computing device, characterized in that, It includes a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the method according to any one of claims 1 to 5 or 6.
9. A computer-readable storage medium storing computer instructions, characterized in that, When executed by the processor, this instruction implements the steps of the method according to any one of claims 1 to 5 or 6.
Citation Information
Patent Citations
Post timeliness discrimination method and device, and storage medium
CN111324711A
Dialogue strategy model training and dialogue method and system
CN113010653A