Training method of certificate classification model, certificate classification method, device and medium
By preset data enhancement algorithm sets and sequential dynamic processing of document samples, combined with convolutional neural networks and attention layers, the problem of poor accuracy of document classification models in small data volume scenarios is solved, and efficient document classification is achieved.
Patent Information
- Application Number
- CN202111521244.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-13
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-12-13
AI Technical Summary
Existing electronic document data enhancement processing methods are difficult to effectively improve the classification accuracy of machine learning models in scenarios with small data volumes.
By presetting a variety of data enhancement algorithm sets and their order of use, the appropriate data enhancement algorithm is dynamically determined to process the document samples, generating diverse target samples, and using the convolutional neural network and Attention layer to extract features to train the document classification model .
It improves the classification accuracy and diversity of the document classification model in small data volume scenarios, and can effectively distinguish different types of documents.
Smart Images

Figure CN114202673B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a document classification model training method, a document classification method, a device and a computer-readable storage medium. Background Art
[0002] As the number of user certificates increases, the demand for electronic certificate classification by the government or enterprises is also increasing. In the electronic certificate classification scenario, some related technologies use machine learning models for classification, but the inventors have found that before using electronic certificate samples to train machine learning models, the electronic certificate samples need to be data enhanced, but the existing data enhancement processing method is only applicable to scenarios with large amounts of electronic certificate sample data; however, in some special scenarios, the amount of electronic certificate sample data is small, or it is impossible to obtain electronic certificate samples with large amounts of data. If the existing data enhancement processing method is continued to be used to perform data enhancement processing on these small amounts of electronic certificate samples, the final machine learning model classification accuracy will be poor. Summary of the invention
[0003] The purpose of the present invention is to provide a training method for a certificate classification model, a certificate classification method, a device and a computer-readable storage medium, which can solve the above-mentioned technical problems.
[0004] One aspect of the present invention provides a method for training a document classification model, the method comprising: obtaining a document sample set and extracting a document sample from the document sample set; obtaining a preset set of N data enhancement algorithms and an order of use of the N data enhancement algorithm sets; determining a data enhancement algorithm set from the N data enhancement algorithm sets according to the order of use for performing data enhancement processing on the document sample, and performing data enhancement processing on the document sample according to the determined data enhancement algorithm set to obtain a target document sample; and training a document classification model for document classification based on multiple target document samples.
[0005] Optionally, each data enhancement algorithm set is associated with a label range, and the data enhancement algorithm set used to perform data enhancement processing on the document sample is determined from the N data enhancement algorithm sets in the order of use, and the document sample is subjected to data enhancement processing according to the determined data enhancement algorithm set to obtain a target document sample, including: step A1, generating a label value for the document sample, and determining whether the label value is within the label range associated with the first data enhancement algorithm set, if so, executing step A2, and otherwise executing step A3; step A2, performing data enhancement processing on the document sample according to the first data enhancement algorithm set, and executing step A3; step A3, generating a label value for the document sample again, and determining whether the label value is within the label range associated with the i+1th data enhancement algorithm set. If the ID sample is within the range of labels associated with the algorithm set, then execute step A4; if not, execute step A5, wherein i is a positive integer with an initial value of 1; step A4, if the first i data enhancement algorithm sets have performed data enhancement processing on the ID sample, then continue to perform data enhancement processing on the ID sample after the last data enhancement processing according to the i+1th data enhancement algorithm set, and execute step A5; if the first i data enhancement algorithm sets have not performed data enhancement processing on the ID sample, then perform data enhancement processing on the ID sample according to the i+1th data enhancement algorithm set, and execute step A5; step A5, determine whether i+1 is equal to N, if so, record the ID sample after the last data enhancement processing as the target ID sample, if not, assign i to i+1 and return to execute step A3.
[0006] Optionally, generating the label value of the certificate sample includes: determining a maximum label boundary value from all label ranges; and randomly generating a value in the range of [0, the maximum label boundary value] as the label value of the certificate sample.
[0007] Optionally, the training of a document classification model for document classification based on multiple target document samples includes: extracting features of the target document samples through m convolutional layers of a convolutional neural network to obtain m first feature vectors, where m is a positive integer greater than or equal to 2; setting weights for feature elements in the first feature vector output by the mth convolutional layer through the Attention layer of the convolutional neural network to obtain the m'th first feature vector; calculating the classification value of the target document sample based on the m'th first feature vector; extracting the classification values of the multiple target document samples from the document sample set, and training the document classification model based on the classification values of the multiple target document samples in the document sample set and the calculated classification values of the corresponding target document samples.
[0008] Optionally, calculating the classification value of the target document sample based on the m'th first feature vector includes: filtering out p first feature vectors from the first feature vectors output by the first m-1 convolutional layers; calculating the classification value of the target document sample based on the p first feature vectors and the m'th first feature vector; wherein p is a positive integer greater than or equal to 1 and less than or equal to m.
[0009] Another aspect of the present invention provides a document classification method, the method comprising: obtaining a document to be classified; extracting features of the document to be classified through m convolutional layers of a document classification model to obtain m second feature vectors, wherein m is a positive integer greater than or equal to 2, and the document classification model is obtained through the training method of the document classification model described in any of the above embodiments; setting weights for feature elements in the second feature vector output by the mth convolutional layer through the Attention layer of the document classification model to obtain an m'th second feature vector; calculating the classification value of the document to be classified based on the m'th second feature vector; filtering out the largest classification value from all calculated classification values, and using the document category pointed to by the largest classification value as the document category to which the document to be classified belongs.
[0010] Optionally, calculating the classification value of the document to be classified based on the m'th second eigenvector includes: screening out p second eigenvectors from the second eigenvectors output by the first m-1 convolutional layers; calculating the classification value of the document sample to be classified based on the p second eigenvectors and the m'th second eigenvector; wherein p is a positive integer greater than or equal to 1 and less than or equal to m.
[0011] Another aspect of the present invention provides a training device for a document classification model, the device comprising: a sample acquisition module, used to acquire a document sample set and extract a document sample from the document sample set; a data set acquisition module, used to acquire a preset N data enhancement algorithm set and the usage order of the N data enhancement algorithm sets; an enhancement processing module, used to determine a data enhancement algorithm set for performing data enhancement processing on the document sample from the N data enhancement algorithm sets according to the usage order, and perform data enhancement processing on the document sample according to the determined data enhancement algorithm set to obtain a target document sample; and a model training module, used to train a document classification model for document classification based on multiple target document samples.
[0012] Another aspect of the present invention provides a document classification device, which includes: a document acquisition module for acquiring documents to be classified; a feature extraction module for extracting features of the document to be classified through m convolutional layers of a document classification model to obtain m second feature vectors, wherein m is a positive integer greater than or equal to 2, and the document classification model is obtained by the described method; a weight setting module for setting weights for feature elements in the second feature vector output by the mth convolutional layer through the Attention layer of the document classification model to obtain the m'th second feature vector; a classification value calculation module for calculating the classification value of the document to be classified based on the m'th second feature vector; and a document classification module for screening out the largest classification value from all calculated classification values, and using the document category pointed to by the largest classification value as the document category to which the document to be classified belongs.
[0013] Yet another aspect of the present invention provides a computer device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the training method for the certificate classification model described in any of the above embodiments and / or the certificate classification method described in any of the above embodiments.
[0014] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the training method of the certificate classification model described in any of the above embodiments and / or the certificate classification method described in any of the above embodiments. Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of blockchain nodes, etc.
[0015] The present invention provides a training method for a certificate classification model, which pre-divides N data enhancement algorithm sets and sets the order of use of the data enhancement algorithm sets, then determines the data enhancement algorithm set used for performing data enhancement processing on the certificate sample from the N data enhancement algorithm sets according to the order of use, and performs data enhancement processing on the certificate sample according to each determined data enhancement algorithm set to obtain a target certificate sample, and performs the above-mentioned data enhancement operation on multiple certificate samples so that the target certificate sample finally obtained has complex and diverse features, so that when the certificate classification model is trained according to these target certificate samples, different categories of features can be obtained according to a small amount of data, so that the certificate classification model can efficiently and accurately distinguish different certificates. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0017] Figure 1 A flow chart of a method for training a certificate classification model provided in the first embodiment of the present invention is shown;
[0018] Figure 2 A flow chart of a method for classifying certificates provided in Embodiment 2 of the present invention is shown;
[0019] Figure 3 A block diagram of a training device for a certificate classification model provided in a third embodiment of the present invention is shown;
[0020] Figure 4 A block diagram of a document classification device provided in a fourth embodiment of the present invention is shown;
[0021] Figure 5 A block diagram of a computer device suitable for implementing a training method for a certificate classification model and / or a certificate classification method provided in a fifth embodiment of the present invention is shown; DETAILED DESCRIPTION
[0022] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0023] It should be noted that, in this article, the terms "include", "comprises" or any other variations 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, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0024] Embodiment 1
[0025] The present invention provides a training method for a certificate classification model, which pre-divides N data enhancement algorithm sets and sets the order of use of these data enhancement algorithm sets, then determines the data enhancement algorithm set used for data enhancement processing of the certificate sample from the N data enhancement algorithm sets according to the order of use, and performs data enhancement processing on the certificate sample according to each determined data enhancement algorithm set to obtain a target certificate sample, and performs the above data enhancement operation on multiple certificate samples so that the target certificate sample finally obtained has complex and diverse features, so that when training the certificate classification model based on these target certificate samples, different categories of features can be obtained based on a small amount of data, so that the certificate classification model can efficiently and accurately distinguish different certificates. Specifically, Figure 1 As shown, Figure 1 The flowchart of the training method of the certificate classification model provided in the first embodiment of the present invention is shown. The method comprises steps S1 to S4, wherein:
[0026] Step S1, obtaining a document sample set, and extracting a document sample from the document sample set.
[0027] The certificate sample set includes multiple certificate samples and a classification value of each certificate sample, wherein the multiple certificate samples belong to multiple categories (such as driver's license category, identity card category, social security card category, work card category, etc.), and the classification value of each certificate sample is used to characterize the category to which the certificate sample belongs. In this embodiment, when data enhancement processing is performed on the certificate samples in the certificate sample set, the data enhancement processing logic of each certificate sample can be implemented through steps S1 to S3.
[0028] As an optional embodiment, the database contains multiple candidate certificate samples, which belong to different categories, and in some scenarios, the data volume of candidate certificate samples in each category varies greatly. When obtaining a certificate sample set from the database, it is preferred to obtain the same or similar number of candidate certificate samples from the candidate certificate samples of each category, so that the obtained candidate certificate samples are used as a certificate sample set, and each candidate certificate sample obtained can be recorded as a certificate sample in the certificate sample set. Specifically, when the number of candidate certificate samples in some or all categories differs greatly, the proportion of candidate certificate samples in each category to all candidate certificate samples can be counted first, and then weights can be set for corresponding categories according to the proportions, so that when sampling from candidate certificate samples in each category according to the weights, the number of samples in each category can be made consistent as much as possible, so that the final certificate classification model is not overly biased towards the characteristics of a certain category.
[0029] Step S2, obtaining a preset set of N data enhancement algorithms and the order in which the N data enhancement algorithms are used.
[0030] Arranged in order of use, these N data enhancement algorithm sets may include: a hue type data enhancement algorithm set, an angle type data enhancement algorithm set, and a noise type data enhancement algorithm set, wherein the hue type data enhancement algorithm set includes data enhancement algorithms such as brightness, chroma, contrast, sharpness, etc., the angle type data enhancement algorithm set may include data enhancement algorithms such as 90 degree rotation, 180 degree rotation, 360 rotation, horizontal rotation, and vertical rotation, and the noise type data enhancement algorithm set may include data enhancement algorithms such as Gaussian blur, motion blur, Gaussian noise, shadow noise, stain noise, aperture noise, etc.
[0031] Step S3, determining a data enhancement algorithm set for performing data enhancement processing on the document sample from the N data enhancement algorithm sets in the usage order, and performing data enhancement processing on the document sample according to the determined data enhancement algorithm set to obtain a target document sample.
[0032] For each certificate sample, you can select all data enhancement algorithm sets to perform data enhancement processing on the certificate sample, or you can select some data enhancement algorithm sets to perform data enhancement processing on the certificate sample. Regardless of which method is used, the corresponding data enhancement algorithm sets need to be applied to the certificate sample in the order of use, and the certificate sample that has completed the data enhancement processing for the last time will be recorded as the target certificate sample.
[0033] For example, the data enhancement algorithm set used to perform data enhancement processing on the document sample is: a data enhancement algorithm set of hue type and an angle type. It is necessary to first use the data enhancement algorithm set of hue type to perform data enhancement processing on the document sample, and then use the data enhancement algorithm set of angle type to continue to perform data enhancement processing on the document sample. The target document sample obtained is: the result obtained after data enhancement processing on the document sample using the data enhancement algorithm set of hue type and angle type.
[0034] As an optional embodiment, step S3 includes steps A1 to A5, wherein:
[0035] Step A1, generating a label value of the document sample, and determining whether the label value is within the label range associated with the first data enhancement algorithm set, if yes, executing step A2, otherwise executing step A3;
[0036] Step A2, performing data enhancement processing on the document sample according to the first data enhancement algorithm set, and executing step A3;
[0037] Step A3, regenerate the label value of the certificate sample, and determine whether the label value is within the label range associated with the i+1th data enhancement algorithm set. If yes, execute step A4; otherwise, execute step A5, wherein i is a positive integer with an initial value of 1;
[0038] Step A4: if the first i data enhancement algorithm sets have performed data enhancement processing on the document sample, then the i+1th data enhancement algorithm set is used to continue to perform data enhancement processing on the document sample after the last data enhancement processing, and step A5 is executed; if the first i data enhancement algorithm sets have not performed data enhancement processing on the document sample, then the i+1th data enhancement algorithm set is used to perform data enhancement processing on the document sample, and step A5 is executed;
[0039] Step A5, determine whether i+1 is equal to N. If so, record the document sample after the last data enhancement processing as the target document sample. If not, assign i to i+1 and return to step A3.
[0040] For example, the label range associated with the first data enhancement algorithm set (such as the hue type data enhancement algorithm set) is [0, 0.3], the label range associated with the second data enhancement algorithm set (such as the angle type data enhancement algorithm set) is [0, 0.2], and the label range associated with the third data enhancement algorithm set (such as the noise type data enhancement algorithm set) is [0, 0.1]. A label value is generated. If the label value is 0.1, the first data enhancement algorithm set is used to perform data enhancement processing on the document sample; a label value is generated again. If the label value is 0.1, the first data enhancement algorithm set is used to perform data enhancement processing on the document sample; a label value is generated again. If the value is 0.25, the second data enhancement algorithm set is not used to perform data enhancement processing on the document sample; a label value is generated again. If the label value is 0.05, the third data enhancement algorithm set is used to continue data enhancement processing on the document sample after the last data enhancement processing, that is, the result of data enhancement processing on the document sample using the first data enhancement algorithm set is obtained, and the third data enhancement algorithm set is used again to perform data enhancement processing on the result, and a result is obtained again, and this result is used as the target document sample.
[0041] The data enhancement processing logic of this embodiment can effectively increase the diversity of target certificate samples, and has the effect of increasing the diversity and complexity of the training set of the certificate classification model, especially the training set with a small number, so that the certificate classification model finally trained can accurately identify various certificates.
[0042] As an optional embodiment, the step of generating the label value of the certificate sample in step A1 and step A3 includes:
[0043] Determine a maximum label boundary value from all label ranges;
[0044] A value in the range of [0, the maximum label boundary value] is randomly generated as the label value of the certificate sample.
[0045] Each time the label value of the document sample is generated, a value in the range of [0, the maximum label boundary value] can be generated by a random function, and then the value is used as the label value. For example, in combination with the above example, it can be known that the maximum label boundary value is 0.3, and a random number between [0, 0.3] can be generated by a random function as the label value of the document sample.
[0046] As an optional embodiment:
[0047] Step A2 includes: randomly selecting a data enhancement algorithm from the first data enhancement algorithm set, performing data enhancement processing on the document sample according to the data enhancement algorithm, and executing step A3;
[0048] Step A4 includes: if the first i data enhancement algorithm sets have performed data enhancement processing on the certificate sample, then randomly selecting a data enhancement algorithm from the i+1th data enhancement algorithm set, continuing to perform data enhancement processing on the certificate sample after the last data enhancement processing according to the data enhancement algorithm, and executing step A5; if the first i data enhancement algorithm sets have not performed data enhancement processing on the certificate sample, then randomly selecting a data enhancement algorithm from the i+1th data enhancement algorithm set, performing data enhancement processing on the certificate sample according to the data enhancement algorithm, and executing step A5.
[0049] Step S4, training a document classification model for document classification based on multiple target document samples.
[0050] In this embodiment, steps S1 to S4 can be performed on multiple certificate samples in the certificate sample set to obtain target certificate samples corresponding to each certificate sample in the multiple certificate samples, and then the learning model is trained based on the obtained target certificate samples to train a certificate classification model. The learning model can be a convolutional neural network, a decision tree, a random forest, etc.
[0051] As an optional embodiment:
[0052] Step S4 includes steps B1 to B4, wherein:
[0053] Step B1, extracting features of the target document sample through m convolutional layers of a convolutional neural network to obtain m first feature vectors, where m is a positive integer greater than or equal to 2;
[0054] Step B2, setting weights for feature elements in the first feature vector output by the mth convolutional layer through the Attention layer of the convolutional neural network, to obtain the m'th first feature vector;
[0055] Step B3, calculating the classification value of the target document sample according to the m'th first feature vector;
[0056] Step B4: extracting the classification values of the multiple target certificate samples from the certificate sample set, and training the certificate classification model according to the classification values of the multiple target certificate samples in the certificate sample set and the calculated classification values of the corresponding target certificate samples.
[0057] Among them, in the process of training the model, the feature vector output by each convolution layer is called the first feature vector. This embodiment adds an Attention layer on the basis of the existing convolutional neural network. The Attention layer is used to assign weights to the first feature vector output by the last convolution layer. The specific assignment size can be obtained through learning. The newly added Attention layer makes the trained document classification model pay more attention to the differences between different background features. The feature vectors output by the Attention layer and the last convolution layer are learned and fused, and different weights are assigned to different features, so that the confidence score of the final document classification model is higher.
[0058] As an optional embodiment, step B3 includes:
[0059] Filter out p first eigenvectors from the first eigenvectors output by the first m-1 convolutional layers;
[0060] Calculating the classification value of the target document sample according to the p first feature vectors and the m'th first feature vector;
[0061] Here, p is a positive integer greater than or equal to 1 and less than or equal to m.
[0062] The classification value of the target document sample is calculated according to the p first feature vectors and the m'th first feature vector as follows: the p first feature vectors and the m'th first feature vector are fused with the same features by bilinear interpolation, and then the classification value is calculated according to the fusion result.
[0063] Compared with the prior art that only uses the last layer of feature vectors to calculate the classification value, this embodiment also takes feature fusion into consideration. By fusing the shallow feature vectors (i.e., the p first feature vectors) and the deep feature vectors of the last layer (i.e., the m'th first feature vector) and then calculating the classification value, the document classification model not only pays attention to the features of large areas, but also pays attention to the differences in small details. Therefore, when the document classification model is inferred, it can better distinguish between different categories of documents.
[0064] Embodiment 2
[0065] Figure 2 FIG. 1 is a flow chart showing a method for classifying certificates provided in Embodiment 2 of the present invention. Figure 2 As shown, the method includes steps M1 to M5, wherein:
[0066] Step M1, obtaining the certificate to be classified.
[0067] The document to be classified can be an electronic document obtained by directly taking a photo, or the electronic document obtained by taking a photo can be used as a document sample and then executed as a target document sample obtained through steps S1 to S3, or it can be obtained by performing data enhancement processing on the electronic document obtained by taking a photo through an existing data enhancement method.
[0068] Step M2, extracting the features of the document to be classified through m convolutional layers of the document classification model to obtain m second feature vectors, wherein m is a positive integer greater than or equal to 2, and the document classification model is obtained by the method described in Example 1.
[0069] In the process of document classification, the feature vector output by each convolutional layer is called the second feature vector.
[0070] Step M3: weight the feature elements in the second feature vector output by the mth convolutional layer through the Attention layer of the document classification model to obtain the m'th second feature vector.
[0071] This embodiment adds an Attention layer on the basis of the existing convolutional neural network. The Attention layer is used to assign weights to the first feature vector output by the last convolutional layer. The specific value can be obtained through learning. The newly added Attention layer makes the trained document classification model pay more attention to the difference between different background features. The feature vectors output by the Attention layer and the last convolutional layer are learned and fused, and different weights are assigned to different features, so that the confidence score of the final document classification model is higher.
[0072] Step M4, calculating the classification value of the document to be classified according to the m'th second feature vector.
[0073] Solution 1: directly calculate the classification value of the document to be classified through the m'th second eigenvector.
[0074] Solution 2, step M4 includes:
[0075] Filter out p second eigenvectors from the second eigenvectors output by the first m-1 convolutional layers;
[0076] Calculating the classification value of the document sample to be classified according to the p second feature vectors and the m'th second feature vector;
[0077] Here, p is a positive integer greater than or equal to 1 and less than or equal to m.
[0078] The classification value of the document sample to be classified is calculated according to the p second feature vectors and the m'th second feature vector: the p second feature vectors and the m'th second feature vector are fused with the same features by bilinear interpolation, and then the classification value is calculated according to the fusion result.
[0079] Compared with the prior art that only uses the last layer of feature vectors to calculate the classification value, this embodiment also takes feature fusion into consideration. By fusing the shallow feature vectors (i.e., the p second feature vectors) and the deep feature vectors of the last layer (i.e., the m'th second feature vector) and then calculating the classification value, the document classification model not only pays attention to the features of large areas, but also pays attention to the differences in small details. Therefore, when the document classification model is inferred, it can better distinguish between different categories of documents.
[0080] Step M5, screening out the largest classification value from all the calculated classification values, and taking the document category pointed to by the largest classification value as the document category to which the document to be classified belongs.
[0081] The number of calculated classification values is the same as the number of pre-set document categories. The larger the calculated classification value is, the greater the probability that the document to be classified belongs to the document category associated with the classification value is.
[0082] Embodiment 3
[0083] Embodiment 3 of the present invention further provides a training device for a certificate classification model, which corresponds to the training method for a certificate classification model provided in the above embodiment 1. The corresponding technical features and technical effects are not described in detail in this embodiment, and the relevant parts can refer to the above embodiment 1. Specifically, Figure 3 FIG. 4 is a block diagram of a training device for a certificate classification model provided in Embodiment 3 of the present invention. Figure 3As shown, the training device 300 for the certificate classification model includes a sample acquisition module 301, a data set acquisition module 302, an enhancement processing module 303 and a model training module 304, wherein:
[0084] The sample acquisition module 301 is used to acquire a document sample set and extract a document sample from the document sample set;
[0085] A data set acquisition module 302 is used to acquire a preset set of N data enhancement algorithms and the order in which the N data enhancement algorithms are used;
[0086] An enhancement processing module 303 is used to determine a data enhancement algorithm set for performing data enhancement processing on the document sample from the N data enhancement algorithm sets in the usage order, and perform data enhancement processing on the document sample according to the determined data enhancement algorithm set to obtain a target document sample;
[0087] The model training module 304 is used to train a document classification model for document classification based on multiple target document samples.
[0088] Optionally, each data enhancement algorithm set is associated with a label range, and the enhancement processing module is specifically used for: step A1, generating a label value for the certificate sample, judging whether the label value is within the label range associated with the first data enhancement algorithm set, if so, executing step A2, if not, executing step A3; step A2, performing data enhancement processing on the certificate sample according to the first data enhancement algorithm set, and executing step A3; step A3, generating the label value of the certificate sample again, judging whether the label value is within the label range associated with the i+1th data enhancement algorithm set, if so, executing step A4, if not, executing step A5, wherein i is an initial value of 1 positive integer; Step A4, if the first i data enhancement algorithm sets have performed data enhancement processing on the document sample, then continue to perform data enhancement processing on the document sample after the last data enhancement processing according to the i+1th data enhancement algorithm set, and execute step A5; if the first i data enhancement algorithm sets have not performed data enhancement processing on the document sample, then perform data enhancement processing on the document sample according to the i+1th data enhancement algorithm set, and execute step A5; Step A5, determine whether i+1 is equal to N, if so, record the document sample after the last data enhancement processing as the target document sample, if not, assign i to i+1 and return to execute step A3.
[0089] Optionally, when executing the step of generating the label value of the certificate sample, the enhanced processing module is specifically used to: determine a maximum label boundary value from all label ranges; and randomly generate a value in the range of [0, the maximum label boundary value] as the label value of the certificate sample.
[0090] Optionally, the model training module is specifically used to: extract features of the target document sample through m convolutional layers of a convolutional neural network to obtain m first feature vectors, where m is a positive integer greater than or equal to 2; set weights for feature elements in the first feature vector output by the mth convolutional layer through the Attention layer of the convolutional neural network to obtain the m'th first feature vector; calculate the classification value of the target document sample based on the m'th first feature vector; extract the classification values of the multiple target document samples from the document sample set, and train the document classification model based on the classification values of the multiple target document samples in the document sample set and the calculated classification values of the corresponding target document samples.
[0091] Optionally, when the model training module executes the calculation of the classification value of the target document sample based on the m'th first feature vector, it is specifically used to: filter out p first feature vectors from the first feature vectors output by the first m-1 convolutional layers; calculate the classification value of the target document sample based on the p first feature vectors and the m'th first feature vector; wherein p is a positive integer greater than or equal to 1 and less than or equal to m.
[0092] Embodiment 4
[0093] Embodiment 4 of the present invention further provides a document classification device, which corresponds to the document classification method provided in the above embodiment 1. The corresponding technical features and technical effects are not described in detail in this embodiment. For relevant parts, please refer to the above embodiment 2. Specifically, Figure 4 FIG. 4 shows a block diagram of a document classification device provided by Embodiment 4 of the present invention. Figure 4 As shown, the document classification device 400 includes a document acquisition module 401, a feature extraction module 402, a weight setting module 403, a classification value calculation module 404 and a document classification module 405, wherein:
[0094] The certificate acquisition module 401 is used to acquire the certificate to be classified;
[0095] A feature extraction module 402 is used to extract the features of the document to be classified through m convolutional layers of the document classification model to obtain m second feature vectors, wherein m is a positive integer greater than or equal to 2, and the document classification model is obtained by the method described;
[0096] A weight setting module 403 is used to set weights for feature elements in the second feature vector output by the mth convolutional layer through the Attention layer of the document classification model to obtain an m'th second feature vector;
[0097] A classification value calculation module 404, used to calculate the classification value of the document to be classified according to the m'th second feature vector;
[0098] The certificate classification module 405 is used to filter out the largest classification value from all the calculated classification values, and use the certificate category pointed to by the largest classification value as the certificate category to which the certificate to be classified belongs.
[0099] Optionally, the classification value calculation module is specifically used to: filter out p second feature vectors from the second feature vectors output by the first m-1 convolutional layers; calculate the classification value of the document sample to be classified based on the p second feature vectors and the m'th second feature vector; wherein p is a positive integer greater than or equal to 1 and less than or equal to m.
[0100] Embodiment 5
[0101] Figure 5 A block diagram of a computer device suitable for implementing a training method for a document classification model and / or a document classification method provided in Embodiment 5 of the present invention is shown. In this embodiment, the computer device 500 may be a smart phone, tablet computer, laptop computer, desktop computer, rack server, blade server, tower server or cabinet server (including an independent server or a server cluster composed of multiple servers) that executes a program. Figure 5 As shown, the computer device 500 of this embodiment includes at least but is not limited to: a memory 501, a processor 502, and a network interface 505 that can be interconnected through a system bus. It should be noted that Figure 5 Only computer device 500 is shown with components 501 - 505 , but it should be understood that implementing all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.
[0102] In this embodiment, the memory 505 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 501 can be an internal storage unit of the computer device 500, such as a hard disk or memory of the computer device 500. In other embodiments, the memory 501 can also be an external storage device of the computer device 500, such as a plug-in hard disk equipped on the computer device 500, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 501 can also include both the internal storage unit of the computer device 500 and its external storage device. In this embodiment, the memory 501 is generally used to store an operating system and various application software installed on the computer device 500, such as a training method for a certificate classification model and / or a program code for a certificate classification method.
[0103] In some embodiments, the processor 502 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 502 is generally used to control the overall operation of the computer device 500. For example, it performs control and processing related to data interaction or communication with the computer device 500. In this embodiment, the processor 502 is used to run the program code of the training method of the certificate classification model and / or the steps of the certificate classification method stored in the memory 501.
[0104] In this embodiment, the training method of the certificate classification model and / or the certificate classification method stored in the memory 501 can also be divided into one or more program modules and executed by one or more processors (processor 502 in this embodiment) to complete the present invention.
[0105] The network interface 505 may include a wireless network interface or a wired network interface, and the network interface 505 is generally used to establish a communication link between the computer device 500 and other computer devices. For example, the network interface 505 is used to connect the computer device 500 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 500 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.
[0106] Embodiment 6
[0107] This embodiment four also provides a computer-readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, server, App application store, etc., on which a computer program is stored, and when the computer program is executed by a processor, a training method for a document classification model and / or steps of a document classification method are implemented.
[0108] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.
[0109] It should be noted that the serial numbers of the embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0110] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.
[0111] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A training method for a document classification model, characterized in that: The method comprises: Acquire a document sample set, and extract a document sample from the document sample set; Obtaining a preset set of N data enhancement algorithms and an order of using the N data enhancement algorithm sets; Determining a data enhancement algorithm set for performing data enhancement processing on the document sample from the N data enhancement algorithm sets in the usage order, and performing data enhancement processing on the document sample according to the determined data enhancement algorithm set to obtain a target document sample; A document classification model for document classification is trained based on multiple target document samples; Each data enhancement algorithm set is associated with a label range, and the data enhancement algorithm set used for performing data enhancement processing on the document sample is determined from the N data enhancement algorithm sets in the usage order, and the document sample is data enhanced according to the determined data enhancement algorithm set to obtain a target document sample, including: Step A1, generating a label value of the document sample, and determining whether the label value is within the label range associated with the first data enhancement algorithm set, if yes, executing step A2, otherwise executing step A3; Step A2, performing data enhancement processing on the document sample according to the first data enhancement algorithm set, and executing step A3; Step A3, regenerate the label value of the certificate sample, and determine whether the label value is within the label range associated with the i+1th data enhancement algorithm set. If yes, execute step A4; otherwise, execute step A5, wherein i is a positive integer with an initial value of 1; Step A4: if the first i data enhancement algorithm sets have performed data enhancement processing on the document sample, then the i+1th data enhancement algorithm set is used to continue to perform data enhancement processing on the document sample after the last data enhancement processing, and step A5 is executed; if the first i data enhancement algorithm sets have not performed data enhancement processing on the document sample, then the i+1th data enhancement algorithm set is used to perform data enhancement processing on the document sample, and step A5 is executed; Step A5, determine whether i+1 is equal to N. If so, record the document sample after the last data enhancement processing as the target document sample. If not, assign i to i+1 and return to step A3.
2. The method according to claim 1, characterized in that The step of generating the label value of the certificate sample comprises: Determine a maximum label boundary value from all label ranges; A value in the range of [0, the maximum label boundary value] is randomly generated as the label value of the certificate sample.
3. The method according to claim 1, characterized in that The step of training a document classification model for document classification based on a plurality of target document samples includes: Extracting features of the target document sample through m convolutional layers of a convolutional neural network to obtain m first feature vectors, where m is a positive integer greater than or equal to 2; Setting weights for feature elements in the first feature vector output by the mth convolutional layer through the Attention layer of the convolutional neural network to obtain an m'th first feature vector; Calculate the classification value of the target document sample according to the m'th first feature vector; The classification values of the multiple target certificate samples are extracted from the certificate sample set, and the certificate classification model is trained according to the classification values of the multiple target certificate samples in the certificate sample set and the calculated classification values of the corresponding target certificate samples.
4. The method according to claim 3, characterized in that The calculating the classification value of the target certificate sample according to the m'th first feature vector comprises: Filter out p first eigenvectors from the first eigenvectors output by the first m-1 convolutional layers; Calculating the classification value of the target document sample according to the p first feature vectors and the m'th first feature vector; Here, p is a positive integer greater than or equal to 1 and less than or equal to m.
5. A method for classifying certificates, characterized in that: The method comprises: Obtain the documents to be classified; Extracting features of the document to be classified through m convolutional layers of a document classification model to obtain m second feature vectors, wherein m is a positive integer greater than or equal to 2, and the document classification model is obtained by the method described in any one of claims 1 to 4; Setting weights for feature elements in the second feature vector output by the mth convolutional layer through the Attention layer of the document classification model to obtain the m'th second feature vector; Calculate the classification value of the document to be classified according to the m'th second eigenvector; The largest classification value is screened out from all the calculated classification values, and the document category pointed to by the largest classification value is used as the document category to which the document to be classified belongs.
6. The method according to claim 5, characterized in that The step of calculating the classification value of the document to be classified according to the m'th second feature vector comprises: Filter out p second eigenvectors from the second eigenvectors output by the first m-1 convolutional layers; Calculating the classification value of the document sample to be classified according to the p second feature vectors and the m'th second feature vector; Here, p is a positive integer greater than or equal to 1 and less than or equal to m.
7. A training device for a document classification model for implementing the method according to any one of claims 1 to 4, characterized in that: The device comprises: A sample acquisition module, used to acquire a document sample set and extract a document sample from the document sample set; A data set acquisition module is used to acquire a preset set of N data enhancement algorithms and the order in which the N data enhancement algorithms are used; an enhancement processing module, configured to determine a data enhancement algorithm set for performing data enhancement processing on the document sample from the N data enhancement algorithm sets in the order of use, and perform data enhancement processing on the document sample according to the determined data enhancement algorithm set to obtain a target document sample; The model training module is used to train a document classification model for document classification based on multiple target document samples.
8. A document classification device, characterized in that: The device comprises: A certificate acquisition module is used to acquire certificates to be classified; A feature extraction module, used to extract the features of the document to be classified through m convolutional layers of a document classification model to obtain m second feature vectors, wherein m is a positive integer greater than or equal to 2, and the document classification model is obtained by the method described in any one of claims 1 to 4; A weight setting module, used for setting weights for feature elements in the second feature vector output by the mth convolutional layer through the Attention layer of the document classification model to obtain the m'th second feature vector; A classification value calculation module, used for calculating the classification value of the document to be classified according to the m'th second feature vector; The certificate classification module is used to filter out the largest classification value from all the calculated classification values, and use the certificate category pointed to by the largest classification value as the certificate category to which the certificate to be classified belongs.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 and / or the method according to any one of claims 5 to 6 is implemented.
Citation Information
Patent Citations
Enhancement strategy verification method and device, electronic equipment and storage medium
CN112613543A
