An adaptive sparse sampling text classifier based on gating mechanism

Through the adaptive sparse sampling technology based on the gating mechanism, the problems of high redundancy and low accuracy of existing text classifiers are solved, and efficient, flexible and accurate text classification is achieved, which is suitable for various text tasks.

CN114547291BInactive Publication Date: 2024-09-06ZHEJIANG UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111321902.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-09
Publication Date
2024-09-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Since the model input of existing text classifiers is the entire text, the lack of prior knowledge leads to high redundancy and low accuracy. When the text length is too large, it can only be simply truncated, resulting in high classification time costs and excessive model parameter space. It is difficult to train and lacks high flexibility, agility and accuracy.

Method used

An adaptive sparse sampling text classifier based on the gating mechanism is used to achieve real-time classification of text data through data preprocessing, parameter optimization, sparse sampling and adaptive classification modules, including data preprocessing, keyword extraction, and gravity search. Algorithm optimization, sparse sampling and gated adaptive classification reduce model training and inference time and improve classification efficiency.

Benefits of technology

It achieves text classification with high flexibility, agility and accuracy, overcomes the problems of high time cost and excessive model parameter space of the original classifier, and improves the accuracy and efficiency of text data recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114547291B
    Figure CN114547291B
Patent Text Reader

Abstract

The present invention discloses an adaptive sparse sampling text classifier based on a gating mechanism, which is used for classifying text data and is composed of a text data collector, a database, a text classification recognition instrument, a classification result display instrument and the like. The text classification recognition instrument includes a data preprocessing module, a parameter optimization module, a sparse sampling module, a gated adaptive classification module and an integration module. In order to overcome the shortcomings of existing text classification algorithms, such as poor flexibility, inability to adaptively adjust difficulty according to input, and inability to effectively recognize text, the present invention performs staggered sampling of a given text through various sparse sampling modules, and realizes rapid, efficient and stable classification and recognition of text data by combining a highly flexible adaptive classification module and a highly robust integration module.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of text classification and recognition, and in particular to an adaptive sparse sampling text classifier based on a gating mechanism. Background Art

[0002] Text classification is to classify text according to certain rules. The "rules" can be set by people or automatically summarized from labeled data by algorithms. At present, text classification algorithms are widely used. As the cornerstone of sentiment analysis, intent recognition, question-answer matching, sentence matching, and coreference resolution, the performance of classification algorithms largely determines the performance of various downstream tasks.

[0003] The text classification problem is a classic problem in the field of natural language processing. The earliest related research can be traced back to the use of expert rules (patterns) for classification, but this method is time-consuming and labor-intensive, and the coverage and accuracy are very limited. Later, with the development of statistical learning methods, especially the growth of the number of online texts on the Internet and the rise of machine learning after the 1990s, a process of combining artificial feature engineering with shallow classification modeling has gradually been formed. The main problem with traditional approaches is that their text representation is high-dimensional and sparse, with weak feature expression capabilities, and requires high-cost artificial feature engineering construction. The deep learning method initially achieved great success in images and speech, which also correspondingly promoted the development of deep learning in NLP, making deep learning models show potential in text classification tasks.

[0004] Current deep learning research related to text classification has spawned models based on attention mechanisms and large-scale data, including Transformer and BERT, which have made significant breakthroughs in classification tasks. However, the most advanced text classifiers based on deep learning today, because the input of their models is usually a whole paragraph of text, the lack of prior knowledge leads to high model redundancy and low accuracy, and when the text length is too long, it only performs a simple truncation operation, resulting in the inability to retain valid text content; the above methods used by current mainstream classifiers result in high time cost for text classification, too large model parameter space and difficulty in training. Therefore, there is an urgent need for a text classifier with high flexibility, high agility and high accuracy to solve the above problems. Summary of the invention

[0005] In order to overcome the above shortcomings of current text classifiers, the purpose of the present invention is to provide an adaptive sparse sampling text classifier based on a gating mechanism. Compared with the shortcomings of the original classifiers, which have high classification time cost, large model parameter space and difficulty in training, the novel classifier realizes the recognition and classification of adaptive sparse sampling text data based on the gating mechanism, so that various tasks based on the classifier and its derivative instruments have high flexibility, high agility and high accuracy.

[0006] The technical solution adopted by the present invention to solve the technical problem is: an adaptive sparse sampling text classifier based on a gating mechanism, which is used to classify text data in real time, including a data preprocessing module, a parameter optimization module, a sparse sampling module, an adaptive classification module and an integration module, wherein:

[0007] Data preprocessing module: Its input comes from topic text data, and the text data with a length greater than 1000 words is screened. After being annotated by researchers, text data consisting of m (m>1000) words is obtained. Text * After invalid word processing, we get text = {x′1, x′2, ..., x′ m-k}={x′1,x′2,...,x′ n}, where text is the processed text data, x is the specific character, the superscript * indicates before processing, the superscript ' indicates after processing, k is the number of invalid words deleted, and n is the sentence length after invalid words are processed.

[0008] Extract keywords from the text after invalid word processing. The specific steps are as follows:

[0009] (1) Merge the training text into a label set text set i ={text i1 ,text i2 ,…,text im}, different training set label texts form different label text sets Set = {set1, set2,…, set n}, where i is the corresponding label category and m is the number of texts under the corresponding category.

[0010] (2) Count the average frequency of each word relative to the text in each tag set. The calculation formula is as follows:

[0011]

[0012] Among them, TF ik Word k In the tag set i The average word frequency in count(word k ,text ij ) means word k In text ij The number of times it appears in .

[0013] (3) Calculate the inverse frequency of each word relative to the label. The calculation formula is as follows.

[0014]

[0015] Among them, count(word k ,set j ) represents word word k In the tag set i Medium times, |set j | indicates a tag set set i The total number of words in .

[0016] (4) Calculate the importance score of each word relative to the label:

[0017] TF-IDF ik =TF ik ×IDF ik (3)

[0018] (5) The importance scores of the words in the training set text are searched in the label word set to which the text belongs. The top m words with the highest scores in each text segment constitute the keyword library of the text data of this category. i ={word1,word2,…,word m}, where i is the corresponding category label.

[0019] The importance score of each word relative to each label obtained from the training set is used to guide the subsequent sparse sampling module and serve as the basis for measuring the importance of the field and the difficulty of text classification.

[0020] Parameter optimization module: Through the parameter optimization strategy based on the gravitational search algorithm, the keyword center degree k involved in the sparse sampling module is optimized to achieve the global optimality of each gated adaptive classification module. The specific implementation steps are as follows:

[0021] (1) Algorithm initialization: All particles are randomly initialized, and each particle represents a candidate solution to the problem. In a D-dimensional search space, assuming that there are NP particles, the position of the i-th particle is defined as

[0022]

[0023] Set the iteration end condition, iter max That is, the maximum number of iterations;

[0024] (2) At a certain time t, define the magnitude of the gravitational force exerted by the jth particle on the ith particle for:

[0025]

[0026] Among them, M aj (t) and Mpi (t) are the inertial mass of the acting particle j and the inertial mass of the acted particle i, respectively, R ij (t) is the Euclidean distance between the ith particle and the jth particle, ε is a very small constant, and G(t) is the gravitational constant at time t:

[0027]

[0028] Among them, α is the descent coefficient, G0 is the initial gravitational constant, iter max is the maximum number of iterations;

[0029] (3) The inertial mass of a particle is calculated based on its fitness value. The larger the inertial mass, the closer it is to the optimal value. It also means that the particle has a greater attraction, but its movement speed is slower. Assuming that the gravitational mass is equal to the inertial mass, the mass of the particle can be updated by appropriate calculation rules. The update algorithm is as follows:

[0030] M ai =M pi =M ii =M i ,i=1,2,…,NP (7)

[0031]

[0032]

[0033] Among them, fit i (t) represents the fitness value of the ith particle at time t; M i (t) is the inertial mass of the ith particle; m i represents the absolute mass of the ith particle, m j represents the absolute mass of the jth particle; M ii represents the self-gravitational mass of the ith particle. For solving the minimum problem, best(t) and worst(t) are defined as follows:

[0034]

[0035]

[0036] For solving the maximum problem, best(t) and worst(t) are defined as follows:

[0037]

[0038]

[0039] (4) Assume that the total force acting on the i-th particle in the d-th dimension at time t is It is equal to the sum of the forces exerted on it by all other particles, and the calculation formula is as follows:

[0040]

[0041] Among them, rand j is a random number in the range [0,1], Kbest is the set of the first K particles with the best fitness at the beginning;

[0042] According to Newton's second law, the acceleration of particle i in the dth dimension at time t is for:

[0043]

[0044] (5) In the next iteration, the particle’s new velocity is the sum of part of its current velocity and its acceleration; therefore, during each iteration of GSA, the particle updates its velocity and position according to the following formula:

[0045] v i (t+1)=ωv i (t)+c1r i1 a i (t)+c2r i2 (gbest-x i (t)) (16)

[0046] x i (t+1)=x i (t)+v i (t+1) (17)

[0047] Among them, v i (t) is the velocity of particle i at the tth iteration, x i (t) is the position of particle i at the tth iteration, a i (t) is the acceleration of particle i at the tth iteration, gbest is the current optimal solution, r i1 and r i2 are two random numbers between [0,1]; ω is the gradually decreasing inertia factor, c1 and c2 are the adaptive acceleration coefficients, and the calculation formula is as follows:

[0048]

[0049]

[0050]

[0051] Among them, t and iter max are the current number of iterations and the maximum number of iterations respectively; c 1i、c 1f 、c 2i and c 2f is a constant, so that c1 gradually decreases from 2.5 to 0.5, and c2 gradually increases from 0.5 to 2.5;

[0052] (6) Repeat the above steps until the maximum number of iterations is reached, select the solution with the best fitness value as the optimal solution of the algorithm, end the algorithm and return;

[0053] Furthermore, in order to prevent all agents from being attracted to the local optimal point and unable to jump out of the global optimal solution, chaotic mapping is introduced in the parameter optimization module to form a more globally optimal chaotic gravitational search algorithm. When an agent fails to find a better solution after several consecutive iterations, a chaotic mapping is performed on its position:

[0054]

[0055]

[0056]

[0057] Where f(·) represents the chaotic mapping function, Indicates the position before mapping, represents the position after chaotic mapping, and Respectively represent the positions with the largest and smallest distances in the mapping position, Represents the new position after mapping; The chaos mapping function is very sensitive to the initial value, which makes two agents with similar positions be mapped to completely different positions, further increasing the diversity of the system. Logistic mapping is used as the chaos mapping function used in this module:

[0058] f(x)=μx(1-x) (24)

[0059] Where the parameters μ∈(0,4], x∈[0,1];

[0060] The parameter optimization module of CGSA can break the current local optimal balance at the right time, increase the search breadth of the optimization algorithm, and improve the probability of finding the global optimum within a certain range of search iterations and the number of agents;

[0061] Sparse sampling module: used to introduce staggered sampling to improve classification speed;

[0062] (1) Text data As input, the text is first stripped of high-frequency stop words to reduce the noise that may be generated by the remaining modules.

[0063] (2) Compare the text after removing high-frequency stop words with the keywords of each category in turn i ={word1,word2,…,word m} to obtain the top m possible categories with the highest confidence, the keyword center vector κ i ={k1 i ,k2 i ,…,k n i}, where k j i is the centrality of the confidence ranking j in the i-th category.

[0064] (3) The κ of category i i According to the parameter optimization algorithm module, the parameter vector κ is obtained i , introduce the sparse sampling module, randomly extract the center vector of each category keyword, and obtain the new randomly extracted overall keyword center vector κ={k1,k2,...,k n}, where k i is the degree of the center word randomly and uniformly extracted from each category according to the confidence level, CenterWord={centerword1,centerword2,...,centerword n} is the keyword word list corresponding to the overall keyword center vector, where centerword i k i The corresponding word.

[0065] (4) Input from the keyword word list CenterWord and the overall keyword center vector κ Perform sparse sampling, traverse the keyword table CenterWord, and according to centerword i The central degree k of the corresponding central word i Determine the length range s of sparse sampling i , and obtain the sampling length table S of the corresponding keyword vocabulary = {s1, s2, ..., s n}; and through the sampling length table Sampling is performed separately to obtain TEXT = {text′1, text′2,…, text′ n}, where TEXT is the sampled text set, text′ i The text after the original text is sampled by the keyword at the i-th position.

[0066] (5) Perform word embedding on the sampled text set TEXT. Word embedding is a type of word representation. Words with similar meanings have similar representations. It is a general term for methods of mapping vocabulary to real vectors. Optionally, this application uses the GloVe word vector method, and the input is a single text data in TEXT. After being processed by this method, the encoded text word embedding vector embedding = {X1, X2, ..., X n}, where X is a word vector with a dimension of 300, and embedding is a word vector matrix formed by sequentially concatenating the words that make up the text. Embedding is used as the input of the subsequent gated adaptive classification module. There are a total of n inputs corresponding to n gated adaptive classification modules.

[0067] Adaptive classification module: It is based on the TextRnn model to realize the classification of text data of a certain length. It realizes fast and efficient classification of text data by inputting n intercepted input embeddings. Due to the introduction of the gated adaptive mechanism, it has the advantages of high flexibility and speed. The TextRnn model consists of three parts, namely the input layer, the Bi-LSTM layer and the fully connected layer, as follows:

[0068] (1) Input layer: The dense word vector is truncated, the maximum number of words in a single sentence is set to 256, and the embedding dimension of a single word is 300. For texts of different lengths, fixed-length sentences are randomly truncated to obtain diverse word embedding vectors;

[0069] (2) Bi-LSTM layer, the output dimension is a 128-dimensional vector, that is, the hidden state of the last word is used as the final hidden vector, which can be regarded as containing the information of all the previous words.

[0070] (3) The fully connected layer uses softmax as the activation function to output text classification results;

[0071] The gating adaptive mechanism introduces a keyword-centric gating mechanism on its basis, and makes certain improvements in the second part of the Bi-LSTM layer in the original TextRnn model, namely:

[0072] (4) By using the original embedding = {X1,X2,...,X n} is divided into two parts according to the keywords embedding′={X1,X2,...,X m} and embedding″={X m+1 ,X m+2 ,...,X n} and use it as the bidirectional input of Bi-LSTM to replace the original input.

[0073] (5) When the Bi-LSTM layer performs cyclic forward propagation, add a gate switch:

[0074] gate t =sigmoid((W*LSTM(embedding′))*(W*LSTM(embedding″)) (25)

[0075] Where t is the corresponding time step, W is the gating weight matrix, and LSTM is the computational unit in Bi-LSTM;

[0076] (6) By inputting embedding′ and embedding″, the gate switch gate t Output a value a. If the value a is greater than the threshold α, the current LSTM (embedding′) and LSTM (embedding″) are directly cascaded and output without going through subsequent time steps, and then input into the fully connected layer.

[0077] Integration module: Combine multiple classifiers in a certain way to enhance the generalization ability of the model while increasing the hypothesis space of the algorithm, thereby improving the credibility of the final classification result and increasing robustness. The outputs of each adaptive classification module are weighted based on the threshold to obtain the final classification result.

[0078] The technical concept of the present invention is: by combining a highly flexible sparse sampling algorithm that maximizes the use of original data, an adaptive classification module that reduces the model training and inference time, and an integrated module that can stabilize the recognition and classification results, a highly flexible, highly agile and highly accurate classifier for text data is established, so as to accurately grasp the category of the detected text data, obtain key text information at the first time, and assist the smooth progress of downstream tasks.

[0079] The beneficial effects of the present invention are mainly manifested in: overcoming the shortcomings of the original classifier, such as high classification time cost, large model parameter space and difficulty in training. The classifier realizes the recognition and classification of adaptive sparse sampling text data based on the gating mechanism, so that various tasks based on the classifier and its derivative instruments have high flexibility, high agility and high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0080] Figure 1 This is the structural block diagram of the adaptive sparse sampling text classifier.

[0081] Figure 2 It is an adaptive sparse sampling text classifier. DETAILED DESCRIPTION

[0082] The present invention is described in detail below with reference to the accompanying drawings.

[0083] Reference Figure 1 , an adaptive sparse sampling text classifier based on a gate control mechanism, comprising a text data collector 1, a database 2, a text classification recognition device 3, and a classification result display device 4. The various parts are connected in sequence.

[0084] Reference Figure 2 , the adaptive sparse sampling text classifier 3 based on the gating mechanism also includes:

[0085] The data preprocessing module 5: its input comes from the topic text data, and the text data with a text length of 100 to 3000 words is screened. After being annotated by researchers, the text data consisting of m (3000>m>100) words is obtained. Process text* for invalid words to obtain text = {x′1, x′2, ..., x′ m-k}={x′1,x′2,...,x′ n}, where text is the processed text data, x is the specific character, k is the number of invalid words deleted, and n is the sentence length after invalid words are processed.

[0086] Extract keywords from the text after invalid word processing. The specific steps are as follows:

[0087] (1) Merge the training text into a label set text set i ={text i1 ,text i2 ,…,text im}, different training set label texts form different label text sets Set = {set1, set2,…, set n}, where i is the corresponding label category and m is the number of texts under the corresponding category.

[0088] (2) Count the average frequency of each word relative to the text in each tag set. The calculation formula is as follows:

[0089]

[0090] Among them, TF ik Word wotf k In the tag set i The average word frequency in count(word k ,text ij ) means word k In text ij The number of times it appears in .

[0091] (3) Calculate the inverse frequency of each word relative to the label. The calculation formula is as follows.

[0092]

[0093] Among them, count(word k ,set j ) represents word word k In the tag set i Medium times, |set j | indicates a tag set set i The total number of words in .

[0094] (4) Calculate the importance score of each word relative to the label:

[0095] TF-IDF ik =TF ik ×IDF ik (3)

[0096] (5) The importance scores of the words in the training set text are searched in the label word set to which the text belongs. The top m words with the highest scores in each text segment constitute the keyword library of the text data of this category. i ={word1,word2,…,word m}, where i is the corresponding category label.

[0097] The importance score of each word relative to each label obtained from the training set is used to guide the subsequent sparse sampling module and serve as the basis for measuring the importance of the field and the difficulty of text classification.

[0098] The parameter optimization module 6: optimizes the keyword center degree k involved in the sparse sampling module in the following text through a parameter optimization strategy based on the gravitational search algorithm to achieve the global optimum of each gated adaptive classification module. The specific implementation steps are as follows:

[0099] (1) Algorithm initialization: All particles are randomly initialized, and each particle represents a candidate solution to the problem. In a D-dimensional search space, assuming that there are NP particles, the position of the i-th particle is defined as

[0100]

[0101] Set the iteration end condition, iter max That is, the maximum number of iterations;

[0102] (2) At a certain time t, define the magnitude of the gravitational force exerted by the jth particle on the ith particle for:

[0103]

[0104] Among them, M aj (t) and M pi (t) are the inertial mass of the acting particle j and the inertial mass of the acted particle i, respectively, R ij (t) is the Euclidean distance between the ith particle and the jth particle, ε is a very small constant, and G(t) is the gravitational constant at time t:

[0105]

[0106] Among them, α is the descent coefficient, G0 is the initial gravitational constant, iter max is the maximum number of iterations;

[0107] (3) The inertial mass of a particle is calculated based on its fitness value. The larger the inertial mass, the closer it is to the optimal value. It also means that the particle has a greater attraction, but its movement speed is slower. Assuming that the gravitational mass is equal to the inertial mass, the mass of the particle can be updated by appropriate calculation rules. The update algorithm is as follows:

[0108] M ai =M pi =M ii =M i ,i=1,2,…,NP (7)

[0109]

[0110]

[0111] Among them, fit i (t) represents the fitness value of the ith particle at time t; M i (t) is the inertial mass of the ith particle; m i represents the absolute mass of the ith particle, m j represents the absolute mass of the jth particle; M ii represents the self-gravitational mass of the ith particle. For solving the minimum problem, best(t) and worst(t) are defined as follows:

[0112]

[0113]

[0114] For solving the maximum problem, best(t) and worst(t) are defined as follows:

[0115]

[0116]

[0117] (4) Assume that the total force acting on the i-th particle in the d-th dimension at time t is It is equal to the sum of the forces exerted on it by all other particles, and the calculation formula is as follows:

[0118]

[0119] Among them, rand j is a random number in the range [0,1], Kbest is the set of the first K particles with the best fitness at the beginning;

[0120] According to Newton's second law, the acceleration of particle i in the dth dimension at time t is for:

[0121]

[0122] (5) In the next iteration, the particle’s new velocity is the sum of part of its current velocity and its acceleration; therefore, during each iteration of GSA, the particle updates its velocity and position according to the following formula:

[0123] v i (t+1)=ωv i (t)+c1r i1 a i (t)+c2r i2 (gbest-x i (t)) (16)

[0124] x i (t+1)=x i (t)+v i (t+1) (17)

[0125] Among them, v i (t) is the velocity of particle i at the tth iteration, x i (t) is the position of particle i at the tth iteration, a i (t) is the acceleration of particle i at the tth iteration, gbest is the current optimal solution, r i1 and r i2 are two random numbers between [0,1]; ω is the gradually decreasing inertia factor, c1 and c2 are the adaptive acceleration coefficients, and the calculation formula is as follows:

[0126]

[0127]

[0128]

[0129] Among them, t and iter max are the current number of iterations and the maximum number of iterations respectively; c 1i 、c 1f 、c 2i and c 2f is a constant, so that c1 gradually decreases from 2.5 to 0.5, and c2 gradually increases from 0.5 to 2.5;

[0130] (6) Repeat the above steps until the maximum number of iterations is reached, select the solution with the best fitness value as the optimal solution of the algorithm, end the algorithm and return;

[0131] Furthermore, in order to prevent all agents from being attracted to the local optimal point and unable to jump out of the global optimal solution, chaotic mapping is introduced in the parameter optimization module to form a more globally optimal chaotic gravitational search algorithm. When an agent fails to find a better solution after several consecutive iterations, a chaotic mapping is performed on its position:

[0132]

[0133]

[0134]

[0135] Where f(·) represents the chaotic mapping function, Indicates the position before mapping, represents the position after chaotic mapping, and Respectively represent the positions with the largest and smallest distances in the mapping position, Represents the new position after mapping; The chaos mapping function is very sensitive to the initial value, which makes two agents with similar positions be mapped to completely different positions, further increasing the diversity of the system. Logistic mapping is used as the chaos mapping function used in this module:

[0136] f(x)=μx(1-x) (24)

[0137] Where the parameters μ∈(0,4], x∈[0,1];

[0138] The parameter optimization module of CGSA can break the current local optimal balance at the right time, increase the search breadth of the optimization algorithm, and improve the probability of finding the global optimum within a certain range of search iterations and the number of agents;

[0139] The sparse sampling module 7 is used to introduce staggered sampling to improve the classification speed;

[0140] (1) Text data As input, the text is first stripped of high-frequency stop words to reduce the noise that may be generated by the remaining modules.

[0141] (2) Compare the text after removing high-frequency stop words with the keywords of each category in turn i ={word1,word2,…,word m} to obtain the top m possible categories with the highest confidence, the keyword center vector κ i ={k1 i ,k2 i ,…,k n i}, where k j i is the centrality of the confidence ranking j in the i-th category.

[0142] (3) The κ of category i i According to the parameter optimization algorithm module, the parameter vector κ is obtained i , introduce the sparse sampling module, randomly extract the center vector of each category keyword, and obtain the new randomly extracted overall keyword center vector κ={k1,k2,...,k n}, where k i is the degree of the center word randomly and uniformly extracted from each category according to the confidence level, CenterWord={centerword1,centerword2,...,centerword n} is the keyword word list corresponding to the overall keyword center vector, where centerword i k i The corresponding word.

[0143] (4) Input from the keyword word list CenterWord and the overall keyword center vector κ Perform sparse sampling, traverse the keyword table CenterWord, and according to centerword i The central degree k of the corresponding central word i Determine the length range s of sparse sampling i , and obtain the sampling length table S of the corresponding keyword vocabulary = {s1, s2, ..., s n}; and through the sampling length table Sampling is performed separately to obtain TEXT = {text′1, text′2,…, text′ n}, where TEXT is the sampled text set, text′ i The text after the original text is sampled by the keyword at the i-th position.

[0144] (5) Perform word embedding on the sampled text set TEXT. Word embedding is a type of word representation. Words with similar meanings have similar representations. It is a general term for methods of mapping vocabulary to real vectors. Optionally, this application uses the GloVe word vector method, and the input is a single text data in TEXT. After being processed by this method, the encoded text word embedding vector embedding = {X1, X2, ..., X n}, where X is a word vector with a dimension of 300, and embedding is a word vector matrix formed by sequentially concatenating the words that make up the text. Embedding is used as the input of the subsequent gated adaptive classification module. There are a total of n inputs corresponding to n gated adaptive classification modules.

[0145] The adaptive classification module 8: It is based on the TextRnn model to realize the classification of text data of a certain length. It realizes fast and efficient classification of text data by inputting the intercepted n input embeddings, and has the advantages of high flexibility and rapidity due to the introduction of the gated adaptive mechanism; the TextRnn model consists of three parts, namely the input layer, the Bi-LSTM layer and the fully connected layer, as follows:

[0146] (1) Input layer: The dense word vector is truncated, the maximum number of words in a single sentence is set to 256, and the embedding dimension of a single word is 300. For texts of different lengths, fixed-length sentences are randomly truncated to obtain diverse word embedding vectors;

[0147] (2) Bi-LSTM layer, the output dimension is a 128-dimensional vector, that is, the hidden state of the last word is used as the final hidden vector, which can be regarded as containing the information of all the previous words.

[0148] (3) The fully connected layer uses softmax as the activation function to output text classification results;

[0149] The gating adaptive mechanism introduces a keyword-centric gating mechanism on its basis, and makes certain improvements in the second part of the Bi-LSTM layer in the original TextRnn model, namely:

[0150] (1) By using the original embedding = {X1,X2,...,X n} is divided into two parts according to the keywords embedding′={X1,X2,...,X m} and embedding″={X m+1 ,X m+2 ,...,Xn} and use it as the bidirectional input of Bi-LSTM to replace the original input.

[0151] (2) When the Bi-LSTM layer performs cyclic forward propagation, add a gate switch:

[0152] gate t =sigmoid((W*LSTM(embedding′))*(W*LSTM(embedding″)) (25)

[0153] Where t is the corresponding time step, W is the gating weight matrix, and LSTM is the computational unit in Bi-LSTM;

[0154] (3) By inputting embedding′ and embedding″, the gate switch gate t Output a value a. If the value a is greater than the threshold α, the current LSTM (embedding′) and LSTM (embedding″) are directly cascaded and output without going through subsequent time steps, and then input into the fully connected layer.

[0155] The integration module 9: By combining multiple classifiers in a certain way, the generalization ability of the model is enhanced and the hypothesis space of the algorithm is increased, thereby improving the credibility of the final classification result and increasing the robustness. The outputs of each adaptive classification module are weighted based on the threshold to obtain the final classification result.

[0156] When text data of unknown category is input into the adaptive sparse sampling text classifier, the classification result display device 4 displays the classification result.

[0157] The above embodiments are used to illustrate the present invention rather than to limit the present invention. Any modification and change made to the present invention within the spirit of the present invention and the protection scope of the claims shall fall within the protection scope of the present invention.

Claims

1. An adaptive sparse sampling text classifier based on a gating mechanism, which is composed of a text data collector, a database, a text classification recognition instrument, and a classification result display instrument; the text collector is responsible for collecting texts that meet the requirements from massive text data, and is connected to the database; the database is connected to the text classification recognition instrument and the classification result display instrument in sequence, and can realize text classification through text classification data; it is characterized in that: The text classification recognition instrument comprises a data preprocessing module, a parameter optimization module, a sparse sampling module, a gated adaptive classification module and an integration module; the data preprocessing module is connected to the parameter optimization module, takes the text classification data as input, and takes the processed output text data as input of the parameter optimization module; the parameter optimization module is connected to the corresponding sparse sampling module, and introduces staggered sampling to improve the classification speed; the sparse sampling module is connected to the corresponding gated adaptive classification module, and the classification structure depth is dynamically adjusted according to the task difficulty; each gated adaptive classification module is connected to the same integration module, and the integration module integrates and infers the classification results of each gated adaptive classification module and outputs the final result; The sparse sampling module is used to introduce staggered sampling to improve the classification speed; (1) Text data As input, we first remove high-frequency stop words from the text to reduce the noise that may be generated by the remaining modules; (2) Compare the text after removing high-frequency stop words with the keywords of each category in turn i ={word1,word2,…,word m } to obtain the top m possible categories with the highest confidence, the keyword center vector κ i ={k1 i ,k2 i ,…,k n i }, where k j i is the centrality of the confidence ranking j in the i-th category; (3) The κ of category i i According to the parameter optimization algorithm module, the parameter vector κ is obtained i , introduce the sparse sampling module, randomly extract the center vector of each category keyword, and obtain the new randomly extracted overall keyword center vector κ={k1,k2,...,k n }, where k i is the degree of the center word randomly and uniformly extracted from each category according to the confidence level, CenterWord = {centerword1, centerword2, ..., centerword n } is the keyword word list corresponding to the overall keyword center vector, where centerword i k i The corresponding words; (4) Input from the keyword word list CebterWord and the overall keyword center vector k Perform sparse sampling, traverse the keyword table CenterWord, and according to centerword i The central degree k of the corresponding central word i Determine the length range s of sparse sampling i , and obtain the sampling length table S of the corresponding keyword vocabulary = {s1, s2, ..., s n }; and through the sampling length table Sampling is performed separately to obtain TEXT = {text′1, text′2,…, text′ n }, where TEXT is the sampled text set, text′ i The text after the original text is sampled by the keyword at the i-th position; (5) The sampled text set TEXT is processed by word embedding. Word embedding is a type of word representation. Words with similar meanings have similar representations. It is a general term for methods of mapping vocabulary to real number vectors. The GloVe word embedding method is used, and the input is a single text data in TEXT. After being processed by this method, the encoded text word embedding vector embedding = {X1, X2, ..., X n }, where X is a word vector with a dimension of 300, and embedding is a word vector matrix formed by sequentially concatenating the words that constitute the text; embedding is used as the input of the subsequent gated adaptive classification module, and there are a total of n inputs corresponding to n gated adaptive classification modules.

2. The adaptive sparse sampling text classifier based on the gating mechanism according to claim 1 is characterized in that: The input of the data preprocessing module comes from the topic text data, and the text data with a text length greater than 1000 words is screened. After annotation, the text data consisting of m words is obtained. m>1000; process text* with invalid words to obtain text={x′1,x′2,...,x′ m-k }={x′1,x′2,...,x′ n }, where text is the processed text data, x is the specific character, the superscript * indicates before processing, the superscript ' indicates after processing, k is the number of invalid words deleted, and n is the sentence length after invalid words are processed; Extract keywords from the text after invalid word processing. The specific steps are as follows: (1) Merge the training text into a label set text set i ={text i1 ,text i2 ,…,text im }, different training set label texts form different label text sets Set = {set1, set2,…, set n }, where i is the corresponding label category and m is the number of texts in the corresponding category; (2) Count the average frequency of each word relative to the text in each tag set. The calculation formula is as follows: Among them, TF ik Word k In the tag set i The average word frequency in count(word k ,text ij ) means word k In TeX ij The number of times it appears in (3) Calculate the inverse frequency of each word relative to the label. The calculation formula is as follows; Among them, count(word k ,set j ) represents word word k In the tag set i Medium times, |set j | indicates a tag set set i The total number of words in (4) Calculate the importance score of each word relative to the label: TF-IDF ik =TF ik ×IDF ik (3) (5) The importance scores of the words in the training set text are searched in the label word set to which the text belongs; the top m words with the highest scores in each text segment constitute the keyword library Keywords of the text data of this category i ={word1,word2,…,word m }, where i is the corresponding category label; The importance score of each word relative to each label obtained from the training set is used to guide the subsequent sparse sampling module and serve as the basis for measuring the importance of the field and the difficulty of text classification.

3. The adaptive sparse sampling text classifier based on the gating mechanism according to claim 1 is characterized in that: The parameter optimization module optimizes the keyword centrality k involved in the sparse sampling module in the following text through a parameter optimization strategy based on the gravitational search algorithm, and achieves the global optimization of each gated adaptive classification module. The specific implementation steps are as follows: The parameter optimization module based on the improved gravitational search algorithm is used to optimize the keyword center degree k involved in the sparse sampling module later. The specific steps are as follows: (1) Algorithm initialization: All particles are randomly initialized, and each particle represents a candidate solution to the problem. In a D-dimensional search space, assuming that there are NP particles, the position of the i-th particle is defined as Set the iteration end condition, iter max That is, the maximum number of iterations; (2) At a certain time t, define the magnitude of the gravitational force exerted by the jth particle on the ith particle for: Among them, M aj (t) and M pi (t) are the inertial mass of the acting particle j and the inertial mass of the acted particle i, respectively, R ij (t) is the Euclidean distance between the ith particle and the jth particle, ε is a very small constant, and G(t) is the gravitational constant at time t: Among them, α is the descent coefficient, G0 is the initial gravitational constant, iter max is the maximum number of iterations; (3) The inertial mass of a particle is calculated based on its fitness value. The larger the inertial mass, the closer it is to the optimal value. It also means that the particle has a greater attraction, but its movement speed is slower. Assuming that the gravitational mass is equal to the inertial mass, the mass of the particle is updated using appropriate calculation rules. The update algorithm is as follows: M ai =M pi =M ii =M i ,i=1,2,…,NP (7) Among them, fit i (t) represents the fitness value of the ith particle at time t; M i (t) is the inertial mass of the ith particle; m i represents the absolute mass of the ith particle, m j represents the absolute mass of the jth particle; M ii represents the self-gravitational mass of the i-th particle; for solving the minimum problem, best(t) and worst(t) are defined as follows: For solving the maximum problem, best(t) and worst(t) are defined as follows: (4) Assume that the total force acting on the i-th particle in the d-th dimension at time t is It is equal to the sum of the forces exerted on it by all other particles, and the calculation formula is as follows: Among them, rnad j is a random number in the range [0,1], Kbest is the set of the first K particles with the best fitness at the beginning; According to Newton's second law, the acceleration of particle i in the dth dimension at time t is for: (5) In the next iteration, the particle’s new velocity is the sum of part of its current velocity and its acceleration; therefore, during each iteration of GSA, the particle updates its velocity and position according to the following formula: v i (t+1)=ωv i (t)+c1r i1 a i (t)+c2r i2 (gbest-x i (t)) (16) x i (t+1)=x i (t)+v i (t+1) (17) Among them, v i (t) is the velocity of particle i at the tth iteration, x i (t) is the position of particle i at the tth iteration, a i (t) is the acceleration of particle i at the tth iteration, gbest is the current optimal solution, r i1 and r i2 are two random numbers between [0,1]; ω is the gradually decreasing inertia factor, c1 and c2 are the adaptive acceleration coefficients, and the calculation formula is as follows: Among them, t and iter max are the current number of iterations and the maximum number of iterations respectively; c 1i 、c 1f 、c 2i and c 2f is a constant, so that c1 gradually decreases from 2.5 to 0.5, and c2 gradually increases from 0.5 to 2.5; (6) Repeat the above steps until the maximum number of iterations is reached, select the solution with the best fitness value as the optimal solution of the algorithm, end the algorithm and return; In order to prevent all agents from being attracted to the local optimal point and unable to jump out of the global optimal solution, chaotic mapping is introduced in the parameter optimization module to form a chaotic gravitational search algorithm with more global optimal characteristics; when an agent fails to find a better solution after several consecutive iterations, chaotic mapping is performed on its position: Where f(·) represents the chaotic mapping function, Indicates the position before mapping, represents the position after chaotic mapping, and Respectively represent the positions with the largest and smallest distances in the mapping position, Indicates the new position after mapping; the chaotic mapping function is very sensitive to the initial value, which makes two agents with similar positions be mapped to completely different positions, further increasing the diversity of the system; Logistic mapping is used as the chaotic mapping function used in this module: f(x)=μx(1-x) (24) Where the parameters μ∈(0,4], x∈[0,1]; The parameter optimization module using the chaotic gravitational search algorithm can break the current local optimal balance at the right time, increase the search breadth of the optimization algorithm, and improve the probability of finding the global optimum within a certain number of search iterations and the number of intelligent agents.

4. The adaptive sparse sampling text classifier based on the gating mechanism according to claim 1 is characterized in that: Gated adaptive classification module: Based on the TextRnn model, it realizes the classification of text data of a certain length. It realizes fast and efficient classification of text data by inputting n intercepted input embeddings. Due to the introduction of the gated adaptive mechanism, it has the advantages of high flexibility and speed. The TextRnn model consists of three parts, namely the input layer, the Bi-LSTM layer and the fully connected layer, as follows: (1) In the input layer, the dense word vector is truncated, the maximum number of words in a single sentence is set to 256, and the embedding dimension of a single word is 300; for texts of different lengths, fixed-length sentences are randomly truncated to obtain a diverse word embedding vector; (2) Bi-LSTM layer, the output dimension is a 128-dimensional vector, that is, the hidden state of the last word is used as the final hidden vector, which is considered to contain the information of all previous words; (3) The fully connected layer uses softmax as the activation function to output text classification results; The gating adaptive mechanism introduces a keyword-centric gating mechanism on its basis, and improves the second part of the Bi-LSTM layer in the original TextRnn model, namely: (1) By using the original embedding = {X1,X2,...,X n } is divided into two parts according to the keywords embedding′={X1,x2,...,X m } and embedding″={X m+1 ,X m+2 ,...,X n }, and use it as the bidirectional input of Bi-LSTM to replace the original input; (2) When the Bi-LSTM layer performs cyclic forward propagation, add a gate switch: gate t =sigmoid((W*LSTM(embedding′))*(W*LSTM(embedding″)) (25) Where t is the corresponding time step, W is the gating weight matrix, and LSTM is the computational unit in Bi-LSTM; (3) By inputting embedding′ and embedding″, the gate switch gate t Output a value a. If the value a is greater than the threshold α, the current LSTM (embedding′) and LSTM (embedding″) are directly cascaded and output without going through subsequent time steps, and then input into the fully connected layer.

Citation Information

Patent Citations

  • Fast and effective dynamic MRI method based on compressive sensing technology

    CN103505207A

  • Measuring method and device of fluorescence lifetime

    CN108489947A

  • Chinese spam recognition method based on chaos particle swarm optimization CNN

    CN108647206A

  • Method for automatically categorizing large-scale customer complaint data

    WO2019214133A1