Chinese text sentiment classification method and device
By adopting an initial feature extraction network based on pulse cycle in the emotional classification of Chinese texts, the problem of long-sequence information transmission loss in the existing technology is solved, and more efficient time information encoding and transmission is achieved, and the classification effect is improved.
Patent Information
- Application Number
- CN202411915340.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-24
AI Technical Summary
The existing Chinese text emotion classification method loses information transmission when processing long sequences, resulting in poor classification results.
The initial feature extraction network based on pulse cycle is used to perform pulse encoding classification of Chinese text, and the emotional classification results of Chinese text are generated by pre-training word vectors and pulse cycle neural models.
The time information is more efficiently encoded and transmitted through pulse coding, reducing the information attenuation problem in long sequences, thereby improving the classification effect.
Smart Images

Figure CN119721050A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a Chinese text sentiment classification method and device. Background Art
[0002] In the Internet age, people communicate through text to convey their emotions, and the emotional information contained in these texts is crucial to understanding social dynamics and individual attitudes.
[0003] Text sentiment analysis can extract valuable information from massive amounts of online text and help understand public opinion and market trends. By analyzing sentiment in texts such as social media, product reviews, and news reports, we can effectively monitor public opinion, recommend products, and even filter harmful information. However, text sentiment analysis faces many challenges, such as how to accurately extract text features, how to use contextual information, and how to model the relationship between words.
[0004] Most of the existing Chinese text sentiment classification methods are based on models such as RNN (Recurrent Neural Network), LSTM (Long - Short Term Memory) and GRU (Gated Recurrent Unit) to encode time information through continuous vector representation, thereby completing the sentiment classification of Chinese text. However, this process will cause information transmission loss when processing long sequences, resulting in poor classification results. Summary of the invention
[0005] The present invention provides a Chinese text sentiment classification method and device, which are used to solve the technical problem that the existing Chinese text sentiment classification method leads to poor classification effect.
[0006] The first aspect of the present invention provides a Chinese text sentiment classification method, comprising:
[0007] Acquire the Chinese text to be detected, and pre-process the Chinese text to be detected based on a preset text processing tool to output a target text;
[0008] Based on the target text, determining a plurality of text tensors;
[0009] Based on the pre-trained word vectors, an initial feature extraction network based on pulse cycles is used to perform pulse coding classification on each of the text tensors to generate Chinese text sentiment classification results.
[0010] Optionally, the preset text processing tool includes a stop word list and a stuttering library; the preprocessing of the Chinese text to be detected based on the preset text processing tool and outputting the target text includes:
[0011] Using a stop word list to remove redundant characters and redundant symbols from the Chinese text to be detected to obtain an intermediate text;
[0012] The intermediate text is segmented and stop words are removed through the Jieba library to output the target text.
[0013] Optionally, determining a plurality of text tensors based on the target text includes:
[0014] constructing a vocabulary based on the target text;
[0015] The indexes and labels corresponding to the multiple words in the vocabulary are converted to generate multiple text tensors.
[0016] Optionally, based on the pre-trained word vectors, the initial feature extraction network based on pulse cycles is used to perform pulse coding classification on each of the text tensors to generate a Chinese text sentiment classification result, including:
[0017] Using pre-trained word vectors to update network parameters of an initial embedding module in the initial feature extraction network based on pulse cycles, and determining a target feature extraction network based on pulse cycles;
[0018] Inputting each of the text tensors into the pulse cycle-based target feature extraction network; the pulse cycle-based target feature extraction network includes a target embedding module, a target pulse cycle neural model and a target output layer;
[0019] Using the target embedding module to perform feature embedding on each of the text tensors, and outputting an embedded low-precision vector corresponding to each of the text tensors;
[0020] Performing deep feature mining on each of the embedded low-precision vectors through the target pulse recurrent neural model, and outputting the target pulse corresponding to each of the embedded low-precision vectors;
[0021] The target pulses are accumulated through the target output layer to generate a Chinese text sentiment classification result.
[0022] Optionally, the target embedding module includes an embedding layer, an activation function layer and a quantization layer; the adopting the target embedding module to perform feature embedding on each of the text tensors respectively, and outputting the embedded low-precision vector corresponding to each of the text tensors, includes:
[0023] Aggregating each of the text tensors through an embedding layer, and outputting an embedding vector corresponding to each of the text tensors;
[0024] Using an activation function layer to perform nonlinear mapping on each of the embedding vectors, and output a nonlinear vector;
[0025] Each of the nonlinear vectors is input into a quantization layer for quantization to generate an embedded low-precision vector corresponding to each of the nonlinear vectors.
[0026] Optionally, the target pulse recurrent neural model includes a first fully connected layer, a first leaky ignition neuron layer, a second fully connected layer, and a second leaky ignition neuron layer; the target pulse recurrent neural model is used to perform deep feature mining on each of the embedded low-precision vectors, and output a target pulse corresponding to each of the embedded low-precision vectors, including:
[0027] Splicing each of the embedded low-precision vectors with the hidden layer pulse output at the historical moment corresponding to each of the embedded low-precision vectors to generate a splicing vector corresponding to each of the embedded low-precision vectors;
[0028] Using each of the splicing vectors as an input of a first fully connected layer, and outputting a first fully connected low-precision vector corresponding to each of the splicing vectors;
[0029] Using a first leaky firing neuron layer to perform pulse screening and excitation on each of the first fully connected low-precision vectors, and outputting a hidden layer pulse output corresponding to each of the first fully connected low-precision vectors at the current moment;
[0030] Using the hidden layer pulse outputs at the current moment as the input of the second fully connected layer, and outputting the second fully connected low-precision vectors corresponding to the hidden layer pulse outputs at the current moment;
[0031] The second leakage firing neuron layer performs pulse screening and excitation on each of the second fully connected low-precision vectors to generate a target pulse corresponding to each of the second fully connected low-precision vectors.
[0032] A second aspect of the present invention provides a Chinese text sentiment classification device, comprising:
[0033] An acquisition module, used for acquiring Chinese text to be detected, and preprocessing the Chinese text to be detected based on a preset text processing tool, and outputting a target text;
[0034] A determination module, used for determining a plurality of text tensors based on the target text;
[0035] The classification module is used to perform pulse coding classification on each of the text tensors based on the pre-trained word vectors using an initial feature extraction network based on a pulse cycle to generate a Chinese text sentiment classification result.
[0036] A third aspect of the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the Chinese text sentiment classification method as described in any one of the above items.
[0037] A fourth aspect of the present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed, the steps of the Chinese text sentiment classification method as described in any one of the above items are implemented.
[0038] A fifth aspect of the present invention provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions, wherein when the program instructions are executed by a computer, the computer executes the steps of the Chinese text sentiment classification method as described in any one of the above items.
[0039] It can be seen from the above technical solutions that the present invention has the following advantages:
[0040] Acquire the Chinese text to be detected, and pre-process the Chinese text to be detected based on a preset text processing tool to output a target text;
[0041] Based on the target text, determining a plurality of text tensors;
[0042] The above technical scheme of the present invention provides a method for sentiment classification of Chinese text. First, the Chinese text to be detected is obtained, and based on a preset text processing tool, the Chinese text to be detected is preprocessed to output a target text; then, based on the target text, multiple text tensors are determined; finally, based on the pre-trained word vector, an initial feature extraction network based on a pulse cycle is used to perform pulse coding classification on each text tensor to generate a Chinese text sentiment classification result; based on the above scheme, after performing preprocessing and other operations on the obtained Chinese text to be detected, multiple text tensors are obtained, and based on the pre-trained word vector, an initial feature extraction network based on a pulse cycle is used to perform pulse coding classification on each of the text tensors to generate a Chinese text sentiment classification result. The pulse-based encoding method of the initial feature extraction network based on a pulse cycle proposed by the present invention can more effectively encode and transmit time information, reduce the problem of information attenuation in long sequences, and thus improve the classification effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0044] Figure 1 A flowchart of a method for classifying Chinese text sentiment provided in the first embodiment of the present invention;
[0045] Figure 2 A flowchart of the Chinese text sentiment classification method provided in the first embodiment of the present invention;
[0046] Figure 3 A schematic diagram of the structure of a target feature extraction network based on pulse cycles provided in the first embodiment of the present invention;
[0047] Figure 4 This is a structural block diagram of a Chinese text sentiment classification device provided in Embodiment 2 of the present invention. DETAILED DESCRIPTION
[0048] The embodiment of the present invention provides a Chinese text sentiment classification method and device, which are used to solve the technical problem that the existing Chinese text sentiment classification method leads to poor classification effect.
[0049] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] Terminology explanation:
[0051] SNN:Spiking Neural Network.
[0052] RNN: Recurrent Neural Network.
[0053] SRNN: Spiking Recurrent Neural Network.
[0054] LIF: Leaky Integrate-and-Fire.
[0055] LSTM: Long-Short Term Memory.
[0056] GRU: Gated Recurrent Unit.
[0057] See also Figure 1 , Figure 1 A flowchart of the steps of a Chinese text sentiment classification method provided in Example 1 of the present invention.
[0058] A Chinese text sentiment classification method provided by the present invention includes:
[0059] Step 101: Obtain the Chinese text to be detected, and preprocess the Chinese text to be detected based on a preset text processing tool, and output a target text.
[0060] The preset text processing tool includes a stop word list and the Jieba library, and the Jieba library is the jieba library.
[0061] Further, the process of preprocessing the Chinese text to be detected based on the preset text processing tool and outputting the target text can be implemented by executing the following sub-steps S11 to S12:
[0062] Step S11: Use the stop word list to remove redundant characters and symbols from the Chinese text to be detected, and obtain an intermediate text.
[0063] Step S12: Segment the intermediate text and remove stop words through the Jieba library, and output the target text.
[0064] It should be noted that first, load the training and validation data sets from the specified path, remove the redundant characters, symbols, etc. in the Chinese text to be detected in the data sets, that is, redundant characters and symbols, according to the stop word list, obtain the intermediate text, and then segment the intermediate text through the jieba library and remove common and non-discriminative words, such as "de", "he", "shi", etc., and output the target text.
[0065] In this embodiment, the Chinese text to be detected is obtained, and the Chinese text to be detected is preprocessed based on the preset text processing tool, and the target text is output.
[0066] Step 102: Determine multiple text tensors based on the target text.
[0067] Specifically, step 102 may include the following sub-steps S21-S22:
[0068] Step S21: Construct a vocabulary based on the target text.
[0069] Step S22: Convert the indexes and labels corresponding to multiple words in the vocabulary, and generate multiple text tensors.
[0070] It should be noted that the output target text is constructed into a vocabulary, each word has a unique index in the vocabulary, and the size of the vocabulary is counted. The indexes corresponding to the target text and the corresponding labels are batch-converted into a tensor format and saved using a list, so as to obtain multiple text tensors.
[0071] In this embodiment, multiple text tensors are determined based on the target text.
[0072] Step 103: Based on the pre-trained word vectors, an initial feature extraction network based on pulse cycles is used to perform pulse coding classification on each text tensor to generate a Chinese text sentiment classification result.
[0073] Specifically, step 103 may include the following sub-steps S31-S35:
[0074] Step S31, using the pre-trained word vector to update the network parameters of the initial embedding module in the initial feature extraction network based on the pulse cycle, and determining the target feature extraction network based on the pulse cycle;
[0075] It should be noted that the Word2Vec model of the Gensim library is used to load the pre-trained word vector, and the weights (network parameters) of the initial embedding module in the initial feature extraction network based on pulse cycle are set to the pre-trained word vector to obtain the target embedding module. Then, the initial pulse cycle neural model and the initial output layer in the initial feature extraction network based on pulse cycle are used as the corresponding target pulse cycle neural model and the target output layer, thereby obtaining the target feature extraction network based on pulse cycle.
[0076] For further information, see Figure 2 Based on the above operations, the obtained Chinese text to be detected is preprocessed and combined with the pre-trained word vector to complete the update of the network parameters of the initial embedding module in the initial feature extraction network based on the pulse cycle, and the generated multiple text tensors are input into the target feature extraction network based on the pulse cycle for processing, so as to output the Chinese text sentiment classification result. The categories corresponding to the Chinese text sentiment classification result include positive and negative. There are a certain number of pulses in both the positive and negative categories. The category with more pulses determines whether the result is positive or negative.
[0077] For further information, see Figure 3 The target embedding module includes an embedding layer (EmbeddingBag), an activation function layer (rule layer) and a quantization layer; the target pulse cycle neural model (SRNN model) includes a first fully connected layer, a first leaky ignition neuron layer (LIF neuron layer), a second fully connected layer and a second leaky ignition neuron layer; the pulse cycle-based target feature extraction network constructed by the present invention adopts a 258 LIF neuron model, in which the input layer has 16 neurons, the hidden layer has 256 neurons, and the output layer has 2 neurons. The network structure and flow chart are shown in the figure. Figure 3 shown.
[0078] Step S32, inputting each text tensor into a pulse cycle-based target feature extraction network; the pulse cycle-based target feature extraction network includes a target embedding module, a target pulse cycle neural model and a target output layer;
[0079] Step S33, using the target embedding module to perform feature embedding on each text tensor respectively, and outputting the embedded low-precision vector corresponding to each text tensor;
[0080] The target embedding module includes an embedding layer, an activation function layer, and a quantization layer.
[0081] Specifically, step S33 may include the following sub-steps S331-S333:
[0082] Step S331, aggregate each text tensor through the embedding layer, and output the embedding vector corresponding to each text tensor;
[0083] Step S332: Use an activation function layer to perform nonlinear mapping on each embedded vector and output a nonlinear vector;
[0084] Step S333: Input each nonlinear vector to the quantization layer for quantization, and generate an embedded low-precision vector corresponding to each nonlinear vector.
[0085] It should be noted that for the embedding module, EmbeddingBag is used to convert the tensor into an embedding vector representation, and the ReLU activation function is applied. The data processing process of the embedding module can be expressed by the formula: E=Quantize(ReLU(Embedding(X))), where E represents the output of the embedding module, that is, the embedded low-precision vector, Embedding(X) is the embedding representation (embedding vector) of the input text tensor X, ReLU is the activation function, and Quantize represents the quantization operation, which can be applied to subsequent pulse signal encoding.
[0086] Furthermore, the quantization layer is to quantize the vector converted into Chinese text, that is, the nonlinear vector x. Specifically, a quantization factor n is first defined, and the continuous decimal value domain is discretized into a finite number of integer values by multiplying by n and rounding, and then the value is reduced to a multiple of 1 / n by dividing by n. Finally, the reduced value is limited to the range of [a, b] through the clip() function. Values less than a are set to a, and values greater than b are set to b. Through quantization, the original 32-bit floating point value can be mapped to an 8-bit integer value limited to [a, b], which can effectively reduce the computational complexity. Among them, the data processing process of the quantization layer can be expressed as:
[0087] ;
[0088] Among them, Quantize(x) is the embedded low-precision vector; x is the nonlinear direction; a is the lower boundary of the quantized value, and the value less than a after quantization will be assigned a; b is the upper boundary of the quantized value, and the value greater than b after quantization will be assigned b; n is the quantization factor; clip() is the limiting function; round() is the rounding function.
[0089] In this embodiment, the present invention uses a fixed embedding layer EmbeddingBag layer, and converts continuous embedding vectors into pulse sequences through quantization processing, encodes text data into pulse signals, and simulates the discharge behavior of biological neurons.
[0090] Step S34, performing deep feature mining on each embedded low-precision vector through a target pulse recurrent neural model, and outputting a target pulse corresponding to each embedded low-precision vector;
[0091] The target pulse recurrent neural model includes a first fully connected layer, a first leaky firing neuron layer, a second fully connected layer, and a second leaky firing neuron layer.
[0092] It should be noted that the Leaky Integrate-and-Fire (LIF) neuron model used in the present invention is a simplified neuron model used to simulate the discharge behavior of neurons when receiving electrical signals. The LIF model includes three processes: integration, leakage, and pulse transmission. The formula is as follows:
[0093]
[0094]
[0095]
[0096] Among them, V this the threshold. If the membrane potential exceeds the threshold, a pulse is sent, that is, S(t+1)=1; V(t) is the membrane potential at time step t; V(t+1) is the membrane potential at time step t+1; S(t) is the pulse output (0 or 1) at time step t, that is, the hidden layer pulse output; I(t+1) is the signal input at time step t+1. When I(t+1) is input, if S(t) is 1, V(t)=0, V(t+1) equals I(t+1); if S(t) is 0, V(t+1) equals the sum of I(t+1) and the decayed V(t). This integration process simulates the accumulation of charge and limits V(t+1) to the range [-a, a]. If V(t+1) exceeds the range, it will be set to -a or a to prevent the membrane potential value from being too large or too small, resulting in numerical instability or overflow. The membrane potential V(t) gradually decays over time, and the decay coefficient is δ, simulating the charge leakage of biological neurons. When the membrane potential V(t+1) reaches the threshold Vth, the neuron will emit a pulse, S(t+1) is set to 1, and the membrane potential V(t+1) is reset to 0. Otherwise, S(t+1) is 0 and V(t+1) decays over time.
[0097] Furthermore, the activation function used in the data processing of the LIF neuron model is the Gaussian function. Since the LIF neuron pulse function is not differentiable at the trigger threshold, it is difficult to directly calculate the gradient. In order to solve this problem, the Gaussian function is used as the approximate derivative of the activation function. The Gaussian function, as the approximate derivative of the pulse function, provides a smooth gradient, allowing the neural network to be trained through backpropagation, and bypasses the non-differentiability of the pulse function at the threshold point, avoiding the problem of zero or infinite gradients. The calculation formula is:
[0098]
[0099] Where, at time step t, x is V(t)-V th The result is σ, σ is the standard deviation, and f(x) is the result of the Gaussian function.
[0100] It is worth mentioning that in the hidden layer and output layer, the present invention adopts the LIF (Leaky Integrate-and-Fire) neuron model with limited membrane potential range to prevent the membrane potential value from being too large or too small, resulting in numerical instability or overflow, affecting the training process and convergence of the model, and being able to simulate the membrane potential update and pulse emission process of neurons, which enables the model to capture the dynamic characteristics of time series data; at the same time, in each forward propagation step, the model limits the weight value of the linear layer and quantizes the embedded vector, which can prevent numerical instability, reduce computational complexity, and simulate the limited precision in digital hardware, facilitating future hardware implementation. Combining the feedforward linear layer with the loop structure, a recursive structure is formed by returning the pulse state of the hidden layer to the input in each time step. This combination enhances the expressiveness of the model and can capture more complex text emotional information.
[0101] Specifically, step S34 may include the following sub-steps S341-S345:
[0102] Step S341, splicing each embedded low-precision vector with the hidden layer pulse output at the historical moment corresponding to each embedded low-precision vector, to generate a splicing vector corresponding to each embedded low-precision vector;
[0103] The hidden layer pulse output at a historical moment is the hidden layer pulse output at the previous moment.
[0104] Step S342: taking each concatenated vector as the input of the first fully connected layer, and outputting a first fully connected low-precision vector corresponding to each concatenated vector;
[0105] Step S343: Use the first leakage firing neuron layer to perform pulse screening and excitation on each first fully connected low-precision vector, and output the hidden layer pulse output corresponding to each first fully connected low-precision vector at the current moment;
[0106] It should be noted that before executing the data processing of the first fully connected layer, it is necessary to splice each embedded low-precision vector with the hidden layer pulse output of the historical moment corresponding to each embedded low-precision vector; for example, if the number of embedded low-precision vectors is 2, the hidden layer pulse output of the previous moment corresponding to the first embedded low-precision vector is 0, the first embedded low-precision vector is spliced with its corresponding hidden layer pulse (i.e., 0) output of the previous moment, and then processed by the first fully connected layer and the first leakage firing neuron layer in sequence, and the hidden layer pulse output of the current moment corresponding to the first embedded low-precision vector is output, and the hidden layer pulse output of the current moment corresponding to the first embedded low-precision vector is used as the hidden layer pulse output of the historical moment of the second embedded low-precision vector, and after being spliced with the second embedded low-precision vector, it is processed by the first fully connected layer and the first leakage firing neuron layer in sequence, so as to obtain the hidden layer pulse output of the current moment corresponding to the second embedded low-precision vector, thereby obtaining the hidden layer pulse output of the current moment corresponding to each embedded low-precision vector.
[0107] It is worth mentioning that the current input pulse (embedded low-precision vector) is concatenated with the pulse of the previous hidden layer (the hidden layer pulse output at the historical moment corresponding to the embedded low-precision vector), and the processed input information is combined with the membrane potential and pulse output of the hidden layer, and information is transmitted through two fully connected layers (input to hidden layer and hidden layer to output layer). Among them, the data processing process of the first fully connected layer and the first leaky firing neuron layer can be expressed as:
[0108]
[0109] Among them, H t is the hidden layer pulse output at the current moment, indicating the hidden layer pulse output at the current time step; Liner i2h is the linear transformation from input to hidden layer, [S t ;H t-1 ] means concatenating the current input pulse with the pulse of the previous hidden layer.
[0110] Step S344: taking the hidden layer pulse output at each current moment as the input of the second fully connected layer, and outputting the second fully connected low-precision vector corresponding to the hidden layer pulse output at each current moment;
[0111] Step S345: Perform pulse screening and excitation on each second fully connected low-precision vector through the second leakage firing neuron layer to generate a target pulse corresponding to each second fully connected low-precision vector.
[0112] It should be noted that the data processing process of the second fully connected layer and the second leaky ignition neuron layer can be expressed as:
[0113]
[0114] Among them, O t is the output pulse of the current time step, that is, the target pulse, Linear h2o is the linear transformation from hidden layer to output layer; H t is the hidden layer pulse output at the current moment, and represents the hidden layer pulse output at the current time step.
[0115] Step S35: accumulate each target pulse through the target output layer to generate a Chinese text sentiment classification result.
[0116] It should be noted that the pulses of the output layer are accumulated after all time steps to form the final result for classification. It can be expressed as:
[0117]
[0118] Among them, T is the total number of time steps, and Output is the output of the model, which represents the classification result of the input text, that is, the Chinese text sentiment classification result.
[0119] In this embodiment, based on the pre-trained word vectors, an initial feature extraction network based on pulse cycles is used to perform pulse coding classification on each text tensor to generate a Chinese text sentiment classification result.
[0120] As a comparison of technical effects, we can refer to existing technologies. The spiking neural network (SNN) is a computational model that simulates biological neuron activity, and it has unique advantages in processing time series data. Similarly, the recurrent neural network (RNN) is a deep learning model that is particularly suitable for processing sequence data because it can remember previous information and use this information in subsequent time steps. Through its unique spatiotemporal processing capabilities, SRNN can not only process complex sequence data and better capture long-distance dependencies and dynamic changes in text, but also simulate the way the human brain processes information, thereby improving the accuracy and efficiency of sentiment analysis.
[0121] In text sentiment analysis, GRU, RNN, LSTM and other methods are used as basic units for building deep learning networks, each with different characteristics and advantages and disadvantages. RNN can process sequence data, but it has the problem of gradient vanishing, which limits its performance in long-sequence sentiment analysis. LSTM effectively solves the gradient vanishing problem by introducing a gating mechanism and can capture long-distance dependencies, but the model structure is relatively complex, with many parameters and a long training time. GRU is a simplified version of LSTM. While maintaining the ability to capture long-distance dependencies, it has fewer parameters, but is not as stable as LSTM. Due to the excellent performance of recurrent neural networks (RNNs) in time series processing and the gradual maturity of SNN training algorithms, researchers have begun to explore the implementation and application of SRNNs.
[0122] In view of the above problems, the present invention proposes a Chinese text sentiment classification method, which performs preprocessing operations such as word segmentation, stop word removal, word embedding vector loading and batch processing on Chinese text data to establish a mapping relationship between text and vector. A fixed embedding layer EmbeddingBag layer is used, and continuous embedding vectors are converted into pulse sequences through quantization processing, and text data is encoded into pulse signals. In the hidden layer and output layer, the model adopts a LIF (Leaky Integrate-and-Fire) neuron model with a limited membrane potential range to prevent the membrane potential value from being too large or too small, resulting in numerical instability or overflow, affecting the training process and convergence of the model, and can simulate the membrane potential update and pulse emission process of neurons, which enables the model to capture the dynamic characteristics of time series data. Combining the feedforward linear layer with the loop structure, a recursive structure is formed by returning the pulse state of the hidden layer to the input in each time step. This combination enhances the expressiveness of the model and can capture more complex text sentiment information.
[0123] Compared with the prior art, the existing RNN and LSTM have relatively low temporal resolution when processing time series data, and it is difficult to capture the fine-grained emotional changes in Chinese text. The feature extraction network based on the pulse cycle proposed in the present invention introduces a pulse neuron model, so that the network can simulate the activity of neurons on a finer time scale. This enables the feature extraction network based on the pulse cycle to better capture the temporal characteristics of emotional vocabulary in the Chinese text sentiment analysis and improve the accuracy of sentiment analysis. At the same time, in the Chinese text sentiment analysis, the long-term dependency problem has always been a difficult problem that traditional models have been difficult to overcome. Although LSTM has alleviated the long-term dependency problem to a certain extent, there is still a risk of gradient disappearance and gradient explosion. In contrast, the feature extraction network based on the pulse cycle realizes the effective storage and transmission of long-term memory through the synaptic connection between the pulse neurons. This enables the feature extraction network based on the pulse cycle to better capture the correlation between sentences when processing long text sentiment analysis and improve the processing ability of long-term dependency problems. In addition, RNN and LSTM have low computational efficiency when processing large-scale Chinese text data, resulting in too long training time. The pulse cycle-based feature extraction network uses the information transmission mechanism of pulse neurons to achieve sparse coding and event-driven computing, greatly reducing the computational complexity of the model. This enables the pulse cycle-based feature extraction network to significantly improve computing efficiency and reduce training costs while ensuring the analysis effect in Chinese text sentiment analysis.
[0124] In summary, in the field of Chinese text sentiment analysis, existing technologies such as RNN, LSTM and GRU usually process sequence data based on fixed time steps, which limits their fineness in temporal resolution. In contrast, the feature extraction network based on pulse cycle can dynamically respond to the time of event occurrence, thereby providing data processing capabilities with higher temporal resolution, which is essential for capturing rapid emotional changes in text. At the same time, existing methods encode temporal information through continuous vector representation, which may lead to information transmission loss when processing long sequences. The feature extraction network based on pulse cycle adopts a pulse-based encoding method, which can more effectively encode and transmit temporal information and reduce the problem of information attenuation in long sequences. Although LSTM and GRU solve the gradient vanishing and gradient explosion problems encountered by traditional RNN in long sequence learning through gating mechanisms, these structures are relatively complex and have high computational costs. The feature extraction network based on pulse cycle can process information more efficiently through the pulse mechanism, reducing unnecessary computational burden. In addition, RNN, LSTM and GRU are usually time-driven, and they perform calculations at every time step, even if there is no new information input. The feature extraction network based on pulse cycle is event-driven and only performs calculations when an event is detected. It has lower computing power consumption and achieves high-performance, low-power Chinese text sentiment analysis by adopting the LIF model.
[0125] Therefore, the present invention has higher accuracy than the text sentiment classification method using traditional RNN. Its event-driven characteristics enable SRNN to respond to inputs at precise time points, thereby processing data with higher temporal resolution and effectively capturing subtle emotional changes in texts; its design is closer to the information processing method of the human brain, simulating the neuron discharge process, and may understand human emotions more accurately; the sparsity of the network and its adaptability to neuromorphic computing hardware have brought about improved energy efficiency; SRNN has continuous learning capabilities, adapts to dynamic emotional changes, and has high parameter efficiency, reducing model complexity; at the same time, they have strong resistance to input noise. In addition, thanks to the computing characteristics of SNN, SNN has obvious advantages in power consumption performance compared to traditional neural networks of the same structure. Similarly, in the case of the same network structure, the feature extraction network based on pulse cycles and the traditional RNN have an advantage of 1-3 orders of magnitude in theoretical power consumption compared to RNN.
[0126] In an embodiment of the present invention, the present invention provides a method for sentiment classification of Chinese text. First, the Chinese text to be detected is obtained, and based on a preset text processing tool, the Chinese text to be detected is preprocessed to output a target text; then, based on the target text, multiple text tensors are determined; finally, based on a pre-trained word vector, an initial feature extraction network based on a pulse cycle is used to perform pulse coding classification on each text tensor to generate a Chinese text sentiment classification result; based on the above scheme, after performing preprocessing and other operations on the obtained Chinese text to be detected, multiple text tensors are obtained, and based on the pre-trained word vector, an initial feature extraction network based on a pulse cycle is used to perform pulse coding classification on each text tensor to generate a Chinese text sentiment classification result. The pulse-based encoding method of the initial feature extraction network based on a pulse cycle proposed by the present invention can more effectively encode and transmit time information, reduce the problem of information attenuation in long sequences, and thus improve the classification effect.
[0127] See also Figure 4 , Figure 4 This is a structural block diagram of a Chinese text sentiment classification device provided in Embodiment 2 of the present invention.
[0128] The present invention provides a Chinese text sentiment classification device, comprising:
[0129] The acquisition module 401 is used to acquire the Chinese text to be detected, and pre-process the Chinese text to be detected based on a preset text processing tool, and output a target text;
[0130] A determination module 402, configured to determine a plurality of text tensors based on the target text;
[0131] The classification module 403 is used to perform pulse coding classification on each text tensor based on the pre-trained word vector and adopt an initial feature extraction network based on pulse cycle to generate a Chinese text sentiment classification result.
[0132] Furthermore, the preset text processing tool includes a stop word list and a stuttering library; the acquisition module 401 is specifically used for:
[0133] The stop word list is used to remove redundant characters and symbols of the Chinese text to be detected to obtain the intermediate text;
[0134] The intermediate text is segmented and stop words are removed through the Jieba library, and the target text is output.
[0135] Further, the determination module 402 is specifically about:
[0136] Build a vocabulary based on the target text;
[0137] The indexes and labels corresponding to multiple words in the vocabulary are transformed to generate multiple text tensors.
[0138] Furthermore, the classification module 403 includes:
[0139] The first submodule is used to update the network parameters of the initial embedding module in the initial feature extraction network based on the pulse cycle by using the pre-trained word vector, and determine the target feature extraction network based on the pulse cycle;
[0140] The second submodule is used to input each text tensor into a pulse cycle-based target feature extraction network; the pulse cycle-based target feature extraction network includes a target embedding module, a target pulse cycle neural model and a target output layer;
[0141] The third submodule is used to use the target embedding module to perform feature embedding on each text tensor respectively, and output the embedded low-precision vector corresponding to each text tensor;
[0142] The fourth submodule is used to perform deep feature mining on each embedded low-precision vector through a target pulse recurrent neural model, and output a target pulse corresponding to each embedded low-precision vector;
[0143] The fifth submodule is used to accumulate each target pulse through the target output layer to generate the Chinese text sentiment classification result.
[0144] Furthermore, the target embedding module includes an embedding layer, an activation function layer and a quantization layer; the third submodule is specifically used for:
[0145] Aggregate each text tensor through the embedding layer and output the embedding vector corresponding to each text tensor;
[0146] Use the activation function layer to perform nonlinear mapping on each embedded vector and output a nonlinear vector;
[0147] Each nonlinear vector is input into the quantization layer for quantization to generate an embedded low-precision vector corresponding to each nonlinear vector.
[0148] Furthermore, the target pulse recurrent neural model includes a first fully connected layer, a first leaky firing neuron layer, a second fully connected layer, and a second leaky firing neuron layer; a fourth submodule is specifically used for:
[0149] Each embedded low-precision vector is concatenated with the hidden layer pulse output at the historical moment corresponding to each embedded low-precision vector to generate a concatenated vector corresponding to each embedded low-precision vector;
[0150] Each concatenated vector is used as the input of the first fully connected layer, and the first fully connected low-precision vector corresponding to each concatenated vector is output;
[0151] The first leakage firing neuron layer is used to perform pulse screening and excitation on each first fully connected low-precision vector, and outputs the hidden layer pulse output corresponding to each first fully connected low-precision vector at the current moment;
[0152] The hidden layer pulse outputs at each current moment are respectively used as the input of the second fully connected layer, and the second fully connected low-precision vectors corresponding to the hidden layer pulse outputs at each current moment are output;
[0153] The second leakage firing neuron layer performs pulse screening and excitation on each second fully connected low-precision vector to generate a target pulse corresponding to each second fully connected low-precision vector.
[0154] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, modules and sub-modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0155] An embodiment of the present invention further provides a computer device, including a memory and a processor, wherein a computer program is stored in the memory; when the computer program is executed by the processor, the processor executes the steps of the Chinese text sentiment classification method of the above-mentioned embodiment 1.
[0156] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the steps of the Chinese text sentiment classification method as described in the first embodiment are implemented.
[0157] The embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the steps of the Chinese text sentiment classification method as described in the first embodiment when the computer program / instruction is executed by a processor.
[0158] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. 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.
[0159] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0160] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A Chinese text sentiment classification method, characterized in that: include: Acquire the Chinese text to be detected, and pre-process the Chinese text to be detected based on a preset text processing tool to output a target text; Based on the target text, determining a plurality of text tensors; Based on the pre-trained word vectors, an initial feature extraction network based on pulse cycles is used to perform pulse coding classification on each of the text tensors to generate Chinese text sentiment classification results.
2. The Chinese text sentiment classification method according to claim 1, characterized in that: The preset text processing tool includes a stop word list and a stuttering library; the preprocessing of the Chinese text to be detected based on the preset text processing tool and outputting the target text includes: Using a stop word list to remove redundant characters and redundant symbols from the Chinese text to be detected to obtain an intermediate text; The intermediate text is segmented and stop words are removed through the Jieba library to output the target text.
3. The Chinese text sentiment classification method according to claim 1 is characterized in that: The step of determining a plurality of text tensors based on the target text includes: constructing a vocabulary based on the target text; The indexes and labels corresponding to the multiple words in the vocabulary are converted to generate multiple text tensors.
4. The Chinese text sentiment classification method according to claim 1, characterized in that: Based on the pre-trained word vector, the initial feature extraction network based on pulse cycle is used to perform pulse coding classification on each of the text tensors to generate a Chinese text sentiment classification result, including: Using pre-trained word vectors to update network parameters of an initial embedding module in the initial feature extraction network based on pulse cycles, and determining a target feature extraction network based on pulse cycles; Inputting each of the text tensors into the pulse cycle-based target feature extraction network; the pulse cycle-based target feature extraction network includes a target embedding module, a target pulse cycle neural model and a target output layer; Using the target embedding module to perform feature embedding on each of the text tensors, and outputting an embedded low-precision vector corresponding to each of the text tensors; Performing deep feature mining on each of the embedded low-precision vectors through the target pulse recurrent neural model, and outputting the target pulse corresponding to each of the embedded low-precision vectors; The target pulses are accumulated through the target output layer to generate a Chinese text sentiment classification result.
5. The Chinese text sentiment classification method according to claim 4 is characterized in that: The target embedding module includes an embedding layer, an activation function layer and a quantization layer; the target embedding module is used to perform feature embedding on each of the text tensors, and outputs an embedded low-precision vector corresponding to each of the text tensors, including: Aggregating each of the text tensors through an embedding layer, and outputting an embedding vector corresponding to each of the text tensors; Using an activation function layer to perform nonlinear mapping on each of the embedding vectors, and output a nonlinear vector; Each of the nonlinear vectors is input into a quantization layer for quantization to generate an embedded low-precision vector corresponding to each of the nonlinear vectors.
6. The Chinese text sentiment classification method according to claim 4 is characterized in that: The target pulse recurrent neural model includes a first fully connected layer, a first leaky ignition neuron layer, a second fully connected layer, and a second leaky ignition neuron layer; the target pulse recurrent neural model is used to perform deep feature mining on each of the embedded low-precision vectors, and output a target pulse corresponding to each of the embedded low-precision vectors, including: Splicing each of the embedded low-precision vectors with the hidden layer pulse output at the historical moment corresponding to each of the embedded low-precision vectors to generate a splicing vector corresponding to each of the embedded low-precision vectors; Using each of the splicing vectors as an input of a first fully connected layer, and outputting a first fully connected low-precision vector corresponding to each of the splicing vectors; Using a first leaky firing neuron layer to perform pulse screening and excitation on each of the first fully connected low-precision vectors, and outputting a hidden layer pulse output corresponding to each of the first fully connected low-precision vectors at the current moment; Using the hidden layer pulse outputs at the current moment as the input of the second fully connected layer, and outputting the second fully connected low-precision vectors corresponding to the hidden layer pulse outputs at the current moment; The second leakage firing neuron layer performs pulse screening and excitation on each of the second fully connected low-precision vectors to generate a target pulse corresponding to each of the second fully connected low-precision vectors.
7. A Chinese text sentiment classification device, characterized in that: include: An acquisition module, used for acquiring Chinese text to be detected, and preprocessing the Chinese text to be detected based on a preset text processing tool, and outputting a target text; A determination module, used for determining a plurality of text tensors based on the target text; The classification module is used to perform pulse coding classification on each of the text tensors based on the pre-trained word vectors using an initial feature extraction network based on a pulse cycle to generate a Chinese text sentiment classification result.
8. A computer device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the Chinese text sentiment classification method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, the Chinese text sentiment classification method as described in any one of claims 1-6 is implemented.
10. A computer program product, characterized in that The computer program product includes a computer program stored on a non-transitory computer-readable storage medium, wherein the computer program includes program instructions, wherein when the program instructions are executed by a computer, the computer is caused to execute the Chinese text sentiment classification method as described in any one of claims 1-6.
Citation Information
Patent Citations
Pulse neural network deployment method, device and equipment for emotion recognition
CN116882469A
Text sentiment classification method and device and electronic equipment
CN117235251A