LLM-based emotion classification method and device, electronic equipment and medium

By integrating multiple large language models and adopting adaptive enhancement algorithms, the problem of low emotional recognition accuracy in the prior art is solved, and higher accuracy of text emotion category classification is achieved.

CN119537595APending Publication Date: 2025-02-28CHINA MOBILE COMM CORP TIANJIN +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411600229.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The prior art has low accuracy in identifying the emotional categories of the speaker, ignoring the interaction and influence between the speakers.

Method used

The accuracy of emotion recognition is improved by integrating multiple large language models into strong classifiers and integrating many weak classifiers using adaptive enhancement algorithms into strong classification ideas.

Benefits of technology

The accuracy of text emotion category classification is improved, and the performance of emotion recognition model is enhanced through the integration and iterative training of multiple LLMs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537595A_ABST
    Figure CN119537595A_ABST
Patent Text Reader

Abstract

The invention provides an LLMs-based emotion classification method and device, electronic equipment and a medium, and relates to the technical field of artificial intelligence. The LLM-based sentiment classification method comprises the following steps: constructing a basic learner of an adaptive enhancement algorithm by using a target LLM set, and initializing initial weight distribution of a training sample; according to the training sample and the initial weight distribution, a basic learning device is finely adjusted to obtain a first weak classifier, and the basic learning device is trained into a second weak classifier according to the error rate and the weight coefficient of the first weak classifier; on the basis of the error rate and the weight coefficient of the second weak classifier, continuously iterating the weight distribution of the training sample, and integrating the weak classifiers into a strong classifier; and based on a to-be-classified text, obtaining a text sentiment category through the strong classifier. Through the technical scheme provided by the invention, the problem of low accuracy when a large model recognizes the emotion category of the text is solved, and the recognition accuracy of the emotion category of the text is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a sentiment classification method, device, electronic device and medium based on LLM. Background Art

[0002] With the rapid development of the Internet and social networks, more and more users rely on instant messaging software such as WeChat, QQ, and DingTalk for daily communication. The Internet records a large number of chat conversations every day. These conversations usually carry a large number of evolving subjective attitudes and emotions of the talkers. Emotion recognition is becoming a new research topic, attracting the attention of academia and industry. Its importance has been recognized by all walks of life in society. For example, it can help product manufacturers improve their products and help the government understand the preferences of the people. Therefore, emotion recognition not only has important theoretical significance, but also contains huge social value. This paper mainly studies the most common chat conversation emotions on social platforms, that is, text conversation emotion recognition technology.

[0003] Conversational emotion recognition aims to detect the emotional attitude of each speaker in the conversation and study the evolution trend of their emotional state throughout the interaction. Current text emotion recognition technology mainly focuses on personal narrative comments or blog posts, and rarely involves modeling of multi-person interactions. Compared with this, conversational emotion recognition is a more challenging task for the following reasons:

[0004] (1) In a chat, each speaker is influenced by other speakers (which is reflected in the text, i.e., contextual influence), so that his or her emotional state may not remain consistent but may change;

[0005] (2) The interactions between the interlocutors conceal a lot of information, such as their cultural background, professional environment, and social relationships;

[0006] (3) During a chat, the speaker’s thinking logic may jump and the content of the conversation may not be coherent.

[0007] At present, a variety of data corpora have emerged in the field of emotion recognition to support the evaluation and verification of emotion recognition models. These corpora are mainly personal movie reviews, product reviews, personal Weibo tweets, etc., and do not yet reflect the emotional interaction between the speakers. The relative lack of high-quality and open-source conversation emotion corpora in academia and industry has become the primary bottleneck for the development of conversation emotion recognition models.

[0008] In the related technology, text sentiment classification is mainly performed through large language models such as the Chat General Language Model (ChatGLM) and the Large Language Model Meta AI (LLaMA). However, this method often treats each speaker in the conversation in isolation, analyzes the sentiment polarity of each sentence separately, ignores the interaction and influence between the speakers, and results in a low accuracy rate of the final recognition result. Summary of the invention

[0009] The present disclosure provides a sentiment classification method, device, electronic device and medium based on LLM to solve the problem of low accuracy of large models in identifying the sentiment category of the speaker. By integrating many weak classifiers of the adaptive enhancement algorithm into strong classifiers, multiple large models are integrated into strong classifiers to improve the accuracy of sentiment recognition.

[0010] The first aspect of the present disclosure proposes a sentiment classification method based on LLM, the method comprising:

[0011] Using the target LLM set to construct a base learner of the adaptive boosting algorithm, and initializing the initial weight distribution of the training samples, wherein the training samples are used to train the base learner, and the target LLM set includes at least three different LLMs;

[0012] According to the training samples and the initial weight distribution, the basic learner is fine-tuned to obtain a first weak classifier, and according to the error rate and weight coefficient of the first weak classifier, the basic learner is trained as a second weak classifier;

[0013] Based on the error rate and weight coefficient of the second weak classifier, the weight distribution of the training samples is continuously iterated, and the first weak classifier and the second weak classifier are integrated into a strong classifier;

[0014] Based on the text to be classified, the text sentiment category is obtained through a strong classifier.

[0015] In one embodiment of the present disclosure, fine-tuning a basic learner to obtain a first weak classifier according to a training sample and an initial weight distribution includes:

[0016] Based on the training set, generating, by a basic learner, a first output text corresponding to each training sample in the training set, wherein the training set includes the training samples;

[0017] According to the label of the training sample and the first output text, the loss value of each training sample in the basic learner is determined by the loss function;

[0018] For each training sample, the loss value is weighted and summed to get the total loss value;

[0019] The basic learner corresponding to the minimum value in the total loss value is used as the first weak classifier.

[0020] In one embodiment of the present disclosure, according to the error rate and weight coefficient of the first weak classifier, the basic learner is trained as a second weak classifier, including:

[0021] Use the error rate to update the weight coefficient to the target weight coefficient;

[0022] Based on the training sample, determining whether the classification result of the first weak classifier is the same as the sample label of the training sample;

[0023] If the classification result is the same as the sample label, the weight distribution of the first weak classifier for the training sample is enlarged according to the target weight coefficient to obtain the first weight distribution; otherwise, the weight distribution of the first weak classifier for the training sample is reduced according to the target weight coefficient to obtain the second weight distribution;

[0024] A second weak classifier is determined according to the first weight distribution, the second weight distribution, and the basic learner.

[0025] In one embodiment of the present disclosure, based on the error rate and weight coefficient of the second weak classifier, the weight distribution of the training samples is continuously iterated, and the first weak classifier and the second weak classifier are integrated into a strong classifier, including:

[0026] Based on the training sample, generating a first prompt word through a first LLM, the first prompt word including a first error rate;

[0027] Based on the first prompt word, generating a second error rate by a second LLM, the second weak classifier including the first LLM and the second LLM;

[0028] Based on each training sample in the training set, the first weak classifier and the second weak classifier are integrated into a strong classifier by continuously iterating the weight distribution of the training sample.

[0029] In one embodiment of the present disclosure, before using the target LLM set to construct a base learner of the adaptive boosting algorithm and initializing the initial weight distribution of the training samples, the method further includes:

[0030] Obtain a text dataset, which includes multiple types of multi-task texts;

[0031] The text dataset is preprocessed and the first proportion of samples are randomly selected as training samples.

[0032] In one embodiment of the present disclosure, before generating the first output text corresponding to each training sample in the training set by the basic learner based on the training set, the method further includes:

[0033] The text of each training sample is used as the input text;

[0034] Based on the input text and the preset sentiment classification description, a prompt template for the basic learner is constructed;

[0035] The prompt template is used as the input text for the base learner as a training sample.

[0036] The second aspect of the present disclosure provides a sentiment classification device based on LLM, the device comprising:

[0037] A construction module is used to construct a basic learner of the adaptive boosting algorithm using a target LLM set and initialize an initial weight distribution of training samples, wherein the training samples are used to train the basic learner and the target LLM set includes at least three different LLMs;

[0038] A fine-tuning module, used for fine-tuning the basic learner to obtain a first weak classifier according to the training sample and the initial weight distribution, and training the basic learner into a second weak classifier according to the error rate and weight coefficient of the first weak classifier;

[0039] An iteration module, used for continuously iterating the weight distribution of training samples based on the error rate and weight coefficient of the second weak classifier, and integrating the first weak classifier and the second weak classifier into a strong classifier;

[0040] The classification module is used to obtain the text sentiment category based on the text to be classified through a strong classifier.

[0041] The third aspect embodiment of the present disclosure proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any one of the methods in the first aspect embodiment of the present disclosure.

[0042] The fourth aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, characterized in that the computer instructions are used to enable a computer to execute the method in the first aspect embodiment of the present disclosure.

[0043] The fifth aspect embodiment of the present disclosure proposes a computer program product, characterized in that it includes a computer program, and when the computer program is executed by a processor, it implements any method in the first aspect embodiment of the present disclosure.

[0044] In summary, the sentiment classification method based on LLM proposed in this disclosure can achieve the following beneficial effects:

[0045] By using multiple different LLMs as the basic learners of the adaptive boosting algorithm, sentiment classification results with high reliability can be obtained;

[0046] By fine-tuning the basic learner as the first weak classifier and training it as the second weak classifier, the first weak classifier and the second weak classifier are integrated into a strong classifier, thereby improving the accuracy of text sentiment category classification.

[0047] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0049] Figure 1 is a flow chart of a sentiment classification method based on LLM according to an embodiment of the present disclosure;

[0050] Figure 2 A flowchart of an embodiment of the present disclosure for fine-tuning a basic learner to obtain a first weak classifier according to training samples and initial weight distribution;

[0051] Figure 3 A flowchart of an embodiment of the present disclosure for training a basic learner into a second weak classifier according to an error rate and a weight coefficient of a first weak classifier;

[0052] Figure 4 A flowchart of an embodiment of the present disclosure that continuously iterates the weight distribution of training samples based on the error rate and weight coefficient of the second weak classifier to integrate the first weak classifier and the second weak classifier into a strong classifier;

[0053] Figure 5 A flowchart of arranging training samples according to an embodiment of the present disclosure;

[0054] Figure 6 A flowchart of constructing a prompt template according to an embodiment of the present disclosure;

[0055] Figure 7 A flowchart of a text sentiment classification method of a large language model inspired by Boosting according to an embodiment of the present disclosure;

[0056] Figure 8 This is a schematic diagram of the comparison results of different models based on the Boosting algorithm;

[0057] Fig. 9 Schematic diagram of experimental comparison results of different models on the SST-2 dataset;

[0058] Fig.10 Schematic diagram of the experimental comparison results of different models on the AG news dataset;

[0059] Fig.11 Schematic diagram of experimental comparison results of different models on the Ohsumed dataset;

[0060] Fig.12 Schematic diagram of the structure of a sentiment classification device based on LLM according to an embodiment of the present disclosure;

[0061] Fig.13 It is a block diagram of an electronic device for implementing the LLM-based sentiment classification method disclosed in the present invention according to an exemplary embodiment. DETAILED DESCRIPTION

[0062] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout identify the same or similar originals or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.

[0063] First, a brief introduction to the relevant terms in this disclosure is given:

[0064] Large Language Model (LLM): In this disclosure, refers to a deep learning-based Natural Language Processing (NLP) model that can understand and generate natural language text, such as Generative Pre-trained Transformer 4 (GPT-4). In this disclosure, LLMs are large language models composed of multiple LLMs.

[0065] Adaptive Boosting (Adaboost): In this disclosure, it refers to an ensemble learning technique that aims to build a strong learner by combining multiple weak learners. The core idea is to repeatedly train different weak classifiers for the same training set, and adjust the weights of samples according to the error rate of each classifier, so that subsequent weak classifiers pay more attention to samples that were previously misclassified.

[0066] Text sentiment classification is an important branch of NLP, which aims to assign predefined categories to given text information, including sentiment analysis classification. In today's information age, text sentiment classification has become a key technology with great practical value and a powerful means to organize and manage data. As LLMs have shown extraordinary effectiveness in many downstream natural language processing tasks, this has brought challenges and uncertainties to future research on text sentiment classification. In the era of large language models, text sentiment classification is usually regarded as a label generation task, in which the model is used to generate correct label-related tags. People pay more attention to complex tasks and sophisticated fields, but text sentiment classification has received little attention. Therefore, how to maximize the advantages of large language models in text sentiment classification has become a research topic that needs to be explored urgently. This paper proposes an adaptive enhancement framework that aims to generate a specialized large language model for text sentiment classification by gradually combining a set of powerful basic learners.

[0067] In recent years, significant progress in the field of NLP has been attributed to the emergence of LLMs. These models have demonstrated outstanding capabilities such as contextual learning, few-shot prompts, following instructions, etc. With the birth of two pioneering models, ChatGPT and GPT-4, OpenAI has achieved important milestones. However, due to their proprietary nature, many large language model variants have emerged, including models with billions or even tens of billions of parameters. These large language models are divided into two groups according to their specialization: general-purpose LLMs (aimed at achieving diversity across a wide range of NLP task domains), and prominent examples of these models are ChatGLM, LLaMA-2, PanGu-Σ, etc. These large language models generally perform well on a variety of tasks, but their potential in specific fields remains to be further explored. Dedicated LLMs, fine-tuned with specific task architectures and knowledge to achieve higher performance. Unlike the above-mentioned techniques, this disclosure pioneered a specialized large language model by iteratively improving and integrating the basic large language model to exert its untapped potential in the task of text sentiment classification.

[0068] Traditional text emotion recognition methods often treat each speaker in the conversation in isolation, analyzing the emotional polarity of each sentence separately, ignoring the interaction and influence between speakers, resulting in low accuracy of the final recognition results. There is a lack of research and industry on the interaction between speakers, and the understanding of the interaction characteristics is not yet clear and unified. Different researchers have different understandings of the attributes and characteristics of the interaction due to different disciplinary perspectives and entry points.

[0069] The present disclosure mainly enhances knowledge and cognition by introducing multi-scenario dialogue data from external text datasets. The text datasets collected from three datasets, ST2, AG_news, and Ohsumed, contain a large amount of two-person and multi-person dialogue data, which not only reflects the logical evolution of people with different roles in the dialogue, but also provides the characteristics of professional knowledge in different scenarios, produces a knowledge accumulation effect, and avoids the problem of traditional text sentiment analysis outputting sentiment analysis results from a single role and a single dialogue process.

[0070] The present disclosure proposes a Boosting-based large language model text sentiment classification analysis method, which is mainly used to solve the above-mentioned shortcomings of the prior art. In order to reflect the role of interaction and influence between talkers, the present disclosure uses the powerful context modeling, dialogue structure analysis, attention mechanism, multi-task learning, and application of sentiment dictionary and domain knowledge of the large language model itself in cognitive enhancement. In terms of knowledge enhancement, an integrated basic learner can be built based on text data collected from ST2, AG news, and Ohsumed to produce a knowledge accumulation effect. Ultimately, in the text sentiment classification model based on the large model, better attention will be paid to the interaction and influence between talkers, thereby improving the accuracy and practicality of sentiment classification.

[0071] The present disclosure is based on the existing text sentiment classification data set, which includes movie reviews, news texts, medical abstracts and other contents. The training strategy of cyclic integration is used to selectively integrate basic learners, and the prediction results and error rates of the previous learner will be incorporated into the input prompts of the next learner. Ultimately, this chain characteristic ensures that each subsequent learner can improve and supplement the existing knowledge and produce a knowledge accumulation effect, thereby constructing a powerful and specialized large language model RGPT. In the end, RGPT will obtain more accurate classification results for different text sentiment classification tasks (news headlines, emotions and medical diseases). The application scenarios are not limited in the embodiments of the present disclosure.

[0072] The LLM-based sentiment classification method provided by the present disclosure is introduced in detail below in conjunction with the accompanying drawings.

[0073] Figure 1 FIG. 1 is a flow chart of a sentiment classification method based on LLM according to an embodiment of the present disclosure. Figure 1 In the embodiment shown, the LLM-based sentiment classification method includes:

[0074] Step 101, using the target LLM set to construct a base learner of the adaptive boosting algorithm, and initialize the initial weight distribution of the training samples, wherein the training samples are used to train the base learner, and the target LLM set includes at least three different LLMs.

[0075] The target LLM set refers to a set consisting of multiple LLMs. Optionally, the target LLM set includes pre-trained language models (PLMs) such as RoBERTa, as well as Alpace, LLaMA-2, ChatGLM-2, etc. The target LLM set includes at least three different LLMs. In this embodiment, there is no limitation on the large models specifically included in the target LLM set. The basic learner (or weak classifier) ​​in the adaptive boosting algorithm refers to a simple model trained in each round of iteration. These basic learners are usually relatively simple and poorly performing models, but by combining multiple basic learners, a powerful comprehensive model, such as a strong classifier, can be constructed.

[0076] In order to obtain a sentiment classification that is better than a single LLM or a simple weighted combination of multiple LLMs, the target LLM set is used to construct the basic learner of the adaptive boosting algorithm, and the weight distribution of the training samples is initialized. Assume that the initial weight distribution That is W (0) Represents the weight distribution of the initial training sample. Each sample will be initialized to the same weight. is the weight distribution vector after initialization with the same weight, that is in Represents a set of i=N, which is initialized to the same weight. A vector of weights that are iteratively updated based on the error rate of the base learner.

[0077] Step 102: fine-tune the basic learner to obtain a first weak classifier according to the training samples and the initial weight distribution, and train the basic learner into a second weak classifier according to the error rate and weight coefficient of the first weak classifier.

[0078] The first weak classifier refers to the learner model obtained by fine-tuning the basic learner using the training samples. The error rate refers to the ratio of the number of misclassified samples to the total number of samples, the weight coefficient refers to the importance of a classifier, and the second weak classifier refers to the learner model obtained by training the basic learner using the error rate and weight coefficient of the first weak classifier.

[0079] Preferably, the present disclosure combines the large language model LLaMA2-7B with the basic learner, using LLaMA2-7B as the initial basic learner. Using the training samples and the initial weight distribution, the basic learner is fine-tuned. That is, the core parameters of the last layer of the large model are fine-tuned. The sentiment classification accuracy of the present disclosure depends on the parameter weights of the classifier model. Use the weight distribution of training samples To fine-tune the initial base learner When fine-tuning the basic learner based on the large model, it is preferred to focus on the adjustment of the model's internal parameters (weights, biases, multi-head self-attention parameters) and the final hyperparameters, which have an important impact on the performance of the model in the text classification task. Fine-tune the basic learner to obtain the first weak classifier. According to the error rate and weight coefficient of the first weak classifier, the training sample is input into the fine-tuned basic learner based on the large model to update the weight distribution of the sample. In other words, the basic learner is trained as the second weak classifier.

[0080] Step 103: Based on the error rate and weight coefficient of the second weak classifier, the weight distribution of the training samples is continuously iterated to integrate the first weak classifier and the second weak classifier into a strong classifier.

[0081] A strong classifier is a more complex and accurate classifier formed by combining multiple weak classifiers. According to the error rate and weight coefficient of the second weak classifier, the weight distribution is continuously iterated using training samples, and the obtained multiple weak classifiers are integrated into a strong classifier.

[0082] Step 104: Based on the text to be classified, a text sentiment category is obtained by a strong classifier.

[0083] The text to be classified refers to the text data that needs to be classified for text sentiment. After obtaining a strong classifier for text sentiment classification, the text to be classified is used as the input text of the strong classifier to obtain the text sentiment category.

[0084] In summary, according to the LLM-based sentiment classification method proposed in the present invention, a sentiment classification result with high reliability can be obtained by using multiple different LLMs as the basic learners of the adaptive enhancement algorithm; by fine-tuning the basic learner as the first weak classifier and training it as the second weak classifier, the weak classifiers are integrated into a strong classifier, thereby improving the accuracy of text sentiment category classification.

[0085] Figure 2 The present invention is a flowchart of an embodiment of fine-tuning a basic learner to obtain a first weak classifier according to training samples and initial weight distribution. Figure 2 Yes Figure 1 Further explanation of step 102 is based on Figure 2 The embodiment shown comprises the following steps:

[0086] Step 201: Based on a training set, a first output text corresponding to each training sample in the training set is generated by a basic learner, and the training set includes the training samples.

[0087] The first output text refers to the output text generated by the basic learner using the training samples. Based on each training sample in the training set, the first output text corresponding to each training sample in the training set is generated by the basic learner.

[0088] Step 202: Determine the loss value of each training sample in the basic learner through a loss function according to the label of the training sample and the first output text.

[0089] According to the label value of the training sample and the first output text, the loss value of the training sample in the basic learner can be obtained using the loss function. The loss value can be expressed as in, represents the i-th input document at the k-th iteration, represents the output value of the learner at the kth iteration, θ (k) represents the built-in iterative acceleration parameter of the learner, is the loss function, and f represents the initial base learner

[0090] Step 203: For each training sample, the loss value is weighted and summed to obtain a total loss value.

[0091] Traverse each training sample in the training set, and perform weighted summation of the loss values ​​corresponding to each training sample to obtain the total loss value. The total loss value can be expressed as Among them, D (k) Represents the document set at the kth iteration, that is, all training samples of the training set.

[0092] Step 204: Use the basic learner corresponding to the minimum value in the total loss value as the first weak classifier.

[0093] The basic learner corresponding to the minimum value in the total loss value is used as the first weak classifier. The first weak classifier can be expressed as:

[0094] In this embodiment, the large model of the basic learner is fine-tuned using training samples to obtain the first weak classifier, making it more suitable for processing sentiment category texts.

[0095] Figure 3 The present invention is a flowchart of an embodiment of the present invention for training a basic learner into a second weak classifier according to an error rate and a weight coefficient of a first weak classifier. Figure 3 Yes Figure 1 Further explanation of step 102 is based on Figure 3 The embodiment shown comprises the following steps:

[0096] Step 301, using the error rate to update the weight coefficient to the target weight coefficient.

[0097] The target weight coefficient is the weight coefficient of the second weak classifier. and the labels of the training samples The number of samples whose product is -1 is calculated by The ratio of misclassified samples to the total number of samples can be obtained, that is, the error rate of the basic learner. The error rate can be used to update the weight coefficient to the target weight coefficient. In the formula, c is usually the inverse of the error rate plus 1, α (k) express The importance of.

[0098] Step 302: Based on the training sample, determine whether the classification result of the first weak classifier is the same as the sample label of the training sample.

[0099] It is determined whether the classification result of the training sample in the first weak classifier is the same as the sample label of the training sample to determine the adjustment of the sample weight of the basic learner.

[0100] Step 303: If the classification result is the same as the sample label, the weight distribution of the first weak classifier for the training sample is enlarged according to the target weight coefficient to obtain the first weight distribution; otherwise, the weight distribution of the first weak classifier for the training sample is reduced according to the target weight coefficient to obtain the second weight distribution.

[0101] The first weight distribution and the second weight distribution are both weight distributions of the second weak classifier for the training sample. The first weight distribution is the adjustment value of the weight distribution of the training sample when the classification result of the first weak classifier is the same as the sample label. The second weight distribution is the adjustment value of the weight distribution of the training sample when the classification result of the first weak classifier is different from the sample label.

[0102] If the classification result is the same as the sample label, then according to the target weight coefficient, the weight distribution of the first weak classifier for the training sample is enlarged to obtain the first weight distribution. On the contrary, if the classification result is different from the sample label, then according to the target weight coefficient, the weight distribution of the first weak classifier for the training sample is reduced to obtain the second weight distribution. The above relationship can be expressed as the following formula:

[0103]

[0104] In the formula, Represents the normalization factor. is the output of the base learner at the kth iteration. (k+1) The weight distribution of the training samples used for the second weak classifier, W (k) The weight distribution of the training samples is used for the first weak classifier.

[0105] Step 304: Determine a second weak classifier according to the first weight distribution, the second weight distribution and the basic learner.

[0106] When the classification result of the first weak classifier is the same as the sample label, there is only the first weight distribution, and the second weak classifier is obtained by using the first weight distribution and the basic learner; when the classification result of the first weak classifier is different from the sample label, the second weak classifier is obtained by using the second weight distribution and the basic learner.

[0107] In this embodiment, the basic learner is trained as the second weak classifier according to the error rate and weight coefficient of the first weak classifier. The historical results generated by the weak classifier are selectively used to obtain two complementary and powerful basic learners. Multiple basic learners are continuously constructed to achieve accurate sentiment classification for massive texts.

[0108] Figure 4 This is a flowchart of an embodiment of the present disclosure for integrating a first weak classifier and a second weak classifier into a strong classifier by continuously iterating the weight distribution of training samples based on the error rate and weight coefficient of the second weak classifier. Figure 4 Yes Figure 1 The specific description of step 103 is based on Figure 4 The embodiment shown comprises the following steps:

[0109] Step 401: Generate a first prompt word through a first LLM based on a training sample, where the first prompt word includes a first error rate.

[0110] The first LLM refers to a large model in the target LLM set. The first error rate refers to the misclassification ratio of the first LLM for all samples in the training set. The first prompt word refers to the prompt text generated by the first LLM, which includes the first error rate. The first prompt word is generated based on the training sample as the input text of the first LLM.

[0111] Step 402: Based on the first prompt word, generate a second error rate through a second LLM, where the second weak classifier includes the first LLM and the second LLM.

[0112] The second LLM refers to a large model in the target LLM set, and the input of the large model is the output of the first LLM. The second error rate refers to the misclassification ratio of the second LLM for all samples in the training set. Based on the first prompt word, the second error rate of the training sample is generated by the second LLM.

[0113] Step 403 , based on each training sample in the training set, by continuously iterating the weight distribution of the training samples, the first weak classifier and the second weak classifier are integrated into a strong classifier.

[0114] Based on each training sample in the training set, the error rate of the current weak classifier is calculated and the input text of the next weak classifier is passed. By continuously iterating the weight distribution of the training samples, the first weak classifier and the second weak classifier are integrated into a strong classifier. In particular, only the first weak classifier and the second weak classifier are used as examples to illustrate the composition of the strong classifier. Usually, the strong classifier includes any number of weak classifiers.

[0115] In this embodiment, by continuously iterating the weight distribution of training samples, weak classifiers are integrated into strong classifiers, thereby obtaining a machine learning model that can accurately classify text into sentiment categories.

[0116] Figure 5 The present invention is a flowchart of organizing training samples according to an embodiment of the present invention. Figure 5 Yes Figure 1 The specific instructions before step 101 are based on Figure 5 The embodiment shown comprises the following steps:

[0117] Step 501: Acquire a text dataset, where the text dataset includes multiple types of multi-task texts.

[0118] In order to train the basic learner, a text dataset is obtained. The text dataset includes various types of multi-task texts, which can ensure stable and accurate classification for different emotion categories and improve the robustness of the classifier.

[0119] In one possible implementation of the present disclosure, an English data set is collected and organized, and the data set includes multi-task text samples of sentiment classification, news headline classification, and medical disease classification, and the sentiment classification samples include positive and negative; the news headline classification includes world, business, sports, and technology; and the medical diseases include 23 categories of diseases such as C01 and C02.

[0120] Step 502: pre-process the text data set and randomly select samples of a first proportion as training samples.

[0121] After obtaining the text data set, preprocessing is performed by removing noise words, unifying text encoding, text vectorization, etc.; and a first proportion of samples are randomly selected from the processed sample data as training samples.

[0122] In one possible implementation of the present disclosure, the text datasets collected from SST2, AG_news, and Ohsumed are preprocessed, such as removing noise data, text cleaning, and text standardization, and finally processed into a text dataset in dictionary form ({Instruction: Text, Input: Text, Output: Text}). Then 70%*140,000 text samples are randomly selected as training sets, and 30%*140,000 samples are used as test sets to test the classification performance of the proposed method. Among them, SST2, AG_news, and Ohsumed correspond to open source datasets for text classification of emotions, news, and medicine.

[0123] In this embodiment, training samples are provided for training the basic learner.

[0124] Figure 6 The present invention is a flowchart of constructing a prompt template according to an embodiment of the present invention. Figure 6 Yes Figure 2 The specific description before step 201 is based on Figure 6 The embodiment shown comprises the following steps:

[0125] Step 601: Take the text of each training sample as the text to be input.

[0126] Before generating the first output text corresponding to each training sample in the training set by the basic learner, the text content of each training sample is used as the to-be-input text.

[0127] Step 602: construct a prompt template for a basic learner based on the text to be input and the preset sentiment classification description.

[0128] Based on the text to be input and the preset sentiment classification description, it is organized into a prompt template for the basic learner.

[0129] In one possible implementation of the present disclosure, the text sentiment classification task is performed following the paradigm of zero-sample prompts. In each iteration, the prompt template Prompt i It consists of two components: preset emotional classification description INS i and the text to be input x i . Prompt i The specification is provided for the text sentiment classification target and the output constraints are declared, such as the prompt template for the sentiment classification task: "Classify the sentiment of the input text and assign an accurate label from ["Positive", "Negative"].". Finally, the single-task prompt template is constructed: Prompt sen 、Prompt news 、Prompt med .

[0130]

[0131] Prompt i is a zero-shot prompt template, i∈{sen,news,med}, representing the sentiment classification task, news headline classification task, and medical disease classification task, respectively.

[0132] Step 603: Use the prompt template as a training sample for the input text of the basic learner.

[0133] By using the prompt template as a training sample for the input text of the basic learner, a unified input text can be obtained to ensure the clarity of the meaning during the classification process.

[0134] In this embodiment, a prompt template of a basic learner is constructed by combining training samples and sentiment classification instructions, which provides specifications for the text sentiment classification target.

[0135] In one embodiment of the present disclosure, 1 million customer service user conversation text data are sampled, and negative customer service user conversation text data are extracted through a binary classification benchmark model. With reference to the industry's open source sentiment word list, the word list is manually checked and divided into corresponding sentiment categories. As shown in Table 1, the distribution table of sample indicators of the training set and the test set shows that the average overall accuracy of the particle swarm optimization model can reach 0.885, which is 3% and 6% higher than the accuracy of the two models that do not use the optimization algorithm. The recall rate of the model for text conversations with a high degree of negative emotions is the highest, reaching 0.95. Through the method provided by the present disclosure, the accuracy of sentiment category classification reaches 88.5%,

[0136] Table 1 Distribution of sample indicators of training set and test set

[0137]

[0138] Figure 7 Flow chart of a method for text sentiment classification based on a large language model inspired by Boosting according to an embodiment of the present disclosure. Figure 7As shown in the figure, a text classification dataset containing emotions, news headlines, and medical diseases is collected, and data preprocessing is performed on the text classification dataset. Multiple large models are selected from many large models to build a basic learner. For emotional text, an emotional classification prompt template is constructed; for news text, a bidding news headline classification prompt template is constructed; for medical text, a medical disease classification prompt template is constructed. Based on the basic learner, the weights of the training samples are initialized. Fine-tune the basic learner to obtain the weak classifier LLM1, and update the weight according to the error rate and weight distribution of LLM1, continuously iterate the Kth weak classifier LLMK, and use a loop to integrate K weak classifiers to obtain RGPT to obtain the text classification result.

[0139] Figure 8 This is a schematic diagram of the comparison of the effects of different models based on the Boosting algorithm. Figure 8 As shown, compared with the base learners constructed by a single large model such as RoBERTa, Alpaca, ChatGLM-2, LLaMA-2, etc., the strong classifiers constructed by the RGPT and base learners disclosed in the present invention can achieve higher accuracy.

[0140] Fig. 9 Schematic diagram of the experimental comparison results of different models on the SST-2 dataset.

[0141] Fig.10 Schematic diagram of the experimental comparison results of different models on the AG news dataset.

[0142] Fig.11 Schematic diagram of the experimental comparison results of different models on the Ohsumed dataset.

[0143] As mentioned above Fig. 9 , Fig.10 and Fig.11 As shown, for the SST-2 dataset, AG news dataset and Ohsumed dataset, the method disclosed in the present invention (Our Method) can achieve higher classification accuracy than RoBERTa, XLNet, DeBERTa, ERNIE, T5-11B, BBTv2, PromptBoosting, CARP and other methods.

[0144] Corresponding to the methods provided in the above-mentioned embodiments, the present disclosure also provides a sentiment classification device based on LLM. Since the device provided in the embodiments of the present disclosure corresponds to the methods provided in the above-mentioned embodiments, the implementation method of the method is also applicable to the device provided in this embodiment and will not be described in detail in this embodiment.

[0145] Fig.12 FIG. 1 is a schematic diagram of the structure of an LLM-based sentiment classification device 1200 according to an embodiment of the present disclosure. Fig.12 As shown, the LLM-based sentiment classification device includes:

[0146] A construction module 1210 is used to construct a basic learner of the adaptive boosting algorithm using a target LLM set, and initialize an initial weight distribution of training samples, wherein the training samples are used to train the basic learner, and the target LLM set includes at least three different LLMs;

[0147] A fine-tuning module 1220 is used to fine-tune the basic learner to obtain a first weak classifier according to the training sample and the initial weight distribution, and train the basic learner into a second weak classifier according to the error rate and weight coefficient of the first weak classifier;

[0148] An iteration module 1230, configured to continuously iterate the weight distribution of the training samples based on the error rate and weight coefficient of the second weak classifier, and integrate the first weak classifier and the second weak classifier into a strong classifier;

[0149] The classification module 1240 is used to obtain a text sentiment category based on the text to be classified through a strong classifier.

[0150] In some embodiments, the fine-tuning module 1220 fine-tunes the basic learner to obtain the first weak classifier according to the training samples and the initial weight distribution in the following manner:

[0151] Based on the training set, generating, by a basic learner, a first output text corresponding to each training sample in the training set, wherein the training set includes the training samples;

[0152] According to the label of the training sample and the first output text, the loss value of each training sample in the basic learner is determined by the loss function;

[0153] For each training sample, the loss value is weighted and summed to get the total loss value;

[0154] The basic learner corresponding to the minimum value in the total loss value is used as the first weak classifier.

[0155] In some embodiments, the fine-tuning module 1220 trains the basic learner into the second weak classifier according to the error rate and weight coefficient of the first weak classifier in the following manner:

[0156] Use the error rate to update the weight coefficient to the target weight coefficient;

[0157] Based on the training sample, determining whether the classification result of the first weak classifier is the same as the sample label of the training sample;

[0158] If the classification result is the same as the sample label, the weight distribution of the first weak classifier for the training sample is enlarged according to the target weight coefficient to obtain the first weight distribution; otherwise, the weight distribution of the first weak classifier for the training sample is reduced according to the target weight coefficient to obtain the second weight distribution;

[0159] A second weak classifier is determined according to the first weight distribution, the second weight distribution, and the basic learner.

[0160] In some embodiments, the iteration module 1230 is used to:

[0161] Based on the training sample, generating a first prompt word through a first LLM, the first prompt word including a first error rate;

[0162] Based on the first prompt word, generating a second error rate by a second LLM, the second weak classifier including the first LLM and the second LLM;

[0163] Based on each training sample in the training set, the first weak classifier and the second weak classifier are integrated into a strong classifier by continuously iterating the weight distribution of the training sample.

[0164] In some embodiments, before using the target LLM set to construct the base learner of the adaptive boosting algorithm and initializing the initial weight distribution of the training samples, the construction module 1210 is further configured to:

[0165] Obtain a text dataset, which includes multiple types of multi-task texts;

[0166] The text dataset is preprocessed and the first proportion of samples are randomly selected as training samples.

[0167] In some embodiments, before the fine-tuning module 1220 generates the first output text corresponding to each training sample in the training set through the basic learner based on the training set, it is further configured to:

[0168] The text of each training sample is used as the input text;

[0169] Based on the input text and the preset sentiment classification description, a prompt template for the basic learner is constructed;

[0170] The prompt template is used as the input text for the base learner as a training sample.

[0171] In summary, through the LLM-based sentiment classification device, the target LLM set is used to construct the basic learner of the adaptive enhancement algorithm, and the initial weight distribution of the training samples is initialized, wherein the training samples are used to train the basic learner, and the target LLM set includes at least three different LLMs;

[0172] According to the training samples and the initial weight distribution, the basic learner is fine-tuned to obtain the first weak classifier, and according to the error rate and weight coefficient of the first weak classifier, the basic learner is trained as the second weak classifier; based on the error rate and weight coefficient of the second weak classifier, the weight distribution of the training samples is continuously iterated to integrate the weak classifiers into a strong classifier; based on the text to be classified, the text sentiment category is obtained through the strong classifier. This device solves the problem of low accuracy of large models in identifying the sentiment category of text, and improves the recognition accuracy of text sentiment category.

[0173] In the above embodiments provided by the present disclosure, the methods and devices provided by the embodiments of the present disclosure are introduced. In order to implement the functions in the methods provided by the above embodiments of the present disclosure, the electronic device may include a hardware structure and a software module, and implement the above functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. One of the above functions may be executed in the form of a hardware structure, a software module, or a hardware structure plus a software module.

[0174] Fig.13 is a block diagram of an electronic device 1300 for implementing the above-mentioned LLM-based sentiment classification method according to an exemplary embodiment.

[0175] For example, the electronic device 1300 may be a mobile phone, a computer, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0176] Reference Fig.13 , the electronic device 1300 may include one or more of the following components: a processing component 1302 , a memory 1304 , a power component 1306 , a multimedia component 1308 , an audio component 1310 , an input / output (I / O) interface 1312 , a sensor component 1314 , and a communication component 1316 .

[0177] The processing component 1302 generally controls the overall operation of the electronic device 1300, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1302 may include one or more processors 1320 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 1302 may include one or more modules to facilitate the interaction between the processing component 1302 and other components. For example, the processing component 1302 may include a multimedia module to facilitate the interaction between the multimedia component 1308 and the processing component 1302.

[0178] The memory 1304 is configured to store various types of data to support operations on the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 1300, contact data, phone book data, messages, pictures, videos, etc. The memory 1304 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0179] The power supply component 1306 provides power to the various components of the electronic device 1300. The power supply component 1306 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 1300.

[0180] The multimedia component 1308 includes a screen that provides an output interface between the electronic device 1300 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1308 includes a front camera and / or a rear camera. When the electronic device 1300 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0181] The audio component 1310 is configured to output and / or input audio signals. For example, the audio component 1310 includes a microphone (MIC), and when the electronic device 1300 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1304 or sent via the communication component 1316. In some embodiments, the audio component 1310 also includes a speaker for outputting audio signals.

[0182] I / O interface 1312 provides an interface between processing component 1302 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0183] The sensor assembly 1314 includes one or more sensors for providing various aspects of status assessment for the electronic device 1300. For example, the sensor assembly 1314 can detect the open / closed state of the electronic device 1300, the relative positioning of components, such as the display and keypad of the electronic device 1300, and the sensor assembly 1314 can also detect the position change of the electronic device 1300 or a component of the electronic device 1300, the presence or absence of user contact with the electronic device 1300, the orientation or acceleration / deceleration of the electronic device 1300, and the temperature change of the electronic device 1300. The sensor assembly 1314 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 1314 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1314 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0184] The communication component 1316 is configured to facilitate wired or wireless communication between the electronic device 1300 and other devices. The electronic device 1300 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, 4G LTE, 5G NR (NewRadio) or a combination thereof. In an exemplary embodiment, the communication component 1316 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1316 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0185] In an exemplary embodiment, the electronic device 1300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above methods.

[0186] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1304 including instructions, and the instructions can be executed by a processor 1320 of the electronic device 1300 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0187] The embodiments of the present disclosure further provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the LLM-based sentiment classification method described in the above embodiments of the present disclosure.

[0188] An embodiment of the present disclosure further provides a computer program product, including a computer program, which, when executed by a processor, implements the LLM-based sentiment classification method described in the above embodiment of the present disclosure.

[0189] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0190] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0191] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present disclosure includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present disclosure belong.

[0192] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processing module, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (control method), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary, and then stored in a computer memory.

[0193] It should be understood that the various parts of the embodiments of the present disclosure can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0194] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0195] In addition, each functional unit in each embodiment of the present disclosure may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium. The above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0196] Although the embodiments of the present disclosure have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present disclosure. A person skilled in the art may make changes, modifications, substitutions and variations to the above embodiments within the scope of the present disclosure.

Claims

1. A sentiment classification method based on LLM, characterized in that: The method comprises: Using the target LLM set to construct a base learner of the adaptive boosting algorithm, and initializing the initial weight distribution of the training samples, wherein the training samples are used to train the base learner, and the target LLM set includes at least three different LLMs; According to the training sample and the initial weight distribution, fine-tuning the basic learner to obtain a first weak classifier, and according to the error rate and weight coefficient of the first weak classifier, training the basic learner into a second weak classifier; Based on the error rate and weight coefficient of the second weak classifier, continuously iterate the weight distribution of the training samples, and integrate the first weak classifier and the second weak classifier into a strong classifier; Based on the text to be classified, the text sentiment category is obtained by the strong classifier.

2. The method according to claim 1, characterized in that The step of fine-tuning the basic learner to obtain a first weak classifier according to the training sample and the initial weight distribution includes: Based on a training set, generating, by the basic learner, a first output text corresponding to each training sample in the training set, wherein the training set includes the training sample; Determining the loss value of each training sample in the basic learner through a loss function according to the label of the training sample and the first output text; For each training sample, performing weighted summation on the loss values ​​to obtain a total loss value; The basic learner corresponding to the minimum value in the total loss value is used as the first weak classifier.

3. The method according to claim 1, characterized in that The step of training the basic learner into a second weak classifier according to the error rate and weight coefficient of the first weak classifier comprises: Using the error rate to update the weight coefficient to the target weight coefficient; Based on the training sample, determining whether the classification result of the first weak classifier is the same as the sample label of the training sample; If the classification result is the same as the sample label, the weight distribution of the first weak classifier for the training sample is amplified according to the target weight coefficient to obtain a first weight distribution; otherwise, the weight distribution of the first weak classifier for the training sample is reduced according to the target weight coefficient to obtain a second weight distribution; The second weak classifier is determined according to the first weight distribution, the second weight distribution, and the basic learner.

4. The method according to claim 1, characterized in that: The step of continuously iterating the weight distribution of the training samples based on the error rate and weight coefficient of the second weak classifier to integrate the weak classifier into a strong classifier includes: Based on the training sample, generating a first prompt word through a first LLM, wherein the first prompt word includes a first error rate; Based on the first prompt word, generating a second error rate through a second LLM, wherein the second weak classifier includes the first LLM and the second LLM; Based on each training sample in the training set, the first weak classifier and the second weak classifier are integrated into the strong classifier by continuously iterating the weight distribution of the training samples.

5. The method according to claim 1, characterized in that Before using the target LLM set to construct the base learner of the adaptive boosting algorithm and initializing the initial weight distribution of the training samples, it also includes: Acquire a text dataset, wherein the text dataset includes multiple types of multi-task texts; The text data set is preprocessed, and samples of a first proportion are randomly selected as training samples.

6. The method according to claim 2, characterized in that Before generating the first output text corresponding to each training sample in the training set by the basic learner based on the training set, the method further includes: Taking the text of each training sample as the text to be input; Based on the text to be input and the preset sentiment classification description, construct a prompt template for the basic learner; The prompt template is used as the input text of the training sample for the basic learner.

7. A sentiment classification device based on LLM, characterized in that: The device comprises: A construction module, used to construct a basic learner of the adaptive boosting algorithm using a target LLM set, and initialize an initial weight distribution of training samples, wherein the training samples are used to train the basic learner, and the target LLM set includes at least three different LLMs; A fine-tuning module, configured to fine-tune the basic learner to obtain a first weak classifier according to the training sample and the initial weight distribution, and train the basic learner into a second weak classifier according to the error rate and weight coefficient of the first weak classifier; An iteration module, configured to continuously iterate the weight distribution of the training samples based on the error rate and weight coefficient of the second weak classifier, and integrate the first weak classifier and the second weak classifier into a strong classifier; The classification module obtains the text sentiment category based on the text to be classified through the strong classifier.

8. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.

10. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 6.

Citation Information

Cited By

  • A web page parsing method and system based on artificial intelligence

    CN119760650A