Method and apparatus for classifying text
By generating and merging non-structured and structured feature vectors, the problem of excessive similarity between sentence vectors in the BERT model is solved, which significantly improves the accuracy of text classification and feature extraction effect.
Patent Information
- Application Number
- CN202210138933.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-15
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2042-02-15
AI Technical Summary
The existing text classification scheme based on BERT model has the problem of excessive similarity between sentence vectors, which leads to poor feature extraction effect, especially in text classification tasks.
Improve the feature representation of the text by generating eigenvectors containing unstructured eigenvectors and structured eigenvectors. The specific steps include extracting unstructured feature vectors using pre-trained neural network models, building structured feature vectors based on structured data, and combining the two to generate the final feature vector.
By combining unstructured and structured features, the accuracy and effect of text classification are significantly improved, the problem of excessive collapse of sentence vectors is avoided, and the amount of information coverage of feature extraction is enhanced.
Smart Images

Figure CN114969319B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to artificial intelligence technology, and in particular to a method for classifying text, a method for training a text classifier, a computer system for implementing the above method, and a computer-readable storage medium. Background Art
[0002] Text classification automatically classifies and labels text sets according to certain classification systems or standards. Most of the text classification methods based on deep learning are based on CNN models or RNN models, which are based on non-dynamic word vectors or word vectors as input. Since word vectors or word vectors cannot change according to their context, the amount of information they cover is relatively simple.
[0003] In addition, the existing text classification solutions based on the BERT model cannot solve the "collapse" problem of BERT sentences. The "collapse" here means that BERT tends to encode all sentences into a smaller spatial area, which makes most sentence pairs have high similarity scores, even those that are completely unrelated in semantics. Due to the high similarity between sentence vectors, the feature extraction based on sentence vectors is ultimately ineffective. The above problems are particularly evident in text classification tasks. Summary of the invention
[0004] A method for classifying text according to one aspect of the present application includes:
[0005] A. generating a feature vector of the text to be classified, wherein the feature vector of the text to be classified includes an unstructured feature vector and a structured feature vector; and
[0006] B. Obtain the classification result of the text to be classified based on the generated feature vector of the text to be classified.
[0007] In some embodiments, step A of the above method further comprises:
[0008] A1. Use the pre-trained neural network model to extract unstructured feature vectors from the text to be classified;
[0009] A2. constructing a structured feature vector from the attribute values of the structured data in the text to be classified; and
[0010] A3. Generate a feature vector of the text to be classified by merging the unstructured feature vector and the structured feature vector.
[0011] In some embodiments, in step A1, multiple pre-trained neural network models are used to extract unstructured feature vectors, wherein the pre-training of each neural network model is based on its corresponding corpus.
[0012] In some embodiments, the neural network model is one of the following: a BERT model, an XLNet model, and a RoBERTa model.
[0013] In some embodiments, the neural network model is pre-trained in one of the following ways: a hidden language model (Masked LM) and a next sentence prediction (Next Sentence Prediction).
[0014] In some embodiments, the structured feature vector includes at least one of the following: an attribute feature vector, a network location feature vector, and a statistical attribute feature vector.
[0015] In some embodiments, step A2 comprises:
[0016] A21, read the attribute value of the structured data of the text to be classified;
[0017] A22. Convert the read attribute value into an attribute feature vector based on pre-built rules.
[0018] In some embodiments, step A2 further includes:
[0019] A23, constructing a relationship network between the text to be classified and other texts about at least one attribute value, wherein the text to be classified and other texts constitute nodes in the relationship network, and the relationship between the attribute values of the text to be classified and other texts constitutes an edge of the relationship network;
[0020] A24. Extract the point degree centrality and node attribute information in the constructed relationship network to generate a network position feature vector.
[0021] In some embodiments, step A2 further includes:
[0022] A25. Determine a statistical feature of at least one attribute value in the text to be classified;
[0023] A26. Generate a statistical feature attribute vector from the determined statistical features.
[0024] In some embodiments, step B comprises:
[0025] B1. Input the generated feature vector of the text to be classified into the classifier;
[0026] B2. Using the classifier to determine the probability value of the text to be classified belonging to various text types;
[0027] B3. Determine the text type corresponding to the maximum probability value as the type to which the text to be classified belongs.
[0028] In some embodiments, the classification algorithm adopted by the classifier is selected from the following group: K nearest neighbor classification algorithm, naive Bayes algorithm, support vector machine algorithm, gradient boosting tree algorithm, random forest algorithm, convolutional neural network algorithm and long short-term memory network algorithm.
[0029] In some embodiments, the optimization method of the classifier is selected from the group consisting of: gradient descent algorithm, stochastic gradient descent algorithm, L-BFGS algorithm, ADAM algorithm, RMSProp algorithm.
[0030] A computer system according to another aspect of the present application comprises:
[0031] at least one memory;
[0032] at least one processor; and
[0033] A computer program stored on the memory and executable on the processor, the execution of which results in the following operations:
[0034] A. generating a feature vector of the text to be classified, wherein the feature vector of the text to be classified includes an unstructured feature vector and a structured feature vector; and
[0035] B. Obtain the classification result of the text to be classified based on the generated feature vector of the text to be classified.
[0036] A method for training a text classifier according to another aspect of the present application comprises the following steps:
[0037] A. Pre-train the neural network model;
[0038] B. For each text sample in the training sample set, use the pre-trained neural network model to extract the corresponding unstructured feature vector;
[0039] C. For each text sample in the training sample set, a structured feature vector is constructed from the attribute values of the corresponding structured data;
[0040] D. For each text sample in the training sample set, generate a corresponding feature vector from its unstructured feature vector and structured feature vector; and
[0041] E. Train the text classifier by taking the feature vector of each text sample as input and the classification label of the text sample as output.
[0042] A computer system according to another aspect of the present application comprises:
[0043] at least one memory;
[0044] at least one processor; and
[0045] A computer program stored on the memory and executable on the processor, the execution of which results in the following operations:
[0046] A. Pre-train the neural network model;
[0047] B. For each text sample in the training sample set, use the pre-trained neural network model to extract the corresponding unstructured feature vector;
[0048] C. For each text sample in the training sample set, a structured feature vector is constructed from the attribute values of the corresponding structured data;
[0049] D. For each text sample in the training sample set, generate a corresponding feature vector from its unstructured feature vector and structured feature vector; and
[0050] E. Train the text classifier by taking the feature vector of each text sample as input and the classification label of the text sample as output.
[0051] According to another aspect of the present application, a computer-readable storage medium stores a computer program, which implements the above-mentioned method when executed by a processor.
[0052] In some embodiments of the present application, in the feature extraction process, not only the unstructured information in the text is used, but also the structured information in the text is used synchronously, so as to make more full use of the information contained in the text. In addition, by using the structured feature vector of the text, expert knowledge can be introduced to improve the classification effect. Furthermore, compared with the traditional word segmentation model and CNN model, the use of the BERT model can make more full use of prior information (such as expert knowledge, etc.). BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The above and / or other aspects and advantages of the present application will become clearer and easier to understand through the following description of various aspects in conjunction with the accompanying drawings, in which the same or similar units are represented by the same reference numerals. The accompanying drawings include:
[0054] Figure 1 The present invention is a flowchart of a method for classifying text according to some embodiments of the present application.
[0055] Figure 2 The present invention is a flowchart of a method for generating a feature vector of a text according to some other embodiments of the present application.
[0056] Figure 3 The present invention is a flowchart of a method for generating a structured feature vector of a text according to some other embodiments of the present application.
[0057] Figure 4 The present invention is a flowchart of a text classification processing method according to some other embodiments of the present application.
[0058] Figure 5 is a schematic block diagram of a computer system according to some other embodiments of the present application.
[0059] Figure 6 The present invention is a flowchart of a method for training a text classifier according to some other embodiments of the present application.
[0060] Figure 7 is a schematic block diagram of a computer system according to some other embodiments of the present application. DETAILED DESCRIPTION
[0061] The present application is described more fully below with reference to the accompanying drawings in which illustrative embodiments of the present application are illustrated. However, the present application may be implemented in different forms and should not be interpreted as being limited to the embodiments given herein. The above embodiments are given to make the disclosure herein comprehensive and complete, so as to more fully convey the scope of protection of the present application to those skilled in the art.
[0062] In this specification, terms such as "comprise" and "include" indicate that in addition to the units and steps directly and explicitly stated in the specification and claims, the technical solution of the present application does not exclude the situation where there are other units and steps that are not directly or explicitly stated.
[0063] Terms such as "first" and "second" do not indicate the order of the units in terms of time, space, size, etc., but are only used to distinguish the units.
[0064] In this specification, the BERT model refers to a language representation model that uses pre-training technology. Unlike the pre-training method that uses traditional unidirectional language models or shallowly concatenated unidirectional language models, this model uses methods such as a hidden language model (Masked language model, hereinafter referred to as MLM) to generate deep bidirectional language representation.
[0065] Figure 1 The present invention is a flowchart of a method for classifying text according to some embodiments of the present application. Figure 1 The method shown comprises the following steps which are performed by running a computer program in a computer system:
[0066] Step 110: Generation of feature vectors for text to be classified
[0067] In this step, feature vectors are extracted from the text to be classified. In particular, the extracted feature vectors include both unstructured feature vectors and structured feature vectors. After completing step 110, Figure 1 The process shown proceeds to step 120 .
[0068] For example, the feature vector can be generated according to Figure 2 Specifically, Figure 2 The process shown includes the following steps:
[0069] Step 210: Generation of unstructured feature vector
[0070] In step 210, unstructured feature vectors are extracted from the text to be classified using a pre-trained neural network model. Unstructured data in a text generally refers to data with an irregular or incomplete data structure and no predefined data, including but not limited to images, videos, audios, texts with uncertain contents, etc. Exemplarily, unstructured data in a text may be input into a trained neural network model, and the output word vector sequence may be used as an unstructured feature vector of the text.
[0071] Step 220: Generation of structured feature vector
[0072] In step 220, a structured feature vector is extracted from the text to be classified. Structured data generally refers to data suitable for logical expression and implementation using a two-dimensional table structure. A structured feature vector can be constructed based on the attribute values of the structured data.
[0073] For example, it can be Figure 3 The structured feature vector is generated or constructed in the manner shown. Figure 3 As shown, in step 310, the attribute value of the text structured data is read and converted according to the pre-built rules to obtain the attribute feature vector.
[0074] Optionally, Figure 3 The method shown may also include steps 320 and 330. Specifically, in step 320, a relational network about at least one attribute value is constructed between the text to be classified and other texts, wherein the text to be classified and other texts constitute nodes in the relational network, and the relationship between the attribute values of the text to be classified and other texts (such as a reference relationship, a question-answer relationship, etc.) constitutes an edge of the relational network. Then in step 330, the point degree centrality and node attribute information in the constructed relational network are extracted to generate a network position feature vector.
[0075] Optionally, Figure 3The method shown may further include steps 340 and 350. Specifically, in step 340, a statistical feature about at least one attribute value in the to-be-classified text is determined. Then, in step 350, a statistical feature attribute vector is generated from the determined statistical feature.
[0076] Step 230: Generate a feature vector based on the unstructured feature vector and the structured feature vector
[0077] In step 230, a feature vector of the text to be classified is generated by merging the unstructured feature vector and the structured feature vector.
[0078] It should be pointed out that in Figure 2 In the method shown, steps 210 and 220 may be executed in parallel or sequentially (eg, step 210 is executed first, and then step 220; or step 220 is executed first, and then step 210).
[0079] Step 120: Text classification
[0080] The generated feature vector of the text to be classified is input into the classifier to obtain the classification result of the text to be classified.
[0081] For example, it can be Figure 4 The text classification process is performed in the manner shown. Figure 4 The method shown includes the following steps:
[0082] Step 410: Input the generated feature vector of the text to be classified into a classifier. Optionally, the feature vector of the text to be classified can be synthesized into a feature vector matrix as the input of the fully connected layer of the classifier to achieve linear dimensionality reduction, thereby obtaining an N-dimensional vector F N , where N is the number of text categories.
[0083] Step 420: The classifier determines the probability value of the text to be classified belonging to various text types based on the feature vector of the text to be classified. Optionally, a softmax layer is used to classify the N-dimensional vector V N Calculate to get the probability prediction vector P = {p1, p2, ..., p j ,...,p N}, each element in the vector P represents the probability that the text to be classified belongs to the corresponding category, for example, p j It represents the probability of being classified as the jth category.
[0084] Step 430: Determine the text type corresponding to the maximum probability value as the type of the text to be classified. In other words, determine the type corresponding to the element with the largest value in the vector P as the type of the text to be classified.
[0085] Figure 5is a schematic block diagram of a computer system according to some other embodiments of the present application.
[0086] like Figure 5 As shown, the computer system 50 includes at least one memory 510 (e.g., non-volatile memory such as flash memory, ROM, hard disk drive, magnetic disk, optical disk, etc.), at least one processor 520, and a computer program 530 stored in the memory 510 and executable on the processor 520.
[0087] The memory 510 stores a computer program 530 executable by the processor 520. The processor 520 is configured to execute the computer program 530 to implement the reference Figure 1-4 Describe the method steps.
[0088] Optionally, Figure 5 The computer system 50 shown can be implemented in the form of a cloud computing platform or cloud platform, in which computing, network and storage services are provided in the form of a resource pool, wherein most of the computing resources are hosted on the Internet and allocated to users on demand. Alternatively, the computer system 50 can also be implemented in the form of a stand-alone system, in which computing resources are basically limited to a single local system, and computer applications, data storage and processing capabilities are close to or relatively close to users.
[0089] Figure 6 Flowchart of a method for training a text classifier according to some other embodiments of the present application. Figure 6 A text classifier trained in the manner shown should be useful for Figure 1 The text classification process steps in .
[0090] Figure 6 The method shown comprises the following steps which are performed by running a computer program in a computer system:
[0091] Step 610: Pre-training of neural network model
[0092] In this step, the neural network model is pre-trained. Optionally, the neural network model is one of the following: BERT model, XLNet model and RoBERTa model.
[0093] Alternatively, in this step, multiple pre-trained neural network models can be used to extract unstructured feature vectors from the text to be classified, wherein the pre-training of each neural network model is based on its own corresponding corpus (for example, relevant external materials can be selected to obtain corpus similar to the problem background).
[0094] Alternatively, the neural network model may be pre-trained in one of the following ways: a hidden language model (Masked LM) and a next sentence prediction (Next Sentence Prediction).
[0095] Step 620: Generation of unstructured feature vector
[0096] In this step, for each text sample in the training sample set, the corresponding unstructured feature vector is extracted using the pre-trained neural network model. In some examples, the unstructured data can be input to the neural network model trained in step 610, and the output word vector sequence is used as the unstructured feature vector of the text.
[0097] Step 630: Generation of structured feature vector
[0098] In this step, a structured feature vector may be constructed based on the attribute values of the structured data. Optionally, the structured feature vector may include at least one of the following items: an attribute feature vector, a network location feature vector, and a statistical attribute feature vector. The method for generating the structured feature vector has been described above with reference to Figure 3 It has been described and will not be repeated here.
[0099] Step 640: Generating feature vectors of text samples
[0100] In this step, for each text sample in the training sample set, a corresponding feature vector is generated from its unstructured feature vector and structured feature vector (for example, in a vector merging manner).
[0101] Step 650: Training of text classifier
[0102] In this step, the text classifier is trained by taking the feature vector of each text sample as input and the classification label of the text sample as output.
[0103] Optionally, the classification algorithm adopted by the text classifier is selected from the following set: K nearest neighbor classification algorithm, naive Bayes algorithm, support vector machine algorithm, gradient boosting tree algorithm, random forest algorithm, convolutional neural network algorithm and long short-term memory network algorithm.
[0104] Alternatively, the optimization method of the text classifier is selected from the group consisting of: gradient descent algorithm, stochastic gradient descent algorithm, L-BFGS algorithm, ADAM algorithm, RMSProp algorithm.
[0105] In one example, the historical data of text classification can be used as classification labels, cross entropy can be used as the loss function, ADAM can be used as the optimizer, and accuracy can be used as the indicator to train the classifier, and the training can be stopped after the maximum number of iterations is reached. After multiple trainings, the model with the highest accuracy on the validation set can be determined as the final classifier to be used.
[0106] Optionally, for situations where there are advantages and disadvantages, orders, and levels among different classification labels, different weights can be assigned to the loss function according to the difference between the classification result and the correct result, wherein a larger weight is assigned when the difference is large, and a smaller weight is assigned when the difference is small.
[0107] Figure 7 is a schematic block diagram of a computer system according to some other embodiments of the present application.
[0108] like Figure 7 As shown, the computer system 70 includes a communication unit 710, at least one memory 720 (e.g., a non-volatile memory such as a flash memory, a ROM, a hard disk drive, a magnetic disk, an optical disk, etc.), at least one processor 730, and a computer program 740 stored on the memory 720 and executable on the processor 730.
[0109] The communication unit 710 serves as a communication interface and is configured to receive text data to be processed from an external device or network (eg, a client terminal and a server, etc.) and return a processing result to the external device or network.
[0110] The memory 720 stores a computer program 740 executable by the processor 730. The processor 730 is configured to execute the computer program 740 to implement the reference Figure 6 Describe the method steps.
[0111] Optionally, Figure 7 The computer system 70 shown can be implemented in a cloud computing platform or cloud platform, in which computing, network and storage services are provided in the form of resource pools, wherein most of the computing resources are hosted on the Internet and allocated to users on demand. Alternatively, the computer system 70 can also be implemented in a stand-alone system, in which computing resources are basically limited to a single local system, and computer applications, data storage and processing capabilities are close to or relatively close to users.
[0112] The following describes a specific example of the method for training a text classifier using patent text rating as an example.
[0113] In this specific example, the text classifier training method includes the following steps:
[0114] Step 801: Determine the evaluation indicator dimensions and specific indicators of each dimension. For example, in the pre-patent application evaluation, the three-dimensional indicator system of technology, economy and law is generally used.
[0115] Step 802: Based on the ratings of each dimension of the patent (A, B, C, D), form the patent classification label set Y1 = {A, B, C, D}, Y2 = {A, B, C, D}, Y3 = {A, B, C, D}, and thereby construct the unlabeled corpora S1, S2, S3 of each dimension.
[0116] Step 803: Read the patent structured data of the patent text to be classified. Exemplarily, the patent bibliographic data of the patent text can be used as the patent structured data. The patent bibliographic data includes, but is not limited to, the number of patent inventors, the number of applicants, whether an agency is entrusted, the number of cited patent documents, the number of cited non-patent documents, the nature of the first applicant, the address of the applicant, etc. The above patent bibliographic data can be integrated into the attribute feature vector F of the patent text, for example. S .
[0117] Step 804: Based on the patent structured data read in step 803, a relationship network with other patent texts is constructed using the patent text as a network node. The relationships that can be used to construct the relationship network include, but are not limited to, co-applicants, co-right holders, co-applicant addresses, patent citation relationships, co-citation document relationships, etc. The features of the above relationships can be integrated into a network position feature vector F N .
[0118] In this step, optionally, new patent features can be constructed based on existing patent attributes to generate a statistical feature attribute vector of the patent text. The above new patent features include, but are not limited to, the number of patent applications filed by the patentee in the field in the past three years / the number of patent applications filed in the field in the past three years, the number of patents granted by the patentee in the field in the past three years / the number of patents granted in the field in the past three years, etc. These newly constructed features can be integrated into a statistical feature attribute vector F M .
[0119] Step 805: Pre-train the BERT model using the unlabeled corpora S1, S2, and S3 constructed in step 802. An exemplary pre-training method is:
[0120] Randomly hide the text in S1 with the "[MASK]" label, with a hiding ratio of 15%, such as:
[0121] Raw text output: A text classification based on expert knowledge and deep learning
[0122] Hidden text input: Text classification based on expert knowledge and [MASK] learning
[0123] The above (input, output) sentence pairs are used as pre-training sets to train the BERT model. The input is text with the "[MASK]" label, and the output is the words hidden by the "[MASK]" label.
[0124] After the above training process, the BERT model can "recognize" the differences between words under different background knowledge, improve the difference of text vectors output by the model between different dimensions, and finally obtain three pre-trained BERT models Bert-Tec, Bert-Eco, and Bert-Law corresponding to the dimensions of technology, economy, and law respectively.
[0125] Step 806: Use the three BERT models pre-trained in step 805 to vectorize the unstructured data of the patent text. For example, the unstructured data of the patent text includes but is not limited to the patent title, patent abstract, patent claims and claims. For each claim, different weights can be assigned according to its order and the reference relationship between it and other claims, so as to reflect the importance of different claims. The vectorized unstructured data can be, for example, a text vector F in three dimensions: T .
[0126] Step 807: Transform the text vector F T , attribute feature vector F S , Statistical feature attribute vector F M and the network position feature vector F N Fusion into feature vector F = {F T , F S , F M , F N}.
[0127] Step 808: Use the feature vector F as the input of the text classifier, use the classification label set Y = {Y1, Y2, Y3} as the output of the text classifier, train the classifier within a set number of iterations, and select the classifier with the highest accuracy as the final classifier.
[0128] It should be pointed out that the classification accuracy of the classifier can be improved by updating the rules for generating structured feature vectors and the corpus for pre-training the neural network model and training the classifier with the updated rules and corpus.
[0129] The embodiments and examples set forth herein are provided to best illustrate embodiments according to the present technology and its specific applications, and thereby enable those skilled in the art to implement and use the present application. However, those skilled in the art will appreciate that the above description and examples are provided only for ease of illustration and example. The description set forth is not intended to cover all aspects of the present application or to limit the present application to the precise form disclosed.
Claims
1. A method for classifying text, characterized in that The following steps are involved: A. generating a feature vector of the text to be classified, wherein the feature vector of the text to be classified includes an unstructured feature vector and a structured feature vector; and B. Obtain the classification result of the text to be classified based on the generated feature vector of the text to be classified, Wherein, the structured feature vector at least includes a network location feature vector, Wherein, step A comprises: A1. Use the pre-trained neural network model to extract unstructured feature vectors from the text to be classified; A2. constructing a structured feature vector from the attribute values of the structured data in the text to be classified; and A3. Generate a feature vector of the text to be classified by combining the unstructured feature vector and the structured feature vector. Wherein, step A2 comprises: A23, constructing a relationship network between the text to be classified and other texts about at least one attribute value, wherein the text to be classified and other texts constitute nodes in the relationship network, and the relationship between the attribute values of the text to be classified and other texts constitutes an edge of the relationship network; A24. Extract the point degree centrality and node attribute information in the constructed relationship network to generate a network position feature vector.
2. The method of claim 1, wherein: In step A1, multiple pre-trained neural network models are used to extract unstructured feature vectors, wherein the pre-training of each neural network model is based on its corresponding corpus.
3. The method according to claim 1 or 2, wherein: The neural network model is one of the following: BERT model, XLNet model and RoBERTa model.
4. The method according to claim 1 or 2, wherein: The neural network model is pre-trained in one of the following ways: a masked language model (Masked LM) and a next sentence prediction (Next Sentence Prediction).
5. The method of claim 1, wherein: The structured feature vector also includes at least one of the following items: an attribute feature vector and a statistical attribute feature vector.
6. The method of claim 5, wherein: Step A2 also includes: A21, read the attribute value of the structured data of the text to be classified; A22. Convert the read attribute value into an attribute feature vector based on pre-built rules.
7. The method of claim 6, wherein: Step A2 also includes: A25. Determine a statistical feature of at least one attribute value in the text to be classified; A26. Generate a statistical feature attribute vector from the determined statistical features.
8. The method of claim 1, wherein: Step B includes: B1. Input the generated feature vector of the text to be classified into the classifier; B2. Using the classifier to determine the probability value of the text to be classified belonging to various text types; B3. Determine the text type corresponding to the maximum probability value as the type to which the text to be classified belongs.
9. The method of claim 8, wherein: The classification algorithm used by the classifier is selected from the following set: K nearest neighbor classification algorithm, naive Bayes algorithm, support vector machine algorithm, gradient boosting tree algorithm, random forest algorithm, convolutional neural network algorithm and long short-term memory network algorithm.
10. The method of claim 8, wherein: The optimization method of the classifier is selected from the group consisting of: gradient descent algorithm, stochastic gradient descent algorithm, L-BFGS algorithm, ADAM algorithm, RMSProp algorithm.
11. A computer system comprising: at least one memory; at least one processor; and A computer program stored on the memory and executable on the processor, the execution of which results in the following operations: A. Generate the feature vector of the text to be classified, where The feature vector of the text to be classified includes an unstructured feature vector and a structured feature vector; and B. Obtain the classification result of the text to be classified based on the generated feature vector of the text to be classified, Wherein, the structured feature vector at least includes a network location feature vector, The execution of the computer program causes operation A to be performed in the following manner: A1. Use the pre-trained neural network model to extract unstructured feature vectors from the text to be classified; A2. constructing a structured feature vector from the attribute values of the structured data in the text to be classified; and A3. Generate a feature vector of the text to be classified by combining the unstructured feature vector and the structured feature vector. The execution of the computer program causes operation A2 to be performed in the following manner: A23, constructing a relationship network between the text to be classified and other texts about at least one attribute value, wherein the text to be classified and other texts constitute nodes in the relationship network, and the relationship between the attribute values of the text to be classified and other texts constitutes an edge of the relationship network; A24. Extract the point degree centrality and node attribute information in the constructed relationship network to generate a network position feature vector.
12. The computer system of claim 11, wherein: The execution of the computer program results in extracting unstructured feature vectors using multiple pre-trained neural network models in operation A1, wherein the pre-training of each neural network model is based on a corresponding corpus.
13. The computer system of claim 11 or 12, wherein: The neural network model is one of the following: BERT model, XLNet model and RoBERTa model.
14. The computer system according to claim 11 or 12, wherein: The neural network model is pre-trained in one of the following ways: a masked language model (Masked LM) and a next sentence prediction (Next Sentence Prediction).
15. The computer system of claim 11, wherein: The structured feature vector includes at least one of the following items: an attribute feature vector and a statistical attribute feature vector.
16. The computer system of claim 15, wherein: The execution of the computer program further causes operation A2 to be performed in the following manner: A21, read the attribute value of the structured data of the text to be classified; A22. Convert the read attribute value into an attribute feature vector based on pre-built rules.
17. The computer system of claim 16, wherein: The execution of the computer program further causes operation A2 to be performed in the following manner: A25. Determine a statistical feature of at least one attribute value in the text to be classified; A26. Generate a statistical feature attribute vector from the determined statistical features.
18. The computer system of claim 11, wherein: The execution of the computer program causes operation B to be performed in the following manner: B1. Input the generated feature vector of the text to be classified into the classifier; B2. Using the classifier to determine the probability value of the text to be classified belonging to various text types; B3. Determine the text type corresponding to the maximum probability value as the type to which the text to be classified belongs.
19. The computer system of claim 18, wherein: The classification algorithm used by the classifier is selected from the following set: K nearest neighbor classification algorithm, naive Bayes algorithm, support vector machine algorithm, gradient boosting tree algorithm, random forest algorithm, convolutional neural network algorithm and long short-term memory network algorithm.
20. The computer system of claim 18, wherein: The optimization method of the classifier is selected from the group consisting of: gradient descent algorithm, stochastic gradient descent algorithm, L-BFGS algorithm, ADAM algorithm, RMSProp algorithm.
21. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
22. A method for training a text classifier, characterized in that The following steps are involved: A. Pre-train the neural network model; B. For each text sample in the training sample set, use the pre-trained neural network model to extract the corresponding unstructured feature vector; C. For each text sample in the training sample set, a structured feature vector is constructed from the attribute values of the corresponding structured data; D. For each text sample in the training sample set, generate a corresponding feature vector from its unstructured feature vector and structured feature vector; and E. Train the text classifier by taking the feature vector of each text sample as input and the classification label of the text sample as output. Wherein, the structured feature vector at least includes a network location feature vector, Wherein, step C comprises: C3, constructing a relationship network between each text sample and other text samples in the training sample set about at least one attribute value, wherein each text sample and other text samples in the training sample set constitute nodes in the relationship network, and the relationship between the attribute values of each text sample and other text samples in the training sample set constitutes an edge of the relationship network; C4. Extract the point degree centrality and node attribute information in the constructed relationship network to generate a network position feature vector.
23. The method of claim 22, wherein: In step A, multiple neural network models are pre-trained, and the pre-training of each neural network model is based on its corresponding corpus.
24. The method of claim 22, wherein: The neural network model is one of the following: BERT model, XLNet model and RoBERTa model.
25. The method according to any one of claims 22 to 24, wherein: The neural network model is pre-trained in one of the following ways: a masked language model (Masked LM) and a next sentence prediction (Next Sentence Prediction).
26. The method according to any one of claims 22 to 24, wherein: The structured feature vector includes at least one of the following items: an attribute feature vector and a statistical attribute feature vector.
27. The method of claim 26, wherein: Step C also includes: C1. Read the attribute value of the structured data of the text sample; C2. Convert the read attribute values into attribute feature vectors based on pre-built rules.
28. The method of claim 27, wherein: Step C also includes: C5, determining statistical characteristics of at least one attribute value in each text sample; C6. Generate a statistical feature attribute vector from the determined statistical features.
29. The method of any one of claims 22 to 24, wherein: The classification algorithm adopted by the text classifier is selected from the set consisting of the following items: K nearest neighbor classification algorithm, naive Bayes algorithm, support vector machine algorithm, gradient boosting tree algorithm, random forest algorithm, convolutional neural network algorithm and long short-term memory network algorithm.
30. The method of any one of claims 22 to 24, wherein: In step E, an optimization algorithm selected from the group consisting of the following items is used to optimize the text classifier: gradient descent algorithm, stochastic gradient descent algorithm, L-BFGS algorithm, ADAM algorithm, RMSProp algorithm.
31. A computer system comprising: at least one memory; at least one processor; and A computer program stored on the memory and executable on the processor, the execution of which results in the following operations: A. Pre-train the neural network model; B. For each text sample in the training sample set, use the pre-trained neural network model to extract the corresponding unstructured feature vector; C. For each text sample in the training sample set, a structured feature vector is constructed from the attribute values of the corresponding structured data; D. For each text sample in the training sample set, generate a corresponding feature vector from its unstructured feature vector and structured feature vector; and E. Train the text classifier by taking the feature vector of each text sample as input and the classification label of the text sample as output. in, The structured feature vector at least includes a network position feature vector, The execution of the computer program causes operation C to be performed in the following manner: C3, constructing a relationship network between each text sample and other text samples in the training sample set about at least one attribute value, wherein each text sample and other text samples in the training sample set constitute nodes in the relationship network, and the relationship between the attribute values of each text sample and other text samples in the training sample set constitutes an edge of the relationship network; C4. Extract the point degree centrality and node attribute information in the constructed relationship network to generate a network position feature vector.
32. The computer system of claim 31, wherein: The operation of the computer program causes step A to be performed in the following manner: multiple neural network models are pre-trained, and the pre-training of each neural network model is based on its corresponding corpus.
33. The computer system of claim 31, wherein: The neural network model is one of the following: BERT model, XLNet model and RoBERTa model.
34. A computer system as claimed in any one of claims 31 to 33, wherein: The neural network model is pre-trained in one of the following ways: a hidden language model (Masked LM) and a next sentence prediction (Next SentencePrediction).
35. A computer system as claimed in any one of claims 31 to 33, wherein: The structured feature vector includes at least one of the following items: an attribute feature vector and a statistical attribute feature vector.
36. The computer system of claim 35, wherein: The execution of the computer program also causes operation C to be performed in the following manner: C1. Read the attribute value of the structured data of the text sample; C2. Convert the read attribute values into attribute feature vectors based on pre-built rules.
37. The computer system of claim 36, wherein: The execution of the computer program also causes operation C to be performed in the following manner: C5, determining statistical characteristics of at least one attribute value in each text sample; C6. Generate a statistical feature attribute vector from the determined statistical features.
38. A computer system as claimed in any one of claims 31 to 33, wherein: The classification algorithm adopted by the text classifier is selected from the set consisting of the following items: K nearest neighbor classification algorithm, naive Bayes algorithm, support vector machine algorithm, gradient boosting tree algorithm, random forest algorithm, convolutional neural network algorithm and long short-term memory network algorithm.
39. A computer system as claimed in any one of claims 31 to 33, wherein: In step E, an optimization algorithm selected from the group consisting of the following items is used to optimize the text classifier: gradient descent algorithm, stochastic gradient descent algorithm, L-BFGS algorithm, ADAM algorithm, RMSProp algorithm.
40. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 22 to 30 are implemented.
41. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1-10 and 22-30 are implemented.
Citation Information
Patent Citations
Text classification method and device, electronic equipment and storage medium
CN110399487A