Multi-feature fusion multi-channel text classification method and system

By modeling embedding on two granularities of characters and words, and using the self-attention mechanism for multi-channel fusion, the lack of exploration of character-level embedding and the lack of multi-dimensional semantic information fusion in the existing technology is solved, and the accuracy and generalization ability of text classification are improved.

CN119848261APending Publication Date: 2025-04-18E SURFING VISION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411911451.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

In the prior art, text embedding methods are mostly modeled in terms of words, lacking exploration of character-level embedding, resulting in short text sparse problems and poor classification effects, and the inability to effectively integrate multi-dimensional semantic information, limiting the generalization ability of the model.

Method used

Embedding modeling is performed on two granularities of characters and words, local features and global semantic information are extracted through convolutional neural networks and bidirectional long and short-term memory networks, and multi-channel fusion is used to achieve effective fusion of multi-dimensional semantic information.

Benefits of technology

Through the multi-channel text classification method of multi-feature fusion, the generalization ability of the model in different text classification tasks is improved, the classification accuracy is improved, and the short text sparse problem and the shortcomings of the complementary relationship between local and global features are solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119848261A_ABST
    Figure CN119848261A_ABST
Patent Text Reader

Abstract

The invention relates to a multi-feature fusion multi-channel text classification method and system, and belongs to the field of data processing, and the method comprises the steps: collecting a text data sample, carrying out text preprocessing, and constructing character embedding and word embedding on two granularities of characters and words; character embedding is carried out through one-hot coding, characters are converted into vectors, and then the vectors are input into a convolutional neural network to extract character features; meanwhile, word vectors are generated by using Word2Vec; splicing the character vectors and the word vectors in series, and generating character and word vectors by utilizing a self-attention mechanism; respectively inputting the word vectors into a convolutional neural network and a bidirectional long-short-term memory network, extracting two word features, and splicing the two word features in series to obtain a comprehensive word feature; the character features and the comprehensive word features are used as inputs of multiple channels, and text classification is performed by using a full-connection network after fusion text features are determined by using a self-attention mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of data processing, and in particular relates to a multi-feature fused multi-channel text classification method and system. Background Art

[0002] As one of the core tasks in the field of natural language processing (NLP), text classification is widely used in many practical scenarios such as sentiment analysis, news classification, and spam detection. With the development of deep learning technology, text classification methods based on neural networks have gradually become mainstream. By introducing neural networks, higher-level feature extraction and modeling of text can be performed, thereby improving classification accuracy. However, since different text classification tasks have different requirements for specific levels of text features and semantic information, how to effectively extract and fuse multi-dimensional text feature vectors is still a key challenge to improve classification performance.

[0003] Current text classification methods based on deep learning, such as TextCNN, TextRNN, TextRCNN, LSTM, Transformer, etc., mainly rely on the extraction and training of text features by the neural network layer. Convolutional neural networks (CNNs) are good at extracting local features from texts and can capture important patterns in short texts, so they perform well in short text classification tasks. Long short-term memory networks (LSTMs), as a type of recurrent neural network (RNN), are good at capturing contextual dependencies and can effectively handle classification tasks of long texts. The Transformer architecture captures global information of text through a self-attention mechanism and is widely used in various natural language processing tasks. In addition, word embedding models such as Word2Vec and GloVe provide neural networks with preliminary text vector representations, which effectively improves the effect of text classification.

[0004] However, the existing text embedding methods mostly model words, and have little exploration of finer-grained character-level embedding, which cannot effectively solve the sparsity problem of short texts, resulting in poor classification results. Due to the lack of effective fusion of multi-dimensional semantic information, the complementary relationship between local and global features cannot be flexibly utilized, which limits the generalization ability of the model in different text classification tasks. Summary of the invention

[0005] In view of the above shortcomings of the prior art, the purpose of the invention is to provide a multi-channel text classification method and system with multi-feature fusion, which solves the problem that the traditional text embedding method only focuses on the word level and lacks exploration of character-level embedding, resulting in sparse short text and poor classification effect by embedding modeling at two granularities of characters and words. At the same time, the self-attention mechanism is combined with convolutional neural networks and bidirectional long short-term memory networks to extract local features and global semantic information respectively, and through multi-channel fusion features, the effective fusion of multi-dimensional semantic information is achieved, solving the problem that local and global features cannot complement each other, thereby improving the generalization ability of the model in different text classification tasks and improving the accuracy of classification.

[0006] The first aspect of the present invention provides a multi-channel text classification method for multi-feature fusion, comprising:

[0007] S1, collect text data samples and label the categories for each sample;

[0008] S2, performing text preprocessing on the text data sample;

[0009] S3, segment the pre-processed text data at the character and word granularity, and construct character embedding and word embedding;

[0010] S4, taking the character embedding as input, using one-hot encoding technology, converting the character into a character vector, and inputting the vector into a convolutional neural network to extract character features;

[0011] S5, using the character vector as input, generating a word vector through a Word2Vec model;

[0012] S6, concatenating the character vector and the word vector in series, and inputting the concatenated data into a self-attention model to generate a word vector using a self-attention mechanism;

[0013] S7, inputting the word vector into a convolutional neural network and a bidirectional long short-term memory network respectively, extracting the first word feature and the second word feature;

[0014] S8, concatenating the first word feature and the second word feature in series to obtain a comprehensive word feature;

[0015] S9, using the character features and the comprehensive word features as inputs of multiple channels respectively, and using a self-attention mechanism to determine fused text features;

[0016] S10, taking the fused text features as input, using a fully connected network to perform text classification, and outputting a text category.

[0017] Furthermore, the text preprocessing specifically includes:

[0018] Text standardization, text cleaning, text token replacement, word segmentation, word cleaning, word normalization, and dictionary building.

[0019] Furthermore, the self-attention mechanism is specifically as follows:

[0020] Calculate the similarity score between Q and each K:

[0021] f(Q,K i )=Q T K i

[0022] Among them, f(Q,K i ) represents the similarity score between the query vector and the i-th key vector, Q represents the query vector, K i represents the i-th key vector, () T Represents the transpose of a matrix;

[0023] Use softmax to normalize the feature weights corresponding to each key value:

[0024]

[0025] Among them, a i represents the feature weight corresponding to the i-th key value, L represents the length of the input sequence, exp represents the exponential function, K j represents the j-th key vector;

[0026] Perform weighted summation of the value vector and the corresponding feature weight to calculate the final attention value:

[0027]

[0028] Among them, Attention(Q,K,V) represents the final attention value, V represents the value vector, a i Indicates the feature weight of the i-th word, Value i A vector of values ​​representing the i-th word.

[0029] Furthermore, extracting the first word feature in S7 specifically includes:

[0030] The word vector is input into the convolutional neural network, and convolution operations are performed using convolution kernels of the first preset width, the second preset width, and the third preset width respectively:

[0031] R k =f(K*M k:k+k-1 +b)

[0032] Among them, Rk represents the kth feature matrix after the convolution operation, f() represents the nonlinear activation function, K represents the convolution kernel, M represents the word vector matrix, h represents the sliding window size during the convolution process, and M k:k+h-1 Represents the local text information from the kth row to the k+h-1th row scanned by the convolution kernel in the word vector matrix;

[0033] The eigenvector matrix after the convolution operation with convolution kernels of different widths is expressed as:

[0034] R=(R1,R2,…,R n-h+1 )

[0035] Where R represents the feature vector matrix, n represents the length of the word vector matrix, R1 represents the first row of text information feature vector generated after the convolution kernel scans, R2 represents the second row of text information feature vector generated after the convolution kernel scans, and R n-h+1 Represents the feature vector of the text information in the n-h+1th row generated after the convolution kernel scans;

[0036] Perform a maximum pooling operation on the feature vector matrix to obtain a pooled feature matrix:

[0037] R max =max(R i )

[0038] Among them, R max represents the pooling feature matrix;

[0039] Concatenate each pooled feature matrix to form the first word feature:

[0040]

[0041] Among them, R CNN Represents the first word feature, R u Represents the feature matrix obtained after the maximum pooling of the convolution kernel with the first preset width, R v Represents the feature matrix obtained after the second preset width convolution kernel operation and maximum pooling, R w It represents the feature matrix obtained after the third preset width convolution kernel operation and maximum pooling. Represents a concatenation operation.

[0042] Furthermore, the second word feature in S7 is specifically:

[0043] R LSTM =L(M,H)

[0044] Among them, R LSTMrepresents the second word feature, L represents the operation mode of the bidirectional long short-term memory network, M represents the word vector, and H represents the number of hidden neurons in the bidirectional long short-term memory network.

[0045] Furthermore, the calculation formula of the comprehensive word feature in S8 is specifically:

[0046]

[0047] Among them, R charword Represents comprehensive word features, R CNN Represents the first word feature, R LSTM Indicates the second word feature, Represents a concatenation operation.

[0048] Furthermore, in S9, the feature weight is multiplied by the corresponding channel feature to determine the calculation formula of the fused text feature:

[0049]

[0050] Among them, R F represents the fusion of text features, Attention represents the self-attention mechanism, R char Represents character features, R charword Indicates comprehensive word features. Represents a concatenation operation.

[0051] Furthermore, the S10 specifically includes:

[0052] S1001 takes the fused text features as input, inputs them into the fully connected network, and outputs the category prediction probability through the following formula:

[0053]

[0054] in, represents the category prediction probability, softmax represents the softmax function, z represents the output of the fully connected network, x represents the final text feature, W represents the weight matrix, () T represents the transpose of the matrix, b represents the offset, n represents the number of features, and N represents the total number of categories;

[0055] S1002, taking the category with the highest category prediction probability as the final text category.

[0056] Furthermore, the softmax function is specifically:

[0057]

[0058] in, represents the score of the i-th category in the input vector z, and N represents the total number of categories.

[0059] The second aspect of the present invention proposes a multi-channel text classification system with multi-feature fusion, comprising:

[0060] processor;

[0061] A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the multi-channel text classification method of multi-feature fusion according to any one of claims 1 to 9 is implemented.

[0062] The beneficial effects of the present invention are as follows:

[0063] The method and system of the present invention, by embedding modeling at two granularities, character and word, solve the problem that the traditional text embedding method only focuses on the word level and lacks exploration of character level embedding, resulting in the sparsity problem of short text and poor classification effect. At the same time, the self-attention mechanism is combined with the convolutional neural network and the bidirectional long short-term memory network to extract local features and global semantic information respectively, and through multi-channel fusion features, the effective fusion of multi-dimensional semantic information is achieved, solving the problem that local and global features cannot complement each other, thereby improving the generalization ability of the model in different text classification tasks and improving the accuracy of classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] The accompanying drawings are only used to illustrate specific embodiments and are not considered to limit the present invention. In the entire drawings, the same reference symbols represent the same components. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings.

[0065] Figure 1 A flowchart of a multi-channel text classification method for multi-feature fusion provided by an embodiment of the present invention;

[0066] Figure 2 A schematic diagram of the structure of a multi-channel text classification system with multi-feature fusion provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0067] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work should fall within the scope of protection of the present invention.

[0068] Furthermore, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts disclosed in the present invention.

[0069] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the orientation or position relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside", etc. is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. The terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0070] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of methods and systems consistent with some aspects of the present invention as detailed in the appended claims.

[0071] The present invention proposes a multi-channel text classification method and system with multi-feature fusion, in order to solve the problem that the existing Chinese text embedding methods mostly model based on words, have little exploration of finer-grained character-level embedding, cannot effectively solve the sparsity problem of short texts, and result in poor classification effect; due to the lack of effective fusion of multi-dimensional semantic information, the complementary relationship between local and global features cannot be flexibly utilized, which limits the generalization ability of the model in different text classification tasks.

[0072] Method Embodiment

[0073] Reference Manual Attached Figure 1 , showing a flow chart of a multi-channel text classification method with multi-feature fusion provided in an embodiment of the present invention.

[0074] An embodiment of the present invention provides a multi-channel text classification method with multi-feature fusion, comprising:

[0075] Specifically, the method includes steps S1 to S10.

[0076] S1, collect text data samples and label the category for each sample.

[0077] S2, performs text preprocessing on text data samples.

[0078] In a possible implementation, text preprocessing specifically includes:

[0079] Text standardization, text cleaning, text token replacement, word segmentation, word cleaning, word normalization, and dictionary building.

[0080] In the present invention, through text preprocessing, noise can be removed, data consistency can be enhanced, and feature space can be simplified, thereby improving the accuracy, generalization ability and efficiency of the model.

[0081] S3, segmenting the pre-processed text data at the character and word granularity, and constructing character embedding and word embedding

[0082] Character embedding is a method that converts each character in a text into a low-dimensional vector representation, aiming to capture semantic information at the character level. Character embedding has a more fine-grained feature representation than word embedding, and is particularly advantageous when dealing with scarce vocabulary, spelling errors, or new words.

[0083] Among them, word embedding maps each word in the text into a continuous low-dimensional vector, with the purpose of capturing the semantic relationship between words. Compared with character embedding, word embedding can more directly reflect the semantic similarity of words. Through training, the vectors of semantically similar words will be closer in the embedding space.

[0084] In the present invention, character embedding can handle rare vocabulary, spelling errors and new words, ensuring that the fine-grained features of the text are captured, while word embedding can better reflect the semantic relationship between words and improve the overall semantic understanding of the text. By using these two embedding methods at the same time, the model can take into account both local details and global semantics, thereby improving the accuracy and robustness of text classification.

[0085] S4, takes character embedding as input, uses one-hot encoding technology, converts characters into character vectors, and then inputs them into the convolutional neural network to extract character features.

[0086] One-hot encoding is a common technique for converting discrete data (such as categories or symbols) into numerical representations, and is particularly suitable for processing characters or words in text. The principle is to represent each discrete category (such as a character or word) as a vector of length N, where N is the total number of categories. In this vector, only one position has a value of 1, and all other positions have values ​​of 0.

[0087] Among them, convolutional neural network (CNN) is a type of deep learning model specially designed for processing grid-structured data (such as images, text, etc.), and performs particularly well in tasks such as image recognition and natural language processing. CNN effectively extracts features, reduces parameters, and captures local patterns in data through local perception and weight sharing mechanisms.

[0088] Specifically, one-hot encoding is used to vectorize each character in the text according to the character dictionary to generate a character embedding matrix. One-hot encoding represents each character with a vector of size k, where k is the size of the character dictionary. In the character vector, the element of the corresponding position of the character in the character dictionary is 1, and the elements of other positions are 0. All other characters in the text except the character dictionary are quantized as all-zero vectors. According to the encoding rules, each sentence is represented as a vector sequence of size k. The character dictionary consists of 26 lowercase English letters, 10 Arabic numerals, and 14 other characters, a total of 50 characters, with the specific settings as follows:

[0089] abcdefghijklmnopqrstuvwxyz0123456789.:

[0090] \ / |-@#%~&*<>

[0091] The total length of character embedding is set to 300, and the first 1014 characters of each sample are taken as the sample length. If the length is too long, it is truncated, and if the length is insufficient, it is filled with a 0 vector. The CNN network structure is used to extract local text features without contextual information from character embeddings. Six one-dimensional convolutional neural network layers and three fully connected layers are selected. In addition, in order to increase the diversity of features in the field of view of the CNN convolution kernel, convolution kernels with widths of 3 and 7 are selected to perform convolution operations on the character matrix, and the random inactivation (dropout) method is used between the three fully connected layers to achieve regularization.

[0092] Optionally, the dropout probability is 0.5.

[0093] In the present invention, by using one-hot encoding to vectorize characters and uniquely mapping each character to a specific vector representation, a variety of character types (such as letters, numbers, and symbols) can be processed to adapt to different text contents. The design of the character dictionary ensures the coverage and processing of common characters. At the same time, by embedding at the character level, fine-grained information in the text can be captured, especially when dealing with spelling errors, new words or specific symbols. Character embedding is more flexible than word-level embedding and is suitable for processing sparse text.

[0094] Furthermore, using the local perception mechanism of CNN and extracting local patterns of text through convolution kernels can effectively capture the local dependencies between characters, especially in identifying important information or local features in short texts, thereby increasing the diversity of features and the expressiveness of the model.

[0095] S5, takes the character vector as input and generates word vector through the Word2Vec model.

[0096] Among them, Word2Vec is a commonly used word embedding model that can convert words into low-dimensional, continuous vectors while maintaining the semantic relationship between words. It was proposed by Mikolov et al. in 2013. Based on neural network technology, it learns the performance of each word in context to generate word vectors that can capture semantic similarity. Word2Vec maps words with similar meanings to similar vector space positions through training on large-scale text data.

[0097] In the present invention, word vectors are generated by the Word2Vec model, which can effectively capture the semantic similarity between words. Semantically similar words will be mapped to adjacent positions in the vector space, so that the model can better understand the semantic associations in the text. At the same time, Word2Vec can handle low-frequency words or unregistered words, and generate word vectors through context learning, which improves the generalization ability of the model for rare words and enables the model to better cope with diverse text data.

[0098] S6, concatenates the character vector and word vector, inputs the concatenated data into the self-attention model, and generates word vectors using the self-attention mechanism.

[0099] Among them, the self-attention model is a deep learning mechanism for processing sequence data, which is especially important in natural language processing (NLP). The self-attention model captures global dependencies and contextual information by focusing on the relationship between each element in the input sequence and other elements, thereby effectively modeling long-range dependencies in the sequence.

[0100] In a possible implementation, the self-attention mechanism is specifically:

[0101] Calculate the similarity score between Q and each K:

[0102] f(Q,K i )=Q T K i

[0103] Among them, f(Q,K i ) represents the similarity score between the query vector and the i-th key vector, Q represents the query vector, K i represents the i-th key vector, () T Represents the transpose of a matrix.

[0104] Use softmax to normalize the feature weights corresponding to each key value:

[0105]

[0106] Among them, a i represents the feature weight corresponding to the i-th key value, L represents the length of the input sequence, exp represents the exponential function, K j represents the j-th key vector.

[0107] Perform weighted summation of the value vector and the corresponding feature weight to calculate the final attention value:

[0108]

[0109] Among them, Attention(Q,K,V) represents the final attention value, V represents the value vector, a i Indicates the feature weight of the i-th word, Value i A vector of values ​​representing the i-th word.

[0110] In the present invention, through the self-attention model, weights can be assigned to each character or word, so that the model can dynamically focus on the contextual information that is most important to the current task. This helps the model better capture key semantic fragments when generating word vectors and improves comprehension. At the same time, the self-attention mechanism can efficiently process long texts through parallel calculations without being limited by sequence length. This overcomes the gradient vanishing problem that may occur in traditional recurrent neural networks (RNNs) when processing long sequences, and improves the processing ability of long texts.

[0111] Furthermore, the character vector is concatenated with the word vector, and then further processed through the self-attention mechanism, which can fuse text information of different granularities (character level and word level). This ensures that when the model generates word vectors, it not only considers the semantic information of the word, but also can enhance the feature expression with the help of character-level information, especially when processing fine-grained information (such as word form changes, rare words, etc.).

[0112] S7, input the word vectors into the convolutional neural network and the bidirectional long short-term memory network respectively, and extract the first word feature and the second word feature.

[0113] Among them, the Bidirectional Long Short-Term Memory Network (BiLSTM) is an improved recurrent neural network (RNN) specifically designed for processing sequence data, especially in capturing contextual information and long-distance dependencies. BiLSTM is developed based on the Long Short-Term Memory Network (LSTM), combining two-directional LSTMs to capture the global contextual information of the sequence from both the forward and backward directions.

[0114] In a possible implementation, extracting the first word feature in S7 specifically includes:

[0115] The word vector is input into the convolutional neural network, and the convolution operation is performed using the convolution kernels of the first preset width, the second preset width, and the third preset width respectively:

[0116] R k =f(K*M k:k+k-1 +b)

[0117] Among them, R k represents the kth feature matrix after the convolution operation, f() represents the nonlinear activation function, K represents the convolution kernel, M represents the word vector matrix, h represents the sliding window size during the convolution process, and M k:k+h-1 Represents the local text information from the kth row to the k+h-1th row scanned by the convolution kernel in the word vector matrix.

[0118] In the present invention, the use of convolution kernels of different widths can capture n-gram features of different lengths, enriching the modeling capability of local context information. The diversity of convolution kernels ensures that the model perceives patterns of different lengths, thereby improving the ability to capture complex text structures.

[0119] The eigenvector matrix after the convolution operation with convolution kernels of different widths is expressed as:

[0120] R=(R1,R2,…,R n-h+1 )

[0121] Where R represents the feature vector matrix, n represents the length of the word vector matrix, R1 represents the first row of text information feature vector generated after the convolution kernel scans, R2 represents the second row of text information feature vector generated after the convolution kernel scans, and R n-h+1 Represents the n-h+1th row of text information feature vector generated after the convolution kernel scans.

[0122] Perform the maximum pooling operation on the feature vector matrix to obtain the pooled feature matrix:

[0123] R max =max(R i )

[0124] Among them, R max Represents the pooled feature matrix.

[0125] In the present invention, the use of the maximum pooling operation in CNN can effectively reduce network parameters while retaining important feature information and avoiding overfitting. The pooling operation not only simplifies the feature representation, but also increases the robustness of the network.

[0126] Concatenate each pooled feature matrix to form the first word feature:

[0127]

[0128] Among them, R CNN Represents the first word feature, R u Represents the feature matrix obtained after the maximum pooling of the convolution kernel with the first preset width, R v Represents the feature matrix obtained after the second preset width convolution kernel operation and maximum pooling, R w It represents the feature matrix obtained after the third preset width convolution kernel operation and maximum pooling. Represents a concatenation operation.

[0129] Specifically, three groups of convolution kernels with widths of 3, 4, and 5 are selected to perform convolution operations on the word matrix to enrich the diversity of the CNN convolution kernel field of view. The depth of each group of convolution kernels is 150. The convolution kernel is set to K. The feature matrix after convolution of each convolution kernel is calculated. After convolution, a one-dimensional maximum pooling operation is used to reduce the network parameters. Finally, the final features are spliced ​​after scanning by three groups of convolution kernels.

[0130] In a possible implementation, the second word feature in S7 is specifically:

[0131] R LSTM =L(M,H)

[0132] Among them, R LSTMrepresents the second word feature, L represents the operation mode of the bidirectional long short-term memory network, M represents the word vector, and H represents the number of hidden neurons in the bidirectional long short-term memory network.

[0133] In the present invention, BiLSTM can capture long-range dependencies and bidirectional context information by combining forward and backward LSTM networks. This is particularly important in natural language processing tasks because the meaning of words often depends on the context. Through BiLSTM, the model can have a deeper understanding of the text and capture the global features of long-range dependencies.

[0134] In summary, CNN is good at extracting local features, and BiLSTM is good at capturing global features. By combining the two, the model can handle both short-term and long-term dependency problems, thereby enhancing the overall expression ability of the model, especially when processing complex text data, it can improve classification accuracy.

[0135] S8, concatenating the first word feature and the second word feature to obtain a comprehensive word feature.

[0136] In a possible implementation, the calculation formula of the comprehensive word feature in S8 is specifically:

[0137]

[0138] Among them, R charword Represents comprehensive word features, R CNN Represents the first word feature, R LSTM Indicates the second word feature, Represents a concatenation operation.

[0139] In the present invention, local features (such as n-grams, phrase patterns) and global features (context dependencies) are used simultaneously. This feature fusion method ensures that the model can understand the text from multiple levels and improves the ability to understand complex texts. At the same time, the splicing operation combines different types of features, allowing the model to handle diverse text patterns and relationships. In some tasks, local context information may be more important than global context, while in other tasks, long-distance dependencies may be the key. By combining these two features, the model has better adaptability and can handle different types of text tasks.

[0140] S9 uses character features and comprehensive word features as inputs of multiple channels respectively, and uses the self-attention mechanism to determine the fused text features.

[0141] In a possible implementation, in S9, the feature weight is multiplied by the corresponding channel feature to determine the calculation formula of the fused text feature:

[0142]

[0143] Among them, R F represents the fusion of text features, Attention represents the self-attention mechanism, R char Represents character features, R charword Indicates comprehensive word features. Represents a concatenation operation.

[0144] It should be noted that the dimensions of character embedding and word embedding are both set to 300, and the truncation length of each sample character and word is adjusted according to the average length of the specific task corpus.

[0145] In the present invention, by taking character features and comprehensive word features as inputs of multiple channels respectively, the information at the character level and the word level can be combined to extract features from the text at different granularities. Character features are more suitable for processing fine-grained information, such as spelling errors or scarce vocabulary, while word features can capture higher-level semantic and contextual information. Combining these features enhances the model's ability to understand and express text. At the same time, the self-attention mechanism can automatically assign feature weights according to the context, so that the model can focus on the most important features and reduce the impact of irrelevant information. Through the Attention mechanism, the correlation between character features and word features can be modeled more flexibly, effectively improving the ability to extract key information.

[0146] Furthermore, character features and comprehensive word features extract local details and global semantics respectively, and fuse them through the Attention mechanism, effectively capturing cross-level feature interactions, so that information of different granularities can complement and enhance each other, improving the effect of text classification.

[0147] S10, takes the fused text features as input, uses a fully connected network to perform text classification, and outputs the text category.

[0148] Among them, the fully connected network (FCN) is a basic structure in neural networks and is widely used in various deep learning tasks. Its main feature is that each layer of neurons in the network is connected to all neurons in the previous layer, that is, "fully connected". This structure can achieve global combination and complex mapping of features, thus giving the model powerful expressive power.

[0149] In a possible implementation, S10 specifically includes:

[0150] S1001 takes the fused text features as input, inputs them into the fully connected network, and outputs the category prediction probability through the following formula:

[0151]

[0152] in, represents the category prediction probability, softmax represents the softmax function, z represents the output of the fully connected network, x represents the final text feature, W represents the weight matrix, () T represents the transpose of the matrix, b represents the offset, n represents the number of features, and N represents the total number of categories.

[0153] Specifically, a fully connected network layer is used to realize the mapping from feature space to sample category space. Assume that the number of features is n, the total number of predicted categories is K, and the category prediction probability is obtained after normalization with the softmax function.

[0154] In the present invention, the fully connected network combined with the softmax function can handle multi-category classification tasks. Through the normalized probability distribution, the model can not only handle binary classification problems, but also be well extended to multi-classification problems, output the probability of each category, and ensure the accuracy of category determination.

[0155] S1002, taking the category with the highest category prediction probability as the final text category.

[0156] In the present invention, by selecting the category with the highest prediction probability as the final text category, the model can output the classification result intuitively and accurately. This method is concise and effective, and can make reasonable decisions based on the prediction probability of each category.

[0157] In a possible implementation, the softmax function is specifically:

[0158]

[0159] in, represents the score of the i-th category in the input vector z, and N represents the total number of categories.

[0160] In the present invention, the use of the softmax function makes the output of the model more stable and easy to explain. The probability output by the model can clearly show the prediction confidence of each category, which is helpful for analyzing the decision-making process and results of the model.

[0161] In summary, the use of a fully connected network for classification and the combination of the softmax function for normalization enable the model to have powerful feature integration and classification capabilities, and to generate stable and reasonable category prediction probabilities, thereby achieving higher accuracy and stability in text classification tasks.

[0162] The beneficial effects of the present invention are as follows:

[0163] The method and system of the present invention, by embedding modeling at two granularities, character and word, solve the problem that the traditional text embedding method only focuses on the word level and lacks exploration of character level embedding, resulting in the sparsity problem of short text and poor classification effect. At the same time, the self-attention mechanism is combined with the convolutional neural network and the bidirectional long short-term memory network to extract local features and global semantic information respectively, and through multi-channel fusion features, the effective fusion of multi-dimensional semantic information is achieved, solving the problem that local and global features cannot complement each other, thereby improving the generalization ability of the model in different text classification tasks and improving the accuracy of classification.

[0164] System Example

[0165] Reference Manual Attached Figure 2 , showing a structural schematic diagram of a multi-channel text classification system with multi-feature fusion provided by an embodiment of the present invention.

[0166] An embodiment of the present invention provides a multi-channel text classification system 20 with multi-feature fusion, including:

[0167] Processor 201;

[0168] A memory 202 , wherein computer-readable instructions are stored in the memory, and when the computer-readable instructions are executed by the processor, the multi-channel text classification method with multi-feature fusion according to any one of claims 1 to 9 is implemented.

[0169] The present invention provides a multi-feature fusion multi-channel text classification system 20, which can implement the various steps and technical effects of the multi-feature fusion multi-channel text classification method mentioned above. To avoid repetition, the present invention will not go into details.

[0170] The beneficial effects of the present invention are as follows:

[0171] The method and system of the present invention, by embedding modeling at two granularities, character and word, solve the problem that the traditional text embedding method only focuses on the word level and lacks exploration of character level embedding, resulting in the sparsity problem of short text and poor classification effect. At the same time, the self-attention mechanism is combined with the convolutional neural network and the bidirectional long short-term memory network to extract local features and global semantic information respectively, and through multi-channel fusion features, the effective fusion of multi-dimensional semantic information is achieved, solving the problem that local and global features cannot complement each other, thereby improving the generalization ability of the model in different text classification tasks and improving the accuracy of classification.

[0172] The applicant of the present invention has made a detailed explanation and description of the implementation examples of the present invention in conjunction with the drawings in the specification. However, those skilled in the art should understand that the above implementation examples are only preferred implementation schemes of the present invention, and the detailed description is only to help readers better understand the spirit of the present invention, but not to limit the scope of protection of the present invention. On the contrary, any improvements or modifications based on the inventive spirit of the present invention should fall within the scope of protection of the present invention.

[0173] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the above embodiments, or replace some of the technical features therein 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 invention. Any changes or replacements that can be easily thought of by those skilled in the art within the technical scope disclosed in the present invention should be covered within the protection scope of the present invention.

Claims

1. A multi-channel text classification method with multi-feature fusion, characterized in that: include: S1, collect text data samples and label the categories for each sample; S2, performing text preprocessing on the text data sample; S3, segment the pre-processed text data at the character and word granularity, and construct character embedding and word embedding; S4, taking the character embedding as input, using one-hot encoding technology, converting the character into a character vector, and inputting the vector into a convolutional neural network to extract character features; S5, using the character vector as input, generating a word vector through a Word2Vec model; S6, concatenating the character vector and the word vector in series, and inputting the concatenated data into a self-attention model to generate a word vector using a self-attention mechanism; S7, inputting the word vector into a convolutional neural network and a bidirectional long short-term memory network respectively, extracting the first word feature and the second word feature; S8, concatenating the first word feature and the second word feature in series to obtain a comprehensive word feature; S9, using the character features and the comprehensive word features as inputs of multiple channels respectively, and using a self-attention mechanism to determine fused text features; S10, taking the fused text features as input, using a fully connected network to perform text classification, and outputting a text category.

2. The multi-channel text classification method of multi-feature fusion according to claim 1 is characterized in that: The text preprocessing specifically includes: Text standardization, text cleaning, text token replacement, word segmentation, word cleaning, word normalization, and dictionary building.

3. The multi-channel text classification method of multi-feature fusion according to claim 1 is characterized in that: The self-attention mechanism is specifically: Calculate the similarity score between Q and each K: f(Q,K i )=Q T K i Among them, f(Q,K i ) represents the similarity score between the query vector and the i-th key vector, Q represents the query vector, K i represents the i-th key vector, () T Represents the transpose of a matrix; Use softmax to normalize the feature weights corresponding to each key value: Among them, a i represents the feature weight corresponding to the i-th key value, softmax represents the softmax function, L represents the total number of key vectors, exp represents the exponential function, K j represents the j-th key vector; Perform weighted summation of the value vector and the corresponding feature weight to calculate the final attention value: Among them, Attention(Q,K,V) represents the final attention value, V represents the value vector, Value i A vector of values ​​representing the i-th word.

4. The multi-channel text classification method of multi-feature fusion according to claim 1 is characterized in that: The step of extracting the first word feature in S7 specifically includes: The word vector is input into the convolutional neural network, and convolution operations are performed using convolution kernels of the first preset width, the second preset width, and the third preset width respectively: R k =f(K·M k:k+k-1 +b) Among them, R k represents the i-th feature matrix after the convolution operation, f() represents the nonlinear activation function, K represents the convolution kernel, M represents the word vector matrix, h represents the sliding window size during the convolution process, and M k:k+k-1 represents the local text information from the kth row to the i+h-1th row scanned by the convolution kernel in the word vector matrix, and b represents the bias term; The eigenvector matrix after the convolution operation with convolution kernels of different widths is expressed as: R=(R1,R2,…,R n-h+1 ) Where R represents the feature vector matrix, n represents the length of the word vector matrix, R1 represents the first row of text information feature vector generated after the convolution kernel scans, R2 represents the second row of text information feature vector generated after the convolution kernel scans, and R n-h+1 Represents the feature vector of the text information in the n-h+1th row generated after the convolution kernel scans; Perform a maximum pooling operation on the feature vector matrix to obtain a pooled feature matrix: R max =in(R i ) Among them, R max represents the pooling feature matrix; Concatenate each pooled feature matrix to form the first word feature: Among them, R CNN Represents the first word feature, R u Represents the feature matrix obtained after the maximum pooling of the convolution kernel with the first preset width, R v Represents the feature matrix obtained after the second preset width convolution kernel operation and maximum pooling, R w It represents the feature matrix obtained after the third preset width convolution kernel operation and maximum pooling. Represents a concatenation operation.

5. The multi-channel text classification method of multi-feature fusion according to claim 1 is characterized in that: The second word feature in S7 is specifically: R LSTM =L(M,H) Among them, R LSTM represents the second word feature, L represents the operation mode of the bidirectional long short-term memory network, M represents the word vector, and H represents the number of hidden neurons in the bidirectional long short-term memory network.

6. The multi-channel text classification method of multi-feature fusion according to claim 1 is characterized in that: The calculation formula of the comprehensive word feature in S8 is specifically: Among them, R charword Represents comprehensive word features, R CNN Represents the first word feature, R LSTM Indicates the second word feature, Represents a concatenation operation.

7. The multi-channel text classification method of multi-feature fusion according to claim 1 is characterized in that: In S9, the feature weight is multiplied by the corresponding channel feature to determine the calculation formula of the fused text feature: Among them, R F represents the fusion of text features, Attention represents the self-attention mechanism, R char Represents character features, R charword Indicates comprehensive word features. Represents a concatenation operation.

8. The multi-channel text classification method of multi-feature fusion according to claim 1 is characterized in that: The S10 specifically includes: S1001 takes the fused text features as input, inputs them into the fully connected network, and outputs the category prediction probability through the following formula: in, represents the category prediction probability, softmax represents the softmax function, z represents the output of the fully connected network, x represents the final text feature, W represents the weight matrix, () T represents the transpose of the matrix, b represents the offset, n represents the number of features, and N represents the total number of categories; S1002, taking the category with the highest category prediction probability as the final text category.

9. The multi-channel text classification method of multi-feature fusion according to claim 8 is characterized in that: The softmax function is specifically: in, represents the score of the i-th category in the input vector z, and N represents the total number of categories.

10. A multi-channel text classification system with multi-feature fusion, characterized in that: include: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the multi-channel text classification method of multi-feature fusion according to any one of claims 1 to 9 is implemented.