A method for open service intention detection based on supervised contrastive learning

By adopting a joint model based on BERT and supervised contrast learning in open intent text detection, combined with the open class samples generated by Mix-up operation, the problem of difficult to distinguish known classes and open class intent text in the existing technology is solved, and the problem of realizing the problem of "unknown classes" and "open class intent text" is realized. High accuracy and fast reasoning of open intention text detection effects.

CN115098681BActive Publication Date: 2025-02-18ZHEJIANG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210758042.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-29
Publication Date
2025-02-18
Estimated Expiration
2042-06-29

AI Technical Summary

Technical Problem

The prior art is difficult to effectively distinguish known classes from open class intention text in open class intention text detection, especially in the absence of sufficient known class data, resulting in classification errors and error transmission.

Method used

Using a joint model based on BERT and supervised contrast learning, through joint learning confidence estimation and intent classifier, the knowledge learned in OOD detection is used to improve the IND classification performance, and artificially synthesized OOD samples are generated through Mix-up operations to enhance the data. set.

Benefits of technology

It realizes the rapid and accurate distinction between known classes and open class intention texts in open intent text detection, improves the accuracy and inference speed of intention classification, and reduces the risk of error transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115098681B_ABST
    Figure CN115098681B_ABST
Patent Text Reader

Abstract

The present invention discloses an open service intention detection method based on supervised contrastive learning. First, BERT is used for semantic encoding to obtain an initial word vector representation, and then label information is used to simultaneously learn through a linear classification layer and a supervised contrastive learning representation layer to obtain a rich and discriminative sentence vector feature representation. After the representation learning is completed, the model becomes a feature extractor for the next step of joint training. In order to obtain more open class event texts to help training, a data enhancement method Mix‑up is used to generate new open class samples. Finally, the acquired samples and the synthesized samples are simultaneously input into a joint training model with two branches for training optimization. It is determined which known class the intention event text belongs to. If it does not belong to any known intention event class, it is considered to be an open class intention event. The known intention event classification and open class intention detection detection method constructed by the present invention has the characteristics of fast reasoning speed, strong interpretability and high accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the intersection of anomaly detection and natural language processing, and in particular relates to an open service intention detection method based on BERT and supervised contrastive learning. Background Art

[0002] In the field of open intent text detection, intent labels are usually divided into two categories. One category is known intent labels, which usually have several, also called IND, and the intents that do not belong to the known category are collectively referred to as open categories, also called OOD. The open intent text detection task contains two related tasks, which is to classify the intent text belonging to the known category and detect the open category text that does not belong to the known category.

[0003] Traditional intent classification and recognition follows a closed-world setting, where the training and testing data belong to the same set of intent labels. However, due to the openness and dynamic environmental factors in real scenarios, it is usually difficult to collect all class labels in advance. Therefore, event text from open classes may be incorrectly classified into a known intent label. Taking a multi-turn dialogue system as an example, since new intents may appear as the business changes, the intent classifier will predict the intent text of the open class as the wrong intent of the known class, which will cause the system to make wrong judgments and take wrong actions, resulting in immeasurable losses.

[0004] Therefore, developing a model that can correctly classify intent labels of known classes while reliably rejecting intent texts of open classes is of great significance for building applications based on intent recognition. Obviously, there are two parts involved in this problem setting, which are named as: (1) in-domain (ID) classification, which refers to classifying the input event text with predefined or known intent labels; (2) out-of-domain (OOD) detection, which refers to judging whether the input event text belongs to any predefined label, i.e., IND label. Existing methods for solving the open intent detection problem can be classified into two categories, namely, unsupervised methods that do not use open class samples and supervised methods that use open class samples. Supervised open intent detection methods usually require both IND and OOD samples in the training set. In contrast, unsupervised methods do not require additional OOD samples. In unsupervised methods, a key challenge is how to learn a discriminative feature representation that can achieve the best effect of fully separating each class. However, without sufficient data of known classes, the learned circular or spherical decision boundary may become smaller than the actual one, so more IND samples will be classified as OOD. The supervised method is generally divided into two steps: first determine whether an event text is IND or OOD, and then classify it, but this will cause erroneous transmission. Summary of the invention

[0005] The purpose of the present invention is to provide an open service intention detection method based on supervised contrastive learning in view of the deficiencies of the prior art.

[0006] Based on the idea of ​​utilizing known OOD samples, the present invention proposes a joint model of known class intent classification and open class intent detection based on supervised contrastive learning. The reason for using joint learning is that the two goals of IND intent classification and OOD intent detection are highly related, and joint training can use the knowledge learned from OOD detection to help improve the performance of IND classification, and vice versa. Specifically, the present invention jointly learns confidence estimates and IND classifiers for each input event text. Here, confidence estimates are used to distinguish between IND and OOD event texts.

[0007] The objective of the present invention is achieved through the following technical solution: a method for detecting open service intention based on supervised contrastive learning, comprising the following steps:

[0008] S1: First, the intent event text in the original dataset is classified and the dataset is divided into in-distribution (IND) samples, i.e., known class samples, and out-of-distribution (OOD) samples, i.e., open class samples.

[0009] S2: Preprocess the data set and remove redundant spaces and punctuation marks in the text.

[0010] S3: Perform BERT encoding on the IND sample obtained by preprocessing in step S2 to obtain the sentence vector representation of the entire text;

[0011] S4: Based on the sentence vector representation obtained in step S3, the cross entropy loss function Softmax-Loss is used to capture the features of the same category through the linear classification layer to obtain the cross entropy loss.

[0012] S5: Based on the sentence vector representation obtained in step S3, supervised contrastive learning is used to expand the feature differences of different classes and reduce the feature differences of the same class to obtain the supervised contrastive learning loss.

[0013] S6: Based on the cross entropy loss and supervised contrastive learning loss obtained in step S4 and step S5 respectively, the overall loss of the fine-tuning stage is added together, and training optimization is performed to obtain a feature extractor model with discriminability.

[0014] S7: Based on the preprocessed IND sample obtained in step S2, an artificially synthesized OOD sample is constructed through a Mix-up operation.

[0015] S8: Embedding representation. Input the three parts of data, namely the known IND samples, the known OOD samples and the artificially synthesized OOD samples in step S7, into the feature extractor obtained in step S6 to obtain the sentence embedding vector representation of each sample.

[0016] S9: Multi-task joint optimization, including two parts. The first part is a multi-classification task. IND samples are screened from the samples input in step S8, and the SoftMax cross entropy loss is optimized to obtain the task loss, where the IND samples contain multiple known intent event types. The second part is a confidence learning task, which obtains the confidence loss that a sample belongs to the open class. The two parts of the loss are added together to train to obtain the open intent detection model.

[0017] Furthermore, the intent event text classification described in step S1 specifically refers to: the original intent event texts all belong to known class intents, and a certain proportion (25%, 50% or 75%) of known class labels are deleted by random deletion, and the event texts originally belonging to these classes are re-labeled as open classes. In this way, the remaining known class intent event texts and the re-labeled open class intent event texts are obtained at the same time.

[0018] Furthermore, in step S3, the IND samples obtained by preprocessing in step S2 are BERT-encoded to obtain the sentence vector representation of the entire text. Specifically, the BERT model can model the semantic information of words and integrate it into the semantic information of the sentence, which can then be applied to various downstream tasks. Given a text s, for each word T in the text i (i=1, 2, ..., N) is input into the BERT model:

[0019] x j =mean-pooling(BERT(CLS,T1,T2...,T N ))

[0020] Among them, CLS represents the classification label of the downstream task, N represents the length of the text, and mean-pooling represents the mean processing of the semantics of each word obtained by BERT. Finally, x is obtained. j A sentence vector representation representing the entire text.

[0021] Furthermore, the cross entropy loss function Softmax-Loss described in step S4 is used to capture the features of the same class, specifically using the cross entropy loss function to optimize the parameters of BERT. In order to learn the label information of each event type, the known label information is used as prior knowledge to fine-tune the model, and a linear classifier with a loss of Softmax-loss is used to obtain the cross entropy loss.

[0022] Furthermore, the use of supervised contrastive learning in step S5 uses contrastive loss to expand the feature differences of different classes and reduce the feature differences of the same class. Specifically, supervised contrastive learning uses label information to make samples belonging to the same intent event type more similar in high-dimensional features while making the feature representations of samples of different event types more distinguishable. For a multi-classification task with C classes, a batch contains M samples, represented as where d i Indicates the input event text, y i Indicates the event type to which the event text belongs. The supervised contrast loss of this task can be obtained through supervised contrast learning.

[0023]

[0024] Where A(i) = {1, ..., M}\{i} represents the set of all anchor point samples, P(i) = {p∈A(i): y i =y p} is the set of samples with event label i, τ is the temperature hyperparameter, which allows the model to better learn difficult samples, z i represents the feature representation obtained by the BERT module, z a represents the feature representation of different anchor points, and z p It represents the feature representation of the sample with event label i, and e is a natural constant.

[0025] Furthermore, the overall loss of the fine-tuning stage described in step S6 is By adding the cross entropy loss and the supervised contrastive learning loss, we get:

[0026]

[0027] Furthermore, the artificially synthesized OOD samples are constructed through the Mix-up operation described in step S7, specifically referring to: in the model, in addition to IND samples, OOD samples are also used to assist in training. Considering that the number of OOD samples is small in some cases, the present invention uses a similar idea of ​​Mix-up to synthesize OOD samples for data enhancement. Finally, the trained OOD samples actually have two sources: the first part is known OOD samples, and the second part is synthetic OOD samples generated by Mix-up. Mix-up is a classic data enhancement method, and the present invention goes a step further and uses it to synthesize new OOD samples. Specifically, the synthesized OOD sample x ood is generated by calculating:

[0028] x ood =α*x i+(1-α)*x j

[0029] where x i and x j are the vector representations of two event texts from different IND event types, and α is a uniform distribution from 0 to 1.

[0030] Furthermore, the multi-task joint optimization described in step S9 specifically means: the task of the present invention is to correctly classify IND tags and reliably reject OOD event texts. Because the method of first distinguishing whether it is an IND sample and then classifying these event texts will cause error transmission. Therefore, the present invention can improve the overall performance without error transmission through shared representation and mutual complementation, and joint learning. The present invention adds two parallel parts at the end of the model: one is the multi-classification task part that predicts IND class labels, and the other is the confidence learning task part that estimates the credibility of the network prediction results. These two parts receive the same input, that is, the output from BERT, and then the two parts pass through different MLPs (multi-layer perceptrons). The last layer of the confidence learning task uses a sigmoid activation function to adjust the confidence c between 0-1. i .

[0031] For multi-classification tasks, all IND samples are selected and then cross entropy CE(...) is used to calculate the task loss

[0032]

[0033] Where L i represents the true label of the sample, p i represents the probability vector, and n is the number of IND samples.

[0034] For confidence learning tasks, low confidence indicates that even if the predicted class probability is high, the prediction performance of the multi-classification task cannot be guaranteed. Therefore, the present invention uses confidence to perform OOD detection and designs the following strategy:

[0035]

[0036]

[0037] where c i is the confidence generated by the sigmoid activation function; for OOD samples, subtract c from 1 i , get the target confidence c′ i , otherwise keep c i As c′ i ; Then use c′ iThe negative log-likelihood of As the confidence loss after training the model, will be returned to 0; it makes the c of the IND sample i Close to 1(c i →1, L i ≠0), c of OOD samples i Close to 0(c i →0,L i =0). In practical applications, a confidence threshold θ is pre-set. If the confidence level of a sample c i If it is less than the confidence threshold θ, it is considered to be an OOD sample, otherwise it is an IND sample.

[0038] The beneficial effects of the present invention are:

[0039] The present invention provides a new joint model to realize open intent text detection. The model first learns the sentence vector representation of the text. These sentence vector representations are optimized by cross entropy loss and supervised contrastive learning loss using the deep learning model BERT, so that the feature representation is more suitable for classification tasks than the original method. At the same time, the present invention proposes a new simple and effective data enhancement method: by performing a Mix-up operation on two texts of known class intent, new open class samples are artificially synthesized. On this basis, the model is jointly trained, and two different branches: the known class classification branch and the open class confidence detection branch are optimized at the same time, and the training of the two tasks is completed at the same time. The known intent event classification and open class intent detection detection method constructed by the present invention has the characteristics of fast reasoning speed, strong interpretability and high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 is a flow chart of the method proposed by the present invention;

[0041] Figure 2 It is an architecture diagram of the open service intent detection model based on supervised contrastive learning designed by the present invention. DETAILED DESCRIPTION

[0042] The present invention classifies and identifies the intent texts in the open world. For the intent texts belonging to known categories, it distinguishes which specific category they belong to, and marks other intent texts as belonging to open categories. Through joint learning, an open intent text classification model is formed. The present invention can be regarded as a text classification technology for natural language description texts. The open intent text classification model based on the present invention can help users discover and monitor intent texts, optimize existing service processes, and make them better reflect the actual business of the enterprise.

[0043] The present invention discloses an open service intention detection method based on supervised contrastive learning. Based on BERT, Softmax Loss, Supervised Contrastive Learning, Mix-up and multi-task learning methods, event texts of known classes and event texts belonging to open classes are intelligently classified from all intent texts, and the obtained classification results can be applied to multiple downstream tasks in the field of intent classification. The present invention can effectively classify event texts, and solves the pain points and difficulties of not being able to distinguish whether there are open class intentions in intent text classification. The present invention first uses BERT, and optimizes the sentence vector representation simultaneously through cross entropy loss and supervised contrastive learning loss, and obtains a discriminative representation of the known class event text, which provides help for the next task. At the same time, through the Mix-up operation, two different known class event texts are randomly selected to synthesize new open class event texts, providing more samples for supervised learning, thereby improving performance. After that, it goes through a joint training framework, which includes two different task branches, one is the known class classification branch, which predicts a known class intent label, and the second is the confidence estimation branch, which predicts whether it belongs to an open class intent. If the confidence exceeds the manually set threshold, it is considered to be an open class intent text. Finally, the intent label of the known class and the confidence of whether it belongs to the known class can be obtained at the same time, thereby achieving the goal of realizing the open intent text classification task. In the intent text classification, the present invention can realize a sentence vector representation with discrimination in the event text, and finally obtain the classification result through simultaneous optimization of two different branches.

[0044] The present invention will be described in detail below based on the accompanying drawings and preferred embodiments, and the objectives and effects of the present invention will become more apparent. It should be understood that the specific embodiments described herein are only for explaining the present invention and are not intended to limit the present invention.

[0045] Example 1

[0046] The present invention discloses an open service intent detection method based on supervised contrastive learning. There are many methods for intent text classification in the real world, but they are all limited to the situation where the intents are all known classes. The present invention is based on BERT, Softmax Loss, Supervised Contrastive Learning, Mix-up and multi-task learning methods to intelligently classify event texts of known classes and event texts belonging to open classes from all intent texts. The obtained classification results can be applied to multiple downstream tasks in the field of intent classification. The present invention uses BERT to simultaneously optimize the sentence vector representation through cross entropy loss and supervised contrastive learning loss, and obtains a discriminative representation of the known class event text to provide assistance for the next task. Figure 1 As shown, this embodiment includes the following steps:

[0047] In order to demonstrate the versatility of the present invention for various intent recognition tasks, this embodiment uses the intent classification text dataset in the telecommunications customer service robot as the dataset of the present invention. The unprocessed original dataset is shown in Table 1, and each event text corresponds to a known class intent label.

[0048] Table 1

[0049] content Intent Tags I want to check my phone bill Phone Charge Inquiry I want broadband Broadband management Recommend broadband packages Broadband management My signal is very poor. What is the reason? Signal query My package was 58 yuan, why was 108 yuan deducted? Phone Charge Inquiry

[0050] In order to demonstrate the effectiveness of the present invention for open intent detection, for this data set, a portion of the known class intent labels are randomly deleted, and the event texts belonging to these known class intents are re-labeled with the "open class" intent label, as shown in Table 2.

[0051] Table 2

[0052] content Intent Tags I want to check my phone bill Open Class I want broadband Broadband management Recommend broadband packages Broadband management My signal is very poor. What is the reason? Open Class My package was 58 yuan, why was 108 yuan deducted? Open Class

[0053] Among them, the intent labels of "phone charge inquiry" and "signal inquiry" are deleted, and the samples belonging to these intents are re-labeled as "open class". In this way, the dataset contains both known class intent samples and re-labeled open class samples.

[0054] like Figure 1 As shown in the figure, the model proposed in the present invention includes three modules: representation learning module, sample pre-preparation module and joint training module. The representation learning module is responsible for fully mining rich and discriminative sentence vector representations from different angles. Then, based on the discriminative sentence vector representation, open class samples are artificially synthesized in the sample pre-preparation module, and finally the three parts of samples are sent together to the joint training module to finally obtain the intent classification result.

[0055] To build a sentence vector model, first input the event text into the bert-base model and transform each character generated by BERT The word representation is used as the word embedding vector. For example, the first event text in Table 2 above, after conversion, the word embedding is ["I", "I want", "check", "query", "one", "next", "talk", "fee"]. When using the bert-base model, the word embedding representation is obtained from the last hidden layer, and then the word vector representation of the entire sentence is averaged and pooled to obtain the pooled vector x j ∈R H As this event text d i The high-dimensional space vector representation of:

[0056] x j =mean-pooling([CLS,T1,...,T N ])

[0057] Finally, the pooled vector of the sentence "I want to check my phone bill" is [0.21, -0.44, 0.30, 0.65, -0.81, 0.32, 0.56, 0.12]. Input the sentence "I want to check my phone bill" into the model and get the cross entropy loss. {0.62}, supervised contrast loss is {0.51}.

[0058] Specifically, the cross entropy loss function is used to optimize the parameters of BERT. In order to learn the label information of each event type, the known label information is used as prior knowledge to fine-tune the model, and a linear classifier with a Softmax-loss loss is used to obtain the cross entropy loss.

[0059] Supervised contrastive learning uses label information to make samples of the same intent event type more similar in high-dimensional features while making the feature representations of samples of different event types more discriminative. For a multi-classification task with C classes, a batch contains M samples, represented as where d i Indicates the input event text, y i Indicates the event type to which the event text belongs. The supervised contrast loss of this task can be obtained through supervised contrast learning.

[0060]

[0061] Where A(i) = {1, ..., M}\{i} represents the set of all anchor point samples, P(i) = {p∈A(i): y i =yp} is the set of samples with event label i, τ is the temperature hyperparameter, which allows the model to better learn difficult samples, z i represents the feature representation obtained by the BERT module, z a represents the feature representation of different anchor points, and z p Represents the feature representation of the sample with event label i.

[0062] Add the two parts of the loss to get the complete loss of the sample For {1.13}, repeat the above steps, calculate the complete loss for each sample, and finally optimize the fine-tuning model. In the subsequent steps, this model is used to obtain the high-dimensional sentence vector representation of the sample.

[0063] The present invention uses a data enhancement method Mix-up to generate more OOD samples. Specifically, a new synthetic OOD sample x ood Can be generated like this:

[0064] x ood =α*x i +(1-α)*x j

[0065] For example, the sentence vectors of the two sentences are represented as [0.61, -0.23, 0.93, 0.43, 0.32], [-0.22, 1.03, 0.56.0.76, 0.02], and α is 0.2, then the sentence vector of the artificially synthesized OOD sample is [-0.05, 0.78, 0.63, 0.69, 0.08]. This sentence is also regarded as an open class sample, and all the generated open class samples are input into the model together. The samples finally input into the joint training model include three parts. The first part is the known class samples obtained, the second part is the re-labeled open class samples, and the third part is the above-mentioned artificially synthesized open class samples.

[0066] For the convenience of description, the intent classification data still uses Table 2. In practice, the intent text data and the model building data are different. For the sentence "I want to check the phone bill" in Table 2, it belongs to the open class sample, so the output of the confidence assessment branch 0.76 is subtracted from 1, and the output probability is 0.24. If the output of another sample "Recommend a broadband package" is 0.87 and it belongs to the "broadband application" business, then 0.87 is directly used as the final output probability. Loop through all samples for optimization, and finally get the trained model for testing.

[0067] First, the threshold of the confidence branch is pre-set to θ=0.85, and a new event text [Query which month's phone bill] is input. The classification prediction of the classification branch is [Phone bill query], and the prediction result of the confidence branch is [0.93]. Then it is considered that the prediction of [Phone bill query] is reliable, and the present invention determines that the label of this sample is [Phone bill query]. Similarly, if the prediction result of a confidence evaluation branch is [0.55], 0.55 is less than the set threshold value 0.85, then it is considered that this event text does not belong to the known class, but is [Open Class] intent. By looping through all test samples, the final result of each sample can be obtained.

[0068] At this point, the open intent detection model has been trained, and we can input an event text and output whether the text belongs to the open class. If it does not belong to the open class, we can output which specific known class it belongs to.

[0069] Example 2

[0070] The processing results of the method provided by the present invention are compared with those of several existing methods, and the results are shown in Table 3. In Table 3, DOC, MSP, OpenMax, DeepUnk, and ADB are different baseline methods, and JOSC is the method provided by the present invention; 25%, 50%, and 75% correspond to deleting 25%, 50%, and 75% of the in-domain sample labels in step S1 of the present invention, respectively; the present invention is applicable to both Chinese and English scenarios, and BANKING, StackOverflow, and WOS represent three different English datasets, respectively.

[0071] Table 3

[0072]

[0073] In Table 3, Accuarcy and F1 are evaluation indicators, representing accuracy and F1 value respectively. It can be seen that the Accuarcy and F1 indicators of the method of the present invention are generally higher than those of the existing methods.

[0074] For those skilled in the art, the technical solutions described in the above examples can be modified, or some of the technical features can be replaced by equivalents. Any modification, equivalent replacement, etc. made within the spirit and principle of the invention should be included in the protection scope of the invention.

Claims

1. A method for detecting open service intention based on supervised contrastive learning, characterized in that: The following steps are involved: S1: Classify the intent event text in the original dataset and divide the dataset into in-domain samples IND and out-of-domain samples OOD; S2: Preprocess the data set to remove extra spaces and punctuation marks in the text; S3: Perform BERT encoding on the IND sample obtained by preprocessing in step S2 to obtain the sentence vector representation of the entire text; S4: Based on the sentence vector representation obtained in step S3, the cross entropy loss function Softmax-Loss is used to capture the features of the same category through the linear classification layer to obtain the cross entropy loss. S5: Based on the sentence vector representation obtained in step S3, supervised contrastive learning is used to expand the feature differences of different classes and reduce the feature differences of the same class to obtain the supervised contrastive learning loss. S6: Based on the cross entropy loss and supervised contrastive learning loss obtained in step S4 and step S5 respectively, the overall loss of the fine-tuning stage is obtained by adding them together, and training optimization is performed to obtain a feature extractor model with discriminability; S7: Based on the preprocessed IND sample obtained in step S2, an artificially synthesized OOD sample is constructed through a Mix-up operation; S8: embedding representation, inputting the three parts of data, namely the known IND sample, the known OOD sample and the artificially synthesized OOD sample in step S7, into the feature extractor obtained in step S6 to obtain the sentence embedding vector representation of each sample; S9: Multi-task joint optimization, including two parts. The first part is a multi-classification task, which selects IND samples from the samples input in step S8 and optimizes them using SoftMax cross entropy loss to obtain the task loss. The second part is a confidence learning task, which obtains the confidence loss that a sample belongs to a new event. The two parts of the loss are added together to train to obtain the open intention detection model. The step S3 is specifically as follows: given a text s, for each word T in the text i Input to the BERT model: x j =mena-pooling(BERT(CLS,T1,T2…,T N )) Among them, CLS represents the classification label of the downstream task, N represents the length of the text, and mean-pooling represents the mean processing of the semantics of each word obtained by BERT. Finally, x is obtained. j A sentence vector representation representing the entire text; In step S7, the method for constructing an artificially synthesized OOD sample through a Mix-up operation is as follows: the synthesized OOD sample x ood It is calculated by weighted summation of known class samples from two different categories: x ood =α*x i +(1-a)*x j where x i and x j is the sentence vector representation of two event texts from different IND event types, and α is a uniform distribution from 0 to 1.

2. The open service intention detection method based on supervised contrastive learning according to claim 1 is characterized in that: The intent event text classification described in step S1 is specifically as follows: the intent event texts in the original data set all belong to in-domain samples, a certain proportion of in-domain sample labels are deleted by random deletion, and the corresponding intent event texts are re-marked as out-of-domain samples; the remaining in-domain samples and the re-marked out-of-domain samples are obtained.

3. The open service intention detection method based on supervised contrastive learning according to claim 1 is characterized in that: Step S4 is as follows: Use the cross entropy loss function to optimize the parameters of BERT. In order to learn the label information of each event type, use the known label information as prior knowledge to fine-tune the model, and use a linear classifier with a Softmax-loss loss to obtain the cross entropy loss.

4. The open service intention detection method based on supervised contrastive learning according to claim 1 is characterized in that: Step S5 is as follows: For a multi-classification task with C classes, a batch contains M samples, expressed as where d i Indicates the input event text, y i Indicates the event type to which the event text belongs. The supervised contrast loss of this task is obtained through supervised contrast learning. Where A(i) = {1,…,M}\{i} represents the set of all anchor point samples, P(i) = {p∈A(i):y i =y p } is the sample set with event label i, τ is the temperature hyperparameter, z i represents the feature representation obtained by the BERT module, z a Represents the feature representation of different anchor points, z p Represents the feature representation of the sample with event label i.

5. The open service intention detection method based on supervised contrastive learning according to claim 1 is characterized in that: The two parts described in step S9 receive the same input, i.e., the output from BERT; then the two parts pass through different multi-layer perceptrons MLP; the last layer of the confidence learning task uses a sigmoid activation function to adjust the confidence c between 0-1 i .

6. The open service intention detection method based on supervised contrastive learning according to claim 5 is characterized in that: The multi-classification task in step S9 is as follows: select all IND samples and then use cross entropy CE(…) to calculate the task loss Where L i represents the true label of the sample, p i represents the probability vector, and n is the number of IND samples.

7. The open service intention detection method based on supervised contrastive learning according to claim 5 is characterized in that: The confidence learning task in step S9 is specifically: using confidence to perform OOD detection: where c i is the confidence generated by the sigmoid activation function; for OOD samples, subtract c from 1 i , get the target confidence c′ i , otherwise keep c i As c′ i ; Then use c′ i The negative log-likelihood of As the confidence loss after training the model, will be returned to 0, which makes the c of the IND sample i Close to 1, c of OOD samples i Close to 0; In practical applications, a confidence threshold θ is set in advance. If the confidence level of the sample c i If it is less than the confidence threshold θ, it is considered to be an OOD sample, otherwise it is an IND sample.

Citation Information

Patent Citations

  • Security detection method and device based on open platform, equipment and storage medium

    CN112861125A

  • Weighted negative supervision text sentiment analysis method based on BERT model

    CN113723083A