Event classification method, electronic equipment and computer readable storage medium

By generating and fusing the keyword eigenvectors and semantic eigenvectors of events and optimizing and cleaning in softmax multi-classification model, the problem of event classification error in the prior art is solved, and the accuracy and efficiency of classification are improved.

CN119150148AInactive Publication Date: 2024-12-17CETC NEW SMART CITY RES INST CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411620818.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2024-12-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When processing event data with similar semantics but different classification labels, existing event classifiers ignore the sparse characteristics of keywords, resulting in classification errors and it is difficult to accurately grasp the essence of events.

Method used

By collecting event data, keyword eigenvectors and semantic eigenvectors are generated, and fusion and optimization are carried out based on softmax multi-classification model, and cleaning and retraining are combined with confidence learning to improve classification accuracy.

Benefits of technology

It improves the accuracy and efficiency of event classification, can more effectively identify and fuse sparse keywords and dense semantic features, and reduces classification errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150148A_ABST
    Figure CN119150148A_ABST
Patent Text Reader

Abstract

The invention provides an event classification method, electronic equipment and a computer readable storage medium. The method comprises the following steps: collecting event data, wherein the event data comprises a plurality of events and corresponding manual labeling class labels; the event data is preprocessed; based on the preprocessed event data, generating a keyword feature vector of the event data; based on the preprocessed event data, generating a semantic feature vector of the event data; fusing the keyword feature vector and the semantic feature vector to obtain a fused feature vector; a softmax multi-classification model is trained and optimized on the basis of the fused feature vectors and the manual annotation class labels; and performing event classification based on the softmax multi-classification model to obtain a prediction class label of the event.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of event classification, and in particular to an event classification method, an electronic device, and a computer-readable storage medium. Background Art

[0002] There are a lot of cases in event data with similar semantics but different classification labels. The classification of these data depends not only on the semantic description of the appeal, but also on the significant influence of specific keywords. However, most event classifiers are based on semantic training, ignoring the sparse features of these keywords, which makes it difficult for classifiers to accurately grasp the essence of events in practical applications, resulting in classification errors. Summary of the invention

[0003] Embodiments of the present application provide an event classification method, an electronic device, and a computer-readable storage medium.

[0004] In a first aspect, an embodiment of the present application provides an event classification method, the method comprising: Collect event data, which includes multiple events and corresponding manually annotated class labels; Preprocess event data; Based on the preprocessed event data, generate a keyword feature vector of the event data; Based on the preprocessed event data, a semantic feature vector of the event data is generated; Fusing the keyword feature vector and the semantic feature vector to obtain a fused feature vector; Based on the fused feature vectors and manually annotated class labels, train and optimize the softmax multi-classification model; Event classification is performed based on the softmax multi-classification model to obtain the predicted class label of the event.

[0005] Optionally, based on the preprocessed event data, generating a keyword feature vector of the event data includes: Based on the term frequency-inverse document frequency TF-IDF algorithm, keywords are extracted from the preprocessed event data, and the top three words with the TF-IDF value of each event are obtained as keywords for each event; Generate a keyword vector for each event as the keyword feature vector for each event.

[0006] Optionally, generating a keyword vector for each event includes: Generate a vector for each keyword of each event based on the pre-trained word2vec model; The vectors of all keywords of each event are weighted to obtain the keyword vector of each event.

[0007] Optionally, based on the preprocessed event data, generating a semantic feature vector of the event data includes: The fine-tuned BERT model generates a hidden state vector for each event as the semantic feature vector of each event.

[0008] Optionally, the keyword feature vector and the semantic feature vector are fused to obtain a fused feature vector including: Based on a first linear mapping function, the keyword feature vector and the semantic feature vector are mapped to the same dimension, and the parameters of the first linear mapping function are optimized based on the training of the softmax multi-classification model; Based on the attention network, the attention weights of the keyword feature vector and the semantic feature vector mapped to the same dimension are calculated. The parameters of the attention network are optimized based on the training of the softmax multi-classification model. Based on the attention weight, the keyword feature vector and the semantic feature vector mapped to the same dimension are fused into one vector.

[0009] Optionally, the training and optimization of the softmax multi-classification model is performed based on the first cross entropy loss function, which is determined based on the following formula: , in is the cross entropy loss, is the total number of events, For the The real class label of the event, the real class label is the manually annotated class label that has been verified, For the The predicted class label of an event.

[0010] Optionally, the optimization of the softmax multi-classification model is also based on confidence learning. Confidence learning is used to clean the training samples of the softmax multi-classification model. The cleaned training samples are used to retrain the softmax multi-classification model. Confidence learning cleans the training samples including: Based on the trained softmax multi-classification model, the training samples are cross-validated to obtain the maximum probability class label of the events in the training samples. Among all class labels, the probability of the event under the maximum probability class label is the highest. Filter out events in the training samples whose manually annotated class labels are different from the maximum probability class label.

[0011] In a second aspect, an embodiment of the present application provides an electronic device, including: A collection module is used to collect event data, which includes multiple events and corresponding manually annotated class labels; A preprocessing module, used for preprocessing event data; A first generating module, used to generate a keyword feature vector of the event data based on the preprocessed event data; A second generating module, used for generating a semantic feature vector of the event data based on the preprocessed event data; A fusion module is used to fuse the keyword feature vector and the semantic feature vector to obtain a fused feature vector; The training and optimization module is used to train and optimize the softmax multi-classification model based on the fused feature vectors and manually annotated class labels; The classification module is used to classify events based on the softmax multi-classification model and obtain the predicted class label of the event.

[0012] Optionally, the first generating module includes: An extraction module is used to extract keywords from the preprocessed event data based on the term frequency-inverse document frequency TF-IDF algorithm, and obtain the top three words with the TF-IDF value of each event as the keywords of each event; The first vector module is used to generate a keyword vector for each event as a keyword feature vector for each event.

[0013] Optionally, the first vector module includes: The first module is used to generate the vector of each keyword of each event based on the pre-trained word2vec model; The second module is used to weight the vectors of all keywords of each event to obtain the keyword vector of each event.

[0014] Optionally, the second generation module includes: The second vector module is used to generate a hidden state vector for each event based on the fine-tuned BERT model as the semantic feature vector of each event.

[0015] Optionally, the fusion module includes: A mapping module, used for mapping the keyword feature vector and the semantic feature vector to the same dimension based on a first linear mapping function, wherein the parameters of the first linear mapping function are optimized based on the training of a softmax multi-classification model; The attention module is used to calculate the attention weights of the keyword feature vector and the semantic feature vector after being mapped to the same dimension based on the attention network. The parameters of the attention network are optimized based on the training of the softmax multi-classification model. The third vector module is used to fuse the keyword feature vector and the semantic feature vector mapped to the same dimension into one vector based on the attention weight.

[0016] Optionally, the training and optimization of the softmax multi-classification model is performed based on the first cross entropy loss function, which is determined based on the following formula: , in is the cross entropy loss, is the total number of events, For the The real class label of the event, the real class label is the manually annotated class label that has been verified, For the The predicted class label of an event.

[0017] Optionally, the optimization of the softmax multi-classification model is also performed based on confidence learning, and the confidence learning is used to clean the training samples of the softmax multi-classification model, and the cleaned training samples are used to retrain the softmax multi-classification model. The electronic device also includes a confidence learning module, and the confidence learning module is used to: Based on the trained softmax multi-classification model, the training samples are cross-validated to obtain the maximum probability class label of the events in the training samples. Among all class labels, the probability of the event under the maximum probability class label is the highest. Filter out events in the training samples whose manually annotated class labels are different from the maximum probability class label.

[0018] In a third aspect, an embodiment of the present application provides an electronic device comprising a memory, at least one processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, a method as described in any one of the above-mentioned first aspects is implemented.

[0019] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method as described in any one of the above-mentioned first aspects is implemented.

[0020] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes any one of the methods described in the first aspect.

[0021] Based on this application, sparse keyword features and dense semantic features in events can be extracted and fused respectively, and the softmax multi-classification model can be trained and optimized based on the fused features and manually annotated class labels, which helps to improve the accuracy and efficiency of event classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for describing the embodiments are briefly introduced below.

[0023] Figure 1 It is a flow chart of the event classification method provided in the embodiment of the present application.

[0024] Figure 2 This is an example diagram of the event classification method provided in the embodiment of the present application.

[0025] Figure 3 It is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application.

[0026] Figure 4 It is a structural schematic diagram of an electronic device provided in another embodiment of the present application. DETAILED DESCRIPTION

[0027] The technical solution of the embodiment of the present application will be described below in conjunction with the drawings in the embodiment of the present application.

[0028] There are a lot of cases in event data with similar semantics but different classification labels. The classification of these data depends not only on the semantic description of the appeal, but also on the significant influence of specific keywords. These keywords are often highly indicative and can determine the classification results of events to a certain extent. However, most event classifiers are based on semantic training, ignoring the sparse features of these keywords, which makes it difficult for classifiers to accurately grasp the essence of events in practical applications, resulting in classification errors.

[0029] In past research and practice, although semantic-based training methods have improved the efficiency of event classification to a certain extent, their neglect of the sparse features of keywords makes it difficult for classifiers to achieve accurate classification when faced with complex and changeable events. For example, it is difficult for classifiers to distinguish events that are semantically similar but do not belong to the same category. This limitation is mainly reflected in two aspects: first, the classifier cannot effectively identify keywords that play a decisive role in the classification results; second, even if these keywords are identified, they cannot be effectively integrated with semantic features, which in turn affects the accuracy of classification.

[0030] Based on this, Figure 1 An event classification method is provided according to an embodiment of the present application, and the method includes steps S110-S170.

[0031] In step S110, event data is collected, and the event data includes multiple events and corresponding manually annotated class labels. For example, event text and manually annotated class labels can be collected from the Internet, and the class labels can be used to indicate the classification of events. The present application does not limit the events, for example, they can be social events, and the classification of social events can include resident service facilities, urban public facilities, landscaping and sanitation, etc. It should be noted that the classification scope of the class label may not be limited. For example, the class label can be classified in a small range, so that events with similar semantics can have different class labels. The event text here refers to the text that describes the event. The manually annotated class label refers to the original class label manually assigned to the event. The same event may have one or more manually annotated class labels.

[0032] Optionally, the collected event data may constitute an event data set, and the event data set may be constructed into a training set and a test set in a certain ratio, for example, in a ratio of 8:2.

[0033] In step S120, the event data is preprocessed. The purpose of preprocessing is to ensure the integrity, accuracy and consistency of the data. The preprocessing of the event data may include data cleaning and text preprocessing.

[0034] Data cleaning can be used to remove duplicate data to ensure the uniqueness of event data in the event data set. Data cleaning can also be used to process events that are missing manually annotated class labels (hereinafter referred to as missing samples) to ensure the integrity of event data in the event data set. For example, when the missing samples account for a small proportion of the event data set, the missing samples can be directly deleted. Conversely, when the missing samples account for a large proportion of the event data set, the relevant large model technology can be used to filter out the most relevant class labels for filling.

[0035] Text preprocessing can make the text of events in the event dataset meet the requirements of subsequent processing. The text preprocessing method is not limited. As an example, the original event text can be segmented, stop words and punctuation can be removed, etc. As another example, the original event text can also be converted into a format that can be understood by the relevant model, such as tokenization and adding special characters (such as [cls] and [sep]) to the original event text.

[0036] Tokenization is to divide the text sentence into sub-units and then digitize the sub-units, that is, map them into vectors that the model can recognize. The special characters [cls] and [sep] are special tokens that can be used to indicate the beginning and end of a sentence, or to separate them when processing multiple sentences.

[0037] In step S130, a keyword feature vector of the event data is generated based on the preprocessed event data. The keyword feature vector of the event data can be generated based on the keywords of the event data, and the keywords of the event data can be generated based on the event text.

[0038] Optionally, based on the preprocessed event data, generating a keyword feature vector for the event data may include: performing keyword extraction on the preprocessed event data based on a term frequency-inverse document frequency (TF-IDF) algorithm to obtain the top three words with the TF-IDF value of each event as the keywords of each event; and generating a keyword vector for each event as the keyword feature vector for each event.

[0039] TF-IDF is a commonly used weighting technology for information retrieval and data mining, and is often used to mine keywords in texts. TF-IDF has two meanings, one is "term frequency" (TF), and the other is "inverse document frequency" (IDF). Among them, term frequency can be used to describe the frequency of a word appearing in a text, which can be determined based on formula (1). The definition of inverse document frequency is the logarithm of the ratio of the total number of texts to the text frequency of a word, which can be determined based on formula (2). TF-IDF is the product of term frequency and inverse document frequency, as shown in formula (3).

[0040] (1), (2), (3).

[0041] TF-IDF is an indicator to measure the importance of a word. The TF-IDF of all words in the text is sorted. The larger the TF-IDF of a word, the higher the weight, which means that the word is more important to the text. Therefore, you can select the words with the highest TF-IDF value as the keywords of the text.

[0042] It should be noted that the keywords of events with different class labels are quite different. Therefore, when extracting keywords for events based on TF-IDF, keyword extraction can be performed separately for events with different class labels. For example, if the class labels of events include the first class and the second class, TF-IDF can be used to uniformly extract keywords for all events in the first class, and TF-IDF can be used to uniformly extract keywords for all events in the second class.

[0043] Optionally, generating the keyword vector for each event may include: generating a vector for each keyword for each event based on a pre-trained word2vec model; and weighting the vectors of all keywords for each event to obtain the keyword vector for each event.

[0044] The ‌word2vec‌ model is a toolkit for obtaining word vectors. It can encode words into vectors by considering the context of the words, thereby reflecting more semantic information. The word2vec‌ model can be pre-trained based on the number of pre-processed events, and the pre-training method is not limited.

[0045] For each event, the pre-trained word2vec model can vectorize the three keywords extracted based on TF-IDF to obtain three keyword vectors. The three keyword vectors can be weighted to generate a vector to obtain the final keyword vector. The weighting method is not limited, for example, weighting can be performed using a weighted average algorithm.

[0046] Continue to see Figure 1 In step S140, a semantic feature vector of the event data is generated based on the preprocessed event data. The semantic feature vector of the event data can be used to reflect the semantic features of the event, and the semantic feature vector of the event data can be generated based on the event text.

[0047] Optionally, based on the preprocessed event data, generating a semantic feature vector of the event data may include: generating a hidden state vector of each event based on a fine-tuned bidirectional encoder representations from transformers (BERT) model as the semantic feature vector of each event.

[0048] The BERT model is a transformer-based pre-training model that is mainly used for language representation. It can generate deep bidirectional language representation through a new training strategy, emphasizing that it is no longer pre-trained like traditional unidirectional models, but adopts a bidirectional encoding method to better understand the contextual information of the language.

[0049] The pre-trained BERT model is not suitable for all application scenarios, so it needs to be fine-tuned. Fine-tuning the BERT model can be achieved by adding an additional output layer to the pre-trained BERT model and then training it with task-specific data.

[0050] As an example, the pre-trained BERT model can be the BERT Chinese pre-trained model (BERT-base-chinese). The fine-tuning of the BERT-base-chinese model can be done by adding a softmax layer on top of the model, and then training the model based on the training set and test set in the event dataset, using the cross entropy loss function as the model's loss function until the results converge. Among them, the softmax layer can be used to calculate the probability of event data under different class labels.

[0051] After fine-tuning, the BERT-base-chinese model can take the preprocessed event text as input. After processing by the model, a hidden state vector can be output for each input token of the event text as the semantic feature vector of the event text. The input token here refers to the token of each word in the text generated after the event text is input into the BERT-base-chinese model.

[0052] The hidden state vector is a vector calculated by the model based on the current input and the previous hidden state when processing the input at each time step. Each hidden state vector contains information about all previous inputs, which can help the model take context into account when processing the current input. BERT's hidden layer state vector is often used as a feature representation to input into various machine learning models. For example, in a text classification task, the vector of the first token (usually the [CLS] tag) of the last layer hidden state vector of BERT can be used as the semantic feature vector of the entire sentence, and then input into the classifier for classification.

[0053] It should be noted that before generating the semantic feature vector and before generating the feature word feature vector, the event data can be preprocessed differently. As an example, before generating the semantic feature vector and before generating the feature word feature vector, the event data can be processed differently. For example, before generating the semantic feature vector, the text of the event can be converted into a format that can be understood by the BERT-base-chinese model, including tokenization and adding special characters (such as [cls] and [sep]). For another example, before generating the feature word feature vector, the text of the event can be processed by word segmentation, removal of stop words and punctuation marks, etc.

[0054] In step S150, the keyword feature vector and the semantic feature vector are fused to obtain a fused feature vector. The keywords of the text belong to sparse features, and the semantic features of the text belong to dense features. Therefore, the vector obtained by fusion of the keyword feature vector and the semantic feature vector can simultaneously reflect the sparse features and dense features of the text.

[0055] Optionally, fusing the keyword feature vector and the semantic feature vector to obtain a fused feature vector may include: based on a first linear mapping function, mapping the keyword feature vector and the semantic feature vector to the same dimension; based on an attention network, calculating the attention weights of the keyword feature vector and the semantic feature vector mapped to the same dimension; based on the attention weights, fusing the keyword feature vector and the semantic feature vector mapped to the same dimension into one vector.

[0056] For the same event, the dimensions of the keyword feature vector and the semantic feature vector may be different, so the two vectors need to be mapped to the same dimension before fusion. Usually, the mapping of vectors can be completed by a linear mapping function.

[0057] As an example, the mapping of vectors can be achieved by a fully connected layer in a classification model. The fully connected layer can apply a linear function to linearly map the input of the model.

[0058] For the same event, the influence weights of keyword features and semantic features on the class label of the event may also be different. Therefore, before fusing the two vectors, the weights of the two vectors need to be considered. As an example, an attention network can be introduced to calculate the importance of the two features. Exemplarily, the attention network can be implemented by activating the sigmoid function. After considering the attention weights of the two vectors, the two feature vectors can be fused based on the attention weights of the two vectors.

[0059] It is worth noting that the sigmoid function and the first linear mapping function include several parameters, which can be initialized when two feature vectors are fused, and the parameters can be optimized when the model is trained based on the fused feature vector later.

[0060] In step S160, based on the fused feature vector and the manually annotated class label, the softmax multi-classification model is trained and optimized. That is, the feature vector of the event and the corresponding manually annotated class label can be used as the input of the softmax multi-classification model, and the probability of each event under different class labels can be determined based on the output of the softmax multi-classification model. When the probability of an event under a certain class label is the largest, the class label is the predicted class label of the event.

[0061] As mentioned above, the event dataset can be used to construct a training set and a test set in a certain ratio. The training set can be used to train the softmax multi-classification model, and the test set can be used to optimize the model training. It is worth noting that the parameters of the first linear mapping function can be optimized based on the training of the softmax multi-classification model, and the parameters of the attention network can also be optimized based on the training of the softmax multi-classification model.

[0062] Optionally, the training and optimization of the softmax multi-classification model can be performed based on the first cross entropy loss function, and the first cross entropy loss function can be determined based on formula (4).

[0063] (4), in is the cross entropy loss, is the total number of events, For the The real class label of the event, the real class label is the manually annotated class label that has been verified, For the The verified manually labeled class labels here refer to the correction of errors in the manually labeled class labels to ensure that the manually labeled class labels of each event are correct.

[0064] It is worth noting that when training the softmax multi-classification model, a certain learning rate can be set, and the gradient descent method can be used to iteratively find the optimal parameters. When the loss value of the first cross entropy loss function is less than a certain threshold or the number of iterations is reached, the model training can be stopped and the model can be saved.

[0065] Optionally, the optimization of the softmax multi-classification model can also be performed based on confidence learning. Confidence learning can be used to clean the training samples of the softmax multi-classification model, and the cleaned training samples can be used to retrain the softmax multi-classification model.

[0066] Since there are many interference items with incorrect labels in the training samples, after the model training is completed, the data in the training set can be further cleaned based on confidence learning to improve the accuracy of the training data samples.

[0067] Confidence learning can clean training samples by: cross-validating training samples based on the trained softmax multi-classification model, obtaining the maximum probability class label of events in the training samples, and filtering events in the training samples whose manually labeled class labels are different from the maximum probability class label. The filtered training samples can be used to retrain the softmax multi-classification model to improve the accuracy of the softmax multi-classification model.

[0068] It is worth noting that the training samples here refer to the training set mentioned above. Based on the results of cross-validation of the training samples, the probability of each event under different class labels can be determined. When the probability of an event under a certain class label is the maximum probability among all class labels, the class label is the maximum probability class label of the event.

[0069] Optionally, a confidence threshold for the maximum probability class label of an event can be set. For example, the average probability of each event under a certain class label determined based on the manually labeled labels can be used as the confidence threshold for the class label as the maximum probability class label. When the probability of an event under its maximum probability class label is greater than or equal to the average probability of each event under the maximum probability class label, the maximum probability class label of the event can be considered accurate. However, when the probability of an event under its maximum probability class label is less than the average probability of each event under the maximum probability class label, the maximum probability class label of the event can be considered inaccurate, and the sample of the event can be directly discarded.

[0070] In step S170, event classification is performed based on the softmax multi-classification model to obtain a predicted class label of the event.

[0071] Based on this application, sparse keyword features and dense semantic features in events can be extracted and fused respectively, and the softmax multi-classification model can be trained and optimized based on the fused features and manually annotated class labels, which helps to improve the accuracy and efficiency of event classification.

[0072] Combine the following Figure 2 , the event classification method of the embodiment of the present application is introduced by examples.

[0073] like Figure 2 As shown, the method includes steps S201-S215.

[0074] In step S201, event data is collected, including event text and corresponding manually annotated class labels, to obtain an event data set.

[0075] In step S202, the event data is preprocessed, and the preprocessing includes data cleaning and text preprocessing. Among them, data cleaning includes removing duplicate data and processing missing values. Text preprocessing for keyword feature extraction includes word segmentation, removal of stop words and punctuation marks, and text preprocessing for semantic feature extraction includes converting the text of the event into a format that can be understood by the BERT model, including tokenization and adding special characters (such as [cls] and [sep]). It is worth noting that the preprocessing for semantic feature extraction and the preprocessing for keyword extraction are performed on all event data that have undergone data cleaning.

[0076] In step S203, the event data set is used to construct a training set and a test set in a ratio of 8:2.

[0077] In step S204, TF-IDF is used to extract keywords from event data with different manually labeled labels, and the top three words with the highest TF-IDF value for each piece of data are obtained as keywords extracted from the data.

[0078] In step S205, a word2vec model is trained based on the event data and the corresponding keywords for generating keyword vectors.

[0079] In step S206, the three keyword vectors of each event data are weighted by a weighted average algorithm to obtain a keyword feature vector of each event data, which is set as .

[0080] In step S207, the BERT-base-chinese model is fine-tuned. The event data and the corresponding manually annotated class label data are used as training and test samples, the pre-trained model BERT-base-chinese and its weight parameters are loaded, and a softmax layer is added on top of the model to calculate the probability of each category. The cross entropy loss function is used as the loss function of the model until the results converge.

[0081] In step S208, the preprocessed event text is input into the fine-tuned BERT-base-chinese model, and the last hidden layer output of the [CLS] tag in the model output is taken as the semantic feature vector of the sentence, set to .

[0082] In step S209, a linear mapping function is used. Will and Map to the same dimension , which can be achieved through a fully connected layer, and The mapping results can be shown as formula (5) and formula (6).

[0083] (5), (6), in and is the weight matrix, and is the bias term.

[0084] In step S210, an attention network is defined To calculate the attention weight of each feature, the attention network It can be shown as formula (7).

[0085] (7), in is the activation function sigmoid function, is the weight matrix, is the bias term.

[0086] In step S211, the attention weight is used to fuse the two feature vectors, and the fused feature vector can be shown as formula (8).

[0087] (8), Where F is the fused feature, The fused feature vector is calculated The importance of The fused feature vector is calculated The importance of.

[0088] In step S212, the event data in the training set and the prediction set are used to train and optimize the softmax multi-classification model, where the input of the softmax multi-classification model is the fused features of the event data. and manually annotated class labels.

[0089] The training and optimization of the softmax multi-classification model can be performed based on the cross-entropy loss function. The cross-entropy loss function can measure the difference between the class label predicted by the softmax multi-classification model and the true class label. The cross-entropy loss function can be expressed as formula (9).

[0090] (9), in is the total number of events, is the true class label, is the predicted class label, where the true class label is the manually annotated class label after review.

[0091] It should be noted that when starting to train the softmax multi-classification model, the features of the softmax multi-classification model are input The parameters in (weight matrix , , and the bias term , , ) is randomly initialized and the learning rate of the model is During the model training process, the gradient descent method is used to iteratively find the optimal parameters. When the loss value of the loss function is less than the set threshold or the number of iterations is reached, the model training is stopped and the model is saved.

[0092] In step S213, the first version of the model that has been trained is used to perform cross-validation on the training set to obtain the maximum probability class label for each event data. Specifically, the first The sample in The probability of the category , The confidence interval for each manually annotated class label The average probability of Finally, for the sample , its maximum probability class label for The maximum probability among the categories ,and .

[0093] In step S214, select The subscript corresponding to the maximum probability Samples that are inconsistent with the manually annotated labels are filtered as error samples, that is, events in which the manually annotated class labels in the training samples are different from the maximum probability class labels are filtered.

[0094] In step S215, the softmax multi-classification model is retrained based on the filtered training set.

[0095] exist Figure 2 In the method shown, by fusing the dense semantic features and sparse keyword features of events, events can be more accurately identified and classified, thereby improving the accuracy of classification.

[0096] The method provided in the embodiment of the present application is described in detail above. The device provided in the embodiment of the present application is described in detail below with reference to the accompanying drawings.

[0097] See also Figure 3 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 3 The electronic device 300 shown may include a collection module 310 , a preprocessing module 320 , a first generation module 330 , a second generation module 340 , a fusion module 350 , a training and optimization module 360 ​​, and a classification module 370 .

[0098] The collection module 310 may be used to collect event data, and the event data may include multiple events and corresponding manually annotated class labels; The preprocessing module 320 may be used to preprocess event data; The first generating module 330 may be used to generate a keyword feature vector of the event data based on the preprocessed event data; The second generating module 340 may be used to generate a semantic feature vector of the event data based on the preprocessed event data; The fusion module 350 may be used to fuse the keyword feature vector and the semantic feature vector to obtain a fused feature vector; The training and optimization module 360 ​​can be used to train and optimize the softmax multi-classification model based on the fused feature vectors and the manually annotated class labels; The classification module 370 can be used to classify events based on a softmax multi-classification model to obtain a predicted class label of the event.

[0099] Optionally, the first generating module 330 may include an extracting module and a first vector module.

[0100] The extraction module can be used to extract keywords from the preprocessed event data based on the term frequency-inverse document frequency TF-IDF algorithm, and obtain the top three words with the TF-IDF value of each event as the keywords of each event; The first vector module may be used to generate a keyword vector for each event as a keyword feature vector for each event.

[0101] Optionally, the first vector module may include a first module and a second module.

[0102] The first module can be used to generate a vector for each keyword of each event based on a pre-trained word2vec model; The second module can be used to weight the vectors of all keywords of each event to obtain the keyword vector of each event.

[0103] Optionally, the second generation module 340 may include a second vector module, which may be used to generate a hidden state vector of each event based on the fine-tuned BERT model as a semantic feature vector of each event.

[0104] Optionally, the fusion module 350 may include a mapping module; an attention module and a third vector module.

[0105] The mapping module may be used to map the keyword feature vector and the semantic feature vector to the same dimension based on a first linear mapping function, wherein parameters of the first linear mapping function are optimized based on training of a softmax multi-classification model; The attention module can be used to calculate the attention weights of the keyword feature vector and the semantic feature vector mapped to the same dimension based on the attention network. The parameters of the attention network are optimized based on the training of the softmax multi-classification model. The third vector module can be used to merge the keyword feature vector and the semantic feature vector mapped to the same dimension into one vector based on the attention weight.

[0106] Optionally, the training and optimization of the softmax multi-classification model can be performed based on the first cross entropy loss function, which can be determined based on the following formula: , in is the cross entropy loss, is the total number of events, For the The real class label of the event, the real class label is the manually annotated class label that has been verified, For the The predicted class label of an event.

[0107] Optionally, the optimization of the softmax multi-classification model can also be performed based on confidence learning. Confidence learning can be used to clean the training samples of the softmax multi-classification model. The cleaned training samples can be used to retrain the softmax multi-classification model. The electronic device can also include a confidence learning module. The confidence learning module can be used to: based on the trained softmax multi-classification model, cross-validate the training samples to obtain the maximum probability class label of the events in the training samples, and the probability of the event under the maximum probability class label is the highest among all class labels; filter out events in the training samples whose manually labeled class labels are different from the maximum probability class labels.

[0108] The present application also provides an electronic device. Figure 4 As shown, the electronic device 400 includes: at least one processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the at least one processor 401. When the processor 401 executes the computer program 403, the method provided in the present application is implemented.

[0109] Exemplarily, the computer program 403 may be divided into one or more modules / units, one or more modules / units are stored in the memory 402, and executed by the processor 401 to complete the present application. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device 400.

[0110] Those skilled in the art will understand that Figure 4 It is only an example of the electronic device 400 and does not constitute a limitation of the electronic device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 400 may also include input and output devices, network access devices, buses, etc.

[0111] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0112] The memory 402 may be an internal storage unit of the electronic device 400, such as a hard disk or memory of the electronic device 400. The memory 402 may also be an external storage device of the electronic device 400, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 400. Further, the memory 402 may also include both an internal storage unit of the electronic device 400 and an external storage device. The memory 402 is used to store computer programs and other programs and data required by the electronic device 400. The memory 402 may also be used to temporarily store data that has been output or is to be output.

[0113] The electronic device 400 provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0114] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0115] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0116] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above method embodiments, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above method embodiments can be implemented. Among them, the computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / electronic device, recording medium, computer memory, ROM (read-only memory), RAM (random access memory), CD-ROM (compact disc read-only memory), magnetic tape, floppy disk and optical data storage device. The computer-readable storage medium mentioned in the present application can be a non-volatile storage medium, in other words, it can be a non-transient storage medium.

[0117] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0118] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0119] In the embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0120] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0121] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0122] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0123] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. An event classification method, characterized in that: include: Collecting event data, wherein the event data includes a plurality of events and corresponding manually annotated class labels; Preprocessing the event data; Based on the preprocessed event data, generating a keyword feature vector of the event data; Based on the preprocessed event data, generating a semantic feature vector of the event data; Fusing the keyword feature vector and the semantic feature vector to obtain a fused feature vector; Based on the fused feature vector and the manually annotated class label, training and optimizing a softmax multi-classification model; Event classification is performed based on the softmax multi-classification model to obtain a predicted class label of the event.

2. The method according to claim 1, characterized in that The generating a keyword feature vector of the event data based on the preprocessed event data includes: Perform keyword extraction on the preprocessed event data based on the term frequency-inverse document frequency (TF-IDF) algorithm, and obtain the top three words with the TF-IDF value of each event as keywords of each event; Generate a keyword vector for each of the events as a keyword feature vector for each of the events.

3. The method according to claim 2, characterized in that Generating a keyword vector for each event includes: Generate a vector for each of the keywords of each of the events based on a pre-trained word2vec model; The vectors of all the keywords of each of the events are weighted to obtain a keyword vector of each of the events.

4. The method according to claim 3, characterized in that: The generating a semantic feature vector of the event data based on the preprocessed event data comprises: A hidden state vector of each of the events is generated based on the fine-tuned BERT model as a semantic feature vector of each of the events.

5. The method according to claim 4, characterized in that The fusing of the keyword feature vector and the semantic feature vector to obtain a fused feature vector includes: Based on a first linear mapping function, mapping the keyword feature vector and the semantic feature vector to the same dimension, wherein parameters of the first linear mapping function are optimized based on the training of the softmax multi-classification model; Based on the attention network, the attention weights of the keyword feature vector and the semantic feature vector mapped to the same dimension are calculated, and the parameters of the attention network are optimized based on the training of the softmax multi-classification model; Based on the attention weight, the keyword feature vector and the semantic feature vector mapped to the same dimension are fused into one vector.

6. The method according to claim 5, characterized in that The training and optimization of the softmax multi-classification model are performed based on a first cross entropy loss function, which is determined based on the following formula: , It is stated is the cross entropy loss, is the total number of events, For the The real class label of the event, the real class label is the manually annotated class label that has been reviewed, For the The predicted class label of each of the events.

7. The method according to claim 6, characterized in that The optimization of the softmax multi-classification model is also performed based on confidence learning, and the confidence learning is used to clean the training samples of the softmax multi-classification model. The cleaned training samples are used to retrain the softmax multi-classification model. The confidence learning cleans the training samples including: Based on the trained softmax multi-classification model, cross-validate the training samples to obtain the maximum probability class label of the event in the training samples, and the probability of the event under the maximum probability class label is the highest among all class labels; The events in the training samples whose manually annotated class labels are different from the maximum probability class label are filtered out.

8. An electronic device, characterized in that: include: A collection module, used to collect event data, wherein the event data includes multiple events and corresponding manually annotated class labels; A preprocessing module, used for preprocessing the event data; A first generating module, configured to generate a keyword feature vector of the event data based on the preprocessed event data; A second generating module, configured to generate a semantic feature vector of the event data based on the preprocessed event data; A fusion module, used for fusing the keyword feature vector and the semantic feature vector to obtain a fused feature vector; A training and optimization module, used for training and optimizing a softmax multi-classification model based on the fused feature vector and the manually annotated class label; The classification module is used to classify events based on the softmax multi-classification model to obtain predicted class labels of events.

9. An electronic device comprising a memory, at least one processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Multi-label text classification processing method and system and information data processing terminal

    CN111428026A

  • Text classification method and device based on reinforcement learning, computer equipment and medium

    CN114780727A

  • Test question knowledge label prediction method, storage medium and electronic equipment

    CN117807994A

  • Text classification method based on event tags

    CN118733777A