Real-time topic tweet classification method and device based on small samples
By adopting the small sample real-time classification method and an improved self-attention mechanism in the tweet classification, combined with real-time incremental training, the problem of insufficient accuracy and real-time tweet classification in the existing technology is solved, and efficient and accurate tweet categories.
Patent Information
- Application Number
- CN202411300841.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-02-11
AI Technical Summary
The existing tweet classification methods are insufficient in terms of accuracy and real-timeness, especially when dealing with the auxiliary characteristics of tweets and rapidly changing content, which lacks timeliness and high accuracy.
Using a real-time topic tweet classification method based on small samples, through real-time learning of tweet text and its auxiliary features, the classifier model is updated in real-time, and an improved self-attention mechanism and real-time incremental training method are introduced to ensure the real-time and real-time classification results. High accuracy.
It achieves high classification accuracy and real-time, can adapt to the rapid changes in tweet content, reduces dependence on large-scale labeled data, and improves the interpretability and computing efficiency of the model.
Smart Images

Figure CN119415685A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of text classification and deep learning, and in particular to a method and device for classifying topic tweets based on a small sample, which utilizes a neural network model to classify tweets into different topics. Background Art
[0002] With the rapid development of the Internet and the explosive growth of information, social media tweets have become the main source of people's access to extensive information and deep insights. However, as the content of tweets continues to grow and diversify, researchers face the challenge of information overload in tweet-related scientific research. Tweets can be divided into different topics, each of which has its own unique content and influence. In the field of scientific research, understanding tweets on different topics is crucial to gaining insights into social trends, changes in public opinion, and important events related to the research topic. Therefore, a system that can automatically classify and organize tweets is of great help to researchers in their information acquisition and analysis work.
[0003] Traditionally, text classification methods mainly rely on hand-written rules and feature engineering. This method is limited by the complexity of rules and the subjectivity of feature engineering, which limits its accuracy and scalability. Although text classification has made significant progress with the rise of deep learning and neural network technology, there are still some challenges in the classification of tweets, a special text carrier. One of the main problems is that current methods usually do not include auxiliary features of tweets, such as comments on tweets, the number of likes and reposts of tweets, and the attribute characteristics of the tweeting user, which makes the classifier appear powerless when ignoring this rich contextual information. In addition, existing classification methods usually cannot adapt to the rapidly changing content of tweets in a timely manner and lack timeliness. Traditional text classification tasks usually require large-scale labeled data, but in the real world, tweet data in many fields has limited labeled samples. These factors together lead to the shortcomings of existing tweet classification methods in terms of accuracy and real-time performance. Summary of the invention
[0004] In order to effectively overcome the above shortcomings of the prior art, the present invention proposes a topic tweet classification method and device based on small samples, which can achieve high classification accuracy by learning tweet text and its auxiliary features in real time, and updating the classifier model in real time, so as to ensure that readers and researchers can more easily obtain tweets of their interest, and provide more personalized tweet recommendations. Through the small sample technology, the classifier system can train the model with a small amount of training data, and the high accuracy of the model is guaranteed by increasing the number of real-time training.
[0005] The first aspect of the present invention proposes a topic tweet classification method based on a small sample, comprising the following steps:
[0006] S1. Obtain original tweet sample data, including the original tweet text and tweet features. Label the original tweet sample data for each target topic type to obtain labeled data;
[0007] S2. Divide the original tweet data of the labeled data into a training set and a validation set, and preprocess the training set data by randomly masking (blocking) some words in the text;
[0008] S3. Build a word embedding model and input the preprocessed training set data into the model for training. Through the trained word embedding model, the labeled data (including the original tweet and tweet features) is converted into word vector representation;
[0009] S4. Build a classifier model, pass the training set data into the classifier model, and pre-train with the masked language modeling task as the target task. Introduce an improved self-attention mechanism, calculate and weight the auxiliary features of tweets, so that the weight of important features accounts for a larger proportion and increase the interpretability of the model;
[0010] S5, using a web crawler to obtain tweet data (including original tweets and tweet features) containing specific keywords for each target topic on major social networking sites, and converting the incremental data into word vector representations using the method described in S3 and passing them into the text classifier model to perform incremental training on the model;
[0011] S6. Input the validation set data into the text classifier to obtain the final topic tweet classification result;
[0012] S7. Since tweets are real-time, we repeat the S5 incremental training process in real time on a daily basis, so that the classification effect is also real-time and the accuracy of model classification is improved.
[0013] As a preferred technical solution of the present invention, S1 is characterized by obtaining original tweet sample data, including the original tweet and tweet auxiliary features, the tweet auxiliary features are comments on the tweet, the number of tweet likes, the number of tweet reposts, and the user attribute characteristics of the tweeting user (user gender, user IP region, user personality signature).
[0014] Label the target topic type for the original tweet sample data.
[0015] Obtain labeled data, that is, manually label the data into corresponding topic categories.
[0016] As a preferred technical solution of the present invention, S2 is characterized in that some words in the text are randomly masked, that is, 15% of the words in the text are randomly selected, and among the selected 15% of the words, there is an 80% probability of being replaced by "[MASK]", a 10% probability of being replaced by a random word, and a 10% probability of remaining unchanged as the input sentence. For example: I like your cat, after template construction, it is: 80%-->I like your [MASK]; 10%-->I like your orange; 10%-->I like your cat.
[0017] As a preferred technical solution of the present invention, in S3, it is characterized in that the original text string of the tweet is segmented to obtain a character sequence, and then each character is mapped to a corresponding one-hot vector according to the word list order, so as to obtain the input. The input is passed into the CBOW neural network, and the weight matrix of the hidden layer is learned by back propagation and stochastic gradient descent. The training set samples are processed in the same way as above, and finally the word vector is obtained. Similarly, the tweet feature vector is obtained.
[0018] As a preferred technical solution of the present invention, in S4, it is characterized in that a classifier model is established, that is, a classifier model with an input layer, a convolution layer, a pooling layer and an output layer is constructed. The word vector of the training set is input into the model, and a convolution operation is performed through a convolution kernel and a window to generate a feature. Then, the feature output is spliced to obtain the output of the convolution layer. The convolution layer output is subjected to a 1-max pooling operation to obtain the pooling layer output. Similarly, the word vector of the tweet comment feature is subjected to the same steps as above to finally obtain the tweet feature pooling result. As a preferred technical solution of the present invention, in S5, we use web crawler methods such as requests to obtain tweets containing specific keywords of each target topic on social networking sites such as Weibo and X in real time, and after converting them into word vectors and tweet feature vectors using the method described in S3, the vectors are input into the text classifier model for real-time incremental training.
[0019] An improved self-attention mechanism is introduced, that is, the attention weights of the word vectors in the training set and the feature vectors of each tweet are calculated and normalized, and the attention weights are weighted and summed with the pooling results to obtain the context vector. Finally, the weighted context vector is input into the softmax regression operation to obtain the output layer output. The cross entropy loss is calculated by comparing the output of the classifier with the actual vocabulary distribution, and the parameters of the classifier are updated by the gradient descent method, which will enable the model to gradually learn to predict the correct vocabulary for the mask position in a given context.
[0020] As a preferred technical solution of the present invention, S5 is characterized in that tweet data (including original tweets and tweet features) containing specific keywords of each target topic on major social networking sites are obtained through a web crawler, that is, tweets containing specific keywords of each target topic on social networking sites such as Weibo and X are obtained, and after converting them into word vectors and tweet feature vectors, the vectors are input into a text classifier model for real-time incremental training every day to ensure the real-time and high accuracy of the classification results.
[0021] As a preferred technical solution of the present invention, S6 is characterized in that, 6. It is characterized in that the verification set data is input into the text classifier, and the obtained model output y selects the category with the largest value in y as the prediction result, and the corresponding numerical value represents the probability of selecting this category.
[0022] A second aspect of the present invention relates to a device for classifying real-time topic tweets based on small samples, comprising a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the method for classifying real-time topic tweets based on small samples of the present invention.
[0023] A third aspect of the present invention relates to a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the small sample-based real-time topic tweet classification method of the present invention.
[0024] The present invention obtains original tweet sample data, including original tweets and tweet features, and annotates the original tweet sample data for each target topic type to obtain annotated data. The original tweet data of the annotated data is divided into a training set and a validation set, and some words in the text of the training set data are randomly masked (shielded). The original tweet text string is segmented to obtain a character sequence, and each character is mapped to a corresponding one-hot vector according to the vocabulary order to obtain an input. The input is passed into a CBOW neural network, and a weight matrix of a hidden layer is learned through back propagation and a random gradient descent method. The training set samples are processed in the same way as above to obtain a word vector. Similarly, a tweet feature vector is obtained. A classifier model is established, that is, a classifier model with an input layer, a convolution layer, a pooling layer and an output layer is constructed. The word vector of the training set is input into the model, and a convolution operation is performed with a convolution kernel and a window to generate a feature. The output of the convolution layer is obtained by splicing the feature outputs. The output of the convolution layer is obtained by The 1-max pooling operation is performed to obtain the pooling layer output. Similarly, the word vectors of the tweet comment features are subjected to the same steps as above to finally obtain the tweet feature pooling result. By introducing the improved self-attention mechanism, that is, calculating the attention weights of the word vectors and the feature vectors of each tweet in the training set and normalizing them, the attention weights are weighted and summed with the pooling results to obtain the context vector. The weighted context vector is input into the softmax regression operation to obtain the output layer output. The cross entropy loss is calculated by comparing the output of the classifier with the actual vocabulary distribution, and the parameters of the classifier are updated by the gradient descent method. This will enable the model to gradually learn to predict the correct vocabulary for the mask position in a given context. Through web crawler methods such as requests, tweets containing specific keywords for each target topic on social websites such as Weibo and X are obtained in real time, and converted into word vectors and input into the text classifier model for real-time incremental training. By performing incremental training on the classifier model in real time on a daily basis, the classification effect is also real-time and the accuracy of model classification is improved.
[0025] The beneficial effects of the present invention are as follows: 1. The present invention introduces a variety of auxiliary features of tweets (such as the number of comments, the number of likes, the number of reposts, the gender of the tweeting user, the region and the personal signature, etc.), and combines the self-attention mechanism to innovatively improve the self-attention mechanism, thereby obtaining an improved self-attention mechanism, thereby greatly improving the accuracy and interpretability of tweet classification. Specifically, compared with the traditional self-attention mechanism, the improved method not only focuses on processing the internal dependencies of the original tweet, but also reasonably allocates the attention weights between the text and the auxiliary features, thereby optimizing the final classification effect and improving the model's solvability.
[0026] 2. The present invention proposes a new real-time incremental training method. Through the web crawler system, tweets containing specific keywords of each target topic on social networking sites such as Weibo and X are obtained in real time, and after being converted into word vectors and tweet feature vectors, the vectors are input into the text classifier model for real-time incremental training every day to ensure the real-time and high accuracy of the classification results. This real-time update mechanism enables the model to continuously adjust and optimize as the content and language used in tweets change when processing tweets, ensuring that various real-time personalized topics can be classified with high accuracy. By performing real-time incremental training on the classifier model, an efficient and low-cost solution is provided for processing tasks with high real-time requirements, adapting to the ever-changing content of tweets, and continuously providing high-quality classification services.
[0027] 3. By pre-training and incremental training on a small amount of labeled sample data, the problem of traditional text classification tasks relying on large-scale labeled data is effectively solved. Specifically, by pre-training the classification model with labeled sample data and masked language modeling (MLM) tasks, the text classification task no longer relies on a large number of labeled samples. Only a small number of samples are needed for incremental training to improve the accuracy of the model, which significantly reduces the cost of data collection and annotation. This method greatly improves the accuracy of predictions when dealing with short text classification tasks. The design and adjustment are more intuitive, reducing the risk of over-parameterization, and has high computational efficiency and fast training speed. It can achieve efficient and accurate tweet classification under limited sample conditions.
[0028] The advantages of the present invention are that it can efficiently and conveniently classify the crawled tweet information into topics in real time according to the user's topics of interest, making up for the inadaptability of traditional tweet classifiers to the growing number of new network words, solving the problem of lack of real-time performance, and improving the accuracy of classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0030] Figure 1 It is a schematic diagram of the process of the present invention.
[0031] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0032] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0033] Example 1
[0034] like Figure 1 As shown, the present invention provides a real-time topic tweet classification method based on deep learning, comprising the following steps:
[0035] S1. Obtain the original tweet sample data from the Weibo platform, including the original tweet text and tweet features. Label the original tweet sample data for each target topic type to obtain labeled data;
[0036] S2, dividing the original text data of the annotated Weibo tweets into a training set and a validation set, and preprocessing the training set data, i.e., randomly masking (blocking) some words in the text;
[0037] S3. Build a word2vec model and input the preprocessed training data into the model for training. Through the trained word2vec model, the labeled data (including the original tweet and tweet features) is converted into word vector representation;
[0038] S4. Build a TextCNN classifier model, pass the training set data into the TextCNN classifier model, and pre-train with the MLM (Masked Language Modeling) task as the target task. Introduce an improved self-attention mechanism, calculate the weight and weighted sum of each tweet feature, so that the weight of important features accounts for a larger proportion, and increase the interpretability of the model;
[0039] S5, using a web crawler to obtain tweet data (including original tweets and tweet features) containing specific keywords for each target topic on the Weibo platform, and converting the incremental data into word vector representations using the method described in S3 and passing them into the text classifier model to perform incremental training on the model;
[0040] S6. Input the validation set data into the text classifier to obtain the final topic tweet classification result;
[0041] S7. Since tweets are real-time, we repeat the S5 incremental training process in real time on a daily basis, so that the classification effect is also real-time and the accuracy of model classification is improved.
[0042] Among them, the tweet features in S1 include the comments of this microblog tweet, the number of tweet likes, the number of tweet reposts, and the user attribute characteristics of the tweeting user (user gender, user IP region, user personality signature). After obtaining the original tweet text data, the data is manually annotated and marked as the corresponding topic category.
[0043] Among them, S2 randomly selects 15% of the words in the text. Among the selected 15% of words, there is an 80% probability of being replaced by "[MASK]", a 10% probability of being replaced by a random word, and a 10% probability of remaining unchanged as the input sentence. For example: I like your cat, after template construction, it becomes: 80%-->I like your[MASK]; 10%-->Ilike your orange; 10%-->I like your cat.
[0044] In S3, the text string is segmented to obtain a character sequence, and then each character is mapped to a corresponding one-hot vector according to the vocabulary order, so that the input u={u0,...,u n}. Input U into the CBOW neural network and learn the weight matrix W of the hidden layer through back propagation and stochastic gradient descent v×d , where d represents the dimension of the weight vector and V represents the size of the vocabulary. The training set samples are processed in the same way as above to obtain u'={u'0,...,u' n}, u' and the weight matrix W v×d Multiply to get the word vector e = {e0,...,e n}, where e = W V×d ·u′. Similarly, we get the tweet comment feature vector x a ={x a 0,...,x a n}, where x a =W V×d u', the feature vector of tweet likes, forwarding, user gender, user region, and user signature is x b 、x c 、x d 、x e 、x f .
[0045] In S4, a TextCNN classifier model with an input layer, a convolutional layer, a pooling layer, and an output layer is constructed. Input model, through a convolution kernel and a window e i:i+h-1 Perform a convolution operation to generate a feature c i That is c i =f(W (1) .e i:i+h-1 +b (1) ). Among them, e i:i+h-1 represents a window of size h×d consisting of the i-th row to the i+h-1th row of the input matrix, where h represents the number of words in the window, and W(1) is the h×d dimensional weight matrix, b (1) is the bias parameter, and f is the nonlinear activation function relu. Then, the feature outputs are concatenated to obtain the output of the convolutional layer c = [c1, c2, ..., c n-h+1 ]. Perform 1-max pooling on the convolutional layer output to obtain the pooling layer output: p = max(c). Similarly, the word vector of the tweet comment feature After the same steps as above, we finally get the tweet feature pooling result: a =max(c a ), the pooling result of tweet likes, forwarding, user gender, user region, and user signature features is: p b 、p c 、p d 、p e 、p f . The improved self-attention mechanism is introduced. First, the attention weight is calculated. The attention weight of the training set is calculated as follows:
[0046] e t =tanh(W et p+W ea p a +W ea p b +W ec p c +W ed p d +W ee p e +W ef p f +b) Similarly, the attention weight of tweet comments is calculated as follows:
[0047] e a =tanh(W at p+W aa p a +W ab p b +W ac p c +W ad p d +W ae p e +W af p f +b) The attention weights of tweet likes, reposts, user gender, user region, and user signature features are calculated as e b 、e c 、e d 、e e 、e f Among them, W **is a learnable weight matrix used for linear transformation of different features, and b is a bias vector. The attention weights are normalized, and the normalized attention weights of the training set are calculated as follows:
[0048]
[0049] Similarly, the normalized attention weight of tweet comments is calculated as follows:
[0050]
[0051] The attention weights of tweet likes, reposts, user gender, user region, and user signature features are normalized and calculated as α b , α c , α d , α e , α f . The above attention weights are weighted and summed with each pooling result to obtain the context vector:
[0052] h=α t p+α a p a +α b p b +α c p c +α d p d +α e p e +α f p f
[0053] Finally, the weighted context vector h is input into the softmax regression operation to obtain the output layer output: y = softmax(b h +W h h), where W h is the connection coefficient, b h is the bias parameter, and y is the approximate probability of each category. The cross entropy loss is calculated by comparing the output of TextCNN with the actual vocabulary distribution, and the parameters of TextCNN are updated by gradient descent, which will enable the model to gradually learn to predict the correct vocabulary for the mask position in a given context. The specific cross entropy loss is as follows: L = -(l·log(y)+(1-l)·log(1-y)), where l is the type label (0 is "not included", 1 is "included"), and y is the approximate probability of each category.
[0054] In S5, we used web crawler methods such as requests to obtain tweets containing specific keywords of each target topic on the Weibo platform in real time, and converted them into word vectors and tweet feature vectors using the method described in S3. Then, we input the vectors into the TextCNN model for real-time incremental training.
[0055] Among them, in S6, after using the method described in S3 to obtain the word vector and tweet feature vector of the validation set data, the vector is input into the trained TextCNN model for prediction. The obtained model output y selects the category with the largest value in y as the prediction result, and the corresponding numerical value represents the probability of selecting this category.
[0056] In S7, since tweets are real-time, in order to make the classification effect also real-time, we repeatedly execute the S5 incremental training process in real time on a daily basis, so that the model can be updated in real time every day to improve the accuracy of the classification effect.
[0057] In actual use, this real-time topic tweet classification method based on small samples greatly enriches the input information of the model by introducing multiple auxiliary features of tweets (such as the number of comments, the number of likes, the number of reposts, the gender of the tweeting user, the region of the tweeting user, and the personality signature of the tweeting user). The weight calculation and weighted summation of these features are performed through the improved self-attention mechanism, the importance of each feature is dynamically adjusted, and different weights are assigned according to the importance of each feature, so as to highlight the role of key features in the final classification results and improve the interpretability and accuracy of the classification results. By performing real-time incremental training on the model, the classifier can continuously improve its performance over time, adapt to the changes of emerging topics and languages, and ensure the real-time and high accuracy of the classification results. By pre-training and incremental training on a small amount of labeled sample data, the text classification task no longer depends on a large number of labeled samples. Only a small number of samples are needed for incremental training to significantly improve the accuracy of the model, thereby reducing the cost of data collection and annotation. The classification model is pre-trained by labeled sample data and masked language modeling (MLM) tasks, which effectively solves the problem of traditional text classification methods relying on large-scale labeled data. When dealing with short text classification tasks, the TextCNN model is used for training and prediction, which not only greatly improves the prediction accuracy, but its simple structure also makes the design and adjustment of the model more intuitive, while reducing the risk of over-parameterization.
[0058] Example 2
[0059] The present embodiment relates to a device for classifying real-time topic tweets based on small samples, including a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the method for classifying real-time topic tweets based on small samples of Example 1.
[0060] The present invention greatly enriches the input information of the model by introducing a variety of auxiliary features of tweets (such as the number of comments, the number of likes, the number of reposts, the gender of the tweeting user, the region of the tweeting user, and the personal signature of the tweeting user). These features are weighted and weighted summed through an improved self-attention mechanism, the importance of each feature is dynamically adjusted, and different weights are assigned according to the importance of each feature, so as to highlight the role of key features in the final classification results and improve the interpretability and accuracy of the classification results. By performing real-time incremental training on the model, the classifier can continuously improve its performance over time, adapt to the changes in emerging topics and languages, and ensure the real-time and high accuracy of the classification results. By pre-training and incremental training on a small amount of labeled sample data, the text classification task is no longer dependent on a large number of labeled samples. Only a small number of samples are required for incremental training to significantly improve the accuracy of the model, thereby reducing the cost of data collection and annotation. The classification model is pre-trained by annotating sample data and masked language modeling tasks, which effectively solves the problem of traditional text classification methods relying on large-scale labeled data.
[0061] Example 3
[0062] This embodiment relates to a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the method for classifying real-time topic tweets based on a small sample in embodiment 1 is implemented.
[0063] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention is described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A real-time topic tweet classification method based on small samples, characterized in that: The steps include: S1. Obtain original tweet sample data, including the original tweet text and tweet auxiliary features; Label the original tweet sample data with the target topic type to obtain labeled data; S2, dividing the original tweet data of the labeled data into a training set and a validation set, and preprocessing the training set data, i.e., randomly masking some words in the text; S3. Establish a word embedding model and input the preprocessed training set data into the model for training; through the trained word embedding model, convert the labeled data into word vector representation; S4. Build a classifier model, pass the training set data into the classifier model, and pre-train it with the masked language modeling task as the target task; introduce the improved self-attention mechanism, calculate and weight the auxiliary features of tweets, so that the weight of important features accounts for a larger proportion and increase the interpretability of the model; S5, using a web crawler to obtain tweet data containing specific keywords of each target topic on major social networking sites, including the original tweets and tweet features, and converting the incremental data into word vector representations through the method described in S3 and passing them into the text classifier model to perform incremental training on the model; S6. Input the validation set data into the text classifier to obtain the final topic tweet classification result; S7. Since tweets are real-time, the S5 incremental training process is repeated in real time on a daily basis, so that the classification effect is also real-time and the accuracy of model classification is improved.
2. The method for classifying real-time topic tweets based on a small sample according to claim 1 is characterized in that: The original tweet sample data obtained in step S1 includes the original tweet and the auxiliary features of the tweet, which are the comments of the tweet, the number of tweet likes, the number of tweet reposts, and the user attribute features of the tweeting user, which include the user's gender, the user's IP region, and the user's personal signature; Label the target topic types for the original tweet sample data, and give examples of tweet categories for each target topic; Obtain labeled data, that is, manually label the data into corresponding topic categories.
3. The method for classifying real-time topic tweets based on a small sample according to claim 1, characterized in that: The random masking of some words in the text described in step S2, that is, randomly selecting 15% of the words in the text, among the selected 15% of the words, there is an 80% probability of being replaced by "[MASK]", a 10% probability of being replaced by a random word, and a 10% probability of remaining unchanged as the input sentence.
4. The method for classifying real-time topic tweets based on a small sample according to claim 1, characterized in that: The classifier model established in step S4 is to construct a classifier model with an input layer, a convolution layer, a pooling layer and an output layer; the word vector of the training set is input into the model, and a convolution operation is performed through a convolution kernel and a window to generate a feature; then, the feature output is spliced to obtain the output of the convolution layer; the convolution layer output is subjected to a 1-max pooling operation to obtain the pooling layer output; similarly, the word vector of the tweet comment feature is subjected to the same steps as above to finally obtain the tweet feature pooling result; Step S4 introduces the improved self-attention mechanism, that is, calculates the attention weights of the word vectors and the feature vectors of each tweet in the training set, normalizes them, and weighted sums the attention weights with the pooling results to obtain the context vector; finally, the weighted context vector is input into the softmax regression operation to obtain the output layer output; the cross entropy loss is calculated between the output of the classifier and the actual vocabulary distribution, and the parameters of the classifier are updated by the gradient descent method, which will enable the model to gradually learn to predict the correct vocabulary of the mask position in a given context.
5. The method for classifying real-time topic tweets based on a small sample size according to claims 1 and 3, characterized in that: In step S5, the tweet data containing specific keywords of each target topic on major social networking sites are obtained through web crawlers, that is, tweets containing specific keywords of each target topic on social networking sites such as Weibo and X are obtained, and after being converted into word vectors and tweet feature vectors, the vectors are input into the text classifier model for real-time incremental training every day to ensure the real-time and high accuracy of the classification results.
6. The method for classifying real-time topic tweets based on a small sample according to claim 1, characterized in that: In step S6, the validation set data is input into the text classifier, and the model output y obtained selects the category with the largest value in y as the prediction result, and the corresponding numerical value represents the probability of selecting this category.
7. A real-time topic tweet classification device based on a small sample, characterized in that: It includes a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, it is used to implement the real-time topic tweet classification method based on small samples as described in any one of claims 1-6.
8. A computer-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, the real-time topic tweet classification method based on a small sample as described in any one of claims 1-6 is implemented.
Citation Information
Cited By
Electronic equipment and traffic data label generation method
CN121350255A