Intent recognition model training method, device, electronic device and storage medium

Through contrastive learning training model, data enhancement and K-gathering contrastive learning technology are used to solve the problem of insufficient recognition ability of the text classification model for unknown intention categories, and significantly improve the accuracy of identifying text of new intention categories.

CN114661909BActive Publication Date: 2024-10-18ZHONGKE DINGFU BEIJING TECH DEV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210307380.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-25
Publication Date
2024-10-18
Estimated Expiration
2042-03-25

AI Technical Summary

Technical Problem

Existing text classification models based on neural network structures perform poorly when identifying texts of unknown intent categories, and are difficult to distinguish untrained new intent category texts.

Method used

By obtaining the original data set and the simulated data set, positive and negative sample texts are screened out, and the text classification neural network is trained through comparative learning to generate a model that can identify unknown intent categories. Specific steps include data enhancement of the original text, determining logical conflicts, generating simulation data sets, and updating model parameters using the K-gathering contrastive learning method until the training termination conditions are met.

Benefits of technology

It effectively improves the accuracy of the intent recognition model for unknown intent text, avoids misclassification of unknown intent category text into known intent categories, and enhances the recognition ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114661909B_ABST
    Figure CN114661909B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and storage medium for training an intent recognition model, the method comprising: obtaining an original data set; performing data enhancement simulation on the original data set to obtain a simulated data set, the simulated data set comprising: multiple categories of known intent texts and one category of unknown intent texts, wherein the known intent texts do not have a logical conflict with the original texts, and the unknown intent texts have a logical conflict with the original texts; screening out multiple positive sample texts and multiple negative sample texts from the original data set and the simulated data set, the category of the positive sample texts is different from the category of the negative sample texts; using the multiple positive sample texts and the multiple negative sample texts to perform comparative learning training on a text classification neural network to obtain a trained intent recognition model, the intent recognition model is used to identify the intent category of the text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of natural language processing, and in particular to an intent recognition model training method, device, electronic device and storage medium. Background Art

[0002] At present, text classification models based on neural network structures are usually used to identify the intent category of text content, thereby obtaining the intent results expressed semantically by the text content. However, in actual practice, it is found that these text classification models have a good accuracy rate for trained intent category texts, but it is difficult to identify unknown intent category texts that have not been trained. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide an intent recognition model training method, device, electronic device and storage medium, which are used to improve the problem that it is difficult to recognize text of unknown intent categories that have not been trained.

[0004] In a first aspect, an embodiment of the present application provides a method for training an intent recognition model, comprising: obtaining an original data set, the original data set comprising: original texts of multiple categories, each of the multiple categories having multiple original texts; performing data enhancement simulation on the original data set to obtain a simulated data set, the simulated data set comprising: known intent texts of multiple categories and one category of unknown intent text, wherein the category of the known intent corresponds to the category of the original text, there is no logical conflict between the known intent text and the original text, and there is a logical conflict between the unknown intent text and the original text; screening out multiple positive sample texts and multiple negative sample texts from the original data set and the simulated data set, the category of the positive sample text is different from the category of the negative sample text; using the multiple positive sample texts and the multiple negative sample texts to perform comparative learning training on a text classification neural network to obtain a trained intent recognition model, the intent recognition model is used to identify the intent category of the text. In the implementation process of the above solution, the intent recognition model is trained by using a simulated data set containing texts of unknown intent, and the positive sample texts and negative sample texts are screened out from the original data set and the simulated data set to train the intent recognition model. This avoids the situation where the traditional model always classifies texts of unknown intent categories into known intent categories, so that the trained intent recognition model can effectively identify the text category of unknown intent, thereby improving the accuracy of the trained intent recognition model in identifying texts of unknown intent.

[0005] In an optional implementation of the first aspect, data enhancement simulation is performed on the original data set, including: performing data enhancement on the original text to obtain simulated changed text; determining whether there is a logical conflict between the original text and the changed text corresponding to the original text; if so, determining the changed text as unknown intent text, otherwise, determining the changed text as known intent text, and marking the category of the original text as the category of the known intent.

[0006] In the implementation process of the above scheme, by performing data enhancement on the original text and determining the unknown intent text based on whether there is a logical conflict between the original text and the changed text, the accuracy of simulating the generation of unknown intent text is improved, so that the trained intent recognition model can effectively identify the text category of unknown intent, thereby improving the accuracy of the trained intent recognition model in identifying unknown intent text.

[0007] In an optional implementation of the first aspect, a text classification neural network is trained by contrastive learning using multiple positive sample texts and multiple negative sample texts, including: respectively calculating representation vectors of the positive sample texts and representation vectors of the negative sample texts; determining a contrastive learning target loss value and a classification learning target loss value of the text classification neural network based on the representation vectors of the positive sample texts and the representation vectors of the negative sample texts; determining a total loss value of the text classification neural network based on the contrastive learning target loss value and the classification learning target loss value; and updating model parameters of the intent recognition model based on the total loss value of the text classification neural network until the intent recognition model meets the training termination conditions.

[0008] In the process of implementing the above solution, the model parameters of the intent recognition model are updated through comparative learning, so that data samples of the same type are more focused and closer, and data samples of different types are farther away from each other, so that the intent recognition model can achieve better results after comparative learning.

[0009] In an optional implementation of the first aspect, after respectively calculating the representation vector of the positive sample text and the representation vector of the negative sample text, it also includes: determining the loss value of the decision boundary in the intent recognition model according to the representation vector of the positive sample text and the representation vector of the negative sample text, the decision boundary is a circle with the decision center vector of the target category of the positive sample text in the intent recognition model as the center point of the circle and the decision radius of the target category in the intent recognition model as the radius of the circle, and the decision center vector is the vector mean of all text representation vectors of the target category calculated by the intent recognition model; updating the model parameters of the intent recognition model according to the loss value of the decision boundary until the intent recognition model meets the training termination conditions, the model parameters including: the decision radius of the target category in the intent recognition model.

[0010] In the process of implementing the above solution, the model parameters of the intent recognition model are updated through comparative learning and training, so that data samples of the same type are more focused and closer, and data samples of different types are farther away from each other, so that the decision radius can achieve better results after learning.

[0011] In an optional implementation of the first aspect, after obtaining the trained intent recognition model, it also includes: obtaining a text to be processed; and using the trained intent recognition model to identify the intent category of the text to be processed.

[0012] In an optional implementation of the first aspect, a trained intent recognition model is used to identify the intent category of the text to be processed, including: using the trained intent recognition model to calculate the text representation vector of the text to be processed, and calculating the vector distance between the text representation vector of the text to be processed and the decision center vector corresponding to each category in the intent recognition model to obtain multiple vector distances; determining whether the category corresponding to the minimum vector distance among the multiple vector distances is an unknown intent category; if so, determining the intent category of the text to be processed as an unknown intent category.

[0013] In an optional implementation of the first aspect, after determining whether the category corresponding to the minimum vector distance among multiple vector distances is an unknown intent category, it also includes: if the category corresponding to the minimum vector distance among multiple vector distances is not an unknown intent category, and the minimum vector distance among multiple vector distances is greater than the decision radius of the category corresponding to the minimum vector distance, then the intent category of the text to be processed is determined as an unknown intent category; if the category corresponding to the minimum vector distance among multiple vector distances is not an unknown intent category, and the minimum vector distance among multiple vector distances is less than the decision radius of the category corresponding to the minimum vector distance, then the intent category of the text to be processed is determined as the known intent category corresponding to the minimum vector distance.

[0014] In the implementation process of the above scheme, the model is trained by combining negative sample data simulating unknown intent and K-clustering contrast learning training, which avoids the situation where the traditional model always classifies text of unknown intent category into known intent category, so that the trained intent recognition model can effectively identify the text category of unknown intent, thereby improving the accuracy of the trained intent recognition model in identifying text of unknown intent.

[0015] In the second aspect, an embodiment of the present application provides an intent recognition model training device, including: an original data acquisition module, used to acquire an original data set, the original data set including: original texts of multiple categories, each of the multiple categories having multiple original texts; a data enhancement simulation module, used to perform data enhancement simulation on the original data set to obtain a simulated data set, the simulated data set including: known intent texts of multiple categories and one category of unknown intent text, wherein the category of the known intent corresponds to the category of the original text, there is no logical conflict between the known intent text and the original text, and there is a logical conflict between the unknown intent text and the original text; a sample text screening module, used to screen out multiple positive sample texts and multiple negative sample texts from the original data set and the simulated data set, the category of the positive sample text is different from the category of the negative sample text; a contrastive learning training module, used to perform contrastive learning training on a text classification neural network using multiple positive sample texts and multiple negative sample texts to obtain a trained intent recognition model, the intent recognition model is used to identify the intent category of the text.

[0016] In an optional implementation of the second aspect, the data enhancement simulation module includes: a text data enhancement submodule, which is used to perform data enhancement on the original text to obtain a simulated changed text; a logical conflict judgment submodule, which is used to judge whether there is a logical conflict between the original text and the changed text corresponding to the original text; and a changed text annotation submodule, which is used to determine the changed text as an unknown intent text if there is a logical conflict between the original text and the changed text corresponding to the original text; otherwise, determine the changed text as a known intent text, and annotate the category of the original text as a category of known intent.

[0017] In an optional implementation of the second aspect, the contrastive learning training module includes: a representation vector calculation submodule, which is used to respectively calculate the second representation vector of the positive sample text and the representation vector of the negative sample text; a target loss determination submodule, which is used to determine the contrastive learning target loss value and the classification learning target loss value of the text classification neural network according to the representation vector of the positive sample text and the representation vector of the negative sample text; a total loss value determination submodule, which is used to determine the total loss value of the text classification neural network according to the contrastive learning target loss value and the classification learning target loss value; and a first parameter updating submodule, which is used to update the model parameters of the intent recognition model according to the total loss value of the text classification neural network until the intent recognition model meets the training termination conditions.

[0018] In an optional implementation of the second aspect, the comparative learning training module also includes: a boundary loss determination submodule, which is used to determine the loss value of the decision boundary in the intent recognition model based on the representation vector of the positive sample text and the representation vector of the negative sample text, the decision boundary is a circle with the decision center vector of the target category of the positive sample text in the intent recognition model as the center point of the circle and the decision radius of the target category in the intent recognition model as the radius of the circle, and the decision center vector is the vector mean of all text representation vectors of the target category calculated by the intent recognition model; a second parameter updating submodule, which is used to update the model parameters of the intent recognition model according to the loss value of the decision boundary until the intent recognition model meets the training termination conditions, and the model parameters include: the decision radius of the target category in the intent recognition model.

[0019] In an optional implementation of the second aspect, the intent recognition model training device also includes: a text processing acquisition module for acquiring text to be processed; and an intent category identification module for using the trained intent recognition model to identify the intent category of the text to be processed.

[0020] In an optional implementation of the second aspect, the intent category identification module includes: a vector distance acquisition submodule, which is used to use the trained intent recognition model to calculate the text representation vector of the text to be processed, and calculate the vector distance between the text representation vector of the text to be processed and the decision center vector corresponding to each category in the intent recognition model to obtain multiple vector distances; an intent category judgment submodule, which is used to judge whether the category corresponding to the minimum vector distance among the multiple vector distances is an unknown intent category; and a first intent determination submodule, which is used to determine the intent category of the text to be processed as an unknown intent category if the category corresponding to the minimum vector distance among the multiple vector distances is an unknown intent category.

[0021] In an optional implementation of the second aspect, the intent category identification module also includes: a second intent determination submodule, which is used to determine the intent category of the text to be processed as an unknown intent category if the category corresponding to the minimum vector distance among multiple vector distances is not an unknown intent category, and the minimum vector distance among multiple vector distances is greater than the decision radius of the category corresponding to the minimum vector distance; and a third intent determination submodule, which is used to determine the intent category of the text to be processed as a known intent category corresponding to the minimum vector distance if the category corresponding to the minimum vector distance among multiple vector distances is not an unknown intent category, and the minimum vector distance among multiple vector distances is less than the decision radius of the category corresponding to the minimum vector distance.

[0022] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory, the memory storing machine-readable instructions executable by the processor, and the machine-readable instructions performing the method described above when executed by the processor.

[0023] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and the computer program executes the method described above when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0025] Figure 1 A flow chart of the intention recognition model training method provided in an embodiment of the present application is shown;

[0026] Figure 2 A schematic diagram of a process for identifying text intent categories provided by an embodiment of the present application is shown;

[0027] Figure 3 A schematic diagram of the structure of the intention recognition model training device provided in an embodiment of the present application is shown;

[0028] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0029] 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 a part of the embodiments in the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the embodiments of the present application claimed for protection, but merely represents the selected embodiments in the embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the embodiments of the present application.

[0030] Before introducing the intent recognition model training method provided in the embodiment of the present application, some concepts involved in the embodiment of the present application are first introduced:

[0031] Contrastive Learning is a very important model training method in self-supervised learning. Its main idea is to use a metric function to measure the loss value of the positive sample that is similar to the sample to be processed, and the loss value of the positive sample that is not similar to the sample to be processed. For example, for any data x, the goal of contrastive learning is to learn an encoder f that can make score(f(x),f(x + ))>>score(f(x),f(x - )); where x + is a positive sample similar to x, x - is a negative sample that is not similar to x. score is a measure of the similarity between samples. There are many indicators that can be used for similarity, such as vector inner product, cosine distance, Euclidean distance, Hamming distance or information entropy, etc.

[0032] It should be noted that the intent recognition model training method provided in the embodiment of the present application can be executed by an electronic device, where the electronic device refers to a device terminal or server with the function of executing a computer program, such as a smart phone, a personal computer, a tablet computer, a personal digital assistant, or a mobile Internet device. A server refers to a device that provides computing services through a network, such as an x86 server and a non-x86 server, and non-x86 servers include mainframes, minicomputers, and UNIX servers.

[0033] The following introduces the application scenarios for which the intent recognition model training method is applicable, including but not limited to: text classification, public opinion monitoring, news classification or sentiment classification, etc. Taking the intent recognition field as an example, the intent recognition model training method is used to train the neural network model. Since the model is trained by using the K-clustering contrast learning method through simulated unknown intent data and data with negative samples, it can effectively avoid the situation where the traditional model always classifies the unknown intent category text into the known intent category, thereby improving the accuracy of the trained intent recognition model in identifying unknown intent text.

[0034] See also Figure 1 The flowchart of the intention recognition model training method provided by the embodiment of the present application is shown; the intention recognition model training method may specifically include:

[0035] Step S110: obtaining an original data set, the original data set including: original texts of multiple categories, each of the multiple categories having multiple original texts.

[0036] The original dataset refers to a dataset that has not been augmented or simulated. It can be manually collected text data and manually annotated intent category labels, etc. Of course, it can also be a text dataset directly collected or annotated by others.

[0037] Step S120: Perform data enhancement simulation on the original data set to obtain a simulated data set, where the simulated data set includes: multiple categories of known intent texts and one category of unknown intent texts, wherein the categories of the known intent texts correspond to the categories of the original texts, there is no logical conflict between the known intent texts and the original texts, and there is a logical conflict between the unknown intent texts and the original texts.

[0038] Step S130: Filter out a plurality of positive sample texts and a plurality of negative sample texts from the original data set and the simulated data set, wherein the categories of the positive sample texts are different from the categories of the negative sample texts.

[0039] Step S140: Use multiple positive sample texts and multiple negative sample texts to perform comparative learning training on the text classification neural network to obtain a trained intent recognition model, which is used to identify the intent category of the text.

[0040] In the implementation process of the above solution, the intent recognition model is trained by using a simulated data set containing texts of unknown intent, and the positive sample texts and negative sample texts are screened out from the original data set and the simulated data set to train the intent recognition model. This avoids the situation where the traditional model always classifies texts of unknown intent categories into known intent categories, so that the trained intent recognition model can effectively identify the text category of unknown intent, thereby improving the accuracy of the trained intent recognition model in identifying texts of unknown intent.

[0041] As an optional implementation of the above step S120, the process of data enhancement simulation may include:

[0042] Step S121: Perform data enhancement on the original text to obtain simulated changed text.

[0043] The implementation method of the above-mentioned step S121 includes: randomly replacing at least one word in the original text using a mask (MASK) or at least one randomly selected word; and / or, randomly deleting at least one word in the original text; and / or, randomly selecting at least one word from the word library and adding the at least one word to the original text; and / or, randomly selecting at least one word from multiple words in the original text and moving the at least one word to the starting position of the original text.

[0044] Step S122: Determine whether there is a logical conflict between the original text and the changed text corresponding to the original text.

[0045] Step S123: If there is a logical conflict between the original text and the changed text corresponding to the original text, the changed text is determined as an unknown intention text.

[0046] Step S124: If there is no logical conflict between the original text and the modified text corresponding to the original text, the modified text is determined as a text of known intent, and the category of the original text is marked as the category of the known intent.

[0047] The implementation method of the above steps S122 to S124 is, for example: a neural network model that can determine whether there is a logical conflict between two texts can be trained in advance. This neural network model specifically determines the relationship between the two texts, and the relationship here includes: logical conflict (Contradiction), neutral (Neutral) relationship and implication (Entailment) relationship; therefore, the neural network model is also called an implication model. If the original text is taken as the premise P, and the changed text is taken as the hypothesis H, if H can be inferred from P, then there is an implication relationship between P and H; if there is a logical contradiction between H and P, there is a logical conflict between P and H; if there is neither a logical contradiction nor an implication relationship between H and P, then there is a neutral relationship between P and H. Of course, it can also be judged by the services provided on other servers, or by using manual methods to judge whether there is a logical conflict between two texts.

[0048] The training process of the above-mentioned implication model and the intention recognition process are, for example: obtaining premise text, reasoning text and sample labels, the sample label is the implication relationship between the premise text and the reasoning text, and the implication relationship includes a logical conflict category; using the premise text, reasoning text and sample labels to train the implication neural network to obtain the trained implication model. Then, the trained implication model is used to determine whether there is a logical conflict between the original text and the changed text corresponding to the original text. If there is a logical conflict between the original text and the changed text corresponding to the original text, the changed text is determined as an unknown intention text. If there is no logical conflict between the original text and the changed text corresponding to the original text, the changed text is determined as a known intention text, and the category of the original text is marked as a known intention category.

[0049] It is understandable that there are many ways to implement the data enhancement simulation in the above step S120, including but not limited to: randomly inserting words, deleting words, changing or replacing words, or changing the order of words, etc., to the known intent text or the unknown intent text, so as to obtain more known intent text or unknown intent text.

[0050] As an optional implementation of step S130, a variety of screening methods may be used to screen out multiple positive sample texts and multiple negative sample texts from the original data set and / or the simulated data set, where the categories of the positive sample texts and the negative sample texts are different. For example: a plurality of first original texts randomly screened out from the original data set are determined as positive sample texts, and unknown intent texts and / or known intent texts different from the first original text category screened out from the simulated data set are determined as negative sample texts; and / or, unknown intent texts screened out from the simulated data set are determined as positive sample texts, and original texts randomly screened out from the original data set or known intent texts screened out from the simulated data set are determined as negative sample texts; and / or, a plurality of first category texts randomly screened out from the original data set and the simulated data set are determined as positive sample texts, and a second category text randomly screened out from the original data set and the simulated data set is determined as negative sample text.

[0051] As an optional implementation of step S140, the target loss value can also be calculated using K-clustering contrastive learning, and the intent recognition model can be trained based on the target loss value. The main idea of ​​K-clustering contrastive learning is to make multiple samples of the same type close to each other during training and keep samples of different types away from each other on the basis of contrastive learning. The process of training the intent recognition model using the K-clustering contrastive learning method here may include:

[0052] Step S141: Calculate the representation vector of the positive sample text and the representation vector of the negative sample text respectively.

[0053] There are many ways to calculate the above representation vectors, for example: using a pre-trained language model to calculate the representation vector, or sequentially segmenting and vectorizing the positive sample text and the negative sample text to obtain an embedding vector matrix, the embedding vector matrix includes sentence component vectors, token embedding vectors and / or position embedding vectors, and fusing the sentence component vectors, token embedding vectors, position embedding vectors and / or reverse position embedding vectors to obtain the representation vectors of the above positive sample texts and the representation vectors of the negative sample texts.

[0054] Step S142: Determine the comparison learning target loss value and the classification learning target loss value of the text classification neural network according to the representation vector of the positive sample text and the representation vector of the negative sample text.

[0055] The first calculation method of the comparison learning target loss value in step S142 is, for example, to use the formula The representation vectors of the positive sample text and the negative sample text are calculated to obtain the contrast learning target loss value of the text classification neural network; where L krepresents the target loss value of contrastive learning for K clustering, N is the total number of samples, which includes positive samples (i.e. samples of the same category as the currently selected sample) and negative samples (i.e. samples of different categories from the currently selected sample), k is the number of randomly selected positive sample texts of this category, and v i is the representation vector of the currently selected sample (i.e., the i-th sample), is the representation vector of the randomly selected positive sample text, is the representation vector of the randomly selected negative sample, τ is the preset training hyperparameter, I i≠j Indicates that the sample vector is not calculated with itself.

[0056] The second calculation method of the comparison learning target loss value in the above step S142 is, for example, using the formula The representation vectors of the positive sample text and the negative sample text are calculated to obtain the contrast learning target loss value of the text classification neural network; where L k represents the contrastive learning objective loss value of K clustering, v i represents the representation vector of the randomly selected i-th positive sample text (i.e. from the same category), v j represents the representation vector of the randomly selected jth positive sample text (i.e. from the same category), v i , v j ∈V + , i≠j means that the representation vectors of the i-th and j-th positive sample texts are both representation vectors of the same category in the positive sample text set, v - represents the representation vector of one of the negative sample texts, and τ is the preset training hyperparameter.

[0057] The classification learning target loss value in step S142 is calculated by, for example, using the formula The representation vector of the positive sample text and the representation vector of the negative sample text are calculated to obtain the classification learning target loss value of the text classification neural network; where L CE represents the value calculated by the cross entropy loss function (i.e., the target loss value for classification learning), N represents the total number of samples, where the samples include: positive sample text and negative sample text, y represents the true label of the text intent category of the sample, and p(x) represents the text classification neural network predicting the representation vector of the positive sample text or the representation vector of the negative sample text to obtain the predicted text intent category.

[0058] Step S143: Determine the total loss value of the text classification neural network according to the comparison learning target loss value and the classification learning target loss value.

[0059] The implementation method of the above step S143 is, for example, to use the formula Loss = λ·Lk +(1-λ)·L CE The classification learning target loss value and the contrast learning target loss value are calculated to obtain the total loss value of the text classification neural network; where Loss represents the total loss value, λ represents the smoothing value between the classification learning target loss value and the contrast learning target loss value, and the smoothing value is a hyperparameter that needs to be adjusted according to the training situation, and L k represents the contrastive learning objective loss value of K clustering, L CE Indicates that the value calculated by the cross entropy loss function is used as the classification learning target loss value.

[0060] Step S144: Update the model parameters of the intent recognition model according to the total loss value of the text classification neural network until the intent recognition model meets the training termination conditions, thereby obtaining a trained intent recognition model.

[0061] The implementation method of the above step S144 is, for example: updating the model parameters of the intent recognition model according to the total loss value of the text classification neural network until the intent recognition model meets the training termination condition, where the termination condition may be that the trained intent recognition model is obtained until the accuracy of the text classification neural network no longer increases or the number of iterations (epochs) is greater than a preset threshold. The above preset threshold may also be set according to the specific situation, for example, to 100 or 1000.

[0062] As another optional implementation of step S140, after calculating the representation vector, the decision radius in the intent recognition model can also be learned. Since the K-clustering contrast learning method is also used in the process of learning the decision radius, the same type of data samples are more focused and closer, and the different types of data samples are far away from each other, so that the decision radius can achieve better results after learning. The process of learning the decision radius here may include:

[0063] Step S145: Determine the loss value of the decision boundary in the intent recognition model based on the representation vector of the positive sample text and the representation vector of the negative sample text. The decision boundary is a circle with the decision center vector of the target category of the positive sample text in the intent recognition model as the center point of the circle and the decision radius of the target category in the intent recognition model as the radius of the circle.

[0064] The decision center vector is the vector mean of all representation vectors of the target category calculated by the intent recognition model, which can be understood as the center point of all sample points and is expressed as Among them, c k represents the decision center vector of the k-th category, that is, the vector mean of all representation vectors of the k-th category, y i represents the true label of the text intent category of the i-th sample in the k-th category, zi represents the representation vector of the i-th sample in the k-th category, S k Represents the number of samples of all texts in the kth category.

[0065] Step S146: Update the model parameters of the intent recognition model according to the loss value of the decision boundary until the intent recognition model meets the training termination condition, and the model parameters include: the decision radius of the target category in the intent recognition model.

[0066] The implementation of the above steps S145 to S146 may specifically include the following:

[0067] First, the first vector distance between the representation vector of the positive sample text and the decision center vector, and the second vector distance between the representation vector of the negative sample text and the decision center vector of the target category in the intent classification model are calculated respectively.

[0068] Then, the loss value of the decision boundary is calculated according to the first vector distance and the second vector distance. Specifically, the loss value of the decision boundary can be calculated using the following formula.

[0069]

[0070]

[0071] L t =L p +L n ;

[0072] Among them, L t Represents the loss value of the decision boundary calculated by the total loss function, L p Represents the loss function of the positive sample text, L n represents the loss function of negative sample text, N represents the number of all sample texts in the training data; z i represents the vector of the i-th positive sample text (i.e. from the same category), represents the i-th negative sample text (i.e. from different categories) representation vector, y i Represents the category label corresponding to the i-th positive sample text, Represents the decision center vector corresponding to the target category, The Euclidean distance between the representation vector of the positive sample text and the decision center vector corresponding to its corresponding target category (i.e., the first vector distance), The Euclidean distance between the representation vector of the negative sample text and the decision center vector corresponding to its corresponding target category (i.e., the second vector distance), represents the decision radius of the target category corresponding to the i-th sample text in the intent classification model. η is the proportion of the loss function of negative samples (for example, 0.005 to 1), α i is the weight of whether the negative sample is in the expansion area, β i is the weight of whether the negative sample is in the contraction area, δ i Indicates whether the target category is within the decision boundary. The above α i , β i and δ i The definitions of these three can be expressed using the formula:

[0073]

[0074]

[0075] Among them, z i Represents the representation vector of the i-th positive sample text (i.e. from the same category), Represents the representation vector of the i-th negative sample text (i.e., from different categories), y i represents the target category (i.e., category label) corresponding to the i-th sample text, Represents the decision center vector corresponding to the target category, represents the hyperparameter of a given expansion bound, represents a given shrinkage boundary hyperparameter, the above and Both can be set according to specific circumstances.

[0076] Finally, the loss value of the decision boundary calculated by the above formula is used to update the model parameters of the intent recognition model until the intent recognition model meets the training termination conditions. The model parameters include: the decision radius of the target category in the intent recognition model, and the training termination conditions include: the accuracy of the neural network no longer increases or the number of iterations (epochs) is greater than the preset threshold, which can also be set according to the specific situation, such as 100 or 1000.

[0077] See also Figure 2 The flowchart of identifying the text intent category provided by the embodiment of the present application is shown; as an optional implementation of the intent recognition model training method, after obtaining the trained intent recognition model, the intent recognition model can also be used to identify the text intent category. The process of identifying the text intent category may include:

[0078] Step S210: Obtain the text to be processed.

[0079] Step S220: Use the trained intent recognition model to identify the intent category of the text to be processed.

[0080] As an optional implementation of step S220, the text intent may also be determined according to the minimum vector distance corresponding to the text to be processed. The process of determining the text intent may include:

[0081] Step S221: Use the trained intent recognition model to calculate the text representation vector of the text to be processed, and calculate the vector distance between the text representation vector of the text to be processed and the decision center vector corresponding to each category in the intent recognition model to obtain multiple vector distances.

[0082] Step S222: Determine whether the category corresponding to the minimum vector distance among the multiple vector distances is an unknown intent category.

[0083] Step S223: If the category corresponding to the minimum vector distance among the multiple vector distances is an unknown intent category, the intent category of the text to be processed is determined as the unknown intent category.

[0084] As an optional implementation of step S220, after step S222, the text intent may also be determined according to the decision radius. The process of determining the text intent may include:

[0085] Step S224: If the category corresponding to the minimum vector distance among the multiple vector distances is not an unknown intent category, and the minimum vector distance among the multiple vector distances is greater than the decision radius of the category corresponding to the minimum vector distance, the intent category of the text to be processed is determined to be an unknown intent category.

[0086] Step S225: If the category corresponding to the minimum vector distance among multiple vector distances is not an unknown intent category, and the minimum vector distance among multiple vector distances is smaller than the decision radius of the category corresponding to the minimum vector distance, then the intent category of the text to be processed is determined as the known intent category corresponding to the minimum vector distance.

[0087] The above steps S222 to S225 can be expressed by the formula:

[0088]

[0089] in, represents the final intent category determined for the intent category of the text to be processed, l0 represents the unknown intent category, and l x represents the known intent text category corresponding to the minimum vector distance among multiple vector distances. 1≤x≤m means that the category corresponding to the minimum vector distance is selected from the known intent categories corresponding to multiple vector distances. m+1 represents the unknown intent text category in the simulated dataset, r represents the representation vector of the sample, and c j represents the decision center vector corresponding to the sample j category, b jIt represents the decision boundary of the category corresponding to the sample j, and otherwise represents the remaining cases.

[0090] See also Figure 3 The structure diagram of the intention recognition model training device provided by the embodiment of the present application is shown; the embodiment of the present application provides an intention recognition model training device 300, including:

[0091] The original data acquisition module 310 is used to acquire an original data set, where the original data set includes: original texts of multiple categories, each of which has multiple original texts.

[0092] The data enhancement simulation module 320 is used to perform data enhancement simulation on the original data set to obtain a simulated data set, which includes: multiple categories of known intent texts and one category of unknown intent texts, wherein the categories of the known intent correspond to the categories of the original texts, there is no logical conflict between the known intent texts and the original texts, and there is a logical conflict between the unknown intent texts and the original texts.

[0093] The sample text screening module 330 is used to screen out a plurality of positive sample texts and a plurality of negative sample texts from the original data set and the simulated data set, and the categories of the positive sample texts are different from the categories of the negative sample texts.

[0094] The contrastive learning training module 340 is used to perform contrastive learning training on a text classification neural network using a plurality of positive sample texts and a plurality of negative sample texts to obtain a trained intent recognition model, which is used to recognize the intent category of the text.

[0095] Optionally, in an embodiment of the present application, the data enhancement simulation module includes:

[0096] The text data enhancement submodule is used to perform data enhancement on the original text to obtain simulated changed text.

[0097] The logic conflict judgment submodule is used to judge whether there is a logic conflict between the original text and the changed text corresponding to the original text.

[0098] The change text annotation submodule is used to determine the change text as unknown intention text if there is a logical conflict between the original text and the change text corresponding to the original text; otherwise, determine the change text as known intention text and annotate the category of the original text as the category of the known intention.

[0099] Optionally, in an embodiment of the present application, the comparative learning training module includes:

[0100] The representation vector calculation submodule is used to calculate the representation vector of the positive sample text and the representation vector of the negative sample text respectively.

[0101] The target loss determination submodule is used to determine the contrast learning target loss value and the classification learning target loss value of the text classification neural network according to the representation vector of the positive sample text and the representation vector of the negative sample text.

[0102] The total loss value determination submodule is used to determine the total loss value of the text classification neural network according to the comparison learning target loss value and the classification learning target loss value.

[0103] The first parameter updating submodule is used to update the model parameters of the intent recognition model according to the total loss value of the text classification neural network until the intent recognition model meets the training termination condition.

[0104] Optionally, in the embodiment of the present application, the comparative learning training module further includes:

[0105] The boundary loss determination submodule is used to determine the loss value of the decision boundary in the intent recognition model based on the representation vector of the positive sample text and the representation vector of the negative sample text. The decision boundary is a circle with the decision center vector of the target category of the positive sample text in the intent recognition model as the center point of the circle and the decision radius of the target category in the intent recognition model as the radius of the circle. The decision center vector is the vector mean of all text representation vectors of the target category calculated by the intent recognition model.

[0106] The second parameter updating submodule is used to update the model parameters of the intent recognition model according to the loss value of the decision boundary until the intent recognition model meets the training termination condition, and the model parameters include: the decision radius of the target category in the intent recognition model.

[0107] Optionally, in the embodiment of the present application, the intention recognition model training device further includes:

[0108] The processing text acquisition module is used to obtain the text to be processed.

[0109] The intent category identification module is used to identify the intent category of the text to be processed using the trained intent identification model.

[0110] Optionally, in an embodiment of the present application, the intent category identification module includes:

[0111] The vector distance acquisition submodule is used to calculate the text representation vector of the text to be processed using the trained intent recognition model, and calculate the vector distance between the text representation vector of the text to be processed and the decision center vector corresponding to each category in the intent recognition model to obtain multiple vector distances.

[0112] The intent category judgment submodule is used to judge whether the category corresponding to the minimum vector distance among multiple vector distances is an unknown intent category.

[0113] The first intention determination submodule is used to determine the intention category of the text to be processed as an unknown intention category if the category corresponding to the minimum vector distance among the multiple vector distances is an unknown intention category.

[0114] Optionally, in the embodiment of the present application, the intent category identification module further includes:

[0115] The second intention determination submodule is used to determine the intention category of the text to be processed as an unknown intention category if the category corresponding to the minimum vector distance among multiple vector distances is not an unknown intention category, and the minimum vector distance among multiple vector distances is greater than the decision radius of the category corresponding to the minimum vector distance.

[0116] The third intention determination submodule is used to determine the intention category of the text to be processed as the known intention category corresponding to the minimum vector distance if the category corresponding to the minimum vector distance among multiple vector distances is not an unknown intention category, and the minimum vector distance among multiple vector distances is less than the decision radius of the category corresponding to the minimum vector distance.

[0117] It should be understood that the device corresponds to the above-mentioned intent recognition model training method embodiment, and can execute the various steps involved in the above-mentioned method embodiment. The specific functions of the device can be found in the description above. To avoid repetition, the detailed description is appropriately omitted here. The device includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the operating system (OS) of the device.

[0118] See also Figure 4 An electronic device 400 provided in an embodiment of the present application includes: a processor 410 and a memory 420, wherein the memory 420 stores machine-readable instructions executable by the processor 410, and when the machine-readable instructions are executed by the processor 410, the above method is executed.

[0119] The embodiment of the present application further provides a computer-readable storage medium 430 , on which a computer program is stored. When the computer program is executed by the processor 410 , the above method is executed.

[0120] Among them, the computer-readable storage medium 430 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, disk or optical disk.

[0121] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device 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.

[0122] In several embodiments provided by the embodiments of the present application, it should be understood that the disclosed device and method can also be implemented in other ways. The device embodiments described above are only schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible implementation architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a part of a module, a program segment or a code, and a part of a module, a program segment or a code includes one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also be different from the order of occurrence marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which is mainly determined by the functions involved.

[0123] It is understandable that the "first" and "second" in the embodiments of the present application are used to distinguish similar objects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not necessarily limit the difference.

[0124] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0125] The above description is only an optional implementation manner of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiments of the present application, which should be covered within the protection scope of the embodiments of the present application.

Claims

1. A method for training an intent recognition model. It is characterized in that include: Acquire an original data set, wherein the original data set includes: original texts of multiple categories, each of the multiple categories having multiple original texts; Performing data enhancement simulation on the original data set to obtain a simulated data set, the simulated data set comprising: multiple categories of known intent texts and one category of unknown intent texts, wherein the categories of the known intents correspond to the categories of the original texts, the known intent texts do not have a logical conflict with the original texts, and the unknown intent texts have a logical conflict with the original texts; Screening out a plurality of positive sample texts and a plurality of negative sample texts from the original data set and the simulated data set, wherein the categories of the positive sample texts are different from the categories of the negative sample texts; The multiple positive sample texts and the multiple negative sample texts are used to perform comparative learning training on the text classification neural network to obtain a trained intent recognition model, where the intent recognition model is used to recognize the intent category of the text.

2. The method according to claim 1, It is characterized in that The performing data enhancement simulation on the original data set includes: Performing data enhancement on the original text to obtain a simulated changed text; Determine whether there is a logical conflict between the original text and the changed text corresponding to the original text; If so, the changed text is determined as the unknown intention text; otherwise, the changed text is determined as the known intention text, and the category of the original text is marked as the category of the known intention.

3. The method according to claim 1, It is characterized in that The using the multiple positive sample texts and the multiple negative sample texts to perform comparative learning training on the text classification neural network includes: Calculating the representation vector of the positive sample text and the representation vector of the negative sample text respectively; Determining a comparison learning target loss value and a classification learning target loss value of the text classification neural network according to the representation vector of the positive sample text and the representation vector of the negative sample text; Determine the total loss value of the text classification neural network according to the comparison learning target loss value and the classification learning target loss value; The model parameters of the intent recognition model are updated according to the total loss value of the text classification neural network until the intent recognition model meets the training termination condition.

4. The method according to claim 3, It is characterized in that After respectively calculating the representation vector of the positive sample text and the representation vector of the negative sample text, the method further includes: Determine the loss value of the decision boundary in the intent recognition model according to the representation vector of the positive sample text and the representation vector of the negative sample text, wherein the decision boundary is a circle with the decision center vector of the target category of the positive sample text in the intent recognition model as the center point of the circle and the decision radius of the target category in the intent recognition model as the radius of the circle, and the decision center vector is the vector mean of all text representation vectors of the target category calculated by the intent recognition model; The model parameters of the intent recognition model are updated according to the loss value of the decision boundary until the intent recognition model meets the training termination condition, and the model parameters include: the decision radius of the target category in the intent recognition model.

5. The method according to any one of claims 1 to 4, It is characterized in that After obtaining the trained intent recognition model, the method further includes: Get the text to be processed; The trained intent recognition model is used to identify the intent category of the text to be processed.

6. The method according to claim 5, It is characterized in that The step of using the trained intent recognition model to identify the intent category of the text to be processed includes: Using the trained intention recognition model to calculate the text representation vector of the text to be processed, and calculating the vector distance between the text representation vector of the text to be processed and the decision center vector corresponding to each category in the intention recognition model to obtain multiple vector distances; Determine whether a category corresponding to a minimum vector distance among the multiple vector distances is an unknown intent category; If so, the intent category of the text to be processed is determined to be an unknown intent category.

7. The method according to claim 6, It is characterized in that After determining whether a category corresponding to the minimum vector distance among the multiple vector distances is an unknown intent category, the method further includes: If the category corresponding to the minimum vector distance among the multiple vector distances is not an unknown intent category, and the minimum vector distance among the multiple vector distances is greater than the decision radius of the category corresponding to the minimum vector distance, the intent category of the text to be processed is determined to be an unknown intent category; If the category corresponding to the minimum vector distance among the multiple vector distances is not an unknown intent category, and the minimum vector distance among the multiple vector distances is smaller than the decision radius of the category corresponding to the minimum vector distance, the intent category of the text to be processed is determined as the known intent category corresponding to the minimum vector distance.

8. An intention recognition model training device, It is characterized in that include: The original data acquisition module is used to acquire an original data set, wherein the original data set includes: original texts of multiple categories, each of which has multiple original texts; A data enhancement simulation module is used to perform data enhancement simulation on the original data set to obtain a simulated data set, wherein the simulated data set includes: multiple categories of known intent texts and one category of unknown intent texts, wherein the categories of the known intents correspond to the categories of the original texts, the known intent texts do not have a logical conflict with the original texts, and the unknown intent texts have a logical conflict with the original texts; A sample text screening module, used to screen out a plurality of positive sample texts and a plurality of negative sample texts from the original data set and the simulated data set, wherein the category of the positive sample text is different from the category of the negative sample text; The contrastive learning training module is used to perform contrastive learning training on the text classification neural network using the multiple positive sample texts and the multiple negative sample texts to obtain a trained intent recognition model, wherein the intent recognition model is used to recognize the intent category of the text.

9. An electronic device, It is characterized in that include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the machine-readable instructions are executed by the processor, the method according to any one of claims 1 to 7 is performed.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.

Citation Information

Patent Citations

  • Unknown intention recognition method and device, equipment and storage medium

    CN112966088A

  • Text classification method and device

    CN113849653A