Chinese short text classification method and system based on word similarity

By adopting a method based on word similarity in Chinese text classification, combining BERT and Word2Vec models, and fusing text semantics and similarity vectors, the problem of insufficient feature extraction in the existing technology is solved and the accuracy of text classification is improved.

CN118568255AActive Publication Date: 2024-08-30GUANGDONG UNIV OF TECH

Patent Information

Application Number
CN202410562008.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-08
Publication Date
2024-08-30
Estimated Expiration
2044-05-08

AI Technical Summary

Technical Problem

Existing Chinese text classification methods are insufficient in feature extraction and over-rely on the quality of data annotation, resulting in low classification accuracy.

Method used

Using a method based on word similarity, through word segmentation, text semantic vector extraction, word vectorization and similarity calculation, combined with pre-trained models such as BERT and Word2Vec, text semantic vectors and similarity vectors are integrated to generate total features for classification.

Benefits of technology

The accuracy of text classification is improved, especially when predicting different event types. Through the compensation of the similarity vector, the probability value of the classification output is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568255A
    Figure CN118568255A
Patent Text Reader

Abstract

The invention discloses a Chinese short text classification method and system based on word similarity, which can be applied to judging text event types and classifying texts. Comprising the following steps of: performing word segmentation on a text by utilizing a preset event type set to obtain an event trigger word and a vector form of an event type tag to which the event trigger word belongs; and performing text feature extraction on the obtained word segmentation text to obtain a text semantic vector. And vectorizing the obtained event trigger word and a preset event type set by using a natural language processing model to obtain respective word vectors, and calculating by using the word vectors to obtain a similarity vector between the event trigger word and the event type set. And fusing the text semantic vector and the similarity vector to obtain a total feature, inputting the total feature into a text classifier to classify the text, outputting a classification result, and evaluating the accuracy. According to the method, the concept of text semantic feature and word similarity fusion is introduced, and the features of the text are fully mined, so that the accuracy and efficiency of text classification are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of natural language processing, and more specifically, relates to a Chinese short text classification method and system based on word similarity. Background Art

[0002] At present, artificial intelligence has achieved great results in many fields, such as natural language processing, image processing, data mining, etc. Among them, text classification is an important research direction. Text classification is to organize and extract information by dividing data into pre-defined categories.

[0003] Current text classification technology can quickly determine the category of an unknown document, making massive information processing more efficient, saving a lot of information processing costs, and can quickly determine the text type to filter out the required information.

[0004] The invention patent with the prior art publication number CN116127079A proposes a text classification method, which determines the text category to which the text segment to be classified belongs by calculating the semantic similarity between the text feature vector of the text segment to be classified and the supporting text feature vectors of each text category. However, this scheme has the problem of insufficient feature mining of the text. Summary of the invention

[0005] In order to overcome the problems in the prior art of text classification methods that feature extraction is insufficient and overly dependent on the quality of data annotation, the present invention provides a Chinese short text classification method and system based on word similarity.

[0006] The first aspect of the present invention provides a Chinese short text classification method based on word similarity, comprising the following steps:

[0007] S1: Use the preset event type set to segment the text to be classified, clean the data, extract the label, and obtain the preset vector form of the event trigger word and the event type label to which the text belongs;

[0008] S2: Extract text features from the segmented text obtained in S1 to obtain a text semantic vector;

[0009] S3: The event trigger words and the preset event type set obtained in S1 are vectorized using a pre-trained natural language processing model to obtain respective word vectors, and the similarity vector between the event trigger words and the event type set is calculated using the word vectors;

[0010] S4: Fuse the text semantic vector obtained in S2 with the similarity vector obtained in S3 to obtain the final total feature used for classification;

[0011] S5: Input the total features into the text classifier, classify the text to be classified, output the classification results, and evaluate the classification accuracy.

[0012] Furthermore, the specific method of text feature extraction in step S2 is:

[0013] S2.1: Encode the segmented text obtained in step S1 using an encoder to obtain representation vectors of the text, which are word vectors, segment vectors, and position vectors;

[0014] S2.2: Input the word vector, segment vector and position vector into the pre-trained model BERT to perform text semantic learning and obtain text features. The text features include the text semantic vector of the entire sentence and the semantic vector corresponding to each word.

[0015] Furthermore, in step S3, the natural language processing model adopts the Word2Vec model.

[0016] Furthermore, in step S3, the vector similarity between the trigger word and the event type set is calculated using a cosine similarity algorithm.

[0017] Furthermore, in step S4, the text semantic vector obtained in S2 and the similarity vector obtained in S3 are merged, which specifically includes:

[0018] S4.1: Convert text semantic vector and similarity vector to the same dimension;

[0019] S4.2: Calculate the total weight for feature fusion based on the vector after dimension conversion;

[0020] S4.3: Calculate the fused total feature according to the dimensionally converted vector and the total weight.

[0021] Furthermore, the specific steps of step S5 are:

[0022] S5.1: Input the total features obtained in step S4 into the text classifier;

[0023] S5.2: Classify the text to be classified using the text classifier to obtain a predicted label;

[0024] S5.3: Encode the predicted label by using a label encoder to obtain a preset vector of the predicted label;

[0025] S5.4: Perform classification evaluation using the preset vector obtained from the event type label to which the text belongs and the preset vector of the predicted label to obtain the accuracy rate.

[0026] The second aspect of the present invention provides a Chinese short text classification system based on word similarity, which is used to implement the Chinese short text classification method, and is characterized by comprising:

[0027] A preprocessing module is used to segment the text to be classified, extract the label, convert the label into a preset vector form and extract the text semantic vector;

[0028] A similarity module is used to calculate the word similarity vector between the trigger word and the predefined event type;

[0029] Feature fusion module, used to fuse text semantic vector and similarity vector to obtain total features;

[0030] The text classification and evaluation module is used to input the total features into a text classifier to perform text classification and evaluate the classification accuracy.

[0031] Furthermore, the preprocessing module includes:

[0032] The text preprocessing submodule is used to preprocess the text and divide the text into word strings;

[0033] The label extraction and conversion submodule is used to extract event type labels and trigger words, and convert the event type labels into preset vectors;

[0034] The text semantic vector submodule is used to obtain the semantic vector of the text to be classified.

[0035] Furthermore, the similarity calculation module includes:

[0036] The word vector submodule is used to obtain the word vectors of trigger words and event types;

[0037] The similarity calculation submodule is used to calculate the similarity between words and construct a similarity vector.

[0038] Furthermore, the feature fusion module includes:

[0039] Dimensionality reduction submodule, used to reduce the features to the same dimension;

[0040] A weight calculation submodule is used to calculate the total weight for feature fusion based on the text semantic vector and the similarity vector;

[0041] Fusion submodule: The total feature is obtained by fusion of features based on the total weight obtained by the weight calculation submodule.

[0042] Furthermore, the text classification and evaluation module includes:

[0043] The text classifier builds a submodule based on the fused total features and inputs them into the text classifier;

[0044] The classification submodule classifies the text to be classified based on the text classifier constructed by the text classifier construction submodule;

[0045] Evaluation submodule, used to evaluate classification accuracy.

[0046] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:

[0047] The word similarity feature introduced in the present invention is beneficial to compensating the probability values ​​predicted by the pre-trained model for different event types in the classification output. For event types with high similarity to the trigger words, the probability value predicted as the event type can be improved by compensating the similarity vector, thereby improving the accuracy of text classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to make the purpose and technical solution of the present invention clearer, the present invention provides the following drawings and descriptions:

[0049] Figure 1 It is a flowchart of implementing the text classification method of the present invention;

[0050] Figure 2 A schematic diagram of a preprocessing module of a text classification system of the present invention;

[0051] Figure 3 A schematic diagram of a similarity module of a text classification system of the present invention;

[0052] Figure 4 It is a schematic diagram of a feature fusion module of a text classification system of the present invention;

[0053] Figure 5 A schematic diagram of a text classification and evaluation module of a text classification system of the present invention; DETAILED DESCRIPTION

[0054] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0055] The present invention provides a Chinese short text classification method and system based on word similarity. Figure 1 The implementation process of the text classification method of the present invention is shown, which is described in detail as follows:

[0056] S1: Use the preset event type set to segment the text to be classified, clean the data, extract labels, and obtain the one-hot form of the event trigger word and the event type label to which the text belongs.

[0057] In a specific embodiment, the text to be classified is processed by Chinese word segmentation, and the label is extracted and converted into a label in the form of a one-hot vector. For example, the text to be classified is "The price of the mobile phone has been reduced, 32 million pixels only cost one thousand yuan, and the cost performance is getting higher and higher." After word segmentation, {mobile phone, already, price reduction, pixels, one thousand yuan, cost performance, getting higher and higher} can be obtained. The label of the event type carried by the text is {Finance / Transaction-Price Reduction}, and the trigger word of the text is {Price Reduction}. For example, the predefined event types are {sale, financing, price reduction, listing, joining}, then the event type label can be converted into a one-hot vector, such as Finance / Transaction-Price Reduction can be converted into [0, 0, 1, 0, 0].

[0058] S2: Extract text features from the segmented text obtained in S1. First, use the encoder to encode the text to obtain the vector representation of the text, and then input the vector representation into the pre-trained model BERT for text semantic learning to obtain the text feature ω∈R bs×h , where b represents the number of samples, s represents the length of the sample sequence, and h represents the hidden layer dimension of the BERT model. The form of text features is:

[0059] where F i Represents the text features of the i-th sample.

[0060] F i The form is:

[0061] 768 is the hidden layer dimension of the BERT model. hCLS represents the text semantic vector of the entire sentence, which represents the sentence-level features, and hti represents the semantic vector corresponding to each word in the sentence, which represents the word-level features.

[0062] S3: The event trigger words and the preset event type set obtained in S1 are respectively vectorized using the pre-trained Word2Vec model to obtain their respective word vectors, and the similarity vectors between the event trigger words and the event type set are calculated using the word vectors. The vector similarity calculation is implemented based on the cosine similarity algorithm, where the calculation formula of the cosine similarity is:

[0063]

[0064] The similarity between the trigger word and the event type can be obtained through formula (5).

[0065] S4: Based on the text semantic vector and similarity vector obtained in steps S2 and S3, the two features are fused. First, the two feature vectors are converted to the same dimension, and then the two feature vectors are fused to obtain the final total feature used for classification.

[0066] In a specific embodiment, the text semantic vector is the text feature F i The first row vector is a vector of length 768 in the form of hCLS = [h1CLS, h2CLS, ..., hiCLS, ..., h768CLS], where hiCLS represents the output of the i-th dimension of the last hidden layer of the pre-trained model. The similarity vector is a vector of length 65 in the form of:

[0067] s=[s1,s2,…,si,…,s65]

[0068] Where si represents the similarity between the trigger word and the event type ei. The text semantic vector needs to be reduced to the same dimension as the similarity vector before feature fusion can be performed.

[0069] The feature dimensionality reduction method used is as follows:

[0070]

[0071]

[0072] The fusion used is based on the following formula:

[0073]

[0074] f G =Z G ·f' text +(1-Z G )·f' similar

[0075] Among them, sigmoid() represents the sigmoid activation function, W G , U G is the dimension reduction matrix, f' text is the text feature vector after dimensionality reduction, is the learnable similarity vector weight, where f' similari is the i-th similarity vector. G It is the total weight calculated based on the contribution of the two features, and is a number between 0 and 1. G ∈R b×n It is the total feature after fusion.

[0076] S5: Input the total features into the text classifier, classify the text to be classified, output the classification results, and evaluate the classification accuracy.

[0077] Figure 2-Figure 5 The module structure of the text classification system of the present invention is shown, including:

[0078] Preprocessing module: preprocesses training text and extracts features, the features are text semantic vectors. The preprocessing module includes: a text preprocessing submodule, which is used to preprocess text and segment text into word strings; a label extraction and conversion submodule, which is used to extract event type labels and trigger words, and convert event type labels into one-hot vectors; a text semantic vector submodule, which is used to obtain the semantic vector of the text to be classified.

[0079] Similarity module: used to obtain word vectors and calculate word similarity. The similarity calculation module includes: a word vector submodule, used to obtain word vectors of trigger words and event types; a similarity calculation submodule, used to calculate the similarity between words and construct a similarity vector.

[0080] Feature fusion module: used to fuse text semantic vectors with similarity vectors.

[0081] The feature fusion module includes: a dimensionality reduction submodule, which is used to reduce the features to the same dimension; a weight calculation submodule, which is used to calculate the total weight for feature fusion based on the text semantic vector and similarity features; and a fusion submodule: feature fusion is performed based on the total weight obtained by the weight calculation submodule.

[0082] Text classification and evaluation module: used to build a text classifier and classify the text to be classified. It includes the following submodules: Text classifier construction submodule: construct a text classifier according to the actual task requirements. In a specific embodiment, the number of classification categories is 65, and the text classifier is designed based on this; the classification submodule, based on the text classifier constructed by the text classifier construction submodule, classifies the text to be classified; the evaluation submodule is used to evaluate the classification accuracy of the network. In a specific embodiment, the classifier prediction result is first converted into a one-hot vector, and then the converted prediction result is compared with the true label of the sample. If the predicted label is the same as the true label, it is recorded as a correct prediction, otherwise it is recorded as an incorrect prediction. The final accuracy is obtained by predicting all test samples. If the prediction result of the i-th test sample is P i =[0,0,1,0,0], its true label is T i =[0,1,0,0,0], the predicted result is different from the true label, which is recorded as a prediction error. Finally, the prediction accuracy of the classifier on the test set is Where n represents the number of samples, (P i =T i ) indicates whether the predicted result is the same as the true label. If the same (P i =T i ) is 1 if the value is not set, otherwise it is 0.

[0083] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.

Claims

1. A Chinese short text classification method based on word similarity, characterized in that: The steps include: S1: Use the preset event type set to segment the text to be classified, clean the data, extract the label, and obtain the preset vector form of the event trigger word and the event type label to which the text belongs; S2: Extract text features from the segmented text obtained in S1 to obtain a text semantic vector; S3: The event trigger words and the preset event type set obtained in S1 are vectorized using a pre-trained natural language processing model to obtain respective word vectors, and the similarity vector between the event trigger words and the event type set is calculated using the word vectors; S4: Fuse the text semantic vector obtained in S2 with the similarity vector obtained in S3 to obtain the final total feature used for classification; S5: Input the total features into the text classifier, classify the text to be classified, output the classification results, and evaluate the classification accuracy.

2. A Chinese short text classification method based on word similarity according to claim 1, characterized in that: The specific method of text feature extraction in step S2 is: S2.1: Encode the segmented text obtained in step S1 using an encoder to obtain representation vectors of the text, which are word vectors, segment vectors, and position vectors; S2.2: Input the word vector, segment vector and position vector into the pre-trained model BERT to perform text semantic learning and obtain text features. The text features include the text semantic vector of the entire sentence and the semantic vector corresponding to each word.

3. The Chinese short text classification method based on word similarity according to claim 1 is characterized in that: In step S3, the natural language processing model adopts the Word2Vec model.

4. The Chinese short text classification method based on word similarity according to claim 1 is characterized in that: In step S3, the similarity vector between the event trigger word and the event type set is calculated using a cosine similarity algorithm.

5. The Chinese short text classification method based on word similarity according to claim 1 is characterized in that: In step S4, the text semantic vector obtained in S2 and the similarity vector obtained in S3 are merged, which specifically includes: S4.1: Convert text semantic vector and similarity vector to the same dimension; S4.2: Calculate the total weight for feature fusion based on the vector after dimension conversion; S4.3: Calculate the fused total feature according to the dimensionally converted vector and the total weight.

6. The Chinese short text classification method based on word similarity according to claim 1 is characterized in that: The specific steps of step S5 are: S5.1: Input the total features obtained in step S4 into the text classifier; S5.2: Classify the text to be classified using the text classifier to obtain a predicted label; S5.3: Encode the predicted label by using a label encoder to obtain a preset vector of the predicted label; S5.4: Perform classification evaluation using the preset vector obtained from the event type label to which the text belongs and the preset vector of the predicted label to obtain the accuracy rate.

7. A Chinese short text classification system based on word similarity, used to implement the Chinese short text classification method based on word similarity according to any one of claims 1 to 6, characterized in that: include: A preprocessing module is used to segment the text to be classified, extract the label, convert the label into a preset vector form and extract the text semantic vector; A similarity module is used to calculate the word similarity vector between the trigger word and the predefined event type; Feature fusion module, used to fuse text semantic vector and similarity vector to obtain total features; The text classification and evaluation module is used to input the total features into a text classifier to perform text classification and evaluate the classification accuracy.

8. A Chinese short text classification system based on word similarity according to claim 7, characterized in that: The preprocessing module comprises: The text preprocessing submodule is used to preprocess the text and divide the text into word strings; The label extraction and conversion submodule is used to extract event type labels and trigger words, and convert the event type labels into preset vectors; The text semantic vector submodule is used to obtain the semantic vector of the text to be classified.

9. The Chinese short text classification system based on word similarity according to claim 7, characterized in that: The similarity calculation module comprises: The word vector submodule is used to obtain the word vectors of trigger words and event types; The similarity calculation submodule is used to calculate the similarity between words and construct a similarity vector.

10. The Chinese short text classification system based on word similarity according to claim 7, characterized in that: The feature fusion module includes: Dimensionality reduction submodule, used to reduce the features to the same dimension; A weight calculation submodule is used to calculate the total weight for feature fusion based on the text semantic vector and the similarity vector; The fusion submodule performs feature fusion according to the total weight obtained by the weight calculation submodule to obtain the total feature.

Citation Information

Patent Citations

  • Text classification method and device, electronic equipment and computer readable storage medium

    CN111753079A

  • Multi-label text classification method and system based on dynamic weight contrast learning

    CN114580433A

  • Text classification method and device based on multi-semantic feature fusion

    CN117271765A

  • Methods and apparatuses for training service model and determining text classification category

    US11216620B1

Cited By

  • Semantic dependency analysis-based event extraction method, event extraction framework and system

    CN120337930A

  • An event extraction method, event extraction framework and system based on semantic dependency analysis

    CN120337930B