A Chinese text sentiment classification method and device
By preprocessing and extracting features from Chinese texts using an initial feature extraction network based on pulse cycles, the problem of information transmission loss in long sequences in existing methods is solved, and the accuracy and efficiency of Chinese text sentiment classification are improved.
Patent Information
- Application Number
- CN202411915340.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2044-12-24
AI Technical Summary
Existing Chinese text sentiment classification methods based on models such as RNN, LSTM and GRU suffer from information transmission loss when processing long sequences, resulting in poor classification results.
An initial feature extraction network based on pulse cycles is used to perform pulse coding classification on text tensors to generate a Chinese text sentiment classification method and device, including presetting a text processing tool, determining multiple text tensors, and based on pre-trained word vectors, using an initial feature extraction network based on pulse cycles to perform pulse coding classification on each text tensor to generate a Chinese text sentiment classification result.
The text tensor is pulse-coded and classified through the initial feature extraction network of the pulse cycle to generate a Chinese text sentiment classification device and generate a Chinese text sentiment classification result.
Smart Images

Figure CN119721050B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to a Chinese text sentiment classification method and device. BACKGROUND
[0002] In the Internet era, people communicate through text to convey their emotions. The emotional information contained in these texts is crucial for understanding social dynamics and individual attitudes.
[0003] Text sentiment analysis can extract valuable information from massive network texts, helping to understand public opinion and market trends. Through sentiment analysis of texts such as social media, product reviews, and news reports, it is possible to 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 mutual relationship between words.
[0004] Existing Chinese text sentiment classification methods are mostly based on RNN (Recurrent Neural Network), LSTM (Long-Short Term Memory), and GRU (Gated Recurrent Unit) models that encode temporal information through continuous vector representations to complete sentiment classification of Chinese text. However, this process can cause information transmission loss when processing long sequences, resulting in poor classification results. SUMMARY
[0005] The present application provides a Chinese text sentiment classification method and device to solve the technical problem of poor classification results caused by existing Chinese text sentiment classification methods.
[0006] The first aspect of the present application provides a Chinese text sentiment classification method, comprising:
[0007] Obtain a Chinese text to be detected, and preprocess the Chinese text to be detected based on a preset text processing tool to output a target text;
[0008] Determine a plurality of text tensors based on the target text;
[0009] Based on a pre-trained word vector, an initial feature extraction network based on pulse cycle is used to pulse encode and classify each text tensor to generate a Chinese text sentiment classification result.
[0010] Optionally, the preset text processing tool includes a stop word table and a Jieba library; preprocessing the Chinese text to be detected based on the preset text processing tool to output a target text includes:
[0011] The stop words table is used to remove redundant characters and redundant symbols of the to-be-detected Chinese text, and an intermediate text is obtained.
[0012] The intermediate text is segmented and the stop words are removed by using the Jieba library, and a target text is output.
[0013] Optionally, based on the target text, a plurality of text tensors are determined, including:
[0014] According to the target text, a vocabulary table is constructed;
[0015] The indexes and labels corresponding to the plurality of words in the vocabulary table are converted to generate a plurality of text tensors.
[0016] Optionally, based on the pre-trained word vector, an initial feature extraction network based on pulse cycle is used to pulse code and classify each text tensor to generate a Chinese text sentiment classification result, including:
[0017] The network parameters of an initial embedding module in the initial feature extraction network based on pulse cycle are updated using the pre-trained word vector to determine a target feature extraction network based on pulse cycle;
[0018] Each text tensor is input into the target feature extraction network based on pulse cycle; the target feature extraction network based on pulse cycle includes a target embedding module, a target pulse cycle neural model, and a target output layer;
[0019] Each text tensor is respectively embedded by using the target embedding module, and an embedded low-precision vector corresponding to each text tensor is output;
[0020] Each embedded low-precision vector is respectively subjected to deep feature mining by using the target pulse cycle neural model, and a target pulse corresponding to each embedded low-precision vector is output;
[0021] Each target pulse is accumulated by using 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; and the embedding of each text tensor by using the target embedding module to output an embedded low-precision vector corresponding to each text tensor includes:
[0023] Each text tensor is aggregated by using the embedding layer to output an embedded vector corresponding to each text tensor;
[0024] Each embedded vector is respectively subjected to non-linear mapping by using the activation function layer to output a non-linear vector;
[0025] The nonlinear vectors are input into a quantization layer respectively for quantization to generate embedded low-precision vectors corresponding to the nonlinear vectors.
[0026] Optionally, the target spiking recurrent neural model comprises a first full connection layer, a first leaky ReLU neuron layer, a second full connection layer and a second leaky ReLU neuron layer; the deep feature mining of each embedded low-precision vector by the target spiking recurrent neural model to output a target pulse corresponding to each embedded low-precision vector comprises:
[0027] Each embedded low-precision vector is spliced with a hidden layer pulse output of a historical moment corresponding to the embedded low-precision vector to generate a spliced vector corresponding to the embedded low-precision vector;
[0028] Each spliced vector is taken as an input of the first full connection layer to output a first full connection low-precision vector corresponding to the spliced vector;
[0029] Each first full connection low-precision vector is subjected to pulse screening and excitation by the first leaky ReLU neuron layer to output a hidden layer pulse output of a current moment corresponding to the first full connection low-precision vector;
[0030] Each hidden layer pulse output of the current moment is taken as an input of the second full connection layer to output a second full connection low-precision vector corresponding to the hidden layer pulse output of the current moment;
[0031] Each second full connection low-precision vector is subjected to pulse screening and excitation by the second leaky ReLU neuron layer to generate a target pulse corresponding to the second full connection low-precision vector.
[0032] The second aspect of the present application provides a Chinese text sentiment classification device, comprising:
[0033] An acquisition module is configured to acquire a to-be-detected Chinese text, and perform preprocessing on the to-be-detected Chinese text based on a preset text processing tool to output a target text.
[0034] A determination module is configured to determine a plurality of text tensors based on the target text.
[0035] A classification module is configured to perform pulse coding classification on each text tensor by using an initial feature extraction network based on a pulse cycle based on a pre-trained word vector to generate a Chinese text sentiment classification result.
[0036] The third aspect of the present application provides a computer device comprising a memory and a processor, the memory stores a computer program, and the computer program is executed by the processor to make the processor execute the steps of the Chinese text sentiment classification method according to any one of the above aspects.
[0037] The fourth aspect of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed to implement the steps of the Chinese text sentiment classification method according to any one of the above.
[0038] The fifth aspect of the present application provides a computer program product, which comprises a computer program stored on a non-transitory computer readable storage medium, and the computer program comprises program instructions, wherein when the program instructions are executed by a computer, the computer executes the steps of the Chinese text sentiment classification method according to any one of the above.
[0039] From the above technical solutions, the present application has the following advantages:
[0040] Obtaining a to-be-detected Chinese text, and preprocessing the to-be-detected Chinese text based on a preset text processing tool to output a target text;
[0041] Determining a plurality of text tensors based on the target text;
[0042] The above technical solution of the present application provides a Chinese text sentiment classification method. First, a to-be-detected Chinese text is obtained, and the to-be-detected Chinese text is preprocessed based on a preset text processing tool to output a target text. Then, a plurality of text tensors are determined based on the target text. Finally, a pre-trained word vector is used to perform pulse coding classification on each text tensor based on an initial feature extraction network based on pulse cycles to generate a Chinese text sentiment classification result. Based on the above solution, after preprocessing the obtained to-be-detected Chinese text, a plurality of text tensors are obtained, and a pre-trained word vector is used to perform pulse coding classification on each text tensor based on an initial feature extraction network based on pulse cycles to generate a Chinese text sentiment classification result. The initial feature extraction network based on pulse cycles proposed in the present application can more effectively encode and transmit time information and reduce information decay problems in long sequences, thereby improving the classification effect. BRIEF DESCRIPTION OF DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0044] Figure 1 A step flowchart of a Chinese text sentiment classification method provided for the first embodiment of the present application;
[0045] Figure 2 A flow framework diagram of the Chinese text sentiment classification method provided for the first embodiment of the present application is shown in FIG. 1.
[0046] Figure 3 A structural schematic diagram of the target feature extraction network based on pulse cycle provided for the first embodiment of the present application is shown in FIG. 2.
[0047] Figure 4 A structural block diagram of the Chinese text sentiment classification device provided for the second embodiment of the present application is shown in FIG. 3. DETAILED DESCRIPTION
[0048] The embodiments of the present application provide a Chinese text sentiment classification method and device, and aim to solve the technical problem that the existing Chinese text sentiment classification method results in poor classification effect.
[0049] In order to make the technical scheme of the present application clearer and easier to understand, the technical scheme in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the embodiments described below are only some of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.
[0050] Term 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] Please refer to Figure 1 , Figure 1 A step flowchart of the Chinese text sentiment classification method provided for the first embodiment of the present application is shown in FIG. 4.
[0058] The application provides a Chinese text sentiment classification method, which comprises the following steps:
[0059] In step 101, a Chinese text to be detected is obtained, and the Chinese text to be detected is preprocessed based on a preset text processing tool to output a target text.
[0060] The preset text processing tool comprises a stop word removal table and a Jieba library.
[0061] Further, the preprocessing of the Chinese text to be detected based on the preset text processing tool to output the target text can be realized by performing the following sub-steps S11 to S12:
[0062] In step S11, the redundant characters and symbols of the Chinese text to be detected are removed by using the stop word removal table to obtain an intermediate text.
[0063] In step S12, the intermediate text is segmented and the stop words are removed by using the Jieba library to output the target text.
[0064] It should be noted that firstly, the training and verification data sets are loaded from a specified path, and the redundant characters, symbols and the like in the Chinese text to be detected in the data set, i.e., the redundant characters and symbols, are removed according to the stop word removal table to obtain an intermediate text, and then the intermediate text is segmented and the common and non-discriminative words such as "of", "and", "is" and the like are removed by using the Jieba library to 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 to output the target text.
[0066] In step 102, a plurality of text tensors are determined based on the target text.
[0067] Specifically, step 102 can comprise the following sub-steps S21-S22:
[0068] In step S21, a vocabulary table is constructed according to the target text.
[0069] In step S22, the indexes and labels corresponding to a plurality of words in the vocabulary table are converted to generate a plurality of text tensors.
[0070] It should be noted that the output target text is constructed into a vocabulary table, each word in the vocabulary table has a unique index, and the size of the vocabulary table is counted, the indexes and corresponding labels of the target text are converted into a tensor format in batches, and a list is used for storage, so that a plurality of text tensors are obtained.
[0071] In this embodiment, a plurality of text tensors are determined based on the target text.
[0072] Step 103, based on the pre-trained word vector, using the initial feature extraction network based on pulse cycle to pulse coding classification of each text tensor, generate Chinese text sentiment classification results.
[0073] Specifically, step 103 can 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 pulse cycle, determine the target feature extraction network based on pulse cycle;
[0075] It should be noted that the pre-trained word vector is loaded using the Word2Vec model of the Gensim library, the weight (network parameter) of the initial embedding module in the initial feature extraction network based on pulse cycle is set to the pre-trained word vector, the target embedding module is obtained, and 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 target output layer, so as to obtain the target feature extraction network based on pulse cycle.
[0076] Further, please refer to Figure 2 , based on the above preprocessing operation of the obtained to be detected Chinese text, and combining the pre-trained word vector, the network parameters of the initial embedding module in the initial feature extraction network based on pulse cycle are updated, the generated multiple text tensors are input to the target feature extraction network based on pulse cycle for processing, so as to output Chinese text sentiment classification results, the categories corresponding to the Chinese text sentiment classification results include positive and negative, there are a certain number of pulses on the two categories of positive and negative, and the classification of which has more pulses is determined as positive or negative.
[0077] Further, please refer to 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 full connection layer, a first leaky firing neuron layer (LIF neuron layer), a second full connection layer and a second leaky firing neuron layer; the target feature extraction network based on pulse cycle built by the application uses 258 LIF neuron models, of 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 Figure 3 .
[0078] Step S32, input each text tensor into the target feature extraction network based on the pulse cycle; the target feature extraction network based on the pulse cycle includes a target embedding module, a target pulse cycle neural model and a target output layer;
[0079] Step S33, respectively embedding features of each text tensor by using the target embedding module, and output embedding low-precision vectors 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 can include the following sub-steps S331-S333:
[0082] Step S331, respectively aggregate each text tensor by using the embedding layer, and output embedding vectors corresponding to each text tensor;
[0083] Step S332, respectively map each embedding vector by using the activation function layer, and output nonlinear vectors;
[0084] Step S333, respectively input each nonlinear vector into the quantization layer for quantization, and generate embedding low-precision vectors 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 ReLU activation function is applied. The data processing process of the embedding module can be represented by the formula: E = Quantize(ReLU(Embedding(X))), wherein E represents the output of the embedding module, i.e. the embedding 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 the subsequent pulse signal coding.
[0086] Further, the quantization layer is to quantize the vector converted for the Chinese text, i.e. to quantize the nonlinear vector x. Specifically, first define a quantization factor n, discretize the continuous decimal value domain into a finite number of integer values by multiplying n and rounding, then divide the value by n to reduce the value to 1 / n times, and finally limit the reduced value to [a, b] range by using the clip() function, and set the value less than a to a and the value greater than b to b. By quantization, the originally 32-bit floating-point number value can be mapped to an 8-bit integer value limited between [a, b], which can effectively reduce the computational complexity. The data processing process of the quantization layer can be represented as:
[0087] ;
[0088] Wherein, Quantize(x) is an embedded low-precision vector; x is a non-linear vector; a is the lower boundary of the quantized value, and the value less than a after quantization is assigned to a; b is the upper boundary of the quantized value, and the value greater than b after quantization is assigned to b; n is a quantization factor; clip() is a clipping function; round() is a rounding function.
[0089] In the embodiment, the application uses a fixed embedding layer EmbeddingBag layer, and through quantization processing, converts the continuous embedding vector into a pulse sequence, encodes the text data into a pulse signal, and simulates the discharge behavior of a biological neuron.
[0090] Step S34, performing deep feature mining on each embedded low-precision vector through the target pulse recurrent neural model, and outputting the target pulse corresponding to each embedded low-precision vector;
[0091] The target pulse recurrent neural model comprises a first full connection layer, a first leaky integrate-and-fire neuron layer, a second full connection layer, and a second leaky integrate-and-fire neuron layer.
[0092] It should be noted that the Leaky Integrate-and-Fire (LIF) neuron model used in the application is a simplified neuron model, which is used to simulate the discharge behavior of a neuron when receiving an electrical signal. The LIF model includes three processes of integration, leakage and sending pulses. The formula is as follows,
[0093]
[0094]
[0095]
[0096] Wherein, V thV(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 spike output at time step t (0 or 1), i.e., the hidden layer spike output; I(t+1) is the signal input at time step t+1; when I(t+1) input, if S(t) is 1, V(t)=0, V(t+1) is equal to I(t+1); if S(t) is 0, V(t+1) is equal to the sum of I(t+1) and the decay of V(t), this integration process simulates the accumulation of charge, and V(t+1) is limited in 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, leading to 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 fire a spike, 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] Further, the activation function in the data processing process of the LIF neuron model uses a Gaussian function. Since the LIF neuron spike function is not derivable 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 spike function provides a smooth gradient, so that the neural network can be trained by backpropagation, and bypasses the non-derivability of the spike function at the threshold point, avoiding the problem of zero or infinite gradient. The calculation formula is:
[0098]
[0099] where, at time step t, x is V(t)-V th , σ is the standard deviation, and f(x) is the calculation result of the Gaussian function.
[0100] It is worth mentioning that in the hidden layer and the output layer, the LIF (Leaky Integrate-and-Fire) neuron model for limiting the range of membrane potential is adopted in the application, which prevents the membrane potential value from being too large or too small, leading to numerical instability or overflow, affecting the training process and convergence of the model, and can simulate the membrane potential update and pulse firing 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 embedding vector, which can prevent numerical instability, reduce computational complexity, and simulate the limited precision in digital hardware, facilitating future implementation on hardware. Combined with the feedforward linear layer and the loop structure, the pulse state of the hidden layer is returned to the input at each time step, forming a recursive structure. This combination enhances the expressiveness of the model and enables it to capture more complex text sentiment information.
[0101] Specifically, step S34 can include the following sub-steps S341-S345:
[0102] Step S341, splice each embedding low-precision vector with the hidden layer pulse output of the historical time corresponding to each embedding low-precision vector, respectively, to generate a spliced vector corresponding to each embedding low-precision vector;
[0103] The hidden layer pulse output of the historical time is the hidden layer pulse output of the previous time.
[0104] Step S342, respectively, take each spliced vector as the input of the first fully connected layer, and output a first fully connected low-precision vector corresponding to each spliced vector;
[0105] Step S343, use the first leaky integrate-and-fire neuron layer to pulse-screen and excite each first fully connected low-precision vector, respectively, to output the hidden layer pulse output of the current time corresponding to each first fully connected low-precision vector;
[0106] It should be noted that before the data processing of the first full connection layer is performed, each embedded low-precision vector is spliced with the hidden layer pulse output of the historical moment corresponding to the 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 the hidden layer pulse output (i.e. 0) of the previous moment corresponding thereto, and after being sequentially processed by the first full connection layer and the first leaky integrate-and-fire neuron layer, the hidden layer pulse output of the current moment corresponding to the first embedded low-precision vector is output, the hidden layer pulse output of the current moment corresponding to the first embedded low-precision vector is taken 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, the second embedded low-precision vector is sequentially processed by the first full connection layer and the first leaky integrate-and-fire neuron layer, 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 spliced with the pulse of the previous hidden layer (the hidden layer pulse output of the historical moment corresponding to the embedded low-precision vector), the processed input information is combined with the membrane potential and pulse output of the hidden layer, and information transmission is performed through two full connection layers (input to the hidden layer and the hidden layer to the output layer), wherein the data processing process of the first full connection layer and the first leaky integrate-and-fire neuron layer can be represented as:
[0108]
[0109] wherein H t is the hidden layer pulse output of the current moment, represents the hidden layer pulse output of the current time step; Liner i2h is a linear transformation input to the hidden layer, [S t ;H t-1 ] represents splicing the current input pulse with the pulse of the previous hidden layer.
[0110] In step S344, each hidden layer pulse output of the current moment is taken as the input of the second full connection layer, and a second full connection low-precision vector corresponding to each hidden layer pulse output of the current moment is output.
[0111] In step S345, the second leaky integrate-and-fire neuron layer is used to perform pulse screening and excitation on each second full connection low-precision vector, so as to generate a target pulse corresponding to each second full connection low-precision vector.
[0112] It should be noted that the data processing process of the second full connection layer and the second leaky integrate-and-fire neuron layer can be represented as:
[0113]
[0114] wherein O t is the output spike of the current time step, i.e., the target spike, Linear h2o is the linear transformation from the hidden layer to the output layer; H t is the hidden layer spike output at the current time step, representing the hidden layer spike output of the current time step.
[0115] Step S35, each target spike is accumulated by the target output layer to generate a Chinese text sentiment classification result.
[0116] It should be noted that the spikes of the output layer are accumulated after all time steps to form the final result for classification. Formulated as:
[0117]
[0118] wherein T is the total number of time steps, Output is the output of the model, representing the classification result of the input text, i.e., the Chinese text sentiment classification result.
[0119] In this embodiment, based on the pre-trained word vector, an initial feature extraction network based on pulse cycle is used to pulse code classification for each text tensor to generate a Chinese text sentiment classification result.
[0120] As a comparison of technical effects, reference can be made in combination with the prior art. The spiking neural network (SNN) is a computational model that simulates the activity of biological neurons, which 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 it in subsequent time steps. The SRNN, through its unique spatio-temporal processing capability, not only can handle complex sequence data, better capture long-distance dependencies and dynamic changes in text, but also can 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 the basic unit of deep learning network construction, each with different characteristics and advantages and disadvantages. RNN can process sequence data, but it has the problem of gradient disappearance, which limits its performance in long sequence sentiment analysis. LSTM effectively solves the problem of gradient disappearance by introducing a gating mechanism, and can capture long-distance dependencies, but the model structure is complex, with many parameters and long training time. GRU is a simplified version of LSTM, which maintains the ability to capture long-distance dependencies while having fewer parameters, but is not as stable as LSTM. Due to the excellent performance of recurrent neural network (RNN) in time series processing and the gradual maturity of SNN training algorithm, researchers have begun to explore the implementation and application of SRNN.
[0122] To solve the above problems, the present application provides 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, and establishes a mapping relationship between text and vector. A fixed embedding layer EmbeddingBag layer is used, and through quantization processing, the continuous embedding vector is converted into a pulse sequence, and the text data is encoded into a pulse signal. In the hidden layer and the output layer, the model uses the LIF (Leaky Integrate-and-Fire) neuron model to limit the range of membrane potential, preventing the membrane potential value from being too large or too small, causing numerical instability or overflow, affecting the training process and convergence of the model, and simulating the membrane potential update and pulse firing process of neurons, which enables the model to capture the dynamic characteristics of time series data. Combined with the feedforward linear layer and the recurrent structure, the pulse state of the hidden layer is returned to the input at each time step, forming a recursive structure. This combination enhances the expressive power of the model and enables it to capture more complex text sentiment information.
[0123] Compared with the prior art, the existing RNN and LSTM have relatively low time resolution when processing time series data, and it is difficult to capture the fine-grained sentiment changes in Chinese text. The feature extraction network based on pulse cycle proposed in the present application introduces a pulse neuron model, which enables the network to simulate the activity of neurons at a finer time scale. This enables the feature extraction network based on pulse cycle to better capture the timing features of sentiment words in Chinese text sentiment analysis and improve the accuracy of sentiment analysis. At the same time, in Chinese text sentiment analysis, the long-time dependence problem has always been a difficult problem for traditional models to overcome. Although LSTM alleviates the long-time dependence problem to some extent, it still has the risk of gradient disappearance and gradient explosion. In contrast, the feature extraction network based on pulse cycle realizes the effective storage and transmission of long-time memory through the synaptic connections between pulse neurons. This enables the feature extraction network based on pulse cycle to better capture the relevance between sentences when processing long text sentiment analysis, improving the ability to handle long-time dependence problems. In addition, RNN and LSTM have low computational efficiency when processing large-scale Chinese text data, resulting in excessive training time. The feature extraction network based on pulse cycle utilizes the information transmission mechanism of pulse neurons to realize sparse coding and event-driven computing, greatly reducing the computational complexity of the model. This enables the feature extraction network based on pulse cycle to significantly improve the computational efficiency while ensuring the analysis effect in Chinese text sentiment analysis, reducing the training cost.
[0124] In summary, in the field of Chinese text sentiment analysis, the existing technology, RNN, LSTM and GRU models usually process sequence data based on fixed time steps, which limits their precision in time resolution. In contrast, the pulse cycle-based feature extraction network can dynamically respond to the occurrence time of events, providing higher time resolution data processing capability, which is crucial for capturing rapid emotional changes in text. At the same time, existing methods encode time information through continuous vector representation, which may cause information transmission loss when processing long sequences. The pulse cycle-based feature extraction network uses pulse-based encoding, which can more effectively encode and transmit time information, reducing the information decay problem 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 cost. The pulse cycle-based feature extraction network 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 will perform calculations at each time step even if there is no new information input. The pulse cycle-based feature extraction network is event-driven and only performs calculations when events occur, resulting in lower computational power consumption. By using the LIF model, it achieves high-performance, low-power Chinese text sentiment analysis.
[0125] Therefore, the present application has higher accuracy compared to traditional RNN-based text sentiment classification methods. Its event-driven nature allows SRNN to respond to inputs at precise time points, enabling higher time resolution data processing and effectively capturing subtle emotional changes in text. Its design is more similar to human brain information processing, simulating neuron firing processes, which may more accurately understand human emotions. The sparsity of the network and its adaptability to neuromorphic computing hardware improve energy efficiency. SRNN has continuous learning ability, adapts to dynamic emotional changes, and has high parameter efficiency, reducing model complexity. At the same time, it has strong resistance to input noise. In addition, due to the computational characteristics of SNN, SNN has a clear advantage in power consumption compared to traditional neural networks with the same structure. Similarly, the pulse cycle-based feature extraction network has a 1-3 order of magnitude advantage over RNN in theoretical power consumption under the same network structure.
[0126] In the embodiment of the present application, the present application provides a Chinese text sentiment classification method, first, obtaining a to-be-detected Chinese text, and preprocessing the to-be-detected Chinese text based on a preset text processing tool to output a target text; then, based on the target text, determining a plurality of text tensors; finally, based on a pre-trained word vector, using an initial feature extraction network based on pulse cycle to pulse code and classify 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 to-be-detected Chinese text, a plurality of text tensors are obtained, based on a pre-trained word vector, using an initial feature extraction network based on pulse cycle to pulse code and classify each text tensor to generate a Chinese text sentiment classification result, through the initial feature extraction network based on pulse cycle proposed in the present application, the coding mode based on pulse can more effectively encode and transmit time information, reduce the information decay problem in long sequence, thereby improving the classification effect.
[0127] Please refer to Figure 4 , Figure 4 The structure block diagram of a Chinese text sentiment classification device provided in the second embodiment of the present application.
[0128] The Chinese text sentiment classification device provided in the present application comprises:
[0129] The obtaining module 401 is configured to obtain a to-be-detected Chinese text, and preprocess the to-be-detected Chinese text based on a preset text processing tool to output a target text;
[0130] The determining module 402 is configured to determine a plurality of text tensors based on the target text;
[0131] The classification module 403 is configured to, based on a pre-trained word vector, use an initial feature extraction network based on pulse cycle to pulse code and classify each text tensor to generate a Chinese text sentiment classification result.
[0132] Further, the preset text processing tool comprises a stop word table and a jiba library; the obtaining module 401 is specifically configured to:
[0133] The stop word table is used to remove redundant characters and redundant symbols of the to-be-detected Chinese text to obtain an intermediate text;
[0134] The jiba library is used to perform word segmentation and stop word removal on the intermediate text to output the target text.
[0135] Further, the determining module 402 is specifically about:
[0136] According to the target text, a vocabulary table is constructed;
[0137] The indexes and labels corresponding to a plurality of words in the vocabulary table are converted to generate a plurality of text tensors.
[0138] Further, the classification module 403 comprises:
[0139] a first submodule, configured to update network parameters of an initial embedding module in an initial feature extraction network based on a pulse cycle by using a pre-trained word vector, and determine a target feature extraction network based on a pulse cycle;
[0140] a second submodule, configured to input each text tensor into the target feature extraction network based on the pulse cycle; the target feature extraction network based on the pulse cycle comprises a target embedding module, a target pulse recurrent neural model, and a target output layer;
[0141] a third submodule, configured to perform feature embedding on each text tensor by using the target embedding module respectively, and output an embedding low-precision vector corresponding to each text tensor;
[0142] a fourth submodule, configured to perform deep feature mining on each embedding low-precision vector by using the target pulse recurrent neural model respectively, and output a target pulse corresponding to each embedding low-precision vector;
[0143] a fifth submodule, configured to accumulate each target pulse by using the target output layer, and generate a Chinese text sentiment classification result.
[0144] Further, the target embedding module comprises an embedding layer, an activation function layer, and a quantization layer; and the third submodule is specifically configured to:
[0145] aggregate each text tensor by using the embedding layer respectively, and output an embedding vector corresponding to each text tensor;
[0146] perform nonlinear mapping on each embedding vector by using the activation function layer respectively, and output a nonlinear vector;
[0147] input each nonlinear vector into the quantization layer for quantization respectively, and generate an embedding low-precision vector corresponding to each nonlinear vector.
[0148] Further, the target pulse recurrent neural model comprises a first full connection layer, a first leaky ReLU neuron layer, a second full connection layer, and a second leaky ReLU neuron layer; and the fourth submodule is specifically configured to:
[0149] splice each embedding low-precision vector with a hidden layer pulse output corresponding to a historical moment of each embedding low-precision vector respectively, and generate a spliced vector corresponding to each embedding low-precision vector;
[0150] input each spliced vector into the first full connection layer respectively, and output a first full connection low-precision vector corresponding to each spliced vector;
[0151] The first leaky pyramidal neuron layer is used for pulse screening and excitation of each first full connection low-precision vector, and hidden layer pulse outputs corresponding to the current moment of each first full connection low-precision vector are output.
[0152] The hidden layer pulse outputs of the current moment are taken as inputs of the second full connection layer respectively, and second full connection low-precision vectors corresponding to the hidden layer pulse outputs of the current moment are output.
[0153] The second leaky pyramidal neuron layer is used for pulse screening and excitation of each second full connection low-precision vector, and target pulses corresponding to each second full connection low-precision vector are generated.
[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 foregoing method embodiments, and will not be described here.
[0155] The embodiment of the application further provides a computer device, including a memory and a processor, the memory stores a computer program; the computer program is executed by the processor, so that the processor executes the steps of the Chinese text sentiment classification method of the above-mentioned embodiment one.
[0156] The embodiment of the application further provides a computer readable storage medium, which stores a computer program / instruction, and the computer program / instruction is executed by a processor to realize the steps of the Chinese text sentiment classification method of the above-mentioned embodiment one.
[0157] The embodiment of the application further provides a computer program product, which includes a computer program / instruction, and the computer program / instruction is executed by a processor to realize the steps of the Chinese text sentiment classification method of the above-mentioned embodiment one.
[0158] In 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, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed units can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.
[0159] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may also be distributed to multiple network units. Part or all of the units can be selected to achieve the purpose of the embodiment scheme according to actual needs.
[0160] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can still be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for Chinese text sentiment classification, characterized in that, The method comprises the following steps: acquiring a Chinese text to be detected, and preprocessing the Chinese text to be detected based on a preset text processing tool to output a target text; determining a plurality of text tensors based on the target text; generating a Chinese text sentiment classification result by performing pulse coding classification on each of the text tensors based on a pre-trained word vector and an initial feature extraction network based on a pulse cycle; the step of generating a Chinese text sentiment classification result by performing pulse coding classification on each of the text tensors based on a pre-trained word vector and an initial feature extraction network based on a pulse cycle comprises the following steps: updating the network parameters of an initial embedding module in the initial feature extraction network based on a pulse cycle by using a pre-trained word vector to determine a target feature extraction network based on a pulse cycle; inputting each of the text tensors into the target feature extraction network based on a pulse cycle; the target feature extraction network based on a pulse cycle comprises a target embedding module, a target pulse cycle neural model, and a target output layer; performing feature embedding on each of the text tensors by using the target embedding module to output an embedded low-precision vector corresponding to each of the text tensors; performing deep feature mining on each of the embedded low-precision vectors by using the target pulse cycle neural model to output a target pulse corresponding to each of the embedded low-precision vectors; generating a Chinese text sentiment classification result by accumulating each of the target pulses through the target output layer; the target pulse cycle neural model comprises a first full connection layer, a first leaky ReLU neuron layer, a second full connection layer, and a second leaky ReLU neuron layer; the step of performing deep feature mining on each of the embedded low-precision vectors by using the target pulse cycle neural model to output a target pulse corresponding to each of the embedded low-precision vectors comprises the following steps: splicing each of the embedded low-precision vectors with a hidden layer pulse output at a historical time corresponding to each of the embedded low-precision vectors to generate a spliced vector corresponding to each of the embedded low-precision vectors; inputting each of the spliced vectors as an input of the first full connection layer to output a first full connection low-precision vector corresponding to each of the spliced vectors; performing pulse screening excitation on each of the first full connection low-precision vectors by using the first leaky ReLU neuron layer to output a hidden layer pulse output at a current time corresponding to each of the first full connection low-precision vectors; inputting each of the hidden layer pulse outputs at the current time as an input of the second full connection layer to output a second full connection low-precision vector corresponding to each of the hidden layer pulse outputs at the current time; generating a target pulse corresponding to each of the second full connection low-precision vectors by performing pulse screening excitation on each of the second full connection low-precision vectors through the second leaky ReLU neuron layer.
2. The Chinese text sentiment classification method of claim 1, wherein, The preset text processing tool comprises a stop word table and a Jiba library; the step of preprocessing the Chinese text to be detected based on the preset text processing tool to output a target text comprises the following steps: removing redundant characters and symbols in the Chinese text to be detected by using the stop word table to obtain an intermediate text; performing word segmentation and stop word removal on the intermediate text by using the Jiba library to output a target text.
3. The Chinese text sentiment classification method of claim 1, wherein, The method comprises the following steps: According to the target text, a vocabulary table is constructed; The indexes and labels corresponding to the words in the vocabulary table are converted to generate a plurality of text tensors.
4. The Chinese text sentiment classification method of claim 1, wherein, The target embedding module comprises an embedding layer, an activation function layer and a quantization layer; the target embedding module is used to perform feature embedding on each text tensor respectively, and output an embedding low-precision vector corresponding to each text tensor, which comprises: Each text tensor is aggregated by the embedding layer respectively, and an embedding vector corresponding to each text tensor is output; Each embedding vector is nonlinearly mapped by the activation function layer respectively, and a nonlinear vector is output; Each nonlinear vector is input into the quantization layer for quantization, and an embedding low-precision vector corresponding to each nonlinear vector is generated.
5. A Chinese text sentiment classification device applied to the Chinese text sentiment classification method of claim 1, characterized in that, The method comprises the following steps: An acquisition module is configured to acquire a Chinese text to be detected, and pre-process the Chinese text to be detected based on a pre-set text processing tool to output a target text; A determination module is configured to determine a plurality of text tensors based on the target text; A classification module is configured to perform pulse coding classification on each text tensor based on a pre-trained word vector and an initial feature extraction network based on pulse cycle to generate a Chinese text sentiment classification result.
6. A computer device, comprising: The computer program is executed to implement the Chinese text sentiment classification method according to any one of claims 1-4.
7. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed to implement the Chinese text sentiment classification method according to any one of claims 1-4.
8. A computer program product, characterised in that, The computer program product comprises a computer program stored on a non-transitory computer readable storage medium, and the computer program comprises program instructions, wherein when the program instructions are executed by a computer, the computer executes the Chinese text sentiment classification method according to any one of claims 1-4.
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