Model training method, intention recognition method, device, equipment and storage medium
By training the intent matching model through adversarial perturbation processing and contrastive learning methods, the problem of insufficient robustness of the intent matching model in the existing technology is solved, and a more efficient intent recognition effect is achieved.
Patent Information
- Application Number
- CN202211037465.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-26
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-08-26
AI Technical Summary
Existing intent matching models are unable to accurately determine whether to reject the intent corresponding to a user's question due to the limited number of training samples labeled with rejection intent, resulting in poor robustness.
By obtaining multiple positive and negative sample pairs, adversarial perturbation processing is performed. The feature vector similarity of the sample pairs and negative sample pairs after adversarial perturbation processing is used to iteratively train the intent matching model to enhance the robustness of the model. The intent matching model is trained by minimizing the loss of similar samples and maximizing the loss of dissimilar samples through contrastive learning method.
The adaptability and accuracy of the intent matching model are improved, and it can more accurately determine whether to reject the intent corresponding to the text to be recognized, reduce training costs, and solve the problem of insufficient model robustness in existing technologies.
Smart Images

Figure CN116150314B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a model training method, intent recognition method, apparatus, device and storage medium. Background Art
[0002] With the rapid development of computing and internet technologies, more and more intelligent interaction methods have become increasingly integrated into daily life. For example, in outbound conversational bot scenarios, the bot can identify the user's intent based on the question and provide an appropriate answer. If the user's question falls outside the bot's response range, the bot refuses to identify (i.e., rejects) the intent and provides a fallback answer based on pre-set rules.
[0003] Currently, rejection is typically performed using the following approach: inputting a user question into an intent matching model, obtaining matching results based on the confidence level of each intent category corresponding to the user question, and then determining whether to reject the intent corresponding to the user question based on the matching results. The intent matching model is trained using training samples labeled with rejection intents. However, the limited number of training samples labeled with rejection intents makes it difficult for the obtained intent matching model to accurately determine whether to reject the intent corresponding to the user question. Summary of the Invention
[0004] The present application provides a model training method, intent recognition method, apparatus, device and storage medium to solve the problem that the current intent matching model cannot accurately determine whether to reject the intent corresponding to the text to be recognized.
[0005] In a first aspect, the present application provides a model training method, comprising:
[0006] Acquire multiple first training samples, where the first training samples include a first positive sample pair or a first negative sample pair, where the intent categories of the two first positive samples in the first positive sample pair are the same, and the intent categories of the two first negative samples in the first negative sample pair are different, and the first training samples include a standard question and a question similar to the standard question;
[0007] Performing adversarial perturbation processing on each first positive sample pair to obtain each first positive sample pair after adversarial perturbation processing;
[0008] Inputting multiple first positive sample pairs and multiple first negative sample pairs after adversarial perturbation processing into the initial intent matching model to obtain a first feature vector set, where the first feature vector set includes feature vectors corresponding to the two first positive samples in each first positive sample pair and feature vectors corresponding to the two first negative samples in each first negative sample pair;
[0009] Obtaining a first similarity of the feature vectors corresponding to the two first positive samples in each first positive sample pair in the first feature vector set, and a second similarity of the feature vectors corresponding to the two first negative samples in each first negative sample pair;
[0010] According to the first similarity and the second similarity, a loss function value corresponding to the loss function of the initial intent matching model is determined; according to the loss function value, the initial intent matching model is iteratively trained to obtain the intent matching model.
[0011] In a second aspect, the present application provides an intent recognition method, comprising:
[0012] Get the text to be recognized;
[0013] Inputting the text to be recognized into the intent matching model and matching it with the standard question and similar questions in the intent matching model to obtain a second matching result, where the intent matching model is a model trained using the model training method described in the first aspect of the present application;
[0014] According to the second matching result, it is determined whether to reject the text to be recognized.
[0015] In a third aspect, the present application provides a model training device, comprising:
[0016] A first acquisition module is configured to acquire a plurality of first training samples, the first training samples comprising a first positive sample pair or a first negative sample pair, the two first positive samples in the first positive sample pair having the same intent category, the two first negative samples in the first negative sample pair having different intent categories, and the first training samples comprising a standard question and a question similar to the standard question;
[0017] a processing module, configured to perform adversarial perturbation processing on each first positive sample pair to obtain each first positive sample pair after adversarial perturbation processing;
[0018] A second acquisition module is configured to input the plurality of first positive sample pairs and the plurality of first negative sample pairs after adversarial perturbation processing into the initial intent matching model to obtain a first feature vector set, where the first feature vector set includes feature vectors corresponding to the two first positive samples in each first positive sample pair and feature vectors corresponding to the two first negative samples in each first negative sample pair;
[0019] A third acquisition module is configured to acquire a first similarity of the feature vectors corresponding to the two first positive samples in each first positive sample pair in the first feature vector set, and a second similarity of the feature vectors corresponding to the two first negative samples in each first negative sample pair;
[0020] The training module is used to determine the loss function value corresponding to the loss function of the initial intent matching model based on the first similarity and the second similarity; and iteratively train the initial intent matching model based on the loss function value to obtain the intent matching model.
[0021] In a fourth aspect, the present application provides an intention recognition device, comprising:
[0022] An acquisition module is used to obtain the text to be recognized;
[0023] a matching module, configured to input the text to be recognized into an intent matching model, and match it with a standard question and similar questions in the intent matching model to obtain a second matching result, wherein the intent matching model is a model trained using the model training method described in the first aspect of the present application;
[0024] The determination module is used to determine whether to reject the text to be recognized based on the second matching result.
[0025] In a fifth aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0026] Memory stores computer-executable instructions;
[0027] The processor executes the computer-executable instructions stored in the memory to implement the model training method as described in the first aspect of this application.
[0028] In a sixth aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0029] Memory stores computer-executable instructions;
[0030] The processor executes the computer-executable instructions stored in the memory to implement the intention recognition method as described in the second aspect of the present application.
[0031] In the seventh aspect, the present application provides a computer-readable storage medium, which stores computer program instructions. When the computer program instructions are executed by a processor, the model training method described in the first aspect of the present application is implemented.
[0032] In an eighth aspect, the present application provides a computer-readable storage medium, in which computer program instructions are stored. When the computer program instructions are executed by a processor, the intention recognition method described in the second aspect of the present application is implemented.
[0033] In a ninth aspect, the present application provides a computer program product, comprising a computer program, which, when executed by a processor, implements the model training method as described in the first aspect of the present application.
[0034] In a tenth aspect, the present application provides a computer program product, comprising a computer program, which, when executed by a processor, implements the intention recognition method as described in the second aspect of the present application.
[0035] The model training method, intent recognition method, apparatus, device and storage medium provided in the present application obtain multiple first training samples, where the first training samples include a first positive sample pair or a first negative sample pair, perform adversarial perturbation processing on each first positive sample pair, and input the multiple first positive sample pairs and the multiple first negative sample pairs after adversarial perturbation processing into the initial intent matching model to obtain a first feature vector set; determine the loss function value corresponding to the loss function of the initial intent matching model based on the first similarity of the feature vectors corresponding to the two first positive samples in each first positive sample pair in the first feature vector set, and the second similarity of the feature vectors corresponding to the two first negative samples in each first negative sample pair; and iteratively train the initial intent matching model based on the loss function value to obtain an intent matching model. Since the present application performs adversarial perturbation processing on each first positive sample pair, the data domain of the first positive sample is increased, thereby improving the adaptability of the intent matching model and making the intent matching model more robust; at the same time, the intent matching model is obtained by iterative training based on the first similarity and the second similarity. During the training process, the loss between the two first positive samples in the first positive sample pair is minimized by maximizing the first similarity, and the loss between the two first negative samples in the first negative sample pair is maximized by minimizing the second similarity. Therefore, the obtained intent matching model can accurately determine whether to reject the intent corresponding to the text to be recognized. In addition, since the first training samples include standard questions and similar questions of the standard questions, there is no need to mark training samples with rejected intents. Therefore, the training efficiency of the intent matching model can be improved and the training cost can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0037] Figure 1 A schematic diagram of an application scenario of the model training method provided in one embodiment of the present application;
[0038] Figure 2 A flowchart of a model training method provided in one embodiment of the present application;
[0039] Figure 3 A schematic diagram of a double-tower structure model provided in one embodiment of the present application;
[0040] Figure 4 A schematic diagram of the structure of the intent knowledge base provided in one embodiment of the present application;
[0041] Figure 5 A schematic diagram of a comparative learning training method provided in one embodiment of the present application;
[0042] Figure 6 A flowchart of an intent recognition method provided in one embodiment of the present application;
[0043] Figure 7 A schematic diagram of a robot conversation process provided in one embodiment of the present application;
[0044] Figure 8 A schematic diagram of the structure of a model training device provided in one embodiment of the present application;
[0045] Figure 9 A schematic diagram of the structure of an intention recognition device provided in one embodiment of the present application;
[0046] Figure 10 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0047] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0048] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0049] First, some technical terms involved in this application are explained:
[0050] Bidirectional Encoder Representations from Transformers (BERT), a language representation model represented by a bidirectional encoder using a Transformer. This model consists of a pre-training phase and a fine-tuning phase, where the fine-tuning phase uses a pre-trained language model. It is widely used in tasks such as text classification and text matching.
[0051] Question Answering System (QA) is an advanced form of information retrieval system that can answer questions raised by users in natural language accurately and concisely.
[0052] Contrastive Learning, a type of self-supervised learning, learns the feature representation of a sample by comparing it with positive and negative samples in feature space. The core of its training is to minimize the loss between two similar samples and maximize the loss between two dissimilar samples.
[0053] Intent recognition is one of the most fundamental tasks of a dialogue system. It identifies the intent of user input and classifies the user's intent, corresponding to a specific business problem. This is essentially a text classification problem in natural language processing (NLP).
[0054] Rejected intent, also known as other intent, generally refers to a collection of intent categories other than the intent to be recognized. For example, if the text to be recognized is "Query train tickets from City 1 to City 2" input to a bank customer service robot, the intent of the text to be recognized is not within the scope of the bank customer service robot's answer, so it should be recognized as other intent.
[0055] Intent recognition is the most critical step in conversations between customer service robots and users. A robot that accurately recognizes intent can effectively assist businesses and is the core of business automation. Typical customer service robots are typically used in specific scenarios. When a user's question falls outside the robot's scope of response, the robot needs to determine whether the question falls within its scope and provide a fallback answer based on pre-set rules. This prevents the robot from pretending to know something and negatively impacting the user experience. However, determining whether a question falls within its scope remains a technical challenge in this area.
[0056] For example, in the case of outbound call chatbots, due to the time-sensitive and rapid nature of outbound call conversations, many bots are defined on the fly based on scenarios like marketing and debt collection, designed solely to handle a specific marketing activity. Therefore, these bots are typically trained on small-sample intent classification scenarios, using a limited number of training samples. Furthermore, call centers typically have a large number of bots for various business scenarios, necessitating automated training and immediate use using existing data.
[0057] In a related art, whether a pre-trained model (such as BERT) or a text convolutional neural network (textCNN) is used as the baseline model for outbound call robot intent recognition, the final step essentially requires a softmax function (a normalized exponential function) to convert the model output into a logits (i.e., unnormalized probability) score (between 0 and 1) for each intent classification (corresponding to different intent categories). A threshold is usually set to filter out data with insufficient confidence. For example, if the threshold is set to 0.5, taking a five-category model as an example, if a text is passed through the model and the resulting logits list of intent classifications is [0.1, 0.05, 0.45, 0.15, 0.25], and the maximum value in the logits list is less than the threshold of 0.5, it can be considered that the text does not match any intent and is identified as having other intents, i.e., the text is rejected. This related art uses a threshold calculation method for rejection, but the logits score output by the model is not a similarity score. The higher the score, the more similar it is. It is simply a normalized result of the score that the model believes should be classified into which category. Specifically, the model has the following shortcomings: (1) Different intent classifications should theoretically not use the same threshold. For example, the effect of setting the binary classification threshold to 0.8 is completely different from that of setting the binary classification threshold to 0.8. (2) Even if both are binary classifications (or other classifications), the logits of different models are very different, which is very obvious in NLP scenarios. (3) The logits score is not a similarity score. A low score does not completely indicate that the text with a low score does not belong to a certain category. (4) The model is obtained by training samples labeled with rejection intent. However, the training samples labeled with rejection intent are limited, resulting in poor robustness of the obtained model.
[0058] Another related technique involves classifying text that should not be answered by the robot as "other intents," converting this task into an N+1 classification task. For example, a robot designed to detect customer resistance might detect: Category 1: The customer explicitly refuses to be disturbed; Category 2: The customer mentions a complaint. This is a two-classification problem. By adding a new intent, Category 3: "other intents," the two-classification task is converted into a three-classification task. For many high-traffic customer service robot scenarios, "other intents" can be regularly labeled and sampled, added to the training model, and after multiple iterations, sufficient "other intent" data can be obtained. This technique is the simplest and most effective approach. However, this related technology is not applicable to the outbound conversation robot scenario. The reasons are: (1) Training data for other intents is difficult to obtain. Users’ answers are varied and it is difficult to obtain some effective other intent data, that is, it is difficult to recall samples of other intents, resulting in poor robustness of the model; (2) Due to the large number of robots used for outbound conversations, the robot intent classification systems are different. For a specific robot, there is mostly no historical data to refer to for the robot’s other intent classification; (3) Even if there is a small amount of data that can be determined as other intent classification, the sample space of this part of the data is only a small part of the sample space of all other intents, that is, these classified data will only allow the model to recognize the way of asking questions with this part of other intents, and the vast majority of other intent classifications cannot be recalled, resulting in the obtained other intent classification being only understood as a new classification composed of a small amount of data.
[0059] Based on the above problems, the present application provides a model training method, intent recognition method, apparatus, equipment and storage medium, which obtains training samples of the intent matching model based on standard questions and similar questions recalled based on the standard questions, and the training samples include positive sample pairs or negative sample pairs; each positive sample pair is subjected to adversarial perturbation processing, and the intent matching model is trained based on the similarity of the feature vectors corresponding to the two positive samples in the positive sample pairs after multiple adversarial perturbation processing, and the similarity of the feature vectors corresponding to the two negative samples in the multiple negative sample pairs. This can greatly improve the robustness of the trained intent matching model, and can be used to more accurately determine whether to reject the intent corresponding to the text to be recognized.
[0060] Below, the application scenarios of the solution provided in this application are first illustrated.
[0061] Figure 1 Schematic diagram of an application scenario of the model training method provided in one embodiment of the present application. Figure 1As shown, this application scenario may include: a server cluster 11 and a terminal 12. The server cluster 11 includes multiple servers 111 and storage 112. The terminal 12 may be a smartphone, tablet computer, laptop computer, desktop computer, intelligent voice interaction device, smart home appliance, or vehicle-mounted terminal. Server 111 is used to train the intent matching model. During the training process, it obtains data from storage 112 and stores the generated data in storage 112. Furthermore, during the training process, it communicates with the terminal 12 via a wireless or wired network.
[0062] Furthermore, embodiments of the present application can be applied in intent recognition scenarios. For example, a customer service robot in a call center dials a user's smartphone, i.e., the customer service robot proactively makes an outbound call. During a conversation with a user, the customer service robot asks the user a question and, based on the user's response, determines whether it recognizes the intent corresponding to the user's response. If the customer service robot determines that it recognizes the intent corresponding to the user's response, it sends a fallback answer to the user.
[0063] It should be noted that Figure 1 This is only a schematic diagram of an application scenario provided by the embodiment of the present application. Figure 1 The equipment included in the Figure 1 The positional relationship between the devices is limited.
[0064] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0065] Figure 2 This is a flow chart of a model training method provided in one embodiment of the present application. The method of the embodiment of the present application can be applied to an electronic device, which can be a server or a server cluster. Figure 2 As shown, the method of the embodiment of the present application includes:
[0066] S201: Acquire multiple first training samples, where the first training samples include a first positive sample pair or a first negative sample pair.
[0067] The two first positive samples in the first positive sample pair have the same intent category, the two first negative samples in the first negative sample pair have different intent categories, and the first training samples include standard questions and questions similar to the standard questions.
[0068] It can be understood that the first training sample is a training sample consisting of a standard question and a question similar to the standard question. By combining the standard question and the question similar to the standard question in pairs, the first positive sample pair or the first negative sample pair included in the first training sample can be obtained. The two first positive samples in the first positive sample pair have the same intent category, and the two first negative samples in the first negative sample pair have different intent categories. Specifically, for the first positive sample pair, the format of the first positive sample pair is, for example, (textA, textB, label), where textA represents one of the first positive samples in the first positive sample pair, textB represents the other first positive sample in the first positive sample pair, and label represents the label. The value of label is 1, indicating that the intent categories of textA and textB are the same. The first positive sample pair is, for example: ("I want to report you", "I want to complain about you", 1). For the first negative sample pair, the format of the first negative sample pair is, for example, (textC, textD, label), where textC represents one of the first negative samples in the first negative sample pair, textD represents the other first negative sample in the first negative sample pair, and the value of label is 0, indicating that the intent categories of textC and textD are different. For how to obtain the first training sample, please refer to the subsequent embodiments and will not be described in detail here.
[0069] S202: Perform adversarial perturbation processing on each first positive sample pair to obtain each first positive sample pair after adversarial perturbation processing.
[0070] In this step, in order to improve the robustness of the intent matching model, the method of adding adversarial perturbation can be adopted to enhance each first positive sample pair, that is, each first positive sample pair is subjected to adversarial perturbation processing to obtain each first positive sample pair after adversarial perturbation processing.
[0071] Further, optionally, performing adversarial perturbation processing on each first positive sample pair to obtain each first positive sample pair after adversarial perturbation processing can include: obtaining the eigenvectors corresponding to the two first positive samples in each first positive sample pair; obtaining the gradient corresponding to the eigenvector based on the loss function and the eigenvector; obtaining the amplitude of the adversarial perturbation performed on each first positive sample pair according to the gradient; and obtaining each first positive sample pair after adversarial perturbation processing according to the amplitude, the eigenvector and the preset perturbation amount.
[0072] For example, when performing adversarial perturbation processing on each first positive sample pair, the perturbation is added to the loss function. The loss function is a loss function using contrastive learning. Specifically, the loss function is, for example, a cross entropy loss (CE loss) function. The method of adding perturbation is to add a worst-case perturbation to the original cross entropy loss to maximize the loss of the original loss function. The specific formula is as follows:
[0073]
[0074] Wherein, Lce represents the cross entropy loss; δ represents the amplitude of the disturbance; θ represents the parameters of the model; x represents the characteristic vector of the sample, and the sample is, for example, the first positive sample in the above embodiment; δ′ represents the disturbance amount; ∈ represents the regularization boundary, which is used to control the upper limit of the disturbance amplitude.
[0075] The worst-case perturbation can be obtained by maximizing the loss, increasing the perturbation along the gradient direction that maximizes the loss, and obtaining the perturbation amplitude δ as follows:
[0076] in,
[0077] Here, g represents the gradient of the cross-entropy loss with respect to x. The gradient indicates the maximum value of the directional derivative of the loss function at x along that direction. δ normalizes g and then multiplies it by ∈ to limit the magnitude of the perturbation. y represents the label, with a value of 1 for a positive sample pair and a value of 0 for a negative sample pair. Alternatively, the value of δ can be obtained experimentally, in addition to using Formula 2.
[0078] Obtain the eigenvectors corresponding to the two first positive samples in each first positive sample pair. Based on the above formula 2, the gradient corresponding to the eigenvector and the amplitude of the adversarial perturbation for each first positive sample pair obtained based on the gradient can be obtained. Based on the above formula 1, each first positive sample pair after adversarial perturbation processing can be obtained based on the amplitude, eigenvector, and the preset perturbation amount.
[0079] S203: Input the plurality of first positive sample pairs and the plurality of first negative sample pairs after adversarial perturbation processing into the initial intent matching model to obtain a first feature vector set.
[0080] The first feature vector set includes feature vectors corresponding to the two first positive samples in each first positive sample pair and feature vectors corresponding to the two first negative samples in each first negative sample pair.
[0081] In this step, after obtaining each first positive sample pair after adversarial perturbation processing, multiple first positive sample pairs after adversarial perturbation processing and multiple first negative sample pairs can be input into the initial intent matching model to obtain a first feature vector set.
[0082] S204 , obtaining a first similarity of the feature vectors corresponding to the two first positive samples in each first positive sample pair in the first feature vector set, and a second similarity of the feature vectors corresponding to the two first negative samples in each first negative sample pair.
[0083] Exemplarily, after obtaining the first feature vector set, a method such as calculating cosine similarity can be used to obtain the first similarity of the feature vectors corresponding to the two first positive samples in each first positive sample pair in the first feature vector set, and the second similarity of the feature vectors corresponding to the two first negative samples in each first negative sample pair.
[0084] S205. Determine a loss function value corresponding to the loss function of the initial intent matching model based on the first similarity and the second similarity; iteratively train the initial intent matching model based on the loss function value to obtain an intent matching model.
[0085] For example, the intention matching model is a twin-tower structure model. Figure 3 A schematic diagram of a double-tower structure model provided in one embodiment of the present application is shown in FIG. Figure 3 As shown in the figure, the characteristic of the dual-tower structure model is that the parameters on the left and right sides of the model are the same. Sentence A is input as one side of the dual-tower structure model, and sentence B is input as the other side of the dual-tower structure model. Both sides of the dual-tower structure model are connected to a representation layer, namely BERT. The feature vectors output by the two representation layers are pooled by the pooling layer to obtain feature vector u and feature vector v. The cosine similarity of feature vector u and feature vector v is calculated to obtain a matching score between 0 and 1.
[0086] In this step, the loss function value corresponding to the loss function of the initial intent matching model can be determined based on the first similarity and the second similarity. The initial intent matching model can be iteratively trained based on the loss function value, and the intent matching model can be obtained when the loss function value tends to be stable. The above process of obtaining the intent matching model is the process of iterative training using the contrastive learning method, wherein the contrastive learning method can shorten the distance between similar samples and increase the distance between irrelevant samples. After obtaining the intent matching model, the standard question and the similar questions of the standard question can be saved in the intent matching model for use in identifying the rejection intent of the text to be recognized.
[0087] The model training method provided in the embodiment of the present application obtains multiple first training samples, where the first training samples include a first positive sample pair or a first negative sample pair, performs adversarial perturbation processing on each first positive sample pair, and inputs the multiple first positive sample pairs and the multiple first negative sample pairs after adversarial perturbation processing into the initial intention matching model to obtain a first feature vector set; determines the loss function value corresponding to the loss function of the initial intention matching model based on the first similarity of the feature vectors corresponding to the two first positive samples in each first positive sample pair in the first feature vector set, and the second similarity of the feature vectors corresponding to the two first negative samples in each first negative sample pair; and iteratively trains the initial intention matching model based on the loss function value to obtain an intention matching model. Since the embodiment of the present application performs adversarial perturbation processing on each first positive sample pair, the data domain of the first positive sample is increased, thereby improving the adaptability of the intent matching model and making the intent matching model more robust; at the same time, the intent matching model is iteratively trained based on the first similarity and the second similarity. During the training process, the loss between the two first positive samples in the first positive sample pair is minimized by maximizing the first similarity, and the loss between the two first negative samples in the first negative sample pair is maximized by minimizing the second similarity. Therefore, the obtained intent matching model can accurately determine whether to reject the intent corresponding to the text to be recognized. In addition, since the first training samples include standard questions and similar questions of the standard questions, there is no need to mark training samples with rejection intent, therefore, the training efficiency of the intent matching model can be improved and the training cost can be reduced. Compared with the method of directly setting thresholds to judge other intents in the related art, the embodiment of the present application is more comprehensive and reasonable, and the judgment of other intents is more accurate.
[0088] Based on the above embodiment, optionally, the first training sample used when training the intent matching model is obtained in the following manner: the data pair to be predicted is input into the text representation model to obtain a first matching result of the data to be predicted in the data pair to be predicted; wherein the data pair to be predicted includes the data to be predicted and any one of the standard question or seed corpus, the standard question is a question obtained based on the intent knowledge base, and the seed corpus is the first similar question of the standard question recalled according to a preset regular expression; if the first matching result is a successful match, it is determined that the data to be predicted is the second similar question of the standard question; and the standard question, the first similar question and the second similar question are determined as the first training sample.
[0089] For example, the establishment of the intent knowledge base depends on the business personnel's understanding of the business, and its establishment mainly follows two principles: (1) The intent knowledge base needs to be established as a tree structure rather than a conventional classification structure. Figure 4 This is a schematic diagram of the structure of the intent knowledge base provided in one embodiment of the present application, such as Figure 4As shown in the figure, the intent knowledge base is a tree structure, including three intent classification groups, namely pre-loan, mid-loan and post-loan, and each intent classification group contains multiple intent classifications. (2) Each leaf node represents a specific intent classification. There should be no repeated semantics between the intent classifications under each branch. If there are parts with repeated semantics, it is necessary to specify which intent classification it belongs to. For example, the intent knowledge base contains two intent classifications: "User Rejection" and "Complaint". If the user's conversation is: "No, I want to complain to you!", the business party needs to force this type of data to belong to a certain intent classification, such as classifying the user's conversation as the "Complaint" intent classification. After the intent knowledge base is established, the business party needs to complete the standard questions of the intent knowledge base and configure the retrieval regular expression (i.e., preset regular expression) for the intent classification corresponding to the standard questions, so as to search the real online conversation corpus and recall the seed corpus.
[0090] In some application scenarios, such as for new call center robots, in addition to the intent knowledge base, since new robots rarely have previous historical corpus to draw on, similar questions for new robots rely heavily on manual work. Therefore, the business side needs to manually write regular expressions (i.e., obtain preset regular expressions) to recall relevant data under the intent classification (i.e., the first similar questions of the standard questions). Preset regular expressions can be understood as business rules obtained based on business keywords using preset syntactic logic rules, where preset syntactic logic rules include logical AND (&&), logical OR (||), and logical NOT (!). Specifically, a preset regular expression is for example: report || complaint. It is important to note that the preset regular expression needs to be diverse in order to be able to recall diverse data. Based on the labeling problem of intent classification, the data recalled using the preset regular expression requires manual verification. Typically, only a few dozen data items are retained for each intent classification. These dozens of data items serve as the seed corpus for the intent classification.
[0091] After obtaining the seed corpus, it is obviously not enough to train the intent matching model using only the seed corpus. Therefore, after obtaining the seed corpus, it is necessary to learn the text representation of intent classification through limited data to further recall other data under the intent classification. In other words, the limited seed corpus is mined through the text representation model to recall more corpus from a large amount of online data.
[0092] The data to be predicted is paired with each standard question and seed corpus to obtain a pair of data to be predicted, that is, the data pair to be predicted includes the data to be predicted and any one of the standard questions or seed corpus. Specifically, the format of the data pair to be predicted is (x1, x2), where x1 represents each standard question or seed corpus and x2 represents the data to be predicted. The data pair to be predicted is input into the text representation model to obtain the first matching result and threshold of the data to be predicted in the data pair to be predicted. The first matching result of 1 indicates a successful match, and the first matching result of 0 indicates a failed match. The threshold is similar to the similarity. In order to recall the diversity of the data, the following method can be used to recall the data: each threshold is segmented. Assuming that 0.8 is the lower limit of the threshold for recalling data, the recall threshold is [0.8, 0.85], [0.85, 0.9], [0.9, 0.95], and [0.95, 1], with X data in each of the four intervals. By recalling data in the above manner, it is possible to ensure that the recalled data has a certain accuracy rate while having data diversity, thereby preventing the situation where all the recalled data is concentrated in one expression. For how to obtain the text representation model, please refer to the subsequent embodiments, which will not be described in detail here.
[0093] After obtaining the first matching result, if the first matching result is a successful match, it can be determined that the data to be predicted is the second similar question of the standard question, and further, the standard question, the first similar question, and the second similar question can be determined as the first training sample. It can be understood that the first similar question and the second similar question are both similar questions of the standard question. Obtaining the first training sample in the above manner eliminates the need for corpus labeled with other intents, and only requires corpus with the primary intent. This can solve the problem of difficulty in obtaining training data for the intent matching model.
[0094] Based on the above embodiments, in a possible implementation, a text representation model can be obtained in the following manner: obtaining multiple second training samples, the second training samples include second positive sample pairs or second negative sample pairs, the intention categories of the two second positive samples in the second positive sample pairs are the same, and the intention categories of the two second negative samples in the second negative sample pairs are different, and the second training samples include standard questions and seed corpus; inputting multiple second positive sample pairs and multiple second negative sample pairs into the initial text representation model to obtain a second feature vector set, the second feature vector set includes feature vectors corresponding to the two second positive samples in each second positive sample pair and feature vectors corresponding to the two second negative samples in each second negative sample pair, and the initial text representation model is obtained by text pre-training on unsupervised corpus; obtaining the third similarity of the feature vectors corresponding to the two second positive samples in each second positive sample pair in the second feature vector set, and the fourth similarity of the feature vectors corresponding to the two second negative samples in the second negative sample pair; based on the third similarity and the fourth similarity, iteratively training the initial text representation model to obtain a text representation model.
[0095] Exemplarily, the training method of the text representation model includes the following two steps:
[0096] The first step is to perform text pre-training on a large amount of unsupervised corpus to obtain an initial text representation model. Specifically, pre-trained models such as BERT are pre-trained again using massive online data to make the pre-trained models more adaptable to the scenario corpus. The pre-training method can be found in current related technologies and will not be repeated here.
[0097] The second step involves supervised training to obtain a text representation model. While pre-trained models obtained using only unsupervised methods can directly obtain sentence vector similarity and thus recall data, the sentence vector representations obtained for each training sample are very similar. This results in a lack of discriminability in the recalled online text and a limited number of valid samples. Therefore, contrastive learning methods are added to this step for training. Figure 5 A schematic diagram of a comparative learning training method provided in an embodiment of the present application is shown in FIG. Figure 5 As shown in the figure, a batch of data includes sample data 1 to sample data n, which are input into the model at the same time. Sample data 1 to sample data n are encoded by the encoder to obtain corresponding digital vector representations; the standard questions of each intent category are used as anchor sentences, and the standard questions under the same intent category are combined with each seed corpus in pairs as positive sample pairs, and the standard questions under different intent categories are combined with each seed corpus in pairs as negative sample pairs.
[0098] refer to Figure 5In the example, a second positive sample pair and a second negative sample pair can be obtained, the two second positive samples in the second positive sample pair have the same intent category, and the two second negative samples in the second negative sample pair have different intent categories. After obtaining the second positive sample pair and the second negative sample pair, multiple second positive sample pairs and multiple second negative sample pairs can be input into the initial text representation model to obtain a second feature vector set; obtain the third similarity of the feature vectors corresponding to the two second positive samples in each second positive sample pair in the second feature vector set, and the fourth similarity of the feature vectors corresponding to the two second negative samples in the second negative sample pair; based on the third similarity and the fourth similarity, iteratively train the initial text representation model until the loss function value tends to be stable or reaches a preset number of iterations, and obtain a text representation model. The above process of obtaining a text representation model is a process of iterative training using a contrastive learning method.
[0099] Contrastive learning methods are used to minimize the loss between two similar samples and maximize the loss between two dissimilar samples. This involves constructing pairs of similar samples, such as (xi, xi+), and dissimilar samples, such as (xi, xj+). In outbound conversational bot scenarios, constructing pairs of samples is easy and effective: using a standard question within one intent category as an anchor sentence, questions similar to the standard question serve as positive samples, while standard questions from other intent categories or questions similar to the standard question serve as negative samples. During training, the method of pulling positive samples closer and pushing negative samples further away allows for rapid construction of training data. Contrastive learning methods can learn the characteristics of the model and facilitate the recall of unlabeled corpus.
[0100] Figure 6 This is a flow chart of an intention recognition method provided by an embodiment of the present application. The method of the embodiment of the present application can be applied to an electronic device, which can be a server or a server cluster. Figure 6 As shown, the method of the embodiment of the present application includes:
[0101] S601: Obtain text to be recognized.
[0102] In the embodiment of the present application, the text to be recognized may be input by a user to the electronic device executing the embodiment of the present method, or may be sent by another device to the electronic device executing the embodiment of the present method. For example, the text to be recognized may be "No, I want to complain to you!"
[0103] S602: Input the text to be recognized into the intention matching model, match it with the standard question and similar questions in the intention matching model, and obtain a second matching result.
[0104] Among them, the intention matching model is a model trained using the model training method in any of the above method embodiments.
[0105] It can be understood that standard questions and similar questions of standard questions are preset in the intent matching model. Each standard question and similar question has a corresponding intent category, and the standard questions and similar questions constitute the data domain of the intent category. As for how to obtain standard questions and similar questions of standard questions, please refer to the above embodiment and will not be repeated here. In this step, after obtaining the text to be recognized, the text to be recognized can be input into the intent matching model, and matched with the standard questions and similar questions of the standard questions in the intent matching model by traversal, that is, judging whether the text to be recognized is in the data domain, and obtaining a second matching result. Specifically, the intent matching model is, for example, a double-tower structure model, in which the text to be recognized is input as one side of the double-tower structure model, and each standard question and similar question of the standard question is input as the other side of the double-tower structure model in turn, and the matching result of the text to be recognized with each standard question and similar question of the standard question is obtained by traversal, that is, the second matching result is obtained.
[0106] S603: Determine whether to reject the text to be recognized based on the second matching result.
[0107] In this step, after obtaining the second matching result, it can be determined whether to reject the text to be recognized based on the second matching result.
[0108] Further, optionally, determining whether to reject the text to be recognized based on the second matching result may include: if the second matching result is a matching failure, rejecting the text to be recognized and outputting a preset rejection answer; if the second matching result is a matching success, identifying the target intent corresponding to the text to be recognized and outputting the target intent.
[0109] Exemplarily, the preset rejection answer can be understood as a fallback answer. If the second matching result is a matching failure, that is, no standard question or similar question of a standard question can match the text to be recognized, and the text to be recognized is not in the data domain composed of standard questions and similar questions of standard questions, then the text to be recognized is rejected and a fallback answer is output to the user. If the second matching result is a matching success, that is, a standard question or similar question of a standard question can match the text to be recognized, and the text to be recognized is in the data domain composed of standard questions and similar questions of standard questions, then the target intent corresponding to the text to be recognized can be identified through the preset intent classification model, and the target intent can be output, and the answer corresponding to the target intent can be output to the user according to the target intent. Among them, the preset intent classification model is, for example, a model obtained after fine-tuning BERT, and reference can be made to current related technologies.
[0110] The intent recognition method provided in the embodiment of the present application inputs the text to be recognized into an intent matching model, matches it with standard questions and similar questions in the intent matching model, and obtains a second matching result; based on the second matching result, it determines whether to reject the text to be recognized. Because the intent matching model in the embodiment of the present application has good robustness, it can more accurately determine whether to reject the intent corresponding to the text to be recognized through the intent matching model. When rejection is determined, a preset rejection answer can be directly output, thereby improving the user experience.
[0111] Based on the above embodiments, Figure 7 A schematic diagram of a robot conversation process provided in an embodiment of the present application is shown as follows: Figure 7 As shown, the robot conversation process can include five steps:
[0112] S701: Identify the user's answer based on Automatic Speech Recognition (ASR) technology and convert the user's answer into text.
[0113] S702: Perform ASR post-processing to obtain the text to be recognized; wherein the ASR post-processing includes text error correction processing.
[0114] S703: Perform intent recognition on the text to be recognized and determine whether to reject the text to be recognized.
[0115] In this step, the text to be recognized is input into the intent matching model and matched against the standard question and similar questions in the intent matching model to obtain a second matching result. Based on the second matching result, it is determined whether to reject the text to be recognized. If the second matching result indicates a match failure, step S704 is executed; if the second matching result indicates a match success, step S705 is executed.
[0116] S704: Reject the text to be recognized and output a preset rejection answer to the user.
[0117] S705: Identify the target intent corresponding to the text to be recognized, and output an answer corresponding to the target intent to the user.
[0118] Repeat steps S701 to S705 to complete this round of conversation.
[0119] Basic Figure 7 The robot conversation process shown does not require other labeled intent corpora. Only the robot's main intent is needed to determine whether to reject the text to be recognized. This implements an effective method for establishing a new robot in an outbound call conversation scenario and can complete the robot online from 0 to 1.
[0120] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0121] Figure 8 A schematic diagram of the structure of a model training device provided in one embodiment of the present application is shown in FIG. Figure 8 As shown, the model training device 800 of the embodiment of the present application includes: a first acquisition module 801, a processing module 802, a second acquisition module 803, a third acquisition module 804 and a training module 805. Among them:
[0122] The first acquisition module 801 is used to obtain multiple first training samples, where the first training samples include a first positive sample pair or a first negative sample pair, the two first positive samples in the first positive sample pair have the same intent category, and the two first negative samples in the first negative sample pair have different intent categories, and the first training samples include standard questions and similar questions to the standard questions.
[0123] The processing module 802 is configured to perform adversarial perturbation processing on each first positive sample pair to obtain each first positive sample pair after the adversarial perturbation processing.
[0124] The second acquisition module 803 is used to input multiple first positive sample pairs and multiple first negative sample pairs after adversarial perturbation processing into the initial intention matching model to obtain a first feature vector set, where the first feature vector set includes feature vectors corresponding to the two first positive samples in each first positive sample pair and feature vectors corresponding to the two first negative samples in each first negative sample pair.
[0125] The third acquisition module 804 is configured to acquire a first similarity of the feature vectors corresponding to the two first positive samples in each first positive sample pair in the first feature vector set, and a second similarity of the feature vectors corresponding to the two first negative samples in each first negative sample pair.
[0126] The training module 805 is used to determine the loss function value corresponding to the loss function of the initial intent matching model based on the first similarity and the second similarity; and iteratively train the initial intent matching model based on the loss function value to obtain the intent matching model.
[0127] In some embodiments, the processing module 802 can be specifically used to: obtain the feature vectors corresponding to the two first positive samples in each first positive sample pair; obtain the gradient corresponding to the feature vector based on the loss function and the feature vector; obtain the amplitude of the adversarial perturbation for each first positive sample pair according to the gradient; and obtain each first positive sample pair after the adversarial perturbation processing according to the amplitude, the feature vector and the preset perturbation amount.
[0128] Optionally, the model training device 800 may also include a fourth acquisition module 806, which is used to obtain a first training sample in the following manner: inputting the data pair to be predicted into the text representation model to obtain a first matching result of the data to be predicted in the data pair to be predicted; wherein the data pair to be predicted includes the data to be predicted and any one of the standard question or seed corpus, the standard question is a question obtained based on the intention knowledge base, and the seed corpus is the first similar question of the standard question recalled according to a preset regular expression; if the first matching result is a successful match, it is determined that the data to be predicted is the second similar question of the standard question; and the standard question, the first similar question and the second similar question are determined to be the first training sample.
[0129] Optionally, the model training device 800 may also include a fifth acquisition module 807, which is used to train a text representation model in the following manner: obtain multiple second training samples, the second training samples include second positive sample pairs or second negative sample pairs, the intention categories of the two second positive samples in the second positive sample pairs are the same, and the intention categories of the two second negative samples in the second negative sample pairs are different, and the second training samples include standard questions and seed corpus; input multiple second positive sample pairs and multiple second negative sample pairs into the initial text representation model to obtain a second feature vector set, the second feature vector set includes feature vectors corresponding to the two second positive samples in each second positive sample pair and feature vectors corresponding to the two second negative samples in each second negative sample pair, and the initial text representation model is obtained by text pre-training on unsupervised corpus; obtain the third similarity of the feature vectors corresponding to the two second positive samples in each second positive sample pair in the second feature vector set, and the fourth similarity of the feature vectors corresponding to the two second negative samples in the second negative sample pair; based on the third similarity and the fourth similarity, iteratively train the initial text representation model to obtain a text representation model.
[0130] The device of the embodiment of the present application can be used to execute the model training method in any of the above method embodiments. Its implementation principles and technical effects are similar and will not be repeated here.
[0131] Figure 9 This is a schematic diagram of the structure of the intention recognition device provided in one embodiment of the present application, as shown in FIG. Figure 9 As shown, the intention recognition device 900 of the embodiment of the present application includes: an acquisition module 901, a matching module 902 and a determination module 903. Among them:
[0132] The acquisition module 901 is used to acquire the text to be recognized.
[0133] Matching module 902 is used to input the text to be recognized into the intention matching model, match it with the standard questions and similar questions of the standard questions in the intention matching model, and obtain a second matching result. The intention matching model is a model trained using the model training method in any of the above method embodiments.
[0134] The determination module 903 is configured to determine whether to reject the text to be recognized based on the second matching result.
[0135] In some embodiments, the determination module 903 can be specifically used to: if the second matching result is a matching failure, reject the text to be recognized and output a preset rejection answer; if the second matching result is a matching success, identify the target intent corresponding to the text to be recognized and output the target intent.
[0136] The device of the embodiment of the present application can be used to execute the solution of the intention recognition method in any of the above method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0137] Figure 10 This is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. For example, the electronic device can be provided as a server or a computer. Figure 10 The electronic device 1000 includes a processing component 1001, which further includes one or more processors, and a memory resource represented by a memory 1002 for storing instructions executable by the processing component 1001, such as an application. The application stored in the memory 1002 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1001 is configured to execute the instructions to perform any of the above-described method embodiments.
[0138] The electronic device 1000 may further include a power supply component 1003 configured to perform power management of the electronic device 1000, a wired or wireless network interface 1004 configured to connect the electronic device 1000 to a network, and an input / output (I / O) interface 1005. The electronic device 1000 may operate based on an operating system stored in the memory 1002, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or the like.
[0139] The present application also provides a computer-readable storage medium, which stores computer-executable instructions. When a processor executes the computer-executable instructions, the above-mentioned intent recognition method and model training method are implemented.
[0140] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the above-mentioned intent recognition method and model training method.
[0141] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile memory 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 memory, flash memory, magnetic disk, or optical disk. The computer-readable storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0142] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be an integral part of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in an intent recognition device or an intent rejection model training device.
[0143] Those skilled in the art will appreciate that all or part of the steps in the above-described method embodiments can be implemented using hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0144] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A model training method, characterized in that: include: Acquire multiple first training samples, where the first training samples include a first positive sample pair or a first negative sample pair, where the intent categories of two first positive samples in the first positive sample pair are the same, and the intent categories of two first negative samples in the first negative sample pair are different, and the first training samples include a standard question and a question similar to the standard question; Performing adversarial perturbation processing on each of the first positive sample pairs to obtain each first positive sample pair after adversarial perturbation processing; Inputting a plurality of first positive sample pairs and a plurality of first negative sample pairs after the adversarial perturbation processing into an initial intent matching model to obtain a first feature vector set, where the first feature vector set includes feature vectors corresponding to the two first positive samples in each first positive sample pair and feature vectors corresponding to the two first negative samples in each first negative sample pair; Obtaining a first similarity of the feature vectors corresponding to the two first positive samples in each of the first positive sample pairs in the first feature vector set, and a second similarity of the feature vectors corresponding to the two first negative samples in each of the first negative sample pairs; According to the first similarity and the second similarity, a loss function value corresponding to the loss function of the initial intent matching model is determined; according to the loss function value, the initial intent matching model is iteratively trained to obtain the intent matching model.
2. The model training method according to claim 1, characterized in that The performing the adversarial perturbation processing on each of the first positive sample pairs to obtain each first positive sample pair after the adversarial perturbation processing includes: Obtaining feature vectors corresponding to the two first positive samples in each first positive sample pair; Based on the loss function and the eigenvector, obtaining a gradient corresponding to the eigenvector; Obtaining, according to the gradient, an amplitude of adversarial perturbation performed on each of the first positive sample pairs; Each first positive sample pair after anti-disturbance processing is obtained according to the amplitude, the eigenvector and the preset disturbance amount.
3. The model training method according to claim 1 or 2, characterized in that: The first training sample is obtained by: Inputting a data pair to be predicted into a text representation model to obtain a first matching result for the data to be predicted in the data pair to be predicted; wherein the data pair to be predicted includes the data to be predicted and any one of a standard question or a seed corpus, the standard question is a question obtained based on an intent knowledge base, and the seed corpus is a first similar question to the standard question recalled according to a preset regular expression; If the first matching result is a successful match, determining that the data to be predicted is a second similar question of the standard question; The standard question, the first similar question, and the second similar question are determined as the first training samples.
4. The model training method according to claim 3, characterized in that The text representation model is trained in the following way: Acquire a plurality of second training samples, where the second training samples include a second positive sample pair or a second negative sample pair, the two second positive samples in the second positive sample pair have the same intent category, and the two second negative samples in the second negative sample pair have different intent categories, and the second training samples include the standard question and the seed corpus; Inputting a plurality of second positive sample pairs and a plurality of second negative sample pairs into an initial text representation model to obtain a second feature vector set, wherein the second feature vector set includes feature vectors corresponding to the two second positive samples in each second positive sample pair and feature vectors corresponding to the two second negative samples in each second negative sample pair, wherein the initial text representation model is obtained by performing text pre-training on unsupervised corpus; Obtaining a third similarity of the feature vectors corresponding to the two second positive samples in each second positive sample pair in the second feature vector set, and a fourth similarity of the feature vectors corresponding to the two second negative samples in the second negative sample pair; Based on the third similarity and the fourth similarity, the initial text representation model is iteratively trained to obtain the text representation model.
5. A method for identifying intention, characterized in that: include: Get the text to be recognized; Inputting the to-be-recognized text into an intent matching model, and matching it with a standard question and a similar question to the standard question in the intent matching model to obtain a second matching result, wherein the intent matching model is a model trained using the model training method according to any one of claims 1 to 4; According to the second matching result, it is determined whether to reject the text to be recognized.
6. The intention recognition method according to claim 5, characterized in that: According to the said Second, the matching result determines whether to reject the text to be recognized, including: If the second matching result is a match failure, rejecting the text to be recognized and outputting a preset rejection answer; If the second matching result is a successful match, the target intent corresponding to the text to be recognized is identified and the target intent is output.
7. A model training device, characterized in that: include: A first acquisition module is configured to acquire a plurality of first training samples, wherein the first training samples include a first positive sample pair or a first negative sample pair, wherein the two first positive samples in the first positive sample pair have the same intent category, and the two first negative samples in the first negative sample pair have different intent categories, and the first training samples include a standard question and a question similar to the standard question; a processing module, configured to perform adversarial perturbation processing on each of the first positive sample pairs to obtain each first positive sample pair after the adversarial perturbation processing; A second acquisition module is configured to input the plurality of first positive sample pairs and the plurality of first negative sample pairs after the adversarial perturbation processing into an initial intent matching model to obtain a first feature vector set, where the first feature vector set includes feature vectors corresponding to the two first positive samples in each first positive sample pair and feature vectors corresponding to the two first negative samples in each first negative sample pair; a third acquisition module, configured to acquire a first similarity of the feature vectors corresponding to the two first positive samples in each of the first positive sample pairs in the first feature vector set, and a second similarity of the feature vectors corresponding to the two first negative samples in each of the first negative sample pairs; A training module is used to determine the loss function value corresponding to the loss function of the initial intent matching model based on the first similarity and the second similarity; and iteratively train the initial intent matching model based on the loss function value to obtain the intent matching model.
8. An intention recognition device, characterized in that: include: An acquisition module is used to obtain the text to be recognized; a matching module, configured to input the to-be-recognized text into an intent matching model, and match it with a standard question in the intent matching model and questions similar to the standard question, to obtain a second matching result, wherein the intent matching model is a model trained using the model training method according to any one of claims 1 to 4; A determination module is used to determine whether to reject the text to be recognized based on the second matching result.
9. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Text classification model training method and device, equipment and storage medium
CN111767405A
Text matching model training method and device, equipment and storage medium
CN113569011A