Text classification method, device, equipment and storage medium based on timeliness
By combining the domain characteristics and semantic characteristics of the article, and using the fusion of the domain fusion matrix and multiple feature extraction layers, the problem of low accuracy of the timeliness classification in the existing technology is solved, and a more accurate timeliness judgment is achieved.
Patent Information
- Application Number
- CN202011498337.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-17
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2040-12-17
AI Technical Summary
In the current technology, in the timeliness classification of articles, it only relies on text content, making it difficult to accurately distinguish the timeliness characteristics of different fields, resulting in low classification accuracy.
Combining the domain characteristics and semantic characteristics of the article, time-sensitive classification is carried out, and the accuracy of feature extraction and classification is improved through the fusion of the domain fusion matrix and multiple feature extraction layers.
It improves the accuracy of article timeliness classification, can more accurately distinguish the timeliness characteristics of different fields, and enhances the judgment of text timeliness.
Smart Images

Figure CN112434166B_ABST
Abstract
Description
Background Art
[0002] For articles, they can be classified according to their timeliness, and the classification result can usually characterize the article as a long-term article or a short-term article. Among them, long-term articles are generally popular science articles, and short-term articles are generally news about sudden events.
[0003] With the continuous development of artificial intelligence technology, people can extract the text features of articles through neural networks, and then classify them according to their text features. However, the timeliness of an article is not only related to its text content but also to other aspects of the article. Classifying the timeliness of a text only by its text content is prone to low timeliness classification accuracy.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application and therefore does not constitute information of the prior art known to ordinary technicians in the field. Summary of the invention
[0005] Based on the above problems, the inventors have conducted corresponding thinking and made targeted improvements, providing a timeliness-based text classification method, a timeliness-based text classification device, an electronic device and a computer-readable storage medium, which can combine the domain characteristics and semantic characteristics of the text to classify the text timeliness, and can improve the accuracy of timeliness classification.
[0006] According to a first aspect of an embodiment of the present application, a timeliness-based text classification method is disclosed, comprising:
[0007] According to the domain of the text to be classified, a domain feature vector corresponding to the text to be classified is determined from the domain fusion matrix;
[0008] Through multiple feature extraction layers corresponding to different extraction targets, feature extraction is performed on the text to be classified respectively to obtain a feature extraction result set;
[0009] The feature extraction results in the feature extraction result set are merged to obtain the semantic feature vector corresponding to the text to be classified;
[0010] The timeliness of the text to be classified is classified according to the domain feature vector and semantic feature vector.
[0011] In one embodiment, based on the above solution, before determining the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified, the method further includes:
[0012] The feature vectors corresponding to each text field in the text field set are concatenated to obtain a target matrix; wherein the text field set includes the field of the text to be classified;
[0013] The target matrix is subjected to multiple different linear processing to obtain the reference indicator matrix, the domain description matrix and the weight reference matrix respectively;
[0014] The domain fusion matrix is calculated according to the reference indicator matrix, the domain description matrix and the weight reference matrix; wherein the domain fusion matrix is composed of domain feature vectors corresponding to each text domain.
[0015] In one embodiment, based on the above solution, the domain fusion matrix is calculated according to the reference indicator matrix, the domain description matrix and the weight reference matrix, including:
[0016] The correlation coefficients between the text fields are calculated by referring to the indicator matrix and the field description matrix;
[0017] Calculate intermediate parameters based on the correlation coefficient and the dimension corresponding to the eigenvector;
[0018] Normalize the intermediate parameters to obtain the similarity between each text field;
[0019] The domain fusion matrix is calculated through the weight reference matrix and similarity.
[0020] In one embodiment, based on the above scheme, feature extraction is performed on the text to be classified respectively through multiple feature extraction layers corresponding to different extraction targets to obtain a feature extraction result set, including:
[0021] The text to be classified is input into a plurality of feature extraction layers, so that each of the plurality of feature extraction layers calculates the word vector of the text to be classified and calculates the corresponding feature extraction results according to the word vector to obtain a feature extraction result set.
[0022] In one embodiment, based on the above solution, each feature extraction result in the feature extraction result set is fused to obtain a semantic feature vector corresponding to the text to be classified, including:
[0023] Performing a linear transformation on each feature extraction result in the feature extraction result set to obtain a weight value set; wherein there is a one-to-one correspondence between each weight value in the weight value set and each feature extraction result in the feature extraction result set;
[0024] The weighted sum of the weight value set and the feature extraction result set is calculated according to the one-to-one correspondence, and the weighted sum is determined as a semantic feature vector.
[0025] In one embodiment, based on the above solution, the timeliness classification of the to-be-classified text is performed according to the domain feature vector and the semantic feature vector, including:
[0026] The domain feature vector and the semantic feature vector corresponding to the text to be classified are concatenated to obtain a reference vector;
[0027] The text to be classified is temporally classified according to the reference vector.
[0028] In one embodiment, based on the above scheme, the timeliness classification of the to-be-classified text is performed according to the reference vector, including:
[0029] Perform linear transformation on the reference vector to obtain the fusion vector;
[0030] Multiply the fusion vector by the preset classification matrix to obtain a reference probability set; wherein each reference probability in the reference probability set corresponds to each timeliness level one by one;
[0031] Normalize each reference probability to obtain the probability of the text to be classified corresponding to each timeliness level;
[0032] The timeliness of the text to be classified is classified according to the probability that the text to be classified corresponds to each timeliness level.
[0033] In one embodiment, based on the above scheme, the timeliness classification of the text to be classified is performed according to the probability that the text to be classified corresponds to each timeliness level, including:
[0034] determining a maximum probability from the probabilities corresponding to each timeliness level;
[0035] The target timeliness level corresponding to the maximum probability is determined as the timeliness classification result of the text to be classified.
[0036] In one embodiment, based on the above solution, a linear transformation is performed on the reference vector to obtain a fusion vector, including:
[0037] The reference vector is linearly transformed, and the product of the linear transformation result and the activation function is calculated, and the product is determined as the fusion vector.
[0038] According to a second aspect of an embodiment of the present application, a time-effectiveness-based text classification device is disclosed, characterized in that it includes: a feature vector determination unit, a feature extraction unit, a feature fusion unit, and a text classification unit, wherein:
[0039] A feature vector determination unit, used to determine a domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified;
[0040] A feature extraction unit, used to extract features from the texts to be classified respectively through a plurality of feature extraction layers corresponding to different extraction targets, and obtain a feature extraction result set;
[0041] A feature fusion unit is used to fuse the feature extraction results in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified;
[0042] The text classification unit is used to perform timeliness classification on the text to be classified based on the domain feature vector and the semantic feature vector.
[0043] In one embodiment, based on the above solution, the above device further includes:
[0044] A vector concatenation unit is used to concatenate the feature vectors corresponding to each text field in the text field set to obtain a target matrix before the feature vector determination unit determines the field feature vector corresponding to the text to be classified from the field fusion matrix according to the field of the text to be classified; wherein the text field set includes the field of the text to be classified;
[0045] The linear calculation unit is used to perform multiple different linear processing on the target matrix to obtain the reference indicator matrix, the domain description matrix and the weight reference matrix respectively;
[0046] The matrix calculation unit is used to calculate the domain fusion matrix according to the reference indicator matrix, the domain description matrix and the weight reference matrix; wherein the domain fusion matrix is composed of domain feature vectors corresponding to each text domain.
[0047] In one embodiment, based on the above solution, the matrix calculation unit calculates the domain fusion matrix according to the reference indicator matrix, the domain description matrix and the weight reference matrix, including:
[0048] The correlation coefficients between the text fields are calculated by referring to the indicator matrix and the field description matrix;
[0049] Calculate intermediate parameters based on the correlation coefficient and the dimension corresponding to the eigenvector;
[0050] Normalize the intermediate parameters to obtain the similarity between each text field;
[0051] The domain fusion matrix is calculated through the weight reference matrix and similarity.
[0052] In one embodiment, based on the above scheme, the feature extraction unit performs feature extraction on the to-be-classified texts respectively through a plurality of feature extraction layers corresponding to different extraction targets, and obtains a feature extraction result set, including:
[0053] The text to be classified is input into a plurality of feature extraction layers, so that each of the plurality of feature extraction layers calculates the word vector of the text to be classified and calculates the corresponding feature extraction results according to the word vector to obtain a feature extraction result set.
[0054] In one embodiment, based on the above solution, the feature fusion unit fuses the feature extraction results in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified, including:
[0055] Performing a linear transformation on each feature extraction result in the feature extraction result set to obtain a weight value set; wherein there is a one-to-one correspondence between each weight value in the weight value set and each feature extraction result in the feature extraction result set;
[0056] The weighted sum of the weight value set and the feature extraction result set is calculated according to the one-to-one correspondence, and the weighted sum is determined as a semantic feature vector.
[0057] In one embodiment, based on the above solution, the text classification unit performs timeliness classification on the text to be classified according to the domain feature vector and the semantic feature vector, including:
[0058] The domain feature vector and the semantic feature vector corresponding to the text to be classified are concatenated to obtain a reference vector;
[0059] The text to be classified is temporally classified according to the reference vector.
[0060] In one embodiment, based on the above solution, the text classification unit performs timeliness classification on the text to be classified according to the reference vector, including:
[0061] Perform linear transformation on the reference vector to obtain the fusion vector;
[0062] Multiply the fusion vector by the preset classification matrix to obtain a reference probability set; wherein each reference probability in the reference probability set corresponds to each timeliness level one by one;
[0063] Normalize each reference probability to obtain the probability of the text to be classified corresponding to each timeliness level;
[0064] The timeliness of the text to be classified is classified according to the probability that the text to be classified corresponds to each timeliness level.
[0065] In one embodiment, based on the above scheme, the text classification unit classifies the text to be classified according to the probability that the text to be classified corresponds to each timeliness level, including:
[0066] determining a maximum probability from the probabilities corresponding to each timeliness level;
[0067] The target timeliness level corresponding to the maximum probability is determined as the timeliness classification result of the text to be classified.
[0068] In one embodiment, based on the above solution, the text classification unit performs a linear transformation on the reference vector to obtain a fusion vector, including:
[0069] The reference vector is linearly transformed, and the product of the linear transformation result and the activation function is calculated, and the product is determined as the fusion vector.
[0070] According to a third aspect of an embodiment of the present application, an electronic device is disclosed, including: a processor; and a memory, wherein computer-readable instructions are stored in the memory, and when the computer-readable instructions are executed by the processor, the timeliness-based text classification method disclosed in the first aspect is implemented.
[0071] According to the fourth aspect of the embodiment of the present application, a computer program medium is disclosed, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the timeliness-based text classification method disclosed in the first aspect of the present application.
[0072] The embodiments of the present application can determine the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified; perform feature extraction on the text to be classified respectively through multiple feature extraction layers corresponding to different extraction targets to obtain a feature extraction result set; fuse each feature extraction result in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified; and perform timeliness classification on the text to be classified according to the domain feature vector and the semantic feature vector. Compared with the prior art, the implementation of the embodiments of the present application can, on the one hand, combine the domain features and semantic features of the text to classify the timeliness of the text, which can improve the accuracy of timeliness classification. On the other hand, the implementation of the embodiments of the present application can also perform feature extraction on the text to be classified through multiple feature extraction layers corresponding to different extraction targets, and fuse the multiple feature extraction results obtained, thereby improving the feature extraction accuracy of the text to be classified, and further, improving the accuracy of timeliness classification.
[0073] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0074] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become readily understood. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, wherein:
[0076] Figure 1 What is shown is a flowchart of a time-effectiveness-based text classification method according to an example implementation of the present application;
[0077] Figure 2 What is shown is a schematic diagram of a feature extraction layer for extracting features from text to be classified according to an example implementation of the present application;
[0078] Figure 3What is shown is a schematic diagram of the structure of a time-effectiveness classification network according to an example implementation of the present application;
[0079] Figure 4 What is shown is a flowchart of a time-effectiveness-based text classification method according to an example implementation of the present application;
[0080] Figure 5 What is shown is a structural block diagram of a time-effectiveness-based text classification device according to an optional exemplary embodiment of the present application;
[0081] Figure 6 Shown is a structural block diagram of a time-effectiveness-based text classification device according to another optional exemplary embodiment of the present application.
[0082] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts. DETAILED DESCRIPTION
[0083] The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present application, and are not intended to limit the scope of the present application in any way. On the contrary, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.
[0084] Those skilled in the art know that the embodiments of the present application can be implemented as a device, apparatus, method or computer program product. Therefore, the present application can be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0085] According to the implementation manner of the present application, a timeliness-based text classification method, a timeliness-based text classification device, an electronic device, and a computer-readable storage medium are proposed.
[0086] Any number of elements in the drawings is for illustration and not limitation, and any naming is for distinction only and does not have any limiting meaning.
[0087] The principles and spirit of the present application are explained in detail below with reference to several representative implementations of the present application. SUMMARY OF THE INVENTION
[0089] Generally speaking, different articles have different time sensitivity. For example, news bulletin articles are usually more time-sensitive, while popular science articles are usually less time-sensitive. The method of timeliness classification is usually to input the text features of the article into a trained classifier, learn the text features, and then output the timeliness classification result with the highest confidence. However, for news articles, the timeliness text features in different fields are usually different. For example, in the social field, emergencies are features of short-term timeliness, while in the scientific field, new astronomical discoveries are features of long-term timeliness. The granularity of short-term and long-term text features is usually different. Short-term timeliness pays more attention to time words, while long-term timeliness pays more attention to the theme content of the entire article. Therefore, the timeliness of an article is not only related to its text content but also to other aspects of the article. Classifying the timeliness of a text only by its text content is prone to the problem of low timeliness classification accuracy.
[0090] Based on the above problems, the applicant thought of combining the domain features and semantic features of the text to classify the text timeliness in order to improve the timeliness classification accuracy, and that feature extraction can be performed on the text to be classified through multiple feature extraction layers corresponding to different extraction targets, and the multiple feature extraction results obtained can be fused to improve the feature extraction accuracy of the text to be classified, so as to further improve the timeliness classification accuracy.
[0091] Application Scenario Overview
[0092] It should be noted that the following application scenarios are only shown to facilitate understanding of the spirit and principle of the present application, and the implementation of the present application is not limited in this respect. On the contrary, the implementation of the present application can be applied to any applicable scenario.
[0093] When applied to article timeliness classification, the domain feature vector of the article can be determined from the domain fusion matrix according to the domain to which the article belongs, and features of the article can be extracted respectively through multiple feature extraction layers corresponding to different extraction targets, and the feature extraction results can be fused to obtain the semantic feature vector of the article. Furthermore, the article can be classified according to the domain feature vector and the semantic feature vector to improve the accuracy of timeliness classification.
[0094] Exemplary Methods
[0095] In combination with the above application scenarios, refer to Figure 1 and Figure 4 To describe the timeliness-based text classification method according to an exemplary embodiment of the present application.
[0096] See also Figure 1 , Figure 1The figure shows a flow chart of a time-based text classification method according to an example embodiment of the present application. The time-based text classification method can be implemented by a server or a terminal device. Figure 1 As shown, the timeliness-based text classification method may include:
[0097] Step S110: determining a domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified.
[0098] Step S120: performing feature extraction on the text to be classified respectively through a plurality of feature extraction layers corresponding to different extraction targets to obtain a feature extraction result set.
[0099] Step S130: Fusing the feature extraction results in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified.
[0100] Step S140: performing timeliness classification on the text to be classified according to the domain feature vector and the semantic feature vector.
[0101] Implementation Figure 1 The timeliness-based text classification method shown can combine the domain features and semantic features of the text to classify the text timeliness, which can improve the timeliness classification accuracy. In addition, it can also extract features of the to-be-classified text through multiple feature extraction layers corresponding to different extraction targets, and fuse the multiple feature extraction results obtained to improve the feature extraction accuracy of the to-be-classified text, thereby improving the timeliness classification accuracy.
[0102] These steps are described in detail below.
[0103] In step S110, a domain feature vector corresponding to the text to be classified is determined from the domain fusion matrix according to the domain of the text to be classified.
[0104] Specifically, the text to be classified can be composed of Chinese characters, foreign characters, numbers, symbols, etc., which are not limited in the embodiments of the present application. Optionally, the text to be classified can also include static images, dynamic images, videos, etc. For example, the text to be classified can be a news article, which can contain text and images, videos, etc. The news text can be composed of a title and a text, and both the title and the text can be used as the content of the text to be classified. The domain feature vector corresponding to the text to be classified can be used as a representation of the field to which the text to be classified belongs.
[0105] In addition, the domain fusion matrix can be obtained by D 领域 To express, D 领域 It can be the vertical concatenation of the domain feature vectors corresponding to each text domain, D 领域Each row in D corresponds to a domain feature vector of a text domain. 领域 The corresponding parameter can be N×D, that is, N rows and D columns; where N is used to represent the number of types in the text field, and the number of types can be expressed as num 领域 , D is used to represent the dimension corresponding to the domain feature vector of each row, which can be expressed as d 领域 , N and D are both positive integers.
[0106] In addition, before determining the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified, the above method may also include the following steps: query whether the domain (such as society) to which the text to be classified belongs exists in the pre-stored text domain set; if so, execute the above-mentioned determination of the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified; if not, generate a specific vector corresponding to the domain to which the text to be classified belongs, and fuse the feature vectors of each text domain with the specific vector according to the target matrix obtained by splicing each text domain in the text domain set to obtain the domain feature vector corresponding to the domain to which the text to be classified belongs, and add the domain feature vector to the domain fusion matrix, and then execute the above-mentioned step S120; wherein, the domain feature vector corresponding to the domain to which the text to be classified belongs is a vector that fuses the feature vectors of each text domain.
[0107] Furthermore, before querying whether the field to which the text to be classified belongs exists in the pre-stored text field set, the above method may also include: reading a label / identifier corresponding to the text to be classified, which label / identifier may be selected by the text inputter and may be used to indicate the field to which the text to be classified corresponds; or, reading all keywords contained in the text to be classified; based on the ratio of the number of keywords belonging to the same target text field to the total number of all keywords; if the ratio is greater than a preset threshold (e.g., 60%), the target text field is determined as the field to which the text to be classified belongs.
[0108] As an optional embodiment, before determining the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified, the above method also includes: splicing the feature vectors corresponding to each text domain in the text domain set to obtain a target matrix; wherein the text domain set includes the domain of the text to be classified; performing multiple different linear processing on the target matrix to obtain a reference indicator matrix, a domain description matrix and a weight reference matrix respectively; calculating the domain fusion matrix according to the reference indicator matrix, the domain description matrix and the weight reference matrix; wherein the domain fusion matrix is composed of the domain feature vectors corresponding to each text domain.
[0109] Specifically, the text domain set may include one or more domains. For example, the text domain set may include text domains such as politics and law, economy, culture and education, health, sports, and society. If the feature vectors corresponding to the text domains such as politics and law, economy, culture and education, health, sports, and society are F1=(a1, a2, a3), F2=(b1, b2, b3), F3=(c1, c2, c3), F4=(d1, d2, d3), F5=(e1, e2, e3), ...; wherein the feature vectors corresponding to the text domains such as politics and law, economy, culture and education, health, sports, and society correspond to the same dimension.
[0110] Then, by concatenating the feature vectors corresponding to each text field in the text field set, we can get the target matrix, which can be expressed as E 领域 , the size of the target matrix can be expressed as (num 领域 , d 领域 ), where num 领域 It is used to indicate the number of text domain types in the text domain set, d 领域 It is used to represent the dimension of the feature vector corresponding to each text field mentioned above (e.g., 3). Based on the above example, E 领域 It can be exemplified as:
[0111]
[0112] In addition, before the feature vectors corresponding to each text field in the text field set are spliced to obtain the target matrix, the above method may also include the following steps: select the corresponding random vectors for each text field, each random vector corresponds to the same dimension; input the random vector into the text classification network so that the text classification network predicts the reference field corresponding to the random vector; use AdamW (Adaptive moment estimation) as the optimizer of the model to calculate the loss function between the reference field corresponding to the random vector and the text field corresponding to the random vector; adjust the random vector according to the loss function until the loss function converges, so as to obtain the feature vectors corresponding to each text field. Among them, the loss function can be a 0-1 loss function, an absolute value loss function, a logarithmic loss function, an exponential loss function, a Hinge loss function, a perceptual loss function or a cross entropy loss function, etc., which is not limited in the embodiments of the present application. It should be noted that AdamW is an extension of the stochastic gradient descent method, and its stochastic gradient descent maintains a single learning rate for all weight updates.
[0113] In addition, the target matrix is subjected to multiple different linear processing to obtain the reference indicator matrix, the domain description matrix and the weight reference matrix, including: Q , UK and U V Respectively with E 领域 By multiplying them, we can obtain the reference indicator matrix, the domain description matrix and the weight reference matrix respectively, so as to realize multiple different linear processing of the target matrix; among them, U Q , U K and U V The reference indicator matrix can be obtained by Q 领域 To express, Q 领域 =E 领域 *U Q , the domain description matrix can be obtained by K 领域 To express, K 领域 =E 领域 *U K , the weight reference matrix can be obtained by V 领域 To express, V 领域 =E 领域 *U V .
[0114] It can be seen that the implementation of this optional embodiment can determine the category features corresponding to the text to be classified, which is conducive to improving the timeliness classification accuracy of the text by combining the text features.
[0115] As an optional embodiment, a domain fusion matrix is calculated based on a reference indicator matrix, a domain description matrix and a weight reference matrix, including: calculating the correlation coefficient between each text domain through the reference indicator matrix and the domain description matrix; calculating intermediate parameters based on the correlation coefficient and the dimension corresponding to the eigenvector; normalizing the intermediate parameters to obtain the similarity between each text domain; and calculating the domain fusion matrix through the weight reference matrix and the similarity.
[0116] Among them, the reference indicator matrix, domain description matrix and weight reference matrix are calculated based on the attention mechanism. It should be noted that the attention mechanism is a data processing method in machine learning, which can be applied to various types of machine learning tasks such as natural language processing, image recognition and speech recognition.
[0117] Specifically, Q 领域 It is used to represent the attention weight of each row feature vector in the target matrix, K 领域 Used to describe the field corresponding to each row of feature vectors, V 领域 It is used to characterize the feature vectors of each row after reinforcement learning in the target matrix. Based on this, the correlation coefficients between the text fields are calculated by referring to the indicator matrix and the field description matrix, including: determining K 领域 The corresponding transposed matrix K 领域 T; Q 领域 *K 领域 T Determined as the correlation coefficient between each text field, correlation coefficient = Q 领域 *K 领域 T Then, the intermediate parameters are calculated based on the correlation coefficient and the dimension corresponding to the eigenvector, including: 领域 *K 领域 T and special 领域 calculate Will Then, the intermediate parameters are normalized to obtain the similarity between the text fields, including: Normalization is performed, and the normalization result is used to represent the similarity between each text field. Then, the weight reference matrix and the similarity calculation field fusion matrix are used, including: calculating V 领域 and softmax The product of Among them, D 领域 You can use (num 领域 , d 领域 ), that is, the domain fusion matrix D 领域 With the target matrix E 领域 Both correspond to num 领域 There are (e.g., 5) text domains and each text domain corresponds to a dimension d 领域 (e.g., 5 dimensions). For example, the above domain fusion matrix can be expressed as:
[0118]
[0119] Regarding the above D 领域It should be noted that the text domain set may include the text domains of politics and law, economy, culture, education, health, sports, society, etc. Specifically, the feature vector of politics and law can be (a1′, a2′, a3′) after integrating the feature vectors of the text domains of economy, culture, education, health, sports, and society; the feature vector of the economic text domain can be (b1′, b2′, b3′) after integrating the feature vectors of the text domains of politics and law, economy, sports, and society; the feature vector of the text domain of culture, education, health, can be (c1′, c2′, c3′) after integrating the feature vectors of the text domains of politics and law, economy, sports, and society; the feature vector of the text domain of sports can be (d1′, d2′, d3′) after integrating the feature vectors of the text domains of politics and law, economy, culture, education, health, and society; the feature vector of the social text domain can be (e1′, e2′, e3′) after integrating the feature vectors of the text domains of politics and law, economy, culture, education, health, and society.
[0120] It can be seen that the implementation of this optional embodiment can utilize the reference indicator matrix, the domain description matrix and the weight reference matrix in the self-attention mechanism to improve the feature similarity between related domains, so as to improve the accuracy of timeliness classification.
[0121] In step S120, feature extraction is performed on the text to be classified respectively through a plurality of feature extraction layers corresponding to different extraction targets to obtain a feature extraction result set.
[0122] Specifically, the extraction target can be represented by a weight value. If there are two feature extraction layers corresponding to different extraction targets, then the weight values corresponding to the two feature extraction layers are also different. For example, if the two feature extraction layers are convolutional layers, the convolution kernels of each convolutional layer are different, and the convolution kernel is composed of multiple weight values. The size of the convolution kernel can be n*n, where n is a positive integer.
[0123] In addition, the feature extraction result set includes feature extraction results respectively extracted by multiple feature extraction layers; each feature extraction result in the feature extraction result set is related to other feature extraction results in the feature extraction result set.
[0124] As an optional embodiment, feature extraction is performed on the text to be classified respectively through multiple feature extraction layers corresponding to different extraction targets to obtain a feature extraction result set, including: inputting the text to be classified into multiple feature extraction layers, so that each feature extraction layer in the multiple feature extraction layers calculates the word vector of the text to be classified and calculates the corresponding feature extraction results based on the word vector to obtain a feature extraction result set.
[0125] Among them, multiple feature extraction layers may belong to the BERT (Bidirectional Encoder Representation from Transformers) model. BERT is used to learn task-independent text features in large-scale unsupervised text corpora using the MASK language model. The text features expressed by each feature extraction layer in BERT have different granularity. Generally, the lower layers (e.g., 1 to 6 layers) can express underlying features such as text grammar and syntax, and the higher layers (e.g., 7 to 12 layers) can express text themes, abstract summaries and other features. Based on this, optionally, feature extraction is performed on the text to be classified respectively through multiple feature extraction layers corresponding to different extraction targets to obtain a set of feature extraction results: feature extraction is performed on the text to be classified respectively through multiple feature extraction layers corresponding to different extraction targets in BERT to obtain a set of feature extraction results.
[0126] Optionally, the text to be classified is input into multiple feature extraction layers so that each of the multiple feature extraction layers calculates the word vector of the text to be classified, including: performing word segmentation processing on the text to be classified to obtain text segmentation; inputting the text segmentation into multiple feature extraction layers so that each of the multiple feature extraction layers calculates the word vector of the text segmentation; wherein the text segmentation includes multiple segmentations, and the text to be classified is composed of multiple segmentations.
[0127] Specifically, the text segmentation is input into a plurality of feature extraction layers so that each of the plurality of feature extraction layers calculates the word vector of the text segmentation, including: the text segmentation is input into the first layer of the plurality of feature extraction layers so that the first layer calculates the word vectors respectively corresponding to the plurality of word segmentations in the text segmentation to obtain a first word vector set; each word vector in the first word vector set is determined as the input of the second layer of the plurality of feature extraction layers so that the second layer calculates the word vector respectively corresponding to each word vector in the first word vector set to obtain a second word vector set; wherein the input of each layer of the plurality of feature extraction layers (except the first layer) is the output of the previous layer.
[0128] Alternatively, the text segmentation is input into multiple feature extraction layers so that each of the multiple feature extraction layers calculates the word vector of the text segmentation, including: inputting the text segmentation into the first layer of the multiple feature extraction layers so that the first layer calculates the word vector of the text segmentation to obtain a first word vector set; determining each word vector in the first word vector set and the text segmentation as the input of the second layer of the multiple feature extraction layers so that the second layer calculates the word vector corresponding to each word vector in the first word vector set to obtain a second word vector set.
[0129] In addition, the feature extraction results corresponding to each other are calculated based on the word vectors to obtain a set of feature extraction results, including: adding the word vectors, and calculating the quotient of each element in the addition result divided by the number of word vectors as the feature extraction result corresponding to the feature extraction layer; wherein the feature extraction result can be a sentence vector, which is used as the unique representation of the article to be classified for the extraction purpose of the feature extraction layer. It should be noted that since different feature extraction layers correspond to different feature extraction purposes, different feature extraction layers correspond to different word vectors, and based on the fact that each feature extraction layer corresponds to a different word vector, the feature extraction results corresponding to the feature extraction layer are also different; wherein, the number of word vectors output by a feature extraction layer can be one or more, which is not limited in the embodiments of the present application.
[0130] For example, if the multiple feature extraction layers include layer A and layer B, the word vectors output by layer A include word vectors A1=(a11, a12, a13), word vectors A2=(a21, a22, a23), and word vectors A3=(a31, a32, a33), and the word vectors output by layer B include word vectors B1=(b11, b12, b13), word vectors B2=(b21, b22, b23), and word vectors B3=(b31, b32, b33), then the feature extraction result corresponding to layer A can be The feature extraction result corresponding to layer B can be
[0131] See also Figure 2 , Figure 2 FIG. 1 is a schematic diagram of a feature extraction layer for extracting features from text to be classified according to an exemplary embodiment of the present application. Figure 2 As shown, the input of the i-th feature extraction layer 200 (i.e., the i-th layer) can be the output vector 1 of the (i-1)-th layer, the output vector 2 of the (i-1)-th layer, ..., the output vector n of the (i-1)-th layer, and the output can be the output vector 1 of the i-th layer, the output vector 2 of the i-th layer, ..., the output vector n of the i-th layer; wherein n is a positive integer, and i can be used as the unique representation of the current feature extraction layer among multiple feature extraction layers. For example, if the number of multiple feature extraction layers is 5, then i∈[1,5]. Specifically, for any feature extraction layer among the multiple feature extraction layers (except the first feature extraction layer), it can be Figure 2 The feature extraction layer 200 shown, that is, uses the output of the previous feature extraction layer (ie, the (i-1) layer) as the input of this layer, and uses the output of this layer as the input of the next feature extraction layer.
[0132] Generally speaking, due to the different feature granularity of short-term text and long-term text recognition, the characteristics of short-term text are usually certain sentences with time words (such as recently, recently, ...), and the required text granularity is low-level granularity. Long-term text is generally analyzed as a whole (such as the origin of the universe), so the text granularity required for long-term text is high-level granularity. Through the multi-layer feature extraction and fusion in this application, it can be helpful to distinguish whether the text to be classified is long-term or short-term, and improve the classification accuracy of the text to be classified.
[0133] In step S130, the feature extraction results in the feature extraction result set are fused to obtain a semantic feature vector corresponding to the text to be classified.
[0134] Specifically, the fusion result can be used as a semantic feature vector corresponding to the text to be classified, and the semantic feature vector is used to represent the semantics corresponding to the text to be classified.
[0135] As an optional embodiment, each feature extraction result in the feature extraction result set is fused to obtain a semantic feature vector corresponding to the text to be classified, including: performing a linear transformation on each feature extraction result in the feature extraction result set to obtain a weight value set; wherein there is a one-to-one correspondence between each weight value in the weight value set and each feature extraction result in the feature extraction result set; and calculating the weighted sum of the weight value set and the feature extraction result set according to the one-to-one correspondence, and determining the weighted sum as the semantic feature vector.
[0136] Among them, each feature extraction result in the feature extraction result set is linearly transformed to obtain a weight value set, including: performing a linear transformation softmax (V i层的输出向量 *U 文本权重i ), to convert each feature extraction result into a weight value W corresponding to each feature extraction result 文本权重i , and obtain a set of weight values, where i is a positive integer and is used to represent the i-th layer in multiple feature extraction layers.
[0137] For example, if the feature extraction result set includes feature extraction result 1, feature extraction result 2 and feature extraction result 3, the linear layer can convert feature extraction result 1, feature extraction result 2 and feature extraction result 3 into weight value 1, weight value 2 and weight value 3 respectively, and weight value 1, weight value 2 and weight value 3 can constitute the above-mentioned weight value set.
[0138] Then, the weighted sum of the weight value set and the feature extraction result set is calculated according to the one-to-one correspondence, and the weighted sum is determined as the semantic feature vector, including: calculating W according to the one-to-one correspondence 文本权重1 *V 1层的输出向量 +W 文本权重2 *V2层的输出向量 +……+W 文本权重n *V n层的输出向量 , the calculation result is determined as the semantic feature vector, and n is used to represent the number of feature extraction layers.
[0139] It can be seen that the implementation of this optional embodiment can fuse feature extraction results of different granularities, thereby improving the feature extraction accuracy of the text to be classified, which is beneficial to improving the timeliness classification accuracy of the text to be classified.
[0140] In step S140, the text to be classified is time-sensitively classified according to the domain feature vector and the semantic feature vector.
[0141] Specifically, timeliness is used to indicate the timeliness sensitivity of the text to be classified. The timeliness classification results corresponding to different texts to be classified may be different or the same. The timeliness classification results may be represented by levels (e.g., long timeliness, medium timeliness, short timeliness) or by numerical values (e.g., 20, 30, ...). The higher the numerical value, the lower the timeliness of the text to be classified (e.g., breaking news).
[0142] As an optional embodiment, timeliness classification is performed on the text to be classified based on the domain feature vector and the semantic feature vector, including: concatenating the domain feature vector and the semantic feature vector corresponding to the text to be classified to obtain a reference vector; and timeliness classification is performed on the text to be classified based on the reference vector.
[0143] Specifically, the reference vector can represent both the domain feature vector and the semantic feature vector. The domain feature vector and the semantic feature vector corresponding to the text to be classified are concatenated to obtain the reference vector, including: 领域 The semantic feature vector v corresponding to the text to be classified 文本 , get the reference vector v 参考 =concat(v 领域 , v 文本 ), where v 参考 The dimension can be v 领域 and v 文本 The sum of the dimensions of .
[0144] It can be seen that by implementing this optional embodiment, the timeliness classification of the text to be classified can be performed by combining the reference vector of the domain feature vector and the semantic feature vector, thereby improving the timeliness classification accuracy of the text to be classified.
[0145] As an optional embodiment, timeliness classification is performed on the text to be classified according to the reference vector, including: linearly transforming the reference vector to obtain a fusion vector; multiplying the fusion vector with a preset classification matrix to obtain a reference probability set; wherein each reference probability in the reference probability set corresponds one-to-one to each timeliness level; normalizing each reference probability to obtain the probability that the text to be classified corresponds to each timeliness level; and classifying the text to be classified according to the probability that the text to be classified corresponds to each timeliness level.
[0146] Specifically, the fusion vector is multiplied by the preset classification matrix to obtain a reference probability set, including: 融合 With the preset classification matrix U 分类 Multiply them to obtain a reference probability set. Then, normalize each reference probability to obtain the probability of the text to be classified corresponding to each timeliness level, including: normalize each reference probability by a softmax function softmax(v 融合 *U 分类 ), and obtain the probability score of the text to be classified corresponding to each timeliness level 时效性 .
[0147] It can be seen that the implementation of this optional embodiment can improve the timeliness classification accuracy of the text to be classified by fusing the domain feature vector and the semantic feature vector.
[0148] As an optional embodiment, the text to be classified is time-sensitively classified according to the probabilities of the text to be classified corresponding to each time-sensitive level, including: determining the maximum probability from the probabilities corresponding to each time-sensitive level; and determining the target time-sensitive level corresponding to the maximum probability as the time-sensitive classification result of the text to be classified.
[0149] Specifically, the target timeliness corresponding to the maximum probability may be long timeliness, short timeliness, medium timeliness, etc., and the timeliness classification result of the text to be classified may also include long timeliness, short timeliness or medium timeliness, which is not limited in the embodiments of the present application.
[0150] In addition, after determining the target timeliness level corresponding to the maximum probability as the timeliness classification result of the text to be classified, the above method may further include: generating a prompt message including the timeliness classification result and displaying the prompt message.
[0151] And, after determining the target timeliness level corresponding to the maximum probability as the timeliness classification result of the text to be classified, the above method may also include: adjusting the background color of the text to be classified in the text content display interface according to the timeliness classification result, the adjusted background color is consistent with the preset background color (such as red), so that the user can directly understand the timeliness of the text to be classified when browsing the text content of the text to be classified; wherein, the timeliness classification result corresponds to the preset background color, and different timeliness classification results can correspond to different preset background colors.
[0152] And, after determining the target timeliness level corresponding to the maximum probability as the timeliness classification result of the text to be classified, the above method may also include: setting the timeliness that matches the text to be classified according to the timeliness classification result; when it is detected that the timeliness has expired, the display entrance of the text to be classified can be removed from the display interface to avoid expired text occupying the display interface, which is conducive to improving the real-time performance of the articles displayed on the display interface.
[0153] For example, a red preset background color may be used to indicate long-term validity, a yellow preset background color may be used to indicate medium-term validity, and a green preset background color may be used to indicate short-term validity.
[0154] It can be seen that by implementing this optional embodiment, the timeliness classification result of the text to be classified can be determined according to the probability corresponding to each timeliness level, thereby improving the timeliness classification accuracy of the text to be classified.
[0155] As an optional embodiment, performing a linear transformation on the reference vector to obtain a fused vector includes: performing a linear transformation on the reference vector, calculating the product of the linear transformation result and the activation function, and determining the product as the fused vector.
[0156] The reference vector is linearly transformed, and the product of the linear transformation result and the activation function is calculated, and the product is determined as the fusion vector, including: 融合 Perform a linear transformation v on the reference vector 参考 *U 融合 , and calculate the linear transformation result v 参考 *U 融合 The product of tanh(v 参考 *U 融合 ), the product is determined as the fusion vector v 融合 Among them, the activation function can also be a sigmoid function, a ReLU function, an ELU function, a PReLU function, etc., which is not limited in the embodiment of the present application.
[0157] See also Figure 3 , Figure 3FIG. 1 is a schematic diagram of a time-sensitive classification network according to an exemplary embodiment of the present application. Figure 3 As shown, the temporal classification network may include a first feature extraction layer 311, a second feature extraction layer 312, ..., an nth feature extraction layer 313, a self-attention layer 320 and a fusion layer 330; wherein n is a positive integer.
[0158] Among them, the self-attention layer 320 is used to perform multiple different linear processing on the target matrix to obtain a reference indicator matrix, a domain description matrix and a weight reference matrix respectively; wherein the target matrix is obtained by concatenating the feature vectors corresponding to each text domain in the text domain set; the domain fusion matrix is calculated according to the reference indicator matrix, the domain description matrix and the weight reference matrix; and the domain feature vector corresponding to the text to be classified is determined from the domain fusion matrix according to the domain of the text to be classified.
[0159] Among them, the first feature extraction layer 311, the second feature extraction layer 312, ..., the nth feature extraction layer 313 are respectively used to generate feature extraction results corresponding to different extraction targets, that is, feature extraction result 1, feature extraction result 2, ..., feature extraction result n; wherein, feature extraction result 1, feature extraction result 2, ..., feature extraction result n correspond one-to-one with the first feature extraction layer 311, the second feature extraction layer 312, ..., the nth feature extraction layer 313; furthermore, the weighted sum between weight 1, weight 2, ..., weight n corresponding to each feature extraction result and feature extraction result 1, feature extraction result 2, ..., feature extraction result n can be calculated to realize the fusion of multiple feature extraction results and obtain a semantic feature vector.
[0160] The fusion layer 330 is used to fuse the domain feature vector and the semantic feature vector and perform timeliness classification on the text to be classified according to the fusion result.
[0161] See also Figure 4 , Figure 4 FIG. 1 is a flow chart of a time-based text classification method according to an example implementation of the present application. Figure 4 As shown, the timeliness-based text classification method may include: steps S400 to S422.
[0162] Step S400: concatenate the feature vectors corresponding to each text field in the text field set to obtain a target matrix; wherein the text field set includes the field of the text to be classified.
[0163] Step S402: Perform multiple different linear processing on the target matrix to obtain a reference indicator matrix, a domain description matrix and a weight reference matrix respectively.
[0164] Step S404: Calculate the correlation coefficients between the text fields by referring to the indicator matrix and the field description matrix, calculate the intermediate parameters based on the correlation coefficients and the dimensions corresponding to the feature vectors, normalize the intermediate parameters, obtain the similarities between the text fields, and then calculate the field fusion matrix by using the weight reference matrix and the similarities; wherein the field fusion matrix is composed of the field feature vectors corresponding to the text fields.
[0165] Step S406: Determine the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified.
[0166] Step S408: input the text to be classified into multiple feature extraction layers, so that each feature extraction layer in the multiple feature extraction layers calculates the word vector of the text to be classified and calculates the corresponding feature extraction results based on the word vector to obtain a feature extraction result set.
[0167] Step S410: performing a linear transformation on each feature extraction result in the feature extraction result set to obtain a weight value set; wherein there is a one-to-one correspondence between each weight value in the weight value set and each feature extraction result in the feature extraction result set.
[0168] Step S412: Calculate the weighted sum of the weight value set and the feature extraction result set according to the one-to-one correspondence, and determine the weighted sum as a semantic feature vector.
[0169] Step S414: concatenate the domain feature vector and the semantic feature vector corresponding to the text to be classified to obtain a reference vector.
[0170] Step S416: Perform a linear transformation on the reference vector, calculate the product of the linear transformation result and the activation function, and determine the product as the fusion vector.
[0171] Step S418: multiply the fusion vector by the preset classification matrix to obtain a reference probability set; wherein each reference probability in the reference probability set corresponds one-to-one to each timeliness level.
[0172] Step S420: normalize the reference probabilities to obtain the probabilities of the text to be classified corresponding to each timeliness level.
[0173] Step S422: Determine the maximum probability from the probabilities corresponding to each timeliness level, and determine the target timeliness level corresponding to the maximum probability as the timeliness classification result of the text to be classified.
[0174] It should be noted that steps S400 to S422 are Figure 1 The steps and their embodiments shown correspond to each other. For the specific implementation of steps S400 to S422, please refer to Figure 1The steps and embodiments shown are not described in detail here.
[0175] It can be seen that implementation Figure 4 The method shown can combine the domain features and semantic features of the text to classify the timeliness of the text, which can improve the accuracy of timeliness classification. In addition, it can also extract features of the text to be classified through multiple feature extraction layers corresponding to different extraction targets, and fuse the multiple feature extraction results obtained to improve the feature extraction accuracy of the text to be classified, thereby improving the accuracy of timeliness classification.
[0176] In addition, although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0177] Exemplary Media
[0178] After introducing the method according to the exemplary embodiment of the present application, next, the medium according to the exemplary embodiment of the present application will be described.
[0179] In some possible implementations, various aspects of the present application may also be implemented as a medium on which program code is stored, which, when executed by a processor of a device, is used to implement the steps of the timeliness-based text classification method according to various exemplary implementations of the present application described in the above “Exemplary Method” section of this specification.
[0180] Specifically, when the processor of the device executes the program code, it is used to implement the following steps: determine the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified; perform feature extraction on the text to be classified through multiple feature extraction layers corresponding to different extraction targets to obtain a feature extraction result set; fuse the feature extraction results in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified; and perform timeliness classification on the text to be classified according to the domain feature vector and the semantic feature vector.
[0181] In some embodiments of the present application, the processor of the device is also used to implement the following steps when executing the program code: splicing the feature vectors corresponding to each text domain in the text domain set to obtain a target matrix; wherein the text domain set includes the domain of the text to be classified; performing multiple different linear processing on the target matrix to obtain a reference indicator matrix, a domain description matrix and a weight reference matrix respectively; calculating the domain fusion matrix based on the reference indicator matrix, the domain description matrix and the weight reference matrix; wherein the domain fusion matrix is composed of the domain feature vectors corresponding to each text domain.
[0182] In some embodiments of the present application, the processor of the device is also used to implement the following steps when executing the program code: calculating the correlation coefficient between each text domain by referring to the indicator matrix and the domain description matrix; calculating the intermediate parameters based on the correlation coefficient and the dimension corresponding to the feature vector; normalizing the intermediate parameters to obtain the similarity between each text domain; and calculating the domain fusion matrix through the weight reference matrix and the similarity.
[0183] In some embodiments of the present application, the processor of the device is also used to implement the following steps when executing the program code: input the text to be classified into multiple feature extraction layers, so that each feature extraction layer in the multiple feature extraction layers calculates the word vector of the text to be classified and calculates the corresponding feature extraction results based on the word vector to obtain a feature extraction result set.
[0184] In some embodiments of the present application, the processor of the device is also used to implement the following steps when executing the program code: performing a linear transformation on each feature extraction result in the feature extraction result set to obtain a weight value set; wherein there is a one-to-one correspondence between each weight value in the weight value set and each feature extraction result in the feature extraction result set; calculating the weighted sum of the weight value set and the feature extraction result set according to the one-to-one correspondence, and determining the weighted sum as a semantic feature vector.
[0185] In some embodiments of the present application, the processor of the device is further used to implement the following steps when executing the program code: concatenating the domain feature vector and the semantic feature vector corresponding to the text to be classified to obtain a reference vector; and performing timeliness classification on the text to be classified according to the reference vector.
[0186] In some embodiments of the present application, the processor of the device is further used to implement the following steps when executing the program code: linearly transform the reference vector to obtain a fusion vector; multiply the fusion vector by a preset classification matrix to obtain a reference probability set; wherein each reference probability in the reference probability set corresponds one-to-one to each timeliness level; normalize each reference probability to obtain the probability that the text to be classified corresponds to each timeliness level; and classify the text to be classified by timeliness according to the probability that the text to be classified corresponds to each timeliness level.
[0187] In some embodiments of the present application, the processor of the device is further used to implement the following steps when executing the program code: determining the maximum probability from the probabilities corresponding to each timeliness level; and determining the target timeliness level corresponding to the maximum probability as the timeliness classification result of the text to be classified.
[0188] In some embodiments of the present application, when the processor of the device executes the program code, it is also used to implement the following steps: perform a linear transformation on the reference vector, calculate the product of the linear transformation result and the activation function, and determine the product as the fusion vector.
[0189] It should be noted that the above-mentioned medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0190] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to: electromagnetic signals, optical signals, or any suitable combination of the above. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0191] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0192] Program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user computing device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0193] Exemplary Devices
[0194] After introducing the medium of the exemplary embodiment of the present application, next, reference is made to Figure 5 The text classification device based on timeliness according to the exemplary embodiment of the present application is described.
[0195] See also Figure 5 , Figure 5 FIG. 2 shows a structural block diagram of a time-based text classification device according to an example embodiment of the present application. Figure 5 As shown, a time-based text classification device 500 according to an exemplary embodiment of the present application includes: a feature vector determination unit 501, a feature extraction unit 502, a feature fusion unit 503 and a text classification unit 504, wherein:
[0196] A feature vector determination unit 501 is used to determine a domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified;
[0197] A feature extraction unit 502 is used to extract features from the text to be classified respectively through a plurality of feature extraction layers corresponding to different extraction targets to obtain a feature extraction result set;
[0198] A feature fusion unit 503 is used to fuse the feature extraction results in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified;
[0199] The text classification unit 504 is used to classify the text to be classified according to the domain feature vector and the semantic feature vector.
[0200] It can be seen that implementation Figure 5The device shown can combine the domain features and semantic features of the text to classify the timeliness of the text, which can improve the accuracy of timeliness classification. In addition, it can also extract features of the text to be classified through multiple feature extraction layers corresponding to different extraction targets, and fuse the multiple feature extraction results obtained to improve the feature extraction accuracy of the text to be classified, thereby improving the accuracy of timeliness classification.
[0201] In one embodiment, based on the above solution, the above device further includes:
[0202] A vector concatenation unit (not shown) is used to concatenate the feature vectors corresponding to the text fields in the text field set to obtain a target matrix before the feature vector determination unit 501 determines the field feature vector corresponding to the text to be classified from the field fusion matrix according to the field of the text to be classified; wherein the text field set includes the field of the text to be classified;
[0203] A linear calculation unit (not shown) is used to perform multiple different linear processing on the target matrix to obtain a reference indicator matrix, a domain description matrix and a weight reference matrix respectively;
[0204] The matrix calculation unit (not shown) is used to calculate the domain fusion matrix based on the reference indicator matrix, the domain description matrix and the weight reference matrix; wherein the domain fusion matrix is composed of domain feature vectors corresponding to each text domain.
[0205] It can be seen that the implementation of this optional embodiment can determine the category features corresponding to the text to be classified, which is conducive to improving the timeliness classification accuracy of the text by combining the text features.
[0206] In one embodiment, based on the above solution, the matrix calculation unit calculates the domain fusion matrix according to the reference indicator matrix, the domain description matrix and the weight reference matrix, including:
[0207] The correlation coefficients between the text fields are calculated by referring to the indicator matrix and the field description matrix;
[0208] Calculate intermediate parameters based on the correlation coefficient and the dimension corresponding to the eigenvector;
[0209] Normalize the intermediate parameters to obtain the similarity between each text field;
[0210] The domain fusion matrix is calculated through the weight reference matrix and similarity.
[0211] It can be seen that the implementation of this optional embodiment can utilize the reference indicator matrix, the domain description matrix and the weight reference matrix in the self-attention mechanism to improve the feature similarity between related domains, so as to improve the accuracy of timeliness classification.
[0212] In one embodiment, based on the above solution, the feature extraction unit 502 performs feature extraction on the text to be classified through multiple feature extraction layers corresponding to different extraction targets, and obtains a feature extraction result set, including:
[0213] The text to be classified is input into a plurality of feature extraction layers, so that each of the plurality of feature extraction layers calculates the word vector of the text to be classified and calculates the corresponding feature extraction results according to the word vector to obtain a feature extraction result set.
[0214] It can be seen that the implementation of this optional embodiment, through the multi-layer feature extraction and fusion in this application, can be helpful in distinguishing whether the text to be classified is of long-term or short-term nature, thereby improving the classification accuracy of the text to be classified.
[0215] In one embodiment, based on the above solution, the feature fusion unit 503 fuses the feature extraction results in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified, including:
[0216] Performing a linear transformation on each feature extraction result in the feature extraction result set to obtain a weight value set; wherein there is a one-to-one correspondence between each weight value in the weight value set and each feature extraction result in the feature extraction result set;
[0217] The weighted sum of the weight value set and the feature extraction result set is calculated according to the one-to-one correspondence, and the weighted sum is determined as a semantic feature vector.
[0218] It can be seen that the implementation of this optional embodiment can fuse feature extraction results of different granularities, thereby improving the feature extraction accuracy of the text to be classified, which is beneficial to improving the timeliness classification accuracy of the text to be classified.
[0219] In one embodiment, based on the above solution, the text classification unit 504 performs timeliness classification on the text to be classified according to the domain feature vector and the semantic feature vector, including:
[0220] The domain feature vector and the semantic feature vector corresponding to the text to be classified are concatenated to obtain a reference vector;
[0221] The text to be classified is temporally classified according to the reference vector.
[0222] It can be seen that by implementing this optional embodiment, the timeliness classification of the text to be classified can be performed by combining the reference vector of the domain feature vector and the semantic feature vector, thereby improving the timeliness classification accuracy of the text to be classified.
[0223] In one embodiment, based on the above solution, the text classification unit 504 performs timeliness classification on the text to be classified according to the reference vector, including:
[0224] Perform linear transformation on the reference vector to obtain the fusion vector;
[0225] Multiply the fusion vector by the preset classification matrix to obtain a reference probability set; wherein each reference probability in the reference probability set corresponds to each timeliness level one by one;
[0226] Normalize each reference probability to obtain the probability of the text to be classified corresponding to each timeliness level;
[0227] The timeliness of the text to be classified is classified according to the probability that the text to be classified corresponds to each timeliness level.
[0228] It can be seen that the implementation of this optional embodiment can improve the timeliness classification accuracy of the text to be classified by fusing the domain feature vector and the semantic feature vector.
[0229] In one embodiment, based on the above solution, the text classification unit 504 classifies the text to be classified according to the probability that the text to be classified corresponds to each timeliness level, including:
[0230] determining a maximum probability from the probabilities corresponding to each timeliness level;
[0231] The target timeliness level corresponding to the maximum probability is determined as the timeliness classification result of the text to be classified.
[0232] It can be seen that by implementing this optional embodiment, the timeliness classification result of the text to be classified can be determined according to the probability corresponding to each timeliness level, thereby improving the timeliness classification accuracy of the text to be classified.
[0233] In one embodiment, based on the above solution, the text classification unit 504 performs a linear transformation on the reference vector to obtain a fusion vector, including:
[0234] The reference vector is linearly transformed, and the product of the linear transformation result and the activation function is calculated, and the product is determined as the fusion vector.
[0235] It can be seen that the implementation of this optional embodiment can improve the computational efficiency of the timeliness classification results by linearly transforming the reference vector.
[0236] It should be noted that although several modules or units of the time-based text classification device are mentioned in the above detailed description, this division is not mandatory. In fact, according to the implementation of the present application, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.
[0237] Exemplary Electronic Devices
[0238] After introducing the method, medium, and apparatus according to the exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.
[0239] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.
[0240] Refer to the following Figure 6 A time-based text classification device 600 according to yet another optional exemplary embodiment of the present application is described. Figure 6 The displayed timeliness-based text classification device 600 is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0241] like Figure 6 As shown, the time-based text classification device 600 is presented in the form of an electronic device. The components of the time-based text classification device 600 may include but are not limited to: the at least one processing unit 610, the at least one storage unit 620, and a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610).
[0242] The storage unit stores a program code, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps according to various exemplary embodiments of the present application described in the description of the exemplary method described above in this specification. For example, the processing unit 610 can perform the following steps: Figure 1 and Figure 4 The steps shown in .
[0243] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .
[0244] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0245] Bus 630 may represent one or more of several types of bus structures, including an address bus, a control bus, and / or a data bus.
[0246] The timeliness-based text classification device 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), and may also communicate with one or more devices that enable a user to interact with the timeliness-based text classification device 600, and / or communicate with any device that enables the timeliness-based text classification device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 650. Furthermore, the timeliness-based text classification device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 660. Figure 6 As shown, the network adapter 660 communicates with other modules of the time-based text classification device 600 via the bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the time-based text classification device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0247] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0248] Although the spirit and principle of the present application have been described with reference to several specific embodiments, it should be understood that the present application is not limited to the specific embodiments of the invention, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present application is intended to cover various modifications and equivalent arrangements included in the spirit and scope of the attached claims.
Claims
1. A time-based text classification method, characterized in that: include: Determining the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified; wherein the domain fusion matrix is composed of the domain feature vectors corresponding to the domains of each text; Extracting features of the text to be classified respectively through a plurality of feature extraction layers corresponding to different extraction targets, and obtaining a feature extraction result set; Merging the feature extraction results in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified; Performing timeliness classification on the text to be classified according to the domain feature vector and the semantic feature vector; The timeliness classification of the text to be classified according to the domain feature vector and the semantic feature vector includes: Concatenating the domain feature vector and the semantic feature vector corresponding to the text to be classified to obtain a reference vector; Performing a linear transformation on the reference vector to obtain a fusion vector; Multiplying the fusion vector with a preset classification matrix to obtain a reference probability set; wherein each reference probability in the reference probability set corresponds to each timeliness level one by one; Normalizing the reference probabilities to obtain the probabilities of the text to be classified corresponding to the timeliness levels; The text to be classified is classified according to the probability that the text to be classified corresponds to each timeliness level.
2. The method according to claim 1, characterized in that Before determining the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified, the method further includes: The feature vectors corresponding to each text field in the text field set are concatenated to obtain a target matrix; wherein the text field set includes the field of the text to be classified; Performing multiple different linear processing on the target matrix to obtain a reference indicator matrix, a domain description matrix and a weight reference matrix respectively; The domain fusion matrix is calculated according to the reference indicator matrix, the domain description matrix and the weight reference matrix.
3. The method according to claim 2, characterized in that Calculating the domain fusion matrix according to the reference indicator matrix, the domain description matrix and the weight reference matrix includes: Calculate the correlation coefficients between the text fields through the reference indicator matrix and the field description matrix; Calculate an intermediate parameter based on the correlation coefficient and the dimension corresponding to the feature vector; Normalizing the intermediate parameters to obtain the similarities between the text fields; The domain fusion matrix is calculated using the weight reference matrix and the similarity.
4. The method according to claim 1, characterized in that The feature extraction of the to-be-classified text is performed respectively through a plurality of feature extraction layers corresponding to different extraction targets, and a feature extraction result set is obtained, including: The text to be classified is input into the multiple feature extraction layers, so that each feature extraction layer in the multiple feature extraction layers calculates the word vector of the text to be classified and calculates the corresponding feature extraction results according to the word vector to obtain the feature extraction result set.
5. The method according to claim 1, characterized in that The feature extraction results in the feature extraction result set are merged to obtain a semantic feature vector corresponding to the text to be classified, including: Performing a linear transformation on each feature extraction result in the feature extraction result set to obtain a weight value set; wherein there is a one-to-one correspondence between each weight value in the weight value set and each feature extraction result in the feature extraction result set; A weighted sum of the weight value set and the feature extraction result set is calculated according to the one-to-one correspondence, and the weighted sum is determined as the semantic feature vector.
6. The method according to claim 1, characterized in that Classifying the text to be classified according to the probability that the text to be classified corresponds to each timeliness level includes: Determining a maximum probability from the probabilities corresponding to the timeliness levels; The target timeliness level corresponding to the maximum probability is determined as the timeliness classification result of the text to be classified.
7. The method according to claim 1, characterized in that The reference vector is linearly transformed to obtain a fusion vector, including: The reference vector is linearly transformed, and the product of the linear transformation result and the activation function is calculated, and the product is determined as the fusion vector.
8. A text classification device based on timeliness, characterized in that: include: A feature vector determination unit, used to determine the domain feature vector corresponding to the text to be classified from the domain fusion matrix according to the domain of the text to be classified; wherein the domain fusion matrix is composed of the domain feature vectors corresponding to the domains of each text; A feature extraction unit, used to extract features of the text to be classified respectively through a plurality of feature extraction layers corresponding to different extraction targets, to obtain a feature extraction result set; A feature fusion unit, used for fusing each feature extraction result in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified; A text classification unit, used for classifying the text to be classified according to the domain feature vector and the semantic feature vector; The text classification unit performs timeliness classification on the text to be classified according to the domain feature vector and the semantic feature vector, including: Concatenating the domain feature vector and the semantic feature vector corresponding to the text to be classified to obtain a reference vector; Performing a linear transformation on the reference vector to obtain a fusion vector; Multiplying the fusion vector with a preset classification matrix to obtain a reference probability set; wherein each reference probability in the reference probability set corresponds to each timeliness level one by one; Normalizing the reference probabilities to obtain the probabilities of the text to be classified corresponding to the timeliness levels; The text to be classified is classified according to the probability that the text to be classified corresponds to each timeliness level.
9. The device according to claim 8, characterized in that The device also includes: A vector concatenation unit is used to concatenate the feature vectors corresponding to the text fields in the text field set to obtain a target matrix before the feature vector determination unit determines the field feature vector corresponding to the text to be classified from the field fusion matrix according to the field of the text to be classified; wherein the text field set includes the field of the text to be classified; A linear calculation unit, used for performing multiple different linear processing on the target matrix to obtain a reference indicator matrix, a domain description matrix and a weight reference matrix respectively; A matrix calculation unit is used to calculate the domain fusion matrix according to the reference indicator matrix, the domain description matrix and the weight reference matrix.
10. The device according to claim 9, characterized in that The matrix calculation unit calculates the domain fusion matrix according to the reference indicator matrix, the domain description matrix and the weight reference matrix, including: Calculate the correlation coefficients between the text fields through the reference indicator matrix and the field description matrix; Calculate an intermediate parameter based on the correlation coefficient and the dimension corresponding to the feature vector; Normalizing the intermediate parameters to obtain the similarities between the text fields; The domain fusion matrix is calculated using the weight reference matrix and the similarity.
11. The device according to claim 8, characterized in that The feature extraction unit extracts features of the text to be classified respectively through a plurality of feature extraction layers corresponding to different extraction targets, and obtains a feature extraction result set, including: The text to be classified is input into the multiple feature extraction layers, so that each feature extraction layer in the multiple feature extraction layers calculates the word vector of the text to be classified and calculates the corresponding feature extraction results according to the word vector to obtain the feature extraction result set.
12. The device according to claim 8, characterized in that The feature fusion unit fuses the feature extraction results in the feature extraction result set to obtain a semantic feature vector corresponding to the text to be classified, including: Performing a linear transformation on each feature extraction result in the feature extraction result set to obtain a weight value set; wherein there is a one-to-one correspondence between each weight value in the weight value set and each feature extraction result in the feature extraction result set; A weighted sum of the weight value set and the feature extraction result set is calculated according to the one-to-one correspondence, and the weighted sum is determined as the semantic feature vector.
13. The device according to claim 8, characterized in that The text classification unit classifies the text to be classified according to the probability that the text to be classified corresponds to each timeliness level, including: Determining a maximum probability from the probabilities corresponding to the timeliness levels; The target timeliness level corresponding to the maximum probability is determined as the timeliness classification result of the text to be classified.
14. The device according to claim 8, characterized in that The text classification unit performs a linear transformation on the reference vector to obtain a fusion vector, including: The reference vector is linearly transformed, and the product of the linear transformation result and the activation function is calculated, and the product is determined as the fusion vector.
15. An electronic device, characterized in that: include: processor; as well as A memory having computer-readable instructions stored thereon, wherein the computer-readable instructions, when executed by the processor, implement the timeliness-based text classification method according to any one of claims 1 to 7.
16. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the timeliness-based text classification method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Text classification method and system
CN110968692A
Text classification method and device, terminal equipment and storage medium
CN111460148A