Classification and identification method, device, electronic device and computer-readable storage medium
By predicting and text vectorization of new categories data, combining the classification vectorization module and the cross-combination module, the problem that classification models in the existing technology cannot identify new categories in a timely manner, and the effect of being able to identify new categories in a timely manner without retraining the model.
Patent Information
- Application Number
- CN202111454458.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-01
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2041-12-01
AI Technical Summary
Classification models in the prior art cannot be identified in time when facing new category data because the model needs to be retrained. This process takes a long time, which makes it meaningless when the model is successfully trained after the event.
By predicting the new category data, a prediction vector is obtained; the text data to be identified is converted into a text vector, and the classification vector is determined through the classification vectorization module; a similar text vector group is determined based on the prediction vector and the preset classification vector; and then the target vector is determined based on the classification vector and the text vector group, and its classification information is output.
It is realized that the new category of text data to be identified without training the new category of data, so that the event is timely recognized when an event occurs, avoiding the impact of model training delay.
Smart Images

Figure CN113987137B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a classification and identification method, device, electronic device and computer-readable storage medium. Background Art
[0002] The classification model recognition in the existing technology can only recognize the category data in the training set. If the data is added, deleted or modified, the classification category data must be retrained to accurately recognize the new classification category data, but the training of the classification model takes several hours or even longer.
[0003] In specific applications, such as in intelligent customer service scenarios, due to certain system problems or special events, problems that have never been seen before suddenly appear. The current intent classification system cannot adapt to this situation. After the operation personnel discover it, they promptly add some new category annotation data, hoping to solve such problems. However, due to model training, there is a certain delay. If the event time is short, the model may be successfully trained after the event ends, which is not very meaningful at this time. Therefore, when the classification model in the existing technology is not trained again, it is impossible to identify new categories. Summary of the invention
[0004] The object of the present invention is to provide a classification recognition method, device, electronic device and readable storage medium, which can achieve the effect of recognizing new categories when the new categories are not trained.
[0005] In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0006] In a first aspect, an embodiment of the present application provides a classification recognition method, which is applied to a classification model, wherein the classification model includes a text vectorization module and a classification vectorization module, and the method includes:
[0007] Predict the new category data and obtain the prediction vector of the prediction result of each new category data;
[0008] Determining text data to be recognized;
[0009] Convert the text data to be recognized into text vectors through the text vectorization module;
[0010] Determine the classification vector of the text vector by the classification vectorization module;
[0011] Based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model, determining a preset number of first text vector groups similar to the classification vector;
[0012] Determine a target vector based on the classification vector and the first text vector group;
[0013] The classification information of the target vector is determined as the classification information of the text data to be recognized, and outputted.
[0014] In an optional implementation, the step of determining a preset number of first text vector groups similar to the classification vector based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model comprises:
[0015] Calculating the cosine value of the cosine angle between the classification vector and each preset classification vector and prediction vector in the classification model;
[0016] Sort the cosine values from large to small;
[0017] A preset number of preset classification vectors corresponding to the cosine angles in the front order are obtained as a first text vector group.
[0018] In an optional implementation, the step of determining a preset number of first text vector groups similar to the classification vector based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model comprises:
[0019] Based on the retrieval algorithm, calculating the similarity between the classification vector and each preset classification vector and each prediction vector in the classification model;
[0020] Sort the similarities from largest to smallest;
[0021] A preset number of preset classification vectors corresponding to the similarities in the previous order are obtained as a first text vector group.
[0022] In an optional implementation, the classification model further includes a cross-combination module, and the step of determining the target vector based on the classification vector and the first text vector group includes:
[0023] Using the first text vector group and the classification vector as inputs of the cross combination module;
[0024] Outputting multiple probability values through the cross-combination module;
[0025] Obtain the maximum probability value among multiple probability values;
[0026] A first text vector corresponding to the maximum probability value is determined as a target vector.
[0027] In an optional embodiment, the method further comprises:
[0028] Get a text sample set;
[0029] The classification model is trained based on the text sample set.
[0030] In an optional implementation, the step of training the classification model based on the text sample set includes:
[0031] Input each text data in the text sample set into a text vector conversion module and convert it into a second text vector;
[0032] Inputting each of the second text vectors into a classification vectorization module to obtain a predicted classification vector of each of the second text vectors;
[0033] Calculate the classification loss of each predicted classification vector and the labeled classification vector;
[0034] Calculate the contrast loss between each second text vector;
[0035] concatenate every two of the second text vectors into a plurality of third text vectors;
[0036] Calculating the matching loss of each of the third text vectors;
[0037] Based on the classification loss, contrast loss and matching loss, an updated classification model is obtained;
[0038] Return to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the classification loss, contrast loss, and matching loss converge.
[0039] In an optional implementation, the step of obtaining an updated classification model based on the classification loss, contrast loss, and matching loss includes:
[0040] Based on the classification loss, contrast loss and matching loss, a target loss is calculated;
[0041] The step of returning to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the classification loss, contrast loss and matching loss converge, includes:
[0042] Return to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the target loss converges.
[0043] In a second aspect, an embodiment of the present application provides a classification identification device, the device comprising: a determination module and a processing module;
[0044] The processing module is used to predict the new category data and obtain the prediction vector of the prediction result of each new category data;
[0045] The determination module is used to: determine the text data to be recognized;
[0046] The processing module is used to convert the text data to be recognized into a text vector through the text vectorization module;
[0047] Determine the classification vector of the text vector by the classification vectorization module;
[0048] Based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model, determining a preset number of first text vector groups similar to the classification vector;
[0049] Determine a target vector based on the classification vector and the first text vector group;
[0050] The classification information of the target vector is determined as the classification information of the text data to be recognized, and outputted.
[0051] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the classification and identification method when executing the computer program.
[0052] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the classification and identification method when executed by a processor.
[0053] This application has the following beneficial effects:
[0054] The present application predicts new category data to obtain prediction vectors of prediction results of each new category data; determines text data to be identified; converts the text data to be identified into text vectors through a text vectorization module; determines the classification vector of the text vector through a classification vectorization module; determines a preset number of first text vector groups similar to the classification vector based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model; determines a target vector based on the classification vector and the first text vector group; determines the classification information of the target vector as the classification information of the text data to be identified, and outputs it. When new category data appears, the new category of the text data to be identified can be identified without training the new category data. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0056] Figure 1 A block diagram of an electronic device provided by an embodiment of the present invention;
[0057] Figure 2 One of the flow charts of a classification and identification method provided by an embodiment of the present invention;
[0058] Figure 3 A second flowchart of a classification and identification method provided by an embodiment of the present invention;
[0059] Figure 4 A third flowchart of a classification and identification method provided by an embodiment of the present invention;
[0060] Figure 5 A fourth flowchart of a classification and identification method provided by an embodiment of the present invention;
[0061] Figure 6 A structural block diagram of a classification and identification device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0063] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0064] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0065] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, they are based on the orientation or position relationship shown in the accompanying drawings, or are the orientation or position relationship in which the product of the invention is usually placed when used. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0066] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.
[0067] In the description of this application, it should also be noted that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0068] After extensive research, the inventors found that classification models can only recognize category data in the training set. If data is added, deleted or modified, retraining is required to accurately recognize the new category data. However, training the classification model takes several hours or even longer, which results in the lack of timely recognition of new categories.
[0069] In view of the discovery of the above problems, the present embodiment provides a method for predicting new category data, obtaining prediction vectors of prediction results of each new category data; determining text data to be recognized; converting the text data to be recognized into text vectors through a text vectorization module; determining the classification vector of the text vector through a classification vectorization module; determining a preset number of first text vector groups similar to the classification vector based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model; determining a target vector based on the classification vector and the first text vector group; determining the classification information of the target vector as the classification information of the text data to be recognized, and outputting it. When new category data appears, the new category of the text data to be recognized can be recognized without training the new category data. The scheme provided by the present embodiment is described in detail below.
[0070] This embodiment provides an electronic device that can identify classification. In a possible implementation, the electronic device can be a user terminal, for example, the electronic device can be, but is not limited to, a server, a smart phone, a personal computer (PC), a tablet computer, a personal digital assistant (PDA), a mobile Internet device (MID, etc.).
[0071] Please refer to Figure 1 , Figure 1 1 is a schematic diagram of the structure of the electronic device 100 provided in the embodiment of the present application. The electronic device 100 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0072] The electronic device 100 includes a classification identification device 110 , a memory 120 and a processor 130 .
[0073] The components of the memory 120 and the processor 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The classification identification device 110 includes at least one software function module that can be stored in the memory 120 in the form of software or firmware or solidified in the operating system (OS) of the electronic device 100. The processor 130 is used to execute the executable modules stored in the memory 120, such as the software function modules and computer programs included in the classification identification device 110.
[0074] The memory 120 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 120 is used to store a program, and the processor 130 executes the program after receiving an execution instruction.
[0075] Please refer to Figure 2 , for application Figure 1 The flowchart of a classification and identification method of the electronic device 100 is shown in FIG. 1 , and each step of the method is described in detail below.
[0076] Step 201: predict the new category data to obtain a prediction vector of the prediction result of each new category data.
[0077] Step 202: Determine text data to be recognized.
[0078] Step 203: Convert the text data to be recognized into a text vector through a text vectorization module.
[0079] Step 204: Determine the classification vector of the text vector through the classification vectorization module.
[0080] Step 205: Based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model, determine a preset number of first text vector groups similar to the classification vector.
[0081] Step 206: Determine a target vector based on the classification vector and the first text vector group.
[0082] Step 207: Determine the classification information of the target vector as the classification information of the text data to be recognized, and output it.
[0083] The classification model is not trained with new category data. The classification model in this embodiment is a model trained based on original data, and the new category data is only predicted and labeled based on the classification model, and the classification model is not trained based on the new category data.
[0084] This embodiment not only predicts the new category data, but also the original data in the classification model needs to be predicted.
[0085] When the category of the text data to be identified does not belong to the category that the classification model can identify, it is necessary to predict the new category data. When the category of the text data to be identified belongs to the category that the classification model can identify, the category of the text data to be identified is determined directly based on the existing classification and recognition method.
[0086] Determine the text data to be recognized, where the text data to be recognized is text data that needs to be classified and predicted, and the classification of the text data to be recognized can be a classification that has been trained in the classification model, or can be a classification that has not been trained.
[0087] For example, if a text data to be identified is "How is the weather today?", the categories that can be predicted in the classification model include "Weather consultation category" and "Purchase consultation category". The classification model can directly output the category of the text data to be identified as "Weather consultation category". If the text data to be identified is "How to open a membership", the category of the text data to be identified is identified based on the above steps 202 to 207.
[0088] The text data to be recognized is first passed through the text vectorization module to convert the text data to be recognized into a text vector, that is, the text data to be recognized is converted into a language that can be recognized by the machine, that is, a text vector, and the text vector is input into the classification vectorization module to output the classification vector corresponding to the text vector.
[0089] Exemplarily, the classification model includes a text vectorization module and a classification vectorization module, and the classification model can only identify "weather consultation classification" and "purchase consultation classification". The text data to be identified is "how to open a membership". The text data to be identified is converted into a text vector through the text vectorization module, and the text vector is input into the classification vectorization module to obtain a classification vector (a, b), where the range of a is (0,1), the range of b is (0,1), and a and b correspond to the probability values of the classification of "weather consultation classification" and "purchase consultation classification", respectively.
[0090] Of course, when the classification model can identify N categories, the classification vector of the text data to be identified is (a, b, c, ...N).
[0091] Based on the classification vector of the text data to be identified, a first text vector group similar to the classification vector is determined from the prediction vector of each new category data and the preset classification vector of the original data in the classification model. The number of vectors in the first text vector group is a preset number, wherein the preset number can be 15, 31, etc., and the embodiment of the present invention does not impose any specific limitation on this.
[0092] Determining the first text vector group similar to the classification vector from the prediction vector of each new category data and the preset classification vector of the original data in the classification model is a rough sorting method for the text data to be identified. The classification vectors corresponding to the text data to be identified are retrieved from the constructed vector retrieval library to find a preset number of the most similar problems, that is, to retrieve a preset number of first text vector groups that are similar.
[0093] Then, from the determined first text vector group, the one with the highest similarity to the classification vector of the text data to be recognized is obtained as the classification information of the text data to be recognized.
[0094] The present application predicts new category data to obtain prediction vectors of prediction results of each new category data; determines text data to be identified; converts the text data to be identified into text vectors through a text vectorization module; determines the classification vector of the text vector through a classification vectorization module; determines a preset number of first text vector groups similar to the classification vector based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model; determines a target vector based on the classification vector and the first text vector group; determines the classification information of the target vector as the classification information of the text data to be identified, and outputs it. When new category data appears, the new category of the text data to be identified can be identified without training the new category data.
[0095] Regarding the method for obtaining the first text vector, regarding the above step 205, as Figure 3 FIG. 1 is a flow chart of a classification and identification method provided in an embodiment of the present application, which specifically includes the following steps:
[0096] Step 205 - 1 : Calculate the cosine value of the cosine angle between the classification vector and each preset classification vector and prediction vector in the classification model.
[0097] Step 205 - 2 : Sort the cosine values from large to small.
[0098] Step 205 - 3 : obtaining a preset number of pre-sorted cosine values corresponding to a plurality of preset classification vectors as a first text vector group.
[0099] The classification vector corresponding to the text data to be identified is respectively compared with the preset classification vector in the classification model and the prediction vector of the new category data, and the cosine value of the cosine angle is calculated. When the cosine value of the angle is close to 1, it indicates that the text data to be identified is similar to the text data corresponding to the preset classification vector, or that the text data to be identified is similar to the text data corresponding to the prediction vector of the new category data. When the cosine value of the angle is close to 0, it indicates that the similarity between the two text data is low.
[0100] Cosine similarity uses the cosine value of the angle between two vectors in the vector space as a measure of the difference between two text data. The closer the cosine value is to 1, the closer the angle is to 0 degrees, that is, the more similar the two vectors are, which is called "cosine similarity".
[0101] Based on the cosine value of the cosine angle between the classification vector and each preset classification vector and prediction vector in the classification model, the first text vector group can be accurately obtained.
[0102] Determining the first text vector group based on the cosine value makes the obtained first text vector group more accurate, but the calculation time is long. In order to shorten the calculation time, the first text vector can also be obtained in the following way: based on the retrieval algorithm, calculate the similarity between the classification vector and each preset classification vector and each prediction vector in the classification model; sort the similarities from large to small; obtain a preset number of similarities with the highest order corresponding to multiple preset classification vectors as the first text vector group.
[0103] Get the retrieval algorithm in faiss. Faiss is an open source library developed by the Facebook AI team. Its full name is Facebook AI Similarity Search. This open source library provides efficient and reliable similarity clustering and retrieval methods for massive data (dense vectors) in high-dimensional space. It can support searches of billions of vectors and is currently the most mature approximate neighbor search library.
[0104] In addition to using a retrieval algorithm to calculate the similarity between a classification vector and each preset classification vector and each prediction vector in a classification model, a Milvus algorithm may also be used to calculate the similarity between a classification vector and each preset classification vector and each prediction vector in a classification model.
[0105] The similarity of the vectors can be calculated by using a calculation method of vector similarity such as Euclidean distance, Manhattan distance, Pearson correlation coefficient, Spearman correlation coefficient, Jaccard correlation coefficient, etc., so as to obtain the first text vector group.
[0106] For the acquisition of the target vector, for the above step 206, as Figure 4 FIG. 1 is a flow chart of a classification and identification method provided in an embodiment of the present application, which specifically includes the following steps:
[0107] Step 206 - 1 : Use the first text vector group and the classification vector as inputs of the cross combination module.
[0108] Step 206 - 2 : Output multiple probability values through the cross-combination module.
[0109] Step 206 - 3 : Obtain the maximum probability value among multiple probability values.
[0110] Step 206 - 4 : Determine the first text vector corresponding to the maximum probability value as the target vector.
[0111] Each first text vector in the first text vector group is spliced with the classification vector of the text data to be recognized, and the spliced vector group is used as the input of the cross-combination module. The cross-combination module outputs the probability value of each spliced vector, which is the probability that the text data corresponding to the first text vector is similar to the classification of the text data to be recognized. The maximum probability value among the multiple probability values is obtained. The first text vector corresponding to the maximum probability value is determined as the target vector.
[0112] It should be noted that the cross-combination module is a fully connected layer neural network, wherein the fully connected layer neural network can be an FNN feedforward neural network, a convolutional neural network, a recurrent neural network, etc., and the embodiment of the present invention does not impose specific restrictions on this.
[0113] This embodiment is to find the most similar question category from the TOPN questions. Here, the classification vector of the text data to be identified and the TOPN data, i.e., the first text vector group, are combined into a batch of data input models. According to the cross-combination module, i.e., the fully connected layer neural network, the most similar question output is found from the output results.
[0114] like Figure 5 FIG. 1 is a flow chart of a classification and identification method provided in an embodiment of the present application, which specifically includes the following steps:
[0115] Step 301: Obtain a text sample set.
[0116] Step 302: training the classification model based on the text sample set.
[0117] The specific training process is as follows: input each text data in the text sample set into the text vector conversion module to be converted into a second text vector; input each second text vector into the classification vectorization module to obtain a predicted classification vector of each second text vector; calculate the classification loss of each predicted classification vector and the labeled classification vector; calculate the contrast loss between each second text vector; concatenate every two second text vectors into multiple third text vectors; calculate the matching loss of each third text vector; based on the classification loss, contrast loss and matching loss, obtain an updated classification model; return to execute the steps of calculating the classification loss of each predicted classification vector and the labeled classification vector to calculating the matching loss of each third text vector, until the classification loss, contrast loss and matching loss converge.
[0118] Exemplarily, a batch of data is input each time the model is trained, and the number is 3 for example, corresponding to q1 text data, q2 text data, and q3 text data input.
[0119] The same text vectorization processing method is used for each text data, and the corresponding text vectors qv1, qv2, qv3 are output. This vectorization module can use Bert's vectorization tool BertTokenizer, qv1 is cls, t1, t2..., and other text vectors are processed similarly.
[0120] All the above text vectors are passed through the same classification vectorization module twice, and two groups of classification vector outputs a and b are output. Group a outputs three vectors qo1a, qo2a, and qo3a. qo1a contains the values pc1 and pc2 corresponding to each category. Softmax+Cross Entropy is used to calculate the classification loss of each classification vector and the labeled classification vector.
[0121] q1 text data, q2 text data, q3 text data, 9 3*3 sample pairs, calculate the classification vector of q1 text data, the classification vector of q2 text data, the classification vector of q3 text data respectively, and use contrastive loss or infoNCE loss to obtain the contrast loss between the second text vectors.
[0122] Each two second text vectors are concatenated into multiple third text vectors; the matching loss of each third text vector is calculated, and the matching loss is calculated using Sigmod+BCELoss.
[0123] Another way to train the classification model is: based on the classification loss, contrast loss and matching loss, calculate the target loss; return to execute the steps of calculating the classification loss of each predicted classification vector and the labeled classification vector to calculating the matching loss of each third text vector until the target loss converges.
[0124] The target loss can be obtained by weighted summing the classification loss, contrast loss and matching loss.
[0125] Please refer to Figure 6 The present application embodiment also provides a method for applying Figure 1 The classification identification device 110 of the electronic device 100 includes:
[0126] A determination module 111 and a processing module 112;
[0127] The processing module 112 is used to predict the new category data and obtain the prediction vector of the prediction result of each new category data;
[0128] The determination module 111 is used to: determine the text data to be recognized;
[0129] The processing module 112 is used to convert the text data to be recognized into a text vector through the text vectorization module;
[0130] Determine the classification vector of the text vector by the classification vectorization module;
[0131] Based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model, determining a preset number of first text vector groups similar to the classification vector;
[0132] Determine a target vector based on the classification vector and the first text vector group;
[0133] The classification information of the target vector is determined as the classification information of the text data to be recognized, and outputted.
[0134] Optionally, the processing module 112 is further configured to:
[0135] Calculating the cosine value of the cosine angle between the classification vector and each preset classification vector and prediction vector in the classification model;
[0136] Sort the cosine values from large to small;
[0137] A preset number of pre-sorted cosine values corresponding to a plurality of preset classification vectors are obtained as a first text vector group.
[0138] Optionally, the processing module 112 is further configured to:
[0139] Based on the retrieval algorithm, calculating the similarity between the classification vector and each preset classification vector and each prediction vector in the classification model;
[0140] Sort the similarities from largest to smallest;
[0141] A preset number of preset classification vectors corresponding to the similarities in the previous order are obtained as a first text vector group.
[0142] Optionally, the processing module 112 is further configured to:
[0143] Using the first text vector group and the classification vector as inputs of the cross combination module;
[0144] Outputting multiple probability values through the cross-combination module;
[0145] Obtain the maximum probability value among multiple probability values;
[0146] A first text vector corresponding to the maximum probability value is determined as a target vector.
[0147] Optionally, the processing module 112 is further configured to:
[0148] Get a text sample set;
[0149] The classification model is trained based on the text sample set.
[0150] Optionally, the processing module 112 is further configured to:
[0151] Input each text data in the text sample set into a text vector conversion module and convert it into a second text vector;
[0152] Inputting each of the second text vectors into a classification vectorization module to obtain a predicted classification vector of each of the second text vectors;
[0153] Calculate the classification loss of each predicted classification vector and the labeled classification vector;
[0154] Calculate the contrast loss between each second text vector;
[0155] concatenate every two of the second text vectors into a plurality of third text vectors;
[0156] Calculating the matching loss of each of the third text vectors;
[0157] Based on the classification loss, contrast loss and matching loss, an updated classification model is obtained;
[0158] Return to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the classification loss, contrast loss, and matching loss converge.
[0159] Optionally, the processing module 112 is further configured to:
[0160] Based on the classification loss, contrast loss and matching loss, a target loss is calculated;
[0161] The step of returning to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the classification loss, contrast loss and matching loss converge, includes:
[0162] Return to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the target loss converges.
[0163] In summary, the present application predicts new category data to obtain prediction vectors of prediction results of each new category data; determines text data to be identified; converts the text data to be identified into text vectors through a text vectorization module; determines the classification vector of the text vector through a classification vectorization module; determines a preset number of first text vector groups similar to the classification vector based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model; determines a target vector based on the classification vector and the first text vector group; determines the classification information of the target vector as the classification information of the text data to be identified, and outputs it. When new category data appears, the new category of the text data to be identified can be identified without training the new category data.
[0164] The present application also provides an electronic device 100, which includes a processor 130 and a memory 120. The memory 120 stores computer executable instructions, and when the computer executable instructions are executed by the processor 130, the classification and recognition method is implemented.
[0165] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by the processor 130, the classification and identification method is implemented.
[0166] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0167] In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk.
[0168] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article 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, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0169] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A classification recognition method is applied to a classification model, wherein the classification model includes a text vectorization module and a classification vectorization module, characterized in that: The method comprises: Predict the new category data and obtain the prediction vector of the prediction result of each new category data; Determining text data to be recognized; Convert the text data to be recognized into text vectors through the text vectorization module; Determine the classification vector of the text vector by the classification vectorization module; Based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model, determining a preset number of first text vector groups similar to the classification vector; Determine a target vector based on the classification vector and the first text vector group; Determine the classification information of the target vector as the classification information of the text data to be recognized, and output it; The method further comprises: Get a text sample set; Training the classification model based on the text sample set; The step of training the classification model based on the text sample set includes: Input each text data in the text sample set into a text vector conversion module and convert it into a second text vector; Inputting each of the second text vectors into a classification vectorization module to obtain a predicted classification vector of each of the second text vectors; Calculate the classification loss of each predicted classification vector and the labeled classification vector; Calculate the contrast loss between each second text vector; concatenate every two of the second text vectors into a plurality of third text vectors; Calculating the matching loss of each of the third text vectors; Based on the classification loss, contrast loss and matching loss, an updated classification model is obtained; Return to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the classification loss, contrast loss, and matching loss converge.
2. The method according to claim 1, characterized in that The step of determining a preset number of first text vector groups similar to the classification vector based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model comprises: Calculating the cosine value of the cosine angle between the classification vector and each preset classification vector and prediction vector in the classification model; Sort the cosine values from large to small; A preset number of pre-sorted cosine values corresponding to a plurality of preset classification vectors are obtained as a first text vector group.
3. The method according to claim 1, characterized in that: The step of determining a preset number of first text vector groups similar to the classification vector based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model comprises: Based on the retrieval algorithm, calculating the similarity between the classification vector and each preset classification vector and each prediction vector in the classification model; Sort the similarities from largest to smallest; A preset number of preset classification vectors corresponding to the similarities in the previous order are obtained as a first text vector group.
4. The method according to claim 1, characterized in that: The classification model further includes a cross-combination module, and the step of determining a target vector based on the classification vector and the first text vector group includes: Using the first text vector group and the classification vector as inputs of the cross combination module; Outputting multiple probability values through the cross-combination module; Obtain the maximum probability value among multiple probability values; A first text vector corresponding to the maximum probability value is determined as a target vector.
5. The method according to claim 1, characterized in that The step of obtaining an updated classification model based on the classification loss, contrast loss and matching loss comprises: Based on the classification loss, contrast loss and matching loss, a target loss is calculated; The step of returning to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the classification loss, contrast loss and matching loss converge, includes: Return to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the target loss converges.
6. A classification and recognition device, characterized in that: Applied to a classification model, the classification model includes a text vectorization module and a classification vectorization module, and the device includes: a determination module and a processing module; The processing module is used to predict the new category data and obtain the prediction vector of the prediction result of each new category data; The determination module is used to: determine the text data to be recognized; The processing module is used to convert the text data to be recognized into a text vector through a text vectorization module; Determine the classification vector of the text vector through a classification vectorization module; Based on the prediction vector of each new category data and the preset classification vector of the original data in the classification model, determining a preset number of first text vector groups similar to the classification vector; Determine a target vector based on the classification vector and the first text vector group; Determine the classification information of the target vector as the classification information of the text data to be recognized, and output it; The processing module is also used for: Get a text sample set; Input each text data in the text sample set into a text vector conversion module and convert it into a second text vector; Inputting each of the second text vectors into a classification vectorization module to obtain a predicted classification vector of each of the second text vectors; Calculate the classification loss of each predicted classification vector and the labeled classification vector; Calculate the contrast loss between each second text vector; concatenate every two of the second text vectors into a plurality of third text vectors; Calculating the matching loss of each of the third text vectors; Based on the classification loss, contrast loss and matching loss, an updated classification model is obtained; Return to the step of calculating the classification loss of each predicted classification vector and the labeled classification vector to the step of calculating the matching loss of each third text vector until the classification loss, contrast loss, and matching loss converge.
7. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Task-type intent classification method and device
CN108334891A
Intention identification method and device based on text classification, equipment and storage medium
CN110147445A