Intent recognition method, device and equipment
By optimizing and training the BERT model, linear features and nonlinear features are extracted, and these features are combined for intent recognition, which solves the accuracy and efficiency problems of intent recognition in intelligent dialogue systems and achieves more efficient user intent recognition.
Patent Information
- Application Number
- CN202210453637.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-24
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2042-04-24
AI Technical Summary
In terms of user intent recognition, existing intelligent dialogue systems have problems such as insufficient utilization of pre-trained knowledge information and long time consumption caused by the large number of BERT model parameters. Especially when the number of tags is large, the intent recognition effect is poor.
By optimizing and training the BERT model, extracting linear features and nonlinear features, and combining these features for intent recognition processing, the optimized model can better utilize pre-training knowledge information, reduce reasoning time, and improve the accuracy of intent recognition. .
It improves the accuracy and efficiency of user intention recognition, solves the problems of poor knowledge reasoning ability and long time consumption of traditional models, and realizes multi-feature extraction and intention recognition.
Smart Images

Figure CN114860905B
Abstract
Description
Technical Field
[0001] This document relates to the field of data processing technology, and in particular to an intent recognition method, device and equipment. Background Art
[0002] With the continuous development of natural language processing (NLP) technology, intelligent dialogue systems are widely used in various scenarios, such as pre-sales consultation, after-sales service, risk control, etc. They can not only save labor costs, but also respond to users in a timely manner and improve user experience. How to accurately identify user intentions based on the text submitted by users is the key to intelligent dialogue systems.
[0003] Currently, there are two main ways to identify user intent: First, the traditional intent recognition model represented by LSTM (Long short-term memory) and TextCNN or its variants. Figure 1 The following is the structure of a traditional intent recognition model that combines LSTM and TextCNN. This method is difficult to combine with pre-trained knowledge information and has poor knowledge reasoning capabilities. Second, the traditional BERT model is used, and its structure is as follows Figure 2 As shown in the figure, due to the large number of parameters in this method, model inference takes a long time, and BERT Poole cannot extract enough knowledge information. When the number of tags is large, the intent recognition effect is not good. Therefore, how to improve the recognition efficiency and accuracy of user intent is a technical problem that needs to be solved urgently. Summary of the invention
[0004] One or more embodiments of the present specification provide a method for intent recognition. The method includes preprocessing the acquired data to be recognized to obtain target data. Based on the intent recognition model, feature extraction processing is performed on the target data to obtain linear features and nonlinear features of the target data. The intent recognition model is obtained by optimizing and training the BERT model. Based on the intent recognition model, intent recognition processing is performed according to the linear features and the nonlinear features to obtain the intent recognition result of the data to be recognized.
[0005] One or more embodiments of the present specification provide an intent recognition device. The device includes a preprocessing module that preprocesses the acquired data to be recognized to obtain target data. The device also includes a feature extraction module that performs feature extraction processing on the target data based on an intent recognition model to obtain linear features and nonlinear features of the target data. The intent recognition model is obtained by optimizing and training the BERT model. The device also includes an intent recognition unit that performs intent recognition processing based on the linear features and the nonlinear features based on the intent recognition model to obtain intent recognition results for the data to be recognized.
[0006] One or more embodiments of the present specification provide an intent recognition device. The device includes a processor. The device also includes a memory arranged to store computer executable instructions. When the computer executable instructions are executed, the processor pre-processes the acquired data to be recognized to obtain target data. Feature extraction processing is performed on the target data based on the intent recognition model to obtain linear features and non-linear features of the target data. The intent recognition model is obtained by optimizing and training the BERT model. Intent recognition processing is performed based on the linear features and the non-linear features based on the intent recognition model to obtain the intent recognition result of the data to be recognized.
[0007] One or more embodiments of the present specification provide a storage medium. The storage medium is used to store computer executable instructions. When the computer executable instructions are executed by the processor, the acquired data to be identified is preprocessed to obtain target data. Feature extraction processing is performed on the target data based on the intent recognition model to obtain linear features and nonlinear features of the target data. The intent recognition model is obtained by optimizing and training the BERT model. Based on the intent recognition model, intent recognition processing is performed according to the linear features and the nonlinear features to obtain the intent recognition result of the data to be identified. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate one or more embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0009] Figure 1 It is a structural diagram of the first intention recognition model in the prior art;
[0010] Figure 2 It is a structural diagram of a second intention recognition model in the prior art;
[0011] Figure 3 A first flow chart of an intent recognition method provided for one or more embodiments of this specification;
[0012] Figure 4 A second flow chart of an intent recognition method provided for one or more embodiments of this specification;
[0013] Figure 5 A schematic diagram of the structure of an intent recognition model provided for one or more embodiments of this specification;
[0014] Figure 6 A third flow chart of an intent recognition method provided for one or more embodiments of this specification;
[0015] Figure 7 A schematic diagram of the module composition of an intention recognition device provided in one or more embodiments of this specification;
[0016] Figure 8 A schematic diagram of the structure of an intent recognition device provided for one or more embodiments of this specification. DETAILED DESCRIPTION
[0017] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the following will be combined with the drawings in one or more embodiments of this specification to clearly and completely describe the technical solutions in one or more embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this document.
[0018] Figure 3 A flowchart of an intent recognition method provided in one or more embodiments of this specification, Figure 3 The method can be executed by an intention recognition device, which can be set in a terminal device or a server. The terminal device can be a mobile phone, a tablet computer, a desktop computer, a portable notebook, etc. The server can be an independent server or a server cluster composed of multiple servers. Figure 3 As shown, the method comprises the following steps:
[0019] Step S102, preprocessing the acquired data to be identified to obtain target data;
[0020] Specifically, the data to be identified is obtained, and the obtained data to be identified is preprocessed to obtain the target data. The data to be identified includes text data to be identified, and the text data to be identified may include one or more of words, numbers, letters, punctuation marks, special characters, etc.; special characters include @, *, &, etc.
[0021] The intent recognition method provided in the embodiments of this specification can be used not only to recognize the intent of the dialogue content in the intelligent dialogue system, but also to recognize the intent of individual sentences. Specifically, in one embodiment, obtaining the data to be recognized may include: obtaining the data to be recognized from a specified intelligent dialogue system. In another embodiment, obtaining the data to be recognized may include: receiving the data to be recognized sent by the requesting device. In yet another embodiment, the intent recognition device may include an input module, and correspondingly, obtaining the data to be recognized may include: obtaining the data to be recognized input by the user. The method for obtaining the data to be recognized can be set by oneself according to needs in actual applications, and this specification does not make specific limitations on this.
[0022] It should be pointed out that when the intention recognition device performs intent recognition on the conversation content in the intelligent dialogue system, the intention recognition device and the intelligent dialogue system can be independently set in the same terminal device or the same server; the intention recognition device can also be embedded in the intelligent dialogue system as a part of the intelligent dialogue system; the intention recognition device can also be independently set in different terminal devices or different servers from the intelligent dialogue system.
[0023] Step S104, performing feature extraction processing on the target data based on the intent recognition model to obtain linear features and nonlinear features of the target data; wherein the intent recognition model is obtained by optimizing and training the BERT model;
[0024] Considering that the traditional BERT model has problems such as large number of parameters and long time consumption, in the embodiments of this specification, the structure of the traditional BERT model is optimized in advance, and the intent recognition model is trained to obtain the intent recognition model, so as to perform feature extraction processing on the target data based on the intent recognition model. The specific structure of the intent recognition model and the specific process of feature extraction processing can be found in the relevant description below.
[0025] Step S106, performing intent recognition processing based on the linear features and nonlinear features based on the intent recognition model to obtain intent recognition results of the data to be recognized.
[0026] In one or more embodiments of the present specification, the traditional BERT model is optimized and trained in advance to obtain an intent recognition model, and based on the intent recognition unit, feature extraction processing is performed on the preprocessed target data to obtain linear features and nonlinear features, and intent recognition processing is performed based on the linear features and nonlinear features to obtain intent recognition results. Therefore, by optimizing the BERT model, not only can the pre-trained knowledge information of the BERT model be well utilized, solving the problem that the traditional LSTM model and TextCNN model have no knowledge reasoning ability, but also solving the problem that the traditional BERT model takes a long time. Furthermore, the intent recognition model obtained by optimizing the BERT model can extract the linear features and nonlinear features of the target data, realize the extraction of multiple features, and then perform intent recognition based on the multiple features, greatly improving the accuracy of intent recognition.
[0027] In order to effectively perform feature extraction processing and thus perform intent recognition, in one or more embodiments of this specification, the acquired data to be processed is first preprocessed. Specifically, Figure 4 As shown, step S102 may include the following steps S102-2 to S102-8:
[0028] Step S102-2, performing word segmentation processing on the data to be recognized according to a preset word segmentation method to obtain a word segmentation result;
[0029] Among them, the word segmentation method can be set according to the needs in actual application. In one embodiment, the tokenizer in BERT can be used to perform word segmentation on the recognition data to obtain the word segmentation result. Among them, the word segmentation result includes one or more of text, Chinese words, numbers, letters, English words, etc. In this specification, individual text, numbers, letters, etc. are collectively referred to as characters, and Chinese words, English words, etc. are collectively referred to as words. As an example, the data to be processed is "I want to buy a computer", and the word segmentation result is "I, want, buy, computer".
[0030] It should be pointed out that when the data to be identified is a conversation in an intelligent dialogue system, the question part and the reply part in the conversation can be first concatenated, and then the concatenated data can be segmented according to a preset segmentation method to obtain a segmentation result.
[0031] Step S102-4, determining identification information of each word in the word segmentation result;
[0032] Specifically, an association relationship between each word and identification information is established in advance, and the associated identification information is obtained from the association relationship according to each word in the word segmentation result, and is determined as the identification information of the corresponding word. The identification information may be a number, and the number of numbers included in different identification information may be different. For example, the identification information of the word "I" is 1, the identification information of the word "want" is 10, the identification information of the word "buy" is 23, and the identification information of the word "computer" is 68, etc.
[0033] Step S102-6, according to the position information of each word in the word segmentation result in the data to be identified, concatenate the identification information to obtain an identification information sequence;
[0034] Specifically, according to the position information of each word in the word segmentation result in the data to be identified, the arrangement order of each word in the word segmentation result is determined, and according to the determined arrangement order, the corresponding identification information is spliced to obtain the identification information sequence. Continuing with the above example, the identification information sequence obtained by splicing is 1102368.
[0035] Step S102-8: convert the identification information sequence into target data, where the target data includes a preset amount of identification information.
[0036] Specifically, determine the relationship between the first number of identification information included in the identification information sequence and the preset number. If the first number is less than the preset number, the identification information sequence is supplemented according to the preset supplement method to obtain target data including the preset number of identification information; if the first number is equal to the preset number, the identification information sequence is determined as the target number; if the first number is greater than the preset number, the identification information after the preset number in the identification information sequence is discarded in order from front to back. Among them, the supplement method and the preset number can be set as needed in actual applications. In one embodiment, the supplement method can be to supplement the preset identification information (for example, "0"), and the preset number can be 64. For example, if the first number is 30, four "0"s are supplemented after the 30th identification information; for another example, if the first number is 68, the 65th to 68th identification information are discarded in order from front to back.
[0037] By preprocessing the data to be processed to obtain the target data, it can be ensured that the target data meets the data processing requirements of the intent recognition model, thereby effectively performing feature extraction and intent recognition processing.
[0038] like Figure 5 As shown, the intent recognition model provided in the embodiment of this specification includes an optimized BERT unit, a nonlinear feature extraction unit and an intent recognition unit. Figure 6As shown, step S104 may include the following steps S104-2 and S104-6, and step S106 may include the following steps S106-2 and S106-4:
[0039] Step S104-2, performing linear feature extraction processing on the target data based on the optimized BERT unit of the intent recognition model to obtain the linear features of the target data;
[0040] like Figure 3 As shown, the optimized BERT unit of the intent recognition model includes a BertEmbedding layer, a BertEncoder layer, a first fully connected layer, a first normalization layer, a second normalization layer, and a maximum pooling layer. Accordingly, step S102-2 may include the following steps S102-2-2 to S102-2-16:
[0041] Step S102-2-2, converting each identification information in the target data through the BertEmbedding layer to obtain conversion data of each identification information;
[0042] Specifically, the target data is input into the BertEmbedding layer, and each identification information in the target data is converted through the BertEmbedding layer to obtain conversion data of preset dimensions for each identification information, and the conversion data is output. Among them, the specific method of the conversion processing of the BertEmbedding layer can refer to the conversion processing method of the BertEmbedding layer of the traditional BERT model, which will not be described in detail in this specification. The preset dimension can be set by itself as needed in actual applications. As an example, the target data includes 64 identification information, and the preset dimension is 1*768, then each identification information is converted into 1*768 conversion data, and 64 1*768 conversion data are obtained.
[0043] Step S102-2-4, determining the association relationship between each converted data through the BertEncoder layer, and generating a first feature matrix of the target data according to the association relationship;
[0044] Specifically, each conversion data is input into the BertEncoder layer, the association relationship between each conversion data is determined by the BertEncoder layer, and the first feature matrix of the target data is generated according to the determined association relationship, and the first feature matrix is output. Among them, the specific method of the BertEncoder layer to determine the association relationship between the conversion data and generate the first feature matrix can refer to the processing method of the BertEncoder layer of the traditional BERT model, which will not be described in detail in this specification. Continuing with the previous example, a 64*768 first feature matrix is generated based on 64 1*768 conversion data.
[0045] Step S102-2-6, converting the first feature matrix through the first fully connected layer to obtain a second feature matrix;
[0046] Specifically, the first feature matrix is input into the first fully connected layer, and the first feature matrix is multiplied by the preset matrix through the first fully connected layer to obtain the second feature matrix and output the second feature matrix. The first fully connected layer can also be represented as a Linear layer. Continuing with the above example, the 64*768 first feature matrix is converted through the first fully connected layer to obtain a 64*768 second feature matrix.
[0047] Step S102-2-8, performing a first normalization process on the second characteristic matrix through a first normalization layer to obtain a third characteristic matrix;
[0048] Specifically, the second characteristic matrix is input into the first normalization layer, and the first normalization layer is used to perform the first normalization processing on the second characteristic matrix to obtain the third characteristic matrix and output the third characteristic matrix. Among them, the first normalization layer can also be expressed as the first Norm layer. The specific method of the first normalization processing can be set by itself according to needs in practical applications. By performing the first normalization processing, it is ensured that the values of each element in the third characteristic matrix are within a reasonable range, and the problems such as reducing the model effect due to data dispersion are avoided. Continuing with the above example, the first normalization layer is used to perform the first normalization processing on the second characteristic matrix of 64*768 to obtain the third characteristic matrix of 64*768.
[0049] Step S102-2-10, performing a first merging process on the first characteristic matrix and the third characteristic matrix to obtain a fourth characteristic matrix;
[0050] Specifically, the first characteristic matrix and the third characteristic matrix are added to obtain a fourth characteristic matrix. Continuing with the above example, the first characteristic matrix of 64*768 and the third characteristic matrix of 64*768 are added to obtain a fourth characteristic matrix of 64*768.
[0051] Step S102-2-12, performing a second normalization process on the fourth characteristic matrix through a second normalization layer to obtain a fifth characteristic matrix;
[0052] Specifically, the fourth characteristic matrix is input into the second normalization layer, and the fourth characteristic matrix is subjected to the second normalization processing by the second normalization layer to obtain the fifth characteristic matrix and output the fifth characteristic matrix. The second normalization layer can also be expressed as the second Norm layer. The second normalization processing method can be the same as or different from the first normalization processing method, which can be set according to the actual application. Continuing with the above example, the fourth characteristic matrix of 64*768 is subjected to the second normalization processing by the second normalization layer to obtain the fifth characteristic matrix of 64*768.
[0053] Step S102-2-14, performing a second merging process on the first characteristic matrix and the fifth characteristic matrix to obtain a sixth characteristic matrix;
[0054] Specifically, the first characteristic matrix and the fifth characteristic matrix are concatenated to obtain the sixth characteristic matrix. Continuing with the above example, the first characteristic matrix of 64*768 and the fifth characteristic matrix of 64*768 are concatenated to obtain the sixth characteristic matrix of 64*1536.
[0055] Step S102-2-16, performing maximum pooling processing on the sixth feature matrix through the maximum pooling layer to obtain the linear features of the target data.
[0056] Specifically, the sixth feature matrix is input into the maximum pooling layer, and the elements included in each column of the sixth feature matrix are compared through the maximum pooling layer to obtain the maximum element in each column, and the linear features of the target data are generated and output according to the maximum element in each column. Continuing with the above example, the 64*1536 sixth feature matrix is subjected to maximum pooling processing through the maximum pooling layer to obtain the 1*1536 linear features of the target data. It can be seen that by concatenating the first feature matrix and the fifth feature matrix and then performing the maximum pooling processing, the feature space is expanded, and the problem of multi-label classification can be better handled.
[0057] Depend on Figure 2It can be seen that the traditional BERT model includes a BertEmbedding layer, a BertEncoder layer and a BertPooler layer. Among them, the BertEncoder layer is usually repeated in multiple layers. It is generally believed that the more BertEncoder layers are set, the better the recognition effect, but the longer it takes. In the traditional BERT model, the BertEncoder layer is usually set to 12 layers. The optimized BERT unit in the intent recognition model provided in the embodiment of this specification replaces the BertPooler layer of the traditional BERT model with the above-mentioned first fully connected layer, first normalization layer, second normalization layer and maximum pooling layer, which not only realizes the extraction of linear features and the expansion of feature space, but also sets the BertEncoder layer to 5 layers to achieve results similar to those of the traditional 12-layer BertEncoder, thereby greatly reducing the number of BertEncoder layers, thereby reducing the time consumption of reasoning.
[0058] The following is a comparison of the F1 metric and inference time of the combined LSTM and TextCNN model, the traditional BERT model, and the intent recognition model provided in this manual:
[0059]
[0060]
[0061] It can be seen that the F1 metric and reasoning time of the intent recognition model provided in this manual are better than the combined model of LSTM and TextCNN and the traditional BERT model, which means that the recognition accuracy is improved and the reasoning time is reduced.
[0062] Step S104-4, the nonlinear feature extraction unit based on the intention recognition model performs nonlinear transformation processing on the linear features of the target data to obtain the nonlinear features of the target data;
[0063] like Figure 5 As shown, the nonlinear feature extraction unit includes a third normalization layer and a nonlinear layer. Accordingly, step S104-4 may include the following steps S104-4-2 and S104-4-4:
[0064] Step S104-4-2, performing a third normalization process on the linear features through a third normalization layer to obtain target linear features;
[0065] Specifically, the linear features are input into the third normalization layer, and the third normalization layer is used to perform the third normalization processing on the linear features to obtain the target linear features and output the target linear features. The third normalization layer can also be expressed as a third Norm layer. The third normalization processing method can be the same as or different from the first normalization and the second normalization processing methods mentioned above, and it can be set according to needs in practical applications. Continuing with the above example, the third normalization layer is used to perform the third normalization processing on the 1*1536 linear features to obtain the 1*1536 target linear features.
[0066] Step S104-4-4, performing nonlinear transformation processing on the target linear features through a nonlinear layer to obtain the nonlinear features of the target data.
[0067] Specifically, the target linear feature is input into the nonlinear layer, and the target linear feature is nonlinearly transformed by the activation function in the nonlinear layer to obtain the nonlinear feature of the target data and output the nonlinear feature. Continuing with the above example, the nonlinear layer performs nonlinear transformation on the 1*1536 target linear feature to obtain the 1*1536 nonlinear feature of the target data.
[0068] Step S106-2, the intention recognition unit based on the intention recognition model determines the intention classification label corresponding to the data to be recognized according to the linear features and the non-linear features;
[0069] like Figure 5 As shown, the intent recognition unit includes a fourth normalization layer and a second fully connected layer. Accordingly, step S106-2 may include the following steps S106-2-2 to S102-2-8:
[0070] Step S106-2-2, performing a first merging process on the target linear feature and the nonlinear feature to obtain a merged feature;
[0071] Specifically, the target linear feature and the nonlinear feature are added to obtain the merged feature. Continuing with the above example, the target linear feature of 1*1536 and the nonlinear feature of 1*1536 are merged to obtain the merged feature of 1*1536.
[0072] Step S106-2-4, performing fourth normalization processing on the merged features through a fourth normalization layer to obtain a target merged feature;
[0073] Specifically, the merged features are input into the fourth normalization layer, and the merged features are subjected to fourth normalization processing through the fourth normalization layer to obtain target merged features. The fourth normalization layer can also be expressed as the fourth Norm layer. The fourth normalization process may be the same as or different from the aforementioned first normalization process, second normalization process, and third normalization process, and it can be set as needed in practical applications. Continuing with the above example, the merged features of 1*1536 are subjected to fourth normalization processing through the fourth normalization layer to obtain target merged features of 1*1536.
[0074] Step S106-2-6, mapping the target merged features into probabilities corresponding to each preset intent classification label through the second fully connected layer;
[0075] Specifically, the target merged features are input into the second fully connected layer, and the target merged features are mapped into probabilities corresponding to each preset intent classification label through the second fully connected layer, and the seventh feature matrix composed of the probabilities is output. Continuing with the previous example, if the number of preset intent classification labels is m, the 1*1536 target merged features are mapped into m probabilities through the second fully connected layer, and the 1*m seventh feature matrix composed of the m probabilities is output.
[0076] Wherein, m is an integer greater than 0. Different intent identification tags are used to identify different intents. For example, intent identification tag 1 is used to identify the corresponding intent of purchasing electronic products, and intent identification tag 2 is used to identify the intent of logistics inquiry, etc.
[0077] Step S106-2-8, obtaining at least one target probability greater than the probability threshold from each probability, and determining the intent classification label corresponding to the target probability as the intent classification label corresponding to the data to be identified.
[0078] Specifically, each probability in the seventh feature matrix is compared with a preset probability threshold to obtain at least one target probability greater than the probability threshold, and the intent classification label corresponding to the at least one target probability is determined as the intent classification label corresponding to the data to be identified.
[0079] Step S106-4, determining the intent recognition result of the data to be recognized according to the intent classification label.
[0080] Considering that in actual applications, various factors may cause conflicting labels in the intent recognition labels corresponding to the target probability, that is, multiple labels that cannot be established at the same time. For example, the data to be processed is that the user wants to express his or her identity, but the intent recognition labels corresponding to the target probability include an intent recognition label that represents the user's identity as a father, and also include an intent recognition label that represents the user's identity as a mother. Since these two labels cannot be established at the same time, the two labels are conflicting labels. Based on this, in one or more embodiments of this specification, step S106-4 may include the following steps S106-4-2 and step S106-4-4:
[0081] S106-4-2, determining whether the intent classification label contains a preset conflict label;
[0082] S106-4-4, if yes, remove the intent classification labels with small probability in the conflicting labels, and determine the intent recognition result of the data to be recognized based on the remaining intent classification labels.
[0083] Specifically, when m intent recognition labels are preset, conflict labels among the m intent recognition labels are also set. After obtaining the intent classification label corresponding to the data to be recognized, determine whether the intent classification label corresponding to the data to be recognized contains the preset conflict label. If it does, compare the probabilities corresponding to the intent classification labels included in the conflict label to obtain the maximum probability, and determine the intent corresponding to the intent classification label corresponding to the maximum probability as the intent recognition result of the data to be recognized.
[0084] Therefore, by combining linear features and nonlinear features to determine the intent recognition result, the accuracy of the intent recognition result is greatly improved.
[0085] In order to achieve efficient and accurate intent recognition, in one or more embodiments of this specification, before step S102, the following steps S100-2 and S100-4 are also included:
[0086] Step S100-2, obtaining a sample data set to be trained; wherein each sample data in the sample data set is marked with an intent classification label;
[0087] In one embodiment, multiple sample data can be obtained from the intelligent dialogue system, and the intent classification labels can be annotated to obtain a sample data set to be trained. The method for obtaining the sample data set is not specifically limited in this specification, and it can be set according to actual needs in actual applications.
[0088] Step S100-4, performing model training processing based on the sample data set to obtain an intent recognition model.
[0089] Specifically, the sample data set is iteratively input into the model to be trained, and feature extraction is performed on each sample data in the training set based on the model to be trained to obtain linear features and nonlinear features of each sample data; intent recognition is performed based on the extracted linear features and nonlinear features based on the model to be trained to obtain predicted intent classification labels for the sample data; if the preset training stop condition is determined to be met based on the preset loss function, the intent classification labels annotated with the sample data, and the predicted intent classification labels corresponding to the sample data, then the corresponding model to be trained is determined as the intent recognition model.
[0090] Among them, the specific process of extracting features from each sample data in the training set based on the model to be trained, obtaining the linear features and nonlinear features of each sample data, and performing intent recognition processing based on the extracted linear features and nonlinear features of the model to be trained can be referred to the relevant description in the previous text, and the repetition will not be repeated here. The training stop condition can be set by oneself according to the actual application as needed, such as the number of training times reaches the preset number of times, or the recognition accuracy is determined to be greater than the preset accuracy based on the loss function. The loss function can be Softmax, etc. The sample data set can also be divided into a training set and a test set, and the aforementioned training process is performed based on the training set, and when it is determined that the preset training stop condition is met, the corresponding model to be trained is determined as the intent recognition model to be tested; the intent recognition model to be tested is tested based on the test set; if the test result meets the preset condition, the intent recognition model to be tested is determined as the final intent recognition model, and if the test result does not meet the preset condition, the training process is performed again based on the training set. The specific process of training can be set by oneself according to the actual application as needed.
[0091] In one or more embodiments of the present specification, the traditional BERT model is optimized and trained in advance to obtain an intent recognition model, and based on the intent recognition unit, feature extraction processing is performed on the preprocessed target data to obtain linear features and nonlinear features, and intent recognition processing is performed based on the linear features and nonlinear features to obtain intent recognition results. Therefore, by optimizing the BERT model, not only can the pre-trained knowledge information of the BERT model be well utilized, solving the problem that the traditional LSTM model and TextCNN model have no knowledge reasoning ability, but also solving the problem that the traditional BERT model takes a long time. Furthermore, the intent recognition model obtained by optimizing the BERT model can extract the linear features and nonlinear features of the target data, realize the extraction of multiple features, and then perform intent recognition based on the multiple features, greatly improving the accuracy of intent recognition.
[0092] Corresponding to the intention recognition method described above, based on the same technical concept, one or more embodiments of this specification also provide an intention recognition device. Figure 7 A schematic diagram of the module composition of an intention recognition device provided in one or more embodiments of this specification, such as Figure 7 As shown, the device comprises:
[0093] A preprocessing module 201 preprocesses the acquired data to be identified to obtain target data;
[0094] A feature extraction module 202 performs feature extraction processing on the target data based on an intent recognition model to obtain linear features and nonlinear features of the target data; the intent recognition model is obtained by optimizing and training the BERT model;
[0095] The intention recognition module 203 performs intention recognition processing based on the intention recognition model according to the linear features and the nonlinear features to obtain an intention recognition result of the data to be recognized.
[0096] Optionally, the intent recognition model includes an optimized BERT unit and a nonlinear feature extraction unit;
[0097] Correspondingly, the feature extraction module 202 performs linear feature extraction processing on the target data based on the optimized BERT unit to obtain the linear features of the target data; and
[0098] Based on the nonlinear feature extraction unit, nonlinear transformation processing is performed on the linear features of the target data to obtain the nonlinear features of the target data.
[0099] Optionally, the intention recognition module 203, based on the intention recognition unit of the intention recognition model, determines the intention classification label corresponding to the data to be recognized according to the linear features and the non-linear features; and determines the intention recognition result of the data to be recognized according to the intention classification label.
[0100] Optionally, the device further comprises: an acquisition module and a training module;
[0101] The acquisition module acquires a sample data set to be trained; each sample data in the sample data set is marked with an intent classification label;
[0102] The training module performs model training processing based on the sample data set to obtain the intent recognition model.
[0103] The intent recognition device provided by one or more embodiments of the present specification optimizes and trains the traditional BERT model in advance to obtain an intent recognition model, and based on the intent recognition unit, performs feature extraction processing on the preprocessed target data to obtain linear features and non-linear features, and performs intent recognition processing based on the linear features and non-linear features to obtain intent recognition results. Therefore, by optimizing the BERT model, not only can the pre-trained knowledge information of the BERT model be well utilized, solving the problem that the traditional LSTM model and TextCNN model have no knowledge reasoning ability, but also solving the problem that the traditional BERT model takes a long time. Furthermore, the intent recognition model obtained by optimizing the BERT model can extract the linear features and non-linear features of the target data, realize the extraction of multiple features, and then perform intent recognition based on the multiple features, which greatly improves the accuracy of intent recognition.
[0104] It should be noted that the embodiments of the intent recognition device in this specification and the embodiments of the intent recognition method in this specification are based on the same inventive concept, so the specific implementation of this embodiment can refer to the implementation of the corresponding intent recognition method mentioned above, and the repeated parts will not be repeated.
[0105] Further, corresponding to the above-described intention recognition method, based on the same technical concept, one or more embodiments of this specification also provide an intention recognition device, which is used to execute the above-described intention recognition method. Figure 8 A schematic diagram of the structure of an intent recognition device provided for one or more embodiments of this specification.
[0106] like Figure 8 As shown, the intent recognition device may have relatively large differences due to different configurations or performances, and may include one or more processors 301 and memory 302, and the memory 302 may store one or more storage applications or data. Among them, the memory 302 can be a short-term storage or a persistent storage. The application stored in the memory 302 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the intent recognition device. Furthermore, the processor 301 can be configured to communicate with the memory 302 and execute a series of computer executable instructions in the memory 302 on the intent recognition device. The intent recognition device may also include one or more power supplies 303, one or more wired or wireless network interfaces 304, one or more input and output interfaces 305, one or more keyboards 306, etc.
[0107] In a specific embodiment, the intent recognition device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions for the intent recognition device, and the one or more programs are configured to be executed by one or more processors, including computer executable instructions for performing the following:
[0108] Preprocessing the acquired data to be identified to obtain target data;
[0109] Performing feature extraction processing on the target data based on the intent recognition model to obtain linear features and nonlinear features of the target data; the intent recognition model is obtained by optimizing and training the BERT model;
[0110] Based on the intention recognition model, intention recognition processing is performed according to the linear features and the nonlinear features to obtain the intention recognition result of the data to be recognized.
[0111] The intent recognition device provided by one or more embodiments of the present specification optimizes and trains the traditional BERT model in advance to obtain an intent recognition model, and based on the intent recognition unit, performs feature extraction processing on the preprocessed target data to obtain linear features and non-linear features, and performs intent recognition processing based on the linear features and non-linear features to obtain intent recognition results. Therefore, by optimizing the BERT model, not only can the pre-trained knowledge information of the BERT model be well utilized, solving the problem that the traditional LSTM model and TextCNN model have no knowledge reasoning ability, but also solving the problem that the traditional BERT model takes a long time. Furthermore, the intent recognition model obtained by optimizing the BERT model can extract the linear features and non-linear features of the target data, realize the extraction of multiple features, and then perform intent recognition based on the multiple features, which greatly improves the accuracy of intent recognition.
[0112] It should be noted that the embodiments of the intent recognition device in this specification and the embodiments of the intent recognition method in this specification are based on the same inventive concept, so the specific implementation of this embodiment can refer to the implementation of the corresponding intent recognition method mentioned above, and the repeated parts will not be repeated.
[0113] Furthermore, corresponding to the above-described intention recognition method, based on the same technical concept, one or more embodiments of this specification further provide a storage medium for storing computer executable instructions. In a specific embodiment, the storage medium may be a USB flash drive, an optical disk, a hard disk, etc. When the computer executable instructions stored in the storage medium are executed by the processor, the following process can be implemented:
[0114] Preprocessing the acquired data to be identified to obtain target data;
[0115] Performing feature extraction processing on the target data based on the intent recognition model to obtain linear features and nonlinear features of the target data; the intent recognition model is obtained by optimizing and training the BERT model;
[0116] Based on the intention recognition model, intention recognition processing is performed according to the linear features and the nonlinear features to obtain the intention recognition result of the data to be recognized.
[0117] The computer executable instructions stored in the storage medium provided in one or more embodiments of this specification are executed by the processor to optimize and train the traditional BERT model in advance to obtain an intent recognition model, and based on the intent recognition unit, perform feature extraction processing on the preprocessed target data to obtain linear features and non-linear features, and perform intent recognition processing based on the linear features and non-linear features to obtain intent recognition results. Therefore, by optimizing the BERT model, not only can the pre-trained knowledge information of the BERT model be well utilized, solving the problem that the traditional LSTM model and TextCNN model have no knowledge reasoning ability, but also solving the problem that the traditional BERT model takes a long time. Furthermore, the intent recognition model obtained by optimizing the BERT model can extract the linear features and non-linear features of the target data, realize the extraction of multiple features, and then perform intent recognition based on the multiple features, which greatly improves the accuracy of intent recognition.
[0118] It should be noted that the embodiments of the storage medium in this specification and the embodiments of the intent recognition method in this specification are based on the same inventive concept, so the specific implementation of this embodiment can refer to the implementation of the corresponding intent recognition method mentioned above, and the repeated parts will not be repeated.
[0119] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0120] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0121] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0122] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0123] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing the embodiments of this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0124] It should be understood by those skilled in the art that one or more embodiments of this specification may be provided as a method, system or computer program product. Therefore, one or more embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0125] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0126] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0127] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0128] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0129] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0130] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0131] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0132] One or more embodiments of the present specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0133] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0134] The above description is only an embodiment of this document and is not intended to limit this document. For those skilled in the art, this document may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this document should be included in the scope of the claims of this document.
Claims
1. An intention recognition method, comprising: Preprocessing the acquired data to be identified to obtain target data; Performing feature extraction processing on the target data based on the intention recognition model to obtain linear features and nonlinear features of the target data; The intent recognition model is a model obtained by optimizing the structure of the BERT model and training it, including an optimized BERT unit for extracting linear features and a nonlinear feature extraction unit, the optimized BERT unit includes a BertEmbedding layer, a BertEncoder layer, a first fully connected layer, a first normalization layer, a second normalization layer and a maximum pooling layer, and the nonlinear feature is obtained by performing nonlinear transformation processing on the linear features of the target data by the nonlinear feature extraction unit; Based on the intention recognition model, intention recognition processing is performed according to the linear features and the nonlinear features to obtain the intention recognition result of the data to be recognized.
2. According to the method of claim 1, the step of preprocessing the acquired data to be identified to obtain target data comprises: Performing word segmentation processing on the data to be identified according to a preset word segmentation method to obtain a word segmentation result; Determining identification information of each word in the word segmentation result; According to the position information of each word in the word segmentation result in the data to be identified, the identification information is concatenated to obtain an identification information sequence; The identification information sequence is converted into target data, wherein the target data includes a preset number of the identification information.
3. The method according to claim 2, wherein the step of performing feature extraction processing on the target data based on the intention recognition model to obtain linear features and nonlinear features of the target data comprises: Performing linear feature extraction processing on the target data based on the optimized BERT unit to obtain linear features of the target data; Based on the nonlinear feature extraction unit, nonlinear transformation processing is performed on the linear features of the target data to obtain the nonlinear features of the target data.
4. The method according to claim 3, The performing linear feature extraction processing on the target data based on the optimized BERT unit to obtain the linear features of the target data includes: Performing conversion processing on each identification information in the target data through the BertEmbedding layer to obtain conversion data of each identification information; Determine the association relationship between the converted data through the BertEncoder layer, and generate a first feature matrix of the target data according to the association relationship; Performing a transformation process on the first feature matrix through the first fully connected layer to obtain a second feature matrix; Performing a first normalization process on the second feature matrix through the first normalization layer to obtain a third feature matrix; Performing a first merging process on the first characteristic matrix and the third characteristic matrix to obtain a fourth characteristic matrix; Performing a second normalization process on the fourth characteristic matrix through the second normalization layer to obtain a fifth characteristic matrix; Performing a second merging process on the first characteristic matrix and the fifth characteristic matrix to obtain a sixth characteristic matrix; The sixth feature matrix is subjected to maximum pooling processing by the maximum pooling layer to obtain linear features of the target data.
5. The method according to claim 3, wherein the nonlinear feature extraction unit comprises a third normalization layer and a nonlinear layer; and the nonlinear feature extraction unit performs nonlinear transformation processing on the linear features of the target data to obtain the nonlinear features of the target data, comprising: Performing a third normalization process on the linear feature through the third normalization layer to obtain a target linear feature; The target linear feature is subjected to nonlinear transformation processing by the nonlinear layer to obtain the nonlinear feature of the target data.
6. The method according to claim 5, wherein the performing intention recognition processing based on the intention recognition model according to the linear features and the nonlinear features to obtain the intention recognition result of the data to be recognized comprises: An intention recognition unit based on the intention recognition model determines the intention classification label corresponding to the data to be recognized according to the linear feature and the non-linear feature; Determine the intent recognition result of the data to be recognized according to the intent classification label.
7. According to the method of claim 6, the intent recognition unit comprises a fourth normalization layer and a second fully connected layer; the intent recognition unit based on the intent recognition model determines the intent classification label corresponding to the data to be recognized according to the linear feature and the nonlinear feature, comprising: Performing a first merging process on the target linear feature and the nonlinear feature to obtain a merged feature; Performing a fourth normalization process on the merged features through the fourth normalization layer to obtain a target merged feature; Mapping the target merged features into probabilities corresponding to each preset intent classification label one by one through the second fully connected layer; At least one target probability greater than a probability threshold is obtained from the probabilities, and the intent classification label corresponding to the target probability is determined as the intent classification label corresponding to the data to be identified.
8. According to the method of claim 7, determining the intent recognition result of the data to be recognized according to the intent classification label comprises: Determining whether the intent classification label contains a preset conflict label; If so, the intent recognition result of the data to be recognized is determined according to the intent classification label with the highest probability among the conflicting labels.
9. The method according to claim 1, further comprising: Obtain a set of sample data to be trained; Each sample data in the sample data set is annotated with an intent classification label; Model training processing is performed based on the sample data set to obtain the intent recognition model.
10. The method according to claim 9, wherein the performing model training processing based on the sample data set to obtain the intention recognition model comprises: Iteratively inputting the sample data set into the model to be trained, performing feature extraction processing on each sample data in the training set based on the model to be trained, and obtaining linear features and nonlinear features of each sample data, wherein the training set is obtained by dividing the sample data set; Performing intent recognition processing based on the linear features and the nonlinear features based on the model to be trained to obtain a predicted intent classification label for the sample data; If it is determined that the preset training stop condition is met based on the preset loss function, the intent classification label annotated by the sample data, and the predicted intent classification label, the corresponding model to be trained is determined as the intent recognition model.
11. An intention recognition device, comprising: A preprocessing module preprocesses the acquired data to be identified to obtain target data; A feature extraction module performs feature extraction processing on the target data based on the intention recognition model to obtain linear features and nonlinear features of the target data; The intent recognition model is a model obtained by optimizing the structure of the BERT model and training it, including an optimized BERT unit for extracting linear features and a nonlinear feature extraction unit, the optimized BERT unit includes a BertEmbedding layer, a BertEncoder layer, a first fully connected layer, a first normalization layer, a second normalization layer and a maximum pooling layer, and the nonlinear feature is obtained by performing nonlinear transformation processing on the linear features of the target data by the nonlinear feature extraction unit; The intention recognition module performs intention recognition processing based on the intention recognition model according to the linear features and the nonlinear features to obtain the intention recognition result of the data to be recognized.
12. An intent recognition device, comprising: processor; as well as, a memory arranged to store computer executable instructions which, when executed, cause the processor to: Preprocessing the acquired data to be identified to obtain target data; Performing feature extraction processing on the target data based on the intention recognition model to obtain linear features and nonlinear features of the target data; The intent recognition model is a model obtained by optimizing the structure of the BERT model and training it, including an optimized BERT unit for extracting linear features and a nonlinear feature extraction unit, the optimized BERT unit includes a BertEmbedding layer, a BertEncoder layer, a first fully connected layer, a first normalization layer, a second normalization layer and a maximum pooling layer, and the nonlinear feature is obtained by performing nonlinear transformation processing on the linear features of the target data by the nonlinear feature extraction unit; Based on the intention recognition model, intention recognition processing is performed according to the linear features and the nonlinear features to obtain the intention recognition result of the data to be recognized.
13. A storage medium for storing computer executable instructions, wherein the computer executable instructions, when executed by a processor, implement the following process: Preprocessing the acquired data to be identified to obtain target data; Performing feature extraction processing on the target data based on the intention recognition model to obtain linear features and nonlinear features of the target data; The intent recognition model is a model obtained by optimizing the structure of the BERT model and training it, including an optimized BERT unit for extracting linear features and a nonlinear feature extraction unit, the optimized BERT unit includes a BertEmbedding layer, a BertEncoder layer, a first fully connected layer, a first normalization layer, a second normalization layer and a maximum pooling layer, and the nonlinear feature is obtained by performing nonlinear transformation processing on the linear features of the target data by the nonlinear feature extraction unit; Based on the intention recognition model, intention recognition processing is performed according to the linear features and the nonlinear features to obtain the intention recognition result of the data to be recognized.
