Text classification method and device, electronic equipment and storage medium

By extracting semantic features and enhancing or weakening features based on word-partition prior information, the problem that text classification models in the prior art are difficult to distinguish awakening words from awakening intentions, and the accuracy and stability of text classification are improved.

CN119848252APending Publication Date: 2025-04-18JILIN KEXUN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In human-computer interaction scenarios, existing text classification models are difficult to effectively distinguish between wake words and wake-intention text in wake-instruction text, resulting in wake-intention words interfering with understanding wake-intention and affecting the classification effect.

Method used

By extracting the semantic features of the text to be classified, enhancing the key word segmentation characteristics based on the prior information of key word segmentation, weakening the margin word segmentation characteristics based on the prior information of margin word segmentation, and determining the classification results based on the prior information of margin word segmentation, combining the three.

Benefits of technology

It improves the accuracy of text classification, reduces the interference of marginal word segmentation on classification results, and enhances the ability to capture key information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119848252A_ABST
    Figure CN119848252A_ABST
Patent Text Reader

Abstract

The invention provides a text classification method and device, electronic equipment and a storage medium. The method comprises the steps of extracting semantic features of a to-be-classified text; based on the key word segmentation prior information, key word segmentation features in the to-be-classified text are enhanced, and key enhanced features are obtained; weakening edge word segmentation features in the to-be-classified text based on the edge word segmentation prior information to obtain edge weakening features; and determining a classification result of the to-be-classified text based on the semantic features, the key enhancement features and the edge weakening features. On the basis of extracting the semantic features, key information which has important influence on the classification of the to-be-classified text can be accurately captured on the basis of the key enhancement features, and the influence of edge information can be ignored on the basis of the weakening edge features, so that the interference of edge word segmentation on the classification result is reduced, and the accuracy of text classification is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a text classification method, device, electronic device and storage medium. Background Art

[0002] Text classification is a core task in natural language processing (NLP) and machine learning. Its goal is to automatically classify input text into predefined categories. Text classification has been widely used in human-computer interaction scenarios, such as intelligent voice assistants, customer service robots, and information recommendation systems. In human-computer interaction scenarios, it is necessary to accurately identify user intent through analysis and understanding of text, and classify text into relevant task categories to trigger corresponding actions or responses.

[0003] In text classification tasks, deep learning methods are often used to build text classification models, which automatically learn feature representations from input text and perform text classification. However, in some scenarios, the classification effect is poor. For example, in the wake-up scenario, it is difficult for the text classification model to effectively distinguish the wake-up words and the wake-up intention text in the wake-up instruction text. As a result, the wake-up words will interfere with the text classification model's understanding of the wake-up intention text, which in turn affects the correct understanding and classification of the wake-up intention in the wake-up instruction text. Summary of the invention

[0004] The present invention provides a text classification method, device, electronic device and storage medium to solve the defects in the prior art.

[0005] The present invention provides a text classification method, comprising the following steps: Extract semantic features of the text to be classified; Based on the prior information of key word segmentation, the key word segmentation features in the text to be classified are enhanced to obtain key enhanced features; Based on the edge segmentation prior information, weaken the edge segmentation features in the text to be classified to obtain edge weakening features; Based on the semantic features, the emphasis enhancement features and the edge weakening features, a classification result of the text to be classified is determined.

[0006] According to a text classification method provided by the present invention, the classification result of the text to be classified is determined based on the semantic feature, the key enhancement feature and the edge weakening feature, including: Based on a first fusion weight between the semantic feature and the key enhancement feature, and a second fusion weight between the semantic feature and the edge weakening feature, splicing the semantic feature, the key enhancement feature, and the edge weakening feature to obtain a splicing feature; Based on the splicing features, a classification result of the text to be classified is determined.

[0007] According to a text classification method provided by the present invention, based on the first fusion weight between the semantic feature and the key enhancement feature, and the second fusion weight between the semantic feature and the edge weakening feature, the semantic feature, the key enhancement feature and the edge weakening feature are spliced ​​to obtain a spliced ​​feature, including: Determining a splicing weight coefficient based on the first fusion weight and the second fusion weight; Based on the splicing weight coefficient, the semantic feature, the key enhancement feature and the edge weakening feature are spliced ​​to obtain the splicing feature.

[0008] According to a text classification method provided by the present invention, determining the classification result of the to-be-classified text based on the splicing feature includes: Extracting the overall semantic features of the text to be classified based on the splicing features; Based on the overall semantic features, a classification result of the text to be classified is determined.

[0009] According to a text classification method provided by the present invention, the semantic features of the text to be classified are extracted, and based on the prior information of the key segmentation, the key segmentation features in the text to be classified are enhanced to obtain the key enhanced features; based on the prior information of the edge segmentation, the edge segmentation features in the text to be classified are weakened to obtain the edge weakened features; based on the semantic features, the key enhanced features and the edge weakened features, the classification result of the text to be classified is determined, including: Based on the text classification model, the semantic features of the text to be classified are extracted; based on the prior information of the key segmentation, the key segmentation features in the text to be classified are enhanced to obtain the key enhanced features; based on the prior information of the edge segmentation, the edge segmentation features in the text to be classified are weakened to obtain the edge weakened features; based on the semantic features, the key enhanced features and the edge weakened features, the classification result of the text to be classified is determined; The text classification model is trained based on sample text and classification labels of the sample text.

[0010] According to a text classification method provided by the present invention, the text classification model is trained to maximize the correlation between the sample key enhancement feature and the sample overall semantic feature, minimize the correlation between the sample edge weakening feature and the sample overall semantic feature, and minimize the difference between the classification result of each sample text and the corresponding classification label. The sample key enhancement feature is obtained by enhancing the key segmentation feature in the sample text based on the key segmentation prior information, the sample edge weakening feature is obtained by weakening the edge segmentation feature in the sample text based on the edge segmentation prior information, and the sample overall semantic feature is determined based on the sample semantic feature, the sample key enhancement feature and the sample edge weakening feature.

[0011] According to a text classification method provided by the present invention, the step of determining the classification result of the text to be classified further includes: Based on the difference between the classification result of each sample text and the corresponding classification label, the key word segmentation prior information and / or the marginal word segmentation prior information are optimized.

[0012] The present invention also provides a text classification device, comprising the following modules: An extraction unit, used to extract semantic features of the text to be classified; An enhancement unit, used for enhancing the key word segmentation features in the text to be classified based on the key word segmentation prior information to obtain key enhanced features; A weakening unit, used for weakening edge segmentation features in the text to be classified based on edge segmentation prior information to obtain edge weakening features; The classification unit is used to determine the classification result of the text to be classified based on the semantic feature, the focus enhancement feature and the edge weakening feature.

[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned text classification methods is implemented.

[0014] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the text classification method described above is implemented.

[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned text classification methods.

[0016] The text classification method, device, electronic device and storage medium provided by the present invention obtain key enhancement features for highlighting key segmentations in the text to be classified based on key segmentation prior information, obtain edge weakening features for weakening edge segmentations in the text to be classified based on edge segmentation prior information, combine the key enhancement features, edge weakening features and semantic features for characterizing the global semantic information of the text to be classified, and on the basis of extracting semantic features, not only can the key information that has an important impact on the classification of the text to be classified be accurately captured based on the key enhancement features, but the influence of edge information can also be ignored based on the weakened edge features, thereby reducing the interference of edge segmentations on the classification results, and further improving the accuracy of text classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 It is a flowchart of the text classification method provided by the present invention.

[0019] Figure 2 It is a flowchart of the text classification model training method provided by the present invention.

[0020] Figure 3 It is a structural schematic diagram of the text classification device provided by the present invention.

[0021] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] In text classification tasks, deep learning methods are often used to build text classification models, which automatically learn feature representations from input text and perform text classification. However, in some scenarios, it is difficult for text classification models to effectively distinguish between important information and information that needs to be ignored in the text. As a result, the information that needs to be ignored will interfere with the text classification model's understanding of important information, thereby affecting the classification effect of the input text.

[0024] For example, in the wake-up scenario, the wake-up command text is "Xiaoyue, play music". "Xiaoyue" is the wake-up word (i.e., information that needs to be ignored), which tells the device that the next input is the specific instruction that the user wants the device to execute. "Play music" is the wake-up intention text (i.e., important information), which is the specific instruction that the user wants the device to execute. However, "Xiaoyue" is also the name of a singer. If "Xiaoyue" is not ignored as a wake-up word, it will greatly affect the semantic understanding effect, such as misunderstanding that the song of the singer "Xiaoyue" is played.

[0025] In addition, there are also methods that rely on manually specified rule sets to classify input texts, where the rules in the rule set can be keyword matching, regular expressions, or grammatical structures, etc. The classification result of the input text is determined by identifying whether the input text contains content that conforms to the rules. However, the formulation of rules in this method relies on prior knowledge, which requires a lot of manpower, and it is difficult to cope with the diversity and complexity of languages. It has poor generalization ability and is difficult to carry out large batches of tasks at the same time.

[0026] In this regard, the present invention provides a text classification method, which can be applied to scenarios such as sentiment analysis, news classification, spam detection, topic classification, and human-computer interaction. In order to facilitate understanding of the technical solution of the present invention, the following embodiments are described using the wake-up scenario applied in human-computer interaction as an example.

[0027] Figure 1 It is a flowchart of the text classification method provided by the present invention, such as Figure 1 As shown, the process includes step 110 , step 120 , step 130 and step 140 .

[0028] Step 110: extracting semantic features of the text to be classified.

[0029] Here, the text to be classified is the text that needs to be classified. The text to be classified can be the text obtained after voice recognition of the user's wake-up command. The semantic features of the text to be classified are used to characterize the global semantic information of the text to be classified, which can be extracted by the BRET model. The BRET model maps the text to be classified into high-dimensional semantic features through a multi-layer Transformer encoder to capture the global semantic information of the text to be classified.

[0030] Step 120: based on the prior information of key word segments, enhance the key word segmentation features in the text to be classified to obtain key enhanced features.

[0031] Specifically, key word prior information refers to the word that has a significant impact on the text classification results, which is predetermined based on historical data, professional knowledge, or experience in a specific field. This type of word can be understood as a key word, and the key word has a higher weight in the text classification process. For example, in the wake-up scenario, words such as "play", "query", and "set" may be regarded as key word prior information.

[0032] Based on the key word prior information, the key word in the text to be identified that has a significant impact on the text classification result can be determined, and then the key word features in the text to be classified can be enhanced. For example, the key word prior information usually includes the category of each key word (such as the category can include singers, songs, etc.) and the position of each key word (for example, the key word can be represented by "1" and the non-key word can be represented by "0").

[0033] After enhancing the key segmentation features in the text to be classified, the obtained key enhancement features are used to highlight the key segmentations in the text to be classified. For example, the key segmentations have a higher weight, so that the key segmentations with a higher weight can be focused on when classifying the text to be classified.

[0034] Exemplarily, based on the position, context, frequency of occurrence and other information of each word segment in the text to be classified, a focus matrix for characterizing the text to be classified is generated, and each row in the focus matrix can represent the category of the focus segment, and each column can represent the position of the focus segment. Then, the focus matrix is ​​input into the fully connected layer to convert the input focus matrix into a higher-dimensional or lower-dimensional feature vector, which is the focus enhancement feature.

[0035] Step 130: based on the edge segmentation prior information, weaken the edge segmentation features in the text to be classified to obtain edge weakened features.

[0036] Specifically, edge segmentation prior information refers to the segmentations that are predetermined based on historical data, professional knowledge, or experience in a specific field and have little impact on the text classification results or may generate noise. Such segmentations can be understood as edge segmentations, which have a lower weight in the text classification process. For example, in the wake-up scenario, "wake-up words can be regarded as edge segmentation prior information.

[0037] Based on the edge segmentation prior information, we can determine the segmentations in the text to be identified that have little impact on the text classification results or may generate noise, and then weaken the edge segmentation features in the text to be classified. For example, the edge segmentation prior information usually includes the category and position of each edge segmentation (for example, the edge segmentation can be represented by "1"). Then, the edge segmentation features in the semantic features can be assigned corresponding weights to reduce the weight of the edge segmentation features in the semantic features, thereby weakening the edge segmentation features in the text to be classified.

[0038] After weakening the marginal segmentation features in the text to be classified, the obtained marginal weakened features are used to weaken or ignore the marginal segmentation in the marginal text to be classified. For example, the weight of the marginal segmentation is low, so as to avoid the misleading of the marginal segmentation when classifying the text to be classified, reduce the interference of noise on the classification results, and improve the accuracy of text classification.

[0039] For example, based on the position, context, frequency of occurrence and other information of each word segment in the text to be classified, a weight reduction matrix is ​​generated to characterize the text to be classified. Each row in the weight reduction matrix can represent the category of the edge word segment, and each column can represent the position of the edge word segment. Then, the weight reduction matrix is ​​input into the fully connected layer to convert the input weight reduction matrix into a higher or lower dimensional feature vector, which is the edge weakening feature.

[0040] Step 140: Determine the classification result of the text to be classified based on the semantic features, the key enhancement features, and the edge weakening features.

[0041] Specifically, the focus enhancement feature is used to characterize the key information that needs to be paid attention to in the text to be classified (i.e., the focus segmentation), the edge weakening feature is used to characterize the information that needs to be ignored in the text to be classified (i.e., the edge segmentation), and the semantic feature is used to characterize the global semantic information of the text to be classified. Then, based on the semantic features, the focus enhancement features and the edge weakening features, on the basis of the global semantic information, not only can the key information that has an important impact on the classification of the text to be classified be accurately captured based on the focus enhancement features, but also the influence of the edge information can be ignored based on the weakened edge features, thereby reducing the interference of the edge segmentation on the classification results, and further improving the accuracy of text classification.

[0042] The text classification method provided by the embodiment of the present invention obtains a key enhancement feature for highlighting the key segmentations in the text to be classified based on the key segmentation prior information, obtains a marginal weakening feature for weakening the marginal segmentations in the text to be classified based on the marginal segmentation prior information, combines the key enhancement feature, the marginal weakening feature and the semantic feature for characterizing the global semantic information of the text to be classified, and on the basis of extracting the semantic features, can not only accurately capture the key information that has an important impact on the classification of the text to be classified based on the key enhancement feature, but also ignore the influence of the marginal information based on the weakened marginal feature, reduce the interference of the marginal segmentations on the classification results, and further improve the accuracy of text classification.

[0043] For example, for the text to be classified "Navigation assistant, open the sunroof", we can focus on the word segmentation "skylight" and ignore the wake-up word "navigation assistant", so that we can accurately understand the user's intention and obtain the wake-up scene category, which is the classification result of the text to be classified.

[0044] Based on the above embodiment, the classification result of the text to be classified is determined based on the semantic features, the key enhancement features and the edge weakening features, including: Based on a first fusion weight between the semantic feature and the key enhancement feature, and a second fusion weight between the semantic feature and the edge weakening feature, the semantic feature, the key enhancement feature, and the edge weakening feature are concatenated to obtain a concatenated feature; Based on the concatenated features, the classification result of the text to be classified is determined.

[0045] Specifically, the first fusion weight is used to characterize the proportion of the semantic feature and the key enhancement feature. The semantic feature is used to characterize the global semantic information of the text to be classified, and the key enhancement feature is used to characterize the key information that may need to be paid attention to in the text to be classified. After determining the first fusion weight, the proportion of the key information that may need to be paid attention to in the text to be classified can be determined, so as to further accurately identify the key information in the text to be classified. The first fusion weight can be generated by the model.

[0046] Similarly, the second fusion weight is used to characterize the proportion of semantic features and edge weakening features. The semantic feature is used to characterize the global semantic information of the text to be classified, and the edge weakening feature is used to characterize the edge information that may need to be ignored in the text to be classified. After determining the second fusion weight, the proportion of edge information that needs to be ignored in the text to be classified can be determined, and the edge information in the text to be classified can be further accurately identified. Among them, the second fusion weight can be generated by the model.

[0047] Based on the first fusion weight and the second fusion weight, the splicing weight coefficients of the semantic features, the key enhancement features and the edge weakening features in the splicing features can be determined, and based on the splicing weight coefficients, the semantic features, the key enhancement features and the edge weakening features are spliced ​​to obtain the splicing features.

[0048] Since the focus enhancement feature is used to represent the key information that needs to be paid attention to in the text to be classified, the semantic feature is used to represent the global semantic information of the text to be classified, and the edge weakening feature is used to represent the information that needs to be ignored in the text to be classified, the spliced ​​feature obtained by splicing the semantic feature, the focus enhancement feature and the edge weakening feature contains both the global semantic information of the text to be classified, the key information that needs to be paid attention to in the text to be classified, and the information that needs to be ignored in the text to be classified.

[0049] Based on any of the above embodiments, based on the first fusion weight between the semantic feature and the key enhancement feature, and the second fusion weight between the semantic feature and the edge weakening feature, the semantic feature, the key enhancement feature and the edge weakening feature are spliced ​​to obtain the spliced ​​feature, including: Determining a splicing weight coefficient based on the first fusion weight and the second fusion weight; Based on the splicing weight coefficient, the semantic features, key enhancement features and edge weakening features are spliced ​​to obtain the splicing features.

[0050] Specifically, the splicing weight coefficient is a comprehensive weight value calculated based on the first fusion weight between the semantic feature and the key enhancement feature, and the second fusion weight between the semantic feature and the edge weakening feature. The splicing weight coefficient is used to measure the proportion of each feature (semantic feature, key enhancement feature, edge weakening feature) when splicing features, so as to ensure that the spliced ​​features can accurately reflect the comprehensive information and key information of the original data.

[0051] For example, the first fusion weight of semantic features and key enhancement features is 0.1:0.9, and the second fusion weight of semantic features and edge weakening features is 0.2:0.8. The splicing weight coefficients are 9 (corresponding coefficient of key enhancement features), 1 (corresponding coefficient of semantic features), and 4 (corresponding coefficient of edge weakening features), that is, splicing features = 9 × key enhancement features + 1 × semantic features + 4 × edge weakening features.

[0052] After splicing semantic features, key enhancement features and edge weakening features based on the splicing weight coefficient, the obtained splicing features can highlight the key information in the text to be classified while weakening the information that needs to be ignored in the text to be classified, thereby improving the accuracy of text classification.

[0053] Based on any of the above embodiments, determining the classification result of the text to be classified based on the splicing features includes: Based on the splicing features, the overall semantic features of the text to be classified are extracted; Based on the overall semantic features, the classification result of the text to be classified is determined.

[0054] Specifically, on the basis of obtaining the splicing features, the embodiment of the present invention further extracts global, high-level feature representations based on the splicing features, namely, overall semantic features. Overall semantic features integrate information of multiple features, and can capture deeper semantic structures and relationships in the text to be classified, thus reflecting the overall semantic information of the text to be classified more comprehensively and accurately. Optionally, the splicing features can be input into a feedforward neural network, and after multi-layer linear transformation and nonlinear activation function processing, the overall semantic features can be obtained.

[0055] Since the overall semantic features can more comprehensively and accurately reflect the overall semantic information of the text to be classified, the classification results can be accurately obtained based on the overall semantic features, further improving the accuracy and robustness of the classification results.

[0056] Based on any of the above embodiments, the semantic features of the text to be classified are extracted; based on the prior information of the key segmentation, the key segmentation features in the text to be classified are enhanced to obtain the key enhanced features; based on the prior information of the edge segmentation, the edge segmentation features in the text to be classified are weakened to obtain the edge weakened features; based on the semantic features, the key enhanced features and the edge weakened features, the classification result of the text to be classified is determined, including: Based on the text classification model, the semantic features of the text to be classified are extracted; based on the prior information of the key segmentation, the key segmentation features in the text to be classified are enhanced to obtain the key enhanced features; based on the prior information of the edge segmentation, the edge segmentation features in the text to be classified are weakened to obtain the edge weakened features; based on the semantic features, the key enhanced features and the edge weakened features, the classification results of the text to be classified are determined; The text classification model is trained based on sample text and the classification labels of the sample text.

[0057] Specifically, the text classification method described in any of the above embodiments can be implemented by a text classification model. The text classification model is trained based on sample texts and classification labels of the sample texts. The specific training process is as follows: Based on the initial model, the sample semantic features of the sample text are extracted. Based on the prior information of the key segmentation, the key segmentation features in the sample text are enhanced to obtain the sample key enhanced features. Based on the prior information of the edge segmentation, the edge segmentation features in the sample text are weakened to obtain the sample edge weakened features. Based on the first sample fusion weight between the sample semantic features and the sample key enhanced features, and the second sample fusion weight between the sample semantic features and the sample edge weakened features, the sample splicing weight coefficient is determined. Based on the sample splicing weight coefficient, the sample semantic features, the sample key enhanced features and the sample edge weakened features are spliced ​​to obtain the sample splicing features. Based on the sample splicing features, the overall semantic features of the sample are extracted, and the classification result of the sample text is determined based on the overall semantic features of the sample.

[0058] Based on the difference between the classification results of the sample text and the corresponding classification labels, the parameters of the initial model are adjusted to obtain a text classification model.

[0059] Based on any of the above embodiments, the text classification model is trained to maximize the correlation between the sample key enhancement features and the sample overall semantic features, minimize the correlation between the sample edge weakening features and the sample overall semantic features, and minimize the difference between the classification results of each sample text and the corresponding classification label. The sample key enhancement features are obtained by enhancing the key segmentation features in the sample text based on the key word prior information, the sample edge weakening features are obtained by weakening the edge segmentation features in the sample text based on the edge word prior information, and the sample overall semantic features are determined based on the sample semantic features, the sample key enhancement features, and the sample edge weakening features.

[0060] Specifically, considering that in text classification tasks, not all the words in the text to be classified have the same influence on the classification results. Some key words (such as keywords, subject words, etc.) have a greater influence on determining the category to which the text belongs. By maximizing the correlation between the key enhancement features of the sample and the overall semantic features of the sample, the model can better identify and focus on the key words, thereby improving the accuracy of classification. If the correlation between the key enhancement features of the sample and the overall semantic features of the sample is very small, the model may not be able to effectively distinguish between important words and minor words, which may cause the model to be misled by redundant information or interference information during classification, thereby reducing the classification performance.

[0061] Therefore, during the training process, by maximizing the correlation between the sample's key enhancement features and the sample's overall semantic features, the model learns how to more effectively extract and represent key words from the input text, enhances the model's ability to recognize key words in the text, and then accurately classifies the text based on key words.

[0062] In addition, considering that in text classification tasks, marginal segmentation words usually refer to segmentation words that have little or no effect on the classification results, these segmentation words may contain noise, redundant information, or common words related to other categories. If the correlation between the marginal weakening features of the sample and the overall semantic features of the sample is maximized, the model may pay too much attention to these marginal segmentation words, thereby introducing noise and interference, affecting the accuracy of classification. On the contrary, minimizing the correlation between the marginal weakening features of the sample and the overall semantic features of the sample can prompt the model to ignore these marginal segmentation words and reduce their impact on the classification results.

[0063] Therefore, during the training process, by minimizing the correlation between the edge weakening features of the sample and the overall semantic features of the sample, the model learns to ignore edge segmentation words during classification, that is, reducing the model's dependence on edge segmentation words, thereby improving the accuracy and efficiency of classification.

[0064] Furthermore, during the training process, by minimizing the difference between the classification results of each sample text and the corresponding classification label, the model learns how to more effectively map the input text to the correct category to improve the classification accuracy of the model.

[0065] Exemplarily, the prior loss value can be determined based on the correlation between the sample focus enhancement feature and the overall semantic feature of the sample, and the correlation between the sample edge weakening feature and the overall semantic feature of the sample, the classification loss value can be determined based on the difference between the classification result of each sample text and the corresponding classification label, the training loss value can be determined based on the prior loss value and the classification loss value, and the parameters of the initial model can be updated based on the training loss value to obtain a text classification model. The training loss value can be determined based on the following formula: L=Loss+Loss2 Loss2=-Loss focus +Loss downweight Among them, L represents the training loss value, Loss represents the classification loss value, Loss2 represents the prior loss value, and Loss focus Based on the correlation between the sample’s key enhancement features and the sample’s overall semantic features, Loss downweight Based on the correlation between the sample edge weakening feature and the sample overall semantic feature, the difference between the above two features can be determined by the cosine similarity (Cosine Similarity), Euclidean Distance, Mutual Information (MI), etc. between the sample key enhancement feature and the sample overall semantic feature.

[0066] Based on any of the above embodiments, the classification result of the text to be classified is determined, and then the method further includes: Based on the difference between the classification result of each sample text and the corresponding classification label, the key word segmentation prior information and / or the marginal word segmentation prior information are optimized.

[0067] Specifically, in text classification tasks, the feature expressions of key words and marginal words are crucial to the performance of the model.

[0068] In this regard, the embodiments of the present invention optimize the key word segmentation prior information and / or the marginal word segmentation prior information based on the difference between the classification result of each sample text and the corresponding classification label, thereby improving the accuracy and efficiency of text classification.

[0069] Exemplarily, based on the difference between the classification results of each sample text and the corresponding classification label, correctly classified sample text and incorrectly classified sample text can be determined, and the correctly classified sample text and the incorrectly classified sample text can be compared to optimize the key word segmentation prior information and / or the marginal word segmentation prior information.

[0070] Based on any of the above embodiments, Figure 2 It is a flowchart of the text classification model training method provided by the present invention, such as Figure 2 As shown, the initial model of the text classification model includes a feature extraction module, an important information introduction module, an edge information introduction module, a first fully connected layer, a second fully connected layer, a feedforward neural network, a feature extraction layer, and a classification layer. The feature extraction module can be a BERT model, the feature extraction layer can be a CLS layer, and the classification layer can be a softmax layer.

[0071] Input the sample text into the feature extraction module to obtain the sample semantic features.

[0072] The sample text is input into the important information introduction module to enhance the key word segmentation features in the sample text to obtain the initial sample key enhancement features, and the initial sample key enhancement features are input into the first fully connected layer to obtain the sample key enhancement features.

[0073] The sample text is input into the edge information introduction module to weaken the edge segmentation features in the sample text to obtain the initial sample edge weakened features, and the initial sample edge weakened features are input into the second fully connected layer to obtain the sample edge weakened features.

[0074] Based on the first sample fusion weight between the sample semantic feature and the sample key enhancement feature, and the second sample fusion weight between the sample semantic feature and the sample edge weakening feature, the sample splicing weight coefficient is determined, and based on the sample splicing weight coefficient, the sample semantic feature, the sample key enhancement feature and the sample edge weakening feature are spliced ​​to obtain the sample splicing feature.

[0075] The sample concatenation features are input into the feedforward neural network to obtain the final feature representation, and the final feature representation is input into the feature extraction layer to obtain the overall semantic features of the sample.

[0076] The overall semantic features of the sample are input into the classification layer to obtain the classification result of the sample text.

[0077] The prior loss value is determined based on the correlation between the sample's key enhancement features and the sample's overall semantic features, as well as the correlation between the sample's edge weakening features and the sample's overall semantic features. The classification loss value is determined based on the difference between the classification results of each sample text and the corresponding classification label. The training loss value is determined based on the prior loss value and the classification loss value. The parameters of the initial model are updated based on the training loss value to obtain a text classification model.

[0078] The text classification device provided by the present invention is described below. The text classification device described below and the text classification method described above can be referenced to each other.

[0079] Based on any of the above embodiments, Figure 3 is a schematic diagram of the structure of the text classification device provided by the present invention, such as Figure 3 As shown, the device comprises: An extraction unit 310, used to extract semantic features of the text to be classified; An enhancement unit 320 is used to enhance the key word segmentation features in the to-be-classified text based on the key word segmentation prior information to obtain key enhanced features; A weakening unit 330 is used to weaken the edge segmentation features in the text to be classified based on the edge segmentation prior information to obtain the edge weakening features; The classification unit 340 is used to determine the classification result of the text to be classified based on the semantic features, the key enhancement features and the edge weakening features.

[0080] Based on any of the above embodiments, the classification result of the text to be classified is determined based on the semantic features, the key enhancement features, and the edge weakening features, including: Based on a first fusion weight between the semantic feature and the key enhancement feature, and a second fusion weight between the semantic feature and the edge weakening feature, the semantic feature, the key enhancement feature, and the edge weakening feature are concatenated to obtain a concatenated feature; Based on the concatenated features, the classification result of the text to be classified is determined.

[0081] Based on any of the above embodiments, based on the first fusion weight between the semantic feature and the key enhancement feature, and the second fusion weight between the semantic feature and the edge weakening feature, the semantic feature, the key enhancement feature and the edge weakening feature are spliced ​​to obtain the spliced ​​feature, including: Determining a splicing weight coefficient based on the first fusion weight and the second fusion weight; Based on the splicing weight coefficient, the semantic features, key enhancement features and edge weakening features are spliced ​​to obtain the splicing features.

[0082] Based on any of the above embodiments, determining the classification result of the text to be classified based on the splicing features includes: Based on the splicing features, the overall semantic features of the text to be classified are extracted; Based on the overall semantic features, the classification result of the text to be classified is determined.

[0083] Based on any of the above embodiments, the semantic features of the text to be classified are extracted; based on the prior information of the key segmentation, the key segmentation features in the text to be classified are enhanced to obtain the key enhanced features; based on the prior information of the edge segmentation, the edge segmentation features in the text to be classified are weakened to obtain the edge weakened features; based on the semantic features, the key enhanced features and the edge weakened features, the classification result of the text to be classified is determined, including: Based on the text classification model, the semantic features of the text to be classified are extracted; based on the prior information of the key segmentation, the key segmentation features in the text to be classified are enhanced to obtain the key enhanced features; based on the prior information of the edge segmentation, the edge segmentation features in the text to be classified are weakened to obtain the edge weakened features; based on the semantic features, the key enhanced features and the edge weakened features, the classification results of the text to be classified are determined; The text classification model is trained based on sample text and the classification labels of the sample text.

[0084] Based on any of the above embodiments, the text classification model is trained to maximize the correlation between the sample key enhancement features and the sample overall semantic features, minimize the correlation between the sample edge weakening features and the sample overall semantic features, and minimize the difference between the classification results of each sample text and the corresponding classification label. The sample key enhancement features are obtained by enhancing the key segmentation features in the sample text based on the key word prior information, the sample edge weakening features are obtained by weakening the edge segmentation features in the sample text based on the edge word prior information, and the sample overall semantic features are determined based on the sample semantic features, the sample key enhancement features, and the sample edge weakening features.

[0085] Based on any of the above embodiments, the classification result of the text to be classified is determined, and then the method further includes: Based on the difference between the classification result of each sample text and the corresponding classification label, the key word segmentation prior information and / or the marginal word segmentation prior information are optimized.

[0086] Figure 4 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the text classification method, which includes: extracting the semantic features of the text to be classified; based on the prior information of the key segmentation, enhancing the key segmentation features in the text to be classified to obtain the key enhancement features; based on the prior information of the edge segmentation, weakening the edge segmentation features in the text to be classified to obtain the edge weakening features; based on the semantic features, the key enhancement features and the edge weakening features, determining the classification result of the text to be classified.

[0087] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0088] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the text classification method provided by the above-mentioned methods, which includes: extracting semantic features of the text to be classified; based on key word prior information, enhancing the key word segmentation features in the text to be classified to obtain key enhanced features; based on edge word prior information, weakening the edge word segmentation features in the text to be classified to obtain edge weakened features; based on the semantic features, the key enhanced features and the edge weakened features, determining the classification result of the text to be classified.

[0089] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the text classification method provided by the above-mentioned methods, the method comprising: extracting semantic features of the text to be classified; based on key word prior information, enhancing the key word features in the text to be classified to obtain key enhanced features; based on edge word prior information, weakening the edge word features in the text to be classified to obtain edge weakened features; and determining the classification result of the text to be classified based on the semantic features, the key enhanced features and the edge weakened features.

[0090] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0091] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0092] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A text classification method, characterized in that: include: Extract semantic features of the text to be classified; Based on the prior information of key word segmentation, the key word segmentation features in the text to be classified are enhanced to obtain key enhanced features; Based on the edge segmentation prior information, weaken the edge segmentation features in the text to be classified to obtain edge weakening features; Based on the semantic features, the emphasis enhancement features and the edge weakening features, a classification result of the text to be classified is determined.

2. The text classification method according to claim 1, characterized in that: The step of determining the classification result of the text to be classified based on the semantic feature, the key enhancement feature and the edge weakening feature includes: Based on a first fusion weight between the semantic feature and the key enhancement feature, and a second fusion weight between the semantic feature and the edge weakening feature, splicing the semantic feature, the key enhancement feature, and the edge weakening feature to obtain a splicing feature; Based on the splicing features, a classification result of the text to be classified is determined.

3. The text classification method according to claim 2, characterized in that: The step of splicing the semantic feature, the key enhancement feature and the edge weakening feature based on the first fusion weight between the semantic feature and the key enhancement feature, and the second fusion weight between the semantic feature and the edge weakening feature to obtain a spliced ​​feature includes: Determining a splicing weight coefficient based on the first fusion weight and the second fusion weight; Based on the splicing weight coefficient, the semantic feature, the key enhancement feature and the edge weakening feature are spliced ​​to obtain the splicing feature.

4. The text classification method according to claim 3, characterized in that: The step of determining the classification result of the text to be classified based on the splicing feature includes: Extracting the overall semantic features of the text to be classified based on the splicing features; Based on the overall semantic features, a classification result of the text to be classified is determined.

5. The text classification method according to any one of claims 1 to 4, characterized in that: The extracting semantic features of the text to be classified, based on the key word prior information, enhancing the key word features in the text to be classified, to obtain key enhanced features; Based on the edge segmentation prior information, weaken the edge segmentation features in the text to be classified to obtain edge weakening features; Determining the classification result of the to-be-classified text based on the semantic feature, the key enhancement feature, and the edge weakening feature includes: Based on the text classification model, the semantic features of the text to be classified are extracted; based on the prior information of the key segmentation, the key segmentation features in the text to be classified are enhanced to obtain the key enhanced features; based on the prior information of the edge segmentation, the edge segmentation features in the text to be classified are weakened to obtain the edge weakened features; based on the semantic features, the key enhanced features and the edge weakened features, the classification result of the text to be classified is determined; The text classification model is trained based on sample text and classification labels of the sample text.

6. The text classification method according to claim 5, characterized in that: The text classification model is trained by maximizing the correlation between the sample key enhancement feature and the sample overall semantic feature, minimizing the correlation between the sample edge weakening feature and the sample overall semantic feature, and minimizing the difference between the classification result of each sample text and the corresponding classification label. The sample key enhancement feature is obtained by enhancing the key segmentation feature in the sample text based on the key segmentation prior information, the sample edge weakening feature is obtained by weakening the edge segmentation feature in the sample text based on the edge segmentation prior information, and the sample overall semantic feature is determined based on the sample semantic feature, the sample key enhancement feature and the sample edge weakening feature.

7. The text classification method according to claim 6, characterized in that: The step of determining the classification result of the text to be classified further includes: Based on the difference between the classification result of each sample text and the corresponding classification label, the key word segmentation prior information and / or the marginal word segmentation prior information are optimized.

8. A text classification device, characterized in that: include: An extraction unit, used to extract semantic features of the text to be classified; An enhancement unit, used for enhancing the key word segmentation features in the text to be classified based on the key word segmentation prior information to obtain key enhanced features; A weakening unit, used for weakening edge segmentation features in the text to be classified based on edge segmentation prior information to obtain edge weakening features; The classification unit is used to determine the classification result of the text to be classified based on the semantic feature, the focus enhancement feature and the edge weakening feature.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the text classification method according to any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the text classification method according to any one of claims 1 to 7 is implemented.