A long-tail distribution complaint reporting text classification method based on balanced loss function

By using the Gumbel activation function and a balanced loss function with regularization constraints in the classification of complaint and report texts, the classification bias caused by long-tail distribution is solved, the classification performance of tail categories is improved, and more efficient text classification results are achieved.

CN118069836BActive Publication Date: 2026-11-24BEIJING UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410094505.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-23
Publication Date
2026-11-24
Estimated Expiration
2044-01-23

AI Technical Summary

Technical Problem

Existing methods for classifying complaint and report texts often struggle to effectively classify tail-category samples when dealing with long-tailed distributions, resulting in poor overall classification performance.

Method used

The Gumbel activation function is used instead of the traditional activation function. Combined with the class balance loss function and regularization constraints, the weights of different classes are adjusted. The Gumbel regularized balance loss function (GRBL) is used to optimize the model training process, suppress classification bias and improve generalization ability.

Benefits of technology

Significantly improved the classification performance of tail categories and enhanced the overall classification effect, especially in real-world environmental complaint and reporting data, where Micro-F1 and Macro-F1 improved by 4.31% and 3.9% respectively.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118069836B_ABST
    Figure CN118069836B_ABST
Patent Text Reader

Abstract

This invention discloses a long-tail distribution complaint and report text classification method based on a balanced loss function, specifically including the following steps: First, data cleaning and stop word removal are performed on the data to reduce interference in the subsequent text classification process; then, a BERT pre-trained model is used for pre-training and feature extraction to obtain the feature vector most relevant to the category information; finally, a fully connected layer classifier is used to obtain the classification result. Furthermore, this invention optimizes the classic loss function by proposing a Gumbel distribution balanced loss function. On the one hand, the Gumbel activation function is used instead of the general activation function, assigning different gradients to the head and tail classes; on the other hand, a regularization term is introduced to suppress overfitting of the tail class and improve its generalization. This invention significantly improves the classification effect of the tail class, thereby improving the overall classification performance and effectively solving the long-tail distribution problem in complaint and report text classification tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to text classification methods in the field of natural language processing, specifically to a long-tailed distribution complaint and report text classification method based on a balanced loss function. Background Technology

[0002] Complaints and reports are an important way for residents to report various urgent problems in their lives to relevant departments. Real-time and effective rapid classification of complaint and report text data can significantly improve the efficiency of relevant departments in handling these issues. The large amount of information and unstructured nature of complaint and report events make manual classification difficult. Therefore, in order to achieve efficient and accurate handling of complaint and report issues, intelligent assisted classification of complaint and report texts is essential.

[0003] Residents submit complaints and reports via WeChat, websites, and telephone. The data is ultimately processed as text, so the process of assigning complaints and reports to different categories is text classification. Text classification is an important research task in the field of natural language processing, primarily referring to the automatic matching of acquired text data with specific labels according to certain rules. Long-tailed distribution is a significant challenge in complaint and report text classification. Most real-world complaint and report datasets exhibit long-tailed distribution characteristics, meaning that a few categories (head classes) have a particularly large number of samples, while most categories (tail classes) have very few samples. This severe imbalance in the distribution of samples between categories increases the difficulty of classification; categories with fewer samples are easily overlooked during classification, leading to poor overall classification results.

[0004] Data resampling and loss reweighting are two mainstream methods for solving the long-tailed distribution problem. Resampling improves training performance by adjusting the distribution of data, mainly including undersampling and oversampling. The oversampling method proposed by Park S et al. (Park S, Hong Y, Heo B, et al. The majority can help the minority: Context-rich minority oversampling for long-tailed classification[C] / / Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition.2022:6887-6896.) pastes the minority class image onto the rich context image of the majority class, using the rich background of the majority class as the background image to enhance the minority class samples. Areveen MA et al. (Arefeen MA, Nimi ST, Rahman M S. Neural network-based undersampling techniques[J]. IEEE Transactions on Systems, Man, and Cybernetics: Systems, 2020, 52(2): 1111-1120.) removed majority samples located near minority samples, alleviating the imbalance problem by undersampling the majority class data. He J et al. (He J, Lin L, Eicher-Miller HA, et al. Long-Tailed Food Classification[J]. Nutrients, 2023, 15(12): 2751.) proposed a two-stage framework, undersampling the head class to remove redundant samples, while oversampling the tail class for data augmentation. However, in the case of a long-tailed distribution of the dataset, artificially changing the class balance of the training samples during model learning can easily lead to poor performance or overfitting. Reweighting can optimize the model training process by adjusting the loss values ​​of different classes during training, which is more flexible and convenient.Lin TY et al. (Lin TY, Goyal P, Girshick R, et al. Focal loss for dense object detection[C] / / Proceedings of the IEEE international conference on computer vision.2017:2980-2988.) focused on the classification performance of easy and difficult samples and proposed a focal loss function that favors difficult samples. Cui Y et al. (Cui Y, Jia M, Lin TY, et al. Class-balanced loss based on effective number of samples[C] / / Proceedings of the IEEE / CVF conference on computer vision and pattern recognition.2019:9268-9277.) introduced the concept of effective number of samples and used a class-balanced reweighting term that is inversely proportional to the effective number of classes to solve the class imbalance problem. However, most of the current reweighting methods are applicable to image processing, and the improvement in classification performance of tail class samples in complaint and report text classification tasks with long-tail distribution characteristics is not significant.

[0005] To address the aforementioned issues, this paper proposes a long-tailed distribution complaint and report text classification method based on a balanced loss function, which significantly improves the classification performance of the tail classes, thereby enhancing the overall classification effect. The Gumbel activation function is used instead of the traditional activation function in the loss function to calculate the network output value, generating more balanced classification weights and suppressing classification bias. Simultaneously, a regularization term is introduced into the loss function, adding constraint factors and bias parameters to prevent the model from overfitting the training data, thus enhancing the model's generalization ability.

[0006] In summary, the long-tailed distribution complaint and report text classification method based on the balanced loss function is an innovative research problem with significant research value. Summary of the Invention

[0007] Long-tailed data distribution is a significant challenge in complaint and report text classification. The imbalance in sample size distribution between categories often makes it difficult to effectively classify the category with fewer samples (the tail class), leading to poor overall classification performance. To address this issue, this paper proposes a long-tailed complaint and report text classification method based on a balanced loss function, adjusting the weights of samples from different categories. Firstly, this method improves the classic loss function by using the Gumbel activation function instead of the general activation function, assigning different gradients to the head and tail classes to balance classification bias. Then, to suppress overfitting of the tail class, a regularization constraint is introduced into the loss function to improve its generalization ability.

[0008] A long-tailed distribution complaint and report text classification method based on a balanced loss function specifically includes:

[0009] (1) Data preprocessing module

[0010] Data preprocessing mainly involves cleaning the text dataset, removing stop words, etc., to obtain standardized samples and labels for subsequent training.

[0011] (2) Feature extraction module

[0012] The BERT model is used for feature extraction. The text content of complaints and reports is vectorized through operations such as word segmentation and word embedding. The output of the model is used as the feature representation of the text input.

[0013] (3) Classifier module

[0014] The feature vectors are classified through a fully connected layer classifier to obtain the predicted labels of the text. The Gumbel activation function is used instead of the traditional Sigmoid activation function to produce more balanced weights in the head and tail classes.

[0015] (4) Balanced loss function

[0016] During training and classification, the predicted and true labels are adjusted using the Gumbel Regularized Balanced Loss (GRBL) function to optimize the weight parameters of the neural network and achieve the best classification results.

[0017] The method (4) uses the Gumbel Regularized Balanced Loss (GRBL) function, which is an improvement on the Class Balanced Loss (CB Loss), for training. The specific process of designing the Gumbel Regularized Balanced Loss (GRBL) function includes the following steps:

[0018] The S1 weight coefficients use the weights r from the Class Balanced Loss (CB Loss) function. CB .

[0019] S2 uses the Gumbel activation function instead of the traditional Sigmoid activation function. The Gumbel activation function allows gradients for positive samples to grow exponentially and provides a sharp decrease in gradients for negative samples. It can be combined with the cross-entropy loss function to smooth the sampling process for minority classes, helping to suppress classification bias and improve the learning ability for minority classes. Furthermore, the Gumbel activation function is frame-insensitive and can be used with other loss functions and datasets, making it widely applicable. Its functional form is typically: σ Gumbel (x)=exp(-e -x ), where σ Gumbel (*) indicates the Gumbel activation function.

[0020] S3 introduces the constraint factor μ and the deviation parameter ε. i In text classification tasks with long-tail distribution characteristics, the model may overemphasize the head class and neglect the tail class because the tail class has a relatively large number of negative samples. Regularization constraints can introduce additional restrictions on the model parameters during training to prevent the model from overfitting to the training data and improve its generalization ability. During model training, a loss function is typically used to measure the difference between the model's predictions and the actual results. Therefore, to prevent the tail class from overfitting to a finite number of positive samples in the space, the Gumbel regularization balance loss function introduces a constraint factor μ and a bias parameter ε. i .

[0021] S4 uses category-balanced weights r CB Combined application of the above Gumbel activation function σ Gumbel (*) and regularization constraints, finally yielding the Gumbel Regularized Balance Loss (GRBL) proposed in this invention, which can solve the long-tail distribution problem in complaint and report text classification tasks. Attached Figure Description

[0022] Figure 1 Flowchart for long-tailed distribution complaint and report text classification based on balanced loss function

[0023] Figure 2 Design diagram for loss function of long-tailed distribution complaint and report text classification based on balanced loss function.

[0024] Figure 3 A comparison chart of the activation function curves of Sigmoid and Gumbel.

[0025] Figure 4 Comparative Experiment Results of Complaint and Report Text Classification

[0026] Figure 5Ablation Experiment Results for the Activation Function Module for Classifying Complaint and Report Text

[0027] Figure 6 Ablation experiment results for the regularization constraint module for classifying complaint and report texts Detailed Implementation

[0028] To make the technical solution of the present invention clearer, the specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.

[0029] This invention proposes a long-tailed distribution complaint and report text classification method based on a balanced loss function. The specific process is as follows: Figure 1 As shown. The method is characterized by providing a dataset of complaint / report text classification. Where x i Let x represent the i-th text sample, and n be the total number of texts in the dataset, specifically 82832 data points. For any input sample x... i Each has its corresponding tag. in Let x be the binary representation of the label of class k, and m be the total number of classes (24 in total). Input sample x i The feature vector f is obtained after the BERT pre-trained model. i ∈R D , where D is the dimension of the model embedding layer, and the dimension is set to 300.

[0030] During classification, the feature vector f i It needs to pass through a fully connected layer classifier θ(·), θ(f i ) = W T f i +b, where W∈R D×m For classification weights, b∈R m This is the deviation item, used to calculate the score. Then, the activation function σ(·) is used to transform the score into a predicted output. in Record the loss as In general, this can be achieved by minimizing the loss calculated on the training set. To extract the optimal classifier parameters W * .

[0031] A long-tailed distribution complaint and report text classification method based on a balanced loss function specifically includes:

[0032] (1) Data preprocessing module

[0033] Data preprocessing mainly involves processing text datasets. Data cleaning and stop word removal are performed to obtain standardized sample x. i and tag y i To facilitate subsequent training.

[0034] (2) Feature extraction module

[0035] The BERT model is used for feature extraction on the text content of complaints and reports. i Vectorization is performed through operations such as word segmentation and word embedding, and the model's output is used as the text input x. i Feature representation f i Here, BERT represents the pre-trained model used, the batch size is set to 32, and the batch size represents the number of samples passed to the model for training in each iteration. The number of training epochs is set to 10, and the learning rate is set to 1e-5.

[0036] (3) Classifier module

[0037] eigenvector f i The text is classified using a fully connected layer classifier θ(·) to obtain the predicted labels. The Gumbel activation function is used instead of the traditional Sigmoid activation function, resulting in a more balanced weight between the head and tail classes.

[0038] (4) Balanced loss function

[0039] Predicting labels during training and classification and real label y i By applying Gumbel regularization to the balanced loss (GRBL) function L GRB Adjust the weight parameters of the neural network to obtain the best classification results.

[0040] In step (4), the balanced loss function is trained using the Gumbel Regularized Balanced Loss (GRBL) function, which is an improvement on the Class Balanced Loss (CB Loss) function. The design process of the Gumbel Regularized Balanced Loss (GRBL) function is as follows: Figure 2 As shown, the specific steps include:

[0041] The S1 weight coefficients use the weights r from the Class Balanced Loss (CB Loss) function. CB The Class Balanced Focusing Loss (CB Loss) introduces the concept of the effective number of samples, reweights the focusing loss, and reduces redundant information in the header, achieving optimal performance in text classification tasks on long-tailed datasets. The specific formula is as follows:

[0042]

[0043]

[0044] Where N k Let β represent the number of samples in class k, and β∈[0,1) is used to control the rate of increase of the effective number. Here, the value of β is 0.9.

[0045] S2 uses the Gumbel activation function instead of the traditional Sigmoid activation function. Traditional loss functions typically use the Sigmoid activation function, which, while symmetric and well-suited for balanced distributions, performs poorly when dealing with long-tailed distributions because it assigns equal weights to positive and negative examples. This paper addresses a single-label multi-class classification problem, thus introducing a new activation function, Gumbel, better suited for long-tailed distributions. Its functional form is typically:

[0046] σ Gumbel (x)=exp(-e -x (3)

[0047] Where σ Gumbel (*) indicates the Gumbel activation function.

[0048] For any input sample x in the complaint and report text classification task i It obtains a score through feature extraction and classification processes. in After processing with the activation function, the final predicted label output is obtained. The formula is as follows:

[0049]

[0050]

[0051] like Figure 3 As shown, the Gumbel activation function allows the gradient of positive samples to grow exponentially and the gradient of negative samples to decrease sharply. It can be used in conjunction with the cross-entropy loss function to smooth the sampling process for minority classes, helping to suppress classification bias and improve the learning ability for minority classes. Furthermore, the Gumbel activation function is frame-insensitive and can be used with other loss functions and datasets, making it widely applicable.

[0052] To prevent tail classes from overfitting a finite number of positive samples in the space, S3 introduces a constraint factor μ and a bias parameter ε into the Gumbel regularization balance loss function. i .

[0053] In the long-tail problem, due to data imbalance, the model may give a relatively conservative prediction for the head class and a relatively aggressive prediction for the tail class during the random initialization phase. Therefore, by introducing a bias parameter ε... i As a threshold, considering the model's inherent bias, the prediction threshold for different classes can be adjusted based on the characteristics of each class, balancing the model's attention to different classes. For example, for classes that are relatively few in the training data, a lower ε can be set. i This makes it easier for the model to capture the features of these minority categories, thereby improving its ability to learn from them.

[0054] Taking the BCE loss function as an example, consider the bias parameter ε i As the only variable, the approximate formula for the average loss of category i is as follows:

[0055]

[0056] Therefore, the deviation parameter ε i The specific formula for estimation by minimizing the loss function is as follows:

[0057]

[0058]

[0059] Where N k Let M be the number of samples in class k, M be the total number of samples, and α be the proportionality coefficient, where α is 0.05.

[0060] In addition, based on the consideration of controlling the loss gradient, we introduce a constraint factor μ to constrain the gradient between 0 and 1, so as to avoid excessively large or small gradient values ​​from adversely affecting model training. Here, μ is 2.

[0061] S4 uses category-balanced weights r CB Combined application of the above Gumbel activation function σ Gumbel (*) and regularization constraints are used to finally obtain the Gumbel Regularized Balance Loss (GRBL) proposed in this invention, which can solve the long-tail distribution problem in complaint and report text classification tasks. The specific formula is as follows:

[0062]

[0063]

[0064] Where γ is the control parameter used to control the classification of easy and difficult samples, and here γ is 2.

[0065] The complaint and reporting dataset used in this invention comes from real environmental complaints and reports received in 2020 from a large environmental complaint and reporting platform. A total of 82,832 environmental-related complaints and reports were collected from WeChat, web pages, and telephone. All labeled data were divided into training, validation, and test sets in an 8:1:1 ratio. Labels were categorized into head (3 categories, ≥6000 cases), middle (7 categories, between 1000 and 6000 cases), and tail (14 categories, ≤1000 cases).

[0066] like Figure 4 As shown, to verify the effectiveness of the Gumbel regularized balanced loss function compared to other loss functions in classifying environmental complaint and report texts, this paper selects commonly used classic loss functions in deep learning, such as Binary Cross-Entropy (BCE) and Focal Loss, as well as Class Balanced Focal Loss (CBLoss) and Distribution Balanced Loss (DB Loss), which are superior in text classification problems, and compares them with the Gumbel regularized balanced loss function. By comparing with classic loss functions BCE and FL, and loss functions that have performed well in recent years, such as CB and DB, it can be seen that our method achieves the best results on environmental complaint and report text data. The improvement is particularly significant in the classification of tail classes, with a 4.31% improvement compared to the best model Micro-F1 and a 3.9% improvement compared to Macro-F1.

[0067] like Figure 5 As shown, to verify the effectiveness of the Gumbel activation function module in solving long-tailed classification problems, comparative experiments were conducted with and without the Gumbel activation function module, using the classic loss functions Binary Cross-Entropy (BCE) and Focal Loss as benchmarks. In long-tailed classification problems, the loss functions BCE and Focal Loss with the Gumbel module performed better than those without. This further validates the effectiveness of the Gumbel module in solving long-tailed classification problems and provides strong support for the model to better handle imbalanced data distributions in real-world applications.

[0068] like Figure 6 As shown, to verify the effectiveness of the regularization constraint module on the long-tailed distribution problem, comparative experiments were conducted with and without the regularization constraint module, using Focal Loss, Class Balanced Focal Loss (CB Loss), and Distribution Balanced Loss (DB Loss) as benchmarks. It can be seen that Micro-F1 performs well with and without the regularization constraint module, but Macro-F1 shows a significant improvement with the regularization constraint module, indicating that this module has a significant mitigating effect on the long-tailed distribution problem.

[0069] This invention addresses the long-tail distribution problem in complaint and report text classification tasks by proposing a novel loss function, GRBL. GRBL, from the perspective of balancing the loss function, replaces the traditional general activation function with the Gumbel activation function and introduces regularization constraints to rebalance the gradients of positive and negative samples for each class. GRBL provides a more efficient solution for long-tail text classification without relying on data distribution adjustments or complex model modifications.

[0070] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for classifying complaint and report texts based on a long-tailed distribution using a balanced loss function, characterized in that, Given a dataset of complaint and report text classification Where x i Let x represent the i-th text sample, and n be the total number of texts in the dataset; for any input sample x i Each has its corresponding tag. in Let x be a binary representation of the label of the k-th class, and m be the total number of classes; input sample x i The feature vector f is obtained after the BERT pre-trained model. i ∈R D Where D is the dimension of the model embedding layer, set to 300; during classification, the feature vector f i It needs to pass through a fully connected layer classifier θ(·), θ(f i ) = W T f i +b, where W∈R D×m For classification weights, b∈R m This is the deviation item, used to calculate the score. Then, the activation function σ(·) is used to transform the score into a predicted output. in Record the loss as By minimizing the loss computed on the training set To extract the optimal classifier parameters W * ; The methods specifically include: (1) Data preprocessing module Data preprocessing is the process of processing text datasets. Data cleaning and stop word removal were performed to obtain standardized sample x. i and tag y i ; (2) Feature extraction module The BERT model is used for feature extraction on the text content of complaints and reports. i By segmenting and embedding words into vectors, the model's output is used as the text input x. i Feature representation f i Where BERT represents the pre-trained model used, the batch size is set to 32, and the batch size represents the number of samples passed to the model for training in each iteration; the number of training epochs is set to 10, and the learning rate is set to 1e-5. (3) Classifier module eigenvector f i The text is classified using a fully connected layer classifier θ(·) to obtain the predicted labels. Use the Gumbel activation function; (4) Balanced loss function Predicting labels during training and classification and real label y i The loss function L is balanced by Gumbel regularization. GRB Adjust the weight parameters of the neural network; specifically as follows: The S1 weight coefficients are derived from the weights r in the class-balanced loss function CB Loss. CB The specific formula is as follows: Where N k This represents the number of samples in the k-th class, and β∈[0,1) is used to control the rate of increase of the effective number. Here, the value of β is 0.

9. S2 uses the Gumbel activation function, which has the following form: σ Gumbel (x)=exp(-e -x ) (3) Where σ Gumbel (*) represents the Gumbel activation function; For any input sample x in the complaint and report text classification task i It obtains a score through feature extraction and classification processes. in After processing with the activation function, the final predicted label output is obtained. The formula is as follows: The S3Gumbel regularized equilibrium loss function introduces a constraint factor μ and a bias parameter ε. i Considering the deviation parameter ε i As the only variable, the approximate formula for the average loss of category i is as follows: Therefore, the deviation parameter ε i The specific formula for estimation by minimizing the loss function is as follows: Where N k Let M be the number of samples in the k-th class, M be the total number of samples, and α be the proportionality coefficient, where α is 0.

05. In addition, based on the consideration of controlling the loss gradient, a constraint factor μ is introduced, where μ is 2; S4 ultimately yields the Gumbel regularized equilibrium loss; the specific formula is as follows: Where γ≥0 is an adjustment factor used to control the loss function to focus on hard-to-classify samples, and γ is 2.