WO2024067377A1 - Sample generation method and apparatus, and electronic device and storage medium - Google Patents

Sample generation method and apparatus, and electronic device and storage medium Download PDF

Info

Publication number
WO2024067377A1
WO2024067377A1 PCT/CN2023/120564 CN2023120564W WO2024067377A1 WO 2024067377 A1 WO2024067377 A1 WO 2024067377A1 CN 2023120564 W CN2023120564 W CN 2023120564W WO 2024067377 A1 WO2024067377 A1 WO 2024067377A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
intent
data
frequency
low
Prior art date
Application number
PCT/CN2023/120564
Other languages
French (fr)
Chinese (zh)
Inventor
丁隆耀
蒋宁
吴海英
李宽
吕乐宾
Original Assignee
马上消费金融股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 马上消费金融股份有限公司 filed Critical 马上消费金融股份有限公司
Publication of WO2024067377A1 publication Critical patent/WO2024067377A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/216Parsing using statistical methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Definitions

  • the present application relates to the field of artificial intelligence, and in particular to a sample generation method, device, electronic device and storage medium.
  • Robot agents can automatically answer questions raised by customers, saving a lot of human resources and improving communication efficiency.
  • the questions raised by customers are varied and varied. Some questions contain user intentions that appear frequently, which can be called high-frequency intentions; other questions contain user intentions that appear less frequently, which can be called low-frequency intentions.
  • high-frequency intentions since the questions related to high-frequency intentions appear frequently, the high-frequency intention training data used for model training is easy to obtain, and the intention recognition results of the robot agent obtained through model training are more accurate.
  • the present application provides a sample generation method, device, electronic device and storage medium to expand the number of low-frequency intent samples to meet model training requirements, thereby improving the recognition accuracy of low-frequency intent.
  • the present application provides a sample generation method, including: obtaining log data to be processed; the log data includes text and intent recognition results of the text; according to the intent recognition results of the text, performing data screening processing on the log data to obtain low-frequency intent data; inputting the low-frequency intent data and standard text of a preset intent category into a text comparison model for similarity prediction processing to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is constructed based on the low-frequency intent data; and generating a low-frequency intent sample based on the text comparison result and a preset similarity threshold.
  • the present application provides a training method for an intent recognition model, comprising: generating low-frequency intent samples by the sample generation method as described in the first aspect; inputting the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
  • the present application provides an intention recognition method applied to a digital human, comprising: obtaining a text to be recognized input by a user; inputting the text to be recognized into an intention recognition model for intent recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into an initial intention recognition model for iterative training; the low-frequency intention samples are generated by the sample generation method as described above; according to the user intention, obtaining a target text corresponding to the user intention in the digital human system, and displaying the target text.
  • the present application provides a sample generation device, including: a first acquisition unit, used to acquire log data to be processed; the log data includes text and intent recognition results of the text; a screening unit, used to perform data screening processing on the log data according to the intent recognition results of the text, to obtain low-frequency intent data; a prediction unit, used to input the low-frequency intent data and standard text of a preset intent category into a text comparison model for similarity prediction processing, to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is based on the low-frequency intent data Construct; a first generation unit, used to generate a low-frequency intent sample according to the text comparison result and a preset similarity threshold.
  • the present application provides a training device for an intent recognition model, comprising: a second generation unit, used to generate low-frequency intent samples through the sample generation method as described in the first aspect; a training unit, used to input the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
  • the present application provides an intention recognition device applied to a digital human, comprising: a second acquisition unit, used to acquire a text to be recognized input by a user; a recognition unit, used to input the text to be recognized into an intention recognition model for intention recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into an initial intention recognition model for iterative training; the low-frequency intention samples are generated by the above-mentioned sample generation method; a display unit, used to obtain a target text corresponding to the user intention in the system of the digital human according to the user intention, and display the target text.
  • the present application provides an electronic device, comprising: a processor; and a memory configured to store computer-executable instructions, which, when executed, cause the processor to execute a sample generation method as described above, or a training method for an intent recognition model as described above, or a method for intent recognition applied to a digital human as described above.
  • the present application provides a computer-readable storage medium for storing computer-executable instructions, which, when executed by a processor, implement the sample generation method as described in the first aspect, or the training method of the intent recognition model as described above, or the intent recognition method applied to a digital human as described above.
  • FIG1 is a processing flow chart of a sample generation method provided in an embodiment of the present application.
  • FIG2 is a processing flow chart of another sample generation method provided in an embodiment of the present application.
  • FIG3 is a schematic diagram of a training method of a text comparison model provided in an embodiment of the present application.
  • FIG4 is a business flow chart of a sample generation method provided in an embodiment of the present application.
  • FIG5 is a processing flow chart of a training method for an intent recognition model provided in an embodiment of the present application.
  • FIG6 is a processing flow chart of a method for identifying intentions of a digital human provided in an embodiment of the present application.
  • FIG7 is a schematic diagram of a sample generation device provided in an embodiment of the present application.
  • FIG8 is a schematic diagram of a training device for an intent recognition model provided in an embodiment of the present application.
  • FIG9 is a schematic diagram of an intention recognition device for a digital human provided in an embodiment of the present application.
  • FIG. 10 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
  • the agent can be a customer service representative or any other position or person who can respond to text or voice.
  • an embodiment of the present application provides a sample generation method.
  • the sample generation method proposed in this application can be executed by an electronic device, specifically by a processor in the electronic device.
  • the electronic device mentioned here can be a terminal device, such as a smart phone, a tablet computer, a desktop computer, an intelligent voice interaction device, a wearable device, a robot, and a vehicle terminal, etc.; or, the electronic device can also be a server, such as an independent physical server, a server cluster composed of multiple servers, or a cloud server capable of cloud computing.
  • FIG. 1 a processing flow chart of a sample generation method provided in an embodiment of the present application is shown.
  • the sample generation method provided in an embodiment of the present application may specifically include the following steps:
  • Step S102 obtaining log data to be processed; the log data includes text and intent recognition results of the text.
  • Log data may be historical data related to the target business recorded during the operation of the target business.
  • the text may be a natural language text for which intent recognition is required.
  • the text may be text input by a user, text obtained by voice conversion, or text obtained by other means. This specification does not impose any special restrictions on the method of obtaining the text.
  • the text may be a question text asked by the customer to the robot, for example: How do I check the bill?
  • the intent recognition result of the text may be the intent recognition result obtained by the robot after performing intent recognition on the above question text. For example, the intent recognition result of "How do I check the bill?" is "Inquire about the bill query method.”
  • Acquiring the log data to be processed may be acquiring the conversation data in the log data to be processed.
  • the conversation data may include the text of the question raised by the customer and the text of the robot's answer to the customer.
  • the robot may be pre-configured with a correspondence between the intent recognition result and the answer text. Based on the correspondence between the intent recognition result and the answer text and the robot's answer text to the customer, the robot may query the Then, the question text can be determined as the text in the log data, and the intention recognition result of the question text can be determined as the intention recognition result of the text in the log data.
  • obtaining the log data to be processed includes: obtaining conversation data in the log data to be processed; the conversation data includes the question text raised by the customer and the robot's response text to the customer; according to the correspondence between the response text and the pre-configured intent recognition result and the response text, querying to obtain the intent recognition result of the question text; determining the question text as the text in the log data, and determining the intent recognition result of the question text as the intent recognition result of the text in the log data.
  • the log data in the agent system is the log text of the interaction between the customer and the agent robot generated in the actual production scenario.
  • the amount of log data generated by the agent system is usually large and comes from different sources.
  • the acquired log data can only include the customer's chat data, excluding the recommended questions, frequently asked questions (FAQ), multi-round engine data, and the remaining data is single-round conversation data, for example: the customer asked: "How to repay in advance", the robot answered "XXX”. Because the robot's answer is bound to the identified intent. So the final log data format is shown in Table 1. Table 1 shows part of the log data.
  • the log data may include multiple records. After obtaining the log data, duplicate data in the log data may be removed to reduce redundancy and improve data processing efficiency. Duplicate data may be multiple records of log data with completely identical customer text.
  • the log data includes:
  • record 1 and record 2 can be determined to be duplicate data, and one of record 1 and record 2 can be deleted.
  • Step S104 based on the intent recognition result of the text, perform data screening processing on the log data to obtain low-frequency intent data.
  • the intent recognition result of the text is a preset high-frequency intent. If so, the text and the intent recognition result of the text are deleted from the log data; if not, the text and the intent recognition result of the text are retained as low-frequency intent data.
  • the log data is screened and processed to obtain low-frequency intention data, including: according to the intention recognition result of the text, determining whether the intention recognition result of the text is a preset high-frequency intention; if the intention recognition result of the text is a preset high-frequency intention, deleting the text and the intention recognition result of the text from the log data; if the intention recognition result of the text is not the preset high-frequency intention, treating the text and the intention recognition result of the text as low-frequency intention data.
  • the log data is screened to obtain low-frequency intent data, including: inputting the log data into a high-frequency intent classification model to obtain first log data and the confidence of the intent classification result of the first log data; the intent classification result of the first log data is a preset high-frequency intent; the high-frequency intent classification model is used to perform intent classification on the log data based on the intent recognition result of the text in the log data; based on the first log data and the confidence of the intent classification result of the first log data, the log data is screened to obtain low-frequency intent data.
  • the high-frequency intent classification model may include a pre-trained language model, a multi-layer perceptron, and a normalized exponential function, i.e., a Softmax function, which are connected in sequence.
  • the output of the pre-trained language model is the input of the multi-layer perceptron; and the output of the multi-layer perceptron is the input of the normalized exponential function.
  • Pre-trained language models include but are not limited to: BERT (Bidirectional Encoder Representations from Transformers) model, or RoBERTa (a Robustly Optimized BERT Pretraining Approach), etc.
  • the BERT model is a language representation model, represented by the bidirectional encoder of Transformer (transformation model).
  • the training process of the BERT model can be divided into a pre-training part and a model fine-tuning part.
  • the model fine-tuning part uses the pre-trained BERT model for model fine-tuning training, which is widely used in text classification, text matching and other tasks.
  • Pre-training and model fine-tuning can be illustrated by the following example: assuming that there is a training set A, the network is first pre-trained with training set A, the network parameters are learned on task A, and then saved for later use. When a new task B comes, the same network structure is adopted. When the network parameters are initialized, the parameters learned in A can be loaded, and other high-level parameters are randomly initialized. Then, the training data of task B is used to train the network. When the loaded parameters are constantly changed as the training of task B progresses, it is called "fine-tuning", that is, the parameters are adjusted to make them more suitable for the current task B.
  • the RoBERTa model is similar to the BERT model, with several adjustments based on BERT: 1) longer training time, larger batch size, and more training data; 2) removal of the next prediction loss; 3) longer training sequences; 4) dynamic adjustment of the mask mechanism. It is widely used in NLP (Natural Language Processing) tasks because it performs better than the BERT model in many scenarios.
  • NLP Natural Language Processing
  • the model fine-tuning of the pre-trained language model can be achieved.
  • the model training effect is better. Since the amount of log data is very large and easy to obtain, the training data of the high-frequency intent classification model is easy to obtain, and thus the training effect of the high-frequency intent classification model is better, and the accuracy of the intent recognition results for high-frequency intents is higher.
  • the log data can be classified according to the intent recognition results of the text in the log data.
  • the intent classification process is performed on the log data to obtain the first log data whose intent classification result is a preset high-frequency intent and the confidence level of the intent classification result of the first log data.
  • the first log data may be a record in the log data, and the first log data may include a text and an intention recognition result of the text. Specifically, the first log data may include a question text raised by a customer and an intention recognition result of the question text.
  • the confidence of the intent classification result can be used to characterize the accuracy of the intent classification result. The higher the confidence, the higher the accuracy of the intent classification result.
  • the preset high-frequency intent may include multiple preset high-frequency intents, for example, "customer consultation preset question 1", “customer consultation preset question 2", “customer complaint”, etc.
  • the intent classification result as the preset high-frequency intent may be that the intent classification result is one of the multiple preset high-frequency intents.
  • the log data is screened to obtain low-frequency intent data, including: determining high-frequency intent data based on a comparison result of the confidence of the intent classification result of the first log data and a preset confidence threshold; and deleting the high-frequency intent data in the log data to obtain low-frequency intent data.
  • the confidence of the intent classification result of the first log data is greater than a preset confidence threshold, it means that the accuracy of the intent classification result of the first log data is high, and the first log data can be determined as high-frequency intent data.
  • the confidence of the intent classification result of the first log data is less than or equal to the preset confidence threshold, it means that the accuracy of the intent classification result of the first log data is low, and it can be considered that the first log data does not belong to high-frequency intent data.
  • the confidence threshold By setting the confidence threshold, high-frequency intent data can be more accurately screened out from the log data.
  • the high-frequency intent data in the log data is deleted to obtain the low-frequency intent data.
  • the low-frequency intent data here is not the intent data with a low frequency of occurrence, but the intent data in the log data except the high-frequency intent data.
  • the log data includes 5 records: record 1, record 2, record 3, record 4, and record Record 5, among which record 1, record 3 and record 4 are high-frequency intention data, then delete record 1, record 3 and record 4 in the log data to obtain record 2 and record 5, and determine record 2 and record 5 as low-frequency intention data.
  • Step S106 input the low-frequency intent data and the standard text of the preset intent category into the text comparison model for similarity prediction processing to obtain the text comparison result corresponding to the low-frequency intent data;
  • the text comparison model is a model obtained by training the initial text comparison model based on the training sample set;
  • the training sample set is constructed based on the low-frequency intent data.
  • low-frequency intent data may be input into an initial text comparison model, and the initial text comparison model may be trained to obtain a text comparison model.
  • the initial text comparison model may be a model to be trained in which all parameters to be trained take initial values.
  • the text contrast model can be a contrastive unsupervised learning model.
  • the low-frequency intent data in the log data cannot use the existing model labels.
  • the low-frequency intent data can be treated as unlabeled data.
  • Self-supervised learning is a type of unsupervised learning paradigm. It does not require manually labeled category label information, but directly uses the data itself as supervision information to learn the feature expression of sample data and use it for downstream tasks.
  • Contrastive Learning is a type of self-supervised learning that learns the feature representation of samples by comparing data with positive samples and negative samples in feature space.
  • the core of its training is to shorten the distance between similar samples and increase the distance between irrelevant samples.
  • contrastive learning is to bring similar samples closer and push dissimilar samples away, that is, to construct similar sample pairs ( xi , xj + ) and dissimilar sample pairs ( xi , xj + ).
  • Low-frequency intent data can be determined as unlabeled samples; the unlabeled samples are input into the initial text comparison model, and the initial text comparison model is iteratively trained to obtain a text comparison model.
  • the initial text comparison model includes an encoder and a similarity prediction module connected in sequence; the output of the encoder is the input of the similarity prediction module; the encoder is used to perform encoding processing according to the low-frequency intent data to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intent data; The similarity prediction module is used to perform iterative training based on similar sample pairs and non-similar sample pairs corresponding to low-frequency intent data.
  • the initial text comparison model includes an encoder and a similarity prediction module connected in sequence; the output of the encoder is the input of the similarity prediction module; the sample generation method also includes: the encoder performs encoding processing based on the low-frequency intent data to obtain similar sample pairs and dissimilar sample pairs corresponding to the low-frequency intent data; the similarity prediction module performs iterative training based on the similar sample pairs and dissimilar sample pairs corresponding to the low-frequency intent data.
  • the following strategy is adopted: using the random deactivation (dropout) mechanism of the encoder, based on the question text in the target record, two texts corresponding to the question text are generated, the semantics of the two texts are exactly the same, and the encoding forms are different. Then, the two texts can be determined as similar text pairs corresponding to the target record. In addition, based on the question text in each record except the target record in the low-frequency intent data, a text corresponding to the question text is generated. Then, based on a text corresponding to the question text in each record and one of the two texts corresponding to the question text in the aforementioned target record, multiple non-similar text pairs can be generated.
  • the similarity prediction module can be iteratively trained.
  • the loss function is as follows.
  • l i is used to represent the loss function value.
  • is used to represent the temperature hyperparameter of softmax, which is only used to control the randomness of the prediction.
  • h i and h i + and h j + are the encoding representations of x i , x i + and x j + in the similar sample pair (x i , x i + ) and the non-similar sample pair (x i , x j + ) respectively.
  • N can be a preset value.
  • the values of i and j can be Determined based on the corner marks of similar sample pairs and non-similar sample pairs.
  • Sim(h 1 , h 2 ) can be used to represent the similarity between two vectors h 1 and h 2.
  • the similarity can be calculated using cosine similarity.
  • the loss function value corresponding to the training can be calculated. If the loss function value is less than or equal to the preset threshold, the training is stopped to obtain a trained similarity prediction module, that is, a trained text comparison model.
  • a trained text comparison model can be obtained. Its significance lies in that the model training can be based on unlabeled samples, so that the trained text comparison model has the ability to judge whether two texts are similar. Since log data is a kind of historical data that can be continuously expanded with time, when the time span is long enough, the amount of log data is large and easy to obtain. Therefore, the amount of low-frequency intent data used to train the text comparison model is large, and unsupervised learning can also achieve relatively good results.
  • the low-frequency intent data includes target text and non-target text
  • the encoder is specifically used to: perform encoding processing according to the target text to obtain a target encoding result and a similar encoding result corresponding to the target text, and perform encoding processing according to the non-target text to obtain an encoding result corresponding to the non-target text; determine the target encoding result and the similar encoding result corresponding to the target text as similar sample pairs corresponding to the low-frequency intent data; determine the target encoding result corresponding to the target text and the encoding result corresponding to the non-target text as non-similar sample pairs corresponding to the low-frequency intent data.
  • the low-frequency intent data includes target text and non-target text;
  • the sample generation method also includes: the encoder performs encoding processing according to the target text to obtain a target encoding result and a similar encoding result corresponding to the target text, and performs encoding processing according to the non-target text to obtain an encoding result corresponding to the non-target text;
  • the target encoding result and the similar encoding result corresponding to the target text are determined as similar sample pairs corresponding to the low-frequency intent data;
  • the target encoding result corresponding to the target text and the encoding result corresponding to the non-target text are determined as non-similar sample pairs corresponding to the low-frequency intent data.
  • the low-frequency intent data includes target text and non-target text.
  • the number of target texts can be one.
  • the number of non-target texts can be one or more.
  • the low-frequency intent data includes record 1, record 2, record 3, record 4, and record 5.
  • record 1 includes the target text and the intent recognition result of the target text
  • record 2 includes non-target text 1 and the intent recognition result of non-target text 1
  • record 3 includes non-target text 2 and the intent recognition result of non-target text 2
  • record 4 includes non-target text 3 and the intent recognition result of non-target text 3
  • record 5 includes non-target text 4 and the intent recognition result of non-target text 4.
  • the target text included in record 1 in the input low-frequency intent data can be encoded by the encoder to obtain the target encoding result and similar encoding result corresponding to the target text.
  • the non-target texts 1-4 included in records 2-5 in the input low-frequency intent data can be encoded by the encoder to obtain the encoding results corresponding to the non-target texts 1-4.
  • the target encoding result and the similar encoding result corresponding to record 1 can be determined as similar sample pairs corresponding to low-frequency intent data
  • the target encoding result corresponding to record 1 and the encoding result corresponding to record 2 can be determined as a non-similar sample pair
  • the target encoding result corresponding to record 1 and the encoding result corresponding to record 3 can be determined as a non-similar sample pair
  • the target encoding result corresponding to record 1 and the encoding result corresponding to record 4 can be determined as a non-similar sample pair
  • the target encoding result corresponding to record 1 and the encoding result corresponding to record 5 can be determined as a non-similar sample pair.
  • a similar sample pair and four non-similar sample pairs are generated.
  • the encoder includes an attention layer and a fully connected layer connected in sequence; the output of the attention layer is the input of the fully connected layer; the attention layer is used to perform a first encoding process according to a preset first random inactivation probability and low-frequency intent data to obtain intermediate encoded data; the fully connected layer is used to perform a conversion process according to a preset second random inactivation probability and the intermediate encoded data to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intent data.
  • the encoder includes an attention layer and a fully connected layer connected in sequence; the output of the attention layer is the input of the fully connected layer; the sample generation method also includes: the attention layer performs a first encoding process according to a preset first random inactivation probability and the low-frequency intention data to obtain intermediate encoded data; the fully connected layer performs a conversion process according to a preset second random inactivation probability and the intermediate encoded data Processing is performed to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intent data.
  • the first random deactivation probability of the attention layer can be pre-configured, and the second random deactivation probability of the fully connected layer can be pre-configured.
  • the effect of the first random inactivation probability will take effect on each layer of the transformer, thereby obtaining two different semantic representations of the same text. By inputting the same text twice, two similar sample pairs with exactly the same semantics will be obtained.
  • the sample generation method further includes: when the text lengths of non-similar sample pairs are different, the length of the shorter text in the non-similar sample pairs is extended by punctuation marks.
  • the preset intent category may be one or more low-frequency intent categories.
  • the low-frequency intent data includes multiple low-frequency intent texts; the text comparison model is specifically used to: determine each low-frequency intent text and a standard text of a preset intent category as a similar sample pair corresponding to each low-frequency intent text; perform similarity prediction processing on the similar sample pairs corresponding to each low-frequency intent text to obtain a similarity score for each low-frequency intent text; and determine the similarity score of each low-frequency intent text as the text comparison result corresponding to the low-frequency intent data.
  • the low-frequency intent data includes multiple low-frequency intent texts; the sample generation method also includes: the text comparison model determines each low-frequency intent text and the standard text of the preset intent category as a similar sample pair corresponding to each low-frequency intent text; performs similarity prediction processing on the similar sample pairs corresponding to each low-frequency intent text to obtain a similarity score for each low-frequency intent text; and determines the similarity score of each low-frequency intent text as the text comparison result corresponding to the low-frequency intent data.
  • Each low-frequency intent text and the standard text of the preset intent category are determined as similar sample pairs corresponding to each low-frequency intent text.
  • one or more standard questions are used as the xi text input to the text comparison model, and the low-frequency intent data is traversed as xi+ to form (xi, xi+) data pairs for prediction.
  • the prediction result is a similarity score of 0-1.
  • Step S110 generating a low-frequency intent sample according to the text comparison result and a preset similarity threshold.
  • the preset similarity threshold may be a preset value, and the preset similarity threshold may be updated once or multiple times based on a pre-configured threshold change rule.
  • the preset similarity threshold may be 95%
  • the threshold change rule may be that each time the threshold is updated, 5% is subtracted from the current similarity threshold to obtain an updated similarity threshold.
  • a low-frequency intent sample is generated.
  • the low-frequency intent text with a similarity score less than the preset similarity threshold can be determined as a low-frequency intent sample, or the low-frequency intent text with a similarity score less than the preset similarity threshold can be determined as similar sample data, and the similar sample data is quality-checked, and the similar sample data that passes the quality check is determined as a low-frequency intent sample.
  • the similar sample data is used to indicate candidate sample data that needs to be quality-checked to determine whether it is a low-frequency intent sample.
  • the quality inspection method can be manual quality inspection or quality inspection processing according to preset quality inspection rules.
  • a low-frequency intent sample is generated according to a text comparison result and a preset similarity threshold, including: determining the number of similar sample data corresponding to the preset similarity threshold according to a comparison result of the preset similarity threshold and the text comparison result; if the number of similar sample data corresponding to the low-frequency intent data is less than the preset number threshold, subtracting a preset reduction value from the current similarity threshold to obtain an updated similarity threshold, and determining an updated number of similar sample data corresponding to the updated similarity threshold according to a comparison result of the updated similarity threshold and the text comparison result, repeating the above operation according to the updated number and the preset number threshold until the updated similarity threshold is met.
  • the preset stopping condition is met; the preset stopping condition is that the number of samples is greater than or equal to the preset number threshold; the number of samples is the sum of the number of similar sample data corresponding to the preset similarity threshold and the number of similar sample data corresponding to each updated similarity threshold; each sample data in the similar sample data corresponding to the preset similarity threshold and the similar sample data corresponding to each updated similarity threshold is determined as a low-frequency intention sample corresponding to each sample data.
  • a low-frequency intent sample is generated, including: according to the comparison result of the preset similarity threshold and the text comparison result, the number of similar sample data corresponding to the preset similarity threshold is determined; if the number of similar sample data corresponding to the low-frequency intent data is less than the preset number threshold, the current similarity threshold is subtracted from the preset reduction value to obtain an updated similarity threshold, and, according to the comparison result of the updated similarity threshold and the text comparison result, the updated number of similar sample data corresponding to the updated similarity threshold is determined; if the sample number is greater than or equal to the preset number threshold, the number of similar sample data corresponding to the preset similarity threshold is determined as the final updated number.
  • the preset number threshold is 100
  • the initial value of the preset similarity threshold is 99%
  • the number of similar sample data corresponding to 99% is determined to be 10, which is less than the preset number threshold 100
  • a threshold update is performed:
  • the initial value of the preset similarity threshold can be relatively high, for example, 95%. Initially, the threshold is set high, candidate data is strictly recalled and quality checked, and qualified data is used as similar question data corresponding to the standard question of this low-frequency intent. When all similar question data under the high threshold are marked and analyzed, the threshold is gradually reduced. Set a low preset similarity threshold, gradually recall new candidate data for quality inspection, and exclude the data that has been quality inspected; repeat the above work to obtain similar question data with low-frequency intent.
  • the workload of quality inspection can be reduced and the efficiency of quality inspection can be improved.
  • the number of low-frequency intent samples can also continue to increase with the expansion of log data.
  • a large number of samples of preset intent categories can be accumulated, and the preset intent category can be an intent category of low-frequency intent.
  • the initial intent recognition model can be trained based on the low-frequency intent samples of the preset intent category to obtain an intent recognition model, and the intent recognition model has a high recognition accuracy for low-frequency intents of the preset intent category.
  • the robot agent can recognize the intent of the text based on the trained intent recognition model.
  • the intent recognition model can be an intent recognition model obtained after training the initial intent recognition model with low-frequency intent samples generated by the sample generation method provided in the embodiment of Figure 1. Since the number of low-frequency intent samples is large enough, the training effect of the intent recognition model is good.
  • the robot agent can use the intent recognition model to accurately identify the user's low-frequency intentions, and then make appropriate responses to the user based on the accurately identified low-frequency intentions, thereby improving user satisfaction.
  • log data to be processed is obtained; the log data includes text and intent recognition results of the text; secondly, according to the intent recognition results of the text, the log data is screened to obtain low-frequency intent data; then, the low-frequency intent data and standard text of a preset intent category are input into a text comparison model for similarity prediction processing to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a text comparison model based on an initial text comparison model of a training sample set. The model obtained by training the model; the training sample set is constructed based on the low-frequency intent data; finally, the low-frequency intent samples are generated according to the text comparison results and the preset similarity threshold.
  • Log data is a kind of historical data that grows continuously over time. Even if the low-frequency intent data appears less frequently in the log data, if the time span corresponding to the log data is long enough, a large amount of accumulated low-frequency intent data can be screened from the log data. Based on this large amount of low-frequency intent data, a sufficient amount of training data can be generated for training the initial text comparison model, and the amount of training data can be continuously expanded as the time span of the log data increases. Therefore, when the amount of training data is large enough, the prediction results of the similarity prediction performed by the text comparison model obtained after training are relatively accurate.
  • the low-frequency intent samples with high similarity to the standard text of the preset intent category in the low-frequency intent data can be determined.
  • a large number of low-frequency intent samples of the preset intent category can be accumulated by using the growing log data and the text comparison model, thereby meeting the training requirements of the intent recognition model corresponding to the low-frequency intent samples and improving the recognition accuracy of the low-frequency intent.
  • FIG2 is a processing flow chart of another sample generation method provided by the embodiment of the present application.
  • the model acquisition stage includes steps S202 to S204 .
  • Step S202 unsupervised contrastive learning training.
  • Step S202 may refer to the corresponding description part of the embodiment of FIG. 1 in which “the text comparison model is a model obtained by training the initial text comparison model based on the training sample set; the training sample set is constructed based on low-frequency intent data”.
  • Step S204 obtaining a comparative learning model.
  • the data recall stage includes steps S206 to S210.
  • Step S206 adjusting the threshold precision recall.
  • the threshold value may be a preset similarity threshold value.
  • the adjustment threshold value in step S206 may be a preset similarity threshold value.
  • the initial value of the similarity threshold. Precision recall can be based on the comparison result of the text comparison result and the preset similarity threshold to determine whether the low-frequency intent text is similar sample data to be inspected.
  • Step S208 Manual quality inspection to see if it is qualified.
  • step S210 is executed.
  • Step S210 adjusting the threshold wide recall.
  • the adjustment threshold in step S210 may be obtained by subtracting a preset reduction value from the current similarity threshold to obtain an updated similarity threshold. Wide recall may be determined based on the comparison result between the text comparison result and the current similarity threshold to determine whether the low-frequency intended text is similar sample data to be inspected.
  • steps S206 , S208 and S210 reference may be made to the corresponding description of step S108 in the embodiment of FIG. 1 .
  • Figure 3 is a schematic diagram of a text contrast model training method provided by the embodiment of the present application.
  • a batch size data may include n sample data: sample data 1, i.e., sample data 301 in FIG3 , sample data 2, i.e., sample data 302 in FIG3 , ... sample data n.
  • n is a natural number greater than 0.
  • the n sample data are input into the encoder 303 for encoding.
  • the encoder 303 may generate an x sample 304 and a similar sample 305 based on the sample data 301.
  • the x sample 304 and the similar sample 305 are two samples with the same semantics but different formats obtained after the same sample data is encoded in different ways.
  • the encoder 303 may generate a non-similar sample 1 based on the sample data 302, i.e., a non-similar sample 306 in FIG3 , ...
  • the encoder 303 may generate a non-similar sample n based on the sample data n.
  • the x sample 304 and the similar sample 305 may constitute a similar sample pair.
  • the x sample 304 and the non-similar sample 306 may constitute a non-similar sample pair.
  • the initial text comparison model can be iteratively trained to obtain a text comparison model.
  • the embodiment of the present application also provides a sample generation method applied to the field of robotics.
  • Business process diagram of the method
  • Step S402 the robot goes online.
  • the robot may be a robot with automatic answering capability, which may call an intent recognition model to perform intent recognition on the text, obtain the user's intent, and then automatically answer based on the user's intent.
  • the robot going online means that the robot enters a working state, and the robot can automatically respond to the obtained text in the working state.
  • Step S404 log analysis.
  • the log may be the work log data of the robot, including but not limited to: the text to be responded to received by the robot, the record data of the robot's intention recognition of the text, and the robot's response record data, etc.
  • Step S406 the algorithm tool recalls similar question data.
  • Step S408 manual labeling and quality inspection.
  • step S406 and step S408 reference may be made to the corresponding description portion of step S108 in the embodiment of FIG. 1 .
  • Step S410 Add new labeled data to the model and perform iterative training.
  • the model may be an intent recognition model, which may be used to recognize whether a text contains a low-frequency intent.
  • Step S412 The new robot comes online and the iteration continues.
  • the present application embodiment also provides a method for training an intent recognition model.
  • FIG5 is a processing flow chart of a method for training an intent recognition model provided by the present application embodiment.
  • Step S502 Generate low-frequency intention samples through a sample generation method.
  • the low-frequency intention sample may be generated by the sample generation method described above in the present application.
  • Step S504 inputs the low-frequency intent samples into the initial intent recognition model for iterative training to obtain the intent recognition model.
  • the initial intent recognition model may be a low-frequency intent classification model in which all parameters to be trained take initial values and the model has not been fine-tuned.
  • the low-frequency intent classification model may be a pre-trained language model.
  • Pre-trained language models include but are not limited to: BERT (Bidirectional Encoder Representations from Transformers) model, or RoBERTa (a Robustly Optimized BERT Pretraining Approach) model, etc.
  • the intent recognition model obtained after iterative training can be used to identify whether the text contains low-frequency intent.
  • a low-frequency intent sample is generated by the sample generation method provided by the above-mentioned sample generation method embodiment; the low-frequency intent sample is input into the initial intent recognition model for iterative training to obtain the intent recognition model.
  • Log data is a kind of historical data that continues to grow over time.
  • the low-frequency intent samples with high similarity to the standard text of the preset intent category in the low-frequency intent data can be determined.
  • the initial intent recognition model can be iteratively trained using the low-frequency intent samples of the preset intent category, which can achieve better training results and ensure that the intent recognition model obtained after training has higher recognition accuracy for low-frequency intents.
  • the present application embodiment also provides an intention recognition method applied to a digital human.
  • Figure 6 is a processing flow chart of an intention recognition method applied to a digital human provided by the present application embodiment.
  • Step S602 obtaining the text to be recognized input by the user.
  • Step S604 input the text to be recognized into the intention recognition model for intent recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into the initial intention recognition model for iterative training; the low-frequency intention samples are generated by a sample generation method.
  • the low-frequency intent samples may be generated by the sample generation method described above in the present application.
  • the initial intent recognition model and the intent recognition model may refer to the corresponding description part of the embodiment of the training method of the intent recognition model shown in FIG5 .
  • Step S606 according to the user intention, the target text corresponding to the user intention is obtained in the digital human system, and the target text is displayed.
  • the digital human system may store a pre-configured correspondence between preset user intentions and preset texts. According to the user intention obtained in step S604 and the correspondence between the preset user intentions and preset texts, the target text corresponding to the user intention may be queried in the digital human system and displayed.
  • a target text corresponding to the user intention is obtained in the digital human system according to the user intention, including: querying the digital human system to obtain the target text corresponding to the user intention according to the correspondence between the user intention and the pre-configured preset user intention and the preset text.
  • the preset user intent can be a pre-configured low-frequency intent, such as "early repayment”
  • the preset text can be the response text predetermined by the digital human system for the low-frequency intent, such as "You can make an appointment for this service with xxx according to xxx”.
  • the text to be recognized input by the user is obtained; secondly, the text to be recognized is input into the intention recognition model for intention recognition to obtain the user's intention; the intention recognition model is obtained by inputting low-frequency intention samples into the initial intention recognition model for iterative training; the low-frequency intention samples are generated by the sample generation method provided by the aforementioned sample generation method embodiment; finally, according to the user's intention, the target text corresponding to the user's intention is obtained in the digital human system, and the target text is displayed.
  • Log data is a kind of historical data that grows continuously over time.
  • the low-frequency intent samples with high similarity to the standard text of the preset intent category in the low-frequency intent data can be determined.
  • the initial intent recognition model is iteratively trained by using the low-frequency intent samples of the preset intent category, and a good training effect can be achieved, so that the intent recognition model obtained after training has a high recognition accuracy for low-frequency intent.
  • the accurate user intent obtained by recognition can be used to obtain and display the target text that meets the user intent from the digital human system, thereby improving the user experience.
  • FIG. 7 is a schematic diagram of a sample generating device provided in an embodiment of the present application.
  • the present embodiment provides a sample generation device, including: a first acquisition unit 701, used to acquire log data to be processed; the log data includes text and intent recognition results of the text; a screening unit 702, used to perform data screening processing on the log data according to the intent recognition results of the text, to obtain low-frequency intent data; a prediction unit 703, used to input the low-frequency intent data and standard text of a preset intent category into a text comparison model for similarity prediction processing, to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is constructed based on the low-frequency intent data; a first generation unit 704, used to generate a low-frequency intent sample according to the text comparison result and a preset similarity threshold.
  • the screening unit 702 includes: a classification subunit, configured to input the log data into a high-frequency intent classification model to obtain the first log data and the confidence of the intent classification result of the first log data;
  • the intent classification result of the first log data is a preset high-frequency intent;
  • the high-frequency intent classification model is used to perform intent classification processing on the log data according to the intent recognition result of the text in the log data;
  • the screening subunit is used to perform data screening processing on the log data according to the first log data and the confidence of the intent classification result of the first log data to obtain low-frequency intent data.
  • the screening subunit is specifically used to: determine high-frequency intent data based on a comparison result of the confidence of the intent classification result of the first log data with a preset confidence threshold; delete the high-frequency intent data in the log data to obtain low-frequency intent data.
  • the initial text comparison model includes an encoder and a similarity prediction module connected in sequence; the output of the encoder is the input of the similarity prediction module; the encoder is used to perform encoding processing based on the low-frequency intent data to obtain similar sample pairs and dissimilar sample pairs corresponding to the low-frequency intent data; the similarity prediction module is used to perform iterative training based on similar sample pairs and dissimilar sample pairs corresponding to the low-frequency intent data.
  • the low-frequency intent data includes target text and non-target text
  • the encoder is specifically used to: perform encoding processing according to the target text to obtain a target encoding result and a similar encoding result corresponding to the target text, and perform encoding processing according to the non-target text to obtain an encoding result corresponding to the non-target text; determine the target encoding result and the similar encoding result corresponding to the target text as similar sample pairs corresponding to the low-frequency intent data; determine the target encoding result corresponding to the target text and the encoding result corresponding to the non-target text as non-similar sample pairs corresponding to the low-frequency intent data.
  • the encoder includes an attention layer and a fully connected layer connected in sequence; the output of the attention layer is the input of the fully connected layer; the attention layer is used to perform a first encoding process according to a preset first random inactivation probability and the low-frequency intent data to obtain intermediate encoded data; the fully connected layer is used to perform conversion processing according to a preset second random inactivation probability and the intermediate encoded data to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intent data.
  • the low-frequency intent data includes a plurality of low-frequency intent texts; the text comparison model is specifically used to: determine each low-frequency intent text and a standard text of a preset intent category as a similar sample pair corresponding to each low-frequency intent text; and perform similarity prediction on the similar sample pairs corresponding to each low-frequency intent text.
  • the similarity score of each low-frequency intent text is obtained by performing measurement processing; and the similarity score of each low-frequency intent text is determined as the text comparison result corresponding to the low-frequency intent data.
  • the first generating unit 704 is specifically used to: determine the number of similar sample data corresponding to the preset similarity threshold according to the comparison result between the preset similarity threshold and the text comparison result; if the number of similar sample data corresponding to the low-frequency intent data is less than the preset number threshold, repeatedly perform the operation of subtracting the preset reduction value from the current similarity threshold to obtain an updated similarity threshold, and, according to the comparison result between the updated similarity threshold and the text comparison result, determine the number of similar sample data corresponding to the updated similarity threshold, until the updated similarity threshold meets the preset stop condition;
  • the preset stop condition is that the number of samples is greater than or equal to the preset number threshold; the number of samples is the sum of the number of similar sample data corresponding to the preset similarity threshold and the number of similar sample data corresponding to each updated similarity threshold; each sample data in the similar sample data corresponding to the preset similarity threshold and the similar sample data corresponding to each updated similarity threshold is determined as a low-frequency intent sample corresponding to each
  • the sample generation device includes: a first acquisition unit, a screening unit, a prediction unit and a first generation unit, wherein the first acquisition unit is used to acquire the log data to be processed; the log data includes text and the intention recognition result of the text; the screening unit is used to perform data screening processing on the log data according to the intention recognition result of the text to obtain low-frequency intention data; the prediction unit is used to input the low-frequency intention data and the standard text of the preset intention category into the text comparison model for similarity prediction processing to obtain the text comparison result corresponding to the low-frequency intention data; the text comparison model is a model obtained by training the initial text comparison model based on the training sample set; the training sample set is constructed based on the low-frequency intention data; the first generation unit is used to generate a low-frequency intention sample according to the text comparison result and the preset similarity threshold.
  • Log data is a kind of historical data that grows continuously with time. Even if the frequency of occurrence of low-frequency intention data in the log data is low, when the time span corresponding to the log data is long enough, a large amount of accumulated low-frequency intention data can be screened from the log data, and a sufficient amount of training data for training the initial text comparison model can be generated based on the large amount of low-frequency intention data, and the amount of training data can increase with the time span of the log data. Therefore, when the amount of training data is large enough, the prediction result of similarity prediction by the text comparison model obtained after training is relatively accurate.
  • the low-frequency intent samples with high similarity to the standard text of the preset intent category in the low-frequency intent data can be determined.
  • a large number of low-frequency intent samples of the preset intent category can be accumulated by using the growing log data and the text comparison model, thereby meeting the training requirements of the intent recognition model corresponding to the low-frequency intent samples and improving the recognition accuracy of the low-frequency intent.
  • FIG8 is a schematic diagram of a training device for an intent recognition model provided in an embodiment of the present application.
  • This embodiment provides a training device for an intent recognition model, including: a second generation unit 801, used to generate low-frequency intent samples through a sample generation method; a training unit 802, used to input the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
  • the training device of the intent recognition model provided in the embodiment of the present application includes a second generation unit and a training unit, wherein the second generation unit is used to generate low-frequency intent samples through the sample generation method provided in the above-mentioned sample generation method embodiment; the training unit is used to input the low-frequency intent samples into the initial intent recognition model for iterative training to obtain the intent recognition model.
  • Log data is a kind of historical data that grows continuously with time.
  • the low-frequency intent data has a low frequency of occurrence in the log data
  • a large amount of accumulated low-frequency intent data can be screened from the log data, and a sufficient amount of training data can be generated based on the large amount of low-frequency intent data for training the initial text comparison model, and the amount of training data can be continuously expanded as the time span of the log data increases. Therefore, when the amount of training data is sufficient, the prediction result when similarity prediction is performed by the text comparison model obtained after training is more accurate.
  • the low-frequency intent samples with higher similarity with the standard text of the preset intent category in the low-frequency intent data can be determined.
  • the unsatisfactory log data can be used to train the initial text comparison model.
  • the continuously growing log data and text comparison model accumulate a large number of low-frequency intent samples of the preset intent category, and then use the low-frequency intent samples of the preset intent category to iteratively train the initial intent recognition model, which can achieve better training results and make the intent recognition model obtained after training have higher recognition accuracy for low-frequency intents.
  • FIG. 9 is a schematic diagram of an intention recognition device for a digital human provided in an embodiment of the present application.
  • This embodiment provides an intention recognition device applied to a digital human, comprising: a second acquisition unit 901, used to acquire a text to be recognized input by a user; a recognition unit 902, used to input the text to be recognized into an intention recognition model for intention recognition, and obtain the user intention; the intention recognition model is obtained by inputting a low-frequency intention sample into an initial intention recognition model for iterative training; the low-frequency intention sample is generated by the above-mentioned sample generation method; a display unit 903, used to obtain a target text corresponding to the user intention in the digital human system according to the user intention, and display the target text.
  • the intention recognition device for digital human includes a second acquisition unit, an identification unit and a display unit, wherein the second acquisition unit is used to acquire the text to be recognized input by the user; the identification unit is used to input the text to be recognized into the intention recognition model for intention recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into the initial intention recognition model for iterative training; the low-frequency intention samples are generated by the sample generation method provided by the aforementioned sample generation method embodiment; the display unit is used to obtain the target text corresponding to the user intention in the digital human system according to the user intention, and display the target text.
  • Log data is a kind of historical data that grows with time.
  • low-frequency intent samples with high similarity to standard text of preset intent categories in low-frequency intent data can be determined.
  • the initial intent recognition model can be iteratively trained using the low-frequency intent samples of the preset intent categories, which can achieve better training results. This makes the intent recognition model obtained after training have high recognition accuracy for low-frequency intents. Then, the accurate user intent obtained by recognition can be used to obtain and display the target text that meets the user intent from the digital human system, thereby improving the user experience.
  • an embodiment of the present application also provides an electronic device, which is used to execute one or more of the sample generation method, the training method for the intent recognition model, and the intent recognition method applied to a digital human provided above.
  • Figure 10 is a structural schematic diagram of an electronic device provided in an embodiment of the present application.
  • electronic devices may have relatively large differences due to different configurations or performances, and may include one or more processors 1001 and memory 1002, and the memory 1002 may store one or more storage applications or data.
  • the memory 1002 may be a short-term storage or a persistent storage.
  • the application stored in the memory 1002 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the electronic device.
  • the processor 1001 may be configured to communicate with the memory 1002 and execute a series of computer executable instructions in the memory 1002 on the electronic device.
  • the electronic device may also include one or more power supplies 1003, one or more wired or wireless network interfaces 1004, one or more input/output interfaces 1005, one or more keyboards 1006, etc.
  • the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs are stored in the memory.
  • the program may include one or more modules, and each module may include a series of computer executable instructions in the electronic device, and is configured to be executed by one or more processors.
  • the one or more programs include the following computer executable instructions: obtaining log data to be processed; the log data includes text and the intent recognition result of the text; according to the intent recognition result of the text, the log data is screened to obtain low-frequency intent data; the low-frequency intent data and the standard text of the preset intent category are input into the text comparison model for similarity prediction processing to obtain the text comparison result corresponding to the low-frequency intent data; the text comparison model is a model obtained by training the initial text comparison model based on the training sample set; the training sample set is constructed based on the low-frequency intent data; and a low-frequency intent sample is generated according to the text comparison result and the preset similarity threshold.
  • an electronic device in another specific embodiment, includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions in the electronic device, and the one or more programs are configured to be executed by one or more processors, and include the following computer executable instructions: generating low-frequency intent samples by a sample generation method; inputting the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
  • the electronic device includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions in the electronic device, and is configured to be executed by one or more processors.
  • the one or more programs include the following computer executable instructions: obtaining text to be recognized input by the user; inputting the text to be recognized into an intention recognition model for intention recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into the initial intention recognition model for iterative training; the low-frequency intention samples are generated by a sample generation method; according to the user intention, a target text corresponding to the user intention is obtained in the digital human system, and the target text is displayed.
  • an embodiment of the present application also provides a computer-readable storage medium.
  • a computer-readable storage medium is used to store computer-executable instructions, which implement the following process when executed by a processor: obtaining log data to be processed; the log data includes text and intent recognition results of the text; based on the intent recognition results of the text, the log data is screened to obtain low-frequency intent data; the low-frequency intent data and standard text of a preset intent category are input into a text comparison model for similarity prediction processing to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is constructed based on the low-frequency intent data; and a low-frequency intent sample is generated based on the text comparison result and a preset similarity threshold.
  • a computer-readable storage medium is used to store computer-executable instructions, which implement the following process when executed by a processor: generating low-frequency intent samples through a sample generation method; inputting the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
  • a computer-readable storage medium is used to store computer-executable instructions, which implement the following process when executed by a processor: obtaining a text to be recognized input by a user; inputting the text to be recognized into an intention recognition model for intent recognition to obtain the user's intention; the intention recognition model is obtained by inputting low-frequency intention samples into an initial intention recognition model for iterative training; the low-frequency intention samples are generated by a sample generation method; and according to the user's intention, a target text corresponding to the user's intention is obtained in the digital human system, and the target text is displayed.
  • the embodiment of the computer-readable storage medium in this specification and at least one of the embodiments of the sample generation method, the training method of the intent recognition model, and the intent recognition method applied to a digital human in this specification are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the corresponding method mentioned above, and the repeated parts will not be repeated.
  • the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the embodiments of the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, this specification may adopt the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
  • a computer-readable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
  • These computer program instructions may also be loaded onto a computer or other programmable device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
  • a computing device includes one or more processors (CPU), input/output interfaces, network interfaces, and memory.
  • processors CPU
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-permanent storage in computer-readable media, random access memory Memory is an example of a computer-readable medium.
  • Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information.
  • Information can be computer readable instructions, data structures, program modules or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
  • computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
  • Embodiments of the present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules.
  • program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types.
  • One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network.
  • program modules may be located in local and remote computer storage media, including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Probability & Statistics with Applications (AREA)
  • Mathematical Physics (AREA)
  • Machine Translation (AREA)

Abstract

Provided in the embodiments of the present description are a sample generation method and apparatus, and an electronic device and a storage medium. The sample generation method comprises: acquiring log data to be processed, wherein the log data comprises text and an intention recognition result of the text; performing data screening processing on the log data according to the intention recognition result of the text, so as to obtain low-frequency intention data; inputting the low-frequency intention data and standard text of a preset intention category into a text comparison model so as to perform similarity prediction processing, and obtaining a text comparison result corresponding to the low-frequency intention data, wherein the text comparison model is a model obtained by training an initial text comparison model on the basis of a training sample set, and the training sample set is constructed on the basis of the low-frequency intention data; and generating a low-frequency intention sample according to the text comparison result and a preset similarity threshold.

Description

样本生成方法、装置、电子设备及存储介质Sample generation method, device, electronic device and storage medium
交叉引用cross reference
本申请要求在2022年09月26日提交中国专利局、申请号为202211178539.7、名称为“样本生成方法、装置、电子设备及存储介质”的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。This application claims priority to a Chinese patent application filed with the China Patent Office on September 26, 2022, with application number 202211178539.7 and title “Sample Generation Method, Device, Electronic Device and Storage Medium”. The entire contents of the application are incorporated by reference into this application.
技术领域Technical Field
本申请涉及人工智能领域,尤其涉及一种样本生成方法、装置、电子设备及存储介质。The present application relates to the field of artificial intelligence, and in particular to a sample generation method, device, electronic device and storage medium.
背景技术Background technique
随着电子技术的发展,机器人的应用越来越广泛。机器人坐席可以自动应答客户提出的问题,节省了大量人力资源,提高沟通效率。客户提出的问题五花八门,多种多样。一部分问题中包含的用户意图出现频率较高,可以将其称为高频意图;另一部分问题包含的用户意图出现频率较低,可以将其称为低频意图。对于各个高频意图,由于与高频意图相关的问题出现频率较高,用于模型训练的高频意图训练数据易获得,则通过模型训练得到的机器人坐席的意图识别结果准确性较高。然而,对于各个低频意图,由于与低频意图相关的问题出现频率较低,在对机器人坐席进行模型训练时往往缺乏足够多的训练数据,导致机器人坐席的意图识别结果的准确性较低,机器人坐席的答复牛头不对马嘴,给用户带来了不好的体验,且间接提高了人工坐席的工作量。With the development of electronic technology, robots are being used more and more widely. Robot agents can automatically answer questions raised by customers, saving a lot of human resources and improving communication efficiency. The questions raised by customers are varied and varied. Some questions contain user intentions that appear frequently, which can be called high-frequency intentions; other questions contain user intentions that appear less frequently, which can be called low-frequency intentions. For each high-frequency intention, since the questions related to high-frequency intentions appear frequently, the high-frequency intention training data used for model training is easy to obtain, and the intention recognition results of the robot agent obtained through model training are more accurate. However, for each low-frequency intention, since the questions related to low-frequency intentions appear less frequently, there is often a lack of sufficient training data when training the model for the robot agent, resulting in a low accuracy of the intention recognition results of the robot agent, and the robot agent's answers are irrelevant, which brings a bad experience to users and indirectly increases the workload of manual agents.
发明内容 Summary of the invention
本申请提供了一种样本生成方法、装置、电子设备及存储介质,以扩增低频意图样本的数量,满足模型训练需求,从而提高低频意图的识别准确性。The present application provides a sample generation method, device, electronic device and storage medium to expand the number of low-frequency intent samples to meet model training requirements, thereby improving the recognition accuracy of low-frequency intent.
一方面,本申请提供了一种样本生成方法,包括:获取待处理的日志数据;所述日志数据包括文本和所述文本的意图识别结果;根据所述文本的意图识别结果,对所述日志数据进行数据筛选处理,得到低频意图数据;将所述低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到所述低频意图数据对应的文本对比结果;所述文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;所述训练样本集基于所述低频意图数据构建;根据所述文本对比结果与预设相似度阈值,生成低频意图样本。On the one hand, the present application provides a sample generation method, including: obtaining log data to be processed; the log data includes text and intent recognition results of the text; according to the intent recognition results of the text, performing data screening processing on the log data to obtain low-frequency intent data; inputting the low-frequency intent data and standard text of a preset intent category into a text comparison model for similarity prediction processing to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is constructed based on the low-frequency intent data; and generating a low-frequency intent sample based on the text comparison result and a preset similarity threshold.
一方面,本申请提供了一种意图识别模型的训练方法,包括:通过如第一方面所述的样本生成方法生成低频意图样本;将所述低频意图样本输入初始意图识别模型进行迭代训练,得到意图识别模型。On the one hand, the present application provides a training method for an intent recognition model, comprising: generating low-frequency intent samples by the sample generation method as described in the first aspect; inputting the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
一方面,本申请提供了一种应用于数字人的意图识别方法,包括:获取用户输入的待识别文本;将所述待识别文本输入意图识别模型进行意图识别,得到用户意图;所述意图识别模型是通过将低频意图样本输入初始意图识别模型进行迭代训练所得到的;所述低频意图样本是通过如上述的样本生成方法所生成的;根据所述用户意图在所述数字人的系统中获取对应所述用户意图的目标文本,并对所述目标文本进行展示。On the one hand, the present application provides an intention recognition method applied to a digital human, comprising: obtaining a text to be recognized input by a user; inputting the text to be recognized into an intention recognition model for intent recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into an initial intention recognition model for iterative training; the low-frequency intention samples are generated by the sample generation method as described above; according to the user intention, obtaining a target text corresponding to the user intention in the digital human system, and displaying the target text.
一方面,本申请提供了一种样本生成装置,包括:第一获取单元,用于获取待处理的日志数据;所述日志数据包括文本和所述文本的意图识别结果;筛选单元,用于根据所述文本的意图识别结果,对所述日志数据进行数据筛选处理,得到低频意图数据;预测单元,用于将所述低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到所述低频意图数据对应的文本对比结果;所述文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;所述训练样本集基于所述低频意图数据 构建;第一生成单元,用于根据所述文本对比结果与预设相似度阈值,生成低频意图样本。On the one hand, the present application provides a sample generation device, including: a first acquisition unit, used to acquire log data to be processed; the log data includes text and intent recognition results of the text; a screening unit, used to perform data screening processing on the log data according to the intent recognition results of the text, to obtain low-frequency intent data; a prediction unit, used to input the low-frequency intent data and standard text of a preset intent category into a text comparison model for similarity prediction processing, to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is based on the low-frequency intent data Construct; a first generation unit, used to generate a low-frequency intent sample according to the text comparison result and a preset similarity threshold.
一方面,本申请提供了一种意图识别模型的训练装置,包括:第二生成单元,用于通过如第一方面所述的样本生成方法生成低频意图样本;训练单元,用于将所述低频意图样本输入初始意图识别模型进行迭代训练,得到意图识别模型。On the one hand, the present application provides a training device for an intent recognition model, comprising: a second generation unit, used to generate low-frequency intent samples through the sample generation method as described in the first aspect; a training unit, used to input the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
一方面,本申请提供了一种应用于数字人的意图识别装置,包括:第二获取单元,用于获取用户输入的待识别文本;识别单元,用于将所述待识别文本输入意图识别模型进行意图识别,得到用户意图;所述意图识别模型是通过将低频意图样本输入初始意图识别模型进行迭代训练所得到的;所述低频意图样本是通过上述的样本生成方法所生成的;展示单元,用于根据所述用户意图在所述数字人的系统中获取对应所述用户意图的目标文本,并对所述目标文本进行展示。On the one hand, the present application provides an intention recognition device applied to a digital human, comprising: a second acquisition unit, used to acquire a text to be recognized input by a user; a recognition unit, used to input the text to be recognized into an intention recognition model for intention recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into an initial intention recognition model for iterative training; the low-frequency intention samples are generated by the above-mentioned sample generation method; a display unit, used to obtain a target text corresponding to the user intention in the system of the digital human according to the user intention, and display the target text.
一方面,本申请提供了一种电子设备,包括:处理器;以及,被配置为存储计算机可执行指令的存储器,所述计算机可执行指令在被执行时使所述处理器执行如上述的样本生成方法,或者,如上述的意图识别模型的训练方法,或者,如上述的应用于数字人的意图识别方法。On the one hand, the present application provides an electronic device, comprising: a processor; and a memory configured to store computer-executable instructions, which, when executed, cause the processor to execute a sample generation method as described above, or a training method for an intent recognition model as described above, or a method for intent recognition applied to a digital human as described above.
一方面,本申请提供了一种计算机可读存储介质,用于存储计算机可执行指令,所述计算机可执行指令在被处理器执行时实现如第一方面所述的样本生成方法,或者,如上述的意图识别模型的训练方法,或者,如上述的应用于数字人的意图识别方法。On the one hand, the present application provides a computer-readable storage medium for storing computer-executable instructions, which, when executed by a processor, implement the sample generation method as described in the first aspect, or the training method of the intent recognition model as described above, or the intent recognition method applied to a digital human as described above.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人 员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图;In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments described in this specification, and it is not difficult for a person skilled in the art to understand them. For the staff, other drawings can be obtained based on these drawings without paying any creative labor;
图1为本申请实施例提供的一种样本生成方法的处理流程图;FIG1 is a processing flow chart of a sample generation method provided in an embodiment of the present application;
图2为本申请实施例提供的另一种样本生成方法的处理流程图;FIG2 is a processing flow chart of another sample generation method provided in an embodiment of the present application;
图3为本申请实施例提供的一种文本对比模型的训练方式示意图;FIG3 is a schematic diagram of a training method of a text comparison model provided in an embodiment of the present application;
图4为本申请实施例提供的一种样本生成方法的业务流程图;FIG4 is a business flow chart of a sample generation method provided in an embodiment of the present application;
图5为本申请实施例提供的一种意图识别模型的训练方法的处理流程图;FIG5 is a processing flow chart of a training method for an intent recognition model provided in an embodiment of the present application;
图6为本申请实施例提供的一种应用于数字人的意图识别方法的处理流程图;FIG6 is a processing flow chart of a method for identifying intentions of a digital human provided in an embodiment of the present application;
图7为本申请实施例提供的一种样本生成装置示意图;FIG7 is a schematic diagram of a sample generation device provided in an embodiment of the present application;
图8为本申请实施例提供的一种意图识别模型的训练装置示意图;FIG8 is a schematic diagram of a training device for an intent recognition model provided in an embodiment of the present application;
图9为本申请实施例提供的一种应用于数字人的意图识别装置示意图;FIG9 is a schematic diagram of an intention recognition device for a digital human provided in an embodiment of the present application;
图10为本申请实施例提供的一种电子设备的结构示意图。FIG. 10 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本申请实施例中的技术方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书的一部分实施例,而不是全部的实施例。基于本申请实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请的保护范围。In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
实际应用中,用户的意图数量非常多,对于一部分高频意图,往往很容易获得充足的训练数据,可用于训练识别意图的意图识别模型,使得高频意图的识别准确性较高。但对于低频意图,不同的用户可能采用不同的表达方式来表达同一个意图,因为低频意图的出现频率较低,故用于训练意图识别模型的训练数据较难获得且数量较少,不利于模型训练效果。在机器人坐席进行意图识别并自动应答的情况下,若忽略低频意图仅识别高频意图,会大 大降低部分客户的用户体验,让该部分客户觉得机器人很“智障”,难以沟通。坐席可以是客服,也可以是其他可以对文本或语音做出回复的岗位或人员。In actual applications, there are a large number of user intentions. For some high-frequency intentions, it is often easy to obtain sufficient training data, which can be used to train the intention recognition model to recognize the intention, making the recognition accuracy of high-frequency intentions higher. However, for low-frequency intentions, different users may use different expressions to express the same intention. Since low-frequency intentions occur less frequently, the training data used to train the intention recognition model is difficult to obtain and the quantity is small, which is not conducive to the model training effect. When the robot seat recognizes the intention and automatically answers, if the low-frequency intention is ignored and only the high-frequency intention is recognized, it will greatly This greatly reduces the user experience of some customers, making them feel that the robot is "retarded" and difficult to communicate with. The agent can be a customer service representative or any other position or person who can respond to text or voice.
为了克服上述问题,本申请实施例提供了一种样本生成方法。In order to overcome the above problems, an embodiment of the present application provides a sample generation method.
本申请提出的样本生成方法可由电子设备执行,具体可由电子设备中的处理器执行。此处所提到的电子设备可以是终端设备,比如智能手机、平板电脑、台式电脑、智能语音交互设备、可穿戴设备、机器人以及车载终端等等;或者,电子设备还可以是服务器,比如独立的物理服务器、由多个服务器组成的服务器集群或者能够进行云计算的云服务器。The sample generation method proposed in this application can be executed by an electronic device, specifically by a processor in the electronic device. The electronic device mentioned here can be a terminal device, such as a smart phone, a tablet computer, a desktop computer, an intelligent voice interaction device, a wearable device, a robot, and a vehicle terminal, etc.; or, the electronic device can also be a server, such as an independent physical server, a server cluster composed of multiple servers, or a cloud server capable of cloud computing.
下面将通过几个实施例具体介绍本申请提出的样本生成方法。The sample generation method proposed in this application will be specifically introduced through several embodiments below.
参照图1,为本申请实施例提供的一种样本生成方法的处理流程图。如图1所示,本申请实施例提供的样本生成方法具体可包括如下步骤:Referring to Figure 1, a processing flow chart of a sample generation method provided in an embodiment of the present application is shown. As shown in Figure 1, the sample generation method provided in an embodiment of the present application may specifically include the following steps:
步骤S102,获取待处理的日志数据;日志数据包括文本和文本的意图识别结果。Step S102, obtaining log data to be processed; the log data includes text and intent recognition results of the text.
日志数据可以是在目标业务的运行过程中记录下来的与目标业务相关的历史数据。Log data may be historical data related to the target business recorded during the operation of the target business.
文本可以是存在意图识别需求的自然语言文本。文本可以是用户输入的文本,可以是由语音转换得到的文本,还可以是通过其他方式获取的文本,本说明书不对文本的获取方式进行特殊限制。The text may be a natural language text for which intent recognition is required. The text may be text input by a user, text obtained by voice conversion, or text obtained by other means. This specification does not impose any special restrictions on the method of obtaining the text.
在机器人自动应答的场景下,文本可以是客户向机器人提出的问题文本,例如:怎么查询账单?文本的意图识别结果,可以是机器人对上述的问题文本进行意图识别之后得到的意图识别结果,例如,“如何查询账单?”的意图识别结果为“咨询账单查询方式”。In the scenario where the robot automatically answers, the text may be a question text asked by the customer to the robot, for example: How do I check the bill? The intent recognition result of the text may be the intent recognition result obtained by the robot after performing intent recognition on the above question text. For example, the intent recognition result of "How do I check the bill?" is "Inquire about the bill query method."
获取待处理的日志数据,可以是获取待处理的日志数据中的对话数据。对话数据可以包括客户提出的问题文本以及机器人对客户的应答文本。机器人可以预先配置有意图识别结果和应答文本之间的对应关系,根据意图识别结果和应答文本之间的对应关系以及机器人对客户的应答文本,可以查询得 到问题文本的意图识别结果。进而,可以将问题文本确定为日志数据中的文本,将问题文本的意图识别结果确定为日志数据中的该文本的意图识别结果。Acquiring the log data to be processed may be acquiring the conversation data in the log data to be processed. The conversation data may include the text of the question raised by the customer and the text of the robot's answer to the customer. The robot may be pre-configured with a correspondence between the intent recognition result and the answer text. Based on the correspondence between the intent recognition result and the answer text and the robot's answer text to the customer, the robot may query the Then, the question text can be determined as the text in the log data, and the intention recognition result of the question text can be determined as the intention recognition result of the text in the log data.
根据以上内容,可知本申请的一些实施方式中,获取待处理的日志数据,包括:获取待处理的日志数据中的对话数据;对话数据包括客户提出的问题文本以及机器人对客户的应答文本;根据应答文本和预先配置的意图识别结果和应答文本之间的对应关系,查询得到问题文本的意图识别结果;将问题文本确定为日志数据中的文本,将问题文本的意图识别结果确定为日志数据中的文本的意图识别结果。Based on the above content, it can be known that in some embodiments of the present application, obtaining the log data to be processed includes: obtaining conversation data in the log data to be processed; the conversation data includes the question text raised by the customer and the robot's response text to the customer; according to the correspondence between the response text and the pre-configured intent recognition result and the response text, querying to obtain the intent recognition result of the question text; determining the question text as the text in the log data, and determining the intent recognition result of the question text as the intent recognition result of the text in the log data.
示例性地,坐席系统中的日志数据是实际生产场景中产生的客户和坐席机器人交互的日志文本。坐席系统产生的日志数据量通常很大,且来源不一。获取的日志数据可以仅包括客户的聊天数据,排除掉推荐问题、常见问题解答(frequently-asked questions,FAQ)、多轮引擎等数据,剩下的数据则是单轮对话数据,例如:客户问:“如何提前还款”,机器人答“XXX”。因为机器人回答是和所识别的意图绑定的。所以最终拿出来的日志数据形式如表1所示。表1示出了部分日志数据。Exemplarily, the log data in the agent system is the log text of the interaction between the customer and the agent robot generated in the actual production scenario. The amount of log data generated by the agent system is usually large and comes from different sources. The acquired log data can only include the customer's chat data, excluding the recommended questions, frequently asked questions (FAQ), multi-round engine data, and the remaining data is single-round conversation data, for example: the customer asked: "How to repay in advance", the robot answered "XXX". Because the robot's answer is bound to the identified intent. So the final log data format is shown in Table 1. Table 1 shows part of the log data.
表1
Table 1
另外,日志数据可以包括多条记录。在获得日志数据之后,为减少冗余,提高数据处理效率,可以去除日志数据中的重复数据。重复数据可以是客户文本完全一致的日志数据的多条记录。例如,日志数据包括:In addition, the log data may include multiple records. After obtaining the log data, duplicate data in the log data may be removed to reduce redundancy and improve data processing efficiency. Duplicate data may be multiple records of log data with completely identical customer text. For example, the log data includes:
记录1:客户文本“如何提前还款”,机器人识别意图“客户咨询如何提前还款”。Record 1: Customer text "How to repay early", robot recognizes the intent "Customer inquires about how to repay early".
记录2:客户文本“如何提前还款”,机器人识别意图“客户咨询如何提前还款”。 Record 2: Customer text "How to repay early", robot recognizes the intent "Customer inquires about how to repay early".
记录3:客户文本“我想提前还款”,机器人识别意图“客户咨询如何提前还款”。Record 3: Customer text "I want to repay early", robot recognizes the intent "Customer asks how to repay early".
由于记录1与记录2的客户文本完全一致,故记录1与记录2可以确定为重复数据,可以删除掉记录1和记录2中的一者。Since the customer texts of record 1 and record 2 are completely consistent, record 1 and record 2 can be determined to be duplicate data, and one of record 1 and record 2 can be deleted.
步骤S104,根据文本的意图识别结果,对日志数据进行数据筛选处理,得到低频意图数据。Step S104, based on the intent recognition result of the text, perform data screening processing on the log data to obtain low-frequency intent data.
在一些实施方式中,可以根据文本的意图识别结果,确定文本的意图识别结果是否为预设的高频意图,若是,则从日志数据中删除掉该文本以及文本的意图识别结果;若否,则保留该文本以及文本的意图识别结果作为低频意图数据。In some embodiments, based on the intent recognition result of the text, it can be determined whether the intent recognition result of the text is a preset high-frequency intent. If so, the text and the intent recognition result of the text are deleted from the log data; if not, the text and the intent recognition result of the text are retained as low-frequency intent data.
根据以上内容,可知本申请的一些实施方式中,根据文本的意图识别结果,对日志数据进行数据筛选处理,得到低频意图数据,包括:根据文本的意图识别结果,确定文本的意图识别结果是否为预设的高频意图;若文本的意图识别结果为预设的高频意图,则从日志数据中删除文本和文本的意图识别结果;若文本的意图识别结果不是预设的高频意图,则将文本以及文本的意图识别结果作为低频意图数据。Based on the above content, it can be known that in some embodiments of the present application, according to the intention recognition result of the text, the log data is screened and processed to obtain low-frequency intention data, including: according to the intention recognition result of the text, determining whether the intention recognition result of the text is a preset high-frequency intention; if the intention recognition result of the text is a preset high-frequency intention, deleting the text and the intention recognition result of the text from the log data; if the intention recognition result of the text is not the preset high-frequency intention, treating the text and the intention recognition result of the text as low-frequency intention data.
在一些实施方式中,根据文本的意图识别结果,对日志数据进行数据筛选处理,得到低频意图数据,包括:将日志数据输入高频意图分类模型,得到第一日志数据和第一日志数据的意图分类结果的置信度;第一日志数据的意图分类结果为预设高频意图;高频意图分类模型用于根据日志数据中文本的意图识别结果对日志数据进行意图分类处理;根据第一日志数据和第一日志数据的意图分类结果的置信度,对日志数据进行数据筛选处理,得到低频意图数据。In some embodiments, based on the intent recognition result of the text, the log data is screened to obtain low-frequency intent data, including: inputting the log data into a high-frequency intent classification model to obtain first log data and the confidence of the intent classification result of the first log data; the intent classification result of the first log data is a preset high-frequency intent; the high-frequency intent classification model is used to perform intent classification on the log data based on the intent recognition result of the text in the log data; based on the first log data and the confidence of the intent classification result of the first log data, the log data is screened to obtain low-frequency intent data.
高频意图分类模型可以包括依次连接的预训练的语言模型、多层感知机以及归一化指数函数,即Softmax函数。预训练的语言模型的输出为多层感知机的输入;多层感知机的输出为归一化指数函数的输入。 The high-frequency intent classification model may include a pre-trained language model, a multi-layer perceptron, and a normalized exponential function, i.e., a Softmax function, which are connected in sequence. The output of the pre-trained language model is the input of the multi-layer perceptron; and the output of the multi-layer perceptron is the input of the normalized exponential function.
预训练的语言模型包括且不限于:BERT(Bidirectional Encoder Representations from Transformers,基于Transformer的双向编码)模型,或者,RoBERTa(a Robustly Optimized BERT Pretraining Approach,一种稳健优化的BERT预训练方法)模型,等等。Pre-trained language models include but are not limited to: BERT (Bidirectional Encoder Representations from Transformers) model, or RoBERTa (a Robustly Optimized BERT Pretraining Approach), etc.
其中,BERT模型是一种语言表征模型,用Transformer(变换模型)的双向编码器表示,BERT模型的训练过程可以分为预训练部分和模型微调部分,其中模型微调部分使用预训练好的BERT模型进行模型微调训练,广泛的应用于文本分类,文本匹配等任务。Among them, the BERT model is a language representation model, represented by the bidirectional encoder of Transformer (transformation model). The training process of the BERT model can be divided into a pre-training part and a model fine-tuning part. The model fine-tuning part uses the pre-trained BERT model for model fine-tuning training, which is widely used in text classification, text matching and other tasks.
预训练和模型微调可以通过如下示例来说明:假设已有A训练集,先用A训练集对网络进行预训练,在A任务上学会网络参数,然后保存以备后用,当来一个新的任务B,采取相同的网络结构,网络参数初始化的时候可以加载A学习好的参数,其他的高层参数随机初始化,之后用B任务的训练数据来训练网络,当加载的参数随着B任务的训练进行不断地改变,称为“fine-tuning(微调)”,即更好地把参数调整使得更适合当前的B任务。Pre-training and model fine-tuning can be illustrated by the following example: assuming that there is a training set A, the network is first pre-trained with training set A, the network parameters are learned on task A, and then saved for later use. When a new task B comes, the same network structure is adopted. When the network parameters are initialized, the parameters learned in A can be loaded, and other high-level parameters are randomly initialized. Then, the training data of task B is used to train the network. When the loaded parameters are constantly changed as the training of task B progresses, it is called "fine-tuning", that is, the parameters are adjusted to make them more suitable for the current task B.
RoBERTa模型和BERT模型类似,主要是在BERT基础上做了几点调整:1)训练时间更长,批尺寸(batch size)更大,训练数据更多;2)移除了下一次预测损失(next predict loss);3)训练序列更长;4)动态调整掩码机制。因其在诸多场景下比BERT模型效果更好而广泛应用在NLP(Natural Language Processing,自然语言处理)任务中。The RoBERTa model is similar to the BERT model, with several adjustments based on BERT: 1) longer training time, larger batch size, and more training data; 2) removal of the next prediction loss; 3) longer training sequences; 4) dynamic adjustment of the mask mechanism. It is widely used in NLP (Natural Language Processing) tasks because it performs better than the BERT model in many scenarios.
通过设置高频意图分类模型包括依次连接的预训练的语言模型、多层感知机以及Softmax函数,可以实现对预训练的语言模型的模型微调,该训练方式下,当用于训练模型的样本数量较多时,模型的训练效果较好。由于日志数据的数据量极大且易获得,故高频意图分类模型的训练数据易获得,进而高频意图分类模型的训练效果较好,对高频意图的意图识别结果的准确率较高。By setting the high-frequency intent classification model to include a pre-trained language model, a multi-layer perceptron, and a Softmax function connected in sequence, the model fine-tuning of the pre-trained language model can be achieved. Under this training method, when the number of samples used to train the model is large, the model training effect is better. Since the amount of log data is very large and easy to obtain, the training data of the high-frequency intent classification model is easy to obtain, and thus the training effect of the high-frequency intent classification model is better, and the accuracy of the intent recognition results for high-frequency intents is higher.
通过高频意图分类模型,可以根据日志数据中文本的意图识别结果对日 志数据进行意图分类处理,得到意图分类结果为预设高频意图的第一日志数据以及第一日志数据的意图分类结果的置信度。Through the high-frequency intent classification model, the log data can be classified according to the intent recognition results of the text in the log data. The intent classification process is performed on the log data to obtain the first log data whose intent classification result is a preset high-frequency intent and the confidence level of the intent classification result of the first log data.
第一日志数据可以是日志数据中的一条记录,第一日志数据可以包括一个文本以及该文本的意图识别结果。具体地,第一日志数据可以包括一个客户提出的问题文本以及该问题文本的意图识别结果。The first log data may be a record in the log data, and the first log data may include a text and an intention recognition result of the text. Specifically, the first log data may include a question text raised by a customer and an intention recognition result of the question text.
意图分类结果的置信度可以用于表征意图分类结果的准确性。置信度越高,说明意图分类结果的准确性越高。The confidence of the intent classification result can be used to characterize the accuracy of the intent classification result. The higher the confidence, the higher the accuracy of the intent classification result.
预设高频意图可以包括多种预设的出现频度较高的意图,例如,“客户咨询预设问题1”,“客户咨询预设问题2”,“客户投诉”,等等。则意图分类结果为预设高频意图可以是,意图分类结果为多种预设的出现频度较高的意图中的一者。The preset high-frequency intent may include multiple preset high-frequency intents, for example, "customer consultation preset question 1", "customer consultation preset question 2", "customer complaint", etc. Then the intent classification result as the preset high-frequency intent may be that the intent classification result is one of the multiple preset high-frequency intents.
在一种实施方式中,根据第一日志数据和第一日志数据的意图分类结果的置信度,对日志数据进行数据筛选处理,得到低频意图数据,包括:根据第一日志数据的意图分类结果的置信度与预设置信度阈值的比较结果,确定高频意图数据;将日志数据中的高频意图数据删除,得到低频意图数据。In one embodiment, based on the first log data and the confidence of the intent classification result of the first log data, the log data is screened to obtain low-frequency intent data, including: determining high-frequency intent data based on a comparison result of the confidence of the intent classification result of the first log data and a preset confidence threshold; and deleting the high-frequency intent data in the log data to obtain low-frequency intent data.
若第一日志数据的意图分类结果的置信度大于预设置信度阈值,说明第一日志数据的意图分类结果的准确性较高,可以将第一日志数据确定为高频意图数据。If the confidence of the intent classification result of the first log data is greater than a preset confidence threshold, it means that the accuracy of the intent classification result of the first log data is high, and the first log data can be determined as high-frequency intent data.
若第一日志数据的意图分类结果的置信度小于等于预设置信度阈值,说明第一日志数据的意图分类结果的准确性较低,可以认为第一日志数据不属于高频意图数据。通过设置置信度阈值,可以从日志数据中较为精确地筛选出高频意图数据。If the confidence of the intent classification result of the first log data is less than or equal to the preset confidence threshold, it means that the accuracy of the intent classification result of the first log data is low, and it can be considered that the first log data does not belong to high-frequency intent data. By setting the confidence threshold, high-frequency intent data can be more accurately screened out from the log data.
将日志数据中的高频意图数据删除,得到低频意图数据。需要注意的是,此处的低频意图数据不是出现频度较低的意图数据,而是日志数据中除高频意图数据外的意图数据。The high-frequency intent data in the log data is deleted to obtain the low-frequency intent data. It should be noted that the low-frequency intent data here is not the intent data with a low frequency of occurrence, but the intent data in the log data except the high-frequency intent data.
例如,日志数据包括5条记录:记录1、记录2、记录3、记录4以及记 录5,其中,记录1、记录3以及记录4为高频意图数据,则将日志数据中的记录1、记录3以及记录4删除,得到记录2和记录5,将记录2和记录5确定为低频意图数据。For example, the log data includes 5 records: record 1, record 2, record 3, record 4, and record Record 5, among which record 1, record 3 and record 4 are high-frequency intention data, then delete record 1, record 3 and record 4 in the log data to obtain record 2 and record 5, and determine record 2 and record 5 as low-frequency intention data.
步骤S106,将低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到低频意图数据对应的文本对比结果;文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;训练样本集基于低频意图数据构建。Step S106, input the low-frequency intent data and the standard text of the preset intent category into the text comparison model for similarity prediction processing to obtain the text comparison result corresponding to the low-frequency intent data; the text comparison model is a model obtained by training the initial text comparison model based on the training sample set; the training sample set is constructed based on the low-frequency intent data.
在步骤S106执行之前,可以将低频意图数据输入初始文本对比模型,对初始文本对比模型进行训练,得到文本对比模型。Before executing step S106, low-frequency intent data may be input into an initial text comparison model, and the initial text comparison model may be trained to obtain a text comparison model.
初始文本对比模型可以是各个待训练参数均取初始值的待训练模型。The initial text comparison model may be a model to be trained in which all parameters to be trained take initial values.
文本对比模型可以是对比无监督学习模型。The text contrast model can be a contrastive unsupervised learning model.
日志数据中的低频意图数据是无法利用现有模型标签的。此处可以将低频意图数据当无标签数据处理。The low-frequency intent data in the log data cannot use the existing model labels. Here, the low-frequency intent data can be treated as unlabeled data.
自监督学习(Self-supervised Learning)属于无监督学习范式的一种,特点是不需要人工标注的类别标签信息,直接利用数据本身作为监督信息,来学习样本数据的特征表达,并用于下游任务。Self-supervised learning is a type of unsupervised learning paradigm. It does not require manually labeled category label information, but directly uses the data itself as supervision information to learn the feature expression of sample data and use it for downstream tasks.
对比学习(Contrastive Learning)是自监督学习的一种,是通过将数据分别与正例样本和负例样本在特征空间进行对比,来学习样本的特征表示。其训练的核心是拉近相似样本的距离,拉远不相干样本的距离。Contrastive Learning is a type of self-supervised learning that learns the feature representation of samples by comparing data with positive samples and negative samples in feature space. The core of its training is to shorten the distance between similar samples and increase the distance between irrelevant samples.
对比学习的主要思想是拉近相似样本,推开非相似样本,即构建相似样本对(xi,xi +)和非相似样本对(xi,xj +)。The main idea of contrastive learning is to bring similar samples closer and push dissimilar samples away, that is, to construct similar sample pairs ( xi , xj + ) and dissimilar sample pairs ( xi , xj + ).
可以将低频意图数据确定为无标签样本;将无标签样本输入初始文本对比模型,对初始文本对比模型进行迭代训练,得到文本对比模型。Low-frequency intent data can be determined as unlabeled samples; the unlabeled samples are input into the initial text comparison model, and the initial text comparison model is iteratively trained to obtain a text comparison model.
在一种实施方式中,初始文本对比模型包括依次连接的编码器和相似度预测模块;编码器的输出为相似度预测模块的输入;编码器用于根据低频意图数据进行编码处理,得到低频意图数据对应的相似样本对和非相似样本对; 相似度预测模块用于根据低频意图数据对应的相似样本对和非相似样本对进行迭代训练。In one embodiment, the initial text comparison model includes an encoder and a similarity prediction module connected in sequence; the output of the encoder is the input of the similarity prediction module; the encoder is used to perform encoding processing according to the low-frequency intent data to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intent data; The similarity prediction module is used to perform iterative training based on similar sample pairs and non-similar sample pairs corresponding to low-frequency intent data.
初始文本对比模型包括依次连接的编码器和相似度预测模块;编码器的输出为相似度预测模块的输入;样本生成方法还包括:编码器根据低频意图数据进行编码处理,得到低频意图数据对应的相似样本对和非相似样本对;相似度预测模块根据低频意图数据对应的相似样本对和非相似样本对进行迭代训练。The initial text comparison model includes an encoder and a similarity prediction module connected in sequence; the output of the encoder is the input of the similarity prediction module; the sample generation method also includes: the encoder performs encoding processing based on the low-frequency intent data to obtain similar sample pairs and dissimilar sample pairs corresponding to the low-frequency intent data; the similarity prediction module performs iterative training based on the similar sample pairs and dissimilar sample pairs corresponding to the low-frequency intent data.
在构建正非相似样本对的时候,采用这样一种策略:利用编码器的随机失活(dropout)机制,基于目标记录中的问题文本,生成该问题文本对应的两个文本,该两个文本的语义完全相同,编码形式不同。进而可以将该两个文本确定为目标记录对应的相似文本对。另外,基于低频意图数据中除目标记录外的每条记录中的问题文本,生成该问题文本对应的一个文本。进而可以基于每条记录中的问题文本对应的一个文本与前述的目标记录中的问题文本对应的两个文本中的一者,生成多个非相似文本对。When constructing positive non-similar sample pairs, the following strategy is adopted: using the random deactivation (dropout) mechanism of the encoder, based on the question text in the target record, two texts corresponding to the question text are generated, the semantics of the two texts are exactly the same, and the encoding forms are different. Then, the two texts can be determined as similar text pairs corresponding to the target record. In addition, based on the question text in each record except the target record in the low-frequency intent data, a text corresponding to the question text is generated. Then, based on a text corresponding to the question text in each record and one of the two texts corresponding to the question text in the aforementioned target record, multiple non-similar text pairs can be generated.
以低频意图数据所包括的记录数量batchsize=64为例,一个batchsize中有2个相似样本,62个非相似样本,形成1个相似样本对,62个非相似样本对。Taking batchsize=64, the number of records included in the low-frequency intent data, as an example, there are 2 similar samples and 62 non-similar samples in one batchsize, forming 1 similar sample pair and 62 non-similar sample pairs.
进而根据低频意图数据对应的相似样本对和非相似样本,可以对相似度预测模块进行迭代训练。Then, based on the similar sample pairs and non-similar samples corresponding to the low-frequency intent data, the similarity prediction module can be iteratively trained.
示例性地,损失函数如下所示。
Exemplarily, the loss function is as follows.
其中,li用于表示损失函数值。τ用于表示softmax的温度超参,仅用来控制预测的随机性。hi和hi +和hj +分别是相似样本对(xi,xi +)和非相似样本对(xi,xj +)中的xi、xi +以及xj +的编码表示。N可以是预设数值。i和j的取值可 以基于相似样本对和非相似样本对的角标确定。
Where, l i is used to represent the loss function value. τ is used to represent the temperature hyperparameter of softmax, which is only used to control the randomness of the prediction. h i and h i + and h j + are the encoding representations of x i , x i + and x j + in the similar sample pair (x i , x i + ) and the non-similar sample pair (x i , x j + ) respectively. N can be a preset value. The values of i and j can be Determined based on the corner marks of similar sample pairs and non-similar sample pairs.
Sim(h1,h2)可以用于表示两个向量h1与h2的相似度。相似度可以采用余弦相似来计算。Sim(h 1 , h 2 ) can be used to represent the similarity between two vectors h 1 and h 2. The similarity can be calculated using cosine similarity.
在每次迭代训练之后都可以计算得到该次训练对应的损失函数值,若损失函数值小于等于预设阈值,则停止训练,得到训练完成的相似度预测模块,即得到训练完成的文本对比模型。After each iterative training, the loss function value corresponding to the training can be calculated. If the loss function value is less than or equal to the preset threshold, the training is stopped to obtain a trained similarity prediction module, that is, a trained text comparison model.
通过以上的方法,即可得到一个训练完成的文本对比模型,其意义在于可以基于无标签样本进行模型训练,使得训练完成的文本对比模型具有判断两个文本是否是相似的能力,由于日志数据是一种可以随着时间变化而不断扩充的历史数据,在时间跨度足够长的情况下,日志数据的数据量很大且易获得,故用于训练文本对比模型的低频意图数据的数据量很大,采用无监督学习亦可达到相对优良的效果。Through the above method, a trained text comparison model can be obtained. Its significance lies in that the model training can be based on unlabeled samples, so that the trained text comparison model has the ability to judge whether two texts are similar. Since log data is a kind of historical data that can be continuously expanded with time, when the time span is long enough, the amount of log data is large and easy to obtain. Therefore, the amount of low-frequency intent data used to train the text comparison model is large, and unsupervised learning can also achieve relatively good results.
在一种实施方式中,低频意图数据包括目标文本和非目标文本;编码器具体用于:根据目标文本进行编码处理,得到目标文本对应的目标编码结果和相似编码结果,以及,根据非目标文本进行编码处理,得到非目标文本对应的编码结果;将目标文本对应的目标编码结果和相似编码结果确定为低频意图数据对应的相似样本对;将目标文本对应的目标编码结果和非目标文本对应的编码结果确定为低频意图数据对应的非相似样本对。In one embodiment, the low-frequency intent data includes target text and non-target text; the encoder is specifically used to: perform encoding processing according to the target text to obtain a target encoding result and a similar encoding result corresponding to the target text, and perform encoding processing according to the non-target text to obtain an encoding result corresponding to the non-target text; determine the target encoding result and the similar encoding result corresponding to the target text as similar sample pairs corresponding to the low-frequency intent data; determine the target encoding result corresponding to the target text and the encoding result corresponding to the non-target text as non-similar sample pairs corresponding to the low-frequency intent data.
低频意图数据包括目标文本和非目标文本;样本生成方法还包括:编码器根据目标文本进行编码处理,得到目标文本对应的目标编码结果和相似编码结果,以及,根据非目标文本进行编码处理,得到非目标文本对应的编码结果;将目标文本对应的目标编码结果和相似编码结果确定为低频意图数据对应的相似样本对;将目标文本对应的目标编码结果和非目标文本对应的编码结果确定为低频意图数据对应的非相似样本对。The low-frequency intent data includes target text and non-target text; the sample generation method also includes: the encoder performs encoding processing according to the target text to obtain a target encoding result and a similar encoding result corresponding to the target text, and performs encoding processing according to the non-target text to obtain an encoding result corresponding to the non-target text; the target encoding result and the similar encoding result corresponding to the target text are determined as similar sample pairs corresponding to the low-frequency intent data; the target encoding result corresponding to the target text and the encoding result corresponding to the non-target text are determined as non-similar sample pairs corresponding to the low-frequency intent data.
低频意图数据包括目标文本和非目标文本。目标文本的数量可以是一个。 非目标文本的数量可以是一个也可以是多个。例如,低频意图数据包括记录1、记录2、记录3、记录4以及记录5。其中,记录1包括目标文本和目标文本的意图识别结果;记录2包括非目标文本1和非目标文本1的意图识别结果;记录3包括非目标文本2和非目标文本2的意图识别结果;记录4包括非目标文本3和非目标文本3的意图识别结果;记录5包括非目标文本4和非目标文本4的意图识别结果。The low-frequency intent data includes target text and non-target text. The number of target texts can be one. The number of non-target texts can be one or more. For example, the low-frequency intent data includes record 1, record 2, record 3, record 4, and record 5. Among them, record 1 includes the target text and the intent recognition result of the target text; record 2 includes non-target text 1 and the intent recognition result of non-target text 1; record 3 includes non-target text 2 and the intent recognition result of non-target text 2; record 4 includes non-target text 3 and the intent recognition result of non-target text 3; record 5 includes non-target text 4 and the intent recognition result of non-target text 4.
通过编码器可以对输入的低频意图数据中的记录1所包括的目标文本进行编码处理,得到目标文本对应的目标编码结果和相似编码结果,以及,同一时间,可以通过编码器对输入的低频意图数据中的记录2-5所包括的非目标文本1-4进行编码处理,得到非目标文本1-4对应的编码结果。The target text included in record 1 in the input low-frequency intent data can be encoded by the encoder to obtain the target encoding result and similar encoding result corresponding to the target text. At the same time, the non-target texts 1-4 included in records 2-5 in the input low-frequency intent data can be encoded by the encoder to obtain the encoding results corresponding to the non-target texts 1-4.
接着,可以将记录1对应的目标编码结果和相似编码结果确定为低频意图数据对应的相似样本对,将记录1对应的目标编码结果和记录2对应的编码结果确定为一个非相似样本对,将记录1对应的目标编码结果和记录3对应的编码结果确定为一个非相似样本对,将记录1对应的目标编码结果和记录4对应的编码结果确定为一个非相似样本对,将记录1对应的目标编码结果和记录5对应的编码结果确定为一个非相似样本对。综上共生成了一个相似样本对和4个非相似样本对。Next, the target encoding result and the similar encoding result corresponding to record 1 can be determined as similar sample pairs corresponding to low-frequency intent data, the target encoding result corresponding to record 1 and the encoding result corresponding to record 2 can be determined as a non-similar sample pair, the target encoding result corresponding to record 1 and the encoding result corresponding to record 3 can be determined as a non-similar sample pair, the target encoding result corresponding to record 1 and the encoding result corresponding to record 4 can be determined as a non-similar sample pair, and the target encoding result corresponding to record 1 and the encoding result corresponding to record 5 can be determined as a non-similar sample pair. In summary, a similar sample pair and four non-similar sample pairs are generated.
在一种实施方式中,编码器包括依次连接的注意力层和全连接层;注意力层的输出为全连接层的输入;注意力层用于根据预设的第一随机失活概率和低频意图数据进行第一编码处理,得到中间编码数据;全连接层用于根据预设的第二随机失活概率和中间编码数据进行转换处理,得到低频意图数据对应的相似样本对和非相似样本对。In one embodiment, the encoder includes an attention layer and a fully connected layer connected in sequence; the output of the attention layer is the input of the fully connected layer; the attention layer is used to perform a first encoding process according to a preset first random inactivation probability and low-frequency intent data to obtain intermediate encoded data; the fully connected layer is used to perform a conversion process according to a preset second random inactivation probability and the intermediate encoded data to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intent data.
所述编码器包括依次连接的注意力层和全连接层;所述注意力层的输出为所述全连接层的输入;样本生成方法还包括:所述注意力层根据预设的第一随机失活概率和所述低频意图数据进行第一编码处理,得到中间编码数据;所述全连接层根据预设的第二随机失活概率和所述中间编码数据进行转换处 理,得到所述低频意图数据对应的相似样本对和非相似样本对。The encoder includes an attention layer and a fully connected layer connected in sequence; the output of the attention layer is the input of the fully connected layer; the sample generation method also includes: the attention layer performs a first encoding process according to a preset first random inactivation probability and the low-frequency intention data to obtain intermediate encoded data; the fully connected layer performs a conversion process according to a preset second random inactivation probability and the intermediate encoded data Processing is performed to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intent data.
具体实施时,可以预先配置注意力层的第一随机失活概率,以及,可以预先配置全连接层的第二随机失活概率。In a specific implementation, the first random deactivation probability of the attention layer can be pre-configured, and the second random deactivation probability of the fully connected layer can be pre-configured.
第一随机失活概率的作用将在transformer的每一层都产生作用,从而得到同一份文本的两个不同的语义表示,将同一份文本输入两次,则得到两个语义完全相同的相似样本对。The effect of the first random inactivation probability will take effect on each layer of the transformer, thereby obtaining two different semantic representations of the same text. By inputting the same text twice, two similar sample pairs with exactly the same semantics will be obtained.
另外,因为相似样本对的长度必定一致,而非相似样本对的长度却不相同,为了消除模型将文本长度作为数据特征从而带来的影响,在训练时采取标点符号填充的方式进行长度扩充,因为逗号的语义特征最小,近乎忽略不计,所以采用将逗号随机插入的方法加入到相对较短的文本中,弥补长度差距带来的影响。In addition, because the lengths of similar sample pairs must be consistent, while the lengths of non-similar sample pairs are different, in order to eliminate the impact of the model using text length as a data feature, punctuation padding is used to expand the length during training. Because the semantic features of commas are the smallest and almost negligible, commas are randomly inserted into relatively short texts to make up for the impact of the length difference.
根据以上内容,可知本申请的一些实施方式中,样本生成方法还包括:在非相似样本对的文本长度不同的情况下,通过标点符号对非相似样本对中文本长度较短的文本进行长度扩充处理。Based on the above, it can be known that in some embodiments of the present application, the sample generation method further includes: when the text lengths of non-similar sample pairs are different, the length of the shorter text in the non-similar sample pairs is extended by punctuation marks.
在获得文本对比模型后,先确定需要召回的预设意图类别,该预设意图类别可以是一种或多种低频意图类别。After obtaining the text comparison model, first determine the preset intent category that needs to be recalled. The preset intent category may be one or more low-frequency intent categories.
在一种实施方式中,低频意图数据包括多个低频意图文本;文本对比模型,具体用于:将每个低频意图文本和预设意图类别的标准文本确定为每个低频意图文本对应的相似样本对;对每个低频意图文本对应的相似样本对进行相似度预测处理,得到每个低频意图文本的相似度评分;将每个低频意图文本的相似度评分确定为低频意图数据对应的文本对比结果。In one embodiment, the low-frequency intent data includes multiple low-frequency intent texts; the text comparison model is specifically used to: determine each low-frequency intent text and a standard text of a preset intent category as a similar sample pair corresponding to each low-frequency intent text; perform similarity prediction processing on the similar sample pairs corresponding to each low-frequency intent text to obtain a similarity score for each low-frequency intent text; and determine the similarity score of each low-frequency intent text as the text comparison result corresponding to the low-frequency intent data.
低频意图数据包括多个低频意图文本;样本生成方法还包括:文本对比模型将每个低频意图文本和预设意图类别的标准文本确定为每个低频意图文本对应的相似样本对;对每个低频意图文本对应的相似样本对进行相似度预测处理,得到每个低频意图文本的相似度评分;将每个低频意图文本的相似度评分确定为低频意图数据对应的文本对比结果。 The low-frequency intent data includes multiple low-frequency intent texts; the sample generation method also includes: the text comparison model determines each low-frequency intent text and the standard text of the preset intent category as a similar sample pair corresponding to each low-frequency intent text; performs similarity prediction processing on the similar sample pairs corresponding to each low-frequency intent text to obtain a similarity score for each low-frequency intent text; and determines the similarity score of each low-frequency intent text as the text comparison result corresponding to the low-frequency intent data.
将每个低频意图文本和预设意图类别的标准文本确定为每个低频意图文本对应的相似样本对。对于每个预设意图类别,将其中的一个或多个标准问作为文本对比模型输入的xi文本,遍历低频意图数据作为xi+,以形成(xi,xi+)数据对进行预测。预测结果为一个0-1的相似度打分。Each low-frequency intent text and the standard text of the preset intent category are determined as similar sample pairs corresponding to each low-frequency intent text. For each preset intent category, one or more standard questions are used as the xi text input to the text comparison model, and the low-frequency intent data is traversed as xi+ to form (xi, xi+) data pairs for prediction. The prediction result is a similarity score of 0-1.
对每个低频意图文本对应的相似样本对进行相似度预测处理,得到每个低频意图文本的相似度评分;将每个低频意图文本的相似度评分确定为低频意图数据对应的文本对比结果。Perform similarity prediction processing on similar sample pairs corresponding to each low-frequency intent text to obtain a similarity score for each low-frequency intent text; determine the similarity score for each low-frequency intent text as a text comparison result corresponding to the low-frequency intent data.
步骤S110,根据文本对比结果与预设相似度阈值,生成低频意图样本。Step S110, generating a low-frequency intent sample according to the text comparison result and a preset similarity threshold.
预设相似度阈值可以是一个预设数值,预设相似度阈值可以基于预先配置的阈值变化规则进行一次或多次阈值更新。The preset similarity threshold may be a preset value, and the preset similarity threshold may be updated once or multiple times based on a pre-configured threshold change rule.
例如,预设相似度阈值可以是95%,阈值变化规则可以是每次进行阈值更新时,对当前的相似度阈值减去5%,得到更新后的相似度阈值。For example, the preset similarity threshold may be 95%, and the threshold change rule may be that each time the threshold is updated, 5% is subtracted from the current similarity threshold to obtain an updated similarity threshold.
根据文本对比结果与预设相似度阈值,生成低频意图样本,可以是将相似度评分小于预设相似度阈值的低频意图文本确定为低频意图样本,也可以是将相似度评分小于预设相似度阈值的低频意图文本确定为相似样本数据,对相似样本数据进行质检,将质检通过的相似样本数据确定为低频意图样本。相似样本数据用于表示需要进行质检以确定其是否为低频意图样本的候选样本数据。质检方式可以是人工质检,也可以是按照预设质检规则进行质检处理。According to the text comparison result and the preset similarity threshold, a low-frequency intent sample is generated. The low-frequency intent text with a similarity score less than the preset similarity threshold can be determined as a low-frequency intent sample, or the low-frequency intent text with a similarity score less than the preset similarity threshold can be determined as similar sample data, and the similar sample data is quality-checked, and the similar sample data that passes the quality check is determined as a low-frequency intent sample. The similar sample data is used to indicate candidate sample data that needs to be quality-checked to determine whether it is a low-frequency intent sample. The quality inspection method can be manual quality inspection or quality inspection processing according to preset quality inspection rules.
在一种实施方式中,根据文本对比结果与预设相似度阈值,生成低频意图样本,包括:根据预设相似度阈值与文本对比结果的比较结果,确定预设相似度阈值对应的相似样本数据的数量;若低频意图数据对应的相似样本数据的数量小于预设数量阈值,则将当前的相似度阈值减去预设降低值以得到更新的相似度阈值,以及,根据更新的相似度阈值与文本对比结果的比较结果,确定更新的相似度阈值对应的相似样本数据的更新后的数量,根据所述更新后的数量与所述预设数量阈值重复上述操作,直至更新的相似度阈值满 足预设停止条件;预设停止条件为样本数量大于等于预设数量阈值;样本数量为预设相似度阈值对应的相似样本数据的数量与各个更新的相似度阈值对应的相似样本数据的数量之和;将预设相似度阈值对应的相似样本数据和各个更新的相似度阈值对应的相似样本数据中的每个样本数据确定为每个样本数据对应的低频意图样本。In one embodiment, a low-frequency intent sample is generated according to a text comparison result and a preset similarity threshold, including: determining the number of similar sample data corresponding to the preset similarity threshold according to a comparison result of the preset similarity threshold and the text comparison result; if the number of similar sample data corresponding to the low-frequency intent data is less than the preset number threshold, subtracting a preset reduction value from the current similarity threshold to obtain an updated similarity threshold, and determining an updated number of similar sample data corresponding to the updated similarity threshold according to a comparison result of the updated similarity threshold and the text comparison result, repeating the above operation according to the updated number and the preset number threshold until the updated similarity threshold is met. The preset stopping condition is met; the preset stopping condition is that the number of samples is greater than or equal to the preset number threshold; the number of samples is the sum of the number of similar sample data corresponding to the preset similarity threshold and the number of similar sample data corresponding to each updated similarity threshold; each sample data in the similar sample data corresponding to the preset similarity threshold and the similar sample data corresponding to each updated similarity threshold is determined as a low-frequency intention sample corresponding to each sample data.
根据文本对比结果与预设相似度阈值,生成低频意图样本,包括:根据预设相似度阈值与文本对比结果的比较结果,确定预设相似度阈值对应的相似样本数据的数量;若低频意图数据对应的相似样本数据的数量小于预设数量阈值,则将当前的相似度阈值减去预设降低值以得到更新的相似度阈值,以及,根据更新的相似度阈值与文本对比结果的比较结果,确定更新的相似度阈值对应的相似样本数据的更新的数量,若样本数量大于等于预设数量阈值,则确定预设相似度阈值对应的相似样本数据的数量为最终的更新的数量。According to the text comparison result and the preset similarity threshold, a low-frequency intent sample is generated, including: according to the comparison result of the preset similarity threshold and the text comparison result, the number of similar sample data corresponding to the preset similarity threshold is determined; if the number of similar sample data corresponding to the low-frequency intent data is less than the preset number threshold, the current similarity threshold is subtracted from the preset reduction value to obtain an updated similarity threshold, and, according to the comparison result of the updated similarity threshold and the text comparison result, the updated number of similar sample data corresponding to the updated similarity threshold is determined; if the sample number is greater than or equal to the preset number threshold, the number of similar sample data corresponding to the preset similarity threshold is determined as the final updated number.
例如,预设数量阈值为100,预设相似度阈值的初始值为99%,根据99%与文本对比结果的比较结果,确定99%对应的相似样本数据的数量为10个,小于预设数量阈值100,则进行一次阈值更新:当前的预设相似度阈值为99%,减去预设降低值5%以得到更新后的相似度阈值94%,以及,根据94%与文本对比结果的比较结果,确定94%对应的相似样本数据的数量为30个,10+30=40,40小于预设数量阈值100,则进行一次阈值更新;当前的相似度阈值为94%,减去预设降低值5%以得到更新后的相似度阈值89%,以及,根据89%与文本对比结果的比较结果,确定89%对应的相似样本数据的数量为70个,10+30+70=110>100,满足预设停止条件,不再进行阈值更新。进而,可以将该110个相似样本数据中的每个样本数据确定为一个低频意图样本。For example, the preset number threshold is 100, the initial value of the preset similarity threshold is 99%, and according to the comparison result between 99% and the text comparison result, the number of similar sample data corresponding to 99% is determined to be 10, which is less than the preset number threshold 100, and then a threshold update is performed: the current preset similarity threshold is 99%, minus the preset reduction value of 5% to obtain the updated similarity threshold 94%, and according to the comparison result between 94% and the text comparison result, the number of similar sample data corresponding to 94% is determined to be 30, 10+30=40, 40 is less than the preset number threshold 100, and then a threshold update is performed; the current similarity threshold is 94%, minus the preset reduction value of 5% to obtain the updated similarity threshold 89%, and according to the comparison result between 89% and the text comparison result, the number of similar sample data corresponding to 89% is determined to be 70, 10+30+70=110>100, which meets the preset stop condition and no longer performs the threshold update. Furthermore, each sample data in the 110 similar sample data can be determined as a low-frequency intention sample.
预设相似度阈值的初始值可以数值较高,例如,95%。初始时将阈值设高,严格的召回候选数据并进行质检,将合格的数据作为此低频意图的标准问对应的相似问数据。当高阈值下的相似问数据被全部打标分析后,逐步降 低预设相似度阈值,逐步召回新的候选数据供进行质检,并且排除掉已经质检过的数据;重复以上工作,获取低频意图的相似问数据。The initial value of the preset similarity threshold can be relatively high, for example, 95%. Initially, the threshold is set high, candidate data is strictly recalled and quality checked, and qualified data is used as similar question data corresponding to the standard question of this low-frequency intent. When all similar question data under the high threshold are marked and analyzed, the threshold is gradually reduced. Set a low preset similarity threshold, gradually recall new candidate data for quality inspection, and exclude the data that has been quality inspected; repeat the above work to obtain similar question data with low-frequency intent.
通过重复执行将当前的相似度阈值减去预设降低值以得到更新的相似度阈值,以及,根据更新的相似度阈值与文本对比结果的比较结果,确定更新的相似度阈值对应的相似样本数据的数量的操作,直至更新的相似度阈值满足预设停止条件的操作,直至更新的相似度阈值满足预设停止条件,可以减少质检的工作量,提高质检效率。By repeatedly performing the operation of subtracting a preset reduction value from a current similarity threshold to obtain an updated similarity threshold, and determining the number of similar sample data corresponding to the updated similarity threshold based on a comparison result between the updated similarity threshold and a text comparison result, until the updated similarity threshold satisfies a preset stop condition, the workload of quality inspection can be reduced and the efficiency of quality inspection can be improved.
由于日志数据可以随着时间变化不断扩增,则低频意图样本的数量也可以随着日志数据的扩增而不断增加。基于海量的日志数据和文本对比模型可以累计得到预设意图类别的大量样本,该预设意图类别可以是一种低频意图的意图类别。在预设意图类别的低频意图样本的数量足够多的情况下,可以基于该预设意图类别的低频意图样本对初始意图识别模型进行训练,得到意图识别模型,且该意图识别模型对于预设意图类别的低频意图的识别准确率较高。Since log data can continue to increase over time, the number of low-frequency intent samples can also continue to increase with the expansion of log data. Based on massive log data and text comparison models, a large number of samples of preset intent categories can be accumulated, and the preset intent category can be an intent category of low-frequency intent. When the number of low-frequency intent samples of the preset intent category is large enough, the initial intent recognition model can be trained based on the low-frequency intent samples of the preset intent category to obtain an intent recognition model, and the intent recognition model has a high recognition accuracy for low-frequency intents of the preset intent category.
在机器人自动应答的场景中,机器人坐席可以基于训练后的意图识别模型对文本进行意图识别,该意图识别模型可以是利用图1实施例所提供的样本生成方法生成的低频意图样本对初始意图识别模型进行训练之后所得到的意图识别模型,由于低频意图样本的数量足够多,该意图识别模型的训练效果较好,机器人坐席利用该意图识别模型可以准确地识别用户的低频意图,进而可以基于准确识别的低频意图对用户做出恰当的应答,提高了用户的满意度。In the scenario where the robot automatically answers, the robot agent can recognize the intent of the text based on the trained intent recognition model. The intent recognition model can be an intent recognition model obtained after training the initial intent recognition model with low-frequency intent samples generated by the sample generation method provided in the embodiment of Figure 1. Since the number of low-frequency intent samples is large enough, the training effect of the intent recognition model is good. The robot agent can use the intent recognition model to accurately identify the user's low-frequency intentions, and then make appropriate responses to the user based on the accurately identified low-frequency intentions, thereby improving user satisfaction.
在如图1所示的实施例中,首先,获取待处理的日志数据;日志数据包括文本和文本的意图识别结果;其次,根据文本的意图识别结果,对日志数据进行数据筛选处理,得到低频意图数据;然后,将低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到低频意图数据对应的文本对比结果;文本对比模型为基于训练样本集对初始文本对比模 型进行训练所得到的模型;训练样本集基于低频意图数据构建;最后,根据文本对比结果与预设相似度阈值,生成低频意图样本。日志数据是一种随着时间变化不断增长的历史数据。即便低频意图数据在日志数据中的出现频率较低,在日志数据所对应的时间跨度足够长的情况下,可以从日志数据中筛选得到累计的大量低频意图数据,基于该大量低频意图数据可以生成数量足够用于训练初始文本对比模型的训练数据,且训练数据的数量可以随着日志数据的时间跨度增长而不断扩增。因此,在训练数据的数量足够多的情况下,通过训练后得到的文本对比模型进行相似度预测时的预测结果较为准确,进而,通过文本对比模型对低频意图数据和预设意图类别的标准文本进行相似度预测处理,可以确定低频意图数据中与预设意图类别的标准文本相似度较高的低频意图样本,在获取的日志数据随着时间变化不断增加的情况下,可以利用不断增长的日志数据和文本对比模型累计得到大量预设意图类别的低频意图样本,进而满足低频意图样本对应的意图识别模型的训练需求,提高低频意图的识别准确性。In the embodiment shown in FIG1 , first, log data to be processed is obtained; the log data includes text and intent recognition results of the text; secondly, according to the intent recognition results of the text, the log data is screened to obtain low-frequency intent data; then, the low-frequency intent data and standard text of a preset intent category are input into a text comparison model for similarity prediction processing to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a text comparison model based on an initial text comparison model of a training sample set. The model obtained by training the model; the training sample set is constructed based on the low-frequency intent data; finally, the low-frequency intent samples are generated according to the text comparison results and the preset similarity threshold. Log data is a kind of historical data that grows continuously over time. Even if the low-frequency intent data appears less frequently in the log data, if the time span corresponding to the log data is long enough, a large amount of accumulated low-frequency intent data can be screened from the log data. Based on this large amount of low-frequency intent data, a sufficient amount of training data can be generated for training the initial text comparison model, and the amount of training data can be continuously expanded as the time span of the log data increases. Therefore, when the amount of training data is large enough, the prediction results of the similarity prediction performed by the text comparison model obtained after training are relatively accurate. Furthermore, by performing similarity prediction processing on the low-frequency intent data and the standard text of the preset intent category through the text comparison model, the low-frequency intent samples with high similarity to the standard text of the preset intent category in the low-frequency intent data can be determined. When the acquired log data increases with time, a large number of low-frequency intent samples of the preset intent category can be accumulated by using the growing log data and the text comparison model, thereby meeting the training requirements of the intent recognition model corresponding to the low-frequency intent samples and improving the recognition accuracy of the low-frequency intent.
出于与图1的方法实施例相同的技术构思,本申请实施例还提供另一种样本生成方法。图2为本申请实施例提供的另一种样本生成方法的处理流程图。Based on the same technical concept as the method embodiment of FIG1 , the embodiment of the present application also provides another sample generation method. FIG2 is a processing flow chart of another sample generation method provided by the embodiment of the present application.
如图2所示,获取模型阶段包括步骤S202至步骤S204。As shown in FIG. 2 , the model acquisition stage includes steps S202 to S204 .
步骤S202,无监督对比学习训练。Step S202: unsupervised contrastive learning training.
步骤S202可以参照图1实施例中的“文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;训练样本集基于低频意图数据构建”的对应说明部分。Step S202 may refer to the corresponding description part of the embodiment of FIG. 1 in which “the text comparison model is a model obtained by training the initial text comparison model based on the training sample set; the training sample set is constructed based on low-frequency intent data”.
步骤S204,获得对比学习模型。Step S204, obtaining a comparative learning model.
召回数据阶段包括步骤S206至步骤S210。The data recall stage includes steps S206 to S210.
步骤S206,调整阈值精召回。Step S206, adjusting the threshold precision recall.
阈值可以是预设相似度阈值。步骤S206中的调整阈值可以是设置预设相 似度阈值的初始值。精召回可以是基于文本对比结果与预设相似度阈值的比较结果确定低频意图文本是否为待质检的相似样本数据。The threshold value may be a preset similarity threshold value. The adjustment threshold value in step S206 may be a preset similarity threshold value. The initial value of the similarity threshold. Precision recall can be based on the comparison result of the text comparison result and the preset similarity threshold to determine whether the low-frequency intent text is similar sample data to be inspected.
步骤S208,人工质检是否合格。Step S208: Manual quality inspection to see if it is qualified.
若合格,则结束人工质检,若不合格,则执行步骤S210。If qualified, the manual quality inspection ends; if unqualified, step S210 is executed.
步骤S210,调整阈值宽召回。Step S210, adjusting the threshold wide recall.
步骤S210中的调整阈值可以是将当前的相似度阈值减去预设降低值以得到更新的相似度阈值。宽召回可以是基于文本对比结果与当前的相似度阈值的比较结果确定低频意图文本是否为待质检的相似样本数据。The adjustment threshold in step S210 may be obtained by subtracting a preset reduction value from the current similarity threshold to obtain an updated similarity threshold. Wide recall may be determined based on the comparison result between the text comparison result and the current similarity threshold to determine whether the low-frequency intended text is similar sample data to be inspected.
步骤S206、步骤S208以及步骤S210可以参照图1实施例中的步骤S108的对应说明部分。For steps S206 , S208 and S210 , reference may be made to the corresponding description of step S108 in the embodiment of FIG. 1 .
出于与图1的方法实施例相同的技术构思,本申请实施例还提供一种文本对比模型的训练方法。图3为本申请实施例提供的一种文本对比模型的训练方式示意图。Based on the same technical concept as the method embodiment of Figure 1, the embodiment of the present application also provides a method for training a text contrast model. Figure 3 is a schematic diagram of a text contrast model training method provided by the embodiment of the present application.
如图3所示,一份Batchsize数据可以包括n个样本数据:样本数据1,即图3中的样本数据301,样本数据2,即图3中的样本数据302……样本数据n。n为大于0的自然数。将n个样本数据输入编码器303进行编码处理。编码器303可以基于样本数据301生成x样本304以及相似样本305,该x样本304和相似样本305是同一个样本数据通过不同方式编码后得到两个语义相同格式不同的样本。编码器303可以基于样本数据302生成非相似样本1,即图3中的非相似样本306……编码器303可以基于样本数据n生成非相似样本n。x样本304和相似样本305可以构成一个相似样本对。x样本304和非相似样本306可以构成一个非相似样本对。As shown in FIG3 , a batch size data may include n sample data: sample data 1, i.e., sample data 301 in FIG3 , sample data 2, i.e., sample data 302 in FIG3 , ... sample data n. n is a natural number greater than 0. The n sample data are input into the encoder 303 for encoding. The encoder 303 may generate an x sample 304 and a similar sample 305 based on the sample data 301. The x sample 304 and the similar sample 305 are two samples with the same semantics but different formats obtained after the same sample data is encoded in different ways. The encoder 303 may generate a non-similar sample 1 based on the sample data 302, i.e., a non-similar sample 306 in FIG3 , ... The encoder 303 may generate a non-similar sample n based on the sample data n. The x sample 304 and the similar sample 305 may constitute a similar sample pair. The x sample 304 and the non-similar sample 306 may constitute a non-similar sample pair.
基于相似样本对和多个非相似样本对,可以对初始文本对比模型进行迭代训练,得到文本对比模型。Based on similar sample pairs and multiple non-similar sample pairs, the initial text comparison model can be iteratively trained to obtain a text comparison model.
出于与图1的方法实施例相同的技术构思,本申请实施例还提供一种应用于机器人领域的样本生成方法。图4为本申请实施例提供的一种样本生成 方法的业务流程图。Based on the same technical concept as the method embodiment of FIG1 , the embodiment of the present application also provides a sample generation method applied to the field of robotics. Business process diagram of the method.
步骤S402,机器人上线。Step S402, the robot goes online.
机器人可以是具有自动应答能力的机器人,该机器人可以调用意图识别模型对文本进行意图识别,得到用户意图,进而根据用户意图进行自动应答。The robot may be a robot with automatic answering capability, which may call an intent recognition model to perform intent recognition on the text, obtain the user's intent, and then automatically answer based on the user's intent.
机器人上线可以是机器人进入工作状态,机器人在工作状态下可以针对获取的文本进行自动应答。The robot going online means that the robot enters a working state, and the robot can automatically respond to the obtained text in the working state.
步骤S404,日志分析。Step S404: log analysis.
日志可以是机器人的工作日志数据。日志包括且不限于:机器人所接收的待应答的文本,机器人对文本进行意图识别的记录数据,以及机器人的应答记录数据,等等。The log may be the work log data of the robot, including but not limited to: the text to be responded to received by the robot, the record data of the robot's intention recognition of the text, and the robot's response record data, etc.
步骤S406,算法工具召回相似问数据。Step S406: the algorithm tool recalls similar question data.
步骤S408,人工标注并质检。Step S408: manual labeling and quality inspection.
步骤S406以及步骤S408可以参照图1实施例的步骤S108的对应说明部分。For step S406 and step S408 , reference may be made to the corresponding description portion of step S108 in the embodiment of FIG. 1 .
步骤S410,新标数据加入模型,迭代训练。Step S410: Add new labeled data to the model and perform iterative training.
模型可以是意图识别模型,该意图识别模型可以用于识别文本是否包含低频意图。The model may be an intent recognition model, which may be used to recognize whether a text contains a low-frequency intent.
步骤S412,新机器人上线,继续迭代。Step S412: The new robot comes online and the iteration continues.
出于与上述各样本生成方法实施例相同的技术构思,本申请实施例还提供了一种意图识别模型的训练方法。图5为本申请实施例提供的一种意图识别模型的训练方法的处理流程图。Based on the same technical concept as the above-mentioned sample generation method embodiments, the present application embodiment also provides a method for training an intent recognition model. FIG5 is a processing flow chart of a method for training an intent recognition model provided by the present application embodiment.
步骤S502,通过样本生成方法生成低频意图样本。Step S502: Generate low-frequency intention samples through a sample generation method.
具体地,低频意图样本可以是通过本申请中前述的样本生成方法所生成的。Specifically, the low-frequency intention sample may be generated by the sample generation method described above in the present application.
步骤S504将低频意图样本输入初始意图识别模型进行迭代训练,得到意图识别模型。 Step S504 inputs the low-frequency intent samples into the initial intent recognition model for iterative training to obtain the intent recognition model.
初始意图识别模型可以是各个待训练参数均取初始值的尚未进行模型微调的低频意图分类模型。该低频意图分类模型可以是预训练的语言模型。预训练的语言模型包括且不限于:BERT(Bidirectional Encoder Representations from Transformers)模型,或者,RoBERTa(a Robustly Optimized BERT Pretraining Approach)模型,等等。The initial intent recognition model may be a low-frequency intent classification model in which all parameters to be trained take initial values and the model has not been fine-tuned. The low-frequency intent classification model may be a pre-trained language model. Pre-trained language models include but are not limited to: BERT (Bidirectional Encoder Representations from Transformers) model, or RoBERTa (a Robustly Optimized BERT Pretraining Approach) model, etc.
在进行迭代训练之后所得到的意图识别模型可以用于识别文本是否包含低频意图。The intent recognition model obtained after iterative training can be used to identify whether the text contains low-frequency intent.
在如图5所示的意图识别模型的训练方法实施例中,通过上述样本生成方法实施例所提供的样本生成方法生成低频意图样本;将低频意图样本输入初始意图识别模型进行迭代训练,得到意图识别模型。日志数据是一种随着时间变化不断增长的历史数据。即便低频意图数据在日志数据中的出现频率较低,在日志数据所对应的时间跨度足够长的情况下,可以从日志数据中筛选得到累计的大量低频意图数据,基于该大量低频意图数据可以生成数量足够用于训练初始文本对比模型的训练数据,且训练数据的数量可以随着日志数据的时间跨度增长而不断扩增。因此,在训练数据的数量足够多的情况下,通过训练后得到的文本对比模型进行相似度预测时的预测结果较为准确,进而,通过文本对比模型对低频意图数据和预设意图类别的标准文本进行相似度预测处理,可以确定低频意图数据中与预设意图类别的标准文本相似度较高的低频意图样本,在获取的日志数据随着时间变化不断增加的情况下,可以利用不断增长的日志数据和文本对比模型累计得到大量预设意图类别的低频意图样本,进而利用该预设意图类别的低频意图样本对初始意图识别模型进行迭代训练,可以取得较好的训练效果,使得训练之后得到的意图识别模型对低频意图的识别准确性较高。In the training method embodiment of the intent recognition model as shown in FIG5 , a low-frequency intent sample is generated by the sample generation method provided by the above-mentioned sample generation method embodiment; the low-frequency intent sample is input into the initial intent recognition model for iterative training to obtain the intent recognition model. Log data is a kind of historical data that continues to grow over time. Even if the frequency of occurrence of low-frequency intent data in the log data is low, if the time span corresponding to the log data is long enough, a large amount of accumulated low-frequency intent data can be screened from the log data, and based on the large amount of low-frequency intent data, a sufficient amount of training data can be generated for training the initial text comparison model, and the amount of training data can be continuously expanded as the time span of the log data increases. Therefore, when the amount of training data is large enough, the prediction results of similarity prediction performed by the text comparison model obtained after training are relatively accurate. Furthermore, by performing similarity prediction processing on the low-frequency intent data and the standard text of the preset intent category through the text comparison model, the low-frequency intent samples with high similarity to the standard text of the preset intent category in the low-frequency intent data can be determined. When the acquired log data increases with time, a large number of low-frequency intent samples of the preset intent category can be accumulated by using the growing log data and the text comparison model. Then, the initial intent recognition model can be iteratively trained using the low-frequency intent samples of the preset intent category, which can achieve better training results and ensure that the intent recognition model obtained after training has higher recognition accuracy for low-frequency intents.
出于与上述各样本生成方法实施例相同的技术构思,本申请实施例还提供了一种应用于数字人的意图识别方法。图6为本申请实施例提供的一种应用于数字人的意图识别方法的处理流程图。 Based on the same technical concept as the above-mentioned sample generation method embodiments, the present application embodiment also provides an intention recognition method applied to a digital human. Figure 6 is a processing flow chart of an intention recognition method applied to a digital human provided by the present application embodiment.
步骤S602,获取用户输入的待识别文本。Step S602: obtaining the text to be recognized input by the user.
步骤S604,将待识别文本输入意图识别模型进行意图识别,得到用户意图;意图识别模型是通过将低频意图样本输入初始意图识别模型进行迭代训练所得到的;低频意图样本是通过样本生成方法所生成的。Step S604, input the text to be recognized into the intention recognition model for intent recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into the initial intention recognition model for iterative training; the low-frequency intention samples are generated by a sample generation method.
具体地,低频意图样本可以是通过本申请中前述的样本生成方法所生成的。初始意图识别模型和意图识别模型可以参照如图5所示的意图识别模型的训练方法实施例的对应说明部分。Specifically, the low-frequency intent samples may be generated by the sample generation method described above in the present application. The initial intent recognition model and the intent recognition model may refer to the corresponding description part of the embodiment of the training method of the intent recognition model shown in FIG5 .
步骤S606,根据用户意图在数字人的系统中获取对应用户意图的目标文本,并对目标文本进行展示。Step S606, according to the user intention, the target text corresponding to the user intention is obtained in the digital human system, and the target text is displayed.
数字人的系统中可以存储有预先配置的预设用户意图与预设文本的对应关系,根据步骤S604中得到的用户意图和预设用户意图与预设文本的对应关系,可以在数字人的系统中查询得到对应用户意图的目标文本并展示。The digital human system may store a pre-configured correspondence between preset user intentions and preset texts. According to the user intention obtained in step S604 and the correspondence between the preset user intentions and preset texts, the target text corresponding to the user intention may be queried in the digital human system and displayed.
根据以上内容,可知本申请的一些实施方式中,根据用户意图在数字人的系统中获取对应用户意图的目标文本,包括:根据用户意图和预先配置的预设用户意图与预设文本的对应关系,在数字人的系统中查询得到用户意图对应的目标文本。Based on the above content, it can be known that in some implementations of the present application, a target text corresponding to the user intention is obtained in the digital human system according to the user intention, including: querying the digital human system to obtain the target text corresponding to the user intention according to the correspondence between the user intention and the pre-configured preset user intention and the preset text.
在数字人场景中,预设用户意图可以是预先配置的低频意图,例如,“提前还款”,预设文本可以是数字人的系统针对该低频意图预先确定的应答文本,例如,“您可以按照xxx向xxx预约该项服务”。In the digital human scenario, the preset user intent can be a pre-configured low-frequency intent, such as "early repayment", and the preset text can be the response text predetermined by the digital human system for the low-frequency intent, such as "You can make an appointment for this service with xxx according to xxx".
如图6所示的应用于数字人的意图识别方法实施例中,首先,获取用户输入的待识别文本;其次,将待识别文本输入意图识别模型进行意图识别,得到用户意图;意图识别模型是通过将低频意图样本输入初始意图识别模型进行迭代训练所得到的;低频意图样本是通过前述样本生成方法实施例所提供的样本生成方法所生成的;最后,根据用户意图在数字人的系统中获取对应用户意图的目标文本,并对目标文本进行展示。日志数据是一种随着时间变化不断增长的历史数据。即便低频意图数据在日志数据中的出现频率较低, 在日志数据所对应的时间跨度足够长的情况下,可以从日志数据中筛选得到累计的大量低频意图数据,基于该大量低频意图数据可以生成数量足够用于训练初始文本对比模型的训练数据,且训练数据的数量可以随着日志数据的时间跨度增长而不断扩增。因此,在训练数据的数量足够多的情况下,通过训练后得到的文本对比模型进行相似度预测时的预测结果较为准确,进而,通过文本对比模型对低频意图数据和预设意图类别的标准文本进行相似度预测处理,可以确定低频意图数据中与预设意图类别的标准文本相似度较高的低频意图样本,在获取的日志数据随着时间变化不断增加的情况下,可以利用不断增长的日志数据和文本对比模型累计得到大量预设意图类别的低频意图样本,进而利用该预设意图类别的低频意图样本对初始意图识别模型进行迭代训练,可以取得较好的训练效果,使得训练之后得到的意图识别模型对低频意图的识别准确性较高,进而利用识别得到的准确的用户意图可以从数字人的系统中获取符合用户意图的目标文本并展示,提高了用户体验。In the embodiment of the intention recognition method applied to a digital human as shown in FIG6, first, the text to be recognized input by the user is obtained; secondly, the text to be recognized is input into the intention recognition model for intention recognition to obtain the user's intention; the intention recognition model is obtained by inputting low-frequency intention samples into the initial intention recognition model for iterative training; the low-frequency intention samples are generated by the sample generation method provided by the aforementioned sample generation method embodiment; finally, according to the user's intention, the target text corresponding to the user's intention is obtained in the digital human system, and the target text is displayed. Log data is a kind of historical data that grows continuously over time. Even if the frequency of occurrence of low-frequency intention data in log data is low, When the time span corresponding to the log data is long enough, a large amount of low-frequency intent data can be screened from the log data to obtain a large amount of accumulated low-frequency intent data. Based on the large amount of low-frequency intent data, a sufficient amount of training data can be generated for training the initial text comparison model, and the amount of training data can be continuously expanded as the time span of the log data increases. Therefore, when the amount of training data is large enough, the prediction result of similarity prediction by the text comparison model obtained after training is relatively accurate. Then, by performing similarity prediction processing on the low-frequency intent data and the standard text of the preset intent category through the text comparison model, the low-frequency intent samples with high similarity to the standard text of the preset intent category in the low-frequency intent data can be determined. When the acquired log data increases with time, a large amount of low-frequency intent samples of the preset intent category can be accumulated by using the growing log data and the text comparison model. Then, the initial intent recognition model is iteratively trained by using the low-frequency intent samples of the preset intent category, and a good training effect can be achieved, so that the intent recognition model obtained after training has a high recognition accuracy for low-frequency intent. Then, the accurate user intent obtained by recognition can be used to obtain and display the target text that meets the user intent from the digital human system, thereby improving the user experience.
在上述的实施例中,提供了一种样本生成方法,与之相对应的,还提供了一种样本生成装置,下面结合附图进行说明。In the above-mentioned embodiment, a sample generation method is provided, and correspondingly, a sample generation device is also provided, which will be described below with reference to the accompanying drawings.
图7为本申请实施例提供的一种样本生成装置示意图。FIG. 7 is a schematic diagram of a sample generating device provided in an embodiment of the present application.
本实施例提供一种样本生成装置,包括:第一获取单元701,用于获取待处理的日志数据;日志数据包括文本和文本的意图识别结果;筛选单元702,用于根据文本的意图识别结果,对日志数据进行数据筛选处理,得到低频意图数据;预测单元703,用于将低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到低频意图数据对应的文本对比结果;文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;训练样本集基于低频意图数据构建;第一生成单元704,用于根据文本对比结果与预设相似度阈值,生成低频意图样本。The present embodiment provides a sample generation device, including: a first acquisition unit 701, used to acquire log data to be processed; the log data includes text and intent recognition results of the text; a screening unit 702, used to perform data screening processing on the log data according to the intent recognition results of the text, to obtain low-frequency intent data; a prediction unit 703, used to input the low-frequency intent data and standard text of a preset intent category into a text comparison model for similarity prediction processing, to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is constructed based on the low-frequency intent data; a first generation unit 704, used to generate a low-frequency intent sample according to the text comparison result and a preset similarity threshold.
可选地,筛选单元702,包括:分类子单元,用于将日志数据输入高频意图分类模型,得到第一日志数据和第一日志数据的意图分类结果的置信度; 第一日志数据的意图分类结果为预设高频意图;高频意图分类模型用于根据日志数据中文本的意图识别结果对日志数据进行意图分类处理;筛选子单元,用于根据第一日志数据和第一日志数据的意图分类结果的置信度,对日志数据进行数据筛选处理,得到低频意图数据。Optionally, the screening unit 702 includes: a classification subunit, configured to input the log data into a high-frequency intent classification model to obtain the first log data and the confidence of the intent classification result of the first log data; The intent classification result of the first log data is a preset high-frequency intent; the high-frequency intent classification model is used to perform intent classification processing on the log data according to the intent recognition result of the text in the log data; the screening subunit is used to perform data screening processing on the log data according to the first log data and the confidence of the intent classification result of the first log data to obtain low-frequency intent data.
可选地,筛选子单元,具体用于:根据第一日志数据的意图分类结果的置信度与预设置信度阈值的比较结果,确定高频意图数据;将日志数据中的高频意图数据删除,得到低频意图数据。Optionally, the screening subunit is specifically used to: determine high-frequency intent data based on a comparison result of the confidence of the intent classification result of the first log data with a preset confidence threshold; delete the high-frequency intent data in the log data to obtain low-frequency intent data.
可选地,初始文本对比模型包括依次连接的编码器和相似度预测模块;编码器的输出为相似度预测模块的输入;编码器用于根据低频意图数据进行编码处理,得到低频意图数据对应的相似样本对和非相似样本对;相似度预测模块用于根据低频意图数据对应的相似样本对和非相似样本对进行迭代训练。Optionally, the initial text comparison model includes an encoder and a similarity prediction module connected in sequence; the output of the encoder is the input of the similarity prediction module; the encoder is used to perform encoding processing based on the low-frequency intent data to obtain similar sample pairs and dissimilar sample pairs corresponding to the low-frequency intent data; the similarity prediction module is used to perform iterative training based on similar sample pairs and dissimilar sample pairs corresponding to the low-frequency intent data.
可选地,低频意图数据包括目标文本和非目标文本;编码器具体用于:根据目标文本进行编码处理,得到目标文本对应的目标编码结果和相似编码结果,以及,根据非目标文本进行编码处理,得到非目标文本对应的编码结果;将目标文本对应的目标编码结果和相似编码结果确定为低频意图数据对应的相似样本对;将目标文本对应的目标编码结果和非目标文本对应的编码结果确定为低频意图数据对应的非相似样本对。Optionally, the low-frequency intent data includes target text and non-target text; the encoder is specifically used to: perform encoding processing according to the target text to obtain a target encoding result and a similar encoding result corresponding to the target text, and perform encoding processing according to the non-target text to obtain an encoding result corresponding to the non-target text; determine the target encoding result and the similar encoding result corresponding to the target text as similar sample pairs corresponding to the low-frequency intent data; determine the target encoding result corresponding to the target text and the encoding result corresponding to the non-target text as non-similar sample pairs corresponding to the low-frequency intent data.
可选地,编码器包括依次连接的注意力层和全连接层;注意力层的输出为全连接层的输入;注意力层用于根据预设的第一随机失活概率和低频意图数据进行第一编码处理,得到中间编码数据;全连接层用于根据预设的第二随机失活概率和中间编码数据进行转换处理,得到低频意图数据对应的相似样本对和非相似样本对。Optionally, the encoder includes an attention layer and a fully connected layer connected in sequence; the output of the attention layer is the input of the fully connected layer; the attention layer is used to perform a first encoding process according to a preset first random inactivation probability and the low-frequency intent data to obtain intermediate encoded data; the fully connected layer is used to perform conversion processing according to a preset second random inactivation probability and the intermediate encoded data to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intent data.
可选地,低频意图数据包括多个低频意图文本;文本对比模型,具体用于:将每个低频意图文本和预设意图类别的标准文本确定为每个低频意图文本对应的相似样本对;对每个低频意图文本对应的相似样本对进行相似度预 测处理,得到每个低频意图文本的相似度评分;将每个低频意图文本的相似度评分确定为低频意图数据对应的文本对比结果。Optionally, the low-frequency intent data includes a plurality of low-frequency intent texts; the text comparison model is specifically used to: determine each low-frequency intent text and a standard text of a preset intent category as a similar sample pair corresponding to each low-frequency intent text; and perform similarity prediction on the similar sample pairs corresponding to each low-frequency intent text. The similarity score of each low-frequency intent text is obtained by performing measurement processing; and the similarity score of each low-frequency intent text is determined as the text comparison result corresponding to the low-frequency intent data.
可选地,第一生成单元704,具体用于:根据预设相似度阈值与文本对比结果的比较结果,确定预设相似度阈值对应的相似样本数据的数量;若低频意图数据对应的相似样本数据的数量小于预设数量阈值,则重复执行将当前的相似度阈值减去预设降低值以得到更新的相似度阈值,以及,根据更新的相似度阈值与文本对比结果的比较结果,确定更新的相似度阈值对应的相似样本数据的数量的操作,直至更新的相似度阈值满足预设停止条件;预设停止条件为样本数量大于等于预设数量阈值;样本数量为预设相似度阈值对应的相似样本数据的数量与各个更新的相似度阈值对应的相似样本数据的数量之和;将预设相似度阈值对应的相似样本数据和各个更新的相似度阈值对应的相似样本数据中的每个样本数据确定为每个样本数据对应的低频意图样本。Optionally, the first generating unit 704 is specifically used to: determine the number of similar sample data corresponding to the preset similarity threshold according to the comparison result between the preset similarity threshold and the text comparison result; if the number of similar sample data corresponding to the low-frequency intent data is less than the preset number threshold, repeatedly perform the operation of subtracting the preset reduction value from the current similarity threshold to obtain an updated similarity threshold, and, according to the comparison result between the updated similarity threshold and the text comparison result, determine the number of similar sample data corresponding to the updated similarity threshold, until the updated similarity threshold meets the preset stop condition; the preset stop condition is that the number of samples is greater than or equal to the preset number threshold; the number of samples is the sum of the number of similar sample data corresponding to the preset similarity threshold and the number of similar sample data corresponding to each updated similarity threshold; each sample data in the similar sample data corresponding to the preset similarity threshold and the similar sample data corresponding to each updated similarity threshold is determined as a low-frequency intent sample corresponding to each sample data.
本申请实施例所提供的样本生成装置包括:第一获取单元、筛选单元、预测单元以及第一生成单元,其中,第一获取单元,用于获取待处理的日志数据;日志数据包括文本和文本的意图识别结果;筛选单元,用于根据文本的意图识别结果,对日志数据进行数据筛选处理,得到低频意图数据;预测单元,用于将低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到低频意图数据对应的文本对比结果;文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;训练样本集基于低频意图数据构建;第一生成单元,用于根据文本对比结果与预设相似度阈值,生成低频意图样本。日志数据是一种随着时间变化不断增长的历史数据。即便低频意图数据在日志数据中的出现频率较低,在日志数据所对应的时间跨度足够长的情况下,可以从日志数据中筛选得到累计的大量低频意图数据,基于该大量低频意图数据可以生成数量足够用于训练初始文本对比模型的训练数据,且训练数据的数量可以随着日志数据的时间跨度增长而不 断扩增。因此,在训练数据的数量足够多的情况下,通过训练后得到的文本对比模型进行相似度预测时的预测结果较为准确,进而,通过文本对比模型对低频意图数据和预设意图类别的标准文本进行相似度预测处理,可以确定低频意图数据中与预设意图类别的标准文本相似度较高的低频意图样本,在获取的日志数据随着时间变化不断增加的情况下,可以利用不断增长的日志数据和文本对比模型累计得到大量预设意图类别的低频意图样本,进而满足低频意图样本对应的意图识别模型的训练需求,提高低频意图的识别准确性。The sample generation device provided in the embodiment of the present application includes: a first acquisition unit, a screening unit, a prediction unit and a first generation unit, wherein the first acquisition unit is used to acquire the log data to be processed; the log data includes text and the intention recognition result of the text; the screening unit is used to perform data screening processing on the log data according to the intention recognition result of the text to obtain low-frequency intention data; the prediction unit is used to input the low-frequency intention data and the standard text of the preset intention category into the text comparison model for similarity prediction processing to obtain the text comparison result corresponding to the low-frequency intention data; the text comparison model is a model obtained by training the initial text comparison model based on the training sample set; the training sample set is constructed based on the low-frequency intention data; the first generation unit is used to generate a low-frequency intention sample according to the text comparison result and the preset similarity threshold. Log data is a kind of historical data that grows continuously with time. Even if the frequency of occurrence of low-frequency intention data in the log data is low, when the time span corresponding to the log data is long enough, a large amount of accumulated low-frequency intention data can be screened from the log data, and a sufficient amount of training data for training the initial text comparison model can be generated based on the large amount of low-frequency intention data, and the amount of training data can increase with the time span of the log data. Therefore, when the amount of training data is large enough, the prediction result of similarity prediction by the text comparison model obtained after training is relatively accurate. Then, by performing similarity prediction processing on the low-frequency intent data and the standard text of the preset intent category through the text comparison model, the low-frequency intent samples with high similarity to the standard text of the preset intent category in the low-frequency intent data can be determined. When the acquired log data increases with time, a large number of low-frequency intent samples of the preset intent category can be accumulated by using the growing log data and the text comparison model, thereby meeting the training requirements of the intent recognition model corresponding to the low-frequency intent samples and improving the recognition accuracy of the low-frequency intent.
在上述的实施例中,提供了一种意图识别模型的训练方法,与之相对应的,还提供了一种意图识别模型的训练装置,下面结合附图进行说明。In the above-mentioned embodiment, a method for training an intent recognition model is provided, and correspondingly, a device for training an intent recognition model is also provided, which will be described below in conjunction with the accompanying drawings.
图8为本申请实施例提供的一种意图识别模型的训练装置示意图。FIG8 is a schematic diagram of a training device for an intent recognition model provided in an embodiment of the present application.
本实施例提供一种意图识别模型的训练装置,包括:第二生成单元801,用于通过样本生成方法生成低频意图样本;训练单元802,用于将所述低频意图样本输入初始意图识别模型进行迭代训练,得到意图识别模型。This embodiment provides a training device for an intent recognition model, including: a second generation unit 801, used to generate low-frequency intent samples through a sample generation method; a training unit 802, used to input the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
本申请实施例提供的意图识别模型的训练装置包括第二生成单元和训练单元,其中,第二生成单元用于通过上述样本生成方法实施例所提供的样本生成方法生成低频意图样本;训练单元用于将低频意图样本输入初始意图识别模型进行迭代训练,得到意图识别模型。日志数据是一种随着时间变化不断增长的历史数据。即便低频意图数据在日志数据中的出现频率较低,在日志数据所对应的时间跨度足够长的情况下,可以从日志数据中筛选得到累计的大量低频意图数据,基于该大量低频意图数据可以生成数量足够用于训练初始文本对比模型的训练数据,且训练数据的数量可以随着日志数据的时间跨度增长而不断扩增。因此,在训练数据的数量足够多的情况下,通过训练后得到的文本对比模型进行相似度预测时的预测结果较为准确,进而,通过文本对比模型对低频意图数据和预设意图类别的标准文本进行相似度预测处理,可以确定低频意图数据中与预设意图类别的标准文本相似度较高的低频意图样本,在获取的日志数据随着时间变化不断增加的情况下,可以利用不 断增长的日志数据和文本对比模型累计得到大量预设意图类别的低频意图样本,进而利用该预设意图类别的低频意图样本对初始意图识别模型进行迭代训练,可以取得较好的训练效果,使得训练之后得到的意图识别模型对低频意图的识别准确性较高。The training device of the intent recognition model provided in the embodiment of the present application includes a second generation unit and a training unit, wherein the second generation unit is used to generate low-frequency intent samples through the sample generation method provided in the above-mentioned sample generation method embodiment; the training unit is used to input the low-frequency intent samples into the initial intent recognition model for iterative training to obtain the intent recognition model. Log data is a kind of historical data that grows continuously with time. Even if the low-frequency intent data has a low frequency of occurrence in the log data, when the time span corresponding to the log data is long enough, a large amount of accumulated low-frequency intent data can be screened from the log data, and a sufficient amount of training data can be generated based on the large amount of low-frequency intent data for training the initial text comparison model, and the amount of training data can be continuously expanded as the time span of the log data increases. Therefore, when the amount of training data is sufficient, the prediction result when similarity prediction is performed by the text comparison model obtained after training is more accurate. Then, by performing similarity prediction processing on the low-frequency intent data and the standard text of the preset intent category through the text comparison model, the low-frequency intent samples with higher similarity with the standard text of the preset intent category in the low-frequency intent data can be determined. When the acquired log data increases continuously with time, the unsatisfactory log data can be used to train the initial text comparison model. The continuously growing log data and text comparison model accumulate a large number of low-frequency intent samples of the preset intent category, and then use the low-frequency intent samples of the preset intent category to iteratively train the initial intent recognition model, which can achieve better training results and make the intent recognition model obtained after training have higher recognition accuracy for low-frequency intents.
在上述的实施例中,提供了一种应用于数字人的意图识别方法,与之相对应的,还提供了一种应用于数字人的意图识别装置,下面结合附图进行说明。In the above-mentioned embodiment, a method for identifying intentions applied to a digital human is provided, and correspondingly, a device for identifying intentions applied to a digital human is also provided, which will be described below in conjunction with the accompanying drawings.
图9为本申请实施例提供的一种应用于数字人的意图识别装置示意图。FIG. 9 is a schematic diagram of an intention recognition device for a digital human provided in an embodiment of the present application.
本实施例提供一种应用于数字人的意图识别装置,包括:第二获取单元901,用于获取用户输入的待识别文本;识别单元902,用于将待识别文本输入意图识别模型进行意图识别,得到用户意图;意图识别模型是通过将低频意图样本输入初始意图识别模型进行迭代训练所得到的;低频意图样本是通过上述的样本生成方法所生成的;展示单元903,用于根据用户意图在数字人的系统中获取对应用户意图的目标文本,并对目标文本进行展示。This embodiment provides an intention recognition device applied to a digital human, comprising: a second acquisition unit 901, used to acquire a text to be recognized input by a user; a recognition unit 902, used to input the text to be recognized into an intention recognition model for intention recognition, and obtain the user intention; the intention recognition model is obtained by inputting a low-frequency intention sample into an initial intention recognition model for iterative training; the low-frequency intention sample is generated by the above-mentioned sample generation method; a display unit 903, used to obtain a target text corresponding to the user intention in the digital human system according to the user intention, and display the target text.
本申请实施例提供的应用于数字人的意图识别装置包括第二获取单元、识别单元以及展示单元,其中,第二获取单元用于获取用户输入的待识别文本;识别单元用于将待识别文本输入意图识别模型进行意图识别,得到用户意图;意图识别模型是通过将低频意图样本输入初始意图识别模型进行迭代训练所得到的;低频意图样本是通过前述样本生成方法实施例所提供的样本生成方法所生成的;展示单元用于根据用户意图在数字人的系统中获取对应用户意图的目标文本,并对目标文本进行展示。日志数据是一种随着时间变化不断增长的历史数据。即便低频意图数据在日志数据中的出现频率较低,在日志数据所对应的时间跨度足够长的情况下,可以从日志数据中筛选得到累计的大量低频意图数据,基于该大量低频意图数据可以生成数量足够用于训练初始文本对比模型的训练数据,且训练数据的数量可以随着日志数据的时间跨度增长而不断扩增。因此,在训练数据的数量足够多的情况下,通过 训练后得到的文本对比模型进行相似度预测时的预测结果较为准确,进而,通过文本对比模型对低频意图数据和预设意图类别的标准文本进行相似度预测处理,可以确定低频意图数据中与预设意图类别的标准文本相似度较高的低频意图样本,在获取的日志数据随着时间变化不断增加的情况下,可以利用不断增长的日志数据和文本对比模型累计得到大量预设意图类别的低频意图样本,进而利用该预设意图类别的低频意图样本对初始意图识别模型进行迭代训练,可以取得较好的训练效果,使得训练之后得到的意图识别模型对低频意图的识别准确性较高,进而利用识别得到的准确的用户意图可以从数字人的系统中获取符合用户意图的目标文本并展示,提高了用户体验。The intention recognition device for digital human provided by the embodiment of the present application includes a second acquisition unit, an identification unit and a display unit, wherein the second acquisition unit is used to acquire the text to be recognized input by the user; the identification unit is used to input the text to be recognized into the intention recognition model for intention recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into the initial intention recognition model for iterative training; the low-frequency intention samples are generated by the sample generation method provided by the aforementioned sample generation method embodiment; the display unit is used to obtain the target text corresponding to the user intention in the digital human system according to the user intention, and display the target text. Log data is a kind of historical data that grows with time. Even if the frequency of occurrence of low-frequency intention data in the log data is low, when the time span corresponding to the log data is long enough, a large amount of accumulated low-frequency intention data can be screened from the log data, and based on the large amount of low-frequency intention data, a sufficient amount of training data for training the initial text comparison model can be generated, and the amount of training data can be continuously expanded as the time span of the log data increases. Therefore, when the amount of training data is large enough, through The text comparison model obtained after training has relatively accurate prediction results when performing similarity prediction. Furthermore, by using the text comparison model to perform similarity prediction processing on low-frequency intent data and standard text of preset intent categories, low-frequency intent samples with high similarity to standard text of preset intent categories in low-frequency intent data can be determined. When the acquired log data increases with time, a large number of low-frequency intent samples of preset intent categories can be accumulated using the growing log data and text comparison model. Then, the initial intent recognition model can be iteratively trained using the low-frequency intent samples of the preset intent categories, which can achieve better training results. This makes the intent recognition model obtained after training have high recognition accuracy for low-frequency intents. Then, the accurate user intent obtained by recognition can be used to obtain and display the target text that meets the user intent from the digital human system, thereby improving the user experience.
对应上述描述的一种样本生成方法,或者,对应上述描述的一种意图识别模型的训练方法,或者,对应上述描述的一种应用于数字人的意图识别方法,基于相同的技术构思,本申请实施例还提供一种电子设备,该电子设备用于执行上述提供的样本生成方法、意图识别模型的训练方法以及应用于数字人的意图识别方法中的一者或多者,图10为本申请实施例提供的一种电子设备的结构示意图。Corresponding to a sample generation method described above, or, corresponding to a training method for an intent recognition model described above, or, corresponding to a method for intent recognition applied to a digital human described above, based on the same technical concept, an embodiment of the present application also provides an electronic device, which is used to execute one or more of the sample generation method, the training method for the intent recognition model, and the intent recognition method applied to a digital human provided above. Figure 10 is a structural schematic diagram of an electronic device provided in an embodiment of the present application.
如图10所示,电子设备可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上的处理器1001和存储器1002,存储器1002中可以存储有一个或一个以上存储应用程序或数据。其中,存储器1002可以是短暂存储或持久存储。存储在存储器1002的应用程序可以包括一个或一个以上模块(图示未示出),每个模块可以包括电子设备中的一系列计算机可执行指令。更进一步地,处理器1001可以设置为与存储器1002通信,在电子设备上执行存储器1002中的一系列计算机可执行指令。电子设备还可以包括一个或一个以上电源1003,一个或一个以上有线或无线网络接口1004,一个或一个以上输入/输出接口1005,一个或一个以上键盘1006等。As shown in FIG10 , electronic devices may have relatively large differences due to different configurations or performances, and may include one or more processors 1001 and memory 1002, and the memory 1002 may store one or more storage applications or data. Among them, the memory 1002 may be a short-term storage or a persistent storage. The application stored in the memory 1002 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the electronic device. Furthermore, the processor 1001 may be configured to communicate with the memory 1002 and execute a series of computer executable instructions in the memory 1002 on the electronic device. The electronic device may also include one or more power supplies 1003, one or more wired or wireless network interfaces 1004, one or more input/output interfaces 1005, one or more keyboards 1006, etc.
在一个具体的实施例中,电子设备包括有存储器,以及一个或一个以上的程序,其中一个或者一个以上程序存储于存储器中,且一个或者一个以上 程序可以包括一个或一个以上模块,且每个模块可以包括对电子设备中的一系列计算机可执行指令,且经配置以由一个或者一个以上处理器执行该一个或者一个以上程序包含用于进行以下计算机可执行指令:获取待处理的日志数据;日志数据包括文本和文本的意图识别结果;根据文本的意图识别结果,对日志数据进行数据筛选处理,得到低频意图数据;将低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到低频意图数据对应的文本对比结果;文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;训练样本集基于低频意图数据构建;根据文本对比结果与预设相似度阈值,生成低频意图样本。In a specific embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs are stored in the memory. The program may include one or more modules, and each module may include a series of computer executable instructions in the electronic device, and is configured to be executed by one or more processors. The one or more programs include the following computer executable instructions: obtaining log data to be processed; the log data includes text and the intent recognition result of the text; according to the intent recognition result of the text, the log data is screened to obtain low-frequency intent data; the low-frequency intent data and the standard text of the preset intent category are input into the text comparison model for similarity prediction processing to obtain the text comparison result corresponding to the low-frequency intent data; the text comparison model is a model obtained by training the initial text comparison model based on the training sample set; the training sample set is constructed based on the low-frequency intent data; and a low-frequency intent sample is generated according to the text comparison result and the preset similarity threshold.
在另一个具体的实施例中,电子设备包括有存储器,以及一个或一个以上的程序,其中一个或者一个以上程序存储于存储器中,且一个或者一个以上程序可以包括一个或一个以上模块,且每个模块可以包括对电子设备中的一系列计算机可执行指令,且经配置以由一个或者一个以上处理器执行该一个或者一个以上程序包含用于进行以下计算机可执行指令:通过样本生成方法生成低频意图样本;将低频意图样本输入初始意图识别模型进行迭代训练,得到意图识别模型。In another specific embodiment, an electronic device includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions in the electronic device, and the one or more programs are configured to be executed by one or more processors, and include the following computer executable instructions: generating low-frequency intent samples by a sample generation method; inputting the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
在又一个具体的实施例中,电子设备包括有存储器,以及一个或一个以上的程序,其中一个或者一个以上程序存储于存储器中,且一个或者一个以上程序可以包括一个或一个以上模块,且每个模块可以包括对电子设备中的一系列计算机可执行指令,且经配置以由一个或者一个以上处理器执行该一个或者一个以上程序包含用于进行以下计算机可执行指令:获取用户输入的待识别文本;将待识别文本输入意图识别模型进行意图识别,得到用户意图;意图识别模型是通过将低频意图样本输入初始意图识别模型进行迭代训练所得到的;低频意图样本是通过样本生成方法所生成的;根据用户意图在数字人的系统中获取对应用户意图的目标文本,并对目标文本进行展示。In another specific embodiment, the electronic device includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions in the electronic device, and is configured to be executed by one or more processors. The one or more programs include the following computer executable instructions: obtaining text to be recognized input by the user; inputting the text to be recognized into an intention recognition model for intention recognition to obtain the user intention; the intention recognition model is obtained by inputting low-frequency intention samples into the initial intention recognition model for iterative training; the low-frequency intention samples are generated by a sample generation method; according to the user intention, a target text corresponding to the user intention is obtained in the digital human system, and the target text is displayed.
对应上述描述的一种样本生成方法,或者,对应上述描述的一种意图识 别模型的训练方法,或者,对应上述描述的一种应用于数字人的意图识别方法,基于相同的技术构思,本申请实施例还提供一种计算机可读存储介质。Corresponding to a sample generation method described above, or corresponding to an intention recognition method described above A training method for a recognition model, or, corresponding to the above-described method for recognizing intentions applied to digital humans, based on the same technical concept, an embodiment of the present application also provides a computer-readable storage medium.
在一个具体的实施例中,计算机可读存储介质,用于存储计算机可执行指令,计算机可执行指令在被处理器执行时实现以下流程:获取待处理的日志数据;日志数据包括文本和文本的意图识别结果;根据文本的意图识别结果,对日志数据进行数据筛选处理,得到低频意图数据;将低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到低频意图数据对应的文本对比结果;文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;训练样本集基于低频意图数据构建;根据文本对比结果与预设相似度阈值,生成低频意图样本。In a specific embodiment, a computer-readable storage medium is used to store computer-executable instructions, which implement the following process when executed by a processor: obtaining log data to be processed; the log data includes text and intent recognition results of the text; based on the intent recognition results of the text, the log data is screened to obtain low-frequency intent data; the low-frequency intent data and standard text of a preset intent category are input into a text comparison model for similarity prediction processing to obtain text comparison results corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is constructed based on the low-frequency intent data; and a low-frequency intent sample is generated based on the text comparison result and a preset similarity threshold.
在另一个具体的实施例中,计算机可读存储介质,用于存储计算机可执行指令,计算机可执行指令在被处理器执行时实现以下流程:通过样本生成方法生成低频意图样本;将低频意图样本输入初始意图识别模型进行迭代训练,得到意图识别模型。In another specific embodiment, a computer-readable storage medium is used to store computer-executable instructions, which implement the following process when executed by a processor: generating low-frequency intent samples through a sample generation method; inputting the low-frequency intent samples into an initial intent recognition model for iterative training to obtain an intent recognition model.
在又一个具体的实施例中,计算机可读存储介质,用于存储计算机可执行指令,计算机可执行指令在被处理器执行时实现以下流程:获取用户输入的待识别文本;将待识别文本输入意图识别模型进行意图识别,得到用户意图;意图识别模型是通过将低频意图样本输入初始意图识别模型进行迭代训练所得到的;低频意图样本是通过样本生成方法所生成的;根据用户意图在数字人的系统中获取对应用户意图的目标文本,并对目标文本进行展示。In another specific embodiment, a computer-readable storage medium is used to store computer-executable instructions, which implement the following process when executed by a processor: obtaining a text to be recognized input by a user; inputting the text to be recognized into an intention recognition model for intent recognition to obtain the user's intention; the intention recognition model is obtained by inputting low-frequency intention samples into an initial intention recognition model for iterative training; the low-frequency intention samples are generated by a sample generation method; and according to the user's intention, a target text corresponding to the user's intention is obtained in the digital human system, and the target text is displayed.
需要说明的是,本说明书中关于计算机可读存储介质的实施例与本说明书中关于样本生成方法的实施例、意图识别模型的训练方法的实施例以及应用于数字人的意图识别方法的实施例中的至少一者基于同一发明构思,因此该实施例的具体实施可以参见前述对应方法的实施,重复之处不再赘述。It should be noted that the embodiment of the computer-readable storage medium in this specification and at least one of the embodiments of the sample generation method, the training method of the intent recognition model, and the intent recognition method applied to a digital human in this specification are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the corresponding method mentioned above, and the repeated parts will not be repeated.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同 于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The above describes certain embodiments of the present 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 different The processes described in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
本领域内的技术人员应明白,本申请实施例可提供为方法、系统或计算机程序产品。因此,本申请实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本说明书可采用在一个或多个其中包含有计算机可用程序代码的计算机可读存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the embodiments of the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, this specification may adopt the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
本说明书是参照根据本说明书实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程设备的处理器以产生一个机器,使得通过计算机或其他可编程设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。This specification is described with reference to the flowchart and/or block diagram of the method, device (system), and computer program product according to the embodiment of this specification. It should be understood that each process and/or box in the flowchart and/or block diagram, as well as the combination of the process and/or box in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable device to produce a machine, so that the instructions executed by the processor of the computer or other programmable device produce a device for implementing the functions specified in one process or multiple processes in the flowchart and/or one box or multiple boxes in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions may also be loaded onto a computer or other programmable device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPU), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器 (RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in computer-readable media, random access memory Memory is an example of a computer-readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
本申请实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本说明书的一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。Embodiments of the present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同 之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
以上所述仅为本文件的实施例而已,并不用于限制本文件。对于本领域技术人员来说,本文件可以有各种更改和变化。凡在本文件的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本文件的权利要求范围之内。 The above description is only an embodiment of this document and is not intended to limit this document. For those skilled in the art, this document may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this document should be included in the scope of the claims of this document.

Claims (17)

  1. 一种样本生成方法,包括:A sample generation method, comprising:
    获取待处理的日志数据;所述日志数据包括文本和所述文本的意图识别结果;Obtaining log data to be processed; the log data includes text and intent recognition results of the text;
    根据所述文本的意图识别结果,对所述日志数据进行数据筛选处理,得到低频意图数据;According to the intention recognition result of the text, the log data is screened to obtain low-frequency intention data;
    将所述低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到所述低频意图数据对应的文本对比结果;所述文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;所述训练样本集基于所述低频意图数据构建;The low-frequency intent data and the standard text of the preset intent category are input into a text comparison model for similarity prediction processing to obtain a text comparison result corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is constructed based on the low-frequency intent data;
    根据所述文本对比结果与预设相似度阈值,生成低频意图样本。A low-frequency intent sample is generated according to the text comparison result and a preset similarity threshold.
  2. 根据权利要求1所述的方法,其中,所述根据所述文本的意图识别结果,对所述日志数据进行数据筛选处理,得到低频意图数据,包括:The method according to claim 1, wherein the step of performing data screening on the log data according to the intent recognition result of the text to obtain low-frequency intent data comprises:
    将所述日志数据输入高频意图分类模型,得到第一日志数据和所述第一日志数据的意图分类结果的置信度;所述第一日志数据的意图分类结果为预设高频意图;所述高频意图分类模型用于根据所述日志数据中所述文本的意图识别结果对所述日志数据进行意图分类处理;Input the log data into a high-frequency intent classification model to obtain first log data and the confidence of the intent classification result of the first log data; the intent classification result of the first log data is a preset high-frequency intent; the high-frequency intent classification model is used to perform intent classification processing on the log data according to the intent recognition result of the text in the log data;
    根据所述第一日志数据和所述第一日志数据的意图分类结果的置信度,对所述日志数据进行数据筛选处理,得到低频意图数据。According to the first log data and the confidence of the intent classification result of the first log data, the log data is screened to obtain low-frequency intent data.
  3. 根据权利要求2所述的方法,其中,所述根据所述第一日志数据和所述第一日志数据的意图分类结果的置信度,对所述日志数据进行数据筛选处理,得到低频意图数据,包括:The method according to claim 2, wherein the step of performing data screening on the log data to obtain low-frequency intent data based on the first log data and the confidence level of the intent classification result of the first log data comprises:
    根据所述第一日志数据的意图分类结果的置信度与预设置信度阈值的比较结果,确定高频意图数据; Determining high-frequency intent data according to a comparison result of the confidence of the intent classification result of the first log data with a preset confidence threshold;
    将所述日志数据中的所述高频意图数据删除,得到所述低频意图数据。The high-frequency intention data in the log data is deleted to obtain the low-frequency intention data.
  4. 根据权利要求1所述的方法,其中,The method according to claim 1, wherein
    所述初始文本对比模型包括依次连接的编码器和相似度预测模块;所述编码器的输出为所述相似度预测模块的输入;The initial text comparison model includes an encoder and a similarity prediction module connected in sequence; the output of the encoder is the input of the similarity prediction module;
    所述方法还包括:The method further comprises:
    所述编码器根据所述低频意图数据进行编码处理,得到所述低频意图数据对应的相似样本对和非相似样本对;The encoder performs encoding processing according to the low-frequency intention data to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intention data;
    所述相似度预测模块根据所述低频意图数据对应的相似样本对和所述非相似样本对进行迭代训练。The similarity prediction module performs iterative training based on the similar sample pairs and the non-similar sample pairs corresponding to the low-frequency intent data.
  5. 根据权利要求4所述的方法,其中,所述低频意图数据包括目标文本和非目标文本;The method according to claim 4, wherein the low-frequency intent data includes target text and non-target text;
    所述方法还包括:所述编码器根据所述目标文本进行编码处理,得到所述目标文本对应的目标编码结果和相似编码结果,以及,根据所述非目标文本进行编码处理,得到所述非目标文本对应的编码结果;The method further comprises: the encoder performs encoding processing according to the target text to obtain a target encoding result and a similar encoding result corresponding to the target text, and performs encoding processing according to the non-target text to obtain an encoding result corresponding to the non-target text;
    将所述目标文本对应的目标编码结果和相似编码结果确定为所述低频意图数据对应的相似样本对;将所述目标文本对应的目标编码结果和所述非目标文本对应的编码结果确定为所述低频意图数据对应的非相似样本对。The target encoding result and the similar encoding result corresponding to the target text are determined as similar sample pairs corresponding to the low-frequency intention data; the target encoding result corresponding to the target text and the encoding result corresponding to the non-target text are determined as non-similar sample pairs corresponding to the low-frequency intention data.
  6. 根据权利要求4所述的方法,其中,所述编码器包括依次连接的注意力层和全连接层;所述注意力层的输出为所述全连接层的输入;The method according to claim 4, wherein the encoder comprises an attention layer and a fully connected layer connected in sequence; the output of the attention layer is the input of the fully connected layer;
    所述方法还包括:The method further comprises:
    所述注意力层根据预设的第一随机失活概率和所述低频意图数据进行第一编码处理,得到中间编码数据;The attention layer performs a first encoding process according to a preset first random inactivation probability and the low-frequency intention data to obtain intermediate encoded data;
    所述全连接层根据预设的第二随机失活概率和所述中间编码数据进行转换处理,得到所述低频意图数据对应的相似样本对和非相似样本对。 The fully connected layer performs conversion processing according to a preset second random inactivation probability and the intermediate coded data to obtain similar sample pairs and non-similar sample pairs corresponding to the low-frequency intent data.
  7. 根据权利要求1所述的方法,其中,所述低频意图数据包括多个低频意图文本;所述方法还包括:The method according to claim 1, wherein the low-frequency intent data comprises a plurality of low-frequency intent texts; the method further comprises:
    所述文本对比模型将每个低频意图文本和预设意图类别的标准文本确定为每个低频意图文本对应的相似样本对;The text comparison model determines each low-frequency intent text and a standard text of a preset intent category as a similar sample pair corresponding to each low-frequency intent text;
    对每个低频意图文本对应的相似样本对进行相似度预测处理,得到每个低频意图文本的相似度评分;将每个低频意图文本的相似度评分确定为所述低频意图数据对应的文本对比结果。Perform similarity prediction processing on similar sample pairs corresponding to each low-frequency intent text to obtain a similarity score for each low-frequency intent text; determine the similarity score for each low-frequency intent text as the text comparison result corresponding to the low-frequency intent data.
  8. 根据权利要求1-7任一项所述的方法,其中,所述根据所述文本对比结果与预设相似度阈值,生成低频意图样本,包括:The method according to any one of claims 1 to 7, wherein generating a low-frequency intent sample according to the text comparison result and a preset similarity threshold comprises:
    根据所述预设相似度阈值与所述文本对比结果的比较结果,确定所述预设相似度阈值对应的相似样本数据的数量;Determining the number of similar sample data corresponding to the preset similarity threshold according to a comparison result between the preset similarity threshold and the text comparison result;
    若所述低频意图数据对应的相似样本数据的数量小于预设数量阈值,则将当前的相似度阈值减去预设降低值以得到更新的相似度阈值,以及,根据所述更新的相似度阈值与所述文本对比结果的比较结果,确定所述更新的相似度阈值对应的相似样本数据的更新的数量,若所述样本数量大于等于所述预设数量阈值,则确定所述预设相似度阈值对应的相似样本数据的数量为最终的更新的数量。If the number of similar sample data corresponding to the low-frequency intent data is less than a preset number threshold, the current similarity threshold is subtracted from the preset reduction value to obtain an updated similarity threshold, and, based on the comparison result between the updated similarity threshold and the text comparison result, the updated number of similar sample data corresponding to the updated similarity threshold is determined; if the sample number is greater than or equal to the preset number threshold, the number of similar sample data corresponding to the preset similarity threshold is determined to be the final updated number.
  9. 根据权利要求1所述的方法,其中,所述根据文本的意图识别结果,对日志数据进行数据筛选处理,得到低频意图数据,包括:The method according to claim 1, wherein the step of performing data screening on the log data according to the intent recognition result of the text to obtain low-frequency intent data comprises:
    根据所述文本的意图识别结果,确定所述文本的意图识别结果是否为预设的高频意图;Determining, based on the intention recognition result of the text, whether the intention recognition result of the text is a preset high-frequency intention;
    若所述文本的意图识别结果为预设的高频意图,则从所述日志数据中删除所述文本和所述文本的意图识别结果;If the intention recognition result of the text is a preset high-frequency intention, deleting the text and the intention recognition result of the text from the log data;
    若所述文本的意图识别结果不是预设的高频意图,则将所述文本以及所 述文本的意图识别结果作为所述低频意图数据。If the intent recognition result of the text is not the preset high-frequency intent, the text and the The intent recognition result of the text is used as the low-frequency intent data.
  10. 根据权利要求1所述的方法,其中,所述获取待处理的日志数据,包括:The method according to claim 1, wherein obtaining the log data to be processed comprises:
    获取待处理的日志数据中的对话数据;所述对话数据包括客户提出的问题文本以及机器人对所述客户的应答文本;Acquire the dialogue data in the log data to be processed; the dialogue data includes the text of the question raised by the customer and the text of the robot's response to the customer;
    根据所述应答文本和预先配置的意图识别结果和应答文本之间的对应关系,查询得到所述问题文本的意图识别结果;According to the correspondence between the answer text and the pre-configured intention recognition result and the answer text, query to obtain the intention recognition result of the question text;
    将所述问题文本确定为所述日志数据中的文本,将所述问题文本的意图识别结果确定为所述日志数据中的文本的意图识别结果。The question text is determined as the text in the log data, and the intention recognition result of the question text is determined as the intention recognition result of the text in the log data.
  11. 根据权利要求4所述的方法,其中,所述样本生成方法还包括:The method according to claim 4, wherein the sample generation method further comprises:
    在所述非相似样本对的文本长度不同的情况下,通过标点符号对所述非相似样本对中文本长度较短的文本进行长度扩充处理。In the case that the text lengths of the non-similar sample pairs are different, the text with a shorter text length in the non-similar sample pairs is extended by using punctuation marks.
  12. 一种意图识别模型的训练方法,包括:A method for training an intent recognition model, comprising:
    通过如权利要求1-11任一项所述的样本生成方法生成低频意图样本;Generate a low-frequency intention sample by using the sample generation method according to any one of claims 1 to 11;
    将所述低频意图样本输入初始意图识别模型进行迭代训练,得到意图识别模型。The low-frequency intent samples are input into the initial intent recognition model for iterative training to obtain the intent recognition model.
  13. 一种应用于数字人的意图识别方法,包括:An intention recognition method applied to a digital human, comprising:
    获取用户输入的待识别文本;Get the text to be recognized input by the user;
    将所述待识别文本输入意图识别模型进行意图识别,得到用户意图;所述意图识别模型是通过将低频意图样本输入初始意图识别模型进行迭代训练所得到的;所述低频意图样本是通过如权利要求1-11任一项所述的样本生成方法所生成的;Inputting the text to be recognized into an intention recognition model for intention recognition to obtain user intention; the intention recognition model is obtained by inputting low-frequency intention samples into an initial intention recognition model for iterative training; the low-frequency intention samples are generated by the sample generation method according to any one of claims 1 to 11;
    根据所述用户意图在所述数字人的系统中获取对应所述用户意图的目标 文本,并对所述目标文本进行展示。According to the user intention, a target corresponding to the user intention is obtained in the digital human system. text, and display the target text.
  14. 根据权利要求13所述的方法,其中,所述根据所述用户意图在所述数字人的系统中获取对应所述用户意图的目标文本,包括:The method according to claim 13, wherein the step of obtaining a target text corresponding to the user intention in the digital human system according to the user intention comprises:
    根据所述用户意图和预先配置的预设用户意图与预设文本的对应关系,在所述数字人的系统中查询得到所述用户意图对应的目标文本。According to the user intention and the correspondence between the pre-configured preset user intention and the preset text, the target text corresponding to the user intention is queried in the digital human system.
  15. 一种样本生成装置,包括:A sample generating device, comprising:
    第一获取单元,用于获取待处理的日志数据;所述日志数据包括文本和所述文本的意图识别结果;A first acquisition unit is used to acquire log data to be processed; the log data includes text and an intention recognition result of the text;
    筛选单元,用于根据所述文本的意图识别结果,对所述日志数据进行数据筛选处理,得到低频意图数据;A screening unit, configured to perform data screening processing on the log data according to the intention recognition result of the text, to obtain low-frequency intention data;
    预测单元,用于将所述低频意图数据、预设意图类别的标准文本输入文本对比模型进行相似度预测处理,得到所述低频意图数据对应的文本对比结果;所述文本对比模型为基于训练样本集对初始文本对比模型进行训练所得到的模型;所述训练样本集基于所述低频意图数据构建;A prediction unit is used to input the low-frequency intent data and the standard text of the preset intent category into a text comparison model for similarity prediction processing to obtain a text comparison result corresponding to the low-frequency intent data; the text comparison model is a model obtained by training an initial text comparison model based on a training sample set; the training sample set is constructed based on the low-frequency intent data;
    第一生成单元,用于根据所述文本对比结果与预设相似度阈值,生成低频意图样本。The first generating unit is used to generate a low-frequency intent sample according to the text comparison result and a preset similarity threshold.
  16. 一种电子设备,包括:An electronic device, comprising:
    处理器;以及,被配置为存储计算机可执行指令的存储器,所述计算机可执行指令在被执行时使所述处理器执行如权利要求1-11任一项所述的样本生成方法,或者,如权利要求12所述的意图识别模型的训练方法,或者,如权利要求13-14任一项所述的应用于数字人的意图识别方法。A processor; and a memory configured to store computer executable instructions, which, when executed, cause the processor to execute the sample generation method as described in any one of claims 1 to 11, or the training method for the intent recognition model as described in claim 12, or the intent recognition method applied to a digital human as described in any one of claims 13 to 14.
  17. 一种计算机可读存储介质,所述计算机可读存储介质用于存储计算机可执行指令,所述计算机可执行指令在被处理器执行时实现如权利要求 1-11任一项所述的样本生成方法,或者,如权利要求12所述的意图识别模型的训练方法,或者,如权利要求13-14所述的应用于数字人的意图识别方法。 A computer-readable storage medium for storing computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the The sample generation method as described in any one of 1-11, or the training method of the intention recognition model as described in claim 12, or the intention recognition method applied to a digital human as described in claims 13-14.
PCT/CN2023/120564 2022-09-26 2023-09-22 Sample generation method and apparatus, and electronic device and storage medium WO2024067377A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211178539.7A CN117807987A (en) 2022-09-26 2022-09-26 Sample generation method, device, electronic equipment and storage medium
CN202211178539.7 2022-09-26

Publications (1)

Publication Number Publication Date
WO2024067377A1 true WO2024067377A1 (en) 2024-04-04

Family

ID=90424072

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/120564 WO2024067377A1 (en) 2022-09-26 2023-09-22 Sample generation method and apparatus, and electronic device and storage medium

Country Status (2)

Country Link
CN (1) CN117807987A (en)
WO (1) WO2024067377A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210089724A1 (en) * 2019-09-25 2021-03-25 Google Llc Contrastive Pre-Training for Language Tasks
US20220164532A1 (en) * 2020-11-23 2022-05-26 International Business Machines Corporation Text data protection against automated analysis
CN114610851A (en) * 2022-03-30 2022-06-10 苏州科达科技股份有限公司 Method for training intention recognition model, intention recognition method, apparatus and medium
CN114661909A (en) * 2022-03-25 2022-06-24 鼎富智能科技有限公司 Intention recognition model training method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210089724A1 (en) * 2019-09-25 2021-03-25 Google Llc Contrastive Pre-Training for Language Tasks
US20220164532A1 (en) * 2020-11-23 2022-05-26 International Business Machines Corporation Text data protection against automated analysis
CN114661909A (en) * 2022-03-25 2022-06-24 鼎富智能科技有限公司 Intention recognition model training method and device, electronic equipment and storage medium
CN114610851A (en) * 2022-03-30 2022-06-10 苏州科达科技股份有限公司 Method for training intention recognition model, intention recognition method, apparatus and medium

Also Published As

Publication number Publication date
CN117807987A (en) 2024-04-02

Similar Documents

Publication Publication Date Title
CN110046221B (en) Machine dialogue method, device, computer equipment and storage medium
CN110377911B (en) Method and device for identifying intention under dialog framework
CN107766511A (en) Intelligent answer method, terminal and storage medium
CN111651609A (en) Multi-turn dialogue method and system integrating knowledge graph and emotion supervision
CN111046132A (en) Customer service question and answer processing method and system for retrieving multiple rounds of conversations
CN111708869B (en) Processing method and device for man-machine conversation
US20200272791A1 (en) Systems and methods for automated conversations with a transactional assistant
CN111813909A (en) Intelligent question answering method and device
US20190286713A1 (en) Systems and methods for enhanced natural language processing for machine learning conversations
CN116049360A (en) Intelligent voice dialogue scene conversation intervention method and system based on client image
CN111400458A (en) Automatic generalization method and device
CN111858854A (en) Question-answer matching method based on historical dialogue information and related device
CA3123387A1 (en) Method and system for generating an intent classifier
CN114564595A (en) Knowledge graph updating method and device and electronic equipment
CN116010581A (en) Knowledge graph question-answering method and system based on power grid hidden trouble shooting scene
CN116775807A (en) Natural language processing and model training method, equipment and storage medium
CN114265921A (en) Question-answer knowledge base construction method and device, equipment, medium and product thereof
WO2024067377A1 (en) Sample generation method and apparatus, and electronic device and storage medium
CN110705310B (en) Article generation method and device
CN116521832A (en) Dialogue interaction method, device and system, electronic equipment and storage medium
CN108959327B (en) Service processing method, device and computer readable storage medium
CN113010658A (en) Intelligent question-answering knowledge base construction method, system, terminal and storage medium
WO2024041350A1 (en) Intention recognition method and apparatus, electronic device, and storage medium
US11907673B1 (en) Enhancing chatbot recognition of user intent through graph analysis
CN112256833B (en) Mobile phone problem intelligent question answering method based on big data and AI algorithm

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23870609

Country of ref document: EP

Kind code of ref document: A1