An emotion classification optimization method and system based on prediction distribution geometric constraint

By introducing a joint loss function with geometric constraints on the prediction distribution and a warm-up strategy into the sentiment classification model, the prediction distribution structure of the model is optimized, which solves the problem of prediction instability in multi-class sentiment tasks and improves the stability and generalization ability of the model.

CN122132565AActive Publication Date: 2026-06-02HUNAN INST OF INFORMATION TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUNAN INST OF INFORMATION TECH
Filing Date
2026-05-06
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies lack structural constraints on the predicted probability distribution of model outputs in multi-class, fine-grained emotion tasks, resulting in prediction instability and insufficient generalization ability. In particular, lightweight models are prone to getting stuck in local optima or training oscillations.

Method used

By introducing a joint loss function based on the geometric constraints of the predicted distribution, the geometric distance of the predicted probability distribution of samples is quantified using the Bregman divergence metric. The sentiment classification model is optimized during training, and a preheating strategy is adopted to introduce geometric constraint terms in stages to avoid interference in the early stages of training.

Benefits of technology

It significantly improves the stability and generalization ability of sentiment classification models, especially the training stability and classification accuracy of lightweight models, and avoids performance degradation caused by premature introduction of geometric constraints.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132565A_ABST
    Figure CN122132565A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of artificial intelligence model training and optimization technology, specifically a sentiment classification optimization method and system based on geometric constraints of predicted distribution. The method includes: extracting feature vectors from text samples to be classified; inputting the feature vectors into a sentiment classification model to obtain a predicted probability distribution; wherein the model is trained by minimizing a joint loss function, which includes a discriminative loss term and a geometric constraint term; the geometric constraint term is constructed based on the geometric distance between the predicted probability distributions of sample pairs, used to reduce the distance between predicted distributions of similar samples and increase the distance between predicted distributions of dissimilar samples during training; finally, the predicted probability distribution is output as the classification result. This invention, by imposing geometric constraints on the predicted probability distribution, enables the model to improve the prediction stability and generalization ability for boundary samples and noisy samples while ensuring classification accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence model training and optimization technology, and in particular to a sentiment classification optimization method and system based on predictive distribution geometric constraints. Background Technology

[0002] Existing technologies for improving sentiment classification performance mainly focus on the following categories: First, introducing different deep learning model architectures to enhance semantic capture capabilities by improving network structure; second, comparing traditional machine learning and deep learning methods to clarify the advantages and disadvantages of each method. However, existing solutions have significant shortcomings. On the one hand, most methods use minimizing label-level losses (such as cross-entropy loss) as the training objective, primarily focusing on whether the final classification result is correct, while lacking systematic constraints on the probability distribution structure of the model output itself. In multi-class sentiment tasks or when fine-grained sentiment expressions exist, relying solely on label consistency constraints is insufficient to fully utilize the similarity between categories and the probability relationships within categories, potentially leading to insufficient model prediction stability. On the other hand, most existing technologies focus on feature-level optimization, dictionary enhancement, or model structure design, without incorporating the overall geometric structure of the predicted probability distribution as a training objective into the model learning process.

[0003] Patent application CN117672268A discloses a multimodal speech emotion recognition method based on relative entropy alignment fusion. It uses KL divergence to align multimodal features, but the method constrains the feature representation of the intermediate layer rather than the predicted probability distribution of the final output. It is mainly applied to multimodal fusion scenarios and does not involve systematic optimization of the geometric structure of the output distribution of a single modality classifier.

[0004] Overall, existing technologies often lack consideration for stability in the early stages of training when dealing with multi-category, fine-grained emotion tasks. Imposing strong geometric constraints directly in the early stages of training can easily cause lightweight models (such as LSTM and MobileBERT) to get stuck in local optima or experience training oscillations. Summary of the Invention

[0005] This invention proposes an optimization method and system for emotion classification based on the geometric constraints of the prediction distribution, aiming to solve the technical problem of unstable prediction of boundary samples and noise samples in multi-class, fine-grained emotion tasks in the prior art.

[0006] In a first aspect, the present invention provides a sentiment classification optimization method based on predictive distribution geometric constraints, comprising: Obtain a text sample to be classified and extract its feature vector; input the feature vector into a pre-trained sentiment classification model, which outputs the predicted probability distribution of the text sample to be classified on a preset sentiment category set; The sentiment classification model is trained by minimizing a joint loss function, which includes a discriminative loss term and a geometric constraint term. The discriminant loss term is used to measure the classification accuracy between the predicted probability distribution output by the sentiment classification model and the true label of the sample; The geometric constraint term is constructed based on the geometric distance between the predicted probability distributions of different sample pairs. The geometric constraint term is used to reduce the geometric distance between the predicted probability distributions of two samples with the same true label and increase the geometric distance between the predicted probability distributions of two samples with different true labels during training. The predicted probability distribution is output as the sentiment classification result.

[0007] The technical effect of the sentiment classification optimization method based on the geometric constraints of the predicted distribution disclosed in this invention is that by jointly optimizing the discriminant loss and the geometric constraints of the predicted distribution, the predicted distributions of similar samples tend to converge while the predicted distributions of dissimilar samples separate, thereby significantly improving the stability, consistency and generalization ability of the sentiment classification results.

[0008] Furthermore, the geometric distance is measured using Bregman divergence; for any two samples and The predicted probability distributions for the two samples are as follows: and Then the Bregman divergence The calculation formula is: ; ; in, This indicates that a strictly convex function defined on the probability distribution is used to generate the Bregman divergence, the value of which is determined by the input distribution. The probabilities of each dimension are calculated in functional form; Scalar hyperparameters used to control the strength of higher-order coupling terms are typically taken as non-negative real numbers; Indicate category With category The elements of the relationship matrix can be taken as non-negative values ​​based on the normalization result of the confusion matrix or semantic similarity; Describes the probability distribution at the th... Values ​​that can be taken on a class.

[0009] Furthermore, the geometric constraint term uses symmetric Bregman divergence as the geometric distance; the formula for calculating the symmetric Bregman divergence is: ; The geometric constraint terms The calculation formula is: ; in, This represents the total number of training samples. This represents the weighting coefficient of the sample pair.

[0010] Furthermore, the sample pairs weight coefficients According to the sample Authentic Labels and samples Authentic Labels Determined, specifically: when hour, ;when hour, ; Specifically, a category-level confusion matrix is ​​constructed based on the model's prediction results on the training set. Then normalize to obtain the confusion matrix , for Misclassified as a category The relative proportion.

[0011] Furthermore, the joint loss function The calculation formula is: ; in, This represents the discriminative loss term. This represents the geometric constraint term. The squared L2 norm of the parameters of the sentiment classification model is represented by... This represents the weighting coefficient of the geometric constraint term, with a value range of 10. 3 Up to 10, This represents the regularization coefficient, with a value range of 10. 4 Up to 1.

[0012] Furthermore, the discriminative loss term The Hinge loss for multi-class classification, based on class margin constraints, is employed; its calculation formula is as follows: ; in, The total number of training samples, For the sample The true label, 'c' represents the emotion category. For the sample The discriminant score on its true category c; the discriminant score function The calculation formula is: ; in, This represents the weight coefficient for category c, with a value ranging from 0.1 to 10. For the sample Predicted probability distribution The predicted probability value for sentiment type c.

[0013] Furthermore, the sentiment classification model is a neural network model, and a warm-up strategy is used during training to introduce the geometric constraint terms in stages; the warm-up strategy includes: In the first training phase, only the discriminant loss term is used. The parameters of the emotion classification model are optimized. After reaching the preset training round threshold, the second training phase begins, using the discriminative loss term. and the geometric constraint terms joint loss function The parameters of the emotion classification model are optimized.

[0014] Further, the feature vector of the text sample to be classified is extracted, specifically including: The text sample to be classified is encoded using a pre-trained language model, and the hidden state vector corresponding to the CLS tag output by the pre-trained language model is obtained. The hidden state vector is then used as the feature vector. Alternatively, average pooling or max pooling can be performed on the sequence features of the text sample to be classified, and the pooled vector can be used as the feature vector.

[0015] Secondly, the present invention provides a sentiment classification optimization system based on predictive distribution geometric constraints, the system being used to implement the method, the system comprising: The feature extraction module is used to acquire text samples to be classified and extract the feature vectors of the text samples to be classified. The sentiment classification module has a pre-trained sentiment classification model built in, which is used to map the feature vector to a predicted probability distribution on a preset set of sentiment categories. A model training module is used to train the sentiment classification model, and the model training module includes a joint loss construction unit; The joint loss construction unit is used to construct a joint loss function, which includes a discriminant loss term and a geometric constraint term. The discriminant loss term is used to measure the classification accuracy between the predicted probability distribution output by the sentiment classification model and the true label of the sample; The geometric constraint term is constructed based on the geometric distance between the predicted probability distributions of different sample pairs. The geometric constraint term is used to reduce the geometric distance between the predicted probability distributions of two samples with the same true label and increase the geometric distance between the predicted probability distributions of two samples with different true labels during training. The model training module optimizes the parameters of the sentiment classification model by minimizing the joint loss function.

[0016] The technical effect of the system disclosed in this invention is that, through the collaborative work of feature extraction, sentiment classification and model training modules, geometric constraints are internalized into model parameters, and structural optimization of the output distribution of the sentiment classification model is achieved without increasing the inference complexity, thereby effectively improving the robustness and classification reliability of the system in practical applications.

[0017] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described thereon. Attached Figure Description

[0018] Figure 1 This is a flowchart illustrating an optimization method for sentiment classification based on predictive distribution geometric constraints proposed in an embodiment of the present invention. Figure 2 A schematic diagram of the predicted distribution space and geometric constraints provided in an embodiment of the present invention; Figure 3 This is a schematic diagram illustrating the training using a preheating strategy provided in an embodiment of the present invention. Detailed Implementation

[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] Existing sentiment classification methods only focus on classification accuracy as an optimization objective, lacking structural constraints on the predicted probability distribution of the model output. This leads to unstable predictions and insufficient generalization ability for boundary and noise samples in multi-class, fine-grained sentiment tasks. Therefore, this invention provides a sentiment classification optimization method based on geometric constraints of the predicted distribution, referencing... Figures 1 to 3 As shown, the specific steps include: Step S101: Obtain the training sample set and extract features.

[0021] Obtain the training sample set for sentiment classification ,in, Indicates the first The feature vector of each sample may be derived from statistical features or bag-of-words features extracted after preprocessing the original text, or from deep semantic features obtained through a pre-trained language model (such as BERT). This represents the sentiment category label corresponding to the sample. The total number of predefined sentiment categories. In this embodiment, a pre-trained BERT model is used to encode the input text, and the 768-dimensional hidden state vector corresponding to the [CLS] marker is extracted as the feature vector of the sample. .

[0022] Step S102: Construct the sentiment prediction distribution space.

[0023] The feature vector of the sample Input parameters are Sentiment classification model In the process, forward reasoning is performed to obtain the corresponding sentiment prediction distribution vector: ; in, Let c be the c-th component of the predicted distribution vector, representing the sample. The predicted probability of sentiment belonging to the c-th sentiment class, satisfying the probability normalization constraint. Therefore, the output of each sample is mapped to a probability simplex in dimension C. One point in the invention. Defined as the sentiment prediction distribution space. The prediction results of all training samples are embedded in this space. Samples of the same type form clustered regions, and the similarity and transitional relationship between different categories are reflected by the geometric relationship between the distribution points.

[0024] Step S103: Construct constraint terms based on the predicted distribution geometry.

[0025] To explicitly optimize the geometric structure of the prediction distribution space, this invention introduces an inter-distribution distance metric based on information geometry theory. For any two samples... and Their corresponding predicted distributions are as follows: and The Bregman divergence is used to characterize the geometric relationship between the two: ; ; in, This indicates that a strictly convex function defined on the probability distribution is used to generate the Bregman divergence, the value of which is determined by the input distribution. The probabilities of each dimension are calculated in functional form; To control the scalar hyperparameter of the strength of higher-order coupling terms, non-negative real numbers are typically chosen to adjust the weights of inter-class interactions. At this point, the aforementioned Bregman divergence degenerates into the standard Kullback-Leibler divergence, thus the method of this invention is a generalized form of it; Indicate category With category The elements of the relationship matrix can be taken as non-negative values ​​based on the normalization result of the confusion matrix or semantic similarity; Describes the probability distribution at the th... The values ​​on the class satisfy And the summation over all categories is .

[0026] in, Normalization is performed using a confusion matrix based on dynamic statistics during training, specifically including: Step A: After each training epoch, or after processing K batches, perform a forward prediction on the training set (or an independent validation subset) using the current model, and obtain the category-level confusion count matrix C, where elements... This represents the number of samples whose true class is a are predicted to be class b.

[0027] Step B: Perform row normalization on matrix C to obtain the normalized confusion matrix. ,in: ; in, This represents the relative frequency of samples of true class a being misclassified as class b, with values ​​between [0,1]. This represents the classification accuracy of category a.

[0028] Step C: Construct the relation matrix M, for ,make: ; This definition makes frequently confused category pairs (such as "fear" and "sadness") more likely to be confused. The value thus enhances its coupling effect in the Bregman divergence; while easily distinguishable category pairs (such as "joy" and "anger") have smaller values. value.

[0029] Step D: In actual training, to avoid drastic fluctuations in the matrix, an exponential moving average (EMA) can be used to adjust the matrix values ​​obtained in each round. Smoothing: ; in, This is a smoothing factor, typically ranging from 0.9 to 0.99.

[0030] Considering the asymmetry of Bregman divergence, and to obtain a more stable geometric constraint form, this invention further employs symmetric information distance: ; In this embodiment, Bregman divergence is preferably used to measure the difference between the predicted distributions. It should be noted that, without departing from the technical concept of this invention, other probability distribution distance metrics can also be used to characterize the geometric relationship between the sample predicted distributions, such as Jensen-Shannon divergence, Wasserstein distance, or other information distance forms based on Kullback-Leibler divergence. These alternative metrics can also be used to construct the geometric constraints between the sample predicted distributions.

[0031] Based on this symmetric distance, construct geometric constraint terms. This is used to constrain the relative relationship of the predicted distributions among samples: ; in, The weighting coefficients for sample pairs are used to characterize the geometric constraint strength under different class relationships. This application no longer assigns uniform weights to dissimilar samples using a fixed constant form, but rather adaptively determines them based on the prediction distribution confusion matrix obtained during training. Specifically, in each round of training or within a preset statistical period, a class-level confusion matrix is ​​first constructed based on the model's prediction results on the training set. , of which elements Indicates the true category is The samples were predicted as class The frequency of the sample size difference is normalized row-wise to eliminate the influence of sample size differences, resulting in a normalized confusion matrix. Its origin Indicate category Misclassified as a category The relative proportions. Based on this, for any sample pair If its true category satisfies Then define This is to ensure that similar samples exhibit a shrinking trend within the predicted distribution space; if The weights are determined based on the values ​​of the corresponding categories in the normalized confusion matrix, which can be specifically expressed as: ; Therefore, when the two categories are highly confused in prediction, If it approaches 1, then As the value approaches zero, the geometric repulsion between out-of-class samples automatically weakens; when the confusion between two classes is low... Approaching 0, then The geometric constraint strength approaches -1, thus maintaining a large structural margin constraint for class pairs with strong discriminative power. This design dynamically aligns the geometric constraint strength with the model's current discriminative ability, causing the predicted distribution of samples of the same class to tend to concentrate in the probabilistic simplex, while the distribution margin strength of samples of different classes is adaptively adjusted according to the actual degree of confusion. This maintains structural discriminative power while avoiding excessive rejection of semantically similar or ambiguous classes, thereby improving the stability and generalization ability of the overall optimization process.

[0032] Step S104: Construct the joint optimization objective function.

[0033] The traditional discriminative sentiment classification objective is modeled in a unified manner with the geometrical constraints of the aforementioned prediction distribution, constructing a joint optimization objective function. Discriminative loss term. To ensure the model's basic classification ability, the discriminant loss term uses a multi-class Hinge loss based on class margin constraints. ; in, The total number of training samples, For the sample The true labels, where c is the total number of emotion categories. and These are the outputs of the sentiment classification model before Softmax normalization. The original discrimination scores of class c and class c; where the original discrimination scores are directly used in the calculation of Hinge loss; Predicted probability distribution The m-th component ;in, This represents the original discrimination score for the k-th class.

[0034] like Figure 2 As shown, the final joint loss function Based on the loss item Geometric constraint terms The L2 regularization term for the model parameters constitutes: ; in, The weighting coefficients for the geometric constraint term are used to adjust the structural consistency strength of the sample prediction distribution in the embedding space. The value range can be set to

[10] . 3

[10] Preferably, the size of the training samples and the feature dimension are adaptively adjusted. When the number of training samples is small or the feature dimension is high, the larger value is selected. This strengthens geometric constraints, thereby improving the model's stability in small sample scenarios. The regularization coefficients for the model parameters are in the range

[10] . 4 [1] is used to suppress excessive fluctuations in model parameters and prevent overfitting.

[0035] Step S105: Model training and parameter optimization.

[0036] After completing the sentiment semantic representation and geometric relationship modeling, the joint loss function is minimized. Parameters of the sentiment classification model Optimization is performed to achieve collaborative learning of semantic discrimination ability and emotional geometric structure constraints. The joint loss function consists of an emotional classification loss term, a geometric consistency constraint term, and a parameter regularization term. The emotional classification loss term characterizes the model's ability to predict emotional categories, the geometric consistency constraint term maintains the structural consistency between the predicted probability distribution and the preset emotional space, and the regularization term suppresses model complexity and improves generalization performance.

[0037] In the specific training process, the input text is encoded into a semantic representation vector using a large language model, and a linear mapping layer is used to obtain the predicted scores for each sentiment category. Then, the Softmax function is used to convert the predicted scores into a probability distribution. A sentiment classification loss term is constructed based on the relationship between this predicted probability distribution and the true labels. Simultaneously, the distance metric between the predicted probability distribution and the preset sentiment geometric space is calculated, thus forming a geometric consistency constraint. Finally, the various loss components are weighted and combined to form the overall optimization objective, and a gradient-based optimization algorithm is used to train the model parameters end-to-end.

[0038] During the parameter update process, an adaptive gradient optimization algorithm (such as Adam or AdamW) can be used to iteratively minimize the joint loss function. The gradient of the loss function with respect to the model parameters is calculated through the backpropagation mechanism, and the model parameters are updated step by step until the loss function converges, thereby obtaining the optimal model parameters that satisfy the constraints of sentiment discrimination ability and geometric consistency.

[0039] To further enhance the stability of model training, especially for lightweight models such as Word2Vec+LSTM and MobileBERT, this embodiment introduces a warmup strategy during training. This strategy divides the training process into two stages: Phase 1 (Warm-up Period): In the first K rounds of training (K=5 in this embodiment), only the discriminant loss term is used. The model parameters are optimized, but geometric constraints are not introduced at this stage. The aim of this stage is to allow the model to establish basic class discrimination capabilities and form a preliminary predicted distribution structure.

[0040] Phase 2 (Constraint Optimization Period): Once the number of training epochs exceeds the threshold K, the full joint loss function is activated. That is, simultaneously optimize the discrimination of loss items. and geometric constraint terms This strategy effectively avoids excessive geometric constraints on the model in the early stages of training due to the fact that the prediction distribution has not yet converged, thus preventing performance degradation and significantly improving the final classification accuracy and F1 score.

[0041] Step S106: Perform sentiment classification using the trained model.

[0042] During the inference phase, the feature vectors of the text samples to be classified are input into the trained sentiment classification model. The model performs conventional forward prediction and outputs its predicted probability distribution in the sentiment category space. The final sentiment category determination can be made based on the maximum probability principle or the discriminant function score. Since the geometric constraints have been internalized as part of the model parameters during the training phase, the model can still output structurally stable and discriminatively consistent predicted distribution results when faced with noisy samples or out-of-distribution samples, and the inference efficiency is completely consistent with the baseline model without the introduction of constraints, without any additional computational overhead.

[0043] We will now use two levels of datasets for validation: SentimentLabelledSentences dataset: Feasibility validation for binary classification tasks.

[0044] The emotion dataset (core validation set) contains a large-scale collection of English Twitter texts, divided into six basic emotion categories: sadness, joy, love, anger, fear, and surprise. This dataset exhibits high inter-category confusion (e.g., fear and sadness appear together, and anger and disgust are easily confused), effectively testing the generalization ability of our method in complex multi-category emotion spaces.

[0045] To verify the generality of the method, multiple sets of comparative models were constructed for the experiment: Traditional deep learning baseline: Word2Vec+LSTM; Pre-trained language model baselines: BERT (Base) and MobileBERT (lightweight); Parameter settings: The optimizer is uniformly AdamW; the number of training epochs is adjusted to 15; the batch size is set to 16. Differential learning rates are set for different models: 1×10⁻⁶ for the Word2Vec model. 3. The BERT model is 2×10 5. The MobileBERT model is 1×10 5.

[0046] Model performance was evaluated using accuracy and F1 score. The experimental results for the small dataset SentimentLabelledSentences are shown in Table 1. Table 1. Experimental results from the SentimentLabelledSentences dataset.

[0047] As shown in Table 1, the classification head with the introduced geometric constraints of the prediction distribution outperforms the traditional Softmax classification head in both accuracy and F1-score, indicating that the proposed method can effectively improve the generalization ability and prediction consistency of the sentiment classification model. However, the experimental results show that the performance improvement of this method for small and medium-sized models such as LSTM and MobileBERT is relatively limited. Further analysis reveals that if the geometric constraints of the prediction distribution are applied directly in the early stages of training, the model's convergence process exhibits significant oscillations, and the classification performance is even lower than the baseline model. This indicates that for lightweight models with a small number of parameters, introducing geometric constraints too early will interfere with the sufficient learning of its discriminative features, leading to training instability and a decline in prediction performance.

[0048] To address the aforementioned issues, this invention introduces a warmup mechanism during training: in the first five rounds of model training, optimization is performed solely based on cross-entropy loss; after the model's discriminative ability is initially established, geometric constraints on the prediction distribution are gradually introduced. To further verify the performance improvement effect of the proposed method on a larger dataset, experiments were conducted on the emotion dataset according to the experimental configuration described above. As shown in Table 2, the experimental results demonstrate that after adopting the warmup strategy, the training process of the two benchmark models, LSTM and MobileBERT, significantly stabilizes, with both classification accuracy and F1 score showing marked improvements, ultimately surpassing the approach of directly applying constraints.

[0049] Table 2 Experimental Results

[0050] In summary, by reasonably controlling the timing of introducing geometric constraints on the prediction distribution, this invention effectively avoids the performance degradation problem caused by excessive constraints in the early training stage of lightweight models, achieves regularization optimization of the prediction distribution structure, and thus improves the overall generalization performance and training stability of the model in the emotion classification task.

[0051] Based on the same inventive concept, embodiments of the present invention also provide a sentiment classification optimization system based on predictive distribution geometric constraints, the system being used to implement the method, the system comprising: The feature extraction module is used to acquire text samples to be classified and extract the feature vectors of the text samples to be classified. The sentiment classification module has a pre-trained sentiment classification model built in, which is used to map the feature vector to a predicted probability distribution on a preset set of sentiment categories. A model training module is used to train the sentiment classification model, and the model training module includes a joint loss construction unit; The joint loss construction unit is used to construct a joint loss function, which includes a discriminant loss term and a geometric constraint term. The discriminant loss term is used to measure the classification accuracy between the predicted probability distribution output by the sentiment classification model and the true label of the sample; The geometric constraint term is constructed based on the geometric distance between the predicted probability distributions of different sample pairs. The geometric constraint term is used to reduce the geometric distance between the predicted probability distributions of two samples with the same true label and increase the geometric distance between the predicted probability distributions of two samples with different true labels during training. The model training module optimizes the parameters of the sentiment classification model by minimizing the joint loss function.

[0052] The technical effect of the system disclosed in this invention is that, through the collaborative work of feature extraction, sentiment classification and model training modules, geometric constraints are internalized into model parameters, and structural optimization of the output distribution of the sentiment classification model is achieved without increasing the inference complexity, thereby effectively improving the robustness and classification reliability of the system in practical applications.

[0053] Based on the same inventive concept, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described thereon.

[0054] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for illustrative purposes only and should be construed as such, and is not intended to be limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in conjunction with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in conjunction with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of the invention as set forth in the appended claims.

Claims

1. A sentiment classification optimization method based on predictive distribution geometric constraints, characterized in that, include: Obtain a text sample to be classified and extract its feature vector; input the feature vector into a pre-trained sentiment classification model, which outputs the predicted probability distribution of the text sample to be classified on a preset sentiment category set; The sentiment classification model is trained by minimizing a joint loss function, which includes a discriminative loss term and a geometric constraint term. The discriminant loss term is used to measure the classification accuracy between the predicted probability distribution output by the sentiment classification model and the true label of the sample; The geometric constraint term is constructed based on the geometric distance between the predicted probability distributions of different sample pairs. The geometric constraint term is used to reduce the geometric distance between the predicted probability distributions of two samples with the same true label and increase the geometric distance between the predicted probability distributions of two samples with different true labels during training. The predicted probability distribution is output as the sentiment classification result.

2. The method according to claim 1, characterized in that, The geometric distance is measured using the Bregman divergence; for any two samples and The predicted probability distributions for the two samples are as follows: and Then the Bregman divergence The calculation formula is: ; ; in, This indicates that a strictly convex function defined on the probability distribution is used to generate the Bregman divergence, the value of which is determined by the input distribution. The probabilities of each dimension are calculated in functional form; Scalar hyperparameters used to control the strength of higher-order coupling terms are typically taken as non-negative real numbers; Indicate category With category The elements of the relationship matrix are specifically defined as: normalized confusion matrix elements obtained from the statistical analysis of the prediction results of the sentiment classification model during training, or cosine similarity sim(c,d) of the pre-trained word vectors of sentiment category labels; The predicted probability distribution is represented at the th... Values ​​that can be taken on a class.

3. The method according to claim 2, characterized in that, The geometric constraint term uses symmetric Bregman divergence as the geometric distance; the symmetric Bregman divergence... The calculation formula is: ; The geometric constraint terms The calculation formula is: ; in, This represents the total number of training samples. This represents the weighting coefficient of the sample pair.

4. The method according to claim 3, characterized in that, The sample pair weighting coefficients According to the sample Authentic Labels and samples Authentic Labels Determined, specifically: when hour, when hour, ; Specifically, a category-level confusion matrix is ​​constructed based on the model's prediction results on the training set. Then normalize to obtain the confusion matrix , for Misclassified as a category The relative proportion.

5. The method according to claim 1, characterized in that, The joint loss function The calculation formula is: ; in, This represents the discriminative loss term. This represents the geometric constraint term. The squared L2 norm of the parameters of the sentiment classification model is represented by... This represents the weighting coefficient of the geometric constraint term, with a value range of 10. 3 Up to 10, This represents the regularization coefficient, with a value range of 10. 4 Up to 1.

6. The method according to claim 5, characterized in that, The discriminant loss term Employing Hinge loss based on class margin constraints for multi-class classification; The calculation formula is as follows: ; in, The total number of training samples, For the sample The true labels, where c is the total number of emotion categories. and These are the outputs of the sentiment classification model before Softmax normalization. The original discrimination scores of class c and class c; where the original discrimination scores are directly used in the calculation of Hinge loss; Predicted probability distribution The c-th component ;in, This represents the original discrimination score for the k-th class.

7. The method according to claim 5, characterized in that, The sentiment classification model is a neural network model, and a warm-up strategy is used during training to introduce the geometric constraint terms in stages; the warm-up strategy includes: In the first training phase, only the discriminant loss term is used. The parameters of the emotion classification model are optimized. After reaching the preset training round threshold, the second training phase begins, using the discriminative loss term. and the geometric constraint terms joint loss function The parameters of the emotion classification model are optimized.

8. The method according to claim 1, characterized in that, Extracting the feature vector of the text sample to be classified specifically includes: The text sample to be classified is encoded using a pre-trained language model, and the hidden state vector corresponding to the CLS tag output by the pre-trained language model is obtained. The hidden state vector is then used as the feature vector. Alternatively, average pooling or max pooling can be performed on the sequence features of the text sample to be classified, and the pooled vector can be used as the feature vector.

9. A sentiment classification optimization system based on predictive distribution geometric constraints, said system being used to implement the method as described in any one of claims 1 to 8, characterized in that, The system includes: The feature extraction module is used to acquire text samples to be classified and extract the feature vectors of the text samples to be classified. The sentiment classification module has a pre-trained sentiment classification model built in, which is used to map the feature vector to a predicted probability distribution on a preset set of sentiment categories. A model training module is used to train the sentiment classification model, and the model training module includes a joint loss construction unit; The joint loss construction unit is used to construct a joint loss function, which includes a discriminant loss term and a geometric constraint term. The discriminant loss term is used to measure the classification accuracy between the predicted probability distribution output by the sentiment classification model and the true label of the sample; The geometric constraint term is constructed based on the geometric distance between the predicted probability distributions of different sample pairs. The geometric constraint term is used to reduce the geometric distance between the predicted probability distributions of two samples with the same true label and increase the geometric distance between the predicted probability distributions of two samples with different true labels during training. The model training module optimizes the parameters of the sentiment classification model by minimizing the joint loss function.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 8.